From eaae0bb5e71b237cc1fe1388ab74e6bd3aa0c69e Mon Sep 17 00:00:00 2001 From: Rubidium Date: Mon, 8 May 2023 19:01:06 +0200 Subject: [PATCH] Codechange: automatic adding of _t to (u)int types, and WChar to char32_t for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done --- src/3rdparty/md5/md5.cpp | 48 +- src/3rdparty/md5/md5.h | 8 +- src/3rdparty/squirrel/include/squirrel.h | 2 +- src/3rdparty/squirrel/squirrel/sqapi.cpp | 6 +- src/3rdparty/squirrel/squirrel/sqlexer.cpp | 6 +- src/3rdparty/squirrel/squirrel/sqlexer.h | 6 +- src/aircraft.h | 8 +- src/aircraft_cmd.cpp | 24 +- src/airport.cpp | 8 +- src/airport.h | 10 +- src/articulated_vehicles.cpp | 6 +- src/autoreplace_base.h | 2 +- src/autoreplace_cmd.cpp | 2 +- src/autoreplace_gui.cpp | 2 +- src/base_consist.h | 8 +- src/base_media_base.h | 4 +- src/base_media_func.h | 2 +- src/base_station_base.h | 16 +- src/blitter/32bpp_anim.cpp | 86 +-- src/blitter/32bpp_anim.hpp | 12 +- src/blitter/32bpp_anim_sse2.cpp | 6 +- src/blitter/32bpp_anim_sse4.cpp | 44 +- src/blitter/32bpp_base.cpp | 54 +- src/blitter/32bpp_base.hpp | 20 +- src/blitter/32bpp_optimized.cpp | 46 +- src/blitter/32bpp_optimized.hpp | 2 +- src/blitter/32bpp_simple.cpp | 4 +- src/blitter/32bpp_simple.hpp | 12 +- src/blitter/32bpp_sse2.cpp | 12 +- src/blitter/32bpp_sse2.hpp | 12 +- src/blitter/32bpp_sse_func.hpp | 32 +- src/blitter/32bpp_sse_type.h | 10 +- src/blitter/40bpp_anim.cpp | 98 ++-- src/blitter/40bpp_anim.hpp | 8 +- src/blitter/8bpp_base.cpp | 50 +- src/blitter/8bpp_base.hpp | 8 +- src/blitter/8bpp_optimized.cpp | 12 +- src/blitter/8bpp_optimized.hpp | 2 +- src/blitter/8bpp_simple.cpp | 8 +- src/blitter/base.hpp | 8 +- src/blitter/common.hpp | 12 +- src/blitter/null.hpp | 8 +- src/bmp.cpp | 10 +- src/bmp.h | 12 +- src/bridge.h | 6 +- src/bridge_gui.cpp | 8 +- src/build_vehicle_gui.cpp | 18 +- src/cargo_type.h | 4 +- src/cargomonitor.cpp | 12 +- src/cargomonitor.h | 12 +- src/cargopacket.cpp | 6 +- src/cargopacket.h | 22 +- src/cargotype.cpp | 6 +- src/cargotype.h | 26 +- src/cheat_gui.cpp | 26 +- src/clear_cmd.cpp | 2 +- src/command.cpp | 4 +- src/command_type.h | 14 +- src/company_base.h | 38 +- src/company_cmd.cpp | 26 +- src/company_cmd.h | 2 +- src/company_gui.cpp | 26 +- src/company_manager_face.h | 4 +- src/company_type.h | 8 +- src/console.cpp | 2 +- src/console_cmds.cpp | 32 +- src/console_gui.cpp | 4 +- src/console_internal.h | 2 +- src/core/bitmath_func.cpp | 10 +- src/core/bitmath_func.hpp | 38 +- src/core/endian_func.hpp | 8 +- src/core/geometry_type.hpp | 8 +- src/core/math_func.cpp | 6 +- src/core/math_func.hpp | 2 +- src/core/overflowsafe_type.hpp | 34 +- src/core/pool_type.hpp | 2 +- src/core/random_func.cpp | 20 +- src/core/random_func.hpp | 28 +- src/cpu.cpp | 20 +- src/cpu.h | 2 +- src/currency.cpp | 4 +- src/currency.h | 6 +- src/date_gui.cpp | 2 +- src/date_type.h | 4 +- src/debug.h | 10 +- src/depot_base.h | 2 +- src/depot_gui.cpp | 6 +- src/depot_type.h | 2 +- src/disaster_vehicle.cpp | 14 +- src/economy.cpp | 32 +- src/economy_func.h | 4 +- src/economy_type.h | 24 +- src/effectvehicle.cpp | 12 +- src/effectvehicle_base.h | 2 +- src/elrail.cpp | 6 +- src/elrail_func.h | 2 +- src/engine.cpp | 28 +- src/engine_base.h | 38 +- src/engine_func.h | 6 +- src/engine_gui.cpp | 4 +- src/engine_gui.h | 2 +- src/engine_type.h | 46 +- src/error.h | 10 +- src/error_gui.cpp | 12 +- src/fios.cpp | 4 +- src/fios.h | 4 +- src/fios_gui.cpp | 2 +- src/fontcache.h | 14 +- src/fontcache/freetypefontcache.cpp | 8 +- src/fontcache/spritefontcache.cpp | 4 +- src/fontcache/spritefontcache.h | 8 +- src/fontcache/truetypefontcache.cpp | 2 +- src/fontcache/truetypefontcache.h | 6 +- src/framerate_gui.cpp | 18 +- src/framerate_type.h | 2 +- src/game/game_gui.cpp | 2 +- src/game/game_text.hpp | 4 +- src/gamelog.cpp | 16 +- src/gamelog.h | 18 +- src/genworld.h | 4 +- src/genworld_gui.cpp | 8 +- src/gfx.cpp | 34 +- src/gfx_func.h | 58 +- src/gfx_layout.cpp | 8 +- src/gfx_layout.h | 2 +- src/gfx_layout_fallback.cpp | 28 +- src/gfx_layout_fallback.h | 6 +- src/gfx_layout_icu.cpp | 8 +- src/gfx_layout_icu.h | 2 +- src/gfx_type.h | 18 +- src/gfxinit.cpp | 2 +- src/goal.cpp | 8 +- src/goal_cmd.h | 4 +- src/goal_gui.cpp | 4 +- src/goal_type.h | 6 +- src/graph_gui.cpp | 30 +- src/ground_vehicle.cpp | 34 +- src/ground_vehicle.hpp | 48 +- src/group.h | 10 +- src/group_cmd.cpp | 4 +- src/group_cmd.h | 2 +- src/group_gui.cpp | 4 +- src/group_type.h | 2 +- src/gui.h | 4 +- src/heightmap.cpp | 2 +- src/highscore.cpp | 2 +- src/highscore.h | 2 +- src/highscore_gui.cpp | 10 +- src/hotkeys.cpp | 26 +- src/hotkeys.h | 14 +- src/house.h | 4 +- src/house_type.h | 4 +- src/industry.h | 20 +- src/industry_cmd.cpp | 94 ++-- src/industry_cmd.h | 4 +- src/industry_gui.cpp | 18 +- src/industry_map.h | 2 +- src/industry_type.h | 6 +- src/industrytype.h | 22 +- src/landscape.cpp | 22 +- src/language.h | 32 +- src/league_base.h | 2 +- src/league_cmd.cpp | 4 +- src/league_cmd.h | 4 +- src/league_type.h | 6 +- src/linkgraph/demands.cpp | 8 +- src/linkgraph/demands.h | 6 +- src/linkgraph/linkgraph.cpp | 16 +- src/linkgraph/linkgraph.h | 10 +- src/linkgraph/linkgraph_gui.cpp | 40 +- src/linkgraph/linkgraph_gui.h | 6 +- src/linkgraph/linkgraph_type.h | 6 +- src/linkgraph/linkgraphjob.cpp | 2 +- src/linkgraph/mcf.cpp | 8 +- src/linkgraph/refresh.cpp | 8 +- src/linkgraph/refresh.h | 10 +- src/main_gui.cpp | 2 +- src/map.cpp | 6 +- src/map_func.h | 16 +- src/map_type.h | 6 +- src/misc/countedobj.cpp | 6 +- src/misc/countedptr.hpp | 6 +- src/misc/getoptdata.h | 2 +- src/misc/hashtable.hpp | 2 +- src/misc_gui.cpp | 8 +- src/mixer.cpp | 68 +-- src/mixer.h | 8 +- src/music.cpp | 4 +- src/music/dmusic.cpp | 4 +- src/music/fluidsynth.cpp | 4 +- src/music/midi.h | 6 +- src/music/midifile.cpp | 70 +-- src/music/midifile.hpp | 14 +- src/music/win32_m.cpp | 2 +- src/network/core/address.cpp | 24 +- src/network/core/address.h | 8 +- src/network/core/config.h | 24 +- src/network/core/game_info.cpp | 4 +- src/network/core/game_info.h | 6 +- src/network/core/packet.cpp | 62 +-- src/network/core/packet.h | 20 +- src/network/core/tcp.h | 4 +- src/network/core/tcp_admin.h | 150 ++--- src/network/core/tcp_connect.cpp | 4 +- src/network/core/tcp_content.h | 42 +- src/network/core/tcp_content_type.h | 4 +- src/network/core/tcp_coordinator.h | 52 +- src/network/core/tcp_game.h | 112 ++-- src/network/core/tcp_listen.h | 2 +- src/network/core/tcp_stun.h | 4 +- src/network/core/tcp_turn.h | 2 +- src/network/network.cpp | 38 +- src/network/network_admin.cpp | 22 +- src/network/network_admin.h | 8 +- src/network/network_chat_gui.cpp | 6 +- src/network/network_client.cpp | 22 +- src/network/network_client.h | 2 +- src/network/network_command.cpp | 2 +- src/network/network_content.cpp | 14 +- src/network/network_content.h | 2 +- src/network/network_content_gui.cpp | 4 +- src/network/network_content_gui.h | 2 +- src/network/network_coordinator.cpp | 34 +- src/network/network_coordinator.h | 8 +- src/network/network_func.h | 8 +- src/network/network_gui.cpp | 14 +- src/network/network_gui.h | 2 +- src/network/network_internal.h | 34 +- src/network/network_server.cpp | 18 +- src/network/network_server.h | 6 +- src/network/network_stun.cpp | 8 +- src/network/network_stun.h | 6 +- src/network/network_survey.cpp | 2 +- src/network/network_turn.cpp | 2 +- src/network/network_turn.h | 6 +- src/network/network_type.h | 14 +- src/network/network_udp.cpp | 2 +- src/newgrf.cpp | 574 ++++++++++---------- src/newgrf.h | 26 +- src/newgrf_airport.cpp | 28 +- src/newgrf_airport.h | 4 +- src/newgrf_airporttiles.cpp | 20 +- src/newgrf_airporttiles.h | 12 +- src/newgrf_animation_base.h | 16 +- src/newgrf_animation_type.h | 14 +- src/newgrf_canal.cpp | 22 +- src/newgrf_canal.h | 4 +- src/newgrf_cargo.cpp | 12 +- src/newgrf_cargo.h | 4 +- src/newgrf_class.h | 6 +- src/newgrf_class_func.h | 8 +- src/newgrf_commons.cpp | 74 +-- src/newgrf_commons.h | 96 ++-- src/newgrf_config.cpp | 14 +- src/newgrf_config.h | 36 +- src/newgrf_debug.h | 2 +- src/newgrf_debug_gui.cpp | 38 +- src/newgrf_engine.cpp | 54 +- src/newgrf_engine.h | 16 +- src/newgrf_generic.cpp | 40 +- src/newgrf_generic.h | 4 +- src/newgrf_gui.cpp | 20 +- src/newgrf_house.cpp | 60 +- src/newgrf_house.h | 26 +- src/newgrf_industries.cpp | 56 +- src/newgrf_industries.h | 30 +- src/newgrf_industrytiles.cpp | 38 +- src/newgrf_industrytiles.h | 16 +- src/newgrf_object.cpp | 32 +- src/newgrf_object.h | 40 +- src/newgrf_profiling.cpp | 16 +- src/newgrf_profiling.h | 20 +- src/newgrf_railtype.cpp | 18 +- src/newgrf_railtype.h | 12 +- src/newgrf_roadstop.cpp | 34 +- src/newgrf_roadstop.h | 26 +- src/newgrf_roadtype.cpp | 14 +- src/newgrf_roadtype.h | 12 +- src/newgrf_sound.cpp | 12 +- src/newgrf_spritegroup.cpp | 42 +- src/newgrf_spritegroup.h | 72 +-- src/newgrf_station.cpp | 78 +-- src/newgrf_station.h | 18 +- src/newgrf_storage.h | 18 +- src/newgrf_text.cpp | 64 +-- src/newgrf_text.h | 18 +- src/newgrf_town.cpp | 8 +- src/newgrf_town.h | 4 +- src/newgrf_townname.cpp | 24 +- src/newgrf_townname.h | 16 +- src/news_cmd.h | 2 +- src/news_func.h | 2 +- src/news_gui.cpp | 16 +- src/news_type.h | 8 +- src/object.h | 2 +- src/object_base.h | 4 +- src/object_cmd.cpp | 18 +- src/object_cmd.h | 4 +- src/object_gui.cpp | 4 +- src/object_type.h | 4 +- src/openttd.cpp | 6 +- src/order_backup.cpp | 12 +- src/order_backup.h | 14 +- src/order_base.h | 36 +- src/order_cmd.cpp | 18 +- src/order_cmd.h | 2 +- src/order_func.h | 2 +- src/order_type.h | 6 +- src/os/macosx/font_osx.cpp | 8 +- src/os/macosx/font_osx.h | 4 +- src/os/macosx/macos.h | 2 +- src/os/macosx/macos.mm | 2 +- src/os/macosx/string_osx.cpp | 8 +- src/os/macosx/string_osx.h | 2 +- src/os/windows/crashlog_win.cpp | 26 +- src/os/windows/font_win32.cpp | 4 +- src/os/windows/font_win32.h | 4 +- src/os/windows/string_uniscribe.cpp | 12 +- src/os/windows/string_uniscribe.h | 2 +- src/os/windows/win32.cpp | 6 +- src/osk_gui.cpp | 6 +- src/pathfinder/follow_track.hpp | 4 +- src/pathfinder/npf/aystar.h | 6 +- src/pathfinder/npf/npf.cpp | 22 +- src/pathfinder/yapf/yapf_node_rail.hpp | 8 +- src/querystring_gui.h | 2 +- src/rail.h | 12 +- src/rail_cmd.cpp | 10 +- src/rail_cmd.h | 2 +- src/rail_gui.cpp | 4 +- src/rail_gui.h | 6 +- src/rail_type.h | 6 +- src/random_access_file.cpp | 4 +- src/random_access_file_type.h | 4 +- src/rev.cpp.in | 2 +- src/rev.h | 2 +- src/road.h | 8 +- src/road_cmd.cpp | 2 +- src/road_cmd.h | 2 +- src/road_func.h | 2 +- src/road_gui.cpp | 6 +- src/road_type.h | 6 +- src/roadveh.h | 24 +- src/roadveh_cmd.cpp | 34 +- src/saveload/afterload.cpp | 12 +- src/saveload/cargomonitor_sl.cpp | 6 +- src/saveload/company_sl.cpp | 6 +- src/saveload/economy_sl.cpp | 2 +- src/saveload/engine_sl.cpp | 2 +- src/saveload/game_sl.cpp | 6 +- src/saveload/labelmaps_sl.cpp | 2 +- src/saveload/linkgraph_sl.cpp | 6 +- src/saveload/map_sl.cpp | 16 +- src/saveload/misc_sl.cpp | 2 +- src/saveload/newgrf_sl.h | 2 +- src/saveload/oldloader.cpp | 32 +- src/saveload/oldloader.h | 8 +- src/saveload/oldloader_sl.cpp | 40 +- src/saveload/order_sl.cpp | 16 +- src/saveload/saveload.cpp | 212 ++++---- src/saveload/saveload.h | 20 +- src/saveload/saveload_internal.h | 10 +- src/saveload/settings_sl.cpp | 2 +- src/saveload/station_sl.cpp | 30 +- src/saveload/story_sl.cpp | 4 +- src/saveload/strings_sl.cpp | 2 +- src/saveload/town_sl.cpp | 16 +- src/saveload/vehicle_sl.cpp | 12 +- src/saveload/waypoint_sl.cpp | 8 +- src/screenshot.cpp | 54 +- src/screenshot.h | 4 +- src/script/api/script_airport.cpp | 2 +- src/script/api/script_base.hpp | 16 +- src/script/api/script_bridge.hpp | 2 +- src/script/api/script_cargo.cpp | 4 +- src/script/api/script_cargo.hpp | 4 +- src/script/api/script_client.hpp | 2 +- src/script/api/script_company.cpp | 6 +- src/script/api/script_company.hpp | 2 +- src/script/api/script_event_types.cpp | 8 +- src/script/api/script_event_types.hpp | 22 +- src/script/api/script_gamesettings.hpp | 2 +- src/script/api/script_goal.cpp | 4 +- src/script/api/script_goal.hpp | 10 +- src/script/api/script_group.cpp | 4 +- src/script/api/script_industrytype.cpp | 6 +- src/script/api/script_info_docs.hpp | 14 +- src/script/api/script_infrastructure.cpp | 8 +- src/script/api/script_news.cpp | 2 +- src/script/api/script_rail.cpp | 2 +- src/script/api/script_road.cpp | 20 +- src/script/api/script_road.hpp | 2 +- src/script/api/script_station.cpp | 2 +- src/script/api/script_story_page.cpp | 6 +- src/script/api/script_story_page.hpp | 2 +- src/script/api/script_storypagelist.cpp | 2 +- src/script/api/script_text.cpp | 4 +- src/script/api/script_town.cpp | 10 +- src/script/api/script_town.hpp | 4 +- src/script/api/script_types.hpp | 26 +- src/script/api/script_vehicle.cpp | 4 +- src/script/api/script_window.hpp.in | 8 +- src/script/script_gui.cpp | 2 +- src/script/script_instance.cpp | 6 +- src/script/script_scanner.cpp | 4 +- src/script/squirrel.cpp | 14 +- src/script/squirrel_helper.hpp | 32 +- src/script/squirrel_helper_type.hpp | 2 +- src/settings.cpp | 74 +-- src/settings_cmd.h | 4 +- src/settings_func.h | 2 +- src/settings_gui.cpp | 30 +- src/settings_internal.h | 40 +- src/settings_table.cpp | 60 +- src/settings_table.h | 2 +- src/settings_type.h | 356 ++++++------ src/ship.h | 4 +- src/ship_cmd.cpp | 12 +- src/signs_base.h | 6 +- src/signs_gui.cpp | 2 +- src/signs_type.h | 2 +- src/slope_type.h | 2 +- src/smallmap_gui.cpp | 42 +- src/smallmap_gui.h | 14 +- src/sortlist_type.h | 14 +- src/sound.cpp | 8 +- src/sound/allegro_s.cpp | 2 +- src/sound_type.h | 12 +- src/sprite.cpp | 12 +- src/sprite.h | 20 +- src/spritecache.cpp | 26 +- src/spritecache.h | 14 +- src/spriteloader/grf.cpp | 20 +- src/spriteloader/grf.hpp | 2 +- src/spriteloader/spriteloader.hpp | 20 +- src/station_base.h | 6 +- src/station_cmd.cpp | 64 +-- src/station_cmd.h | 6 +- src/station_func.h | 6 +- src/station_gui.cpp | 6 +- src/station_kdtree.h | 14 +- src/station_type.h | 4 +- src/statusbar_gui.cpp | 6 +- src/story.cpp | 14 +- src/story_base.h | 12 +- src/story_cmd.h | 4 +- src/story_gui.cpp | 6 +- src/story_type.h | 4 +- src/strgen/strgen.cpp | 4 +- src/strgen/strgen_base.cpp | 8 +- src/string.cpp | 28 +- src/string_func.h | 32 +- src/string_type.h | 14 +- src/stringfilter.cpp | 12 +- src/strings.cpp | 62 +-- src/strings_func.h | 4 +- src/strings_internal.h | 16 +- src/strings_type.h | 2 +- src/subsidy.cpp | 4 +- src/subsidy_base.h | 2 +- src/subsidy_type.h | 2 +- src/table/airport_movement.h | 2 +- src/table/build_industry.h | 8 +- src/table/elrail_data.h | 24 +- src/table/heightmap_colours.h | 6 +- src/table/newgrf_debug_data.h | 34 +- src/table/object_land.h | 2 +- src/table/road_land.h | 2 +- src/table/settings.h.preamble | 2 +- src/table/settings/company_settings.ini | 6 +- src/table/settings/difficulty_settings.ini | 8 +- src/table/settings/economy_settings.ini | 2 +- src/table/settings/game_settings.ini | 20 +- src/table/settings/gui_settings.ini | 16 +- src/table/settings/locale_settings.ini | 2 +- src/table/settings/pathfinding_settings.ini | 2 +- src/table/settings/world_settings.ini | 6 +- src/table/sprites.h | 38 +- src/table/station_land.h | 4 +- src/table/strgen_tables.h | 4 +- src/table/track_land.h | 2 +- src/table/tree_land.h | 4 +- src/table/unicode.h | 2 +- src/table/water_land.h | 2 +- src/terraform_cmd.cpp | 2 +- src/terraform_gui.cpp | 6 +- src/tests/math_func.cpp | 8 +- src/textbuf.cpp | 40 +- src/textbuf_type.h | 36 +- src/texteff.cpp | 4 +- src/texteff.hpp | 6 +- src/tgp.cpp | 14 +- src/tile_cmd.h | 6 +- src/tile_type.h | 20 +- src/tilearea_type.h | 12 +- src/timer/timer_game_calendar.cpp | 6 +- src/timer/timer_game_calendar.h | 10 +- src/timer/timer_game_tick.cpp | 2 +- src/timer/timer_game_tick.h | 2 +- src/timetable.h | 2 +- src/timetable_cmd.cpp | 8 +- src/timetable_cmd.h | 4 +- src/timetable_gui.cpp | 2 +- src/toolbar_gui.cpp | 2 +- src/town.h | 54 +- src/town_cmd.cpp | 84 +-- src/town_cmd.h | 12 +- src/town_gui.cpp | 10 +- src/town_kdtree.h | 4 +- src/town_type.h | 2 +- src/townname.cpp | 20 +- src/townname_func.h | 6 +- src/townname_type.h | 4 +- src/track_type.h | 4 +- src/train.h | 26 +- src/train_cmd.cpp | 44 +- src/train_cmd.h | 2 +- src/train_gui.cpp | 4 +- src/transparency_gui.cpp | 2 +- src/transport_type.h | 2 +- src/tree_cmd.cpp | 38 +- src/tree_gui.cpp | 4 +- src/tunnelbridge_cmd.cpp | 10 +- src/vehicle.cpp | 60 +- src/vehicle_base.h | 72 +-- src/vehicle_cmd.cpp | 22 +- src/vehicle_cmd.h | 8 +- src/vehicle_func.h | 6 +- src/vehicle_gui.cpp | 14 +- src/vehicle_gui.h | 2 +- src/vehicle_type.h | 2 +- src/vehiclelist.cpp | 6 +- src/vehiclelist.h | 8 +- src/video/allegro_v.cpp | 6 +- src/video/cocoa/cocoa_ogl.h | 4 +- src/video/cocoa/cocoa_v.h | 2 +- src/video/cocoa/cocoa_v.mm | 28 +- src/video/cocoa/cocoa_wnd.mm | 22 +- src/video/opengl.cpp | 12 +- src/video/opengl.h | 2 +- src/video/sdl2_opengl_v.h | 4 +- src/video/sdl2_v.cpp | 10 +- src/video/sdl_v.cpp | 10 +- src/video/video_driver.hpp | 2 +- src/video/win32_v.cpp | 18 +- src/video/win32_v.h | 8 +- src/viewport.cpp | 38 +- src/viewport_cmd.h | 2 +- src/viewport_func.h | 4 +- src/viewport_kdtree.h | 10 +- src/viewport_sprite_sorter.h | 24 +- src/viewport_sprite_sorter_sse4.cpp | 8 +- src/viewport_type.h | 8 +- src/water.h | 2 +- src/water_cmd.cpp | 4 +- src/water_map.h | 6 +- src/waypoint_base.h | 4 +- src/widget.cpp | 30 +- src/widget_type.h | 90 +-- src/widgets/dropdown.cpp | 4 +- src/widgets/dropdown_func.h | 2 +- src/window.cpp | 28 +- src/window_gui.h | 40 +- src/window_type.h | 2 +- 564 files changed, 4565 insertions(+), 4565 deletions(-) diff --git a/src/3rdparty/md5/md5.cpp b/src/3rdparty/md5/md5.cpp index a0c1093b0c..2e84d4c354 100644 --- a/src/3rdparty/md5/md5.cpp +++ b/src/3rdparty/md5/md5.cpp @@ -60,7 +60,7 @@ #include "../../safeguards.h" -#define T_MASK ((uint32)~0) +#define T_MASK ((uint32_t)~0) #define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87) #define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9) #define T3 0x242070db @@ -126,31 +126,31 @@ #define T63 0x2ad7d2bb #define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e) -static inline void Md5Set1(const uint32 *X, uint32 *a, const uint32 *b, const uint32 *c, const uint32 *d, const uint8 k, const uint8 s, const uint32 Ti) +static inline void Md5Set1(const uint32_t *X, uint32_t *a, const uint32_t *b, const uint32_t *c, const uint32_t *d, const uint8_t k, const uint8_t s, const uint32_t Ti) { - uint32 t = (*b & *c) | (~*b & *d); + uint32_t t = (*b & *c) | (~*b & *d); t += *a + X[k] + Ti; *a = ROL(t, s) + *b; } -static inline void Md5Set2(const uint32 *X, uint32 *a, const uint32 *b, const uint32 *c, const uint32 *d, const uint8 k, const uint8 s, const uint32 Ti) +static inline void Md5Set2(const uint32_t *X, uint32_t *a, const uint32_t *b, const uint32_t *c, const uint32_t *d, const uint8_t k, const uint8_t s, const uint32_t Ti) { - uint32 t = (*b & *d) | (*c & ~*d); + uint32_t t = (*b & *d) | (*c & ~*d); t += *a + X[k] + Ti; *a = ROL(t, s) + *b; } -static inline void Md5Set3(const uint32 *X, uint32 *a, const uint32 *b, const uint32 *c, const uint32 *d, const uint8 k, const uint8 s, const uint32 Ti) +static inline void Md5Set3(const uint32_t *X, uint32_t *a, const uint32_t *b, const uint32_t *c, const uint32_t *d, const uint8_t k, const uint8_t s, const uint32_t Ti) { - uint32 t = *b ^ *c ^ *d; + uint32_t t = *b ^ *c ^ *d; t += *a + X[k] + Ti; *a = ROL(t, s) + *b; } -static inline void Md5Set4(const uint32 *X, uint32 *a, const uint32 *b, const uint32 *c, const uint32 *d, const uint8 k, const uint8 s, const uint32 Ti) +static inline void Md5Set4(const uint32_t *X, uint32_t *a, const uint32_t *b, const uint32_t *c, const uint32_t *d, const uint8_t k, const uint8_t s, const uint32_t Ti) { - uint32 t = *c ^ (*b | ~*d); + uint32_t t = *c ^ (*b | ~*d); t += *a + X[k] + Ti; *a = ROL(t, s) + *b; } @@ -165,17 +165,17 @@ Md5::Md5() abcd[3] = 0x10325476; } -void Md5::Process(const uint8 *data /*[64]*/) +void Md5::Process(const uint8_t *data /*[64]*/) { - uint32 a = this->abcd[0]; - uint32 b = this->abcd[1]; - uint32 c = this->abcd[2]; - uint32 d = this->abcd[3]; + uint32_t a = this->abcd[0]; + uint32_t b = this->abcd[1]; + uint32_t c = this->abcd[2]; + uint32_t d = this->abcd[3]; - uint32 X[16]; + uint32_t X[16]; - /* Convert the uint8 data to uint32 LE */ - const uint32 *px = (const uint32 *)data; + /* Convert the uint8_t data to uint32_t LE */ + const uint32_t *px = (const uint32_t *)data; for (uint i = 0; i < 16; i++) { X[i] = TO_LE32(*px); px++; @@ -264,15 +264,15 @@ void Md5::Process(const uint8 *data /*[64]*/) void Md5::Append(const void *data, const size_t nbytes) { - const uint8 *p = (const uint8 *)data; + const uint8_t *p = (const uint8_t *)data; size_t left = nbytes; const size_t offset = (this->count[0] >> 3) & 63; - const uint32 nbits = (uint32)(nbytes << 3); + const uint32_t nbits = (uint32_t)(nbytes << 3); if (nbytes <= 0) return; /* Update the message length. */ - this->count[1] += (uint32)(nbytes >> 29); + this->count[1] += (uint32_t)(nbytes >> 29); this->count[0] += nbits; if (this->count[0] < nbits) this->count[1]++; @@ -299,17 +299,17 @@ void Md5::Append(const void *data, const size_t nbytes) void Md5::Finish(MD5Hash &digest) { - static const uint8 pad[64] = { + static const uint8_t pad[64] = { 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; - uint8 data[8]; + uint8_t data[8]; /* Save the length before padding. */ for (uint i = 0; i < 8; ++i) { - data[i] = (uint8)(this->count[i >> 2] >> ((i & 3) << 3)); + data[i] = (uint8_t)(this->count[i >> 2] >> ((i & 3) << 3)); } /* Pad to 56 bytes mod 64. */ @@ -318,6 +318,6 @@ void Md5::Finish(MD5Hash &digest) this->Append(data, 8); for (uint i = 0; i < 16; ++i) { - digest[i] = (uint8)(this->abcd[i >> 2] >> ((i & 3) << 3)); + digest[i] = (uint8_t)(this->abcd[i >> 2] >> ((i & 3) << 3)); } } diff --git a/src/3rdparty/md5/md5.h b/src/3rdparty/md5/md5.h index 1141d8e467..29c7167944 100644 --- a/src/3rdparty/md5/md5.h +++ b/src/3rdparty/md5/md5.h @@ -74,11 +74,11 @@ struct MD5Hash : std::array { struct Md5 { private: - uint32 count[2]; ///< message length in bits, lsw first - uint32 abcd[4]; ///< digest buffer - uint8 buf[64]; ///< accumulate block + uint32_t count[2]; ///< message length in bits, lsw first + uint32_t abcd[4]; ///< digest buffer + uint8_t buf[64]; ///< accumulate block - void Process(const uint8 *data); + void Process(const uint8_t *data); public: Md5(); diff --git a/src/3rdparty/squirrel/include/squirrel.h b/src/3rdparty/squirrel/include/squirrel.h index 7924dde346..5b649bbcdc 100644 --- a/src/3rdparty/squirrel/include/squirrel.h +++ b/src/3rdparty/squirrel/include/squirrel.h @@ -179,7 +179,7 @@ typedef void (*SQPRINTFUNCTION)(HSQUIRRELVM,const std::string &); typedef SQInteger (*SQWRITEFUNC)(SQUserPointer,SQUserPointer,SQInteger); typedef SQInteger (*SQREADFUNC)(SQUserPointer,SQUserPointer,SQInteger); -typedef WChar (*SQLEXREADFUNC)(SQUserPointer); +typedef char32_t (*SQLEXREADFUNC)(SQUserPointer); typedef struct tagSQRegFunction{ const SQChar *name; diff --git a/src/3rdparty/squirrel/squirrel/sqapi.cpp b/src/3rdparty/squirrel/squirrel/sqapi.cpp index 27b678dbb5..fd9dc3ceb3 100644 --- a/src/3rdparty/squirrel/squirrel/sqapi.cpp +++ b/src/3rdparty/squirrel/squirrel/sqapi.cpp @@ -1259,9 +1259,9 @@ struct BufState{ SQInteger size; }; -WChar buf_lexfeed(SQUserPointer file) +char32_t buf_lexfeed(SQUserPointer file) { - /* Convert an UTF-8 character into a WChar */ + /* Convert an UTF-8 character into a char32_t */ BufState *buf = (BufState *)file; const char *p = &buf->buf[buf->ptr]; @@ -1279,7 +1279,7 @@ WChar buf_lexfeed(SQUserPointer file) buf->ptr += len; /* Convert the character, and when definitely invalid, bail out as well. */ - WChar c; + char32_t c; if (Utf8Decode(&c, p) != len) return -1; return c; diff --git a/src/3rdparty/squirrel/squirrel/sqlexer.cpp b/src/3rdparty/squirrel/squirrel/sqlexer.cpp index c4fb852991..e91e9ecc52 100644 --- a/src/3rdparty/squirrel/squirrel/sqlexer.cpp +++ b/src/3rdparty/squirrel/squirrel/sqlexer.cpp @@ -26,7 +26,7 @@ SQLexer::~SQLexer() _keywords->Release(); } -void SQLexer::APPEND_CHAR(WChar c) +void SQLexer::APPEND_CHAR(char32_t c) { char buf[4]; size_t chars = Utf8Encode(buf, c); @@ -101,7 +101,7 @@ NORETURN void SQLexer::Error(const SQChar *err) void SQLexer::Next() { - WChar t = _readf(_up); + char32_t t = _readf(_up); if(t > MAX_CHAR) Error("Invalid character"); if(t != 0) { _currdata = t; @@ -287,7 +287,7 @@ SQInteger SQLexer::GetIDType(SQChar *s) } -SQInteger SQLexer::ReadString(WChar ndelim,bool verbatim) +SQInteger SQLexer::ReadString(char32_t ndelim,bool verbatim) { INIT_TEMP_STRING(); NEXT(); diff --git a/src/3rdparty/squirrel/squirrel/sqlexer.h b/src/3rdparty/squirrel/squirrel/sqlexer.h index b53b309d6b..3a4e76b339 100644 --- a/src/3rdparty/squirrel/squirrel/sqlexer.h +++ b/src/3rdparty/squirrel/squirrel/sqlexer.h @@ -11,7 +11,7 @@ struct SQLexer const SQChar *Tok2Str(SQInteger tok); private: SQInteger GetIDType(SQChar *s); - SQInteger ReadString(WChar ndelim,bool verbatim); + SQInteger ReadString(char32_t ndelim,bool verbatim); SQInteger ReadNumber(); void LexBlockComment(); SQInteger ReadID(); @@ -19,7 +19,7 @@ private: SQInteger _curtoken; SQTable *_keywords; void INIT_TEMP_STRING() { _longstr.resize(0); } - void APPEND_CHAR(WChar c); + void APPEND_CHAR(char32_t c); void TERMINATE_BUFFER() { _longstr.push_back('\0'); } public: @@ -32,7 +32,7 @@ public: SQFloat _fvalue; SQLEXREADFUNC _readf; SQUserPointer _up; - WChar _currdata; + char32_t _currdata; SQSharedState *_sharedstate; sqvector _longstr; CompilerErrorFunc _errfunc; diff --git a/src/aircraft.h b/src/aircraft.h index 71dd0fb46a..815542587a 100644 --- a/src/aircraft.h +++ b/src/aircraft.h @@ -64,15 +64,15 @@ int GetAircraftFlightLevel(T *v, bool takeoff = false); /** Variables that are cached to improve performance and such. */ struct AircraftCache { - uint32 cached_max_range_sqr; ///< Cached squared maximum range. - uint16 cached_max_range; ///< Cached maximum range. + uint32_t cached_max_range_sqr; ///< Cached squared maximum range. + uint16_t cached_max_range; ///< Cached maximum range. }; /** * Aircraft, helicopters, rotors and their shadows belong to this class. */ struct Aircraft FINAL : public SpecializedVehicle { - uint16 crashed_counter; ///< Timer for handling crash animations. + uint16_t crashed_counter; ///< Timer for handling crash animations. byte pos; ///< Next desired position of the aircraft. byte previous_pos; ///< Previous desired position of the aircraft. StationID targetairport; ///< Airport to go to next. @@ -130,7 +130,7 @@ struct Aircraft FINAL : public SpecializedVehicle { * Get the range of this aircraft. * @return Range in tiles or 0 if unlimited range. */ - uint16 GetRange() const + uint16_t GetRange() const { return this->acache.cached_max_range; } diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 8dd421bb0d..9ce0cf3164 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -100,7 +100,7 @@ static const SpriteID _aircraft_sprite[] = { }; template <> -bool IsValidImageIndex(uint8 image_index) +bool IsValidImageIndex(uint8_t image_index) { return image_index < lengthof(_aircraft_sprite); } @@ -172,7 +172,7 @@ static StationID FindNearestHangar(const Aircraft *v) void Aircraft::GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const { - uint8 spritenum = this->spritenum; + uint8_t spritenum = this->spritenum; if (is_custom_sprite(spritenum)) { GetCustomVehicleSprite(this, direction, image_type, result); @@ -202,7 +202,7 @@ void GetRotorImage(const Aircraft *v, EngineImageType image_type, VehicleSpriteS static void GetAircraftIcon(EngineID engine, EngineImageType image_type, VehicleSpriteSeq *result) { const Engine *e = Engine::Get(engine); - uint8 spritenum = e->u.air.image_index; + uint8_t spritenum = e->u.air.image_index; if (is_custom_sprite(spritenum)) { GetCustomVehicleIcon(engine, DIR_W, image_type, result); @@ -1174,7 +1174,7 @@ static bool HandleCrashedAircraft(Aircraft *v) } if (v->crashed_counter < 650) { - uint32 r; + uint32_t r; if (Chance16R(1, 32, r)) { static const DirDiff delta[] = { DIRDIFF_45LEFT, DIRDIFF_SAME, DIRDIFF_SAME, DIRDIFF_45RIGHT @@ -1218,8 +1218,8 @@ static bool HandleCrashedAircraft(Aircraft *v) static void HandleAircraftSmoke(Aircraft *v, bool mode) { static const struct { - int8 x; - int8 y; + int8_t x; + int8_t y; } smoke_pos[] = { { 5, 5 }, { 6, 0 }, @@ -1358,7 +1358,7 @@ static void MaybeCrashAirplane(Aircraft *v) Station *st = Station::Get(v->targetairport); - uint32 prob; + uint32_t prob; if ((st->airport.GetFTA()->flags & AirportFTAClass::SHORT_STRIP) && (AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) && !_cheats.no_jetcrash.value) { @@ -1655,8 +1655,8 @@ static void AircraftEventHandler_Flying(Aircraft *v, const AirportFTAClass *apc) /* save speed before, since if AirportHasBlock is false, it resets them to 0 * we don't want that for plane in air * hack for speed thingie */ - uint16 tcur_speed = v->cur_speed; - uint16 tsubspeed = v->subspeed; + uint16_t tcur_speed = v->cur_speed; + uint16_t tsubspeed = v->subspeed; if (!AirportHasBlock(v, current, apc)) { v->state = landingtype; // LANDING / HELILANDING if (v->state == HELILANDING) SetBit(v->flags, VAF_HELI_DIRECT_DESCENT); @@ -1840,7 +1840,7 @@ static bool AirportHasBlock(Aircraft *v, const AirportFTA *current_pos, const Ai /* same block, then of course we can move */ if (apc->layout[current_pos->position].block != next->block) { const Station *st = Station::Get(v->targetairport); - uint64 airport_flags = next->block; + uint64_t airport_flags = next->block; /* check additional possible extra blocks */ if (current_pos != reference && current_pos->block != NOTHING_block) { @@ -1870,7 +1870,7 @@ static bool AirportSetBlocks(Aircraft *v, const AirportFTA *current_pos, const A /* if the next position is in another block, check it and wait until it is free */ if ((apc->layout[current_pos->position].block & next->block) != next->block) { - uint64 airport_flags = next->block; + uint64_t airport_flags = next->block; /* search for all all elements in the list with the same state, and blocks != N * this means more blocks should be checked/set */ const AirportFTA *current = current_pos; @@ -1907,7 +1907,7 @@ static bool AirportSetBlocks(Aircraft *v, const AirportFTA *current_pos, const A */ struct MovementTerminalMapping { AirportMovementStates state; ///< Aircraft movement state when going to this terminal. - uint64 airport_flag; ///< Bitmask in the airport flags that need to be free for this terminal. + uint64_t airport_flag; ///< Bitmask in the airport flags that need to be free for this terminal. }; /** A list of all valid terminals and their associated blocks. */ diff --git a/src/airport.cpp b/src/airport.cpp index 808d14d6ba..936087f3c0 100644 --- a/src/airport.cpp +++ b/src/airport.cpp @@ -65,7 +65,7 @@ AIRPORT_GENERIC(dummy, nullptr, 0, AirportFTAClass::ALL, 0) #include "table/airport_defaults.h" -static uint16 AirportGetNofElements(const AirportFTAbuildup *apFA); +static uint16_t AirportGetNofElements(const AirportFTAbuildup *apFA); static AirportFTA *AirportBuildAutomata(uint nofelements, const AirportFTAbuildup *apFA); @@ -147,9 +147,9 @@ AirportFTAClass::~AirportFTAClass() * Since it is actually just a big array of AirportFTA types, we only * know one element from the other by differing 'position' identifiers */ -static uint16 AirportGetNofElements(const AirportFTAbuildup *apFA) +static uint16_t AirportGetNofElements(const AirportFTAbuildup *apFA) { - uint16 nofelements = 0; + uint16_t nofelements = 0; int temp = apFA[0].position; for (uint i = 0; i < MAX_ELEMENTS; i++) { @@ -171,7 +171,7 @@ static uint16 AirportGetNofElements(const AirportFTAbuildup *apFA) static AirportFTA *AirportBuildAutomata(uint nofelements, const AirportFTAbuildup *apFA) { AirportFTA *FAutomata = MallocT(nofelements); - uint16 internalcounter = 0; + uint16_t internalcounter = 0; for (uint i = 0; i < nofelements; i++) { AirportFTA *current = &FAutomata[i]; diff --git a/src/airport.h b/src/airport.h index 6b87dd1852..ac831c0971 100644 --- a/src/airport.h +++ b/src/airport.h @@ -85,7 +85,7 @@ enum AirportMovementStates { }; /** Movement Blocks on Airports blocks (eg_airport_flags). */ -static const uint64 +static const uint64_t TERM1_block = 1ULL << 0, ///< Block belonging to terminal 1. TERM2_block = 1ULL << 1, ///< Block belonging to terminal 2. TERM3_block = 1ULL << 2, ///< Block belonging to terminal 3. @@ -129,9 +129,9 @@ static const uint64 /** A single location on an airport where aircraft can move to. */ struct AirportMovingData { - int16 x; ///< x-coordinate of the destination. - int16 y; ///< y-coordinate of the destination. - uint16 flag; ///< special flags when moving towards the destination. + int16_t x; ///< x-coordinate of the destination. + int16_t y; ///< y-coordinate of the destination. + uint16_t flag; ///< special flags when moving towards the destination. Direction direction; ///< Direction to turn the aircraft after reaching the destination. }; @@ -189,7 +189,7 @@ DECLARE_ENUM_AS_BIT_SET(AirportFTAClass::Flags) /** Internal structure used in openttd - Finite sTate mAchine --> FTA */ struct AirportFTA { AirportFTA *next; ///< possible extra movement choices from this position - uint64 block; ///< 64 bit blocks (st->airport.flags), should be enough for the most complex airports + uint64_t block; ///< 64 bit blocks (st->airport.flags), should be enough for the most complex airports byte position; ///< the position that an airplane is at byte next_position; ///< next position from this position byte heading; ///< heading (current orders), guiding an airplane to its target on an airport diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp index d98656ca6c..291deab99f 100644 --- a/src/articulated_vehicles.cpp +++ b/src/articulated_vehicles.cpp @@ -36,7 +36,7 @@ static EngineID GetNextArticulatedPart(uint index, EngineID front_type, Vehicle const Engine *front_engine = Engine::Get(front_type); - uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, index, 0, front_type, front); + uint16_t callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, index, 0, front_type, front); if (callback == CALLBACK_FAILED) return INVALID_ENGINE; if (front_engine->GetGRF()->grf_version < 8) { @@ -103,7 +103,7 @@ uint CountArticulatedParts(EngineID engine_type, bool purchase_window) * @param cargo_type returns the default cargo type, if needed * @return capacity */ -static inline uint16 GetVehicleDefaultCapacity(EngineID engine, CargoID *cargo_type) +static inline uint16_t GetVehicleDefaultCapacity(EngineID engine, CargoID *cargo_type) { const Engine *e = Engine::Get(engine); CargoID cargo = (e->CanCarryCargo() ? e->GetDefaultCargoType() : (CargoID)CT_INVALID); @@ -143,7 +143,7 @@ CargoArray GetCapacityOfArticulatedParts(EngineID engine) const Engine *e = Engine::Get(engine); CargoID cargo_type; - uint16 cargo_capacity = GetVehicleDefaultCapacity(engine, &cargo_type); + uint16_t cargo_capacity = GetVehicleDefaultCapacity(engine, &cargo_type); if (cargo_type < NUM_CARGO) capacity[cargo_type] = cargo_capacity; if (!e->IsGroundVehicle()) return capacity; diff --git a/src/autoreplace_base.h b/src/autoreplace_base.h index c342223a71..3c9c32d893 100644 --- a/src/autoreplace_base.h +++ b/src/autoreplace_base.h @@ -15,7 +15,7 @@ #include "engine_type.h" #include "group_type.h" -typedef uint16 EngineRenewID; +typedef uint16_t EngineRenewID; /** * Memory pool for engine renew elements. DO NOT USE outside of engine.c. Is diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index 81c2831cdb..3f98666ec1 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -498,7 +498,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon if (old_head->type == VEH_TRAIN) { /* Store the length of the old vehicle chain, rounded up to whole tiles */ - uint16 old_total_length = CeilDiv(Train::From(old_head)->gcache.cached_total_length, TILE_SIZE) * TILE_SIZE; + uint16_t old_total_length = CeilDiv(Train::From(old_head)->gcache.cached_total_length, TILE_SIZE) * TILE_SIZE; int num_units = 0; ///< Number of units in the chain for (Train *w = Train::From(old_head); w != nullptr; w = w->GetNextUnit()) num_units++; diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index f7ff774b37..1be79d5aee 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -33,7 +33,7 @@ #include "safeguards.h" -void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count, GroupID selected_group); +void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_list, uint16_t min, uint16_t max, EngineID selected_id, bool show_count, GroupID selected_group); static bool EngineNumberSorter(const GUIEngineListItem &a, const GUIEngineListItem &b) { diff --git a/src/base_consist.h b/src/base_consist.h index da4b11dbed..f8a68faaa6 100644 --- a/src/base_consist.h +++ b/src/base_consist.h @@ -18,16 +18,16 @@ struct BaseConsist { std::string name; ///< Name of vehicle /* Used for timetabling. */ - uint32 current_order_time; ///< How many ticks have passed since this order started. - int32 lateness_counter; ///< How many ticks late (or early if negative) this vehicle is. + uint32_t current_order_time; ///< How many ticks have passed since this order started. + int32_t lateness_counter; ///< How many ticks late (or early if negative) this vehicle is. TimerGameCalendar::Date timetable_start; ///< When the vehicle is supposed to start the timetable. - uint16 service_interval; ///< The interval for (automatic) servicing; either in days or %. + uint16_t service_interval; ///< The interval for (automatic) servicing; either in days or %. VehicleOrderID cur_real_order_index;///< The index to the current real (non-implicit) order VehicleOrderID cur_implicit_order_index;///< The index to the current implicit order - uint16 vehicle_flags; ///< Used for gradual loading and other miscellaneous things (@see VehicleFlags enum) + uint16_t vehicle_flags; ///< Used for gradual loading and other miscellaneous things (@see VehicleFlags enum) virtual ~BaseConsist() = default; diff --git a/src/base_media_base.h b/src/base_media_base.h index 7c36002946..f38e130f10 100644 --- a/src/base_media_base.h +++ b/src/base_media_base.h @@ -60,8 +60,8 @@ struct BaseSet { std::string name; ///< The name of the base set TranslatedStrings description; ///< Description of the base set - uint32 shortname; ///< Four letter short variant of the name - uint32 version; ///< The version of this base set + uint32_t shortname; ///< Four letter short variant of the name + uint32_t version; ///< The version of this base set bool fallback; ///< This set is a fallback set, i.e. it should be used only as last resort MD5File files[NUM_FILES]; ///< All files part of this set diff --git a/src/base_media_func.h b/src/base_media_func.h index 2ad0028375..f83c792f92 100644 --- a/src/base_media_func.h +++ b/src/base_media_func.h @@ -59,7 +59,7 @@ bool BaseSet::FillSetDetails(IniFile *ini, const fetch_metadata("shortname"); for (uint i = 0; (*item->value)[i] != '\0' && i < 4; i++) { - this->shortname |= ((uint8)(*item->value)[i]) << (i * 8); + this->shortname |= ((uint8_t)(*item->value)[i]) << (i * 8); } fetch_metadata("version"); diff --git a/src/base_station_base.h b/src/base_station_base.h index 03a5583943..5a76744a17 100644 --- a/src/base_station_base.h +++ b/src/base_station_base.h @@ -21,20 +21,20 @@ extern StationPool _station_pool; struct StationSpecList { const StationSpec *spec; - uint32 grfid; ///< GRF ID of this custom station + uint32_t grfid; ///< GRF ID of this custom station uint16_t localidx; ///< Station ID within GRF of station }; struct RoadStopSpecList { const RoadStopSpec *spec; - uint32 grfid; ///< GRF ID of this custom road stop + uint32_t grfid; ///< GRF ID of this custom road stop uint16_t localidx; ///< Station ID within GRF of road stop }; struct RoadStopTileData { TileIndex tile; - uint8 random_bits; - uint8 animation_frame; + uint8_t random_bits; + uint8_t animation_frame; }; /** StationRect - used to track station spread out rectangle - cheaper than scanning whole map */ @@ -79,10 +79,10 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> { TimerGameCalendar::Date build_date; ///< Date of construction - uint16 random_bits; ///< Random bits assigned to this station + uint16_t random_bits; ///< Random bits assigned to this station byte waiting_triggers; ///< Waiting triggers (NewGRF) for this station - uint8 cached_anim_triggers; ///< NOSAVE: Combined animation trigger bitmask, used to determine if trigger processing should happen. - uint8 cached_roadstop_anim_triggers; ///< NOSAVE: Combined animation trigger bitmask for road stops, used to determine if trigger processing should happen. + uint8_t cached_anim_triggers; ///< NOSAVE: Combined animation trigger bitmask, used to determine if trigger processing should happen. + uint8_t cached_roadstop_anim_triggers; ///< NOSAVE: Combined animation trigger bitmask for road stops, used to determine if trigger processing should happen. CargoTypes cached_cargo_triggers; ///< NOSAVE: Combined cargo trigger bitmask CargoTypes cached_roadstop_cargo_triggers; ///< NOSAVE: Combined cargo trigger bitmask for road stops @@ -118,7 +118,7 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> { * @param available will return false if ever the variable asked for does not exist * @return the value stored in the corresponding variable */ - virtual uint32 GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const = 0; + virtual uint32_t GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const = 0; /** * Update the coordinated of the sign (as shown in the viewport). diff --git a/src/blitter/32bpp_anim.cpp b/src/blitter/32bpp_anim.cpp index ab6f984d61..19c48deae8 100644 --- a/src/blitter/32bpp_anim.cpp +++ b/src/blitter/32bpp_anim.cpp @@ -30,26 +30,26 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel const SpriteData *src = (const SpriteData *)bp->sprite; const Colour *src_px = (const Colour *)(src->data + src->offset[zoom][0]); - const uint16 *src_n = (const uint16 *)(src->data + src->offset[zoom][1]); + const uint16_t *src_n = (const uint16_t *)(src->data + src->offset[zoom][1]); for (uint i = bp->skip_top; i != 0; i--) { - src_px = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px); - src_n = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n); + src_px = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px); + src_n = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n); } Colour *dst = (Colour *)bp->dst + bp->top * bp->pitch + bp->left; - uint16 *anim = this->anim_buf + this->ScreenToAnimOffset((uint32 *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left; + uint16_t *anim = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left; const byte *remap = bp->remap; // store so we don't have to access it via bp every time for (int y = 0; y < bp->height; y++) { Colour *dst_ln = dst + bp->pitch; - uint16 *anim_ln = anim + this->anim_buf_pitch; + uint16_t *anim_ln = anim + this->anim_buf_pitch; - const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px); + const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px); src_px++; - const uint16 *src_n_ln = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n); + const uint16_t *src_n_ln = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n); src_n += 2; Colour *dst_end = dst + bp->skip_left; @@ -144,7 +144,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel do { uint m = *src_n; if (m == 0) { - uint8 g = MakeDark(src_px->r, src_px->g, src_px->b); + uint8_t g = MakeDark(src_px->r, src_px->g, src_px->b); *dst = ComposeColourRGBA(g, g, g, src_px->a, *dst); *anim = 0; } else { @@ -162,7 +162,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel uint m = *src_n; if (m == 0) { if (src_px->a != 0) { - uint8 g = MakeDark(src_px->r, src_px->g, src_px->b); + uint8_t g = MakeDark(src_px->r, src_px->g, src_px->b); *dst = ComposeColourRGBA(g, g, g, src_px->a, *dst); *anim = 0; } @@ -278,7 +278,7 @@ void Blitter_32bppAnim::DrawColourMappingRect(void *dst, int width, int height, } Colour *udst = (Colour *)dst; - uint16 *anim = this->anim_buf + this->ScreenToAnimOffset((uint32 *)dst); + uint16_t *anim = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)dst); if (pal == PALETTE_TO_TRANSPARENT) { do { @@ -310,17 +310,17 @@ void Blitter_32bppAnim::DrawColourMappingRect(void *dst, int width, int height, Debug(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('{}')", pal); } -void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8 colour) +void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8_t colour) { *((Colour *)video + x + y * _screen.pitch) = LookupColourInPalette(colour); /* Set the colour in the anim-buffer too, if we are rendering to the screen */ if (_screen_disable_anim) return; - this->anim_buf[this->ScreenToAnimOffset((uint32 *)video) + x + y * this->anim_buf_pitch] = colour | (DEFAULT_BRIGHTNESS << 8); + this->anim_buf[this->ScreenToAnimOffset((uint32_t *)video) + x + y * this->anim_buf_pitch] = colour | (DEFAULT_BRIGHTNESS << 8); } -void Blitter_32bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) +void Blitter_32bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash) { const Colour c = LookupColourInPalette(colour); @@ -329,8 +329,8 @@ void Blitter_32bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int *((Colour *)video + x + y * _screen.pitch) = c; }); } else { - uint16 * const offset_anim_buf = this->anim_buf + this->ScreenToAnimOffset((uint32 *)video); - const uint16 anim_colour = colour | (DEFAULT_BRIGHTNESS << 8); + uint16_t * const offset_anim_buf = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)video); + const uint16_t anim_colour = colour | (DEFAULT_BRIGHTNESS << 8); this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [&](int x, int y) { *((Colour *)video + x + y * _screen.pitch) = c; offset_anim_buf[x + y * this->anim_buf_pitch] = anim_colour; @@ -338,7 +338,7 @@ void Blitter_32bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int } } -void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 colour) +void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8_t colour) { if (_screen_disable_anim) { /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */ @@ -347,11 +347,11 @@ void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 colou } Colour colour32 = LookupColourInPalette(colour); - uint16 *anim_line = this->ScreenToAnimOffset((uint32 *)video) + this->anim_buf; + uint16_t *anim_line = this->ScreenToAnimOffset((uint32_t *)video) + this->anim_buf; do { Colour *dst = (Colour *)video; - uint16 *anim = anim_line; + uint16_t *anim = anim_line; for (int i = width; i > 0; i--) { *dst = colour32; @@ -360,7 +360,7 @@ void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 colou dst++; anim++; } - video = (uint32 *)video + _screen.pitch; + video = (uint32_t *)video + _screen.pitch; anim_line += this->anim_buf_pitch; } while (--height); } @@ -368,22 +368,22 @@ void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 colou void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width, int height) { assert(!_screen_disable_anim); - assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); + assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); Colour *dst = (Colour *)video; - const uint32 *usrc = (const uint32 *)src; - uint16 *anim_line = this->ScreenToAnimOffset((uint32 *)video) + this->anim_buf; + const uint32_t *usrc = (const uint32_t *)src; + uint16_t *anim_line = this->ScreenToAnimOffset((uint32_t *)video) + this->anim_buf; for (; height > 0; height--) { /* We need to keep those for palette animation. */ Colour *dst_pal = dst; - uint16 *anim_pal = anim_line; + uint16_t *anim_pal = anim_line; - memcpy(static_cast(dst), usrc, width * sizeof(uint32)); + memcpy(static_cast(dst), usrc, width * sizeof(uint32_t)); usrc += width; dst += _screen.pitch; /* Copy back the anim-buffer */ - memcpy(anim_line, usrc, width * sizeof(uint16)); - usrc = (const uint32 *)&((const uint16 *)usrc)[width]; + memcpy(anim_line, usrc, width * sizeof(uint16_t)); + usrc = (const uint32_t *)&((const uint16_t *)usrc)[width]; anim_line += this->anim_buf_pitch; /* Okay, it is *very* likely that the image we stored is using @@ -408,21 +408,21 @@ void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width, void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height) { assert(!_screen_disable_anim); - assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); - uint32 *udst = (uint32 *)dst; - const uint32 *src = (const uint32 *)video; + assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); + uint32_t *udst = (uint32_t *)dst; + const uint32_t *src = (const uint32_t *)video; if (this->anim_buf == nullptr) return; - const uint16 *anim_line = this->ScreenToAnimOffset((const uint32 *)video) + this->anim_buf; + const uint16_t *anim_line = this->ScreenToAnimOffset((const uint32_t *)video) + this->anim_buf; for (; height > 0; height--) { - memcpy(udst, src, width * sizeof(uint32)); + memcpy(udst, src, width * sizeof(uint32_t)); src += _screen.pitch; udst += width; /* Copy the anim-buffer */ - memcpy(udst, anim_line, width * sizeof(uint16)); - udst = (uint32 *)&((uint16 *)udst)[width]; + memcpy(udst, anim_line, width * sizeof(uint16_t)); + udst = (uint32_t *)&((uint16_t *)udst)[width]; anim_line += this->anim_buf_pitch; } } @@ -430,8 +430,8 @@ void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, in void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) { assert(!_screen_disable_anim); - assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); - uint16 *dst, *src; + assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); + uint16_t *dst, *src; /* We need to scroll the anim-buffer too */ if (scroll_y > 0) { @@ -448,7 +448,7 @@ void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &widt uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x); uint th = height - scroll_y; for (; th > 0; th--) { - memcpy(dst, src, tw * sizeof(uint16)); + memcpy(dst, src, tw * sizeof(uint16_t)); src -= this->anim_buf_pitch; dst -= this->anim_buf_pitch; } @@ -469,7 +469,7 @@ void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &widt uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x); uint th = height + scroll_y; for (; th > 0; th--) { - memmove(dst, src, tw * sizeof(uint16)); + memmove(dst, src, tw * sizeof(uint16_t)); src += this->anim_buf_pitch; dst += this->anim_buf_pitch; } @@ -480,7 +480,7 @@ void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &widt size_t Blitter_32bppAnim::BufferSize(uint width, uint height) { - return (sizeof(uint32) + sizeof(uint16)) * width * height; + return (sizeof(uint32_t) + sizeof(uint16_t)) * width * height; } void Blitter_32bppAnim::PaletteAnimate(const Palette &palette) @@ -493,7 +493,7 @@ void Blitter_32bppAnim::PaletteAnimate(const Palette &palette) * Especially when going between toyland and non-toyland. */ assert(this->palette.first_dirty == PALETTE_ANIM_START || this->palette.first_dirty == 0); - const uint16 *anim = this->anim_buf; + const uint16_t *anim = this->anim_buf; Colour *dst = (Colour *)_screen.dst_ptr; /* Let's walk the anim buffer and try to find the pixels */ @@ -502,8 +502,8 @@ void Blitter_32bppAnim::PaletteAnimate(const Palette &palette) const int anim_pitch_offset = this->anim_buf_pitch - width; for (int y = this->anim_buf_height; y != 0 ; y--) { for (int x = width; x != 0 ; x--) { - uint16 value = *anim; - uint8 colour = GB(value, 0, 8); + uint16_t value = *anim; + uint8_t colour = GB(value, 0, 8); if (colour >= PALETTE_ANIM_START) { /* Update this pixel */ *dst = this->AdjustBrightness(LookupColourInPalette(colour), GB(value, 8, 8)); @@ -533,9 +533,9 @@ void Blitter_32bppAnim::PostResize() this->anim_buf_width = _screen.width; this->anim_buf_height = _screen.height; this->anim_buf_pitch = (_screen.width + 7) & ~7; - this->anim_alloc = CallocT(this->anim_buf_pitch * this->anim_buf_height + 8); + this->anim_alloc = CallocT(this->anim_buf_pitch * this->anim_buf_height + 8); /* align buffer to next 16 byte boundary */ - this->anim_buf = reinterpret_cast((reinterpret_cast(this->anim_alloc) + 0xF) & (~0xF)); + this->anim_buf = reinterpret_cast((reinterpret_cast(this->anim_alloc) + 0xF) & (~0xF)); } } diff --git a/src/blitter/32bpp_anim.hpp b/src/blitter/32bpp_anim.hpp index a0516d13c4..125295c41e 100644 --- a/src/blitter/32bpp_anim.hpp +++ b/src/blitter/32bpp_anim.hpp @@ -15,7 +15,7 @@ /** The optimised 32 bpp blitter with palette animation. */ class Blitter_32bppAnim : public Blitter_32bppOptimized { protected: - uint16 *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation + uint16_t *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation void *anim_alloc; ///< The raw allocated buffer, not necessarily aligned correctly int anim_buf_width; ///< The width of the animation buffer. int anim_buf_height; ///< The height of the animation buffer. @@ -37,9 +37,9 @@ public: void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override; void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override; - void SetPixel(void *video, int x, int y, uint8 colour) override; - void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override; - void DrawRect(void *video, int width, int height, uint8 colour) override; + void SetPixel(void *video, int x, int y, uint8_t colour) override; + void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash) override; + void DrawRect(void *video, int width, int height, uint8_t colour) override; void CopyFromBuffer(void *video, const void *src, int width, int height) override; void CopyToBuffer(const void *video, void *dst, int width, int height) override; void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) override; @@ -59,9 +59,9 @@ public: return this->palette.palette[index]; } - inline int ScreenToAnimOffset(const uint32 *video) + inline int ScreenToAnimOffset(const uint32_t *video) { - int raw_offset = video - (const uint32 *)_screen.dst_ptr; + int raw_offset = video - (const uint32_t *)_screen.dst_ptr; if (_screen.pitch == this->anim_buf_pitch) return raw_offset; int lines = raw_offset / _screen.pitch; int across = raw_offset % _screen.pitch; diff --git a/src/blitter/32bpp_anim_sse2.cpp b/src/blitter/32bpp_anim_sse2.cpp index 117e6ec5c2..b166037ddd 100644 --- a/src/blitter/32bpp_anim_sse2.cpp +++ b/src/blitter/32bpp_anim_sse2.cpp @@ -30,7 +30,7 @@ void Blitter_32bppSSE2_Anim::PaletteAnimate(const Palette &palette) * Especially when going between toyland and non-toyland. */ assert(this->palette.first_dirty == PALETTE_ANIM_START || this->palette.first_dirty == 0); - const uint16 *anim = this->anim_buf; + const uint16_t *anim = this->anim_buf; Colour *dst = (Colour *)_screen.dst_ptr; bool screen_dirty = false; @@ -44,7 +44,7 @@ void Blitter_32bppSSE2_Anim::PaletteAnimate(const Palette &palette) __m128i colour_mask = _mm_set1_epi16(0xFF); for (int y = this->anim_buf_height; y != 0 ; y--) { Colour *next_dst_ln = dst + screen_pitch; - const uint16 *next_anim_ln = anim + anim_pitch; + const uint16_t *next_anim_ln = anim + anim_pitch; int x = width; while (x > 0) { __m128i data = _mm_load_si128((const __m128i *) anim); @@ -61,7 +61,7 @@ void Blitter_32bppSSE2_Anim::PaletteAnimate(const Palette &palette) /* slow path: < 8 pixels left or unexpected brightnesses */ for (int z = std::min(x, 8); z != 0 ; z--) { int value = _mm_extract_epi16(data, 0); - uint8 colour = GB(value, 0, 8); + uint8_t colour = GB(value, 0, 8); if (colour >= PALETTE_ANIM_START) { /* Update this pixel */ *dst = AdjustBrightneSSE(LookupColourInPalette(colour), GB(value, 8, 8)); diff --git a/src/blitter/32bpp_anim_sse4.cpp b/src/blitter/32bpp_anim_sse4.cpp index 93c9cb20c6..6c60a5fb4e 100644 --- a/src/blitter/32bpp_anim_sse4.cpp +++ b/src/blitter/32bpp_anim_sse4.cpp @@ -34,7 +34,7 @@ inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomL { const byte * const remap = bp->remap; Colour *dst_line = (Colour *) bp->dst + bp->top * bp->pitch + bp->left; - uint16 *anim_line = this->anim_buf + this->ScreenToAnimOffset((uint32 *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left; + uint16_t *anim_line = this->anim_buf + this->ScreenToAnimOffset((uint32_t *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left; int effective_width = bp->width; /* Find where to start reading in the source sprite. */ @@ -59,7 +59,7 @@ inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomL Colour *dst = dst_line; const Colour *src = src_rgba_line + META_LENGTH; if (mode != BM_TRANSPARENT) src_mv = src_mv_line; - uint16 *anim = anim_line; + uint16_t *anim = anim_line; if (read_mode == RM_WITH_MARGIN) { assert(bt_last == BT_NONE); // or you must ensure block type is preserved @@ -81,7 +81,7 @@ inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomL for (uint x = (uint) effective_width; x > 0; x--) { if (src->a) { if (animated) { - *anim = *(const uint16*) src_mv; + *anim = *(const uint16_t*) src_mv; *dst = (src_mv->m >= PALETTE_ANIM_START) ? AdjustBrightneSSE(this->LookupColourInPalette(src_mv->m), src_mv->v) : src->data; } else { *anim = 0; @@ -97,7 +97,7 @@ inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomL } for (uint x = (uint) effective_width/2; x != 0; x--) { - uint32 mvX2 = *((uint32 *) const_cast(src_mv)); + uint32_t mvX2 = *((uint32_t *) const_cast(src_mv)); __m128i srcABCD = _mm_loadl_epi64((const __m128i*) src); __m128i dstABCD = _mm_loadl_epi64((__m128i*) dst); @@ -117,26 +117,26 @@ inline void Blitter_32bppSSE4_Anim::Draw(const Blitter::BlitterParams *bp, ZoomL /* Update anim buffer. */ const byte a0 = src[0].a; const byte a1 = src[1].a; - uint32 anim01 = 0; + uint32_t anim01 = 0; if (a0 == 255) { if (a1 == 255) { - *(uint32*) anim = mvX2; + *(uint32_t*) anim = mvX2; goto bmno_full_opacity; } - anim01 = (uint16) mvX2; + anim01 = (uint16_t) mvX2; } else if (a0 == 0) { if (a1 == 0) { goto bmno_full_transparency; } else { - if (a1 == 255) anim[1] = (uint16) (mvX2 >> 16); + if (a1 == 255) anim[1] = (uint16_t) (mvX2 >> 16); goto bmno_alpha_blend; } } if (a1 > 0) { if (a1 == 255) anim01 |= mvX2 & 0xFFFF0000; - *(uint32*) anim = anim01; + *(uint32_t*) anim = anim01; } else { - anim[0] = (uint16) anim01; + anim[0] = (uint16_t) anim01; } } else { if (src[0].a) anim[0] = 0; @@ -159,7 +159,7 @@ bmno_full_transparency: if (src->a == 0) { /* Complete transparency. */ } else if (src->a == 255) { - *anim = *(const uint16*) src_mv; + *anim = *(const uint16_t*) src_mv; *dst = (src_mv->m >= PALETTE_ANIM_START) ? AdjustBrightneSSE(LookupColourInPalette(src_mv->m), src_mv->v) : *src; } else { *anim = 0; @@ -179,7 +179,7 @@ bmno_full_transparency: case BM_COLOUR_REMAP: for (uint x = (uint) effective_width / 2; x != 0; x--) { - uint32 mvX2 = *((uint32 *) const_cast(src_mv)); + uint32_t mvX2 = *((uint32_t *) const_cast(src_mv)); __m128i srcABCD = _mm_loadl_epi64((const __m128i*) src); __m128i dstABCD = _mm_loadl_epi64((__m128i*) dst); @@ -201,14 +201,14 @@ bmno_full_transparency: m_colour = m != 0 ? m_colour : srcm; \ } #ifdef POINTER_IS_64BIT - uint64 srcs = _mm_cvtsi128_si64(srcABCD); - uint64 dsts; + uint64_t srcs = _mm_cvtsi128_si64(srcABCD); + uint64_t dsts; if (animated) dsts = _mm_cvtsi128_si64(dstABCD); - uint64 remapped_src = 0; + uint64_t remapped_src = 0; CMOV_REMAP(c0, animated ? dsts : 0, srcs, mvX2); remapped_src = c0.data; CMOV_REMAP(c1, animated ? dsts >> 32 : 0, srcs >> 32, mvX2 >> 16); - remapped_src |= (uint64) c1.data << 32; + remapped_src |= (uint64_t) c1.data << 32; srcABCD = _mm_cvtsi64_si128(remapped_src); #else Colour remapped_src[2]; @@ -226,11 +226,11 @@ bmno_full_transparency: if (animated) { const byte a0 = src[0].a; const byte a1 = src[1].a; - uint32 anim01 = mvX2 & 0xFF00FF00; + uint32_t anim01 = mvX2 & 0xFF00FF00; if (a0 == 255) { anim01 |= r0; if (a1 == 255) { - *(uint32*) anim = anim01 | (r1 << 16); + *(uint32_t*) anim = anim01 | (r1 << 16); goto bmcr_full_opacity; } } else if (a0 == 0) { @@ -245,9 +245,9 @@ bmno_full_transparency: } if (a1 > 0) { if (a1 == 255) anim01 |= r1 << 16; - *(uint32*) anim = anim01; + *(uint32_t*) anim = anim01; } else { - anim[0] = (uint16) anim01; + anim[0] = (uint16_t) anim01; } } else { if (src[0].a) anim[0] = 0; @@ -272,7 +272,7 @@ bmcr_full_transparency: if (src->a == 0) break; if (src_mv->m) { const uint r = remap[src_mv->m]; - *anim = (animated && src->a == 255) ? r | ((uint16) src_mv->v << 8 ) : 0; + *anim = (animated && src->a == 255) ? r | ((uint16_t) src_mv->v << 8 ) : 0; if (r != 0) { Colour remapped_colour = AdjustBrightneSSE(this->LookupColourInPalette(r), src_mv->v); if (src->a == 255) { @@ -321,7 +321,7 @@ bmcr_alpha_blend_single: for (uint x = (uint) bp->width; x > 0; x--) { if (src_mv->m == 0) { if (src->a != 0) { - uint8 g = MakeDark(src->r, src->g, src->b); + uint8_t g = MakeDark(src->r, src->g, src->b); *dst = ComposeColourRGBA(g, g, g, src->a, *dst); *anim = 0; } diff --git a/src/blitter/32bpp_base.cpp b/src/blitter/32bpp_base.cpp index 744337631a..a6d71998bd 100644 --- a/src/blitter/32bpp_base.cpp +++ b/src/blitter/32bpp_base.cpp @@ -15,15 +15,15 @@ void *Blitter_32bppBase::MoveTo(void *video, int x, int y) { - return (uint32 *)video + x + y * _screen.pitch; + return (uint32_t *)video + x + y * _screen.pitch; } -void Blitter_32bppBase::SetPixel(void *video, int x, int y, uint8 colour) +void Blitter_32bppBase::SetPixel(void *video, int x, int y, uint8_t colour) { *((Colour *)video + x + y * _screen.pitch) = LookupColourInPalette(colour); } -void Blitter_32bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) +void Blitter_32bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash) { const Colour c = LookupColourInPalette(colour); this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](int x, int y) { @@ -31,7 +31,7 @@ void Blitter_32bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int }); } -void Blitter_32bppBase::DrawRect(void *video, int width, int height, uint8 colour) +void Blitter_32bppBase::DrawRect(void *video, int width, int height, uint8_t colour) { Colour colour32 = LookupColourInPalette(colour); @@ -41,17 +41,17 @@ void Blitter_32bppBase::DrawRect(void *video, int width, int height, uint8 colou *dst = colour32; dst++; } - video = (uint32 *)video + _screen.pitch; + video = (uint32_t *)video + _screen.pitch; } while (--height); } void Blitter_32bppBase::CopyFromBuffer(void *video, const void *src, int width, int height) { - uint32 *dst = (uint32 *)video; - const uint32 *usrc = (const uint32 *)src; + uint32_t *dst = (uint32_t *)video; + const uint32_t *usrc = (const uint32_t *)src; for (; height > 0; height--) { - memcpy(dst, usrc, width * sizeof(uint32)); + memcpy(dst, usrc, width * sizeof(uint32_t)); usrc += width; dst += _screen.pitch; } @@ -59,11 +59,11 @@ void Blitter_32bppBase::CopyFromBuffer(void *video, const void *src, int width, void Blitter_32bppBase::CopyToBuffer(const void *video, void *dst, int width, int height) { - uint32 *udst = (uint32 *)dst; - const uint32 *src = (const uint32 *)video; + uint32_t *udst = (uint32_t *)dst; + const uint32_t *src = (const uint32_t *)video; for (; height > 0; height--) { - memcpy(udst, src, width * sizeof(uint32)); + memcpy(udst, src, width * sizeof(uint32_t)); src += _screen.pitch; udst += width; } @@ -71,11 +71,11 @@ void Blitter_32bppBase::CopyToBuffer(const void *video, void *dst, int width, in void Blitter_32bppBase::CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) { - uint32 *udst = (uint32 *)dst; - const uint32 *src = (const uint32 *)video; + uint32_t *udst = (uint32_t *)dst; + const uint32_t *src = (const uint32_t *)video; for (; height > 0; height--) { - memcpy(udst, src, width * sizeof(uint32)); + memcpy(udst, src, width * sizeof(uint32_t)); src += _screen.pitch; udst += dst_pitch; } @@ -83,12 +83,12 @@ void Blitter_32bppBase::CopyImageToBuffer(const void *video, void *dst, int widt void Blitter_32bppBase::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) { - const uint32 *src; - uint32 *dst; + const uint32_t *src; + uint32_t *dst; if (scroll_y > 0) { /* Calculate pointers */ - dst = (uint32 *)video + left + (top + height - 1) * _screen.pitch; + dst = (uint32_t *)video + left + (top + height - 1) * _screen.pitch; src = dst - scroll_y * _screen.pitch; /* Decrease height and increase top */ @@ -107,13 +107,13 @@ void Blitter_32bppBase::ScrollBuffer(void *video, int &left, int &top, int &widt } for (int h = height; h > 0; h--) { - memcpy(dst, src, width * sizeof(uint32)); + memcpy(dst, src, width * sizeof(uint32_t)); src -= _screen.pitch; dst -= _screen.pitch; } } else { /* Calculate pointers */ - dst = (uint32 *)video + left + top * _screen.pitch; + dst = (uint32_t *)video + left + top * _screen.pitch; src = dst - scroll_y * _screen.pitch; /* Decrease height. (scroll_y is <=0). */ @@ -133,7 +133,7 @@ void Blitter_32bppBase::ScrollBuffer(void *video, int &left, int &top, int &widt /* the y-displacement may be 0 therefore we have to use memmove, * because source and destination may overlap */ for (int h = height; h > 0; h--) { - memmove(dst, src, width * sizeof(uint32)); + memmove(dst, src, width * sizeof(uint32_t)); src += _screen.pitch; dst += _screen.pitch; } @@ -142,7 +142,7 @@ void Blitter_32bppBase::ScrollBuffer(void *video, int &left, int &top, int &widt size_t Blitter_32bppBase::BufferSize(uint width, uint height) { - return sizeof(uint32) * width * height; + return sizeof(uint32_t) * width * height; } void Blitter_32bppBase::PaletteAnimate(const Palette &palette) @@ -150,22 +150,22 @@ void Blitter_32bppBase::PaletteAnimate(const Palette &palette) /* By default, 32bpp doesn't have palette animation */ } -Colour Blitter_32bppBase::ReallyAdjustBrightness(Colour colour, uint8 brightness) +Colour Blitter_32bppBase::ReallyAdjustBrightness(Colour colour, uint8_t brightness) { assert(DEFAULT_BRIGHTNESS == 1 << 7); - uint64 combined = (((uint64) colour.r) << 32) | (((uint64) colour.g) << 16) | ((uint64) colour.b); + uint64_t combined = (((uint64_t) colour.r) << 32) | (((uint64_t) colour.g) << 16) | ((uint64_t) colour.b); combined *= brightness; - uint16 r = GB(combined, 39, 9); - uint16 g = GB(combined, 23, 9); - uint16 b = GB(combined, 7, 9); + uint16_t r = GB(combined, 39, 9); + uint16_t g = GB(combined, 23, 9); + uint16_t b = GB(combined, 7, 9); if ((combined & 0x800080008000L) == 0L) { return Colour(r, g, b, colour.a); } - uint16 ob = 0; + uint16_t ob = 0; /* Sum overbright */ if (r > 255) ob += r - 255; if (g > 255) ob += g - 255; diff --git a/src/blitter/32bpp_base.hpp b/src/blitter/32bpp_base.hpp index 2a90602326..a1e1002cb8 100644 --- a/src/blitter/32bpp_base.hpp +++ b/src/blitter/32bpp_base.hpp @@ -18,11 +18,11 @@ /** Base for all 32bpp blitters. */ class Blitter_32bppBase : public Blitter { public: - uint8 GetScreenDepth() override { return 32; } + uint8_t GetScreenDepth() override { return 32; } void *MoveTo(void *video, int x, int y) override; - void SetPixel(void *video, int x, int y, uint8 colour) override; - void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override; - void DrawRect(void *video, int width, int height, uint8 colour) override; + void SetPixel(void *video, int x, int y, uint8_t colour) override; + void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash) override; + void DrawRect(void *video, int width, int height, uint8_t colour) override; void CopyFromBuffer(void *video, const void *src, int width, int height) override; void CopyToBuffer(const void *video, void *dst, int width, int height) override; void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override; @@ -118,7 +118,7 @@ public: * @param b blue component * @return the brightness value of the new colour, now dark grey. */ - static inline uint8 MakeDark(uint8 r, uint8 g, uint8 b) + static inline uint8_t MakeDark(uint8_t r, uint8_t g, uint8_t b) { /* Magic-numbers are ~66% of those used in MakeGrey() */ return ((r * 13063) + (g * 25647) + (b * 4981)) / 65536; @@ -131,7 +131,7 @@ public: */ static inline Colour MakeDark(Colour colour) { - uint8 d = MakeDark(colour.r, colour.g, colour.b); + uint8_t d = MakeDark(colour.r, colour.g, colour.b); return Colour(d, d, d); } @@ -157,9 +157,9 @@ public: static const int DEFAULT_BRIGHTNESS = 128; - static Colour ReallyAdjustBrightness(Colour colour, uint8 brightness); + static Colour ReallyAdjustBrightness(Colour colour, uint8_t brightness); - static inline Colour AdjustBrightness(Colour colour, uint8 brightness) + static inline Colour AdjustBrightness(Colour colour, uint8_t brightness) { /* Shortcut for normal brightness */ if (brightness == DEFAULT_BRIGHTNESS) return colour; @@ -167,9 +167,9 @@ public: return ReallyAdjustBrightness(colour, brightness); } - static inline uint8 GetColourBrightness(Colour colour) + static inline uint8_t GetColourBrightness(Colour colour) { - uint8 rgb_max = std::max(colour.r, std::max(colour.g, colour.b)); + uint8_t rgb_max = std::max(colour.r, std::max(colour.g, colour.b)); /* Black pixel (8bpp or old 32bpp image), so use default value */ if (rgb_max == 0) rgb_max = DEFAULT_BRIGHTNESS; diff --git a/src/blitter/32bpp_optimized.cpp b/src/blitter/32bpp_optimized.cpp index b8c4becb84..74181f0b61 100644 --- a/src/blitter/32bpp_optimized.cpp +++ b/src/blitter/32bpp_optimized.cpp @@ -29,18 +29,18 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL { const SpriteData *src = (const SpriteData *)bp->sprite; - /* src_px : each line begins with uint32 n = 'number of bytes in this line', + /* src_px : each line begins with uint32_t n = 'number of bytes in this line', * then n times is the Colour struct for this line */ const Colour *src_px = (const Colour *)(src->data + src->offset[zoom][0]); - /* src_n : each line begins with uint32 n = 'number of bytes in this line', + /* src_n : each line begins with uint32_t n = 'number of bytes in this line', * then interleaved stream of 'm' and 'n' channels. 'm' is remap, * 'n' is number of bytes with the same alpha channel class */ - const uint16 *src_n = (const uint16 *)(src->data + src->offset[zoom][1]); + const uint16_t *src_n = (const uint16_t *)(src->data + src->offset[zoom][1]); /* skip upper lines in src_px and src_n */ for (uint i = bp->skip_top; i != 0; i--) { - src_px = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px); - src_n = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n); + src_px = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px); + src_n = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n); } /* skip lines in dst */ @@ -54,11 +54,11 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL Colour *dst_ln = dst + bp->pitch; /* next src line begins here */ - const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px); + const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px); src_px++; /* next src_n line begins here */ - const uint16 *src_n_ln = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n); + const uint16_t *src_n_ln = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n); src_n += 2; /* we will end this line when we reach this point */ @@ -146,7 +146,7 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL do { uint m = *src_n; if (m == 0) { - uint8 g = MakeDark(src_px->r, src_px->g, src_px->b); + uint8_t g = MakeDark(src_px->r, src_px->g, src_px->b); *dst = ComposeColourRGBA(g, g, g, src_px->a, *dst); } else { uint r = remap[GB(m, 0, 8)]; @@ -161,7 +161,7 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL uint m = *src_n; if (m == 0) { if (src_px->a != 0) { - uint8 g = MakeDark(src_px->r, src_px->g, src_px->b); + uint8_t g = MakeDark(src_px->r, src_px->g, src_px->b); *dst = ComposeColourRGBA(g, g, g, src_px->a, *dst); } } else { @@ -285,10 +285,10 @@ template Sprite *Blitter_32bppOptimized::EncodeInternal(const * * it has to be stored in one stream so fewer registers are used - * x86 has problems with register allocation even with this solution */ - uint16 *dst_n_orig[ZOOM_LVL_COUNT]; + uint16_t *dst_n_orig[ZOOM_LVL_COUNT]; /* lengths of streams */ - uint32 lengths[ZOOM_LVL_COUNT][2]; + uint32_t lengths[ZOOM_LVL_COUNT][2]; ZoomLevel zoom_min; ZoomLevel zoom_max; @@ -308,25 +308,25 @@ template Sprite *Blitter_32bppOptimized::EncodeInternal(const uint size = src_orig->height * src_orig->width; dst_px_orig[z] = CallocT(size + src_orig->height * 2); - dst_n_orig[z] = CallocT(size * 2 + src_orig->height * 4 * 2); + dst_n_orig[z] = CallocT(size * 2 + src_orig->height * 4 * 2); - uint32 *dst_px_ln = (uint32 *)dst_px_orig[z]; - uint32 *dst_n_ln = (uint32 *)dst_n_orig[z]; + uint32_t *dst_px_ln = (uint32_t *)dst_px_orig[z]; + uint32_t *dst_n_ln = (uint32_t *)dst_n_orig[z]; const SpriteLoader::CommonPixel *src = (const SpriteLoader::CommonPixel *)src_orig->data; for (uint y = src_orig->height; y > 0; y--) { /* Index 0 of dst_px and dst_n is left as space to save the length of the row to be filled later. */ Colour *dst_px = (Colour *)&dst_px_ln[1]; - uint16 *dst_n = (uint16 *)&dst_n_ln[1]; + uint16_t *dst_n = (uint16_t *)&dst_n_ln[1]; - uint16 *dst_len = dst_n++; + uint16_t *dst_len = dst_n++; uint last = 3; int len = 0; for (uint x = src_orig->width; x > 0; x--) { - uint8 a = src->a; + uint8_t a = src->a; uint t = a > 0 && a < 255 ? 1 : a; if (last != t || len == 65535) { @@ -345,7 +345,7 @@ template Sprite *Blitter_32bppOptimized::EncodeInternal(const *dst_n = src->m; if (src->m != 0) { /* Get brightest value */ - uint8 rgb_max = std::max({ src->r, src->g, src->b }); + uint8_t rgb_max = std::max({ src->r, src->g, src->b }); /* Black pixel (8bpp or old 32bpp image), so use default value */ if (rgb_max == 0) rgb_max = DEFAULT_BRIGHTNESS; @@ -383,13 +383,13 @@ template Sprite *Blitter_32bppOptimized::EncodeInternal(const } dst_px = (Colour *)AlignPtr(dst_px, 4); - dst_n = (uint16 *)AlignPtr(dst_n, 4); + dst_n = (uint16_t *)AlignPtr(dst_n, 4); - *dst_px_ln = (uint8 *)dst_px - (uint8 *)dst_px_ln; - *dst_n_ln = (uint8 *)dst_n - (uint8 *)dst_n_ln; + *dst_px_ln = (uint8_t *)dst_px - (uint8_t *)dst_px_ln; + *dst_n_ln = (uint8_t *)dst_n - (uint8_t *)dst_n_ln; - dst_px_ln = (uint32 *)dst_px; - dst_n_ln = (uint32 *)dst_n; + dst_px_ln = (uint32_t *)dst_px; + dst_n_ln = (uint32_t *)dst_n; } lengths[z][0] = (byte *)dst_px_ln - (byte *)dst_px_orig[z]; // all are aligned to 4B boundary diff --git a/src/blitter/32bpp_optimized.hpp b/src/blitter/32bpp_optimized.hpp index f0de770b67..842fbb7b40 100644 --- a/src/blitter/32bpp_optimized.hpp +++ b/src/blitter/32bpp_optimized.hpp @@ -17,7 +17,7 @@ class Blitter_32bppOptimized : public Blitter_32bppSimple { public: /** Data stored about a (single) sprite. */ struct SpriteData { - uint32 offset[ZOOM_LVL_COUNT][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information. + uint32_t offset[ZOOM_LVL_COUNT][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information. byte data[]; ///< Data, all zoomlevels. }; diff --git a/src/blitter/32bpp_simple.cpp b/src/blitter/32bpp_simple.cpp index 9b57d06951..97c0a6bb2b 100644 --- a/src/blitter/32bpp_simple.cpp +++ b/src/blitter/32bpp_simple.cpp @@ -48,7 +48,7 @@ void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoo case BM_CRASH_REMAP: if (src->m == 0) { if (src->a != 0) { - uint8 g = MakeDark(src->r, src->g, src->b); + uint8_t g = MakeDark(src->r, src->g, src->b); *dst = ComposeColourRGBA(g, g, g, src->a, *dst); } } else { @@ -132,7 +132,7 @@ Sprite *Blitter_32bppSimple::Encode(const SpriteLoader::Sprite *sprite, Allocato dst[i].v = 0; } else { /* Get brightest value */ - uint8 rgb_max = std::max({src->r, src->g, src->b}); + uint8_t rgb_max = std::max({src->r, src->g, src->b}); /* Black pixel (8bpp or old 32bpp image), so use default value */ if (rgb_max == 0) rgb_max = DEFAULT_BRIGHTNESS; diff --git a/src/blitter/32bpp_simple.hpp b/src/blitter/32bpp_simple.hpp index 6437a1a5cf..9a7417d378 100644 --- a/src/blitter/32bpp_simple.hpp +++ b/src/blitter/32bpp_simple.hpp @@ -16,12 +16,12 @@ /** The most trivial 32 bpp blitter (without palette animation). */ class Blitter_32bppSimple : public Blitter_32bppBase { struct Pixel { - uint8 r; ///< Red-channel - uint8 g; ///< Green-channel - uint8 b; ///< Blue-channel - uint8 a; ///< Alpha-channel - uint8 m; ///< Remap-channel - uint8 v; ///< Brightness-channel + uint8_t r; ///< Red-channel + uint8_t g; ///< Green-channel + uint8_t b; ///< Blue-channel + uint8_t a; ///< Alpha-channel + uint8_t m; ///< Remap-channel + uint8_t v; ///< Brightness-channel }; public: void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override; diff --git a/src/blitter/32bpp_sse2.cpp b/src/blitter/32bpp_sse2.cpp index 28ba408c54..e841713b09 100644 --- a/src/blitter/32bpp_sse2.cpp +++ b/src/blitter/32bpp_sse2.cpp @@ -22,8 +22,8 @@ static FBlitter_32bppSSE2 iFBlitter_32bppSSE2; Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) { - /* First uint32 of a line = the number of transparent pixels from the left. - * Second uint32 of a line = the number of transparent pixels from the right. + /* First uint32_t of a line = the number of transparent pixels from the left. + * Second uint32_t of a line = the number of transparent pixels from the right. * Then all RGBA then all MV. */ ZoomLevel zoom_min = ZOOM_LVL_NORMAL; @@ -42,7 +42,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::Sprite *sprite, Alloca const SpriteLoader::Sprite *src_sprite = &sprite[z]; sd.infos[z].sprite_width = src_sprite->width; sd.infos[z].sprite_offset = all_sprites_size; - sd.infos[z].sprite_line_size = sizeof(Colour) * src_sprite->width + sizeof(uint32) * META_LENGTH; + sd.infos[z].sprite_line_size = sizeof(Colour) * src_sprite->width + sizeof(uint32_t) * META_LENGTH; const uint rgba_size = sd.infos[z].sprite_line_size * src_sprite->height; sd.infos[z].mv_offset = all_sprites_size + rgba_size; @@ -80,7 +80,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::Sprite *sprite, Alloca if (src->m >= PALETTE_ANIM_START) has_anim = true; /* Get brightest value (or default brightness if it's a black pixel). */ - const uint8 rgb_max = std::max({src->r, src->g, src->b}); + const uint8_t rgb_max = std::max({src->r, src->g, src->b}); dst_mv->v = (rgb_max == 0) ? Blitter_32bppBase::DEFAULT_BRIGHTNESS : rgb_max; /* Pre-convert the mapping channel to a RGB value. */ @@ -96,7 +96,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::Sprite *sprite, Alloca } } else { dst_rgba->data = 0; - *(uint16*) dst_mv = 0; + *(uint16_t*) dst_mv = 0; } dst_rgba++; dst_mv++; @@ -105,7 +105,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::Sprite *sprite, Alloca /* Count the number of transparent pixels from the left. */ dst_rgba = dst_rgba_line + META_LENGTH; - uint32 nb_pix_transp = 0; + uint32_t nb_pix_transp = 0; for (uint x = src_sprite->width; x != 0; x--) { if (dst_rgba->a == 0) nb_pix_transp++; else break; diff --git a/src/blitter/32bpp_sse2.hpp b/src/blitter/32bpp_sse2.hpp index 2921955f59..f6b505bb9e 100644 --- a/src/blitter/32bpp_sse2.hpp +++ b/src/blitter/32bpp_sse2.hpp @@ -32,8 +32,8 @@ public: virtual ~Blitter_32bppSSE_Base() = default; struct MapValue { - uint8 m; - uint8 v; + uint8_t m; + uint8_t v; }; static_assert(sizeof(MapValue) == 2); @@ -65,10 +65,10 @@ public: /** Data stored about a (single) sprite. */ struct SpriteInfo { - uint32 sprite_offset; ///< The offset to the sprite data. - uint32 mv_offset; ///< The offset to the map value data. - uint16 sprite_line_size; ///< The size of a single line (pitch). - uint16 sprite_width; ///< The width of the sprite. + uint32_t sprite_offset; ///< The offset to the sprite data. + uint32_t mv_offset; ///< The offset to the map value data. + uint16_t sprite_line_size; ///< The size of a single line (pitch). + uint16_t sprite_width; ///< The width of the sprite. }; struct SpriteData { SpriteFlags flags; diff --git a/src/blitter/32bpp_sse_func.hpp b/src/blitter/32bpp_sse_func.hpp index e8d9c05061..f0ef4ef266 100644 --- a/src/blitter/32bpp_sse_func.hpp +++ b/src/blitter/32bpp_sse_func.hpp @@ -13,7 +13,7 @@ #ifdef WITH_SSE GNU_TARGET(SSE_TARGET) -static inline void InsertFirstUint32(const uint32 value, __m128i &into) +static inline void InsertFirstUint32(const uint32_t value, __m128i &into) { #if (SSE_VERSION >= 4) into = _mm_insert_epi32(into, value, 0); @@ -24,7 +24,7 @@ static inline void InsertFirstUint32(const uint32 value, __m128i &into) } GNU_TARGET(SSE_TARGET) -static inline void InsertSecondUint32(const uint32 value, __m128i &into) +static inline void InsertSecondUint32(const uint32_t value, __m128i &into) { #if (SSE_VERSION >= 4) into = _mm_insert_epi32(into, value, 1); @@ -35,7 +35,7 @@ static inline void InsertSecondUint32(const uint32 value, __m128i &into) } GNU_TARGET(SSE_TARGET) -static inline void LoadUint64(const uint64 value, __m128i &into) +static inline void LoadUint64(const uint64_t value, __m128i &into) { #ifdef POINTER_IS_64BIT into = _mm_cvtsi64_si128(value); @@ -75,7 +75,7 @@ static inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask) GNU_TARGET(SSE_TARGET) static inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &pack_mask, const __m128i &alpha_mask) { - __m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128()); // PUNPCKLBW, expand each uint8 into uint16 + __m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128()); // PUNPCKLBW, expand each uint8_t into uint16 __m128i dstAB = _mm_unpacklo_epi8(dst, _mm_setzero_si128()); __m128i alphaMaskAB = _mm_cmpgt_epi16(srcAB, _mm_setzero_si128()); // PCMPGTW (alpha > 0) ? 0xFFFF : 0 @@ -111,19 +111,19 @@ static inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &d IGNORE_UNINITIALIZED_WARNING_START GNU_TARGET(SSE_TARGET) -static Colour ReallyAdjustBrightness(Colour colour, uint8 brightness) +static Colour ReallyAdjustBrightness(Colour colour, uint8_t brightness) { - uint64 c16 = colour.b | (uint64) colour.g << 16 | (uint64) colour.r << 32; + uint64_t c16 = colour.b | (uint64_t) colour.g << 16 | (uint64_t) colour.r << 32; c16 *= brightness; - uint64 c16_ob = c16; // Helps out of order execution. + uint64_t c16_ob = c16; // Helps out of order execution. c16 /= Blitter_32bppBase::DEFAULT_BRIGHTNESS; c16 &= 0x01FF01FF01FFULL; /* Sum overbright (maximum for each rgb is 508, 9 bits, -255 is changed in -256 so we just have to take the 8 lower bits into account). */ c16_ob = (((c16_ob >> (8 + 7)) & 0x0100010001ULL) * 0xFF) & c16; - const uint ob = ((uint16) c16_ob + (uint16) (c16_ob >> 16) + (uint16) (c16_ob >> 32)) / 2; + const uint ob = ((uint16_t) c16_ob + (uint16_t) (c16_ob >> 16) + (uint16_t) (c16_ob >> 32)) / 2; - const uint32 alpha32 = colour.data & 0xFF000000; + const uint32_t alpha32 = colour.data & 0xFF000000; __m128i ret; LoadUint64(c16, ret); if (ob != 0) { @@ -145,7 +145,7 @@ IGNORE_UNINITIALIZED_WARNING_STOP /** ReallyAdjustBrightness() is not called that often. * Inlining this function implies a far jump, which has a huge latency. */ -static inline Colour AdjustBrightneSSE(Colour colour, uint8 brightness) +static inline Colour AdjustBrightneSSE(Colour colour, uint8_t brightness) { /* Shortcut for normal brightness. */ if (brightness == Blitter_32bppBase::DEFAULT_BRIGHTNESS) return colour; @@ -154,7 +154,7 @@ static inline Colour AdjustBrightneSSE(Colour colour, uint8 brightness) } GNU_TARGET(SSE_TARGET) -static inline __m128i AdjustBrightnessOfTwoPixels(__m128i from, uint32 brightness) +static inline __m128i AdjustBrightnessOfTwoPixels(__m128i from, uint32_t brightness) { #if (SSE_VERSION < 3) NOT_REACHED(); @@ -298,7 +298,7 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel for (uint x = (uint) effective_width / 2; x > 0; x--) { __m128i srcABCD = _mm_loadl_epi64((const __m128i*) src); __m128i dstABCD = _mm_loadl_epi64((__m128i*) dst); - uint32 mvX2 = *((uint32 *) const_cast(src_mv)); + uint32_t mvX2 = *((uint32_t *) const_cast(src_mv)); /* Remap colours. */ if (mvX2 & 0x00FF00FF) { @@ -314,12 +314,12 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel m_colour = m != 0 ? m_colour : srcm; \ } #ifdef POINTER_IS_64BIT - uint64 srcs = _mm_cvtsi128_si64(srcABCD); - uint64 remapped_src = 0; + uint64_t srcs = _mm_cvtsi128_si64(srcABCD); + uint64_t remapped_src = 0; CMOV_REMAP(c0, 0, srcs, mvX2); remapped_src = c0.data; CMOV_REMAP(c1, 0, srcs >> 32, mvX2 >> 16); - remapped_src |= (uint64) c1.data << 32; + remapped_src |= (uint64_t) c1.data << 32; srcABCD = _mm_cvtsi64_si128(remapped_src); #else Colour remapped_src[2]; @@ -396,7 +396,7 @@ bmcr_alpha_blend_single: for (uint x = (uint) bp->width; x > 0; x--) { if (src_mv->m == 0) { if (src->a != 0) { - uint8 g = MakeDark(src->r, src->g, src->b); + uint8_t g = MakeDark(src->r, src->g, src->b); *dst = ComposeColourRGBA(g, g, g, src->a, *dst); } } else { diff --git a/src/blitter/32bpp_sse_type.h b/src/blitter/32bpp_sse_type.h index fe91b294be..d3a73df1c3 100644 --- a/src/blitter/32bpp_sse_type.h +++ b/src/blitter/32bpp_sse_type.h @@ -21,7 +21,7 @@ #include #endif -#define META_LENGTH 2 ///< Number of uint32 inserted before each line of pixels in a sprite. +#define META_LENGTH 2 ///< Number of uint32_t inserted before each line of pixels in a sprite. #define MARGIN_NORMAL_THRESHOLD (zoom == ZOOM_LVL_OUT_32X ? 8 : 4) ///< Minimum width to use margins with BM_NORMAL. #define MARGIN_REMAP_THRESHOLD 4 ///< Minimum width to use margins with BM_COLOUR_REMAP. @@ -35,10 +35,10 @@ typedef union ALIGN(16) um128i { __m128i m128i; - uint8 m128i_u8[16]; - uint16 m128i_u16[8]; - uint32 m128i_u32[4]; - uint64 m128i_u64[2]; + uint8_t m128i_u8[16]; + uint16_t m128i_u16[8]; + uint32_t m128i_u32[4]; + uint64_t m128i_u64[2]; } um128i; #define CLEAR_HIGH_BYTE_MASK _mm_setr_epi8(-1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0) diff --git a/src/blitter/40bpp_anim.cpp b/src/blitter/40bpp_anim.cpp index b4352492ee..4503ccb26f 100644 --- a/src/blitter/40bpp_anim.cpp +++ b/src/blitter/40bpp_anim.cpp @@ -26,7 +26,7 @@ static FBlitter_40bppAnim iFBlitter_40bppAnim; static const Colour _black_colour(0, 0, 0); -void Blitter_40bppAnim::SetPixel(void *video, int x, int y, uint8 colour) +void Blitter_40bppAnim::SetPixel(void *video, int x, int y, uint8_t colour) { if (_screen_disable_anim) { Blitter_32bppOptimized::SetPixel(video, x, y, colour); @@ -34,11 +34,11 @@ void Blitter_40bppAnim::SetPixel(void *video, int x, int y, uint8 colour) size_t y_offset = static_cast(y) * _screen.pitch; *((Colour *)video + x + y_offset) = _black_colour; - VideoDriver::GetInstance()->GetAnimBuffer()[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y_offset] = colour; + VideoDriver::GetInstance()->GetAnimBuffer()[((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + x + y_offset] = colour; } } -void Blitter_40bppAnim::DrawRect(void *video, int width, int height, uint8 colour) +void Blitter_40bppAnim::DrawRect(void *video, int width, int height, uint8_t colour) { if (_screen_disable_anim) { /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */ @@ -47,11 +47,11 @@ void Blitter_40bppAnim::DrawRect(void *video, int width, int height, uint8 colou } assert(VideoDriver::GetInstance()->GetAnimBuffer() != nullptr); - uint8 *anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer(); + uint8_t *anim_line = ((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer(); do { Colour *dst = (Colour *)video; - uint8 *anim = anim_line; + uint8_t *anim = anim_line; for (int i = width; i > 0; i--) { *dst = _black_colour; @@ -59,12 +59,12 @@ void Blitter_40bppAnim::DrawRect(void *video, int width, int height, uint8 colou dst++; anim++; } - video = (uint32 *)video + _screen.pitch; + video = (uint32_t *)video + _screen.pitch; anim_line += _screen.pitch; } while (--height); } -void Blitter_40bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) +void Blitter_40bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash) { if (_screen_disable_anim) { /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */ @@ -73,7 +73,7 @@ void Blitter_40bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int } assert(VideoDriver::GetInstance()->GetAnimBuffer() != nullptr); - uint8 *anim = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer(); + uint8_t *anim = ((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer(); this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](int x, int y) { *((Colour *)video + x + y * _screen.pitch) = _black_colour; @@ -93,24 +93,24 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel { const SpriteData *src = (const SpriteData *)bp->sprite; - /* src_px : each line begins with uint32 n = 'number of bytes in this line', + /* src_px : each line begins with uint32_t n = 'number of bytes in this line', * then n times is the Colour struct for this line */ const Colour *src_px = (const Colour *)(src->data + src->offset[zoom][0]); - /* src_n : each line begins with uint32 n = 'number of bytes in this line', + /* src_n : each line begins with uint32_t n = 'number of bytes in this line', * then interleaved stream of 'm' and 'n' channels. 'm' is remap, * 'n' is number of bytes with the same alpha channel class */ - const uint16 *src_n = (const uint16 *)(src->data + src->offset[zoom][1]); + const uint16_t *src_n = (const uint16_t *)(src->data + src->offset[zoom][1]); /* skip upper lines in src_px and src_n */ for (uint i = bp->skip_top; i != 0; i--) { - src_px = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px); - src_n = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n); + src_px = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px); + src_n = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n); } /* skip lines in dst */ Colour *dst = (Colour *)bp->dst + bp->top * bp->pitch + bp->left; assert(VideoDriver::GetInstance()->GetAnimBuffer() != nullptr); - uint8 *anim = VideoDriver::GetInstance()->GetAnimBuffer() + ((uint32 *)bp->dst - (uint32 *)_screen.dst_ptr) + bp->top * bp->pitch + bp->left; + uint8_t *anim = VideoDriver::GetInstance()->GetAnimBuffer() + ((uint32_t *)bp->dst - (uint32_t *)_screen.dst_ptr) + bp->top * bp->pitch + bp->left; /* store so we don't have to access it via bp everytime (compiler assumes pointer aliasing) */ const byte *remap = bp->remap; @@ -118,14 +118,14 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel for (int y = 0; y < bp->height; y++) { /* next dst line begins here */ Colour *dst_ln = dst + bp->pitch; - uint8 *anim_ln = anim + bp->pitch; + uint8_t *anim_ln = anim + bp->pitch; /* next src line begins here */ - const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px); + const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32_t *)src_px); src_px++; /* next src_n line begins here */ - const uint16 *src_n_ln = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n); + const uint16_t *src_n_ln = (const uint16_t *)((const byte *)src_n + *(const uint32_t *)src_n); src_n += 2; /* we will end this line when we reach this point */ @@ -184,7 +184,7 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel case BM_CRASH_REMAP: if (src_px->a == 255) { do { - uint8 m = GB(*src_n, 0, 8); + uint8_t m = GB(*src_n, 0, 8); /* In case the m-channel is zero, only apply the crash remap by darkening the RGB colour. */ if (m == 0) { *dst = mode == BM_CRASH_REMAP ? this->MakeDark(*src_px) : *src_px; @@ -203,7 +203,7 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel } while (--n != 0); } else { do { - uint8 m = GB(*src_n, 0, 8); + uint8_t m = GB(*src_n, 0, 8); Colour b = this->RealizeBlendedColour(*anim, *dst); if (m == 0) { Colour c = mode == BM_CRASH_REMAP ? this->MakeDark(*src_px) : *src_px; @@ -274,7 +274,7 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel break; } else { do { - uint8 m = GB(*src_n, 0, 8); + uint8_t m = GB(*src_n, 0, 8); Colour b = this->RealizeBlendedColour(*anim, *dst); if (m == 0) { @@ -337,7 +337,7 @@ void Blitter_40bppAnim::DrawColourMappingRect(void *dst, int width, int height, } Colour *udst = (Colour *)dst; - uint8 *anim = VideoDriver::GetInstance()->GetAnimBuffer() + ((uint32 *)dst - (uint32 *)_screen.dst_ptr); + uint8_t *anim = VideoDriver::GetInstance()->GetAnimBuffer() + ((uint32_t *)dst - (uint32_t *)_screen.dst_ptr); if (pal == PALETTE_TO_TRANSPARENT) { /* If the anim buffer contains a color value, the image composition will @@ -354,7 +354,7 @@ void Blitter_40bppAnim::DrawColourMappingRect(void *dst, int width, int height, anim = anim - width + _screen.pitch; } while (--height); } else if (pal == PALETTE_NEWSPAPER) { - const uint8 *remap = GetNonSprite(pal, SpriteType::Recolour) + 1; + const uint8_t *remap = GetNonSprite(pal, SpriteType::Recolour) + 1; do { for (int i = 0; i != width; i++) { if (*anim == 0) *udst = MakeGrey(*udst); @@ -366,7 +366,7 @@ void Blitter_40bppAnim::DrawColourMappingRect(void *dst, int width, int height, anim = anim - width + _screen.pitch; } while (--height); } else { - const uint8 *remap = GetNonSprite(pal, SpriteType::Recolour) + 1; + const uint8_t *remap = GetNonSprite(pal, SpriteType::Recolour) + 1; do { for (int i = 0; i != width; i++) { *anim = remap[*anim]; @@ -386,21 +386,21 @@ Sprite *Blitter_40bppAnim::Encode(const SpriteLoader::Sprite *sprite, AllocatorP void Blitter_40bppAnim::CopyFromBuffer(void *video, const void *src, int width, int height) { assert(!_screen_disable_anim); - assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); - uint32 *dst = (uint32 *)video; - const uint32 *usrc = (const uint32 *)src; + assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); + uint32_t *dst = (uint32_t *)video; + const uint32_t *usrc = (const uint32_t *)src; - uint8 *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer(); + uint8_t *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer(); if (anim_buf == nullptr) return; - uint8 *anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + anim_buf; + uint8_t *anim_line = ((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + anim_buf; for (; height > 0; height--) { - memcpy(dst, usrc, width * sizeof(uint32)); + memcpy(dst, usrc, width * sizeof(uint32_t)); usrc += width; dst += _screen.pitch; /* Copy back the anim-buffer */ - memcpy(anim_line, usrc, width * sizeof(uint8)); - usrc = (const uint32 *)((const uint8 *)usrc + width); + memcpy(anim_line, usrc, width * sizeof(uint8_t)); + usrc = (const uint32_t *)((const uint8_t *)usrc + width); anim_line += _screen.pitch; } } @@ -408,36 +408,36 @@ void Blitter_40bppAnim::CopyFromBuffer(void *video, const void *src, int width, void Blitter_40bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height) { assert(!_screen_disable_anim); - assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); - uint32 *udst = (uint32 *)dst; - const uint32 *src = (const uint32 *)video; + assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); + uint32_t *udst = (uint32_t *)dst; + const uint32_t *src = (const uint32_t *)video; - uint8 *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer(); + uint8_t *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer(); if (anim_buf == nullptr) return; - const uint8 *anim_line = ((const uint32 *)video - (uint32 *)_screen.dst_ptr) + anim_buf; + const uint8_t *anim_line = ((const uint32_t *)video - (uint32_t *)_screen.dst_ptr) + anim_buf; for (; height > 0; height--) { - memcpy(udst, src, width * sizeof(uint32)); + memcpy(udst, src, width * sizeof(uint32_t)); src += _screen.pitch; udst += width; /* Copy the anim-buffer */ - memcpy(udst, anim_line, width * sizeof(uint8)); - udst = (uint32 *)((uint8 *)udst + width); + memcpy(udst, anim_line, width * sizeof(uint8_t)); + udst = (uint32_t *)((uint8_t *)udst + width); anim_line += _screen.pitch; } } void Blitter_40bppAnim::CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) { - uint8 *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer(); + uint8_t *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer(); if (anim_buf == nullptr) { Blitter_32bppOptimized::CopyImageToBuffer(video, dst, width, height, dst_pitch); return; } - uint32 *udst = (uint32 *)dst; - const uint32 *src = (const uint32 *)video; - const uint8 *anim_line = ((const uint32 *)video - (uint32 *)_screen.dst_ptr) + anim_buf; + uint32_t *udst = (uint32_t *)dst; + const uint32_t *src = (const uint32_t *)video; + const uint8_t *anim_line = ((const uint32_t *)video - (uint32_t *)_screen.dst_ptr) + anim_buf; for (; height > 0; height--) { for (int x = 0; x < width; x++) { @@ -452,9 +452,9 @@ void Blitter_40bppAnim::CopyImageToBuffer(const void *video, void *dst, int widt void Blitter_40bppAnim::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) { assert(!_screen_disable_anim); - assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); - uint8 *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer(); - uint8 *dst, *src; + assert(video >= _screen.dst_ptr && video <= (uint32_t *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch); + uint8_t *anim_buf = VideoDriver::GetInstance()->GetAnimBuffer(); + uint8_t *dst, *src; /* We need to scroll the anim-buffer too */ if (scroll_y > 0) { @@ -471,7 +471,7 @@ void Blitter_40bppAnim::ScrollBuffer(void *video, int &left, int &top, int &widt uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x); uint th = height - scroll_y; for (; th > 0; th--) { - memcpy(dst, src, tw * sizeof(uint8)); + memcpy(dst, src, tw * sizeof(uint8_t)); src -= _screen.pitch; dst -= _screen.pitch; } @@ -492,7 +492,7 @@ void Blitter_40bppAnim::ScrollBuffer(void *video, int &left, int &top, int &widt uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x); uint th = height + scroll_y; for (; th > 0; th--) { - memmove(dst, src, tw * sizeof(uint8)); + memmove(dst, src, tw * sizeof(uint8_t)); src += _screen.pitch; dst += _screen.pitch; } @@ -503,7 +503,7 @@ void Blitter_40bppAnim::ScrollBuffer(void *video, int &left, int &top, int &widt size_t Blitter_40bppAnim::BufferSize(uint width, uint height) { - return (sizeof(uint32) + sizeof(uint8)) * width * height; + return (sizeof(uint32_t) + sizeof(uint8_t)) * width * height; } Blitter::PaletteAnimation Blitter_40bppAnim::UsePaletteAnimation() diff --git a/src/blitter/40bpp_anim.hpp b/src/blitter/40bpp_anim.hpp index c530889f49..ecc7eb110d 100644 --- a/src/blitter/40bpp_anim.hpp +++ b/src/blitter/40bpp_anim.hpp @@ -18,9 +18,9 @@ class Blitter_40bppAnim : public Blitter_32bppOptimized { public: - void SetPixel(void *video, int x, int y, uint8 colour) override; - void DrawRect(void *video, int width, int height, uint8 colour) override; - void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override; + void SetPixel(void *video, int x, int y, uint8_t colour) override; + void DrawRect(void *video, int width, int height, uint8_t colour) override; + void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash) override; void CopyFromBuffer(void *video, const void *src, int width, int height) override; void CopyToBuffer(const void *video, void *dst, int width, int height) override; void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override; @@ -38,7 +38,7 @@ public: template void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom); protected: - static inline Colour RealizeBlendedColour(uint8 anim, Colour c) + static inline Colour RealizeBlendedColour(uint8_t anim, Colour c) { return anim != 0 ? AdjustBrightness(LookupColourInPalette(anim), GetColourBrightness(c)) : c; } diff --git a/src/blitter/8bpp_base.cpp b/src/blitter/8bpp_base.cpp index c0d1f8c377..ab6f0057c9 100644 --- a/src/blitter/8bpp_base.cpp +++ b/src/blitter/8bpp_base.cpp @@ -16,46 +16,46 @@ void Blitter_8bppBase::DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) { - const uint8 *ctab = GetNonSprite(pal, SpriteType::Recolour) + 1; + const uint8_t *ctab = GetNonSprite(pal, SpriteType::Recolour) + 1; do { - for (int i = 0; i != width; i++) *((uint8 *)dst + i) = ctab[((uint8 *)dst)[i]]; - dst = (uint8 *)dst + _screen.pitch; + for (int i = 0; i != width; i++) *((uint8_t *)dst + i) = ctab[((uint8_t *)dst)[i]]; + dst = (uint8_t *)dst + _screen.pitch; } while (--height); } void *Blitter_8bppBase::MoveTo(void *video, int x, int y) { - return (uint8 *)video + x + y * _screen.pitch; + return (uint8_t *)video + x + y * _screen.pitch; } -void Blitter_8bppBase::SetPixel(void *video, int x, int y, uint8 colour) +void Blitter_8bppBase::SetPixel(void *video, int x, int y, uint8_t colour) { - *((uint8 *)video + x + y * _screen.pitch) = colour; + *((uint8_t *)video + x + y * _screen.pitch) = colour; } -void Blitter_8bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) +void Blitter_8bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash) { this->DrawLineGeneric(x, y, x2, y2, screen_width, screen_height, width, dash, [=](int x, int y) { - *((uint8 *)video + x + y * _screen.pitch) = colour; + *((uint8_t *)video + x + y * _screen.pitch) = colour; }); } -void Blitter_8bppBase::DrawRect(void *video, int width, int height, uint8 colour) +void Blitter_8bppBase::DrawRect(void *video, int width, int height, uint8_t colour) { do { memset(video, colour, width); - video = (uint8 *)video + _screen.pitch; + video = (uint8_t *)video + _screen.pitch; } while (--height); } void Blitter_8bppBase::CopyFromBuffer(void *video, const void *src, int width, int height) { - uint8 *dst = (uint8 *)video; - const uint8 *usrc = (const uint8 *)src; + uint8_t *dst = (uint8_t *)video; + const uint8_t *usrc = (const uint8_t *)src; for (; height > 0; height--) { - memcpy(dst, usrc, width * sizeof(uint8)); + memcpy(dst, usrc, width * sizeof(uint8_t)); usrc += width; dst += _screen.pitch; } @@ -63,11 +63,11 @@ void Blitter_8bppBase::CopyFromBuffer(void *video, const void *src, int width, i void Blitter_8bppBase::CopyToBuffer(const void *video, void *dst, int width, int height) { - uint8 *udst = (uint8 *)dst; - const uint8 *src = (const uint8 *)video; + uint8_t *udst = (uint8_t *)dst; + const uint8_t *src = (const uint8_t *)video; for (; height > 0; height--) { - memcpy(udst, src, width * sizeof(uint8)); + memcpy(udst, src, width * sizeof(uint8_t)); src += _screen.pitch; udst += width; } @@ -75,11 +75,11 @@ void Blitter_8bppBase::CopyToBuffer(const void *video, void *dst, int width, int void Blitter_8bppBase::CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) { - uint8 *udst = (uint8 *)dst; - const uint8 *src = (const uint8 *)video; + uint8_t *udst = (uint8_t *)dst; + const uint8_t *src = (const uint8_t *)video; for (; height > 0; height--) { - memcpy(udst, src, width * sizeof(uint8)); + memcpy(udst, src, width * sizeof(uint8_t)); src += _screen.pitch; udst += dst_pitch; } @@ -87,12 +87,12 @@ void Blitter_8bppBase::CopyImageToBuffer(const void *video, void *dst, int width void Blitter_8bppBase::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y) { - const uint8 *src; - uint8 *dst; + const uint8_t *src; + uint8_t *dst; if (scroll_y > 0) { /* Calculate pointers */ - dst = (uint8 *)video + left + (top + height - 1) * _screen.pitch; + dst = (uint8_t *)video + left + (top + height - 1) * _screen.pitch; src = dst - scroll_y * _screen.pitch; /* Decrease height and increase top */ @@ -111,13 +111,13 @@ void Blitter_8bppBase::ScrollBuffer(void *video, int &left, int &top, int &width } for (int h = height; h > 0; h--) { - memcpy(dst, src, width * sizeof(uint8)); + memcpy(dst, src, width * sizeof(uint8_t)); src -= _screen.pitch; dst -= _screen.pitch; } } else { /* Calculate pointers */ - dst = (uint8 *)video + left + top * _screen.pitch; + dst = (uint8_t *)video + left + top * _screen.pitch; src = dst - scroll_y * _screen.pitch; /* Decrease height. (scroll_y is <=0). */ @@ -137,7 +137,7 @@ void Blitter_8bppBase::ScrollBuffer(void *video, int &left, int &top, int &width /* the y-displacement may be 0 therefore we have to use memmove, * because source and destination may overlap */ for (int h = height; h > 0; h--) { - memmove(dst, src, width * sizeof(uint8)); + memmove(dst, src, width * sizeof(uint8_t)); src += _screen.pitch; dst += _screen.pitch; } diff --git a/src/blitter/8bpp_base.hpp b/src/blitter/8bpp_base.hpp index 8bbbc3a9ee..1d29333984 100644 --- a/src/blitter/8bpp_base.hpp +++ b/src/blitter/8bpp_base.hpp @@ -15,12 +15,12 @@ /** Base for all 8bpp blitters. */ class Blitter_8bppBase : public Blitter { public: - uint8 GetScreenDepth() override { return 8; } + uint8_t GetScreenDepth() override { return 8; } void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override; void *MoveTo(void *video, int x, int y) override; - void SetPixel(void *video, int x, int y, uint8 colour) override; - void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override; - void DrawRect(void *video, int width, int height, uint8 colour) override; + void SetPixel(void *video, int x, int y, uint8_t colour) override; + void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash) override; + void DrawRect(void *video, int width, int height, uint8_t colour) override; void CopyFromBuffer(void *video, const void *src, int width, int height) override; void CopyToBuffer(const void *video, void *dst, int width, int height) override; void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override; diff --git a/src/blitter/8bpp_optimized.cpp b/src/blitter/8bpp_optimized.cpp index 669a392e28..bfc03f26c8 100644 --- a/src/blitter/8bpp_optimized.cpp +++ b/src/blitter/8bpp_optimized.cpp @@ -26,8 +26,8 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z uint offset = sprite_src->offset[zoom]; /* Find where to start reading in the source sprite */ - const uint8 *src = sprite_src->data + offset; - uint8 *dst_line = (uint8 *)bp->dst + bp->top * bp->pitch + bp->left; + const uint8_t *src = sprite_src->data + offset; + uint8_t *dst_line = (uint8_t *)bp->dst + bp->top * bp->pitch + bp->left; /* Skip over the top lines in the source image */ for (int y = 0; y < bp->skip_top; y++) { @@ -39,10 +39,10 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z } } - const uint8 *src_next = src; + const uint8_t *src_next = src; for (int y = 0; y < bp->height; y++) { - uint8 *dst = dst_line; + uint8_t *dst = dst_line; dst_line += bp->pitch; uint skip_left = bp->skip_left; @@ -86,7 +86,7 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z switch (mode) { case BM_COLOUR_REMAP: case BM_CRASH_REMAP: { - const uint8 *remap = bp->remap; + const uint8_t *remap = bp->remap; do { uint m = remap[*src]; if (m != 0) *dst = m; @@ -101,7 +101,7 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z break; case BM_TRANSPARENT: { - const uint8 *remap = bp->remap; + const uint8_t *remap = bp->remap; src += pixels; do { *dst = remap[*dst]; diff --git a/src/blitter/8bpp_optimized.hpp b/src/blitter/8bpp_optimized.hpp index a305c954da..5f2c2f39a3 100644 --- a/src/blitter/8bpp_optimized.hpp +++ b/src/blitter/8bpp_optimized.hpp @@ -18,7 +18,7 @@ class Blitter_8bppOptimized FINAL : public Blitter_8bppBase { public: /** Data stored about a (single) sprite. */ struct SpriteData { - uint32 offset[ZOOM_LVL_COUNT]; ///< Offsets (from .data) to streams for different zoom levels. + uint32_t offset[ZOOM_LVL_COUNT]; ///< Offsets (from .data) to streams for different zoom levels. byte data[]; ///< Data, all zoomlevels. }; diff --git a/src/blitter/8bpp_simple.cpp b/src/blitter/8bpp_simple.cpp index d40530536e..a6a556a3c7 100644 --- a/src/blitter/8bpp_simple.cpp +++ b/src/blitter/8bpp_simple.cpp @@ -18,12 +18,12 @@ static FBlitter_8bppSimple iFBlitter_8bppSimple; void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) { - const uint8 *src, *src_line; - uint8 *dst, *dst_line; + const uint8_t *src, *src_line; + uint8_t *dst, *dst_line; /* Find where to start reading in the source sprite */ - src_line = (const uint8 *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom); - dst_line = (uint8 *)bp->dst + bp->top * bp->pitch + bp->left; + src_line = (const uint8_t *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom); + dst_line = (uint8_t *)bp->dst + bp->top * bp->pitch + bp->left; for (int y = 0; y < bp->height; y++) { dst = dst_line; diff --git a/src/blitter/base.hpp b/src/blitter/base.hpp index 0a90f6c661..1555d040f1 100644 --- a/src/blitter/base.hpp +++ b/src/blitter/base.hpp @@ -56,7 +56,7 @@ public: * Get the screen depth this blitter works for. * This is either: 8, 16, 24 or 32. */ - virtual uint8 GetScreenDepth() = 0; + virtual uint8_t GetScreenDepth() = 0; bool Is32BppSupported() override { @@ -96,7 +96,7 @@ public: * @param y The y position within video-buffer. * @param colour A 8bpp mapping colour. */ - virtual void SetPixel(void *video, int x, int y, uint8 colour) = 0; + virtual void SetPixel(void *video, int x, int y, uint8_t colour) = 0; /** * Make a single horizontal line in a single colour on the video-buffer. @@ -105,7 +105,7 @@ public: * @param height The height of the line. * @param colour A 8bpp mapping colour. */ - virtual void DrawRect(void *video, int width, int height, uint8 colour) = 0; + virtual void DrawRect(void *video, int width, int height, uint8_t colour) = 0; /** * Draw a line with a given colour. @@ -120,7 +120,7 @@ public: * @param width Line width. * @param dash Length of dashes for dashed lines. 0 means solid line. */ - virtual void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash = 0) = 0; + virtual void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash = 0) = 0; /** * Copy from a buffer to the screen. diff --git a/src/blitter/common.hpp b/src/blitter/common.hpp index cd3b6276a4..eebdfc05e7 100644 --- a/src/blitter/common.hpp +++ b/src/blitter/common.hpp @@ -50,11 +50,11 @@ void Blitter::DrawLineGeneric(int x1, int y1, int x2, int y2, int screen_width, /* compute frac_diff = width * sqrt(dx*dx + dy*dy) * Start interval: * max(dx, dy) <= sqrt(dx*dx + dy*dy) <= sqrt(2) * max(dx, dy) <= 3/2 * max(dx, dy) */ - int64 frac_sq = ((int64) width) * ((int64) width) * (((int64) dx) * ((int64) dx) + ((int64) dy) * ((int64) dy)); + int64_t frac_sq = ((int64_t) width) * ((int64_t) width) * (((int64_t) dx) * ((int64_t) dx) + ((int64_t) dy) * ((int64_t) dy)); int frac_max = 3 * frac_diff / 2; while (frac_diff < frac_max) { int frac_test = (frac_diff + frac_max) / 2; - if (((int64) frac_test) * ((int64) frac_test) < frac_sq) { + if (((int64_t) frac_test) * ((int64_t) frac_test) < frac_sq) { frac_diff = frac_test + 1; } else { frac_max = frac_test - 1; @@ -89,8 +89,8 @@ void Blitter::DrawLineGeneric(int x1, int y1, int x2, int y2, int screen_width, if (x1 < 0) { dash_count = (-x1) % (dash + gap); - auto adjust_frac = [&](int64 frac, int &y_bound) -> int { - frac -= ((int64) dy) * ((int64) x1); + auto adjust_frac = [&](int64_t frac, int &y_bound) -> int { + frac -= ((int64_t) dy) * ((int64_t) x1); if (frac >= 0) { int quotient = frac / dx; int remainder = frac % dx; @@ -151,8 +151,8 @@ void Blitter::DrawLineGeneric(int x1, int y1, int x2, int y2, int screen_width, if (y1 < 0) { dash_count = (-y1) % (dash + gap); - auto adjust_frac = [&](int64 frac, int &x_bound) -> int { - frac -= ((int64) dx) * ((int64) y1); + auto adjust_frac = [&](int64_t frac, int &x_bound) -> int { + frac -= ((int64_t) dx) * ((int64_t) y1); if (frac >= 0) { int quotient = frac / dy; int remainder = frac % dy; diff --git a/src/blitter/null.hpp b/src/blitter/null.hpp index 9810a7b51a..9eec944708 100644 --- a/src/blitter/null.hpp +++ b/src/blitter/null.hpp @@ -15,14 +15,14 @@ /** Blitter that does nothing. */ class Blitter_Null : public Blitter { public: - uint8 GetScreenDepth() override { return 0; } + uint8_t GetScreenDepth() override { return 0; } void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override {}; void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override {}; Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) override; void *MoveTo(void *video, int x, int y) override { return nullptr; }; - void SetPixel(void *video, int x, int y, uint8 colour) override {}; - void DrawRect(void *video, int width, int height, uint8 colour) override {}; - void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash) override {}; + void SetPixel(void *video, int x, int y, uint8_t colour) override {}; + void DrawRect(void *video, int width, int height, uint8_t colour) override {}; + void DrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash) override {}; void CopyFromBuffer(void *video, const void *src, int width, int height) override {}; void CopyToBuffer(const void *video, void *dst, int width, int height) override {}; void CopyImageToBuffer(const void *video, void *dst, int width, int height, int dst_pitch) override {}; diff --git a/src/bmp.cpp b/src/bmp.cpp index 70e86ee014..eca61335dd 100644 --- a/src/bmp.cpp +++ b/src/bmp.cpp @@ -48,15 +48,15 @@ static inline byte ReadByte(BmpBuffer *buffer) return buffer->data[buffer->pos++]; } -static inline uint16 ReadWord(BmpBuffer *buffer) +static inline uint16_t ReadWord(BmpBuffer *buffer) { - uint16 var = ReadByte(buffer); + uint16_t var = ReadByte(buffer); return var | (ReadByte(buffer) << 8); } -static inline uint32 ReadDword(BmpBuffer *buffer) +static inline uint32_t ReadDword(BmpBuffer *buffer) { - uint32 var = ReadWord(buffer); + uint32_t var = ReadWord(buffer); return var | (ReadWord(buffer) << 16); } @@ -316,7 +316,7 @@ static inline bool BmpRead24(BmpBuffer *buffer, BmpInfo *info, BmpData *data) */ bool BmpReadHeader(BmpBuffer *buffer, BmpInfo *info, BmpData *data) { - uint32 header_size; + uint32_t header_size; assert(info != nullptr); MemSetT(info, 0); diff --git a/src/bmp.h b/src/bmp.h index 3d5ded2a16..9b7289e4d1 100644 --- a/src/bmp.h +++ b/src/bmp.h @@ -13,13 +13,13 @@ #include "gfx_type.h" struct BmpInfo { - uint32 offset; ///< offset of bitmap data from .bmp file beginning - uint32 width; ///< bitmap width - uint32 height; ///< bitmap height + uint32_t offset; ///< offset of bitmap data from .bmp file beginning + uint32_t width; ///< bitmap width + uint32_t height; ///< bitmap height bool os2_bmp; ///< true if OS/2 1.x or windows 2.x bitmap - uint16 bpp; ///< bits per pixel - uint32 compression; ///< compression method (0 = none, 1 = 8-bit RLE, 2 = 4-bit RLE) - uint32 palette_size; ///< number of colours in palette + uint16_t bpp; ///< bits per pixel + uint32_t compression; ///< compression method (0 = none, 1 = 8-bit RLE, 2 = 4-bit RLE) + uint32_t palette_size; ///< number of colours in palette }; struct BmpData { diff --git a/src/bridge.h b/src/bridge.h index 414c24f452..bec4a522e0 100644 --- a/src/bridge.h +++ b/src/bridge.h @@ -42,9 +42,9 @@ typedef uint BridgeType; ///< Bridge spec number. struct BridgeSpec { TimerGameCalendar::Year avail_year; ///< the year where it becomes available byte min_length; ///< the minimum length (not counting start and end tile) - uint16 max_length; ///< the maximum length (not counting start and end tile) - uint16 price; ///< the price multiplier - uint16 speed; ///< maximum travel speed (1 unit = 1/1.6 mph = 1 km-ish/h) + uint16_t max_length; ///< the maximum length (not counting start and end tile) + uint16_t price; ///< the price multiplier + uint16_t speed; ///< maximum travel speed (1 unit = 1/1.6 mph = 1 km-ish/h) SpriteID sprite; ///< the sprite which is used in the GUI PaletteID pal; ///< the palette which is used in the GUI StringID material; ///< the string that contains the bridge description diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index e2a251f8f2..491b55846a 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -214,7 +214,7 @@ public: } } - Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override + Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override { /* Position the window so hopefully the first bridge from the list is under the mouse pointer. */ NWidgetBase *list = this->GetWidget(WID_BBS_BRIDGE_LIST); @@ -245,9 +245,9 @@ public: } } - EventState OnKeyPress(WChar key, uint16 keycode) override + EventState OnKeyPress(char32_t key, uint16_t keycode) override { - const uint8 i = keycode - '1'; + const uint8_t i = keycode - '1'; if (i < 9 && i < this->bridges.size()) { /* Build the requested bridge */ this->BuildBridge(this->bridges[i].index); @@ -432,7 +432,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo item.spec = GetBridgeSpec(brd_type); /* Add to terraforming & bulldozing costs the cost of the * bridge itself (not computed with DC_QUERY_COST) */ - item.cost = ret.GetCost() + (((int64)tot_bridgedata_len * _price[PR_BUILD_BRIDGE] * item.spec->price) >> 8) + infra_cost; + item.cost = ret.GetCost() + (((int64_t)tot_bridgedata_len * _price[PR_BUILD_BRIDGE] * item.spec->price) >> 8) + infra_cost; any_available = true; } } diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 8bbf899901..af2cccec3b 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -401,7 +401,7 @@ static bool AircraftEngineCargoSorter(const GUIEngineListItem &a, const GUIEngin const Engine *e_a = Engine::Get(a.engine_id); const Engine *e_b = Engine::Get(b.engine_id); - uint16 mail_a, mail_b; + uint16_t mail_a, mail_b; int va = e_a->GetDisplayDefaultCapacity(&mail_a); int vb = e_b->GetDisplayDefaultCapacity(&mail_b); int r = va - vb; @@ -426,8 +426,8 @@ static bool AircraftEngineCargoSorter(const GUIEngineListItem &a, const GUIEngin */ static bool AircraftRangeSorter(const GUIEngineListItem &a, const GUIEngineListItem &b) { - uint16 r_a = Engine::Get(a.engine_id)->GetRange(); - uint16 r_b = Engine::Get(b.engine_id)->GetRange(); + uint16_t r_a = Engine::Get(a.engine_id)->GetRange(); + uint16_t r_b = Engine::Get(b.engine_id)->GetRange(); int r = r_a - r_b; @@ -697,7 +697,7 @@ static int DrawRoadVehPurchaseInfo(int left, int right, int y, EngineID engine_n y += FONT_HEIGHT_NORMAL; /* Road vehicle weight - (including cargo) */ - int16 weight = e->GetDisplayWeight(); + int16_t weight = e->GetDisplayWeight(); SetDParam(0, weight); SetDParam(1, GetCargoWeight(te.all_capacities, VEH_ROAD) + weight); DrawString(left, right, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT); @@ -847,7 +847,7 @@ static int DrawAircraftPurchaseInfo(int left, int right, int y, EngineID engine_ y += FONT_HEIGHT_NORMAL; /* Aircraft range, if available. */ - uint16 range = e->GetRange(); + uint16_t range = e->GetRange(); if (range != 0) { SetDParam(0, range); DrawString(left, right, y, STR_PURCHASE_INFO_AIRCRAFT_RANGE); @@ -865,7 +865,7 @@ static int DrawAircraftPurchaseInfo(int left, int right, int y, EngineID engine_ */ static std::optional GetNewGRFAdditionalText(EngineID engine) { - uint16 callback = GetVehicleCallback(CBID_VEHICLE_ADDITIONAL_TEXT, 0, 0, engine, nullptr); + uint16_t callback = GetVehicleCallback(CBID_VEHICLE_ADDITIONAL_TEXT, 0, 0, engine, nullptr); if (callback == CALLBACK_FAILED || callback == 0x400) return std::nullopt; const GRFFile *grffile = Engine::Get(engine)->GetGRF(); assert(grffile != nullptr); @@ -1004,7 +1004,7 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number, * @param show_count Whether to show the amount of engines or not * @param selected_group the group to list the engines of */ -void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_list, uint16 min, uint16 max, EngineID selected_id, bool show_count, GroupID selected_group) +void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_list, uint16_t min, uint16_t max, EngineID selected_id, bool show_count, GroupID selected_group) { static const int sprite_y_offsets[] = { -1, -1, -2, -2 }; @@ -1093,7 +1093,7 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_li */ void DisplayVehicleSortDropDown(Window *w, VehicleType vehicle_type, int selected, int button) { - uint32 hidden_mask = 0; + uint32_t hidden_mask = 0; /* Disable sorting by power or tractive effort when the original acceleration model for road vehicles is being used. */ if (vehicle_type == VEH_ROAD && _settings_game.vehicle.roadveh_acceleration_model == AM_ORIGINAL) { SetBit(hidden_mask, 3); // power @@ -1770,7 +1770,7 @@ struct BuildVehicleWindow : Window { r, this->eng_list, this->vscroll->GetPosition(), - static_cast(std::min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->eng_list.size())), + static_cast(std::min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->eng_list.size())), this->sel_engine, false, DEFAULT_GROUP diff --git a/src/cargo_type.h b/src/cargo_type.h index 3944909518..f9f8550b95 100644 --- a/src/cargo_type.h +++ b/src/cargo_type.h @@ -74,7 +74,7 @@ inline bool IsValidCargoType(CargoType t) { return t != CT_INVALID; } /** Test whether cargo type is not CT_INVALID */ inline bool IsValidCargoID(CargoID t) { return t != CT_INVALID; } -typedef uint64 CargoTypes; +typedef uint64_t CargoTypes; static const CargoTypes ALL_CARGOTYPES = (CargoTypes)UINT64_MAX; @@ -108,7 +108,7 @@ enum class SourceType : byte { Headquarters, ///< Source/destination are company headquarters }; -typedef uint16 SourceID; ///< Contains either industry ID, town ID or company ID (or INVALID_SOURCE) +typedef uint16_t SourceID; ///< Contains either industry ID, town ID or company ID (or INVALID_SOURCE) static const SourceID INVALID_SOURCE = 0xFFFF; ///< Invalid/unknown index of source #endif /* CARGO_TYPE_H */ diff --git a/src/cargomonitor.cpp b/src/cargomonitor.cpp index 993447a970..dc5ab7643f 100644 --- a/src/cargomonitor.cpp +++ b/src/cargomonitor.cpp @@ -66,17 +66,17 @@ void ClearCargoDeliveryMonitoring(CompanyID company) * @param keep_monitoring After returning from this call, continue monitoring. * @return Amount collected since last query/activation for the monitored combination. */ -static int32 GetAmount(CargoMonitorMap &monitor_map, CargoMonitorID monitor, bool keep_monitoring) +static int32_t GetAmount(CargoMonitorMap &monitor_map, CargoMonitorID monitor, bool keep_monitoring) { CargoMonitorMap::iterator iter = monitor_map.find(monitor); if (iter == monitor_map.end()) { if (keep_monitoring) { - std::pair p(monitor, 0); + std::pair p(monitor, 0); monitor_map.insert(p); } return 0; } else { - int32 result = iter->second; + int32_t result = iter->second; iter->second = 0; if (!keep_monitoring) monitor_map.erase(iter); return result; @@ -89,7 +89,7 @@ static int32 GetAmount(CargoMonitorMap &monitor_map, CargoMonitorID monitor, boo * @param keep_monitoring After returning from this call, continue monitoring. * @return Amount of delivered cargo for the monitored combination. */ -int32 GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring) +int32_t GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring) { return GetAmount(_cargo_deliveries, monitor, keep_monitoring); } @@ -101,7 +101,7 @@ int32 GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring) * @return Amount of picked up cargo for the monitored combination. * @note Cargo pick up is counted on final delivery, to prevent users getting credit for picking up cargo without delivering it. */ -int32 GetPickupAmount(CargoMonitorID monitor, bool keep_monitoring) +int32_t GetPickupAmount(CargoMonitorID monitor, bool keep_monitoring) { return GetAmount(_cargo_pickups, monitor, keep_monitoring); } @@ -116,7 +116,7 @@ int32 GetPickupAmount(CargoMonitorID monitor, bool keep_monitoring) * @param st station where the cargo is delivered to. * @param dest industry index where the cargo is delivered to. */ -void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32 amount, SourceType src_type, SourceID src, const Station *st, IndustryID dest) +void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32_t amount, SourceType src_type, SourceID src, const Station *st, IndustryID dest) { if (amount == 0) return; diff --git a/src/cargomonitor.h b/src/cargomonitor.h index 0891bf88b1..ad38a1593f 100644 --- a/src/cargomonitor.h +++ b/src/cargomonitor.h @@ -26,7 +26,7 @@ struct Station; * - bits 19-23 Cargo type. * - bits 24-31 %Company number. */ -typedef uint32 CargoMonitorID; ///< Type of the cargo monitor number. +typedef uint32_t CargoMonitorID; ///< Type of the cargo monitor number. /** Map type for storing and updating active cargo monitor numbers and their amounts. */ typedef std::map CargoMonitorMap; @@ -63,7 +63,7 @@ static inline CargoMonitorID EncodeCargoIndustryMonitor(CompanyID company, Cargo assert(ctype < (1 << CCB_CARGO_TYPE_LENGTH)); assert(company < (1 << CCB_COMPANY_LENGTH)); - uint32 ret = 0; + uint32_t ret = 0; SB(ret, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH, ind); SetBit(ret, CCB_IS_INDUSTRY_BIT); SB(ret, CCB_CARGO_TYPE_START, CCB_CARGO_TYPE_LENGTH, ctype); @@ -83,7 +83,7 @@ static inline CargoMonitorID EncodeCargoTownMonitor(CompanyID company, CargoID c assert(ctype < (1 << CCB_CARGO_TYPE_LENGTH)); assert(company < (1 << CCB_COMPANY_LENGTH)); - uint32 ret = 0; + uint32_t ret = 0; SB(ret, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH, town); SB(ret, CCB_CARGO_TYPE_START, CCB_CARGO_TYPE_LENGTH, ctype); SB(ret, CCB_COMPANY_START, CCB_COMPANY_LENGTH, company); @@ -144,8 +144,8 @@ static inline TownID DecodeMonitorTown(CargoMonitorID num) void ClearCargoPickupMonitoring(CompanyID company = INVALID_OWNER); void ClearCargoDeliveryMonitoring(CompanyID company = INVALID_OWNER); -int32 GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring); -int32 GetPickupAmount(CargoMonitorID monitor, bool keep_monitoring); -void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32 amount, SourceType src_type, SourceID src, const Station *st, IndustryID dest = INVALID_INDUSTRY); +int32_t GetDeliveryAmount(CargoMonitorID monitor, bool keep_monitoring); +int32_t GetPickupAmount(CargoMonitorID monitor, bool keep_monitoring); +void AddCargoDelivery(CargoID cargo_type, CompanyID company, uint32_t amount, SourceType src_type, SourceID src, const Station *st, IndustryID dest = INVALID_INDUSTRY); #endif /* CARGOMONITOR_H */ diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp index b4562a524c..b9d88ac7bc 100644 --- a/src/cargopacket.cpp +++ b/src/cargopacket.cpp @@ -41,7 +41,7 @@ CargoPacket::CargoPacket() * @note We have to zero memory ourselves here because we are using a 'new' * that, in contrary to all other pools, does not memset to 0. */ -CargoPacket::CargoPacket(StationID source, TileIndex source_xy, uint16 count, SourceType source_type, SourceID source_id) : +CargoPacket::CargoPacket(StationID source, TileIndex source_xy, uint16_t count, SourceType source_type, SourceID source_id) : feeder_share(0), count(count), periods_in_transit(0), @@ -68,7 +68,7 @@ CargoPacket::CargoPacket(StationID source, TileIndex source_xy, uint16 count, So * @note We have to zero memory ourselves here because we are using a 'new' * that, in contrary to all other pools, does not memset to 0. */ -CargoPacket::CargoPacket(uint16 count, uint16 periods_in_transit, StationID source, TileIndex source_xy, TileIndex loaded_at_xy, Money feeder_share, SourceType source_type, SourceID source_id) : +CargoPacket::CargoPacket(uint16_t count, uint16_t periods_in_transit, StationID source, TileIndex source_xy, TileIndex loaded_at_xy, Money feeder_share, SourceType source_type, SourceID source_id) : feeder_share(feeder_share), count(count), periods_in_transit(periods_in_transit), @@ -442,7 +442,7 @@ void VehicleCargoList::SetTransferLoadPlace(TileIndex xy) * @param payment Payment object for registering transfers. * return If any cargo will be unloaded. */ -bool VehicleCargoList::Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8 order_flags, const GoodsEntry *ge, CargoPayment *payment) +bool VehicleCargoList::Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8_t order_flags, const GoodsEntry *ge, CargoPayment *payment) { this->AssertCountConsistency(); assert(this->action_counts[MTA_LOAD] == 0); diff --git a/src/cargopacket.h b/src/cargopacket.h index b1fe8112d6..08b7683f9c 100644 --- a/src/cargopacket.h +++ b/src/cargopacket.h @@ -20,7 +20,7 @@ #include "saveload/saveload.h" /** Unique identifier for a single cargo packet. */ -typedef uint32 CargoPacketID; +typedef uint32_t CargoPacketID; struct CargoPacket; /** Type of the pool for cargo packets for a little over 16 million packets. */ @@ -34,7 +34,7 @@ template class CargoList; class StationCargoList; // forward-declare, so we can use it in VehicleCargoList. extern SaveLoadTable GetCargoPacketDesc(); -typedef uint32 TileOrStationID; +typedef uint32_t TileOrStationID; /** * Container for cargo from the same location and time. @@ -42,8 +42,8 @@ typedef uint32 TileOrStationID; struct CargoPacket : CargoPacketPool::PoolItem<&_cargopacket_pool> { private: Money feeder_share; ///< Value of feeder pickup to be paid for on delivery of cargo. - uint16 count; ///< The amount of cargo in this packet. - uint16 periods_in_transit; ///< Amount of cargo aging periods this packet has been in transit. + uint16_t count; ///< The amount of cargo in this packet. + uint16_t periods_in_transit; ///< Amount of cargo aging periods this packet has been in transit. SourceType source_type; ///< Type of \c source_id. SourceID source_id; ///< Index of source, INVALID_SOURCE if unknown/invalid. StationID source; ///< The station where the cargo came from first. @@ -61,11 +61,11 @@ private: friend SaveLoadTable GetCargoPacketDesc(); public: /** Maximum number of items in a single cargo packet. */ - static const uint16 MAX_COUNT = UINT16_MAX; + static const uint16_t MAX_COUNT = UINT16_MAX; CargoPacket(); - CargoPacket(StationID source, TileIndex source_xy, uint16 count, SourceType source_type, SourceID source_id); - CargoPacket(uint16 count, uint16 periods_in_transit, StationID source, TileIndex source_xy, TileIndex loaded_at_xy, Money feeder_share = 0, SourceType source_type = SourceType::Industry, SourceID source_id = INVALID_SOURCE); + CargoPacket(StationID source, TileIndex source_xy, uint16_t count, SourceType source_type, SourceID source_id); + CargoPacket(uint16_t count, uint16_t periods_in_transit, StationID source, TileIndex source_xy, TileIndex loaded_at_xy, Money feeder_share = 0, SourceType source_type = SourceType::Industry, SourceID source_id = INVALID_SOURCE); /** Destroy the packet. */ ~CargoPacket() { } @@ -96,7 +96,7 @@ public: * Gets the number of 'items' in this packet. * @return Item count. */ - inline uint16 Count() const + inline uint16_t Count() const { return this->count; } @@ -129,7 +129,7 @@ public: * value is capped at UINT16_MAX. * @return Length this cargo has been in transit. */ - inline uint16 PeriodsInTransit() const + inline uint16_t PeriodsInTransit() const { return this->periods_in_transit; } @@ -222,7 +222,7 @@ public: protected: uint count; ///< Cache for the number of cargo entities. - uint64 cargo_periods_in_transit; ///< Cache for the sum of number of cargo aging periods in transit of each entity; comparable to man-hours. + uint64_t cargo_periods_in_transit; ///< Cache for the sum of number of cargo aging periods in transit of each entity; comparable to man-hours. Tcont packets; ///< The cargo packets in this list. @@ -398,7 +398,7 @@ public: void SetTransferLoadPlace(TileIndex xy); - bool Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8 order_flags, const GoodsEntry *ge, CargoPayment *payment); + bool Stage(bool accepted, StationID current_station, StationIDStack next_station, uint8_t order_flags, const GoodsEntry *ge, CargoPayment *payment); /** * Marks all cargo in the vehicle as to be kept. This is mostly useful for diff --git a/src/cargotype.cpp b/src/cargotype.cpp index 8fb40ee629..2e903f4603 100644 --- a/src/cargotype.cpp +++ b/src/cargotype.cpp @@ -121,7 +121,7 @@ CargoID GetCargoIDByLabel(CargoLabel cl) * @param bitnum 'bitnum' to find. * @return First CargoID with the given bitnum, or #CT_INVALID if not found or if the provided \a bitnum is invalid. */ -CargoID GetCargoIDByBitnum(uint8 bitnum) +CargoID GetCargoIDByBitnum(uint8_t bitnum) { if (bitnum == INVALID_CARGO) return CT_INVALID; @@ -196,7 +196,7 @@ void InitializeSortedCargoSpecs() /* Count the number of standard cargos and fill the mask. */ _standard_cargo_mask = 0; - uint8 nb_standard_cargo = 0; + uint8_t nb_standard_cargo = 0; for (const auto &cargo : _sorted_cargo_specs) { if (cargo->classes & CC_SPECIAL) break; nb_standard_cargo++; @@ -207,7 +207,7 @@ void InitializeSortedCargoSpecs() _sorted_standard_cargo_specs = { _sorted_cargo_specs.data(), nb_standard_cargo }; } -uint64 CargoSpec::WeightOfNUnitsInTrain(uint32 n) const +uint64_t CargoSpec::WeightOfNUnitsInTrain(uint32_t n) const { if (this->is_freight) n *= _settings_game.vehicle.freight_trains; return this->WeightOfNUnits(n); diff --git a/src/cargotype.h b/src/cargotype.h index 1cd91f864b..a4f7d503d8 100644 --- a/src/cargotype.h +++ b/src/cargotype.h @@ -19,7 +19,7 @@ #include "core/span_type.hpp" /** Globally unique label of a cargo type. */ -typedef uint32 CargoLabel; +typedef uint32_t CargoLabel; /** Town growth effect when delivering cargo. */ enum TownEffect : byte { @@ -54,18 +54,18 @@ static const byte INVALID_CARGO = 0xFF; ///< Constant representing invalid cargo /** Specification of a cargo type. */ struct CargoSpec { - uint8 bitnum; ///< Cargo bit number, is #INVALID_CARGO for a non-used spec. + uint8_t bitnum; ///< Cargo bit number, is #INVALID_CARGO for a non-used spec. CargoLabel label; ///< Unique label of the cargo type. - uint8 legend_colour; - uint8 rating_colour; - uint8 weight; ///< Weight of a single unit of this cargo type in 1/16 ton (62.5 kg). - uint16 multiplier; ///< Capacity multiplier for vehicles. (8 fractional bits) - int32 initial_payment; ///< Initial payment rate before inflation is applied. - uint8 transit_periods[2]; + uint8_t legend_colour; + uint8_t rating_colour; + uint8_t weight; ///< Weight of a single unit of this cargo type in 1/16 ton (62.5 kg). + uint16_t multiplier; ///< Capacity multiplier for vehicles. (8 fractional bits) + int32_t initial_payment; ///< Initial payment rate before inflation is applied. + uint8_t transit_periods[2]; bool is_freight; ///< Cargo type is considered to be freight (affects train freight multiplier). TownEffect town_effect; ///< The effect that delivering this cargo type has on towns. Also affects destination of subsidies. - uint8 callback_mask; ///< Bitmask of cargo callbacks that have to be called + uint8_t callback_mask; ///< Bitmask of cargo callbacks that have to be called StringID name; ///< Name of this type of cargo. StringID name_single; ///< Name of a single entity of this type of cargo. @@ -75,7 +75,7 @@ struct CargoSpec { SpriteID sprite; ///< Icon to display this cargo type, may be \c 0xFFF (which means to resolve an action123 chain). - uint16 classes; ///< Classes of this cargo type. @see CargoClass + uint16_t classes; ///< Classes of this cargo type. @see CargoClass const struct GRFFile *grffile; ///< NewGRF where #group belongs to. const struct SpriteGroup *group; @@ -122,12 +122,12 @@ struct CargoSpec { SpriteID GetCargoIcon() const; - inline uint64 WeightOfNUnits(uint32 n) const + inline uint64_t WeightOfNUnits(uint32_t n) const { return n * this->weight / 16u; } - uint64 WeightOfNUnitsInTrain(uint32 n) const; + uint64_t WeightOfNUnitsInTrain(uint32_t n) const; /** * Iterator to iterate all valid CargoSpec @@ -183,7 +183,7 @@ extern CargoTypes _standard_cargo_mask; void SetupCargoForClimate(LandscapeID l); CargoID GetCargoIDByLabel(CargoLabel cl); -CargoID GetCargoIDByBitnum(uint8 bitnum); +CargoID GetCargoIDByBitnum(uint8_t bitnum); CargoID GetDefaultCargoID(LandscapeID l, CargoType ct); void InitializeSortedCargoSpecs(); diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index 02fd40e5e2..a56f3b5c78 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -44,7 +44,7 @@ * This variable is semantically a constant value, but because the cheat * code requires to be able to write to the variable it is not constified. */ -static int32 _money_cheat_amount = 10000000; +static int32_t _money_cheat_amount = 10000000; /** * Handle cheating of money. @@ -55,7 +55,7 @@ static int32 _money_cheat_amount = 10000000; * @param change_direction is -1 or +1 (down/up) * @return Amount of money cheat. */ -static int32 ClickMoneyCheat(int32 new_value, int32 change_direction) +static int32_t ClickMoneyCheat(int32_t new_value, int32_t change_direction) { Command::Post(Money(_money_cheat_amount) * change_direction); return _money_cheat_amount; @@ -67,7 +67,7 @@ static int32 ClickMoneyCheat(int32 new_value, int32 change_direction) * @param change_direction is -1 or +1 (down/up) * @return The new company. */ -static int32 ClickChangeCompanyCheat(int32 new_value, int32 change_direction) +static int32_t ClickChangeCompanyCheat(int32_t new_value, int32_t change_direction) { while ((uint)new_value < Company::GetPoolSize()) { if (Company::IsValidID((CompanyID)new_value)) { @@ -86,7 +86,7 @@ static int32 ClickChangeCompanyCheat(int32 new_value, int32 change_direction) * @param change_direction unused * @return New value allowing change of industry production. */ -static int32 ClickSetProdCheat(int32 new_value, int32 change_direction) +static int32_t ClickSetProdCheat(int32_t new_value, int32_t change_direction) { _cheats.setup_prod.value = (new_value != 0); InvalidateWindowClassesData(WC_INDUSTRY_VIEW); @@ -101,7 +101,7 @@ extern void EnginesMonthlyLoop(); * @param change_direction +1 (increase) or -1 (decrease). * @return New year. */ -static int32 ClickChangeDateCheat(int32 new_value, int32 change_direction) +static int32_t ClickChangeDateCheat(int32_t new_value, int32_t change_direction) { /* Don't allow changing to an invalid year, or the current year. */ new_value = Clamp(new_value, MIN_YEAR, MAX_YEAR); @@ -135,14 +135,14 @@ static int32 ClickChangeDateCheat(int32 new_value, int32 change_direction) * @return New value (or unchanged old value) of the maximum * allowed heightlevel value. */ -static int32 ClickChangeMaxHlCheat(int32 new_value, int32 change_direction) +static int32_t ClickChangeMaxHlCheat(int32_t new_value, int32_t change_direction) { new_value = Clamp(new_value, MIN_MAP_HEIGHT_LIMIT, MAX_MAP_HEIGHT_LIMIT); /* Check if at least one mountain on the map is higher than the new value. * If yes, disallow the change. */ for (TileIndex t = 0; t < Map::Size(); t++) { - if ((int32)TileHeight(t) > new_value) { + if ((int32_t)TileHeight(t) > new_value) { ShowErrorMessage(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN, INVALID_STRING_ID, WL_ERROR); /* Return old, unchanged value */ return _settings_game.construction.map_height_limit; @@ -178,7 +178,7 @@ enum CheatNumbers { * @param new_value The new value. * @param change_direction Change direction (+1, +1), \c 0 for boolean settings. */ -typedef int32 CheckButtonClick(int32 new_value, int32 change_direction); +typedef int32_t CheckButtonClick(int32_t new_value, int32_t change_direction); /** Information of a cheat. */ struct CheatEntry { @@ -272,7 +272,7 @@ struct CheatWindow : Window { } default: { - int32 val = (int32)ReadValue(ce->variable, ce->type); + int32_t val = (int32_t)ReadValue(ce->variable, ce->type); /* Draw [<][>] boxes for settings of an integer-type */ DrawArrowButtons(button_left, y + button_y_offset, COLOUR_YELLOW, clicked - (i * 2), true, true); @@ -358,7 +358,7 @@ struct CheatWindow : Window { if (btn >= lengthof(_cheats_ui)) return; const CheatEntry *ce = &_cheats_ui[btn]; - int value = (int32)ReadValue(ce->variable, ce->type); + int value = (int32_t)ReadValue(ce->variable, ce->type); int oldvalue = value; if (btn == CHT_CHANGE_DATE && x >= WidgetDimensions::scaled.hsep_wide * 2 + this->box.width + SETTING_BUTTON_WIDTH) { @@ -394,7 +394,7 @@ struct CheatWindow : Window { break; } - if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value); + if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64_t)value); this->SetTimeout(); @@ -413,12 +413,12 @@ struct CheatWindow : Window { if (str == nullptr || StrEmpty(str)) return; const CheatEntry *ce = &_cheats_ui[clicked_widget]; - int oldvalue = (int32)ReadValue(ce->variable, ce->type); + int oldvalue = (int32_t)ReadValue(ce->variable, ce->type); int value = atoi(str); *ce->been_used = true; value = ce->proc(value, value - oldvalue); - if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value); + if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64_t)value); this->SetDirty(); } diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp index ff4c858396..6a1132ac2b 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -319,7 +319,7 @@ void GenerateClearTile() /* add rocky tiles */ i = gi; do { - uint32 r = Random(); + uint32_t r = Random(); tile = RandomTileSeed(r); IncreaseGeneratingWorldProgress(GWP_ROUGH_ROCKY); diff --git a/src/command.cpp b/src/command.cpp index 8be2de9872..dfc82536c4 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -428,7 +428,7 @@ void CommandCost::AddCost(const CommandCost &ret) * There is only one static instance of the array, just like there is only one * instance of normal DParams. */ -uint32 CommandCost::textref_stack[16]; +uint32_t CommandCost::textref_stack[16]; /** * Activate usage of the NewGRF #TextRefStack for the error message. @@ -437,7 +437,7 @@ uint32 CommandCost::textref_stack[16]; */ void CommandCost::UseTextRefStack(const GRFFile *grffile, uint num_registers) { - extern TemporaryStorageArray _temp_store; + extern TemporaryStorageArray _temp_store; assert(num_registers < lengthof(textref_stack)); this->textref_stack_grffile = grffile; diff --git a/src/command_type.h b/src/command_type.h index 4373a92e17..828d64a074 100644 --- a/src/command_type.h +++ b/src/command_type.h @@ -26,10 +26,10 @@ class CommandCost { StringID message; ///< Warning message for when success is unset bool success; ///< Whether the command went fine up to this moment const GRFFile *textref_stack_grffile; ///< NewGRF providing the #TextRefStack content. - uint textref_stack_size; ///< Number of uint32 values to put on the #TextRefStack for the error message. + uint textref_stack_size; ///< Number of uint32_t values to put on the #TextRefStack for the error message. StringID extra_message = INVALID_STRING_ID; ///< Additional warning message for when success is unset - static uint32 textref_stack[16]; + static uint32_t textref_stack[16]; public: /** @@ -118,8 +118,8 @@ public: } /** - * Returns the number of uint32 values for the #TextRefStack of the error message. - * @return number of uint32 values. + * Returns the number of uint32_t values for the #TextRefStack of the error message. + * @return number of uint32_t values. */ uint GetTextRefStackSize() const { @@ -128,9 +128,9 @@ public: /** * Returns a pointer to the values for the #TextRefStack of the error message. - * @return uint32 values for the #TextRefStack + * @return uint32_t values for the #TextRefStack */ - const uint32 *GetTextRefStack() const + const uint32_t *GetTextRefStack() const { return textref_stack; } @@ -184,7 +184,7 @@ public: * * @see _command_proc_table */ -enum Commands : uint16 { +enum Commands : uint16_t { CMD_BUILD_RAILROAD_TRACK, ///< build a rail track CMD_REMOVE_RAILROAD_TRACK, ///< remove a rail track CMD_BUILD_SINGLE_RAIL, ///< build a single rail track diff --git a/src/company_base.h b/src/company_base.h index 5735cda990..53949fa500 100644 --- a/src/company_base.h +++ b/src/company_base.h @@ -23,28 +23,28 @@ struct CompanyEconomyEntry { Money income; ///< The amount of income. Money expenses; ///< The amount of expenses. CargoArray delivered_cargo{}; ///< The amount of delivered cargo. - int32 performance_history; ///< Company score (scale 0-1000) + int32_t performance_history; ///< Company score (scale 0-1000) Money company_value; ///< The value of the company. }; struct CompanyInfrastructure { - uint32 road[ROADTYPE_END]; ///< Count of company owned track bits for each road type. - uint32 signal; ///< Count of company owned signals. - uint32 rail[RAILTYPE_END]; ///< Count of company owned track bits for each rail type. - uint32 water; ///< Count of company owned track bits for canals. - uint32 station; ///< Count of company owned station tiles. - uint32 airport; ///< Count of company owned airports. + uint32_t road[ROADTYPE_END]; ///< Count of company owned track bits for each road type. + uint32_t signal; ///< Count of company owned signals. + uint32_t rail[RAILTYPE_END]; ///< Count of company owned track bits for each rail type. + uint32_t water; ///< Count of company owned track bits for canals. + uint32_t station; ///< Count of company owned station tiles. + uint32_t airport; ///< Count of company owned airports. /** Get total sum of all owned track bits. */ - uint32 GetRailTotal() const + uint32_t GetRailTotal() const { - uint32 total = 0; + uint32_t total = 0; for (RailType rt = RAILTYPE_BEGIN; rt < RAILTYPE_END; rt++) total += this->rail[rt]; return total; } - uint32 GetRoadTotal() const; - uint32 GetTramTotal() const; + uint32_t GetRoadTotal() const; + uint32_t GetTramTotal() const; }; typedef Pool CompanyPool; @@ -53,12 +53,12 @@ extern CompanyPool _company_pool; /** Statically loadable part of Company pool item */ struct CompanyProperties { - uint32 name_2; ///< Parameter of #name_1. + uint32_t name_2; ///< Parameter of #name_1. StringID name_1; ///< Name of the company if the user did not change it. std::string name; ///< Name of the company if the user changed it. StringID president_name_1; ///< Name of the president if the user did not change it. - uint32 president_name_2; ///< Parameter of #president_name_1 + uint32_t president_name_2; ///< Parameter of #president_name_1 std::string president_name; ///< Name of the president if the user changed it. CompanyManagerFace face; ///< Face description of the president. @@ -78,13 +78,13 @@ struct CompanyProperties { byte months_of_bankruptcy; ///< Number of months that the company is unable to pay its debts CompanyMask bankrupt_asked; ///< which companies were asked about buying it? - int16 bankrupt_timeout; ///< If bigger than \c 0, amount of time to wait for an answer on an offer to buy this company. + int16_t bankrupt_timeout; ///< If bigger than \c 0, amount of time to wait for an answer on an offer to buy this company. Money bankrupt_value; - uint32 terraform_limit; ///< Amount of tileheights we can (still) terraform (times 65536). - uint32 clear_limit; ///< Amount of tiles we can (still) clear (times 65536). - uint32 tree_limit; ///< Amount of trees we can (still) plant (times 65536). - uint32 build_object_limit; ///< Amount of tiles we can (still) build objects on (times 65536). Also applies to buying land. + uint32_t terraform_limit; ///< Amount of tileheights we can (still) terraform (times 65536). + uint32_t clear_limit; ///< Amount of tiles we can (still) clear (times 65536). + uint32_t tree_limit; ///< Amount of trees we can (still) plant (times 65536). + uint32_t build_object_limit; ///< Amount of tiles we can (still) build objects on (times 65536). Also applies to buying land. /** * If \c true, the company is (also) controlled by the computer (a NoAI program). @@ -112,7 +112,7 @@ struct CompanyProperties { }; struct Company : CompanyProperties, CompanyPool::PoolItem<&_company_pool> { - Company(uint16 name_1 = 0, bool is_ai = false); + Company(uint16_t name_1 = 0, bool is_ai = false); ~Company(); RailTypes avail_railtypes; ///< Rail types available to this company. diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index 0cf65688f9..362ec0521f 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -60,15 +60,15 @@ INSTANTIATE_POOL_METHODS(Company) * @param name_1 Name of the company. * @param is_ai A computer program is running for this company. */ -Company::Company(uint16 name_1, bool is_ai) +Company::Company(uint16_t name_1, bool is_ai) { this->name_1 = name_1; this->location_of_HQ = INVALID_TILE; this->is_ai = is_ai; - this->terraform_limit = (uint32)_settings_game.construction.terraform_frame_burst << 16; - this->clear_limit = (uint32)_settings_game.construction.clear_frame_burst << 16; - this->tree_limit = (uint32)_settings_game.construction.tree_frame_burst << 16; - this->build_object_limit = (uint32)_settings_game.construction.build_object_frame_burst << 16; + this->terraform_limit = (uint32_t)_settings_game.construction.terraform_frame_burst << 16; + this->clear_limit = (uint32_t)_settings_game.construction.clear_frame_burst << 16; + this->tree_limit = (uint32_t)_settings_game.construction.tree_frame_burst << 16; + this->build_object_limit = (uint32_t)_settings_game.construction.build_object_frame_burst << 16; InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, INVALID_COMPANY); } @@ -362,7 +362,7 @@ static void GenerateCompanyName(Company *c) Town *t = ClosestTownFromTile(c->last_build_coordinate, UINT_MAX); StringID str; - uint32 strp; + uint32_t strp; std::string name; if (t->name.empty() && IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST + 1)) { str = t->townnametype - SPECSTR_TOWNNAME_START + SPECSTR_COMPANY_NAME_START; @@ -561,7 +561,7 @@ Company *DoStartupNewCompany(bool is_ai, CompanyID company = INVALID_COMPANY) _company_colours[c->index] = (Colours)c->colour; /* Scale the initial loan based on the inflation rounded down to the loan interval. The maximum loan has already been inflation adjusted. */ - c->money = c->current_loan = std::min((INITIAL_LOAN * _economy.inflation_prices >> 16) / LOAN_INTERVAL * LOAN_INTERVAL, _economy.max_loan); + c->money = c->current_loan = std::min((INITIAL_LOAN * _economy.inflation_prices >> 16) / LOAN_INTERVAL * LOAN_INTERVAL, _economy.max_loan); c->avail_railtypes = GetCompanyRailtypes(c->index); c->avail_roadtypes = GetCompanyRoadTypes(c->index); @@ -684,7 +684,7 @@ static void HandleBankruptcyTakeover(Company *c) if (c->bankrupt_asked == MAX_UVALUE(CompanyMask)) return; Company *best = nullptr; - int32 best_performance = -1; + int32_t best_performance = -1; /* Ask the company with the highest performance history first */ for (Company *c2 : Company::Iterate()) { @@ -725,7 +725,7 @@ void OnTick_Companies() } if (_new_competitor_timeout.HasFired() && _game_mode != GM_MENU && AI::CanStartNew()) { - int32 timeout = _settings_game.difficulty.competitors_interval * 60 * TICKS_PER_SECOND; + int32_t timeout = _settings_game.difficulty.competitors_interval * 60 * TICKS_PER_SECOND; /* If the interval is zero, check every ~10 minutes if a company went bankrupt and needs replacing. */ if (timeout == 0) timeout = 10 * 60 * TICKS_PER_SECOND; @@ -1149,9 +1149,9 @@ int CompanyServiceInterval(const Company *c, VehicleType type) * Get total sum of all owned road bits. * @return Combined total road road bits. */ -uint32 CompanyInfrastructure::GetRoadTotal() const +uint32_t CompanyInfrastructure::GetRoadTotal() const { - uint32 total = 0; + uint32_t total = 0; for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) { if (RoadTypeIsRoad(rt)) total += this->road[rt]; } @@ -1162,9 +1162,9 @@ uint32 CompanyInfrastructure::GetRoadTotal() const * Get total sum of all owned tram bits. * @return Combined total of tram road bits. */ -uint32 CompanyInfrastructure::GetTramTotal() const +uint32_t CompanyInfrastructure::GetTramTotal() const { - uint32 total = 0; + uint32_t total = 0; for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) { if (RoadTypeIsTram(rt)) total += this->road[rt]; } diff --git a/src/company_cmd.h b/src/company_cmd.h index 4a44fa7077..b2be9a45bc 100644 --- a/src/company_cmd.h +++ b/src/company_cmd.h @@ -14,7 +14,7 @@ #include "company_type.h" #include "livery.h" -enum ClientID : uint32; +enum ClientID : uint32_t; enum Colours : byte; CommandCost CmdCompanyCtrl(DoCommandFlag flags, CompanyCtrlAction cca, CompanyID company_id, CompanyRemoveReason reason, ClientID client_id); diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 37861ae337..dc660a6194 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -626,7 +626,7 @@ typedef GUIList GUIGroupList; /** Company livery colour scheme window. */ struct SelectCompanyLiveryWindow : public Window { private: - uint32 sel; + uint32_t sel; LiveryClass livery_class; Dimension square; uint rows; @@ -635,9 +635,9 @@ private: std::vector indents; Scrollbar *vscroll; - void ShowColourDropDownMenu(uint32 widget) + void ShowColourDropDownMenu(uint32_t widget) { - uint32 used_colours = 0; + uint32_t used_colours = 0; const Livery *livery, *default_livery = nullptr; bool primary = widget == WID_SCL_PRI_COL_DROPDOWN; byte default_col = 0; @@ -1387,7 +1387,7 @@ class SelectCompanyManagerFaceWindow : public Window * @param val the value which will be displayed * @param is_bool_widget is it a bool button */ - void SetFaceStringParameters(byte widget_index, uint8 val, bool is_bool_widget) const + void SetFaceStringParameters(byte widget_index, uint8_t val, bool is_bool_widget) const { const NWidgetCore *nwi_widget = this->GetWidget(widget_index); if (nwi_widget->IsDisabled()) { @@ -1881,14 +1881,14 @@ struct CompanyInfrastructureWindow : Window const Company *c = Company::Get((CompanyID)this->window_number); Money total; - uint32 rail_total = c->infrastructure.GetRailTotal(); + uint32_t rail_total = c->infrastructure.GetRailTotal(); for (RailType rt = RAILTYPE_BEGIN; rt != RAILTYPE_END; rt++) { if (HasBit(this->railtypes, rt)) total += RailMaintenanceCost(rt, c->infrastructure.rail[rt], rail_total); } total += SignalMaintenanceCost(c->infrastructure.signal); - uint32 road_total = c->infrastructure.GetRoadTotal(); - uint32 tram_total = c->infrastructure.GetTramTotal(); + uint32_t road_total = c->infrastructure.GetRoadTotal(); + uint32_t tram_total = c->infrastructure.GetTramTotal(); for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) { if (HasBit(this->roadtypes, rt)) total += RoadMaintenanceCost(rt, c->infrastructure.road[rt], RoadTypeIsRoad(rt) ? road_total : tram_total); } @@ -1969,17 +1969,17 @@ struct CompanyInfrastructureWindow : Window case WID_CI_STATION_COUNT: case WID_CI_TOTAL: { /* Find the maximum count that is displayed. */ - uint32 max_val = 1000; // Some random number to reserve enough space. + uint32_t max_val = 1000; // Some random number to reserve enough space. Money max_cost = 10000; // Some random number to reserve enough space. - uint32 rail_total = c->infrastructure.GetRailTotal(); + uint32_t rail_total = c->infrastructure.GetRailTotal(); for (RailType rt = RAILTYPE_BEGIN; rt < RAILTYPE_END; rt++) { max_val = std::max(max_val, c->infrastructure.rail[rt]); max_cost = std::max(max_cost, RailMaintenanceCost(rt, c->infrastructure.rail[rt], rail_total)); } max_val = std::max(max_val, c->infrastructure.signal); max_cost = std::max(max_cost, SignalMaintenanceCost(c->infrastructure.signal)); - uint32 road_total = c->infrastructure.GetRoadTotal(); - uint32 tram_total = c->infrastructure.GetTramTotal(); + uint32_t road_total = c->infrastructure.GetRoadTotal(); + uint32_t tram_total = c->infrastructure.GetTramTotal(); for (RoadType rt = ROADTYPE_BEGIN; rt < ROADTYPE_END; rt++) { max_val = std::max(max_val, c->infrastructure.road[rt]); max_cost = std::max(max_cost, RoadMaintenanceCost(rt, c->infrastructure.road[rt], RoadTypeIsRoad(rt) ? road_total : tram_total)); @@ -2062,7 +2062,7 @@ struct CompanyInfrastructureWindow : Window case WID_CI_RAIL_COUNT: { /* Draw infrastructure count for each valid railtype. */ - uint32 rail_total = c->infrastructure.GetRailTotal(); + uint32_t rail_total = c->infrastructure.GetRailTotal(); for (const auto &rt : _sorted_railtypes) { if (HasBit(this->railtypes, rt)) { this->DrawCountLine(r, y, c->infrastructure.rail[rt], RailMaintenanceCost(rt, c->infrastructure.rail[rt], rail_total)); @@ -2090,7 +2090,7 @@ struct CompanyInfrastructureWindow : Window case WID_CI_ROAD_COUNT: case WID_CI_TRAM_COUNT: { - uint32 road_tram_total = widget == WID_CI_ROAD_COUNT ? c->infrastructure.GetRoadTotal() : c->infrastructure.GetTramTotal(); + uint32_t road_tram_total = widget == WID_CI_ROAD_COUNT ? c->infrastructure.GetRoadTotal() : c->infrastructure.GetTramTotal(); for (const auto &rt : _sorted_roadtypes) { if (HasBit(this->roadtypes, rt) && RoadTypeIsRoad(rt) == (widget == WID_CI_ROAD_COUNT)) { this->DrawCountLine(r, y, c->infrastructure.road[rt], RoadMaintenanceCost(rt, c->infrastructure.road[rt], road_tram_total)); diff --git a/src/company_manager_face.h b/src/company_manager_face.h index 3c947e05b4..d7d94a74c4 100644 --- a/src/company_manager_face.h +++ b/src/company_manager_face.h @@ -127,9 +127,9 @@ static inline void SetCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyMan * * @pre 0 <= val < _cmf_info[cmfv].valid_values[ge] */ -static inline void IncreaseCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, int8 amount) +static inline void IncreaseCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, int8_t amount) { - int8 val = GetCompanyManagerFaceBits(cmf, cmfv, ge) + amount; // the new value for the cmfv + int8_t val = GetCompanyManagerFaceBits(cmf, cmfv, ge) + amount; // the new value for the cmfv /* scales the new value to the correct scope */ if (val >= _cmf_info[cmfv].valid_values[ge]) { diff --git a/src/company_type.h b/src/company_type.h index ad949b6c24..d87e778cce 100644 --- a/src/company_type.h +++ b/src/company_type.h @@ -46,13 +46,13 @@ static const uint MAX_COMPETITORS_INTERVAL = 500; ///< The maximum interval (in typedef Owner CompanyID; -typedef uint16 CompanyMask; +typedef uint16_t CompanyMask; struct Company; -typedef uint32 CompanyManagerFace; ///< Company manager face bits, info see in company_manager_face.h +typedef uint32_t CompanyManagerFace; ///< Company manager face bits, info see in company_manager_face.h /** The reason why the company was removed. */ -enum CompanyRemoveReason : uint8 { +enum CompanyRemoveReason : uint8_t { CRR_MANUAL, ///< The company is manually removed. CRR_AUTOCLEAN, ///< The company is removed due to autoclean. CRR_BANKRUPT, ///< The company went belly-up. @@ -63,7 +63,7 @@ enum CompanyRemoveReason : uint8 { }; /** The action to do with CMD_COMPANY_CTRL. */ -enum CompanyCtrlAction : uint8 { +enum CompanyCtrlAction : uint8_t { CCA_NEW, ///< Create a new company. CCA_NEW_AI, ///< Create a new AI company. CCA_DELETE, ///< Delete a company. diff --git a/src/console.cpp b/src/console.cpp index da48ec3ad6..50fc1becba 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -127,7 +127,7 @@ void IConsolePrint(TextColour colour_code, const std::string &string) * @param *arg the string to be converted * @return Return true on success or false on failure */ -bool GetArgumentInteger(uint32 *value, const char *arg) +bool GetArgumentInteger(uint32_t *value, const char *arg) { char *endptr; diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 62a22037a3..702a774ba9 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -245,7 +245,7 @@ DEF_CONSOLE_CMD(ConResetTile) } if (argc == 2) { - uint32 result; + uint32_t result; if (GetArgumentInteger(&result, argv[1])) { DoClearSquare((TileIndex)result); return true; @@ -284,7 +284,7 @@ DEF_CONSOLE_CMD(ConZoomToLevel) return true; case 2: { - uint32 level; + uint32_t level; if (GetArgumentInteger(&level, argv[1])) { /* In case ZOOM_LVL_MIN is more than 0, the next if statement needs to be amended. * A simple check for less than ZOOM_LVL_MIN does not work here because we are @@ -333,7 +333,7 @@ DEF_CONSOLE_CMD(ConScrollToTile) } if (argc < 2) return false; - uint32 arg_index = 1; + uint32_t arg_index = 1; bool instant = false; if (strcmp(argv[arg_index], "instant") == 0) { ++arg_index; @@ -342,7 +342,7 @@ DEF_CONSOLE_CMD(ConScrollToTile) switch (argc - arg_index) { case 1: { - uint32 result; + uint32_t result; if (GetArgumentInteger(&result, argv[arg_index])) { if (result >= Map::Size()) { IConsolePrint(CC_ERROR, "Tile does not exist."); @@ -355,7 +355,7 @@ DEF_CONSOLE_CMD(ConScrollToTile) } case 2: { - uint32 x, y; + uint32_t x, y; if (GetArgumentInteger(&x, argv[arg_index]) && GetArgumentInteger(&y, argv[arg_index + 1])) { if (x >= Map::SizeX() || y >= Map::SizeY()) { IConsolePrint(CC_ERROR, "Tile does not exist."); @@ -1499,10 +1499,10 @@ DEF_CONSOLE_CMD(ConScreenShot) if (argc > 7) return false; ScreenshotType type = SC_VIEWPORT; - uint32 width = 0; - uint32 height = 0; + uint32_t width = 0; + uint32_t height = 0; std::string name{}; - uint32 arg_index = 1; + uint32_t arg_index = 1; if (argc > arg_index) { if (strcmp(argv[arg_index], "viewport") == 0) { @@ -1723,7 +1723,7 @@ DEF_CONSOLE_CMD(ConCompanies) std::string colour = GetString(STR_COLOUR_DARK_BLUE + _company_colours[c->index]); IConsolePrint(CC_INFO, "#:{}({}) Company Name: '{}' Year Founded: {} Money: {} Loan: {} Value: {} (T:{}, R:{}, P:{}, S:{}) {}", c->index + 1, colour, company_name, - c->inaugurated_year, (int64)c->money, (int64)c->current_loan, (int64)CalculateCompanyValue(c), + c->inaugurated_year, (int64_t)c->money, (int64_t)c->current_loan, (int64_t)CalculateCompanyValue(c), c->group_all[VEH_TRAIN].num_vehicle, c->group_all[VEH_ROAD].num_vehicle, c->group_all[VEH_AIRCRAFT].num_vehicle, @@ -2279,7 +2279,7 @@ DEF_CONSOLE_CMD(ConNewGRFProfile) IConsolePrint(CC_DEBUG, "Started profiling for GRFID{} {}.", (started > 1) ? "s" : "", grfids); if (argc >= 3) { - uint64 ticks = std::max(atoi(argv[2]), 1); + uint64_t ticks = std::max(atoi(argv[2]), 1); NewGRFProfiler::StartTimer(ticks); IConsolePrint(CC_DEBUG, "Profiling will automatically stop after {} ticks.", ticks); } @@ -2358,11 +2358,11 @@ static void ConDumpRoadTypes() IConsolePrint(CC_DEFAULT, " h = hidden"); IConsolePrint(CC_DEFAULT, " T = buildable by towns"); - std::map grfs; + std::map grfs; for (RoadType rt = ROADTYPE_BEGIN; rt < ROADTYPE_END; rt++) { const RoadTypeInfo *rti = GetRoadTypeInfo(rt); if (rti->label == 0) continue; - uint32 grfid = 0; + uint32_t grfid = 0; const GRFFile *grf = rti->grffile[ROTSG_GROUND]; if (grf != nullptr) { grfid = grf->grfid; @@ -2396,11 +2396,11 @@ static void ConDumpRailTypes() IConsolePrint(CC_DEFAULT, " a = always allow 90 degree turns"); IConsolePrint(CC_DEFAULT, " d = always disallow 90 degree turns"); - std::map grfs; + std::map grfs; for (RailType rt = RAILTYPE_BEGIN; rt < RAILTYPE_END; rt++) { const RailtypeInfo *rti = GetRailTypeInfo(rt); if (rti->label == 0) continue; - uint32 grfid = 0; + uint32_t grfid = 0; const GRFFile *grf = rti->grffile[RTSG_GROUND]; if (grf != nullptr) { grfid = grf->grfid; @@ -2439,11 +2439,11 @@ static void ConDumpCargoTypes() IConsolePrint(CC_DEFAULT, " c = covered/sheltered"); IConsolePrint(CC_DEFAULT, " S = special"); - std::map grfs; + std::map grfs; for (CargoID i = 0; i < NUM_CARGO; i++) { const CargoSpec *spec = CargoSpec::Get(i); if (!spec->IsValid()) continue; - uint32 grfid = 0; + uint32_t grfid = 0; const GRFFile *grf = spec->grffile; if (grf != nullptr) { grfid = grf->grfid; diff --git a/src/console_gui.cpp b/src/console_gui.cpp index 9baef57542..ce2c0df758 100644 --- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -39,7 +39,7 @@ static const uint ICON_BOTTOM_BORDERWIDTH = 12; struct IConsoleLine { std::string buffer; ///< The data to store. TextColour colour; ///< The colour of the line. - uint16 time; ///< The amount of time the line is in the backlog. + uint16_t time; ///< The amount of time the line is in the backlog. IConsoleLine() : buffer(), colour(TC_BEGIN), time(0) { @@ -200,7 +200,7 @@ struct IConsoleWindow : Window if (_iconsole_cmdline.HandleCaret()) this->SetDirty(); } - EventState OnKeyPress(WChar key, uint16 keycode) override + EventState OnKeyPress(char32_t key, uint16_t keycode) override { if (_focused_window != this) return ES_NOT_HANDLED; diff --git a/src/console_internal.h b/src/console_internal.h index 8137a49b6d..4d23a67e1a 100644 --- a/src/console_internal.h +++ b/src/console_internal.h @@ -82,7 +82,7 @@ void IConsoleClearBuffer(); void IConsoleStdLibRegister(); /* Supporting functions */ -bool GetArgumentInteger(uint32 *value, const char *arg); +bool GetArgumentInteger(uint32_t *value, const char *arg); void IConsoleGUIInit(); void IConsoleGUIFree(); diff --git a/src/core/bitmath_func.cpp b/src/core/bitmath_func.cpp index 206c04e54b..09f2a9cb43 100644 --- a/src/core/bitmath_func.cpp +++ b/src/core/bitmath_func.cpp @@ -12,7 +12,7 @@ #include "../safeguards.h" -const uint8 _ffb_64[64] = { +const uint8_t _ffb_64[64] = { 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, @@ -34,13 +34,13 @@ const uint8 _ffb_64[64] = { * @param x The value to search * @return The position of the first bit set */ -uint8 FindFirstBit(uint64 x) +uint8_t FindFirstBit(uint64_t x) { if (x == 0) return 0; /* The macro FIND_FIRST_BIT is better to use when your x is not more than 128. */ - uint8 pos = 0; + uint8_t pos = 0; if ((x & 0xffffffffULL) == 0) { x >>= 32; pos += 32; } if ((x & 0x0000ffffULL) == 0) { x >>= 16; pos += 16; } @@ -63,11 +63,11 @@ uint8 FindFirstBit(uint64 x) * @param x The value to search * @return The position of the last bit set */ -uint8 FindLastBit(uint64 x) +uint8_t FindLastBit(uint64_t x) { if (x == 0) return 0; - uint8 pos = 0; + uint8_t pos = 0; if ((x & 0xffffffff00000000ULL) != 0) { x >>= 32; pos += 32; } if ((x & 0x00000000ffff0000ULL) != 0) { x >>= 16; pos += 16; } diff --git a/src/core/bitmath_func.hpp b/src/core/bitmath_func.hpp index b2d21dacbf..44e81612ca 100644 --- a/src/core/bitmath_func.hpp +++ b/src/core/bitmath_func.hpp @@ -29,7 +29,7 @@ * @return The selected bits, aligned to a LSB. */ template -debug_inline constexpr static uint GB(const T x, const uint8 s, const uint8 n) +debug_inline constexpr static uint GB(const T x, const uint8_t s, const uint8_t n) { return (x >> s) & (((T)1U << n) - 1); } @@ -55,7 +55,7 @@ debug_inline constexpr static uint GB(const T x, const uint8 s, const uint8 n) * @return The new value of \a x */ template -static inline T SB(T &x, const uint8 s, const uint8 n, const U d) +static inline T SB(T &x, const uint8_t s, const uint8_t n, const U d) { x &= (T)(~((((T)1U << n) - 1) << s)); x |= (T)(d << s); @@ -80,7 +80,7 @@ static inline T SB(T &x, const uint8 s, const uint8 n, const U d) * @return The new value of \a x */ template -static inline T AB(T &x, const uint8 s, const uint8 n, const U i) +static inline T AB(T &x, const uint8_t s, const uint8_t n, const U i) { const T mask = ((((T)1U << n) - 1) << s); x = (T)((x & ~mask) | ((x + (i << s)) & mask)); @@ -100,7 +100,7 @@ static inline T AB(T &x, const uint8 s, const uint8 n, const U i) * @return True if the bit is set, false else. */ template -debug_inline static bool HasBit(const T x, const uint8 y) +debug_inline static bool HasBit(const T x, const uint8_t y) { return (x & ((T)1U << y)) != 0; } @@ -118,7 +118,7 @@ debug_inline static bool HasBit(const T x, const uint8 y) * @return The new value of the old value with the bit set */ template -static inline T SetBit(T &x, const uint8 y) +static inline T SetBit(T &x, const uint8_t y) { return x = (T)(x | ((T)1U << y)); } @@ -148,7 +148,7 @@ static inline T SetBit(T &x, const uint8 y) * @return The new value of the old value with the bit cleared */ template -static inline T ClrBit(T &x, const uint8 y) +static inline T ClrBit(T &x, const uint8_t y) { return x = (T)(x & ~((T)1U << y)); } @@ -178,14 +178,14 @@ static inline T ClrBit(T &x, const uint8 y) * @return The new value of the old value with the bit toggled */ template -static inline T ToggleBit(T &x, const uint8 y) +static inline T ToggleBit(T &x, const uint8_t y) { return x = (T)(x ^ ((T)1U << y)); } /** Lookup table to check which bit is set in a 6 bit variable */ -extern const uint8 _ffb_64[64]; +extern const uint8_t _ffb_64[64]; /** * Returns the first non-zero bit in a 6-bit value (from right). @@ -213,7 +213,7 @@ extern const uint8 _ffb_64[64]; * @return The position of the first bit which is set * @see FIND_FIRST_BIT */ -static inline uint8 FindFirstBit2x64(const int value) +static inline uint8_t FindFirstBit2x64(const int value) { if ((value & 0xFF) == 0) { return FIND_FIRST_BIT((value >> 8) & 0x3F) + 8; @@ -222,8 +222,8 @@ static inline uint8 FindFirstBit2x64(const int value) } } -uint8 FindFirstBit(uint64 x); -uint8 FindLastBit(uint64 x); +uint8_t FindFirstBit(uint64_t x); +uint8_t FindLastBit(uint64_t x); /** * Clear the first bit in an integer. @@ -298,7 +298,7 @@ static inline bool HasAtMostOneBit(T value) * @return A bit rotated number */ template -static inline T ROL(const T x, const uint8 n) +static inline T ROL(const T x, const uint8_t n) { if (n == 0) return x; return (T)(x << n | x >> (sizeof(x) * 8 - n)); @@ -314,7 +314,7 @@ static inline T ROL(const T x, const uint8 n) * @return A bit rotated number */ template -static inline T ROR(const T x, const uint8 n) +static inline T ROR(const T x, const uint8_t n) { if (n == 0) return x; return (T)(x >> n | x << (sizeof(x) * 8 - n)); @@ -373,10 +373,10 @@ private: #if defined(__APPLE__) /* Make endian swapping use Apple's macros to increase speed * (since it will use hardware swapping if available). - * Even though they should return uint16 and uint32, we get + * Even though they should return uint16_t and uint32_t, we get * warnings if we don't cast those (why?) */ -# define BSWAP32(x) (static_cast(CFSwapInt32(x))) -# define BSWAP16(x) (static_cast(CFSwapInt16(x))) +# define BSWAP32(x) (static_cast(CFSwapInt32(x))) +# define BSWAP16(x) (static_cast(CFSwapInt16(x))) #elif defined(_MSC_VER) /* MSVC has intrinsics for swapping, resulting in faster code */ # define BSWAP32(x) (_byteswap_ulong(x)) @@ -387,11 +387,11 @@ private: * @param x the variable to bitswap * @return the bitswapped value. */ - static inline uint32 BSWAP32(uint32 x) + static inline uint32_t BSWAP32(uint32_t x) { #if !defined(__ICC) && defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && __GNUC_MINOR__ >= 3)) /* GCC >= 4.3 provides a builtin, resulting in faster code */ - return static_cast(__builtin_bswap32(static_cast(x))); + return static_cast(__builtin_bswap32(static_cast(x))); #else return ((x >> 24) & 0xFF) | ((x >> 8) & 0xFF00) | ((x << 8) & 0xFF0000) | ((x << 24) & 0xFF000000); #endif /* defined(__GNUC__) */ @@ -402,7 +402,7 @@ private: * @param x the variable to bitswap * @return the bitswapped value. */ - static inline uint16 BSWAP16(uint16 x) + static inline uint16_t BSWAP16(uint16_t x) { return (x >> 8) | (x << 8); } diff --git a/src/core/endian_func.hpp b/src/core/endian_func.hpp index e077d977ac..21d992b556 100644 --- a/src/core/endian_func.hpp +++ b/src/core/endian_func.hpp @@ -38,17 +38,17 @@ # define TO_LE32X(x) (x) #endif /* TTD_ENDIAN == TTD_BIG_ENDIAN */ -static inline uint16 ReadLE16Aligned(const void *x) +static inline uint16_t ReadLE16Aligned(const void *x) { - return FROM_LE16(*(const uint16*)x); + return FROM_LE16(*(const uint16_t*)x); } -static inline uint16 ReadLE16Unaligned(const void *x) +static inline uint16_t ReadLE16Unaligned(const void *x) { #if OTTD_ALIGNMENT == 1 return ((const byte*)x)[0] | ((const byte*)x)[1] << 8; #else - return FROM_LE16(*(const uint16*)x); + return FROM_LE16(*(const uint16_t*)x); #endif /* OTTD_ALIGNMENT == 1 */ } diff --git a/src/core/geometry_type.hpp b/src/core/geometry_type.hpp index 36933de6ef..17fba0c833 100644 --- a/src/core/geometry_type.hpp +++ b/src/core/geometry_type.hpp @@ -45,10 +45,10 @@ struct Dimension { /** Padding dimensions to apply to each side of a Rect. */ struct RectPadding { - uint8 left; - uint8 top; - uint8 right; - uint8 bottom; + uint8_t left; + uint8_t top; + uint8_t right; + uint8_t bottom; static const RectPadding zero; diff --git a/src/core/math_func.cpp b/src/core/math_func.cpp index 98fac81aa7..db705092a8 100644 --- a/src/core/math_func.cpp +++ b/src/core/math_func.cpp @@ -74,10 +74,10 @@ int DivideApprox(int a, int b) * @return Rounded integer square root. * @note Algorithm taken from http://en.wikipedia.org/wiki/Methods_of_computing_square_roots */ -uint32 IntSqrt(uint32 num) +uint32_t IntSqrt(uint32_t num) { - uint32 res = 0; - uint32 bit = 1UL << 30; // Second to top bit number. + uint32_t res = 0; + uint32_t bit = 1UL << 30; // Second to top bit number. /* 'bit' starts at the highest power of four <= the argument. */ while (bit > num) bit >>= 2; diff --git a/src/core/math_func.hpp b/src/core/math_func.hpp index c8916fb051..1b0908db32 100644 --- a/src/core/math_func.hpp +++ b/src/core/math_func.hpp @@ -355,6 +355,6 @@ static inline int DivAwayFromZero(int a, uint b) } } -uint32 IntSqrt(uint32 num); +uint32_t IntSqrt(uint32_t num); #endif /* MATH_FUNC_HPP */ diff --git a/src/core/overflowsafe_type.hpp b/src/core/overflowsafe_type.hpp index 53057008b2..ca7b7ad5e0 100644 --- a/src/core/overflowsafe_type.hpp +++ b/src/core/overflowsafe_type.hpp @@ -93,11 +93,11 @@ public: /* Operators for addition and subtraction. */ inline constexpr OverflowSafeInt operator + (const OverflowSafeInt& other) const { OverflowSafeInt result = *this; result += other; return result; } - inline constexpr OverflowSafeInt operator + (const int other) const { OverflowSafeInt result = *this; result += (int64)other; return result; } - inline constexpr OverflowSafeInt operator + (const uint other) const { OverflowSafeInt result = *this; result += (int64)other; return result; } + inline constexpr OverflowSafeInt operator + (const int other) const { OverflowSafeInt result = *this; result += (int64_t)other; return result; } + inline constexpr OverflowSafeInt operator + (const uint other) const { OverflowSafeInt result = *this; result += (int64_t)other; return result; } inline constexpr OverflowSafeInt operator - (const OverflowSafeInt& other) const { OverflowSafeInt result = *this; result -= other; return result; } - inline constexpr OverflowSafeInt operator - (const int other) const { OverflowSafeInt result = *this; result -= (int64)other; return result; } - inline constexpr OverflowSafeInt operator - (const uint other) const { OverflowSafeInt result = *this; result -= (int64)other; return result; } + inline constexpr OverflowSafeInt operator - (const int other) const { OverflowSafeInt result = *this; result -= (int64_t)other; return result; } + inline constexpr OverflowSafeInt operator - (const uint other) const { OverflowSafeInt result = *this; result -= (int64_t)other; return result; } inline constexpr OverflowSafeInt& operator ++ () { return *this += 1; } inline constexpr OverflowSafeInt& operator -- () { return *this += -1; } @@ -136,14 +136,14 @@ public: } /* Operators for multiplication. */ - inline constexpr OverflowSafeInt operator * (const int64 factor) const { OverflowSafeInt result = *this; result *= factor; return result; } - inline constexpr OverflowSafeInt operator * (const int factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; } - inline constexpr OverflowSafeInt operator * (const uint factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; } - inline constexpr OverflowSafeInt operator * (const uint16 factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; } - inline constexpr OverflowSafeInt operator * (const byte factor) const { OverflowSafeInt result = *this; result *= (int64)factor; return result; } + inline constexpr OverflowSafeInt operator * (const int64_t factor) const { OverflowSafeInt result = *this; result *= factor; return result; } + inline constexpr OverflowSafeInt operator * (const int factor) const { OverflowSafeInt result = *this; result *= (int64_t)factor; return result; } + inline constexpr OverflowSafeInt operator * (const uint factor) const { OverflowSafeInt result = *this; result *= (int64_t)factor; return result; } + inline constexpr OverflowSafeInt operator * (const uint16_t factor) const { OverflowSafeInt result = *this; result *= (int64_t)factor; return result; } + inline constexpr OverflowSafeInt operator * (const byte factor) const { OverflowSafeInt result = *this; result *= (int64_t)factor; return result; } /* Operators for division. */ - inline constexpr OverflowSafeInt& operator /= (const int64 divisor) { this->m_value /= divisor; return *this; } + inline constexpr OverflowSafeInt& operator /= (const int64_t divisor) { this->m_value /= divisor; return *this; } inline constexpr OverflowSafeInt operator / (const OverflowSafeInt& divisor) const { OverflowSafeInt result = *this; result /= divisor.m_value; return result; } inline constexpr OverflowSafeInt operator / (const int divisor) const { OverflowSafeInt result = *this; result /= divisor; return result; } inline constexpr OverflowSafeInt operator / (const uint divisor) const { OverflowSafeInt result = *this; result /= (int)divisor; return result; } @@ -181,11 +181,11 @@ public: }; -/* Sometimes we got int64 operator OverflowSafeInt instead of vice versa. Handle that properly. */ -template inline constexpr OverflowSafeInt operator + (const int64 a, const OverflowSafeInt b) { return b + a; } -template inline constexpr OverflowSafeInt operator - (const int64 a, const OverflowSafeInt b) { return -b + a; } -template inline constexpr OverflowSafeInt operator * (const int64 a, const OverflowSafeInt b) { return b * a; } -template inline constexpr OverflowSafeInt operator / (const int64 a, const OverflowSafeInt b) { return (OverflowSafeInt)a / (int)b; } +/* Sometimes we got int64_t operator OverflowSafeInt instead of vice versa. Handle that properly. */ +template inline constexpr OverflowSafeInt operator + (const int64_t a, const OverflowSafeInt b) { return b + a; } +template inline constexpr OverflowSafeInt operator - (const int64_t a, const OverflowSafeInt b) { return -b + a; } +template inline constexpr OverflowSafeInt operator * (const int64_t a, const OverflowSafeInt b) { return b * a; } +template inline constexpr OverflowSafeInt operator / (const int64_t a, const OverflowSafeInt b) { return (OverflowSafeInt)a / (int)b; } /* Sometimes we got int operator OverflowSafeInt instead of vice versa. Handle that properly. */ template inline constexpr OverflowSafeInt operator + (const int a, const OverflowSafeInt b) { return b + a; } @@ -205,8 +205,8 @@ template inline constexpr OverflowSafeInt operator - (const byte a template inline constexpr OverflowSafeInt operator * (const byte a, const OverflowSafeInt b) { return b * (uint)a; } template inline constexpr OverflowSafeInt operator / (const byte a, const OverflowSafeInt b) { return (OverflowSafeInt)a / (int)b; } -typedef OverflowSafeInt OverflowSafeInt64; -typedef OverflowSafeInt OverflowSafeInt32; +typedef OverflowSafeInt OverflowSafeInt64; +typedef OverflowSafeInt OverflowSafeInt32; /* Some basic "unit tests". Also has the bonus of confirming that constexpr is working. */ static_assert(OverflowSafeInt32(INT32_MIN) - 1 == OverflowSafeInt32(INT32_MIN)); diff --git a/src/core/pool_type.hpp b/src/core/pool_type.hpp index d325327521..63278c8d17 100644 --- a/src/core/pool_type.hpp +++ b/src/core/pool_type.hpp @@ -79,7 +79,7 @@ private: template struct Pool : PoolBase { /* Ensure Tmax_size is within the bounds of Tindex. */ - static_assert((uint64)(Tmax_size - 1) >> 8 * sizeof(Tindex) == 0); + static_assert((uint64_t)(Tmax_size - 1) >> 8 * sizeof(Tindex) == 0); static constexpr size_t MAX_SIZE = Tmax_size; ///< Make template parameter accessible from outside diff --git a/src/core/random_func.cpp b/src/core/random_func.cpp index 6fe3617815..cba6dbe376 100644 --- a/src/core/random_func.cpp +++ b/src/core/random_func.cpp @@ -28,10 +28,10 @@ Randomizer _random, _interactive_random; * Generate the next pseudo random number * @return the random number */ -uint32 Randomizer::Next() +uint32_t Randomizer::Next() { - const uint32 s = this->state[0]; - const uint32 t = this->state[1]; + const uint32_t s = this->state[0]; + const uint32_t t = this->state[1]; this->state[0] = s + ROR(t ^ 0x1234567F, 7) + 1; return this->state[1] = ROR(s, 3) - 1; @@ -43,16 +43,16 @@ uint32 Randomizer::Next() * @param limit Limit of the range to be generated from. * @return Random number in [0,\a limit) */ -uint32 Randomizer::Next(uint32 limit) +uint32_t Randomizer::Next(uint32_t limit) { - return ((uint64)this->Next() * (uint64)limit) >> 32; + return ((uint64_t)this->Next() * (uint64_t)limit) >> 32; } /** * (Re)set the state of the random number generator. * @param seed the new state */ -void Randomizer::SetSeed(uint32 seed) +void Randomizer::SetSeed(uint32_t seed) { this->state[0] = seed; this->state[1] = seed; @@ -62,14 +62,14 @@ void Randomizer::SetSeed(uint32 seed) * (Re)set the state of the random number generators. * @param seed the new state */ -void SetRandomSeed(uint32 seed) +void SetRandomSeed(uint32_t seed) { _random.SetSeed(seed); _interactive_random.SetSeed(seed * 0x1234567); } #ifdef RANDOM_DEBUG -uint32 DoRandom(int line, const char *file) +uint32_t DoRandom(int line, const char *file) { if (_networking && (!_network_server || (NetworkClientSocket::IsValidID(0) && NetworkClientSocket::Get(0)->status != NetworkClientSocket::STATUS_INACTIVE))) { Debug(random, 0, "{:08x}; {:02x}; {:04x}; {:02x}; {}:{}", TimerGameCalendar::date, TimerGameCalendar::date_fract, _frame_counter, (byte)_current_company, file, line); @@ -78,8 +78,8 @@ uint32 DoRandom(int line, const char *file) return _random.Next(); } -uint32 DoRandomRange(uint32 limit, int line, const char *file) +uint32_t DoRandomRange(uint32_t limit, int line, const char *file) { - return ((uint64)DoRandom(line, file) * (uint64)limit) >> 32; + return ((uint64_t)DoRandom(line, file) * (uint64_t)limit) >> 32; } #endif /* RANDOM_DEBUG */ diff --git a/src/core/random_func.hpp b/src/core/random_func.hpp index ece90ccc35..3e61738737 100644 --- a/src/core/random_func.hpp +++ b/src/core/random_func.hpp @@ -20,11 +20,11 @@ */ struct Randomizer { /** The state of the randomizer */ - uint32 state[2]; + uint32_t state[2]; - uint32 Next(); - uint32 Next(uint32 limit); - void SetSeed(uint32 seed); + uint32_t Next(); + uint32_t Next(uint32_t limit); + void SetSeed(uint32_t seed); }; extern Randomizer _random; ///< Random used in the game state calculations extern Randomizer _interactive_random; ///< Random used everywhere else, where it does not (directly) influence the game state @@ -55,18 +55,18 @@ static inline void RestoreRandomSeeds(const SavedRandomSeeds &storage) _interactive_random = storage.interactive_random; } -void SetRandomSeed(uint32 seed); +void SetRandomSeed(uint32_t seed); #ifdef RANDOM_DEBUG # ifdef __APPLE__ # define OTTD_Random() DoRandom(__LINE__, __FILE__) # else # define Random() DoRandom(__LINE__, __FILE__) # endif - uint32 DoRandom(int line, const char *file); + uint32_t DoRandom(int line, const char *file); # define RandomRange(limit) DoRandomRange(limit, __LINE__, __FILE__) - uint32 DoRandomRange(uint32 limit, int line, const char *file); + uint32_t DoRandomRange(uint32_t limit, int line, const char *file); #else - static inline uint32 Random() + static inline uint32_t Random() { return _random.Next(); } @@ -78,18 +78,18 @@ void SetRandomSeed(uint32 seed); * @param limit Limit for the range to be picked from. * @return A random number in [0,\a limit). */ - static inline uint32 RandomRange(uint32 limit) + static inline uint32_t RandomRange(uint32_t limit) { return _random.Next(limit); } #endif -static inline uint32 InteractiveRandom() +static inline uint32_t InteractiveRandom() { return _interactive_random.Next(); } -static inline uint32 InteractiveRandomRange(uint32 limit) +static inline uint32_t InteractiveRandomRange(uint32_t limit) { return _interactive_random.Next(limit); } @@ -109,10 +109,10 @@ static inline uint32 InteractiveRandomRange(uint32 limit) * @param r The given randomize-number * @return True if the probability given by r is less or equal to (a/b) */ -static inline bool Chance16I(const uint a, const uint b, const uint32 r) +static inline bool Chance16I(const uint a, const uint b, const uint32_t r) { assert(b != 0); - return (((uint16)r * b + b / 2) >> 16) < a; + return (((uint16_t)r * b + b / 2) >> 16) < a; } /** @@ -152,7 +152,7 @@ static inline bool Chance16(const uint a, const uint b) #ifdef RANDOM_DEBUG # define Chance16R(a, b, r) (r = DoRandom(__LINE__, __FILE__), Chance16I(a, b, r)) #else -static inline bool Chance16R(const uint a, const uint b, uint32 &r) +static inline bool Chance16R(const uint a, const uint b, uint32_t &r) { r = Random(); return Chance16I(a, b, r); diff --git a/src/cpu.cpp b/src/cpu.cpp index e9b875015d..7de424e3d8 100644 --- a/src/cpu.cpp +++ b/src/cpu.cpp @@ -19,7 +19,7 @@ #if defined(_MSC_VER) && !defined(RDTSC_AVAILABLE) #include #include -uint64 ottd_rdtsc() +uint64_t ottd_rdtsc() { #if defined(_M_ARM) return __rdpmccntr64(); @@ -34,20 +34,20 @@ uint64 ottd_rdtsc() /* rdtsc for all other *nix-en (hopefully). Use GCC syntax */ #if (defined(__i386__) || defined(__x86_64__)) && !defined(RDTSC_AVAILABLE) -uint64 ottd_rdtsc() +uint64_t ottd_rdtsc() { - uint32 high, low; + uint32_t high, low; __asm__ __volatile__ ("rdtsc" : "=a" (low), "=d" (high)); - return ((uint64)high << 32) | low; + return ((uint64_t)high << 32) | low; } # define RDTSC_AVAILABLE #endif /* rdtsc for PPC which has this not */ #if (defined(__POWERPC__) || defined(__powerpc__)) && !defined(RDTSC_AVAILABLE) -uint64 ottd_rdtsc() +uint64_t ottd_rdtsc() { - uint32 high = 0, high2 = 0, low; + uint32_t high = 0, high2 = 0, low; /* PPC does not have rdtsc, so we cheat by reading the two 32-bit time-counters * it has, 'Move From Time Base (Upper)'. Since these are two reads, in the * very unlikely event that the lower part overflows to the upper part while we @@ -61,14 +61,14 @@ uint64 ottd_rdtsc() : "=r" (high), "=r" (low), "=r" (high2) : "0" (high), "2" (high2) ); - return ((uint64)high << 32) | low; + return ((uint64_t)high << 32) | low; } # define RDTSC_AVAILABLE #endif /* rdtsc for MCST Elbrus 2000 */ #if defined(__e2k__) && !defined(RDTSC_AVAILABLE) -uint64 ottd_rdtsc() +uint64_t ottd_rdtsc() { uint64_t dst; # pragma asm_inline @@ -80,7 +80,7 @@ uint64 ottd_rdtsc() #if defined(__EMSCRIPTEN__) && !defined(RDTSC_AVAILABLE) /* On emscripten doing TIC/TOC would be ill-advised */ -uint64 ottd_rdtsc() {return 0;} +uint64_t ottd_rdtsc() {return 0;} # define RDTSC_AVAILABLE #endif @@ -88,7 +88,7 @@ uint64 ottd_rdtsc() {return 0;} * you just won't be able to profile your code with TIC()/TOC() */ #if !defined(RDTSC_AVAILABLE) #warning "(non-fatal) No support for rdtsc(), you won't be able to profile with TIC/TOC" -uint64 ottd_rdtsc() {return 0;} +uint64_t ottd_rdtsc() {return 0;} #endif diff --git a/src/cpu.h b/src/cpu.h index 13eaa4f991..edaa8d7c17 100644 --- a/src/cpu.h +++ b/src/cpu.h @@ -14,7 +14,7 @@ * Get the tick counter from the CPU (high precision timing). * @return The count. */ -uint64 ottd_rdtsc(); +uint64_t ottd_rdtsc(); /** * Get the CPUID information from the CPU. diff --git a/src/currency.cpp b/src/currency.cpp index f51ed30261..a3b1636803 100644 --- a/src/currency.cpp +++ b/src/currency.cpp @@ -120,9 +120,9 @@ byte GetNewgrfCurrencyIdConverted(byte grfcurr_id) * get a mask of the allowed currencies depending on the year * @return mask of currencies */ -uint64 GetMaskOfAllowedCurrencies() +uint64_t GetMaskOfAllowedCurrencies() { - uint64 mask = 0LL; + uint64_t mask = 0LL; uint i; for (i = 0; i < CURRENCY_END; i++) { diff --git a/src/currency.h b/src/currency.h index 098f3caca2..33d8d088a2 100644 --- a/src/currency.h +++ b/src/currency.h @@ -70,7 +70,7 @@ enum Currencies { /** Specification of a currency. */ struct CurrencySpec { - uint16 rate; ///< The conversion rate compared to the base currency. + uint16_t rate; ///< The conversion rate compared to the base currency. std::string separator; ///< The thousands separator for this currency. TimerGameCalendar::Year to_euro; ///< Year of switching to the Euro. May also be #CF_NOEURO or #CF_ISEURO. std::string prefix; ///< Prefix to apply when formatting money in this currency. @@ -90,7 +90,7 @@ struct CurrencySpec { CurrencySpec() = default; - CurrencySpec(uint16 rate, const char *separator, TimerGameCalendar::Year to_euro, const char *prefix, const char *suffix, const char *code, byte symbol_pos, StringID name) : + CurrencySpec(uint16_t rate, const char *separator, TimerGameCalendar::Year to_euro, const char *prefix, const char *suffix, const char *code, byte symbol_pos, StringID name) : rate(rate), separator(separator), to_euro(to_euro), prefix(prefix), suffix(suffix), code(code), symbol_pos(symbol_pos), name(name) { } @@ -102,7 +102,7 @@ extern CurrencySpec _currency_specs[CURRENCY_END]; #define _custom_currency (_currency_specs[CURRENCY_CUSTOM]) #define _currency ((const CurrencySpec*)&_currency_specs[GetGameSettings().locale.currency]) -uint64 GetMaskOfAllowedCurrencies(); +uint64_t GetMaskOfAllowedCurrencies(); void ResetCurrencies(bool preserve_custom = true); byte GetNewgrfCurrencyIdConverted(byte grfcurr_id); diff --git a/src/date_gui.cpp b/src/date_gui.cpp index e5481265af..fcb872f51a 100644 --- a/src/date_gui.cpp +++ b/src/date_gui.cpp @@ -56,7 +56,7 @@ struct SetDateWindow : Window { this->date.year = Clamp(this->date.year, min_year, max_year); } - Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override + Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override { Point pt = { this->parent->left + this->parent->width / 2 - sm_width / 2, this->parent->top + this->parent->height / 2 - sm_height / 2 }; return pt; diff --git a/src/date_type.h b/src/date_type.h index 8bbc7ac252..c88b4f2061 100644 --- a/src/date_type.h +++ b/src/date_type.h @@ -12,11 +12,11 @@ #include "timer/timer_game_calendar.h" -typedef int32 Ticks; ///< The type to store ticks in +typedef int32_t Ticks; ///< The type to store ticks in /** - * 1 day is 74 ticks; TimerGameCalendar::date_fract used to be uint16 and incremented by 885. On + * 1 day is 74 ticks; TimerGameCalendar::date_fract used to be uint16_t and incremented by 885. On * an overflow the new day begun and 65535 / 885 = 74. * 1 tick is approximately 27 ms. * 1 day is thus about 2 seconds (74 * 27 = 1998) on a machine that can run OpenTTD normally diff --git a/src/debug.h b/src/debug.h index c2f24e1494..60725df8e5 100644 --- a/src/debug.h +++ b/src/debug.h @@ -88,9 +88,9 @@ std::string GetDebugString(); * machines. Mainly useful for local optimisations. **/ #define TIC() {\ - uint64 _xxx_ = ottd_rdtsc();\ - static uint64 _sum_ = 0;\ - static uint32 _i_ = 0; + uint64_t _xxx_ = ottd_rdtsc();\ + static uint64_t _sum_ = 0;\ + static uint32_t _i_ = 0; #define TOC(str, count)\ _sum_ += ottd_rdtsc() - _xxx_;\ @@ -104,8 +104,8 @@ std::string GetDebugString(); /* Chrono based version. The output is in microseconds. */ #define TICC() {\ auto _start_ = std::chrono::high_resolution_clock::now();\ - static uint64 _sum_ = 0;\ - static uint32 _i_ = 0; + static uint64_t _sum_ = 0;\ + static uint32_t _i_ = 0; #define TOCC(str, _count_)\ _sum_ += (std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - _start_)).count();\ diff --git a/src/depot_base.h b/src/depot_base.h index 28f01c412e..54c774523c 100644 --- a/src/depot_base.h +++ b/src/depot_base.h @@ -22,7 +22,7 @@ struct Depot : DepotPool::PoolItem<&_depot_pool> { std::string name; TileIndex xy; - uint16 town_cn; ///< The N-1th depot for this town (consecutive number) + uint16_t town_cn; ///< The N-1th depot for this town (consecutive number) TimerGameCalendar::Date build_date; ///< Date of construction Depot(TileIndex xy = INVALID_TILE) : xy(xy) {} diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index b00f8e3022..50101fb9db 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -360,7 +360,7 @@ struct DepotWindow : Window { DrawSpriteIgnorePadding((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, flag, false, SA_CENTER); SetDParam(0, v->unitnumber); - DrawString(text, STR_JUST_COMMA, (uint16)(v->max_age - DAYS_IN_LEAP_YEAR) >= v->age ? TC_BLACK : TC_RED); + DrawString(text, STR_JUST_COMMA, (uint16_t)(v->max_age - DAYS_IN_LEAP_YEAR) >= v->age ? TC_BLACK : TC_RED); } } @@ -399,7 +399,7 @@ struct DepotWindow : Window { } } - uint16 rows_in_display = wid->current_y / wid->resize_y; + uint16_t rows_in_display = wid->current_y / wid->resize_y; uint num = this->vscroll->GetPosition() * this->num_columns; uint maxval = static_cast(std::min(this->vehicle_list.size(), num + (rows_in_display * this->num_columns))); @@ -1120,7 +1120,7 @@ struct DepotWindow : Window { * In the case of airports, this is the station ID. * @return Depot or station ID of this window. */ - inline uint16 GetDepotIndex() const + inline uint16_t GetDepotIndex() const { return (this->type == VEH_AIRCRAFT) ? ::GetStationIndex(this->window_number) : ::GetDepotIndex(this->window_number); } diff --git a/src/depot_type.h b/src/depot_type.h index 8c41857138..322990c3e3 100644 --- a/src/depot_type.h +++ b/src/depot_type.h @@ -12,7 +12,7 @@ #include "station_type.h" -typedef uint16 DepotID; ///< Type for the unique identifier of depots. +typedef uint16_t DepotID; ///< Type for the unique identifier of depots. struct Depot; static const DepotID INVALID_DEPOT = (DepotID)INVALID_STATION; diff --git a/src/disaster_vehicle.cpp b/src/disaster_vehicle.cpp index 8cf825ba47..c5419b4f4b 100644 --- a/src/disaster_vehicle.cpp +++ b/src/disaster_vehicle.cpp @@ -54,7 +54,7 @@ #include "safeguards.h" /** Delay counter for considering the next disaster. */ -uint16 _disaster_delay; +uint16_t _disaster_delay; static void DisasterClearSquare(TileIndex tile) { @@ -287,7 +287,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v) v->image_override = SPR_BLIMP_CRASHED; } else if (v->age <= 300) { if (GB(v->tick_counter, 0, 3) == 0) { - uint32 r = Random(); + uint32_t r = Random(); CreateEffectVehicleRel(v, GB(r, 0, 4) - 7, @@ -422,7 +422,7 @@ static void DestructIndustry(Industry *i) * @param news_message The string that's used as news message. * @param industry_flag Only attack industries that have this flag set. */ -static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16 image_override, bool leave_at_top, StringID news_message, IndustryBehaviour industry_flag) +static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16_t image_override, bool leave_at_top, StringID news_message, IndustryBehaviour industry_flag) { v->tick_counter++; v->image_override = (v->state == 1 && HasBit(v->tick_counter, 2)) ? image_override : 0; @@ -440,7 +440,7 @@ static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16 image_override, boo Industry *i = Industry::Get(v->dest_tile); // Industry destructor calls ReleaseDisastersTargetingIndustry, so this is valid int x = TileX(i->location.tile) * TILE_SIZE; int y = TileY(i->location.tile) * TILE_SIZE; - uint32 r = Random(); + uint32_t r = Random(); CreateEffectVehicleAbove( GB(r, 0, 6) + x, @@ -640,7 +640,7 @@ static bool DisasterTick_Big_Ufo_Destroyer(DisasterVehicle *v) delete u; for (int i = 0; i != 80; i++) { - uint32 r = Random(); + uint32_t r = Random(); CreateEffectVehicleAbove( GB(r, 0, 6) + v->x_pos - 32, GB(r, 5, 6) + v->y_pos - 32, @@ -838,7 +838,7 @@ static void Disaster_Submarine_Init(DisasterSubType subtype) int y; Direction dir; - uint32 r = Random(); + uint32_t r = Random(); int x = TileX(r) * TILE_SIZE + TILE_SIZE / 2; if (HasBit(r, 31)) { @@ -961,7 +961,7 @@ void ReleaseDisastersTargetingIndustry(IndustryID i) /* primary disaster vehicles that have chosen target */ if (v->subtype == ST_AIRPLANE || v->subtype == ST_HELICOPTER) { /* if it has chosen target, and it is this industry (yes, dest_tile is IndustryID here), set order to "leaving map peacefully" */ - if (v->state > 0 && v->dest_tile == (uint32)i) v->state = 3; + if (v->state > 0 && v->dest_tile == (uint32_t)i) v->state = 3; } } } diff --git a/src/economy.cpp b/src/economy.cpp index 01ffa2eade..a7e36ba172 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -76,9 +76,9 @@ INSTANTIATE_POOL_METHODS(CargoPayment) * @param shift The amount to shift the value to right. * @return The shifted result */ -static inline int32 BigMulS(const int32 a, const int32 b, const uint8 shift) +static inline int32_t BigMulS(const int32_t a, const int32_t b, const uint8_t shift) { - return (int32)((int64)a * (int64)b >> shift); + return (int32_t)((int64_t)a * (int64_t)b >> shift); } typedef std::vector SmallIndustryList; @@ -99,7 +99,7 @@ const ScoreInfo _score_info[] = { { 0, 0} // SCORE_TOTAL }; -int64 _score_part[MAX_COMPANIES][SCORE_END]; +int64_t _score_part[MAX_COMPANIES][SCORE_END]; Economy _economy; Prices _price; static PriceMultipliers _price_base_multiplier; @@ -304,7 +304,7 @@ int UpdateCompanyRatingAndValue(Company *c, bool update) /* Skip the total */ if (i == SCORE_TOTAL) continue; /* Check the score */ - s = Clamp(_score_part[owner][i], 0, _score_info[i].needed) * _score_info[i].score / _score_info[i].needed; + s = Clamp(_score_part[owner][i], 0, _score_info[i].needed) * _score_info[i].score / _score_info[i].needed; score += s; total_score += _score_info[i].score; } @@ -671,13 +671,13 @@ static void CompaniesGenStatistics() cur_company.Change(c->index); CommandCost cost(EXPENSES_PROPERTY); - uint32 rail_total = c->infrastructure.GetRailTotal(); + uint32_t rail_total = c->infrastructure.GetRailTotal(); for (RailType rt = RAILTYPE_BEGIN; rt < RAILTYPE_END; rt++) { if (c->infrastructure.rail[rt] != 0) cost.AddCost(RailMaintenanceCost(rt, c->infrastructure.rail[rt], rail_total)); } cost.AddCost(SignalMaintenanceCost(c->infrastructure.signal)); - uint32 road_total = c->infrastructure.GetRoadTotal(); - uint32 tram_total = c->infrastructure.GetTramTotal(); + uint32_t road_total = c->infrastructure.GetRoadTotal(); + uint32_t tram_total = c->infrastructure.GetTramTotal(); for (RoadType rt = ROADTYPE_BEGIN; rt < ROADTYPE_END; rt++) { if (c->infrastructure.road[rt] != 0) cost.AddCost(RoadMaintenanceCost(rt, c->infrastructure.road[rt], RoadTypeIsRoad(rt) ? road_total : tram_total)); } @@ -759,7 +759,7 @@ bool AddInflation(bool check_year) void RecomputePrices() { /* Setup maximum loan as a rounded down multiple of LOAN_INTERVAL. */ - _economy.max_loan = ((uint64)_settings_game.difficulty.max_loan * _economy.inflation_prices >> 16) / LOAN_INTERVAL * LOAN_INTERVAL; + _economy.max_loan = ((uint64_t)_settings_game.difficulty.max_loan * _economy.inflation_prices >> 16) / LOAN_INTERVAL * LOAN_INTERVAL; /* Setup price bases */ for (Price i = PR_BEGIN; i < PR_END; i++) { @@ -786,7 +786,7 @@ void RecomputePrices() } /* Apply inflation */ - price = (int64)price * _economy.inflation_prices; + price = (int64_t)price * _economy.inflation_prices; /* Apply newgrf modifiers, remove fractional part of inflation, and normalise on medium difficulty. */ int shift = _price_base_multiplier[i] - 16 - 3; @@ -812,7 +812,7 @@ void RecomputePrices() /* Setup cargo payment */ for (CargoSpec *cs : CargoSpec::Iterate()) { - cs->current_payment = (cs->initial_payment * (int64)_economy.inflation_payment) >> 16; + cs->current_payment = (cs->initial_payment * (int64_t)_economy.inflation_payment) >> 16; } SetWindowClassesDirty(WC_BUILD_VEHICLE); @@ -975,7 +975,7 @@ Money GetPrice(Price index, uint cost_factor, const GRFFile *grf_file, int shift return cost; } -Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16 transit_periods, CargoID cargo_type) +Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16_t transit_periods, CargoID cargo_type) { const CargoSpec *cs = CargoSpec::Get(cargo_type); if (!cs->IsValid()) { @@ -985,8 +985,8 @@ Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16 transit_perio /* Use callback to calculate cargo profit, if available */ if (HasBit(cs->callback_mask, CBM_CARGO_PROFIT_CALC)) { - uint32 var18 = ClampTo(dist) | (ClampTo(num_pieces) << 16) | (ClampTo(transit_periods) << 24); - uint16 callback = GetCargoCallback(CBID_CARGO_PROFIT_CALC, 0, var18, cs); + uint32_t var18 = ClampTo(dist) | (ClampTo(num_pieces) << 16) | (ClampTo(transit_periods) << 24); + uint16_t callback = GetCargoCallback(CBID_CARGO_PROFIT_CALC, 0, var18, cs); if (callback != CALLBACK_FAILED) { int result = GB(callback, 0, 14); @@ -1104,7 +1104,7 @@ static uint DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, uint n * @return Revenue for delivering cargo * @note The cargo is just added to the stockpile of the industry. It is due to the caller to trigger the industry's production machinery */ -static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, TileIndex source_tile, uint16 periods_in_transit, Company *company, SourceType src_type, SourceID src) +static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, TileIndex source_tile, uint16_t periods_in_transit, Company *company, SourceType src_type, SourceID src) { assert(num_pieces > 0); @@ -1157,7 +1157,7 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, Ti static void TriggerIndustryProduction(Industry *i) { const IndustrySpec *indspec = GetIndustrySpec(i->type); - uint16 callback = indspec->callback_mask; + uint16_t callback = indspec->callback_mask; i->was_cargo_delivered = true; @@ -1317,7 +1317,7 @@ static uint GetLoadAmount(Vehicle *v) if (air_mail) load_amount = CeilDiv(load_amount, 4); if (_settings_game.order.gradual_loading) { - uint16 cb_load_amount = CALLBACK_FAILED; + uint16_t cb_load_amount = CALLBACK_FAILED; if (e->GetGRF() != nullptr && e->GetGRF()->grf_version >= 8) { /* Use callback 36 */ cb_load_amount = GetVehicleProperty(v, PROP_VEHICLE_LOAD_AMOUNT, CALLBACK_FAILED); diff --git a/src/economy_func.h b/src/economy_func.h index 5fe5d2d3cf..83c6565346 100644 --- a/src/economy_func.h +++ b/src/economy_func.h @@ -20,7 +20,7 @@ void ResetPriceBaseMultipliers(); void SetPriceBaseMultiplier(Price price, int factor); extern const ScoreInfo _score_info[]; -extern int64 _score_part[MAX_COMPANIES][SCORE_END]; +extern int64_t _score_part[MAX_COMPANIES][SCORE_END]; extern Economy _economy; /* Prices and also the fractional part. */ extern Prices _price; @@ -28,7 +28,7 @@ extern Prices _price; int UpdateCompanyRatingAndValue(Company *c, bool update); void StartupIndustryDailyChanges(bool init_counter); -Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16 transit_periods, CargoID cargo_type); +Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16_t transit_periods, CargoID cargo_type); uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, SourceID source_id, const StationList *all_stations, Owner exclusivity = INVALID_OWNER); void PrepareUnload(Vehicle *front_v); diff --git a/src/economy_type.h b/src/economy_type.h index f0f3fbe706..1c754476b1 100644 --- a/src/economy_type.h +++ b/src/economy_type.h @@ -16,7 +16,7 @@ typedef OverflowSafeInt64 Money; /** Type of the game economy. */ -enum EconomyType : uint8 { +enum EconomyType : uint8_t { ET_BEGIN = 0, ET_ORIGINAL = 0, ET_SMOOTH = 1, @@ -27,18 +27,18 @@ enum EconomyType : uint8 { /** Data of the economy. */ struct Economy { Money max_loan; ///< NOSAVE: Maximum possible loan - int16 fluct; ///< Economy fluctuation status + int16_t fluct; ///< Economy fluctuation status byte interest_rate; ///< Interest byte infl_amount; ///< inflation amount byte infl_amount_pr; ///< inflation rate for payment rates - uint32 industry_daily_change_counter; ///< Bits 31-16 are number of industry to be performed, 15-0 are fractional collected daily - uint32 industry_daily_increment; ///< The value which will increment industry_daily_change_counter. Computed value. NOSAVE - uint64 inflation_prices; ///< Cumulated inflation of prices since game start; 16 bit fractional part - uint64 inflation_payment; ///< Cumulated inflation of cargo payment since game start; 16 bit fractional part + uint32_t industry_daily_change_counter; ///< Bits 31-16 are number of industry to be performed, 15-0 are fractional collected daily + uint32_t industry_daily_increment; ///< The value which will increment industry_daily_change_counter. Computed value. NOSAVE + uint64_t inflation_prices; ///< Cumulated inflation of prices since game start; 16 bit fractional part + uint64_t inflation_payment; ///< Cumulated inflation of cargo payment since game start; 16 bit fractional part /* Old stuff for savegame conversion only */ Money old_max_loan_unround; ///< Old: Unrounded max loan - uint16 old_max_loan_unround_fract; ///< Old: Fraction of the unrounded max loan + uint16_t old_max_loan_unround_fract; ///< Old: Fraction of the unrounded max loan }; /** Score categories in the detailed performance rating. */ @@ -151,7 +151,7 @@ enum Price { DECLARE_POSTFIX_INCREMENT(Price) typedef Money Prices[PR_END]; ///< Prices of everything. @see Price -typedef int8 PriceMultipliers[PR_END]; +typedef int8_t PriceMultipliers[PR_END]; /** Types of expenses. */ enum ExpensesType : byte { @@ -194,17 +194,17 @@ struct PriceBaseSpec { /** The "steps" in loan size, in British Pounds! */ static const int LOAN_INTERVAL = 10000; /** The size of loan for a new company, in British Pounds! */ -static const int64 INITIAL_LOAN = 100000; +static const int64_t INITIAL_LOAN = 100000; /** - * Maximum inflation (including fractional part) without causing overflows in int64 price computations. + * Maximum inflation (including fractional part) without causing overflows in int64_t price computations. * This allows for 32 bit base prices (21 are currently needed). * Considering the sign bit and 16 fractional bits, there are 15 bits left. * 170 years of 4% inflation result in a inflation of about 822, so 10 bits are actually enough. * Note that NewGRF multipliers share the 16 fractional bits. * @see MAX_PRICE_MODIFIER */ -static const uint64 MAX_INFLATION = (1ull << (63 - 32)) - 1; +static const uint64_t MAX_INFLATION = (1ull << (63 - 32)) - 1; /** * Maximum NewGRF price modifiers. @@ -227,6 +227,6 @@ static const uint ROAD_STOP_TRACKBIT_FACTOR = 2; static const uint LOCK_DEPOT_TILE_FACTOR = 2; struct CargoPayment; -typedef uint32 CargoPaymentID; +typedef uint32_t CargoPaymentID; #endif /* ECONOMY_TYPE_H */ diff --git a/src/effectvehicle.cpp b/src/effectvehicle.cpp index c0ac226953..3db32f9d97 100644 --- a/src/effectvehicle.cpp +++ b/src/effectvehicle.cpp @@ -38,7 +38,7 @@ static bool IncrementSprite(EffectVehicle *v, SpriteID last) static void ChimneySmokeInit(EffectVehicle *v) { - uint32 r = Random(); + uint32_t r = Random(); v->sprite_cache.sprite_seq.Set(SPR_CHIMNEY_SMOKE_0 + GB(r, 0, 3)); v->progress = GB(r, 16, 3); } @@ -274,8 +274,8 @@ static const BulldozerMovement _bulldozer_movement[] = { }; static const struct { - int8 x; - int8 y; + int8_t x; + int8_t y; } _inc_by_dir[] = { { -1, 0 }, { 0, 1 }, @@ -317,9 +317,9 @@ static void BubbleInit(EffectVehicle *v) } struct BubbleMovement { - int8 x:4; - int8 y:4; - int8 z:4; + int8_t x:4; + int8_t y:4; + int8_t z:4; byte image:4; }; diff --git a/src/effectvehicle_base.h b/src/effectvehicle_base.h index 6b9ff2a93f..ad308c2916 100644 --- a/src/effectvehicle_base.h +++ b/src/effectvehicle_base.h @@ -22,7 +22,7 @@ * - bubbles (industry) */ struct EffectVehicle FINAL : public SpecializedVehicle { - uint16 animation_state; ///< State primarily used to change the graphics/behaviour. + uint16_t animation_state; ///< State primarily used to change the graphics/behaviour. byte animation_substate; ///< Sub state to time the change of the graphics/behaviour. /** We don't want GCC to zero our struct! It already is zeroed and has an index! */ diff --git a/src/elrail.cpp b/src/elrail.cpp index e8a29a9560..b341516472 100644 --- a/src/elrail.cpp +++ b/src/elrail.cpp @@ -232,8 +232,8 @@ static int GetPCPElevation(TileIndex tile, DiagDirection PCPpos) * Also note that the result of GetSlopePixelZ() is very special on bridge-ramps. */ - int z = GetSlopePixelZ(TileX(tile) * TILE_SIZE + std::min(x_pcp_offsets[PCPpos], TILE_SIZE - 1), - TileY(tile) * TILE_SIZE + std::min(y_pcp_offsets[PCPpos], TILE_SIZE - 1), true); + int z = GetSlopePixelZ(TileX(tile) * TILE_SIZE + std::min(x_pcp_offsets[PCPpos], TILE_SIZE - 1), + TileY(tile) * TILE_SIZE + std::min(y_pcp_offsets[PCPpos], TILE_SIZE - 1), true); /* Round the Z to the nearest half tile height. */ static const uint HALF_TILE_HEIGHT = TILE_HEIGHT / 2; return (z + HALF_TILE_HEIGHT / 2) / HALF_TILE_HEIGHT * HALF_TILE_HEIGHT; @@ -595,7 +595,7 @@ void DrawRailCatenary(const TileInfo *ti) DrawRailCatenaryRailway(ti); } -void SettingsDisableElrail(int32 new_value) +void SettingsDisableElrail(int32_t new_value) { bool disable = (new_value != 0); diff --git a/src/elrail_func.h b/src/elrail_func.h index bd301d6bb1..d9441f4a70 100644 --- a/src/elrail_func.h +++ b/src/elrail_func.h @@ -36,6 +36,6 @@ void DrawRailCatenary(const TileInfo *ti); void DrawRailCatenaryOnTunnel(const TileInfo *ti); void DrawRailCatenaryOnBridge(const TileInfo *ti); -void SettingsDisableElrail(int32 new_value); ///< _settings_game.disable_elrail callback +void SettingsDisableElrail(int32_t new_value); ///< _settings_game.disable_elrail callback #endif /* ELRAIL_FUNC_H */ diff --git a/src/engine.cpp b/src/engine.cpp index a7847763a4..9ae6a9deec 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -49,7 +49,7 @@ EngineOverrideManager _engine_mngr; static TimerGameCalendar::Year _year_engine_aging_stops; /** Number of engines of each vehicle type in original engine data */ -const uint8 _engine_counts[4] = { +const uint8_t _engine_counts[4] = { lengthof(_orig_rail_vehicle_info), lengthof(_orig_road_vehicle_info), lengthof(_orig_ship_vehicle_info), @@ -57,7 +57,7 @@ const uint8 _engine_counts[4] = { }; /** Offset of the first engine of each vehicle type in original engine data */ -const uint8 _engine_offsets[4] = { +const uint8_t _engine_offsets[4] = { 0, lengthof(_orig_rail_vehicle_info), lengthof(_orig_rail_vehicle_info) + lengthof(_orig_road_vehicle_info), @@ -151,7 +151,7 @@ bool Engine::IsEnabled() const * This is the GRF providing the Action 3. * @return GRF ID of the associated NewGRF. */ -uint32 Engine::GetGRFID() const +uint32_t Engine::GetGRFID() const { const GRFFile *file = this->GetGRF(); return file == nullptr ? 0 : file->grfid; @@ -195,7 +195,7 @@ bool Engine::CanCarryCargo() const * @param mail_capacity returns secondary cargo (mail) capacity of aircraft * @return Capacity */ -uint Engine::DetermineCapacity(const Vehicle *v, uint16 *mail_capacity) const +uint Engine::DetermineCapacity(const Vehicle *v, uint16_t *mail_capacity) const { assert(v == nullptr || this->index == v->engine_type); if (mail_capacity != nullptr) *mail_capacity = 0; @@ -213,7 +213,7 @@ uint Engine::DetermineCapacity(const Vehicle *v, uint16 *mail_capacity) const /* Check the refit capacity callback if we are not in the default configuration, or if we are using the new multiplier algorithm. */ if (HasBit(this->info.callback_mask, CBM_VEHICLE_REFIT_CAPACITY) && (new_multipliers || default_cargo != cargo_type || (v != nullptr && v->cargo_subtype != 0))) { - uint16 callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, this->index, v); + uint16_t callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, this->index, v); if (callback != CALLBACK_FAILED) return callback; } @@ -256,8 +256,8 @@ uint Engine::DetermineCapacity(const Vehicle *v, uint16 *mail_capacity) const /* Apply multipliers depending on cargo- and vehicletype. */ if (new_multipliers || (this->type != VEH_SHIP && default_cargo != cargo_type)) { - uint16 default_multiplier = new_multipliers ? 0x100 : CargoSpec::Get(default_cargo)->multiplier; - uint16 cargo_multiplier = CargoSpec::Get(cargo_type)->multiplier; + uint16_t default_multiplier = new_multipliers ? 0x100 : CargoSpec::Get(default_cargo)->multiplier; + uint16_t cargo_multiplier = CargoSpec::Get(cargo_type)->multiplier; capacity *= cargo_multiplier; if (extra_mail_cap > 0) { uint mail_multiplier = CargoSpec::Get(CT_MAIL)->multiplier; @@ -445,7 +445,7 @@ TimerGameCalendar::Date Engine::GetLifeLengthInDays() const * Get the range of an aircraft type. * @return Range of the aircraft type in tiles or 0 if unlimited range. */ -uint16 Engine::GetRange() const +uint16_t Engine::GetRange() const { switch (this->type) { case VEH_AIRCRAFT: @@ -524,7 +524,7 @@ void EngineOverrideManager::ResetToDefaultMapping() * If dynnamic_engines is disabled, all newgrf share the same ID scope identified by INVALID_GRFID. * @return The engine ID if present, or INVALID_ENGINE if not. */ -EngineID EngineOverrideManager::GetID(VehicleType type, uint16 grf_local_id, uint32 grfid) +EngineID EngineOverrideManager::GetID(VehicleType type, uint16_t grf_local_id, uint32_t grfid) { EngineID index = 0; for (const EngineIDMapping &eid : *this) { @@ -611,7 +611,7 @@ void CalcEngineReliability(Engine *e, bool new_month) re = Engine::Get(re->info.variant_id); } - uint32 age = re->age; + uint32_t age = re->age; if (new_month && re->index > e->index && age != INT32_MAX) age++; /* parent variant's age has not yet updated. */ /* Check for early retirement */ @@ -675,7 +675,7 @@ void SetYearEngineAgingStops() * @param aging_date The date used for age calculations. * @param seed Random seed. */ -void StartupOneEngine(Engine *e, TimerGameCalendar::Date aging_date, uint32 seed) +void StartupOneEngine(Engine *e, TimerGameCalendar::Date aging_date, uint32_t seed) { const EngineInfo *ei = &e->info; @@ -692,7 +692,7 @@ void StartupOneEngine(Engine *e, TimerGameCalendar::Date aging_date, uint32 seed ei->base_intro ^ e->type ^ e->GetGRFID()); - uint32 r = Random(); + uint32_t r = Random(); /* Don't randomise the start-date in the first two years after gamestart to ensure availability * of engines in early starting games. @@ -745,7 +745,7 @@ void StartupEngines() { /* Aging of vehicles stops, so account for that when starting late */ const TimerGameCalendar::Date aging_date = std::min(TimerGameCalendar::date, TimerGameCalendar::ConvertYMDToDate(_year_engine_aging_stops, 0, 1)); - uint32 seed = Random(); + uint32_t seed = Random(); for (Engine *e : Engine::Iterate()) { StartupOneEngine(e, aging_date, seed); @@ -863,7 +863,7 @@ static CompanyID GetPreviewCompany(Engine *e) /* For trains the cargomask has no useful meaning, since you can attach other wagons */ CargoTypes cargomask = e->type != VEH_TRAIN ? GetUnionOfArticulatedRefitMasks(e->index, true) : ALL_CARGOTYPES; - int32 best_hist = -1; + int32_t best_hist = -1; for (const Company *c : Company::Iterate()) { if (c->block_preview == 0 && !HasBit(e->preview_asked, c->index) && c->old_economy[0].performance_history > best_hist) { diff --git a/src/engine_base.h b/src/engine_base.h index a05e8ee98f..80b6e508f1 100644 --- a/src/engine_base.h +++ b/src/engine_base.h @@ -37,22 +37,22 @@ extern EnginePool _engine_pool; struct Engine : EnginePool::PoolItem<&_engine_pool> { std::string name; ///< Custom name of engine. TimerGameCalendar::Date intro_date; ///< Date of introduction of the engine. - int32 age; ///< Age of the engine in months. - uint16 reliability; ///< Current reliability of the engine. - uint16 reliability_spd_dec; ///< Speed of reliability decay between services (per day). - uint16 reliability_start; ///< Initial reliability of the engine. - uint16 reliability_max; ///< Maximal reliability of the engine. - uint16 reliability_final; ///< Final reliability of the engine. - uint16 duration_phase_1; ///< First reliability phase in months, increasing reliability from #reliability_start to #reliability_max. - uint16 duration_phase_2; ///< Second reliability phase in months, keeping #reliability_max. - uint16 duration_phase_3; ///< Third reliability phase in months, decaying to #reliability_final. + int32_t age; ///< Age of the engine in months. + uint16_t reliability; ///< Current reliability of the engine. + uint16_t reliability_spd_dec; ///< Speed of reliability decay between services (per day). + uint16_t reliability_start; ///< Initial reliability of the engine. + uint16_t reliability_max; ///< Maximal reliability of the engine. + uint16_t reliability_final; ///< Final reliability of the engine. + uint16_t duration_phase_1; ///< First reliability phase in months, increasing reliability from #reliability_start to #reliability_max. + uint16_t duration_phase_2; ///< Second reliability phase in months, keeping #reliability_max. + uint16_t duration_phase_3; ///< Third reliability phase in months, decaying to #reliability_final. byte flags; ///< Flags of the engine. @see EngineFlags CompanyMask preview_asked; ///< Bit for each company which has already been offered a preview. CompanyID preview_company; ///< Company which is currently being offered a preview \c INVALID_COMPANY means no company. byte preview_wait; ///< Daily countdown timer for timeout of offering the engine to the #preview_company company. CompanyMask company_avail; ///< Bit for each company whether the engine is available for that company. CompanyMask company_hidden; ///< Bit for each company whether the engine is normally hidden in the build gui for that company. - uint8 original_image_index; ///< Original vehicle image index, thus the image index of the overridden vehicle + uint8_t original_image_index; ///< Original vehicle image index, thus the image index of the overridden vehicle VehicleType type; ///< %Vehicle type, ie #VEH_ROAD, #VEH_TRAIN, etc. EngineDisplayFlags display_flags; ///< NOSAVE client-side-only display flags for build engine list. @@ -76,7 +76,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> { */ GRFFilePropsBase grf_prop; std::vector overrides; - uint16 list_position; + uint16_t list_position; Engine() {} Engine(VehicleType type, EngineID base); @@ -98,7 +98,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> { return this->info.cargo_type; } - uint DetermineCapacity(const Vehicle *v, uint16 *mail_capacity = nullptr) const; + uint DetermineCapacity(const Vehicle *v, uint16_t *mail_capacity = nullptr) const; bool CanCarryCargo() const; @@ -113,7 +113,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> { * @return The default capacity * @see GetDefaultCargoType */ - uint GetDisplayDefaultCapacity(uint16 *mail_capacity = nullptr) const + uint GetDisplayDefaultCapacity(uint16_t *mail_capacity = nullptr) const { return this->DetermineCapacity(nullptr, mail_capacity); } @@ -125,7 +125,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> { uint GetDisplayWeight() const; uint GetDisplayMaxTractiveEffort() const; TimerGameCalendar::Date GetLifeLengthInDays() const; - uint16 GetRange() const; + uint16_t GetRange() const; StringID GetAircraftTypeText() const; /** @@ -169,7 +169,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> { return this->grf_prop.grffile; } - uint32 GetGRFID() const; + uint32_t GetGRFID() const; struct EngineTypeFilter { VehicleType vt; @@ -190,10 +190,10 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> { }; struct EngineIDMapping { - uint32 grfid; ///< The GRF ID of the file the entity belongs to - uint16 internal_id; ///< The internal ID within the GRF file + uint32_t grfid; ///< The GRF ID of the file the entity belongs to + uint16_t internal_id; ///< The internal ID within the GRF file VehicleType type; ///< The engine type - uint8 substitute_id; ///< The (original) entity ID to use if this GRF is not available (currently not used) + uint8_t substitute_id; ///< The (original) entity ID to use if this GRF is not available (currently not used) }; /** @@ -204,7 +204,7 @@ struct EngineOverrideManager : std::vector { static const uint NUM_DEFAULT_ENGINES; ///< Number of default entries void ResetToDefaultMapping(); - EngineID GetID(VehicleType type, uint16 grf_local_id, uint32 grfid); + EngineID GetID(VehicleType type, uint16_t grf_local_id, uint32_t grfid); static bool ResetToCurrentNewGRFConfig(); }; diff --git a/src/engine_func.h b/src/engine_func.h index 0513b21c56..8036134c8e 100644 --- a/src/engine_func.h +++ b/src/engine_func.h @@ -20,14 +20,14 @@ void StartupEngines(); void CheckEngines(); /* Original engine data counts and offsets */ -extern const uint8 _engine_counts[4]; -extern const uint8 _engine_offsets[4]; +extern const uint8_t _engine_counts[4]; +extern const uint8_t _engine_offsets[4]; bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company); bool IsEngineRefittable(EngineID engine); void SetYearEngineAgingStops(); void CalcEngineReliability(Engine *e, bool new_month); -void StartupOneEngine(Engine *e, TimerGameCalendar::Date aging_date, uint32 seed); +void StartupOneEngine(Engine *e, TimerGameCalendar::Date aging_date, uint32_t seed); uint GetTotalCapacityOfArticulatedParts(EngineID engine); diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index e15ad40828..d909196b8c 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -190,9 +190,9 @@ static StringID GetTrainEngineInfoString(const Engine *e) static StringID GetAircraftEngineInfoString(const Engine *e) { CargoID cargo = e->GetDefaultCargoType(); - uint16 mail_capacity; + uint16_t mail_capacity; uint capacity = e->GetDisplayDefaultCapacity(&mail_capacity); - uint16 range = e->GetRange(); + uint16_t range = e->GetRange(); uint i = 0; SetDParam(i++, e->GetCost()); diff --git a/src/engine_gui.h b/src/engine_gui.h index b33cfaa36b..56a2409035 100644 --- a/src/engine_gui.h +++ b/src/engine_gui.h @@ -20,7 +20,7 @@ struct GUIEngineListItem { EngineID engine_id; ///< Engine to display in build purchase list EngineID variant_id; ///< Variant group of the engine. EngineDisplayFlags flags; ///< Flags for toggling/drawing (un)folded status and controlling indentation. - int8 indent; ///< Display indentation level. + int8_t indent; ///< Display indentation level. GUIEngineListItem(EngineID engine_id, EngineID variant_id, EngineDisplayFlags flags, int indent) : engine_id(engine_id), variant_id(variant_id), flags(flags), indent(indent) {} diff --git a/src/engine_type.h b/src/engine_type.h index 90446af785..809cb408e6 100644 --- a/src/engine_type.h +++ b/src/engine_type.h @@ -18,7 +18,7 @@ #include "sound_type.h" #include "strings_type.h" -typedef uint16 EngineID; ///< Unique identification number of an engine. +typedef uint16_t EngineID; ///< Unique identification number of an engine. struct Engine; @@ -45,30 +45,30 @@ struct RailVehicleInfo { byte cost_factor; ///< Purchase cost factor; For multiheaded engines the sum of both engine prices. RailType railtype; ///< Railtype, mangled if elrail is disabled. RailType intended_railtype; ///< Intended railtype, regardless of elrail being enabled or disabled. - uint16 max_speed; ///< Maximum speed (1 unit = 1/1.6 mph = 1 km-ish/h) - uint16 power; ///< Power of engine (hp); For multiheaded engines the sum of both engine powers. - uint16 weight; ///< Weight of vehicle (tons); For multiheaded engines the weight of each single engine. + uint16_t max_speed; ///< Maximum speed (1 unit = 1/1.6 mph = 1 km-ish/h) + uint16_t power; ///< Power of engine (hp); For multiheaded engines the sum of both engine powers. + uint16_t weight; ///< Weight of vehicle (tons); For multiheaded engines the weight of each single engine. byte running_cost; ///< Running cost of engine; For multiheaded engines the sum of both running costs. Price running_cost_class; EngineClass engclass; ///< Class of engine for this vehicle byte capacity; ///< Cargo capacity of vehicle; For multiheaded engines the capacity of each single engine. byte ai_passenger_only; ///< Bit value to tell AI that this engine is for passenger use only - uint16 pow_wag_power; ///< Extra power applied to consist if wagon should be powered + uint16_t pow_wag_power; ///< Extra power applied to consist if wagon should be powered byte pow_wag_weight; ///< Extra weight applied to consist if wagon should be powered byte visual_effect; ///< Bitstuffed NewGRF visual effect data byte shorten_factor; ///< length on main map for this type is 8 - shorten_factor byte tractive_effort; ///< Tractive effort coefficient byte air_drag; ///< Coefficient of air drag byte user_def_data; ///< Property 0x25: "User-defined bit mask" Used only for (very few) NewGRF vehicles - int16 curve_speed_mod; ///< Modifier to maximum speed in curves (fixed-point binary with 8 fractional bits) + int16_t curve_speed_mod; ///< Modifier to maximum speed in curves (fixed-point binary with 8 fractional bits) }; /** Information about a ship vehicle. */ struct ShipVehicleInfo { byte image_index; byte cost_factor; - uint16 max_speed; ///< Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h) - uint16 capacity; + uint16_t max_speed; ///< Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h) + uint16_t capacity; byte running_cost; SoundID sfx; bool old_refittable; ///< Is ship refittable; only used during initialisation. Later use EngineInfo::refit_mask. @@ -103,10 +103,10 @@ struct AircraftVehicleInfo { byte subtype; ///< Type of aircraft. @see AircraftSubTypeBits SoundID sfx; byte acceleration; - uint16 max_speed; ///< Maximum speed (1 unit = 8 mph = 12.8 km-ish/h) + uint16_t max_speed; ///< Maximum speed (1 unit = 8 mph = 12.8 km-ish/h) byte mail_capacity; ///< Mail capacity (bags). - uint16 passenger_capacity; ///< Passenger capacity (persons). - uint16 max_range; ///< Maximum range of this aircraft. + uint16_t passenger_capacity; ///< Passenger capacity (persons). + uint16_t max_range; ///< Maximum range of this aircraft. }; /** Information about a road vehicle. */ @@ -116,18 +116,18 @@ struct RoadVehicleInfo { byte running_cost; Price running_cost_class; SoundID sfx; - uint16 max_speed; ///< Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h) + uint16_t max_speed; ///< Maximum speed (1 unit = 1/3.2 mph = 0.5 km-ish/h) byte capacity; - uint8 weight; ///< Weight in 1/4t units - uint8 power; ///< Power in 10hp units - uint8 tractive_effort; ///< Coefficient of tractive effort - uint8 air_drag; ///< Coefficient of air drag + uint8_t weight; ///< Weight in 1/4t units + uint8_t power; ///< Power in 10hp units + uint8_t tractive_effort; ///< Coefficient of tractive effort + uint8_t air_drag; ///< Coefficient of air drag byte visual_effect; ///< Bitstuffed NewGRF visual effect data byte shorten_factor; ///< length on main map for this type is 8 - shorten_factor RoadType roadtype; ///< Road type }; -enum class ExtraEngineFlags : uint32 { +enum class ExtraEngineFlags : uint32_t { None = 0, NoNews = (1U << 0), ///< No 'new vehicle' news will be generated. NoPreview = (1U << 1), ///< No exclusive preview will be offered. @@ -151,10 +151,10 @@ struct EngineInfo { CargoTypes refit_mask; byte refit_cost; byte misc_flags; ///< Miscellaneous flags. @see EngineMiscFlags - uint16 callback_mask; ///< Bitmask of vehicle callbacks that have to be called - int8 retire_early; ///< Number of years early to retire vehicle + uint16_t callback_mask; ///< Bitmask of vehicle callbacks that have to be called + int8_t retire_early; ///< Number of years early to retire vehicle StringID string_id; ///< Default name of engine - uint16 cargo_age_period; ///< Number of ticks before carried cargo is aged. + uint16_t cargo_age_period; ///< Number of ticks before carried cargo is aged. EngineID variant_id; ///< Engine variant ID. If set, will be treated specially in purchase lists. ExtraEngineFlags extra_flags; }; @@ -185,7 +185,7 @@ enum EngineFlags { /** * Contexts an engine name can be shown in. */ -enum EngineNameContext : uint8 { +enum EngineNameContext : uint8_t { Generic = 0x00, ///< No specific context available. VehicleDetails = 0x11, ///< Name is shown in the vehicle details GUI. PurchaseList = 0x20, ///< Name is shown in the purchase list (including autoreplace window 'Available vehicles' panel). @@ -194,9 +194,9 @@ enum EngineNameContext : uint8 { }; /** Combine an engine ID and a name context to an engine name dparam. */ -inline uint64 PackEngineNameDParam(EngineID engine_id, EngineNameContext context, uint32 extra_data = 0) +inline uint64_t PackEngineNameDParam(EngineID engine_id, EngineNameContext context, uint32_t extra_data = 0) { - return engine_id | (static_cast(context) << 32) | (static_cast(extra_data) << 40); + return engine_id | (static_cast(context) << 32) | (static_cast(extra_data) << 40); } static const uint MAX_LENGTH_ENGINE_NAME_CHARS = 32; ///< The maximum length of an engine name in characters including '\0' diff --git a/src/error.h b/src/error.h index a20be8883f..0f1964fb80 100644 --- a/src/error.h +++ b/src/error.h @@ -33,8 +33,8 @@ protected: bool is_critical; ///< Whether the error message is critical. std::vector params; ///< Backup of parameters of the message strings. const GRFFile *textref_stack_grffile; ///< NewGRF that filled the #TextRefStack for the error message. - uint textref_stack_size; ///< Number of uint32 values to put on the #TextRefStack for the error message. - uint32 textref_stack[16]; ///< Values to put on the #TextRefStack for the error message. + uint textref_stack_size; ///< Number of uint32_t values to put on the #TextRefStack for the error message. + uint32_t textref_stack[16]; ///< Values to put on the #TextRefStack for the error message. StringID summary_msg; ///< General error message showed in first line. Must be valid. StringID detailed_msg; ///< Detailed error message showed in second line. Can be #INVALID_STRING_ID. StringID extra_msg; ///< Extra error message shown in third line. Can be #INVALID_STRING_ID. @@ -43,7 +43,7 @@ protected: public: ErrorMessageData(const ErrorMessageData &data); - ErrorMessageData(StringID summary_msg, StringID detailed_msg, bool is_critical = false, int x = 0, int y = 0, const GRFFile *textref_stack_grffile = nullptr, uint textref_stack_size = 0, const uint32 *textref_stack = nullptr, StringID extra_msg = INVALID_STRING_ID); + ErrorMessageData(StringID summary_msg, StringID detailed_msg, bool is_critical = false, int x = 0, int y = 0, const GRFFile *textref_stack_grffile = nullptr, uint textref_stack_size = 0, const uint32_t *textref_stack = nullptr, StringID extra_msg = INVALID_STRING_ID); /* Remove the copy assignment, as the default implementation will not do the right thing. */ ErrorMessageData &operator=(ErrorMessageData &rhs) = delete; @@ -51,7 +51,7 @@ public: /** Check whether error window shall display a company manager face */ bool HasFace() const { return face != INVALID_COMPANY; } - void SetDParam(uint n, uint64 v); + void SetDParam(uint n, uint64_t v); void SetDParamStr(uint n, const char *str); void SetDParamStr(uint n, const std::string &str); @@ -65,7 +65,7 @@ void ScheduleErrorMessage(ErrorList &datas); void ScheduleErrorMessage(const ErrorMessageData &data); void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc); -void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x = 0, int y = 0, const GRFFile *textref_stack_grffile = nullptr, uint textref_stack_size = 0, const uint32 *textref_stack = nullptr, StringID extra_msg = INVALID_STRING_ID); +void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x = 0, int y = 0, const GRFFile *textref_stack_grffile = nullptr, uint textref_stack_size = 0, const uint32_t *textref_stack = nullptr, StringID extra_msg = INVALID_STRING_ID); bool HideActiveErrorMessage(); void ClearErrorMessages(); diff --git a/src/error_gui.cpp b/src/error_gui.cpp index 40b693bd75..7702b43578 100644 --- a/src/error_gui.cpp +++ b/src/error_gui.cpp @@ -88,11 +88,11 @@ ErrorMessageData::ErrorMessageData(const ErrorMessageData &data) : * @param x World X position (TileVirtX) of the error location. Set both x and y to 0 to just center the message when there is no related error tile. * @param y World Y position (TileVirtY) of the error location. Set both x and y to 0 to just center the message when there is no related error tile. * @param textref_stack_grffile NewGRF that provides the #TextRefStack for the error message. - * @param textref_stack_size Number of uint32 values to put on the #TextRefStack for the error message; 0 if the #TextRefStack shall not be used. + * @param textref_stack_size Number of uint32_t values to put on the #TextRefStack for the error message; 0 if the #TextRefStack shall not be used. * @param textref_stack Values to put on the #TextRefStack. * @param extra_msg Extra error message showed in third line. Can be INVALID_STRING_ID. */ -ErrorMessageData::ErrorMessageData(StringID summary_msg, StringID detailed_msg, bool is_critical, int x, int y, const GRFFile *textref_stack_grffile, uint textref_stack_size, const uint32 *textref_stack, StringID extra_msg) : +ErrorMessageData::ErrorMessageData(StringID summary_msg, StringID detailed_msg, bool is_critical, int x, int y, const GRFFile *textref_stack_grffile, uint textref_stack_size, const uint32_t *textref_stack, StringID extra_msg) : is_critical(is_critical), textref_stack_grffile(textref_stack_grffile), textref_stack_size(textref_stack_size), @@ -131,7 +131,7 @@ void ErrorMessageData::CopyOutDParams() * @param n Parameter index * @param v Parameter value */ -void ErrorMessageData::SetDParam(uint n, uint64 v) +void ErrorMessageData::SetDParam(uint n, uint64_t v) { if (n >= this->params.size()) this->params.resize(n + 1); this->params[n] = v; @@ -217,7 +217,7 @@ public: } } - Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override + Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override { /* Position (0, 0) given, center the window. */ if (this->position.x == 0 && this->position.y == 0) { @@ -385,11 +385,11 @@ void ShowErrorMessage(StringID summary_msg, int x, int y, CommandCost cc) * @param x World X position (TileVirtX) of the error location. Set both x and y to 0 to just center the message when there is no related error tile. * @param y World Y position (TileVirtY) of the error location. Set both x and y to 0 to just center the message when there is no related error tile. * @param textref_stack_grffile NewGRF providing the #TextRefStack for the error message. - * @param textref_stack_size Number of uint32 values to put on the #TextRefStack for the error message; 0 if the #TextRefStack shall not be used. + * @param textref_stack_size Number of uint32_t values to put on the #TextRefStack for the error message; 0 if the #TextRefStack shall not be used. * @param textref_stack Values to put on the #TextRefStack. * @param extra_msg Extra error message shown in third line. Can be INVALID_STRING_ID. */ -void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x, int y, const GRFFile *textref_stack_grffile, uint textref_stack_size, const uint32 *textref_stack, StringID extra_msg) +void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel wl, int x, int y, const GRFFile *textref_stack_grffile, uint textref_stack_size, const uint32_t *textref_stack, StringID extra_msg) { assert(textref_stack_size == 0 || (textref_stack_grffile != nullptr && textref_stack != nullptr)); if (summary_msg == STR_NULL) summary_msg = STR_EMPTY; diff --git a/src/fios.cpp b/src/fios.cpp index b78bd1cc49..c2becb25f1 100644 --- a/src/fios.cpp +++ b/src/fios.cpp @@ -604,7 +604,7 @@ const char *FiosGetScreenshotDir() /** Basic data to distinguish a scenario. Used in the server list window */ struct ScenarioIdentifier { - uint32 scenid; ///< ID for the scenario (generated by content). + uint32_t scenid; ///< ID for the scenario (generated by content). MD5Hash md5sum; ///< MD5 checksum of file. std::string filename; ///< filename of the file. @@ -652,7 +652,7 @@ public: id.filename = filename; Md5 checksum; - uint8 buffer[1024]; + uint8_t buffer[1024]; size_t len, size; /* open the scenario file, but first get the name. diff --git a/src/fios.h b/src/fios.h index 71ca224e44..8c727c2e32 100644 --- a/src/fios.h +++ b/src/fios.h @@ -35,7 +35,7 @@ struct LoadCheckData { StringID error; ///< Error message from loading. INVALID_STRING_ID if no error. std::string error_msg; ///< Data to pass to SetDParamStr when displaying #error. - uint32 map_size_x, map_size_y; + uint32_t map_size_x, map_size_y; TimerGameCalendar::Date current_date; GameSettings settings; @@ -78,7 +78,7 @@ extern LoadCheckData _load_check_data; /** Deals with finding savegames */ struct FiosItem { FiosType type; - uint64 mtime; + uint64_t mtime; std::string title; std::string name; bool operator< (const FiosItem &other) const; diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index ffd1b852cf..67883c9a9c 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -735,7 +735,7 @@ public: } } - EventState OnKeyPress(WChar key, uint16 keycode) override + EventState OnKeyPress(char32_t key, uint16_t keycode) override { if (keycode == WKC_ESC) { this->Close(); diff --git a/src/fontcache.h b/src/fontcache.h index 04c38a6888..79af2e2992 100644 --- a/src/fontcache.h +++ b/src/fontcache.h @@ -14,7 +14,7 @@ #include "spritecache.h" /** Glyphs are characters from a font. */ -typedef uint32 GlyphID; +typedef uint32_t GlyphID; static const GlyphID SPRITE_GLYPH = 1U << 30; /** Font cache for basic fonts. */ @@ -78,7 +78,7 @@ public: * @param key The key to map to. * @param sprite The sprite that is being mapped. */ - virtual void SetUnicodeGlyph(WChar key, SpriteID sprite) = 0; + virtual void SetUnicodeGlyph(char32_t key, SpriteID sprite) = 0; /** Initialize the glyph map */ virtual void InitializeUnicodeGlyphMap() = 0; @@ -111,7 +111,7 @@ public: * @param key The character. * @return The glyph ID used to draw the character. */ - virtual GlyphID MapCharToGlyph(WChar key) = 0; + virtual GlyphID MapCharToGlyph(char32_t key) = 0; /** * Read a font table from the font. @@ -119,7 +119,7 @@ public: * @param length The length of the read data. * @return The loaded table data. */ - virtual const void *GetFontTable(uint32 tag, size_t &length) = 0; + virtual const void *GetFontTable(uint32_t tag, size_t &length) = 0; /** * Get the native OS font handle, if there is one. @@ -164,7 +164,7 @@ public: }; /** Map a SpriteID to the font size and key */ -static inline void SetUnicodeGlyph(FontSize size, WChar key, SpriteID sprite) +static inline void SetUnicodeGlyph(FontSize size, char32_t key, SpriteID sprite) { FontCache::Get(size)->SetUnicodeGlyph(key, sprite); } @@ -185,14 +185,14 @@ static inline void ClearFontCache() } /** Get the Sprite for a glyph */ -static inline const Sprite *GetGlyph(FontSize size, WChar key) +static inline const Sprite *GetGlyph(FontSize size, char32_t key) { FontCache *fc = FontCache::Get(size); return fc->GetGlyph(fc->MapCharToGlyph(key)); } /** Get the width of a glyph */ -static inline uint GetGlyphWidth(FontSize size, WChar key) +static inline uint GetGlyphWidth(FontSize size, char32_t key) { FontCache *fc = FontCache::Get(size); return fc->GetGlyphWidth(fc->MapCharToGlyph(key)); diff --git a/src/fontcache/freetypefontcache.cpp b/src/fontcache/freetypefontcache.cpp index 7fbf52e97c..19da21bbe5 100644 --- a/src/fontcache/freetypefontcache.cpp +++ b/src/fontcache/freetypefontcache.cpp @@ -34,14 +34,14 @@ private: FT_Face face; ///< The font face associated with this font. void SetFontSize(FontSize fs, FT_Face face, int pixels); - const void *InternalGetFontTable(uint32 tag, size_t &length) override; + const void *InternalGetFontTable(uint32_t tag, size_t &length) override; const Sprite *InternalGetGlyph(GlyphID key, bool aa) override; public: FreeTypeFontCache(FontSize fs, FT_Face face, int pixels); ~FreeTypeFontCache(); void ClearFontCache() override; - GlyphID MapCharToGlyph(WChar key) override; + GlyphID MapCharToGlyph(char32_t key) override; std::string GetFontName() override { return fmt::format("{}, {}", face->family_name, face->style_name); } bool IsBuiltInFont() override { return false; } const void *GetOSHandle() override { return &face; } @@ -275,7 +275,7 @@ const Sprite *FreeTypeFontCache::InternalGetGlyph(GlyphID key, bool aa) } -GlyphID FreeTypeFontCache::MapCharToGlyph(WChar key) +GlyphID FreeTypeFontCache::MapCharToGlyph(char32_t key) { assert(IsPrintable(key)); @@ -286,7 +286,7 @@ GlyphID FreeTypeFontCache::MapCharToGlyph(WChar key) return FT_Get_Char_Index(this->face, key); } -const void *FreeTypeFontCache::InternalGetFontTable(uint32 tag, size_t &length) +const void *FreeTypeFontCache::InternalGetFontTable(uint32_t tag, size_t &length) { FT_ULong len = 0; FT_Byte *result = nullptr; diff --git a/src/fontcache/spritefontcache.cpp b/src/fontcache/spritefontcache.cpp index 7dbb777de3..92d687482f 100644 --- a/src/fontcache/spritefontcache.cpp +++ b/src/fontcache/spritefontcache.cpp @@ -50,13 +50,13 @@ SpriteFontCache::~SpriteFontCache() this->ClearGlyphToSpriteMap(); } -SpriteID SpriteFontCache::GetUnicodeGlyph(WChar key) +SpriteID SpriteFontCache::GetUnicodeGlyph(char32_t key) { if (this->glyph_to_spriteid_map[GB(key, 8, 8)] == nullptr) return 0; return this->glyph_to_spriteid_map[GB(key, 8, 8)][GB(key, 0, 8)]; } -void SpriteFontCache::SetUnicodeGlyph(WChar key, SpriteID sprite) +void SpriteFontCache::SetUnicodeGlyph(char32_t key, SpriteID sprite) { if (this->glyph_to_spriteid_map == nullptr) this->glyph_to_spriteid_map = CallocT(256); if (this->glyph_to_spriteid_map[GB(key, 8, 8)] == nullptr) this->glyph_to_spriteid_map[GB(key, 8, 8)] = CallocT(256); diff --git a/src/fontcache/spritefontcache.h b/src/fontcache/spritefontcache.h index ce74972b3e..6693119f06 100644 --- a/src/fontcache/spritefontcache.h +++ b/src/fontcache/spritefontcache.h @@ -17,20 +17,20 @@ class SpriteFontCache : public FontCache { private: SpriteID **glyph_to_spriteid_map; ///< Mapping of glyphs to sprite IDs. - SpriteID GetUnicodeGlyph(WChar key); + SpriteID GetUnicodeGlyph(char32_t key); void ClearGlyphToSpriteMap(); public: SpriteFontCache(FontSize fs); ~SpriteFontCache(); - virtual void SetUnicodeGlyph(WChar key, SpriteID sprite); + virtual void SetUnicodeGlyph(char32_t key, SpriteID sprite); virtual void InitializeUnicodeGlyphMap(); virtual void ClearFontCache(); virtual const Sprite *GetGlyph(GlyphID key); virtual uint GetGlyphWidth(GlyphID key); virtual bool GetDrawGlyphShadow(); - virtual GlyphID MapCharToGlyph(WChar key) { assert(IsPrintable(key)); return SPRITE_GLYPH | key; } - virtual const void *GetFontTable(uint32 tag, size_t &length) { length = 0; return nullptr; } + virtual GlyphID MapCharToGlyph(char32_t key) { assert(IsPrintable(key)); return SPRITE_GLYPH | key; } + virtual const void *GetFontTable(uint32_t tag, size_t &length) { length = 0; return nullptr; } virtual std::string GetFontName() { return "sprite"; } virtual bool IsBuiltInFont() { return true; } }; diff --git a/src/fontcache/truetypefontcache.cpp b/src/fontcache/truetypefontcache.cpp index 6933b9ae78..ced99c3f47 100644 --- a/src/fontcache/truetypefontcache.cpp +++ b/src/fontcache/truetypefontcache.cpp @@ -165,7 +165,7 @@ const Sprite *TrueTypeFontCache::GetGlyph(GlyphID key) return this->InternalGetGlyph(key, GetFontAAState(this->fs)); } -const void *TrueTypeFontCache::GetFontTable(uint32 tag, size_t &length) +const void *TrueTypeFontCache::GetFontTable(uint32_t tag, size_t &length) { const auto iter = this->font_tables.find(tag); if (iter != this->font_tables.end()) { diff --git a/src/fontcache/truetypefontcache.h b/src/fontcache/truetypefontcache.h index 18f248f2cb..2c84bbe2c9 100644 --- a/src/fontcache/truetypefontcache.h +++ b/src/fontcache/truetypefontcache.h @@ -55,17 +55,17 @@ protected: GlyphEntry *GetGlyphPtr(GlyphID key); void SetGlyphPtr(GlyphID key, const GlyphEntry *glyph, bool duplicate = false); - virtual const void *InternalGetFontTable(uint32 tag, size_t &length) = 0; + virtual const void *InternalGetFontTable(uint32_t tag, size_t &length) = 0; virtual const Sprite *InternalGetGlyph(GlyphID key, bool aa) = 0; public: TrueTypeFontCache(FontSize fs, int pixels); virtual ~TrueTypeFontCache(); int GetFontSize() const override { return this->used_size; } - void SetUnicodeGlyph(WChar key, SpriteID sprite) override { this->parent->SetUnicodeGlyph(key, sprite); } + void SetUnicodeGlyph(char32_t key, SpriteID sprite) override { this->parent->SetUnicodeGlyph(key, sprite); } void InitializeUnicodeGlyphMap() override { this->parent->InitializeUnicodeGlyphMap(); } const Sprite *GetGlyph(GlyphID key) override; - const void *GetFontTable(uint32 tag, size_t &length) override; + const void *GetFontTable(uint32_t tag, size_t &length) override; void ClearFontCache() override; uint GetGlyphWidth(GlyphID key) override; bool GetDrawGlyphShadow() override; diff --git a/src/framerate_gui.cpp b/src/framerate_gui.cpp index 824896014c..7b416e750e 100644 --- a/src/framerate_gui.cpp +++ b/src/framerate_gui.cpp @@ -415,13 +415,13 @@ struct FramerateWindow : Window { struct CachedDecimal { StringID strid; - uint32 value; + uint32_t value; inline void SetRate(double value, double target) { const double threshold_good = target * 0.95; const double threshold_bad = target * 2 / 3; - this->value = (uint32)(value * 100); + this->value = (uint32_t)(value * 100); this->strid = (value > threshold_good) ? STR_FRAMERATE_FPS_GOOD : (value < threshold_bad) ? STR_FRAMERATE_FPS_BAD : STR_FRAMERATE_FPS_WARN; } @@ -429,7 +429,7 @@ struct FramerateWindow : Window { { const double threshold_good = target / 3; const double threshold_bad = target; - this->value = (uint32)(value * 100); + this->value = (uint32_t)(value * 100); this->strid = (value < threshold_good) ? STR_FRAMERATE_MS_GOOD : (value > threshold_bad) ? STR_FRAMERATE_MS_BAD : STR_FRAMERATE_MS_WARN; } @@ -601,7 +601,7 @@ struct FramerateWindow : Window { void DrawElementTimesColumn(const Rect &r, StringID heading_str, const CachedDecimal *values) const { const Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR); - uint16 skip = sb->GetPosition(); + uint16_t skip = sb->GetPosition(); int drawable = this->num_displayed; int y = r.top; DrawString(r.left, r.right, y, heading_str, TC_FROMSTRING, SA_CENTER, true); @@ -623,7 +623,7 @@ struct FramerateWindow : Window { void DrawElementAllocationsColumn(const Rect &r) const { const Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR); - uint16 skip = sb->GetPosition(); + uint16_t skip = sb->GetPosition(); int drawable = this->num_displayed; int y = r.top; DrawString(r.left, r.right, y, STR_FRAMERATE_MEMORYUSE, TC_FROMSTRING, SA_CENTER, true); @@ -657,7 +657,7 @@ struct FramerateWindow : Window { case WID_FRW_TIMES_NAMES: { /* Render a column of titles for performance element names */ const Scrollbar *sb = this->GetScrollbar(WID_FRW_SCROLLBAR); - uint16 skip = sb->GetPosition(); + uint16_t skip = sb->GetPosition(); int drawable = this->num_displayed; int y = r.top + FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.vsep_normal; // first line contains headings in the value columns for (PerformanceElement e : DISPLAY_ORDER_PFE) { @@ -949,7 +949,7 @@ struct FrametimeGraphWindow : Window { /* Position of last rendered data point */ Point lastpoint = { x_max, - (int)Scinterlate(y_zero, y_max, 0, this->vertical_scale, durations[point]) + (int)Scinterlate(y_zero, y_max, 0, this->vertical_scale, durations[point]) }; /* Timestamp of last rendered data point */ TimingMeasurement lastts = timestamps[point]; @@ -979,8 +979,8 @@ struct FrametimeGraphWindow : Window { /* Draw line from previous point to new point */ Point newpoint = { - (int)Scinterlate(x_zero, x_max, 0, (int64)draw_horz_scale, (int64)draw_horz_scale - (int64)time_sum), - (int)Scinterlate(y_zero, y_max, 0, (int64)draw_vert_scale, (int64)value) + (int)Scinterlate(x_zero, x_max, 0, (int64_t)draw_horz_scale, (int64_t)draw_horz_scale - (int64_t)time_sum), + (int)Scinterlate(y_zero, y_max, 0, (int64_t)draw_vert_scale, (int64_t)value) }; if (newpoint.x > lastpoint.x) continue; // don't draw backwards GfxDrawLine(lastpoint.x, lastpoint.y, newpoint.x, newpoint.y, c_lines); diff --git a/src/framerate_type.h b/src/framerate_type.h index f0116d8182..fc4660f200 100644 --- a/src/framerate_type.h +++ b/src/framerate_type.h @@ -80,7 +80,7 @@ enum PerformanceElement { DECLARE_POSTFIX_INCREMENT(PerformanceElement) /** Type used to hold a performance timing measurement */ -typedef uint64 TimingMeasurement; +typedef uint64_t TimingMeasurement; /** * RAII class for measuring simple elements of performance. diff --git a/src/game/game_gui.cpp b/src/game/game_gui.cpp index e3b1f12e0a..f926409086 100644 --- a/src/game/game_gui.cpp +++ b/src/game/game_gui.cpp @@ -361,7 +361,7 @@ struct GSConfigWindow : public Window { void OnQueryTextFinished(char *str) override { if (StrEmpty(str)) return; - int32 value = atoi(str); + int32_t value = atoi(str); SetValue(value); } diff --git a/src/game/game_text.hpp b/src/game/game_text.hpp index 619d094e6c..b964382796 100644 --- a/src/game/game_text.hpp +++ b/src/game/game_text.hpp @@ -18,9 +18,9 @@ struct StringParam { }; ParamType type; - uint8 consumes; + uint8_t consumes; - StringParam(ParamType type, uint8 consumes) : type(type), consumes(consumes) {} + StringParam(ParamType type, uint8_t consumes) : type(type), consumes(consumes) {} }; using StringParams = std::vector; using StringParamsList = std::vector; diff --git a/src/gamelog.cpp b/src/gamelog.cpp index 3d2a1b46ab..a0e7d63bff 100644 --- a/src/gamelog.cpp +++ b/src/gamelog.cpp @@ -24,7 +24,7 @@ extern const SaveLoadVersion SAVEGAME_VERSION; ///< current savegame version extern SavegameType _savegame_type; ///< type of savegame we are loading -extern uint32 _ttdp_version; ///< version of TTDP savegame (if applicable) +extern uint32_t _ttdp_version; ///< version of TTDP savegame (if applicable) extern SaveLoadVersion _sl_version; ///< the major savegame version identifier extern byte _sl_minor_version; ///< the minor savegame version, DO NOT USE! @@ -406,7 +406,7 @@ void Gamelog::Oldver() * @param oldval old setting value * @param newval new setting value */ -void Gamelog::Setting(const std::string &name, int32 oldval, int32 newval) +void Gamelog::Setting(const std::string &name, int32_t oldval, int32_t newval) { assert(this->action_type == GLAT_SETTING); @@ -459,7 +459,7 @@ void Gamelog::TestMode() * @param bug type of bug, @see enum GRFBugs * @param data additional data */ -void Gamelog::GRFBug(uint32 grfid, byte bug, uint64 data) +void Gamelog::GRFBug(uint32_t grfid, byte bug, uint64_t data) { assert(this->action_type == GLAT_GRFBUG); @@ -475,7 +475,7 @@ void Gamelog::GRFBug(uint32 grfid, byte bug, uint64 data) * @param internal_id the internal ID of whatever's broken in the NewGRF * @return true iff a unique record was done */ -bool Gamelog::GRFBugReverse(uint32 grfid, uint16 internal_id) +bool Gamelog::GRFBugReverse(uint32_t grfid, uint16_t internal_id) { for (const LoggedAction &la : this->data->action) { for (const auto &lc : la.change) { @@ -510,7 +510,7 @@ static inline bool IsLoggableGrfConfig(const GRFConfig *g) * Logs removal of a GRF * @param grfid ID of removed GRF */ -void Gamelog::GRFRemove(uint32 grfid) +void Gamelog::GRFRemove(uint32_t grfid) { assert(this->action_type == GLAT_LOAD || this->action_type == GLAT_GRF); @@ -547,7 +547,7 @@ void Gamelog::GRFCompatible(const GRFIdentifier *newg) * @param grfid GRF that is moved * @param offset how far it is moved, positive = moved down */ -void Gamelog::GRFMove(uint32 grfid, int32 offset) +void Gamelog::GRFMove(uint32_t grfid, int32_t offset) { assert(this->action_type == GLAT_GRF); @@ -559,7 +559,7 @@ void Gamelog::GRFMove(uint32 grfid, int32 offset) * Details about parameters changed are not stored * @param grfid ID of GRF to store */ -void Gamelog::GRFParameters(uint32 grfid) +void Gamelog::GRFParameters(uint32_t grfid) { assert(this->action_type == GLAT_GRF); @@ -678,7 +678,7 @@ void Gamelog::GRFUpdate(const GRFConfig *oldc, const GRFConfig *newc) * @param[out] ever_modified Max value of 'modified' from all binaries that ever saved this savegame. * @param[out] removed_newgrfs Set to true if any NewGRFs have been removed. */ -void Gamelog::Info(uint32 *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs) +void Gamelog::Info(uint32_t *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs) { for (const LoggedAction &la : this->data->action) { for (const auto &lc : la.change) { diff --git a/src/gamelog.h b/src/gamelog.h index 0383169335..919ef9b5ba 100644 --- a/src/gamelog.h +++ b/src/gamelog.h @@ -13,7 +13,7 @@ #include "newgrf_config.h" /** The actions we log. */ -enum GamelogActionType : uint8 { +enum GamelogActionType : uint8_t { GLAT_START, ///< Game created GLAT_LOAD, ///< Game loaded GLAT_GRF, ///< GRF changed @@ -26,7 +26,7 @@ enum GamelogActionType : uint8 { }; /** Type of logged change */ -enum GamelogChangeType : uint8 { +enum GamelogChangeType : uint8_t { GLCT_MODE, ///< Scenario editor x Game, different landscape GLCT_REVISION, ///< Changed game revision string GLCT_OLDVER, ///< Loaded from savegame without logged data @@ -74,22 +74,22 @@ public: void Revision(); void Mode(); void Oldver(); - void Setting(const std::string &name, int32 oldval, int32 newval); + void Setting(const std::string &name, int32_t oldval, int32_t newval); void GRFUpdate(const GRFConfig *oldg, const GRFConfig *newg); void GRFAddList(const GRFConfig *newg); - void GRFRemove(uint32 grfid); + void GRFRemove(uint32_t grfid); void GRFAdd(const GRFConfig *newg); - void GRFBug(uint32 grfid, byte bug, uint64 data); - bool GRFBugReverse(uint32 grfid, uint16 internal_id); + void GRFBug(uint32_t grfid, byte bug, uint64_t data); + bool GRFBugReverse(uint32_t grfid, uint16_t internal_id); void GRFCompatible(const GRFIdentifier *newg); - void GRFMove(uint32 grfid, int32 offset); - void GRFParameters(uint32 grfid); + void GRFMove(uint32_t grfid, int32_t offset); + void GRFParameters(uint32_t grfid); void TestRevision(); void TestMode(); - void Info(uint32 *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs); + void Info(uint32_t *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs); const GRFIdentifier *GetOverriddenIdentifier(const GRFConfig *c); /* Saveload handler for gamelog needs access to internal data. */ diff --git a/src/genworld.h b/src/genworld.h index e6def69444..e76eb15d1f 100644 --- a/src/genworld.h +++ b/src/genworld.h @@ -21,7 +21,7 @@ enum LandscapeGenerator { LG_TERRAGENESIS = 1, ///< TerraGenesis Perlin landscape generator }; -static const uint32 GENERATE_NEW_SEED = UINT32_MAX; ///< Create a new random seed +static const uint32_t GENERATE_NEW_SEED = UINT32_MAX; ///< Create a new random seed /** Modes for GenerateWorld */ enum GenWorldMode { @@ -96,7 +96,7 @@ void SetGeneratingWorldProgress(GenWorldProgress cls, uint total); void IncreaseGeneratingWorldProgress(GenWorldProgress cls); void PrepareGenerateWorldProgress(); void ShowGenerateWorldProgress(); -void StartNewGameWithoutGUI(uint32 seed); +void StartNewGameWithoutGUI(uint32_t seed); void ShowCreateScenario(); void StartScenarioEditor(); diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index a17c8e6633..d76ee4bf1c 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -821,7 +821,7 @@ struct GenerateLandscapeWindow : public Window { break; case WID_GL_WATER_PULLDOWN: { // Water quantity - uint32 hidden_mask = 0; + uint32_t hidden_mask = 0; /* Disable custom water level when the original map generator is active. */ if (_settings_newgame.game_creation.land_generator == LG_ORIGINAL) { SetBit(hidden_mask, CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY); @@ -961,7 +961,7 @@ struct GenerateLandscapeWindow : public Window { /* Was 'cancel' pressed? */ if (str == nullptr) return; - int32 value; + int32_t value; if (!StrEmpty(str)) { value = atoi(str); } else { @@ -1084,7 +1084,7 @@ void StartScenarioEditor() * Start a normal game without the GUI. * @param seed The seed of the new game. */ -void StartNewGameWithoutGUI(uint32 seed) +void StartNewGameWithoutGUI(uint32_t seed) { /* GenerateWorld takes care of the possible GENERATE_NEW_SEED value in 'seed' */ _settings_newgame.game_creation.generation_seed = seed; @@ -1253,7 +1253,7 @@ struct CreateScenarioWindow : public Window void OnQueryTextFinished(char *str) override { if (!StrEmpty(str)) { - int32 value = atoi(str); + int32_t value = atoi(str); switch (this->widget_id) { case WID_CS_START_DATE_TEXT: diff --git a/src/gfx.cpp b/src/gfx.cpp index 2f9e71c95b..ef2bbc06f3 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -38,7 +38,7 @@ byte _support8bpp; CursorVars _cursor; bool _ctrl_pressed; ///< Is Ctrl pressed? bool _shift_pressed; ///< Is Shift pressed? -uint16 _game_speed = 100; ///< Current game-speed; 100 is 1x, 0 is infinite. +uint16_t _game_speed = 100; ///< Current game-speed; 100 is 1x, 0 is infinite. bool _left_button_down; ///< Is left mouse button pressed? bool _left_button_clicked; ///< Is left mouse button clicked? bool _right_button_down; ///< Is right mouse button pressed? @@ -61,7 +61,7 @@ static std::recursive_mutex _palette_mutex; ///< To coordinate access to _cur_pa static void GfxMainBlitterViewport(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = nullptr, SpriteID sprite_id = SPR_CURSOR_MOUSE); static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = nullptr, SpriteID sprite_id = SPR_CURSOR_MOUSE, ZoomLevel zoom = ZOOM_LVL_NORMAL); -static ReusableBuffer _cursor_backup; +static ReusableBuffer _cursor_backup; ZoomLevel _gui_zoom = ZOOM_LVL_OUT_4X; ///< GUI Zoom level ZoomLevel _font_zoom = _gui_zoom; ///< Sprite font Zoom level (not clamped) @@ -145,7 +145,7 @@ void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectM switch (mode) { default: // FILLRECT_OPAQUE - blitter->DrawRect(dst, right, bottom, (uint8)colour); + blitter->DrawRect(dst, right, bottom, (uint8_t)colour); break; case FILLRECT_RECOLOUR: @@ -155,7 +155,7 @@ void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectM case FILLRECT_CHECKER: { byte bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1; do { - for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, (uint8)colour); + for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, (uint8_t)colour); dst = blitter->MoveTo(dst, 0, 1); } while (--bottom > 0); break; @@ -281,7 +281,7 @@ void GfxFillPolygon(const std::vector &shape, int colour, FillRectMode mo void *dst = blitter->MoveTo(dpi->dst_ptr, x1, y); switch (mode) { default: // FILLRECT_OPAQUE - blitter->DrawRect(dst, x2 - x1, 1, (uint8)colour); + blitter->DrawRect(dst, x2 - x1, 1, (uint8_t)colour); break; case FILLRECT_RECOLOUR: blitter->DrawColourMappingRect(dst, x2 - x1, 1, GB(colour, 0, PALETTE_WIDTH)); @@ -290,7 +290,7 @@ void GfxFillPolygon(const std::vector &shape, int colour, FillRectMode mo /* Fill every other pixel, offset such that the sum of filled pixels' X and Y coordinates is odd. * This creates a checkerboard effect. */ for (int x = (x1 + y) & 1; x < x2 - x1; x += 2) { - blitter->SetPixel(dst, x, 0, (uint8)colour); + blitter->SetPixel(dst, x, 0, (uint8_t)colour); } break; } @@ -315,7 +315,7 @@ void GfxFillPolygon(const std::vector &shape, int colour, FillRectMode mo * @param width Width of the line. * @param dash Length of dashes for dashed lines. 0 means solid line. */ -static inline void GfxDoDrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8 colour, int width, int dash = 0) +static inline void GfxDoDrawLine(void *video, int x, int y, int x2, int y2, int screen_width, int screen_height, uint8_t colour, int width, int dash = 0) { Blitter *blitter = BlitterFactory::GetCurrentBlitter(); @@ -909,7 +909,7 @@ ptrdiff_t GetCharAtPosition(std::string_view str, int x, FontSize start_fontsize * @param colour Colour to use, for details see _string_colourmap in * table/palettes.h or docs/ottd-colourtext-palette.png or the enum TextColour in gfx_type.h */ -void DrawCharCentered(WChar c, const Rect &r, TextColour colour) +void DrawCharCentered(char32_t c, const Rect &r, TextColour colour) { SetColourRemap(colour); GfxMainBlitter(GetGlyph(FS_NORMAL, c), @@ -1146,7 +1146,7 @@ static void GfxBlitter(const Sprite * const sprite, int x, int y, BlitterMode mo * @param zoom The zoom level at which to draw the sprites. * @return Pixel buffer, or nullptr if an 8bpp blitter is being used. */ -std::unique_ptr DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zoom) +std::unique_ptr DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zoom) { /* Invalid zoom level requested? */ if (zoom < _settings_client.gui.zoom_min || zoom > _settings_client.gui.zoom_max) return nullptr; @@ -1159,7 +1159,7 @@ std::unique_ptr DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zo const Sprite *sprite = GetSprite(real_sprite, SpriteType::Normal); Dimension dim = GetSpriteSize(real_sprite, nullptr, zoom); size_t dim_size = static_cast(dim.width) * dim.height; - std::unique_ptr result(new uint32[dim_size]); + std::unique_ptr result(new uint32_t[dim_size]); /* Set buffer to fully transparent. */ MemSetT(result.get(), 0, dim_size); @@ -1192,7 +1192,7 @@ std::unique_ptr DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zo if (blitter->GetScreenDepth() == 8) { /* Resolve palette. */ - uint32 *dst = result.get(); + uint32_t *dst = result.get(); const byte *src = pal_buffer.get(); for (size_t i = 0; i < dim_size; ++i) { *dst++ = _cur_palette.palette[*src++].data; @@ -1247,8 +1247,8 @@ bool CopyPalette(Palette &local_palette, bool force_copy) return true; } -#define EXTR(p, q) (((uint16)(palette_animation_counter * (p)) * (q)) >> 16) -#define EXTR2(p, q) (((uint16)(~palette_animation_counter * (p)) * (q)) >> 16) +#define EXTR(p, q) (((uint16_t)(palette_animation_counter * (p)) * (q)) >> 16) +#define EXTR2(p, q) (((uint16_t)(~palette_animation_counter * (p)) * (q)) >> 16) void DoPaletteAnimations() { @@ -1367,7 +1367,7 @@ void DoPaletteAnimations() * @param threshold Background colour brightness threshold below which the background is considered dark and TC_WHITE is returned, range: 0 - 255, default 128. * @return TC_BLACK or TC_WHITE depending on what gives a better contrast. */ -TextColour GetContrastColour(uint8 background, uint8 threshold) +TextColour GetContrastColour(uint8_t background, uint8_t threshold) { Colour c = _cur_palette.palette[background]; /* Compute brightness according to http://www.w3.org/TR/AERT#color-contrast. @@ -1400,7 +1400,7 @@ void LoadStringWidthTable(bool monospace) * @param key Character code glyph * @return Width of the character glyph */ -byte GetCharacterWidth(FontSize size, WChar key) +byte GetCharacterWidth(FontSize size, char32_t key) { /* Use _stringwidth_table cache if possible */ if (key >= 32 && key < 256) return _stringwidth_table[size][key - 32]; @@ -1517,7 +1517,7 @@ void DrawMouseCursor() _cursor.draw_size.x = width; _cursor.draw_size.y = height; - uint8 *buffer = _cursor_backup.Allocate(blitter->BufferSize(_cursor.draw_size.x, _cursor.draw_size.y)); + uint8_t *buffer = _cursor_backup.Allocate(blitter->BufferSize(_cursor.draw_size.x, _cursor.draw_size.y)); /* Make backup of stuff below cursor */ blitter->CopyToBuffer(blitter->MoveTo(_screen.dst_ptr, _cursor.draw_pos.x, _cursor.draw_pos.y), buffer, _cursor.draw_size.x, _cursor.draw_size.y); @@ -1946,7 +1946,7 @@ void UpdateGUIZoom() _gui_scale = Clamp(_gui_scale_cfg, MIN_INTERFACE_SCALE, MAX_INTERFACE_SCALE); } - int8 new_zoom = ScaleGUITrad(1) <= 1 ? ZOOM_LVL_OUT_4X : ScaleGUITrad(1) >= 4 ? ZOOM_LVL_MIN : ZOOM_LVL_OUT_2X; + int8_t new_zoom = ScaleGUITrad(1) <= 1 ? ZOOM_LVL_OUT_4X : ScaleGUITrad(1) >= 4 ? ZOOM_LVL_MIN : ZOOM_LVL_OUT_2X; /* Font glyphs should not be clamped to min/max zoom. */ _font_zoom = static_cast(new_zoom); /* Ensure the gui_zoom is clamped between min/max. */ diff --git a/src/gfx_func.h b/src/gfx_func.h index 9300b2cafd..82c654a598 100644 --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -54,7 +54,7 @@ extern byte _support8bpp; extern CursorVars _cursor; extern bool _ctrl_pressed; ///< Is Ctrl pressed? extern bool _shift_pressed; ///< Is Shift pressed? -extern uint16 _game_speed; +extern uint16_t _game_speed; extern bool _left_button_down; extern bool _left_button_clicked; @@ -69,7 +69,7 @@ extern Dimension _cur_resolution; extern Palette _cur_palette; ///< Current palette void HandleToolbarHotkey(int hotkey); -void HandleKeypress(uint keycode, WChar key); +void HandleKeypress(uint keycode, char32_t key); void HandleTextInput(const char *str, bool marked = false, const char *caret = nullptr, const char *insert_location = nullptr, const char *replacement_end = nullptr); void HandleCtrlChanged(); void HandleMouseEvents(); @@ -90,14 +90,14 @@ Dimension GetScaledSpriteSize(SpriteID sprid); /* widget.cpp */ void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = nullptr); void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = nullptr, ZoomLevel zoom = ZOOM_LVL_GUI); void DrawSpriteIgnorePadding(SpriteID img, PaletteID pal, const Rect &r, bool clicked, StringAlignment align); /* widget.cpp */ -std::unique_ptr DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zoom = ZOOM_LVL_GUI); +std::unique_ptr DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zoom = ZOOM_LVL_GUI); int DrawString(int left, int right, int top, std::string_view str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL); int DrawString(int left, int right, int top, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL); int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL); int DrawStringMultiLine(int left, int right, int top, int bottom, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL); -void DrawCharCentered(WChar c, const Rect &r, TextColour colour); +void DrawCharCentered(char32_t c, const Rect &r, TextColour colour); void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode = FILLRECT_OPAQUE); void GfxFillPolygon(const std::vector &shape, int colour, FillRectMode mode = FILLRECT_OPAQUE); @@ -177,7 +177,7 @@ void SortResolutions(); bool ToggleFullScreen(bool fs); /* gfx.cpp */ -byte GetCharacterWidth(FontSize size, WChar key); +byte GetCharacterWidth(FontSize size, char32_t key); byte GetDigitWidth(FontSize size = FS_NORMAL); void GetBroadestDigit(uint *front, uint *next, FontSize size = FS_NORMAL); @@ -208,7 +208,7 @@ static inline bool IsValidColours(Colours colours) return colours < COLOUR_END; } -TextColour GetContrastColour(uint8 background, uint8 threshold = 128); +TextColour GetContrastColour(uint8_t background, uint8_t threshold = 128); /** * All 16 colour gradients @@ -223,34 +223,34 @@ extern byte _colour_gradient[COLOUR_END][8]; */ #define GREY_SCALE(level) (level) -static const uint8 PC_BLACK = GREY_SCALE(1); ///< Black palette colour. -static const uint8 PC_DARK_GREY = GREY_SCALE(6); ///< Dark grey palette colour. -static const uint8 PC_GREY = GREY_SCALE(10); ///< Grey palette colour. -static const uint8 PC_WHITE = GREY_SCALE(15); ///< White palette colour. +static const uint8_t PC_BLACK = GREY_SCALE(1); ///< Black palette colour. +static const uint8_t PC_DARK_GREY = GREY_SCALE(6); ///< Dark grey palette colour. +static const uint8_t PC_GREY = GREY_SCALE(10); ///< Grey palette colour. +static const uint8_t PC_WHITE = GREY_SCALE(15); ///< White palette colour. -static const uint8 PC_VERY_DARK_RED = 0xB2; ///< Almost-black red palette colour. -static const uint8 PC_DARK_RED = 0xB4; ///< Dark red palette colour. -static const uint8 PC_RED = 0xB8; ///< Red palette colour. +static const uint8_t PC_VERY_DARK_RED = 0xB2; ///< Almost-black red palette colour. +static const uint8_t PC_DARK_RED = 0xB4; ///< Dark red palette colour. +static const uint8_t PC_RED = 0xB8; ///< Red palette colour. -static const uint8 PC_VERY_DARK_BROWN = 0x56; ///< Almost-black brown palette colour. +static const uint8_t PC_VERY_DARK_BROWN = 0x56; ///< Almost-black brown palette colour. -static const uint8 PC_ORANGE = 0xC2; ///< Orange palette colour. +static const uint8_t PC_ORANGE = 0xC2; ///< Orange palette colour. -static const uint8 PC_YELLOW = 0xBF; ///< Yellow palette colour. -static const uint8 PC_LIGHT_YELLOW = 0x44; ///< Light yellow palette colour. -static const uint8 PC_VERY_LIGHT_YELLOW = 0x45; ///< Almost-white yellow palette colour. +static const uint8_t PC_YELLOW = 0xBF; ///< Yellow palette colour. +static const uint8_t PC_LIGHT_YELLOW = 0x44; ///< Light yellow palette colour. +static const uint8_t PC_VERY_LIGHT_YELLOW = 0x45; ///< Almost-white yellow palette colour. -static const uint8 PC_GREEN = 0xD0; ///< Green palette colour. +static const uint8_t PC_GREEN = 0xD0; ///< Green palette colour. -static const uint8 PC_VERY_DARK_BLUE = 0x9A; ///< Almost-black blue palette colour. -static const uint8 PC_DARK_BLUE = 0x9D; ///< Dark blue palette colour. -static const uint8 PC_LIGHT_BLUE = 0x98; ///< Light blue palette colour. +static const uint8_t PC_VERY_DARK_BLUE = 0x9A; ///< Almost-black blue palette colour. +static const uint8_t PC_DARK_BLUE = 0x9D; ///< Dark blue palette colour. +static const uint8_t PC_LIGHT_BLUE = 0x98; ///< Light blue palette colour. -static const uint8 PC_ROUGH_LAND = 0x52; ///< Dark green palette colour for rough land. -static const uint8 PC_GRASS_LAND = 0x54; ///< Dark green palette colour for grass land. -static const uint8 PC_BARE_LAND = 0x37; ///< Brown palette colour for bare land. -static const uint8 PC_RAINFOREST = 0x5C; ///< Pale green palette colour for rainforest. -static const uint8 PC_FIELDS = 0x25; ///< Light brown palette colour for fields. -static const uint8 PC_TREES = 0x57; ///< Green palette colour for trees. -static const uint8 PC_WATER = 0xC9; ///< Dark blue palette colour for water. +static const uint8_t PC_ROUGH_LAND = 0x52; ///< Dark green palette colour for rough land. +static const uint8_t PC_GRASS_LAND = 0x54; ///< Dark green palette colour for grass land. +static const uint8_t PC_BARE_LAND = 0x37; ///< Brown palette colour for bare land. +static const uint8_t PC_RAINFOREST = 0x5C; ///< Pale green palette colour for rainforest. +static const uint8_t PC_FIELDS = 0x25; ///< Light brown palette colour for fields. +static const uint8_t PC_TREES = 0x57; ///< Green palette colour for trees. +static const uint8_t PC_WATER = 0xC9; ///< Dark blue palette colour for water. #endif /* GFX_FUNC_H */ diff --git a/src/gfx_layout.cpp b/src/gfx_layout.cpp index a17ef42f1c..6ae31bfd15 100644 --- a/src/gfx_layout.cpp +++ b/src/gfx_layout.cpp @@ -81,7 +81,7 @@ static inline void GetLayouter(Layouter::LineCacheItem &line, std::string_view s * usable by ParagraphLayout. */ for (; buff < buffer_last && cur != str.end();) { - WChar c = Utf8Consume(cur); + char32_t c = Utf8Consume(cur); if (c == '\0' || c == '\n') { /* Caller should already have filtered out these characters. */ NOT_REACHED(); @@ -209,7 +209,7 @@ Dimension Layouter::GetBounds() /** * Test whether a character is a non-printable formatting code */ -static bool IsConsumedFormattingCode(WChar ch) +static bool IsConsumedFormattingCode(char32_t ch) { if (ch >= SCC_BLUE && ch <= SCC_BLACK) return true; if (ch == SCC_PUSH_COLOUR) return true; @@ -240,7 +240,7 @@ Point Layouter::GetCharPosition(std::string_view::const_iterator ch) const size_t index = 0; auto str = this->string.begin(); while (str < ch) { - WChar c = Utf8Consume(str); + char32_t c = Utf8Consume(str); if (!IsConsumedFormattingCode(c)) index += line->GetInternalCharLength(c); } @@ -294,7 +294,7 @@ ptrdiff_t Layouter::GetCharAtPosition(int x) const for (auto str = this->string.begin(); str != this->string.end();) { if (cur_idx == index) return str - this->string.begin(); - WChar c = Utf8Consume(str); + char32_t c = Utf8Consume(str); if (!IsConsumedFormattingCode(c)) cur_idx += line->GetInternalCharLength(c); } } diff --git a/src/gfx_layout.h b/src/gfx_layout.h index 181bef5561..3a5b48d316 100644 --- a/src/gfx_layout.h +++ b/src/gfx_layout.h @@ -110,7 +110,7 @@ public: virtual int GetWidth() const = 0; virtual int CountRuns() const = 0; virtual const VisualRun &GetVisualRun(int run) const = 0; - virtual int GetInternalCharLength(WChar c) const = 0; + virtual int GetInternalCharLength(char32_t c) const = 0; }; virtual void Reflow() = 0; diff --git a/src/gfx_layout_fallback.cpp b/src/gfx_layout_fallback.cpp index 8656c4ae7d..7982317e63 100644 --- a/src/gfx_layout_fallback.cpp +++ b/src/gfx_layout_fallback.cpp @@ -46,7 +46,7 @@ public: int glyph_count; ///< The number of glyphs. public: - FallbackVisualRun(Font *font, const WChar *chars, int glyph_count, int char_offset, int x); + FallbackVisualRun(Font *font, const char32_t *chars, int glyph_count, int char_offset, int x); FallbackVisualRun(FallbackVisualRun &&other) noexcept; ~FallbackVisualRun() override; const Font *GetFont() const override; @@ -65,14 +65,14 @@ public: int CountRuns() const override; const ParagraphLayouter::VisualRun &GetVisualRun(int run) const override; - int GetInternalCharLength(WChar c) const override { return 1; } + int GetInternalCharLength(char32_t c) const override { return 1; } }; - const WChar *buffer_begin; ///< Begin of the buffer. - const WChar *buffer; ///< The current location in the buffer. + const char32_t *buffer_begin; ///< Begin of the buffer. + const char32_t *buffer; ///< The current location in the buffer. FontMap &runs; ///< The fonts we have to use for this paragraph. - FallbackParagraphLayout(WChar *buffer, int length, FontMap &runs); + FallbackParagraphLayout(char32_t *buffer, int length, FontMap &runs); void Reflow() override; std::unique_ptr NextLine(int max_width) override; }; @@ -84,7 +84,7 @@ public: * @param fontMapping THe mapping of the fonts. * @return The ParagraphLayout instance. */ -/* static */ ParagraphLayouter *FallbackParagraphLayoutFactory::GetParagraphLayout(WChar *buff, WChar *buff_end, FontMap &fontMapping) +/* static */ ParagraphLayouter *FallbackParagraphLayoutFactory::GetParagraphLayout(char32_t *buff, char32_t *buff_end, FontMap &fontMapping) { return new FallbackParagraphLayout(buff, buff_end - buff, fontMapping); } @@ -96,7 +96,7 @@ public: * @param c The character to add. * @return The number of buffer spaces that were used. */ -/* static */ size_t FallbackParagraphLayoutFactory::AppendToBuffer(WChar *buff, const WChar *buffer_last, WChar c) +/* static */ size_t FallbackParagraphLayoutFactory::AppendToBuffer(char32_t *buff, const char32_t *buffer_last, char32_t c) { *buff = c; return 1; @@ -110,7 +110,7 @@ public: * @param char_offset This run's offset from the start of the layout input string. * @param x The initial x position for this run. */ -FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun(Font *font, const WChar *chars, int char_count, int char_offset, int x) : +FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun(Font *font, const char32_t *chars, int char_count, int char_offset, int x) : font(font), glyph_count(char_count) { const bool isbuiltin = font->fc->IsBuiltInFont(); @@ -265,7 +265,7 @@ const ParagraphLayouter::VisualRun &FallbackParagraphLayout::FallbackLine::GetVi * @param length The length of the paragraph. * @param runs The font mapping of this paragraph. */ -FallbackParagraphLayout::FallbackParagraphLayout(WChar *buffer, int length, FontMap &runs) : buffer_begin(buffer), buffer(buffer), runs(runs) +FallbackParagraphLayout::FallbackParagraphLayout(char32_t *buffer, int length, FontMap &runs) : buffer_begin(buffer), buffer(buffer), runs(runs) { assert(runs.rbegin()->first == length); } @@ -308,14 +308,14 @@ std::unique_ptr FallbackParagraphLayout::NextLine } const FontCache *fc = iter->second->fc; - const WChar *next_run = this->buffer_begin + iter->first; + const char32_t *next_run = this->buffer_begin + iter->first; - const WChar *begin = this->buffer; - const WChar *last_space = nullptr; - const WChar *last_char; + const char32_t *begin = this->buffer; + const char32_t *last_space = nullptr; + const char32_t *last_char; int width = 0; for (;;) { - WChar c = *this->buffer; + char32_t c = *this->buffer; last_char = this->buffer; if (c == '\0') { diff --git a/src/gfx_layout_fallback.h b/src/gfx_layout_fallback.h index 15927ac001..89f6b3aaeb 100644 --- a/src/gfx_layout_fallback.h +++ b/src/gfx_layout_fallback.h @@ -18,12 +18,12 @@ class FallbackParagraphLayoutFactory { public: /** Helper for GetLayouter, to get the right type. */ - typedef WChar CharType; + typedef char32_t CharType; /** Helper for GetLayouter, to get whether the layouter supports RTL. */ static const bool SUPPORTS_RTL = false; - static ParagraphLayouter *GetParagraphLayout(WChar *buff, WChar *buff_end, FontMap &fontMapping); - static size_t AppendToBuffer(WChar *buff, const WChar *buffer_last, WChar c); + static ParagraphLayouter *GetParagraphLayout(char32_t *buff, char32_t *buff_end, FontMap &fontMapping); + static size_t AppendToBuffer(char32_t *buff, const char32_t *buffer_last, char32_t c); }; diff --git a/src/gfx_layout_icu.cpp b/src/gfx_layout_icu.cpp index 1311030a64..d731ef68da 100644 --- a/src/gfx_layout_icu.cpp +++ b/src/gfx_layout_icu.cpp @@ -89,7 +89,7 @@ public: int CountRuns() const override { return (uint)this->size(); } const VisualRun &GetVisualRun(int run) const override { return this->at(run); } - int GetInternalCharLength(WChar c) const override + int GetInternalCharLength(char32_t c) const override { /* ICU uses UTF-16 internally which means we need to account for surrogate pairs. */ return c >= 0x010000U ? 2 : 1; @@ -160,7 +160,7 @@ void ICURun::Shape(UChar *buff, size_t buff_length) { /* ICU buffer is in UTF-16. */ auto hbbuf = hb_buffer_create(); - hb_buffer_add_utf16(hbbuf, reinterpret_cast(buff), buff_length, this->start, this->length); + hb_buffer_add_utf16(hbbuf, reinterpret_cast(buff), buff_length, this->start, this->length); /* Set all the properties of this segment. */ hb_buffer_set_direction(hbbuf, (this->level & 1) == 1 ? HB_DIRECTION_RTL : HB_DIRECTION_LTR); @@ -522,10 +522,10 @@ std::unique_ptr ICUParagraphLayout::NextLine(int return line; } -/* static */ size_t ICUParagraphLayoutFactory::AppendToBuffer(UChar *buff, const UChar *buffer_last, WChar c) +/* static */ size_t ICUParagraphLayoutFactory::AppendToBuffer(UChar *buff, const UChar *buffer_last, char32_t c) { /* Transform from UTF-32 to internal ICU format of UTF-16. */ - int32 length = 0; + int32_t length = 0; UErrorCode err = U_ZERO_ERROR; u_strFromUTF32(buff, buffer_last - buff, &length, (UChar32*)&c, 1, &err); return length; diff --git a/src/gfx_layout_icu.h b/src/gfx_layout_icu.h index 2aff3cb555..07f2f68721 100644 --- a/src/gfx_layout_icu.h +++ b/src/gfx_layout_icu.h @@ -25,7 +25,7 @@ public: static const bool SUPPORTS_RTL = true; static ParagraphLayouter *GetParagraphLayout(UChar *buff, UChar *buff_end, FontMap &fontMapping); - static size_t AppendToBuffer(UChar *buff, const UChar *buffer_last, WChar c); + static size_t AppendToBuffer(UChar *buff, const UChar *buffer_last, char32_t c); }; #endif /* GFX_LAYOUT_ICU_H */ diff --git a/src/gfx_type.h b/src/gfx_type.h index 55f6a361a2..af7df61d38 100644 --- a/src/gfx_type.h +++ b/src/gfx_type.h @@ -14,9 +14,9 @@ #include "core/geometry_type.hpp" #include "zoom_type.h" -typedef uint32 SpriteID; ///< The number of a sprite, without mapping bits and colourtables -typedef uint32 PaletteID; ///< The number of the palette -typedef uint32 CursorID; ///< The number of the cursor (sprite) +typedef uint32_t SpriteID; ///< The number of a sprite, without mapping bits and colourtables +typedef uint32_t PaletteID; ///< The number of the palette +typedef uint32_t CursorID; ///< The number of the cursor (sprite) /** Combination of a palette sprite and a 'real' sprite */ struct PalSpriteID { @@ -157,14 +157,14 @@ struct DrawPixelInfo { /** Structure to access the alpha, red, green, and blue channels from a 32 bit number. */ union Colour { - uint32 data; ///< Conversion of the channel information to a 32 bit number. + uint32_t data; ///< Conversion of the channel information to a 32 bit number. struct { #if defined(__EMSCRIPTEN__) - uint8 r, g, b, a; ///< colour channels as used in browsers + uint8_t r, g, b, a; ///< colour channels as used in browsers #elif TTD_ENDIAN == TTD_BIG_ENDIAN - uint8 a, r, g, b; ///< colour channels in BE order + uint8_t a, r, g, b; ///< colour channels in BE order #else - uint8 b, g, r, a; ///< colour channels in LE order + uint8_t b, g, r, a; ///< colour channels in LE order #endif /* TTD_ENDIAN == TTD_BIG_ENDIAN */ }; @@ -175,7 +175,7 @@ union Colour { * @param b The channel for the blue colour. * @param a The channel for the alpha/transparency. */ - Colour(uint8 r, uint8 g, uint8 b, uint8 a = 0xFF) : + Colour(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 0xFF) : #if defined(__EMSCRIPTEN__) r(r), g(g), b(b), a(a) #elif TTD_ENDIAN == TTD_BIG_ENDIAN @@ -195,7 +195,7 @@ union Colour { } }; -static_assert(sizeof(Colour) == sizeof(uint32)); +static_assert(sizeof(Colour) == sizeof(uint32_t)); /** Available font sizes */ diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp index 198787be4f..bc91ea0094 100644 --- a/src/gfxinit.cpp +++ b/src/gfxinit.cpp @@ -406,7 +406,7 @@ MD5File::ChecksumResult MD5File::CheckMD5(Subdirectory subdir, size_t max_size) size = std::min(size, max_size); Md5 checksum; - uint8 buffer[1024]; + uint8_t buffer[1024]; MD5Hash digest; size_t len; diff --git a/src/goal.cpp b/src/goal.cpp index 716b36d477..9b0cb20027 100644 --- a/src/goal.cpp +++ b/src/goal.cpp @@ -245,11 +245,11 @@ CommandCost CmdSetGoalCompleted(DoCommandFlag flags, GoalID goal, bool completed * @param text Text of the question. * @return the cost of this operation or an error */ -CommandCost CmdGoalQuestion(DoCommandFlag flags, uint16 uniqueid, uint32 target, bool is_client, uint32 button_mask, GoalQuestionType type, const std::string &text) +CommandCost CmdGoalQuestion(DoCommandFlag flags, uint16_t uniqueid, uint32_t target, bool is_client, uint32_t button_mask, GoalQuestionType type, const std::string &text) { - static_assert(sizeof(uint32) >= sizeof(CompanyID)); + static_assert(sizeof(uint32_t) >= sizeof(CompanyID)); CompanyID company = (CompanyID)target; - static_assert(sizeof(uint32) >= sizeof(ClientID)); + static_assert(sizeof(uint32_t) >= sizeof(ClientID)); ClientID client = (ClientID)target; static_assert(GOAL_QUESTION_BUTTON_COUNT < 29); @@ -289,7 +289,7 @@ CommandCost CmdGoalQuestion(DoCommandFlag flags, uint16 uniqueid, uint32 target, * @param button Button the company pressed * @return the cost of this operation or an error */ -CommandCost CmdGoalQuestionAnswer(DoCommandFlag flags, uint16 uniqueid, uint8 button) +CommandCost CmdGoalQuestionAnswer(DoCommandFlag flags, uint16_t uniqueid, uint8_t button) { if (button >= GOAL_QUESTION_BUTTON_COUNT) return CMD_ERROR; diff --git a/src/goal_cmd.h b/src/goal_cmd.h index c7e0ff1e24..00fc6ecd15 100644 --- a/src/goal_cmd.h +++ b/src/goal_cmd.h @@ -19,8 +19,8 @@ CommandCost CmdSetGoalDestination(DoCommandFlag flags, GoalID goal, GoalType typ CommandCost CmdSetGoalText(DoCommandFlag flags, GoalID goal, const std::string &text); CommandCost CmdSetGoalProgress(DoCommandFlag flags, GoalID goal, const std::string &text); CommandCost CmdSetGoalCompleted(DoCommandFlag flags, GoalID goal, bool completed); -CommandCost CmdGoalQuestion(DoCommandFlag flags, uint16 uniqueid, uint32 target, bool is_client, uint32 button_mask, GoalQuestionType type, const std::string &text); -CommandCost CmdGoalQuestionAnswer(DoCommandFlag flags, uint16 uniqueid, uint8 button); +CommandCost CmdGoalQuestion(DoCommandFlag flags, uint16_t uniqueid, uint32_t target, bool is_client, uint32_t button_mask, GoalQuestionType type, const std::string &text); +CommandCost CmdGoalQuestionAnswer(DoCommandFlag flags, uint16_t uniqueid, uint8_t button); DEF_CMD_TRAIT(CMD_CREATE_GOAL, CmdCreateGoal, CMD_DEITY | CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT) DEF_CMD_TRAIT(CMD_REMOVE_GOAL, CmdRemoveGoal, CMD_DEITY, CMDT_OTHER_MANAGEMENT) diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp index 1dfb2997cb..bc640b0209 100644 --- a/src/goal_gui.cpp +++ b/src/goal_gui.cpp @@ -327,7 +327,7 @@ struct GoalQuestionWindow : public Window { int button[3]; ///< Buttons to display. TextColour colour; ///< Colour of the question text. - GoalQuestionWindow(WindowDesc *desc, WindowNumber window_number, TextColour colour, uint32 button_mask, const std::string &question) : Window(desc), colour(colour) + GoalQuestionWindow(WindowDesc *desc, WindowNumber window_number, TextColour colour, uint32_t button_mask, const std::string &question) : Window(desc), colour(colour) { this->question = question; @@ -550,7 +550,7 @@ static WindowDesc _goal_question_list_desc[] = { * @param button_mask Buttons to display. * @param question Question to ask. */ -void ShowGoalQuestion(uint16 id, byte type, uint32 button_mask, const std::string &question) +void ShowGoalQuestion(uint16_t id, byte type, uint32_t button_mask, const std::string &question) { assert(type < GQT_END); new GoalQuestionWindow(&_goal_question_list_desc[type], id, type == 3 ? TC_WHITE : TC_BLACK, button_mask, question); diff --git a/src/goal_type.h b/src/goal_type.h index 2db04b9f0a..f4af4af197 100644 --- a/src/goal_type.h +++ b/src/goal_type.h @@ -12,7 +12,7 @@ #include "core/enum_type.hpp" -static const uint32 GOAL_QUESTION_BUTTON_COUNT = 18; ///< Amount of buttons available. +static const uint32_t GOAL_QUESTION_BUTTON_COUNT = 18; ///< Amount of buttons available. enum GoalQuestionType : byte { GQT_QUESTION = 0, @@ -32,9 +32,9 @@ enum GoalType : byte { GT_STORY_PAGE, ///< Destination is a story page }; -typedef uint32 GoalTypeID; ///< Contains either tile, industry ID, town ID, company ID, or story page ID +typedef uint32_t GoalTypeID; ///< Contains either tile, industry ID, town ID, company ID, or story page ID -typedef uint16 GoalID; ///< ID of a goal +typedef uint16_t GoalID; ///< ID of a goal struct Goal; static const GoalID INVALID_GOAL = 0xFFFF; ///< Constant representing a non-existing goal. diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index c145befc88..6559ad485e 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -178,7 +178,7 @@ protected: static const int MIN_GRAPH_NUM_LINES_Y = 9; ///< Minimal number of horizontal lines to draw. static const int MIN_GRID_PIXEL_SIZE = 20; ///< Minimum distance between graph lines. - uint64 excluded_data; ///< bitmask of the datasets that shouldn't be displayed. + uint64_t excluded_data; ///< bitmask of the datasets that shouldn't be displayed. byte num_dataset; byte num_on_x_axis; byte num_vert_lines; @@ -191,8 +191,8 @@ protected: /* These values are used if the graph is being plotted against values * rather than the dates specified by month and year. */ - uint16 x_values_start; - uint16 x_values_increment; + uint16_t x_values_start; + uint16_t x_values_increment; int graph_widget; StringID format_str_y_axis; @@ -234,7 +234,7 @@ protected: double abs_higher = (current_interval.highest < 0) ? 0 : (double)current_interval.highest; int num_pos_grids; - int64 grid_size; + int64_t grid_size; if (abs_lower != 0 || abs_higher != 0) { /* The number of grids to reserve for the positive part is: */ @@ -245,8 +245,8 @@ protected: if (num_pos_grids == num_hori_lines && abs_lower != 0) num_pos_grids--; /* Get the required grid size for each side and use the maximum one. */ - int64 grid_size_higher = (abs_higher > 0) ? ((int64)abs_higher + num_pos_grids - 1) / num_pos_grids : 0; - int64 grid_size_lower = (abs_lower > 0) ? ((int64)abs_lower + num_hori_lines - num_pos_grids - 1) / (num_hori_lines - num_pos_grids) : 0; + int64_t grid_size_higher = (abs_higher > 0) ? ((int64_t)abs_higher + num_pos_grids - 1) / num_pos_grids : 0; + int64_t grid_size_lower = (abs_lower > 0) ? ((int64_t)abs_lower + num_hori_lines - num_pos_grids - 1) / (num_hori_lines - num_pos_grids) : 0; grid_size = std::max(grid_size_higher, grid_size_lower); } else { /* If both values are zero, show an empty graph. */ @@ -267,8 +267,8 @@ protected: uint GetYLabelWidth(ValuesInterval current_interval, int num_hori_lines) const { /* draw text strings on the y axis */ - int64 y_label = current_interval.highest; - int64 y_label_separation = (current_interval.highest - current_interval.lowest) / num_hori_lines; + int64_t y_label = current_interval.highest; + int64_t y_label_separation = (current_interval.highest - current_interval.lowest) / num_hori_lines; uint max_width = 0; @@ -366,8 +366,8 @@ protected: assert(this->num_dataset > 0); /* draw text strings on the y axis */ - int64 y_label = interval.highest; - int64 y_label_separation = abs(interval.highest - interval.lowest) / num_hori_lines; + int64_t y_label = interval.highest; + int64_t y_label_separation = abs(interval.highest - interval.lowest) / num_hori_lines; y = r.top - GetCharacterHeight(FS_SMALL) / 2; @@ -405,7 +405,7 @@ protected: /* Draw x-axis labels for graphs not based on quarterly performance (cargo payment rates). */ x = r.left; y = r.bottom + ScaleGUITrad(2); - uint16 label = this->x_values_start; + uint16_t label = this->x_values_start; for (int i = 0; i < this->num_on_x_axis; i++) { SetDParam(0, label); @@ -1223,8 +1223,8 @@ struct PerformanceRatingDetailWindow : Window { int colour_notdone = _colour_gradient[COLOUR_RED][4]; /* Draw all the score parts */ - int64 val = _score_part[company][score_type]; - int64 needed = _score_info[score_type].needed; + int64_t val = _score_part[company][score_type]; + int64_t needed = _score_info[score_type].needed; int score = _score_info[score_type].score; /* SCORE_TOTAL has its own rules ;) */ @@ -1243,7 +1243,7 @@ struct PerformanceRatingDetailWindow : Window { DrawString(this->score_info_left, this->score_info_right, text_top, STR_JUST_COMMA, TC_BLACK, SA_RIGHT); /* Calculate the %-bar */ - uint x = Clamp(val, 0, needed) * this->bar_width / needed; + uint x = Clamp(val, 0, needed) * this->bar_width / needed; bool rtl = _current_text_dir == TD_RTL; if (rtl) { x = this->bar_right - x; @@ -1256,7 +1256,7 @@ struct PerformanceRatingDetailWindow : Window { if (x != this->bar_right) GfxFillRect(x, bar_top, this->bar_right, bar_top + this->bar_height - 1, rtl ? colour_done : colour_notdone); /* Draw it */ - SetDParam(0, Clamp(val, 0, needed) * 100 / needed); + SetDParam(0, Clamp(val, 0, needed) * 100 / needed); DrawString(this->bar_left, this->bar_right, text_top, STR_PERFORMANCE_DETAIL_PERCENT, TC_FROMSTRING, SA_HOR_CENTER); /* SCORE_LOAN is inversed */ diff --git a/src/ground_vehicle.cpp b/src/ground_vehicle.cpp index 3de93fb668..ef755775e3 100644 --- a/src/ground_vehicle.cpp +++ b/src/ground_vehicle.cpp @@ -23,13 +23,13 @@ void GroundVehicle::PowerChanged() assert(this->First() == this); const T *v = T::From(this); - uint32 total_power = 0; - uint32 max_te = 0; - uint32 number_of_parts = 0; - uint16 max_track_speed = this->vcache.cached_max_speed; // Max track speed in internal units. + uint32_t total_power = 0; + uint32_t max_te = 0; + uint32_t number_of_parts = 0; + uint16_t max_track_speed = this->vcache.cached_max_speed; // Max track speed in internal units. for (const T *u = v; u != nullptr; u = u->Next()) { - uint32 current_power = u->GetPower() + u->GetPoweredPartPower(u); + uint32_t current_power = u->GetPower() + u->GetPoweredPartPower(u); total_power += current_power; /* Only powered parts add tractive effort. */ @@ -37,7 +37,7 @@ void GroundVehicle::PowerChanged() number_of_parts++; /* Get minimum max speed for this track. */ - uint16 track_speed = u->GetMaxTrackSpeed(); + uint16_t track_speed = u->GetMaxTrackSpeed(); if (track_speed > 0) max_track_speed = std::min(max_track_speed, track_speed); } @@ -46,7 +46,7 @@ void GroundVehicle::PowerChanged() /* If air drag is set to zero (default), the resulting air drag coefficient is dependent on max speed. */ if (air_drag_value == 0) { - uint16 max_speed = v->GetDisplayMaxSpeed(); + uint16_t max_speed = v->GetDisplayMaxSpeed(); /* Simplification of the method used in TTDPatch. It uses <= 10 to change more steadily from 128 to 196. */ air_drag = (max_speed <= 10) ? 192 : std::max(2048 / max_speed, 1); } else { @@ -79,10 +79,10 @@ template void GroundVehicle::CargoChanged() { assert(this->First() == this); - uint32 weight = 0; + uint32_t weight = 0; for (T *u = T::From(this); u != nullptr; u = u->Next()) { - uint32 current_weight = u->GetWeight(); + uint32_t current_weight = u->GetWeight(); weight += current_weight; /* Slope steepness is in percent, result in N. */ u->gcache.cached_slope_resistance = current_weight * u->GetSlopeSteepness() * 100; @@ -107,16 +107,16 @@ int GroundVehicle::GetAcceleration() const /* Templated class used for function calls for performance reasons. */ const T *v = T::From(this); /* Speed is used squared later on, so U16 * U16, and then multiplied by other values. */ - int64 speed = v->GetCurrentSpeed(); // [km/h-ish] + int64_t speed = v->GetCurrentSpeed(); // [km/h-ish] /* Weight is stored in tonnes. */ - int32 mass = this->gcache.cached_weight; + int32_t mass = this->gcache.cached_weight; /* Power is stored in HP, we need it in watts. * Each vehicle can have U16 power, 128 vehicles, HP -> watt * and km/h to m/s conversion below result in a maximum of * about 1.1E11, way more than 4.3E9 of int32. */ - int64 power = this->gcache.cached_power * 746ll; + int64_t power = this->gcache.cached_power * 746ll; /* This is constructed from: * - axle resistance: U16 power * 10 for 128 vehicles. @@ -127,9 +127,9 @@ int GroundVehicle::GetAcceleration() const * * 8.4E9 * - air drag: 28 * (U8 drag + 3 * U8 drag * 128 vehicles / 20) * U16 speed * U16 speed * * 6.2E14 before dividing by 1000 - * Sum is 6.3E11, more than 4.3E9 of int32, so int64 is needed. + * Sum is 6.3E11, more than 4.3E9 of int32_t, so int64_t is needed. */ - int64 resistance = 0; + int64_t resistance = 0; bool maglev = v->GetAccelerationType() == 2; @@ -141,7 +141,7 @@ int GroundVehicle::GetAcceleration() const } /* Air drag; the air drag coefficient is in an arbitrary NewGRF-unit, * so we need some magic conversion factor. */ - resistance += static_cast(area) * this->gcache.cached_air_drag * speed * speed / 1000; + resistance += static_cast(area) * this->gcache.cached_air_drag * speed * speed / 1000; resistance += this->GetSlopeResistance(); @@ -151,7 +151,7 @@ int GroundVehicle::GetAcceleration() const const int max_te = this->gcache.cached_max_te; // [N] /* Constructued from power, with need to multiply by 18 and assuming * low speed, it needs to be a 64 bit integer too. */ - int64 force; + int64_t force; if (speed > 0) { if (!maglev) { /* Conversion factor from km/h to m/s is 5/18 to get [N] in the end. */ @@ -178,7 +178,7 @@ int GroundVehicle::GetAcceleration() const int accel = ClampTo((force - resistance) / (mass * 4)); return force < resistance ? std::min(-1, accel) : std::max(1, accel); } else { - return ClampTo(std::min(-force - resistance, -10000) / mass); + return ClampTo(std::min(-force - resistance, -10000) / mass); } } diff --git a/src/ground_vehicle.hpp b/src/ground_vehicle.hpp index a82344f964..331b212048 100644 --- a/src/ground_vehicle.hpp +++ b/src/ground_vehicle.hpp @@ -28,23 +28,23 @@ enum AccelStatus { */ struct GroundVehicleCache { /* Cached acceleration values, recalculated when the cargo on a vehicle changes (in addition to the conditions below) */ - uint32 cached_weight; ///< Total weight of the consist (valid only for the first engine). - uint32 cached_slope_resistance; ///< Resistance caused by weight when this vehicle part is at a slope. - uint32 cached_max_te; ///< Maximum tractive effort of consist (valid only for the first engine). - uint16 cached_axle_resistance; ///< Resistance caused by the axles of the vehicle (valid only for the first engine). + uint32_t cached_weight; ///< Total weight of the consist (valid only for the first engine). + uint32_t cached_slope_resistance; ///< Resistance caused by weight when this vehicle part is at a slope. + uint32_t cached_max_te; ///< Maximum tractive effort of consist (valid only for the first engine). + uint16_t cached_axle_resistance; ///< Resistance caused by the axles of the vehicle (valid only for the first engine). /* Cached acceleration values, recalculated on load and each time a vehicle is added to/removed from the consist. */ - uint16 cached_max_track_speed; ///< Maximum consist speed (in internal units) limited by track type (valid only for the first engine). - uint32 cached_power; ///< Total power of the consist (valid only for the first engine). - uint32 cached_air_drag; ///< Air drag coefficient of the vehicle (valid only for the first engine). + uint16_t cached_max_track_speed; ///< Maximum consist speed (in internal units) limited by track type (valid only for the first engine). + uint32_t cached_power; ///< Total power of the consist (valid only for the first engine). + uint32_t cached_air_drag; ///< Air drag coefficient of the vehicle (valid only for the first engine). /* Cached NewGRF values, recalculated on load and each time a vehicle is added to/removed from the consist. */ - uint16 cached_total_length; ///< Length of the whole vehicle (valid only for the first engine). + uint16_t cached_total_length; ///< Length of the whole vehicle (valid only for the first engine). EngineID first_engine; ///< Cached EngineID of the front vehicle. INVALID_ENGINE for the front vehicle itself. - uint8 cached_veh_length; ///< Length of this vehicle in units of 1/VEHICLE_LENGTH of normal length. It is cached because this can be set by a callback. + uint8_t cached_veh_length; ///< Length of this vehicle in units of 1/VEHICLE_LENGTH of normal length. It is cached because this can be set by a callback. /* Cached UI information. */ - uint16 last_speed; ///< The last speed we did display, so we only have to redraw when this changes. + uint16_t last_speed; ///< The last speed we did display, so we only have to redraw when this changes. }; /** Ground vehicle flags. */ @@ -60,25 +60,25 @@ enum GroundVehicleFlags { * Child classes must define all of the following functions. * These functions are not defined as pure virtual functions at this class to improve performance. * - * virtual uint16 GetPower() const = 0; - * virtual uint16 GetPoweredPartPower(const T *head) const = 0; - * virtual uint16 GetWeight() const = 0; + * virtual uint16_t GetPower() const = 0; + * virtual uint16_t GetPoweredPartPower(const T *head) const = 0; + * virtual uint16_t GetWeight() const = 0; * virtual byte GetTractiveEffort() const = 0; * virtual byte GetAirDrag() const = 0; * virtual byte GetAirDragArea() const = 0; * virtual AccelStatus GetAccelerationStatus() const = 0; - * virtual uint16 GetCurrentSpeed() const = 0; - * virtual uint32 GetRollingFriction() const = 0; + * virtual uint16_t GetCurrentSpeed() const = 0; + * virtual uint32_t GetRollingFriction() const = 0; * virtual int GetAccelerationType() const = 0; - * virtual int32 GetSlopeSteepness() const = 0; + * virtual int32_t GetSlopeSteepness() const = 0; * virtual int GetDisplayMaxSpeed() const = 0; - * virtual uint16 GetMaxTrackSpeed() const = 0; + * virtual uint16_t GetMaxTrackSpeed() const = 0; * virtual bool TileMayHaveSlopedTrack() const = 0; */ template struct GroundVehicle : public SpecializedVehicle { GroundVehicleCache gcache; ///< Cache of often calculated values. - uint16 gv_flags; ///< @see GroundVehicleFlags. + uint16_t gv_flags; ///< @see GroundVehicleFlags. typedef GroundVehicle GroundVehicleBase; ///< Our type @@ -111,9 +111,9 @@ struct GroundVehicle : public SpecializedVehicle { * Calculates the total slope resistance for this vehicle. * @return Slope resistance. */ - inline int64 GetSlopeResistance() const + inline int64_t GetSlopeResistance() const { - int64 incl = 0; + int64_t incl = 0; for (const T *u = T::From(this); u != nullptr; u = u->Next()) { if (HasBit(u->gv_flags, GVF_GOINGUP_BIT)) { @@ -206,13 +206,13 @@ struct GroundVehicle : public SpecializedVehicle { /* DirToDiagDir() is a simple right shift */ DiagDirection dir = DirToDiagDir(this->direction); /* Read variables, so the compiler knows the access doesn't trap */ - int8 x_pos = this->x_pos; - int8 y_pos = this->y_pos; + int8_t x_pos = this->x_pos; + int8_t y_pos = this->y_pos; /* DiagDirToAxis() is a simple mask */ - int8 d = DiagDirToAxis(dir) == AXIS_X ? x_pos : y_pos; + int8_t d = DiagDirToAxis(dir) == AXIS_X ? x_pos : y_pos; /* We need only the least significant bit */ d &= 1; - d ^= (int8)(dir == DIAGDIR_NW || dir == DIAGDIR_NE); + d ^= (int8_t)(dir == DIAGDIR_NW || dir == DIAGDIR_NE); /* Subtraction instead of addition because we are testing for GVF_GOINGUP_BIT. * GVF_GOINGUP_BIT is used because it's bit 0, so simple AND can be used, * without any shift */ diff --git a/src/group.h b/src/group.h index d901a48676..ca867985bc 100644 --- a/src/group.h +++ b/src/group.h @@ -24,9 +24,9 @@ extern GroupPool _group_pool; ///< Pool of groups. struct GroupStatistics { Money profit_last_year; ///< Sum of profits for all vehicles. Money profit_last_year_min_age; ///< Sum of profits for vehicles considered for profit statistics. - uint16 *num_engines; ///< Caches the number of engines of each type the company owns. - uint16 num_vehicle; ///< Number of vehicles. - uint16 num_vehicle_min_age; ///< Number of vehicles considered for profit statistics; + uint16_t *num_engines; ///< Caches the number of engines of each type the company owns. + uint16_t num_vehicle; ///< Number of vehicles. + uint16_t num_vehicle_min_age; ///< Number of vehicles considered for profit statistics; bool autoreplace_defined; ///< Are any autoreplace rules set? bool autoreplace_finished; ///< Have all autoreplacement finished? @@ -63,7 +63,7 @@ struct GroupStatistics { static void UpdateAutoreplace(CompanyID company); }; -enum GroupFlags : uint8 { +enum GroupFlags : uint8_t { GF_REPLACE_PROTECTION, ///< If set to true, the global autoreplace has no effect on the group GF_REPLACE_WAGON_REMOVAL, ///< If set, autoreplace will perform wagon removal on vehicles in this group. GF_END, @@ -75,7 +75,7 @@ struct Group : GroupPool::PoolItem<&_group_pool> { Owner owner; ///< Group Owner VehicleType vehicle_type; ///< Vehicle type of the group - uint8 flags; ///< Group flags + uint8_t flags; ///< Group flags Livery livery; ///< Custom colour scheme for vehicles in this group GroupStatistics statistics; ///< NOSAVE: Statistics and caches on the vehicles in the group. diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp index 407b31ab5d..e202177884 100644 --- a/src/group_cmd.cpp +++ b/src/group_cmd.cpp @@ -29,7 +29,7 @@ INSTANTIATE_POOL_METHODS(Group) GroupStatistics::GroupStatistics() { - this->num_engines = CallocT(Engine::GetPoolSize()); + this->num_engines = CallocT(Engine::GetPoolSize()); } GroupStatistics::~GroupStatistics() @@ -49,7 +49,7 @@ void GroupStatistics::Clear() /* This is also called when NewGRF change. So the number of engines might have changed. Reallocate. */ free(this->num_engines); - this->num_engines = CallocT(Engine::GetPoolSize()); + this->num_engines = CallocT(Engine::GetPoolSize()); } /** diff --git a/src/group_cmd.h b/src/group_cmd.h index 28ef29b974..e177a71614 100644 --- a/src/group_cmd.h +++ b/src/group_cmd.h @@ -17,7 +17,7 @@ #include "vehiclelist_cmd.h" enum Colours : byte; -enum GroupFlags : uint8; +enum GroupFlags : uint8_t; /** Action for \c CmdAlterGroup. */ enum class AlterGroupMode : byte { diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 7999f9faac..da3b8eb522 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -542,7 +542,7 @@ public: WIDGET_LIST_END); /* If not a default group and the group has replace protection, show an enabled replace sprite. */ - uint16 protect_sprite = SPR_GROUP_REPLACE_OFF_TRAIN; + uint16_t protect_sprite = SPR_GROUP_REPLACE_OFF_TRAIN; if (!IsDefaultGroupID(this->vli.index) && !IsAllGroupID(this->vli.index) && HasBit(Group::Get(this->vli.index)->flags, GroupFlags::GF_REPLACE_PROTECTION)) protect_sprite = SPR_GROUP_REPLACE_ON_TRAIN; this->GetWidget(WID_GL_REPLACE_PROTECTION)->widget_data = protect_sprite + this->vli.vtype; @@ -572,7 +572,7 @@ public: case WID_GL_INFO: { Money this_year = 0; Money last_year = 0; - uint64 occupancy = 0; + uint64_t occupancy = 0; for (const Vehicle * const v : this->vehicles) { assert(v->owner == this->owner); diff --git a/src/group_type.h b/src/group_type.h index d3a0487a61..32c4926197 100644 --- a/src/group_type.h +++ b/src/group_type.h @@ -10,7 +10,7 @@ #ifndef GROUP_TYPE_H #define GROUP_TYPE_H -typedef uint16 GroupID; ///< Type for all group identifiers. +typedef uint16_t GroupID; ///< Type for all group identifiers. static const GroupID NEW_GROUP = 0xFFFC; ///< Sentinel for a to-be-created group. static const GroupID ALL_GROUP = 0xFFFD; ///< All vehicles are in this group. diff --git a/src/gui.h b/src/gui.h index a489648193..cbdeafc4c1 100644 --- a/src/gui.h +++ b/src/gui.h @@ -49,8 +49,8 @@ void ShowIndustryDirectory(); void ShowIndustryCargoesWindow(); void ShowSubsidiesList(); void ShowGoalsList(CompanyID company); -void ShowGoalQuestion(uint16 id, byte type, uint32 button_mask, const std::string &question); -void ShowStoryBook(CompanyID company, uint16 page_id = INVALID_STORY_PAGE); +void ShowGoalQuestion(uint16_t id, byte type, uint32_t button_mask, const std::string &question); +void ShowStoryBook(CompanyID company, uint16_t page_id = INVALID_STORY_PAGE); void ShowEstimatedCostOrIncome(Money cost, int x, int y); diff --git a/src/heightmap.cpp b/src/heightmap.cpp index 2964a5c129..7352ceaabb 100644 --- a/src/heightmap.cpp +++ b/src/heightmap.cpp @@ -51,7 +51,7 @@ static_assert(MAX_HEIGHTMAP_SIZE_PIXELS < UINT32_MAX / 8); */ static inline bool IsValidHeightmapDimension(size_t width, size_t height) { - return (uint64)width * height <= MAX_HEIGHTMAP_SIZE_PIXELS && + return (uint64_t)width * height <= MAX_HEIGHTMAP_SIZE_PIXELS && width > 0 && width <= MAX_HEIGHTMAP_SIDE_LENGTH_IN_PIXELS && height > 0 && height <= MAX_HEIGHTMAP_SIDE_LENGTH_IN_PIXELS; } diff --git a/src/highscore.cpp b/src/highscore.cpp index bae91cee02..14bfd33ef8 100644 --- a/src/highscore.cpp +++ b/src/highscore.cpp @@ -60,7 +60,7 @@ int8_t SaveHighScoreValue(const Company *c) if (CheatHasBeenUsed()) return -1; auto &highscores = _highscore_table[SP_CUSTOM]; - uint16 score = c->old_economy[0].performance_history; + uint16_t score = c->old_economy[0].performance_history; auto it = std::find_if(highscores.begin(), highscores.end(), [&score](auto &highscore) { return highscore.score <= score; }); diff --git a/src/highscore.h b/src/highscore.h index b1ddd9fa6f..d3a779dfbc 100644 --- a/src/highscore.h +++ b/src/highscore.h @@ -17,7 +17,7 @@ struct HighScore { std::string name; ///< The name of the companyy and president. StringID title = INVALID_STRING_ID; ///< NOSAVE, has troubles with changing string-numbers. - uint16 score = 0; ///< The score for this high score. Do NOT change type, will break hs.dat + uint16_t score = 0; ///< The score for this high score. Do NOT change type, will break hs.dat }; using HighScores = std::array; ///< Record 5 high scores diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp index 16d8876bce..ab6f3b3f52 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -30,8 +30,8 @@ #include "safeguards.h" struct EndGameHighScoreBaseWindow : Window { - uint32 background_img; - int8 rank; + uint32_t background_img; + int8_t rank; EndGameHighScoreBaseWindow(WindowDesc *desc) : Window(desc) { @@ -70,7 +70,7 @@ struct EndGameHighScoreBaseWindow : Window { this->Close(); } - EventState OnKeyPress(WChar key, uint16 keycode) override + EventState OnKeyPress(char32_t key, uint16_t keycode) override { /* All keys are 'handled' by this window but we want to make * sure that 'quit' still works correctly. Not handling the @@ -158,7 +158,7 @@ struct EndGameWindow : EndGameHighScoreBaseWindow { struct HighScoreWindow : EndGameHighScoreBaseWindow { bool game_paused_by_player; ///< True if the game was paused by the player when the highscore window was opened. - HighScoreWindow(WindowDesc *desc, int difficulty, int8 ranking) : EndGameHighScoreBaseWindow(desc) + HighScoreWindow(WindowDesc *desc, int difficulty, int8_t ranking) : EndGameHighScoreBaseWindow(desc) { /* pause game to show the chart */ this->game_paused_by_player = _pause_mode == PM_PAUSED_NORMAL; @@ -233,7 +233,7 @@ static WindowDesc _endgame_desc( * endgame ranking is set to the top5 element that was newly added * and is thus highlighted */ -void ShowHighscoreTable(int difficulty, int8 ranking) +void ShowHighscoreTable(int difficulty, int8_t ranking) { CloseWindowByClass(WC_HIGHSCORE); new HighScoreWindow(&_highscore_desc, difficulty, ranking); diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp index 0739238db8..d1374e86e1 100644 --- a/src/hotkeys.cpp +++ b/src/hotkeys.cpp @@ -94,7 +94,7 @@ static const KeycodeNames _keycode_to_name[] = { * @param end End of the string to parse. * @return A keycode if a match is found or 0. */ -static uint16 ParseCode(const char *start, const char *end) +static uint16_t ParseCode(const char *start, const char *end) { assert(start <= end); while (start < end && *start == ' ') start++; @@ -108,7 +108,7 @@ static uint16 ParseCode(const char *start, const char *end) if (end - start == 1) { if (*start >= 'a' && *start <= 'z') return *start - ('a'-'A'); /* Ignore invalid keycodes */ - if (*(const uint8 *)start < 128) return *start; + if (*(const uint8_t *)start < 128) return *start; } return 0; } @@ -119,14 +119,14 @@ static uint16 ParseCode(const char *start, const char *end) * @param end End of the input. * @return A valid keycode or 0. */ -static uint16 ParseKeycode(const char *start, const char *end) +static uint16_t ParseKeycode(const char *start, const char *end) { assert(start <= end); - uint16 keycode = 0; + uint16_t keycode = 0; for (;;) { const char *cur = start; while (*cur != '+' && cur != end) cur++; - uint16 code = ParseCode(start, cur); + uint16_t code = ParseCode(start, cur); if (code == 0) return 0; if (code & WKC_SPECIAL_KEYS) { /* Some completely wrong keycode we don't support. */ @@ -155,7 +155,7 @@ static void ParseHotkeys(Hotkey &hotkey, const char *value) while (*start != '\0') { const char *end = start; while (*end != '\0' && *end != ',') end++; - uint16 keycode = ParseKeycode(start, end); + uint16_t keycode = ParseKeycode(start, end); if (keycode != 0) hotkey.AddKeycode(keycode); start = (*end == ',') ? end + 1: end; } @@ -168,7 +168,7 @@ static void ParseHotkeys(Hotkey &hotkey, const char *value) * @param keycode The keycode to convert to a string. * @return A string representation of this keycode. */ -static std::string KeycodeToString(uint16 keycode) +static std::string KeycodeToString(uint16_t keycode) { std::string str; if (keycode & WKC_GLOBAL_HOTKEY) { @@ -226,7 +226,7 @@ std::string SaveKeycodes(const Hotkey &hotkey) * @param name The name of this hotkey. * @param num Number of this hotkey, should be unique within the hotkey list. */ -Hotkey::Hotkey(uint16 default_keycode, const std::string &name, int num) : +Hotkey::Hotkey(uint16_t default_keycode, const std::string &name, int num) : name(name), num(num) { @@ -239,11 +239,11 @@ Hotkey::Hotkey(uint16 default_keycode, const std::string &name, int num) : * @param name The name of this hotkey. * @param num Number of this hotkey, should be unique within the hotkey list. */ -Hotkey::Hotkey(const std::vector &default_keycodes, const std::string &name, int num) : +Hotkey::Hotkey(const std::vector &default_keycodes, const std::string &name, int num) : name(name), num(num) { - for (uint16 keycode : default_keycodes) { + for (uint16_t keycode : default_keycodes) { this->AddKeycode(keycode); } } @@ -253,7 +253,7 @@ Hotkey::Hotkey(const std::vector &default_keycodes, const std::string &n * in addition to any previously added keycodes. * @param keycode The keycode to add. */ -void Hotkey::AddKeycode(uint16 keycode) +void Hotkey::AddKeycode(uint16_t keycode) { this->keycodes.insert(keycode); } @@ -305,7 +305,7 @@ void HotkeyList::Save(IniFile *ini) const * @param global_only Limit the search to hotkeys defined as 'global'. * @return The number of the matching hotkey or -1. */ -int HotkeyList::CheckMatch(uint16 keycode, bool global_only) const +int HotkeyList::CheckMatch(uint16_t keycode, bool global_only) const { for (const Hotkey &hotkey : this->items) { auto begin = hotkey.keycodes.begin(); @@ -348,7 +348,7 @@ void SaveHotkeysToConfig() SaveLoadHotkeys(true); } -void HandleGlobalHotkeys(WChar key, uint16 keycode) +void HandleGlobalHotkeys(char32_t key, uint16_t keycode) { for (HotkeyList *list : *_hotkey_lists) { if (list->global_hotkey_handler == nullptr) continue; diff --git a/src/hotkeys.h b/src/hotkeys.h index 8ac94aa911..1d5360a84d 100644 --- a/src/hotkeys.h +++ b/src/hotkeys.h @@ -19,14 +19,14 @@ * a list of keycodes and a number to help identifying this hotkey. */ struct Hotkey { - Hotkey(uint16 default_keycode, const std::string &name, int num); - Hotkey(const std::vector &default_keycodes, const std::string &name, int num); + Hotkey(uint16_t default_keycode, const std::string &name, int num); + Hotkey(const std::vector &default_keycodes, const std::string &name, int num); - void AddKeycode(uint16 keycode); + void AddKeycode(uint16_t keycode); const std::string name; int num; - std::set keycodes; + std::set keycodes; }; struct IniFile; @@ -43,7 +43,7 @@ struct HotkeyList { void Load(IniFile *ini); void Save(IniFile *ini) const; - int CheckMatch(uint16 keycode, bool global_only = false) const; + int CheckMatch(uint16_t keycode, bool global_only = false) const; GlobalHotkeyHandlerFunc global_hotkey_handler; private: @@ -57,12 +57,12 @@ private: HotkeyList(const HotkeyList &other); }; -bool IsQuitKey(uint16 keycode); +bool IsQuitKey(uint16_t keycode); void LoadHotkeysFromConfig(); void SaveHotkeysToConfig(); -void HandleGlobalHotkeys(WChar key, uint16 keycode); +void HandleGlobalHotkeys(char32_t key, uint16_t keycode); #endif /* HOTKEYS_H */ diff --git a/src/house.h b/src/house.h index 15ffc122d5..25e0753787 100644 --- a/src/house.h +++ b/src/house.h @@ -102,7 +102,7 @@ struct HouseSpec { byte population; ///< population (Zero on other tiles in multi tile house.) byte removal_cost; ///< cost multiplier for removing it StringID building_name; ///< building name - uint16 remove_rating_decrease; ///< rating decrease if removed + uint16_t remove_rating_decrease; ///< rating decrease if removed byte mail_generation; ///< mail generation multiplier (tile based, as the acceptances below) byte cargo_acceptance[HOUSE_NUM_ACCEPTS]; ///< acceptance level for the cargo slots CargoID accepts_cargo[HOUSE_NUM_ACCEPTS]; ///< input cargo slots @@ -112,7 +112,7 @@ struct HouseSpec { /* NewHouses properties */ GRFFileProps grf_prop; ///< Properties related the the grf file - uint16 callback_mask; ///< Bitmask of house callbacks that have to be called + uint16_t callback_mask; ///< Bitmask of house callbacks that have to be called byte random_colour[4]; ///< 4 "random" colours byte probability; ///< Relative probability of appearing (16 is the standard value) HouseExtraFlags extra_flags; ///< some more flags diff --git a/src/house_type.h b/src/house_type.h index c1623598b1..6c5f4d136f 100644 --- a/src/house_type.h +++ b/src/house_type.h @@ -10,8 +10,8 @@ #ifndef HOUSE_TYPE_H #define HOUSE_TYPE_H -typedef uint16 HouseID; ///< OpenTTD ID of house types. -typedef uint16 HouseClassID; ///< Classes of houses. +typedef uint16_t HouseID; ///< OpenTTD ID of house types. +typedef uint16_t HouseClassID; ///< Classes of houses. struct HouseSpec; diff --git a/src/industry.h b/src/industry.h index 5535787576..7842e8c0c4 100644 --- a/src/industry.h +++ b/src/industry.h @@ -96,7 +96,7 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> { ProducedCargoArray produced; ///< INDUSTRY_NUM_OUTPUTS production cargo slots AcceptedCargoArray accepted; ///< INDUSTRY_NUM_INPUTS input cargo slots byte prod_level; ///< general production level - uint16 counter; ///< used for animation and/or production (if available cargo) + uint16_t counter; ///< used for animation and/or production (if available cargo) IndustryType type; ///< type of industry. Owner owner; ///< owner of the industry. Which SHOULD always be (imho) OWNER_NONE @@ -111,13 +111,13 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> { Owner founder; ///< Founder of the industry TimerGameCalendar::Date construction_date; ///< Date of the construction of the industry - uint8 construction_type; ///< Way the industry was constructed (@see IndustryConstructionType) + uint8_t construction_type; ///< Way the industry was constructed (@see IndustryConstructionType) byte selected_layout; ///< Which tile layout was used when creating the industry Owner exclusive_supplier; ///< Which company has exclusive rights to deliver cargo (INVALID_OWNER = anyone) Owner exclusive_consumer; ///< Which company has exclusive rights to take cargo (INVALID_OWNER = anyone) std::string text; ///< General text with additional information. - uint16 random; ///< Random value used for randomisation of all kinds of things + uint16_t random; ///< Random value used for randomisation of all kinds of things PersistentStorage *psa; ///< Persistent storage for NewGRF industries. @@ -211,7 +211,7 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> { * @param type IndustryType to query * @pre type < NUM_INDUSTRYTYPES */ - static inline uint16 GetIndustryTypeCount(IndustryType type) + static inline uint16_t GetIndustryTypeCount(IndustryType type) { assert(type < NUM_INDUSTRYTYPES); return counts[type]; @@ -233,7 +233,7 @@ private: void FillCachedName() const; protected: - static uint16 counts[NUM_INDUSTRYTYPES]; ///< Number of industries per type ingame + static uint16_t counts[NUM_INDUSTRYTYPES]; ///< Number of industries per type ingame }; void ClearAllIndustryCachedNames(); @@ -246,11 +246,11 @@ bool IsTileForestIndustry(TileIndex tile); /** Data for managing the number of industries of a single industry type. */ struct IndustryTypeBuildData { - uint32 probability; ///< Relative probability of building this industry. + uint32_t probability; ///< Relative probability of building this industry. byte min_number; ///< Smallest number of industries that should exist (either \c 0 or \c 1). - uint16 target_count; ///< Desired number of industries of this type. - uint16 max_wait; ///< Starting number of turns to wait (copied to #wait_count). - uint16 wait_count; ///< Number of turns to wait before trying to build again. + uint16_t target_count; ///< Desired number of industries of this type. + uint16_t max_wait; ///< Starting number of turns to wait (copied to #wait_count). + uint16_t wait_count; ///< Number of turns to wait before trying to build again. void Reset(); @@ -262,7 +262,7 @@ struct IndustryTypeBuildData { */ struct IndustryBuildData { IndustryTypeBuildData builddata[NUM_INDUSTRYTYPES]; ///< Industry build data for every industry type. - uint32 wanted_inds; ///< Number of wanted industries (bits 31-16), and a fraction (bits 15-0). + uint32_t wanted_inds; ///< Number of wanted industries (bits 31-16), and a fraction (bits 15-0). void Reset(); diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 09c850c9ab..7612e30f93 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -62,7 +62,7 @@ void BuildOilRig(TileIndex tile); static byte _industry_sound_ctr; static TileIndex _industry_sound_tile; -uint16 Industry::counts[NUM_INDUSTRYTYPES]; +uint16_t Industry::counts[NUM_INDUSTRYTYPES]; IndustrySpec _industry_specs[NUM_INDUSTRYTYPES]; IndustryTileSpec _industry_tile_specs[NUM_INDUSTRYTILES]; @@ -218,7 +218,7 @@ void Industry::PostDestructor(size_t index) /* static */ Industry *Industry::GetRandom() { if (Industry::GetNumItems() == 0) return nullptr; - int num = RandomRange((uint16)Industry::GetNumItems()); + int num = RandomRange((uint16_t)Industry::GetNumItems()); size_t index = MAX_UVALUE(size_t); while (num >= 0) { @@ -256,7 +256,7 @@ static void IndustryDrawSugarMine(const TileInfo *ti) static void IndustryDrawToffeeQuarry(const TileInfo *ti) { - uint8 x = 0; + uint8_t x = 0; if (IsIndustryCompleted(ti->tile)) { x = _industry_anim_offs_toffee[GetAnimationFrame(ti->tile)]; @@ -296,7 +296,7 @@ static void IndustryDrawToyFactory(const TileInfo *ti) static void IndustryDrawCoalPlantSparks(const TileInfo *ti) { if (IsIndustryCompleted(ti->tile)) { - uint8 image = GetAnimationFrame(ti->tile); + uint8_t image = GetAnimationFrame(ti->tile); if (image != 0 && image < 7) { AddChildSpriteScreen(image + SPR_IT_POWER_PLANT_TRANSFORMERS, @@ -399,7 +399,7 @@ static Foundation GetFoundation_Industry(TileIndex tile, Slope tileh) if (gfx >= NEW_INDUSTRYTILEOFFSET) { const IndustryTileSpec *indts = GetIndustryTileSpec(gfx); if (indts->grf_prop.spritegroup[0] != nullptr && HasBit(indts->callback_mask, CBM_INDT_DRAW_FOUNDATIONS)) { - uint32 callback_res = GetIndustryTileCallback(CBID_INDTILE_DRAW_FOUNDATIONS, 0, 0, gfx, Industry::GetByTile(tile), tile); + uint32_t callback_res = GetIndustryTileCallback(CBID_INDTILE_DRAW_FOUNDATIONS, 0, 0, gfx, Industry::GetByTile(tile), tile); if (callback_res != CALLBACK_FAILED && !ConvertBooleanCallback(indts->grf_prop.grffile, CBID_INDTILE_DRAW_FOUNDATIONS, callback_res)) return FOUNDATION_NONE; } } @@ -414,7 +414,7 @@ static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, Ca /* Starting point for acceptance */ CargoID accepts_cargo[lengthof(itspec->accepts_cargo)]; - int8 cargo_acceptance[lengthof(itspec->acceptance)]; + int8_t cargo_acceptance[lengthof(itspec->acceptance)]; MemCpyT(accepts_cargo, itspec->accepts_cargo, lengthof(accepts_cargo)); MemCpyT(cargo_acceptance, itspec->acceptance, lengthof(cargo_acceptance)); @@ -434,7 +434,7 @@ static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, Ca if (HasBit(itspec->callback_mask, CBM_INDT_ACCEPT_CARGO)) { /* Try callback for accepts list, if success override all existing accepts */ - uint16 res = GetIndustryTileCallback(CBID_INDTILE_ACCEPT_CARGO, 0, 0, gfx, Industry::GetByTile(tile), tile); + uint16_t res = GetIndustryTileCallback(CBID_INDTILE_ACCEPT_CARGO, 0, 0, gfx, Industry::GetByTile(tile), tile); if (res != CALLBACK_FAILED) { MemSetT(accepts_cargo, CT_INVALID, lengthof(accepts_cargo)); for (uint i = 0; i < 3; i++) accepts_cargo[i] = GetCargoTranslation(GB(res, i * 5, 5), itspec->grf_prop.grffile); @@ -443,7 +443,7 @@ static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, Ca if (HasBit(itspec->callback_mask, CBM_INDT_CARGO_ACCEPTANCE)) { /* Try callback for acceptance list, if success override all existing acceptance */ - uint16 res = GetIndustryTileCallback(CBID_INDTILE_CARGO_ACCEPTANCE, 0, 0, gfx, Industry::GetByTile(tile), tile); + uint16_t res = GetIndustryTileCallback(CBID_INDTILE_CARGO_ACCEPTANCE, 0, 0, gfx, Industry::GetByTile(tile), tile); if (res != CALLBACK_FAILED) { MemSetT(cargo_acceptance, 0, lengthof(cargo_acceptance)); for (uint i = 0; i < 3; i++) cargo_acceptance[i] = GB(res, i * 4, 4); @@ -806,7 +806,7 @@ static void MakeIndustryTileBigger(TileIndex tile) static void TileLoopIndustry_BubbleGenerator(TileIndex tile) { - static const int8 _bubble_spawn_location[3][4] = { + static const int8_t _bubble_spawn_location[3][4] = { { 11, 0, -4, -14 }, { -4, -10, -4, 1 }, { 49, 59, 60, 65 }, @@ -1035,7 +1035,7 @@ static void PlantFarmField(TileIndex tile, IndustryID industry) } /* determine field size */ - uint32 r = (Random() & 0x303) + 0x404; + uint32_t r = (Random() & 0x303) + 0x404; if (_settings_game.game_creation.landscape == LT_ARCTIC) r += 0x404; uint size_x = GB(r, 0, 8); uint size_y = GB(r, 8, 8); @@ -1139,7 +1139,7 @@ static void ProduceIndustryGoods(Industry *i) /* play a sound? */ if ((i->counter & 0x3F) == 0) { - uint32 r; + uint32_t r; if (Chance16R(1, 14, r) && indsp->number_of_sounds != 0 && _settings_client.sound.ambient) { if (std::any_of(std::begin(i->produced), std::end(i->produced), [](const auto &p) { return p.history[LAST_MONTH].production > 0; })) { /* Play sound since last month had production */ @@ -1162,7 +1162,7 @@ static void ProduceIndustryGoods(Industry *i) } if ((indbehav & INDUSTRYBEH_PLANT_FIELDS) != 0) { - uint16 cb_res = CALLBACK_FAILED; + uint16_t cb_res = CALLBACK_FAILED; if (HasBit(indsp->callback_mask, CBM_IND_SPECIAL_EFFECT)) { cb_res = GetIndustryCallback(CBID_INDUSTRY_SPECIAL_EFFECT, Random(), 0, i, i->type, i->location.tile); } @@ -1177,7 +1177,7 @@ static void ProduceIndustryGoods(Industry *i) if (plant) PlantRandomFarmField(i); } if ((indbehav & INDUSTRYBEH_CUT_TREES) != 0) { - uint16 cb_res = CALLBACK_FAILED; + uint16_t cb_res = CALLBACK_FAILED; if (HasBit(indsp->callback_mask, CBM_IND_SPECIAL_EFFECT)) { cb_res = GetIndustryCallback(CBID_INDUSTRY_SPECIAL_EFFECT, Random(), 1, i, i->type, i->location.tile); } @@ -1495,7 +1495,7 @@ static CommandCost CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTil * @param[out] custom_shape_check Perform custom check for the site. * @return Failed or succeeded command. */ -static CommandCost CheckIfIndustryTileSlopes(TileIndex tile, const IndustryTileLayout &layout, size_t layout_index, int type, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type, bool *custom_shape_check = nullptr) +static CommandCost CheckIfIndustryTileSlopes(TileIndex tile, const IndustryTileLayout &layout, size_t layout_index, int type, uint16_t initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type, bool *custom_shape_check = nullptr) { bool refused_slope = false; bool custom_shape = false; @@ -1746,7 +1746,7 @@ static void PopulateStationsNearby(Industry *ind) * @param founder Founder of the industry; OWNER_NONE in case of random construction. * @param initial_random_bits Random bits for the industry. */ -static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, const IndustryTileLayout &layout, size_t layout_index, Town *t, Owner founder, uint16 initial_random_bits) +static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, const IndustryTileLayout &layout, size_t layout_index, Town *t, Owner founder, uint16_t initial_random_bits) { const IndustrySpec *indspec = GetIndustrySpec(type); @@ -1775,7 +1775,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, i->town = t; i->owner = OWNER_NONE; - uint16 r = Random(); + uint16_t r = Random(); i->random_colour = GB(r, 0, 4); i->counter = GB(r, 4, 12); i->random = initial_random_bits; @@ -1801,7 +1801,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, /* Call callbacks after the regular fields got initialised. */ if (HasBit(indspec->callback_mask, CBM_IND_PROD_CHANGE_BUILD)) { - uint16 res = GetIndustryCallback(CBID_INDUSTRY_PROD_CHANGE_BUILD, 0, Random(), i, type, INVALID_TILE); + uint16_t res = GetIndustryCallback(CBID_INDUSTRY_PROD_CHANGE_BUILD, 0, Random(), i, type, INVALID_TILE); if (res != CALLBACK_FAILED) { if (res < PRODLEVEL_MINIMUM || res > PRODLEVEL_MAXIMUM) { ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_PROD_CHANGE_BUILD, res); @@ -1827,7 +1827,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, } if (HasBit(indspec->callback_mask, CBM_IND_DECIDE_COLOUR)) { - uint16 res = GetIndustryCallback(CBID_INDUSTRY_DECIDE_COLOUR, 0, 0, i, type, INVALID_TILE); + uint16_t res = GetIndustryCallback(CBID_INDUSTRY_DECIDE_COLOUR, 0, 0, i, type, INVALID_TILE); if (res != CALLBACK_FAILED) { if (GB(res, 4, 11) != 0) ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_DECIDE_COLOUR, res); i->random_colour = GB(res, 0, 4); @@ -1840,7 +1840,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, /* Query actual types */ uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? static_cast(i->accepted.size()) : 3; for (uint j = 0; j < maxcargoes; j++) { - uint16 res = GetIndustryCallback(CBID_INDUSTRY_INPUT_CARGO_TYPES, j, 0, i, type, INVALID_TILE); + uint16_t res = GetIndustryCallback(CBID_INDUSTRY_INPUT_CARGO_TYPES, j, 0, i, type, INVALID_TILE); if (res == CALLBACK_FAILED || GB(res, 0, 8) == CT_INVALID) break; if (indspec->grf_prop.grffile->grf_version >= 8 && res >= 0x100) { ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_INPUT_CARGO_TYPES, res); @@ -1872,7 +1872,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, /* Query actual types */ uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? static_cast(i->produced.size()) : 2; for (uint j = 0; j < maxcargoes; j++) { - uint16 res = GetIndustryCallback(CBID_INDUSTRY_OUTPUT_CARGO_TYPES, j, 0, i, type, INVALID_TILE); + uint16_t res = GetIndustryCallback(CBID_INDUSTRY_OUTPUT_CARGO_TYPES, j, 0, i, type, INVALID_TILE); if (res == CALLBACK_FAILED || GB(res, 0, 8) == CT_INVALID) break; if (indspec->grf_prop.grffile->grf_version >= 8 && res >= 0x100) { ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_OUTPUT_CARGO_TYPES, res); @@ -1947,7 +1947,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, * * @post \c *ip contains the newly created industry if all checks are successful and the \a flags request actual creation, else it contains \c nullptr afterwards. */ -static CommandCost CreateNewIndustryHelper(TileIndex tile, IndustryType type, DoCommandFlag flags, const IndustrySpec *indspec, size_t layout_index, uint32 random_var8f, uint16 random_initial_bits, Owner founder, IndustryAvailabilityCallType creation_type, Industry **ip) +static CommandCost CreateNewIndustryHelper(TileIndex tile, IndustryType type, DoCommandFlag flags, const IndustrySpec *indspec, size_t layout_index, uint32_t random_var8f, uint16_t random_initial_bits, Owner founder, IndustryAvailabilityCallType creation_type, Industry **ip) { assert(layout_index < indspec->layouts.size()); const IndustryTileLayout &layout = indspec->layouts[layout_index]; @@ -2011,7 +2011,7 @@ static CommandCost CreateNewIndustryHelper(TileIndex tile, IndustryType type, Do * @param seed seed to use for desyncfree randomisations * @return the cost of this operation or an error */ -CommandCost CmdBuildIndustry(DoCommandFlag flags, TileIndex tile, IndustryType it, uint32 first_layout, bool fund, uint32 seed) +CommandCost CmdBuildIndustry(DoCommandFlag flags, TileIndex tile, IndustryType it, uint32_t first_layout, bool fund, uint32_t seed) { if (it >= NUM_INDUSTRYTYPES) return CMD_ERROR; @@ -2032,8 +2032,8 @@ CommandCost CmdBuildIndustry(DoCommandFlag flags, TileIndex tile, IndustryType i Randomizer randomizer; randomizer.SetSeed(seed); - uint16 random_initial_bits = GB(seed, 0, 16); - uint32 random_var8f = randomizer.Next(); + uint16_t random_initial_bits = GB(seed, 0, 16); + uint32_t random_var8f = randomizer.Next(); size_t num_layouts = indspec->layouts.size(); CommandCost ret = CommandCost(STR_ERROR_SITE_UNSUITABLE); const bool deity_prospect = _current_company == OWNER_DEITY && !fund; @@ -2055,7 +2055,7 @@ CommandCost CmdBuildIndustry(DoCommandFlag flags, TileIndex tile, IndustryType i */ tile = RandomTile(); /* Start with a random layout */ - size_t layout = RandomRange((uint32)num_layouts); + size_t layout = RandomRange((uint32_t)num_layouts); /* Check now each layout, starting with the random one */ for (size_t j = 0; j < num_layouts; j++) { layout = (layout + 1) % num_layouts; @@ -2180,10 +2180,10 @@ static Industry *CreateNewIndustry(TileIndex tile, IndustryType type, IndustryAv { const IndustrySpec *indspec = GetIndustrySpec(type); - uint32 seed = Random(); - uint32 seed2 = Random(); + uint32_t seed = Random(); + uint32_t seed2 = Random(); Industry *i = nullptr; - size_t layout_index = RandomRange((uint32)indspec->layouts.size()); + size_t layout_index = RandomRange((uint32_t)indspec->layouts.size()); [[maybe_unused]] CommandCost ret = CreateNewIndustryHelper(tile, type, DC_EXEC, indspec, layout_index, seed, GB(seed2, 0, 16), OWNER_NONE, creation_type, &i); assert(i != nullptr || ret.Failed()); return i; @@ -2195,10 +2195,10 @@ static Industry *CreateNewIndustry(TileIndex tile, IndustryType type, IndustryAv * @param[out] force_at_least_one Returns whether at least one instance should be forced on map creation. * @return Relative probability for the industry to appear. */ -static uint32 GetScaledIndustryGenerationProbability(IndustryType it, bool *force_at_least_one) +static uint32_t GetScaledIndustryGenerationProbability(IndustryType it, bool *force_at_least_one) { const IndustrySpec *ind_spc = GetIndustrySpec(it); - uint32 chance = ind_spc->appear_creation[_settings_game.game_creation.landscape]; + uint32_t chance = ind_spc->appear_creation[_settings_game.game_creation.landscape]; if (!ind_spc->enabled || ind_spc->layouts.empty() || (_game_mode != GM_EDITOR && _settings_game.difficulty.industry_density == ID_FUND_ONLY) || (chance = GetIndustryProbabilityCallback(it, IACT_MAPGENERATION, chance)) == 0) { @@ -2221,7 +2221,7 @@ static uint32 GetScaledIndustryGenerationProbability(IndustryType it, bool *forc * @param[out] min_number Minimal number of industries that should exist at the map. * @return Relative probability for the industry to appear. */ -static uint16 GetIndustryGamePlayProbability(IndustryType it, byte *min_number) +static uint16_t GetIndustryGamePlayProbability(IndustryType it, byte *min_number) { if (_settings_game.difficulty.industry_density == ID_FUND_ONLY) { *min_number = 0; @@ -2248,7 +2248,7 @@ static uint16 GetIndustryGamePlayProbability(IndustryType it, byte *min_number) static uint GetNumberOfIndustries() { /* Number of industries on a 256x256 map. */ - static const uint16 numof_industry_table[] = { + static const uint16_t numof_industry_table[] = { 0, // none 0, // minimal 10, // very low @@ -2353,9 +2353,9 @@ void GenerateIndustries() { if (_game_mode != GM_EDITOR && _settings_game.difficulty.industry_density == ID_FUND_ONLY) return; // No industries in the game. - uint32 industry_probs[NUM_INDUSTRYTYPES]; + uint32_t industry_probs[NUM_INDUSTRYTYPES]; bool force_at_least_one[NUM_INDUSTRYTYPES]; - uint32 total_prob = 0; + uint32_t total_prob = 0; uint num_forced = 0; for (IndustryType it = 0; it < NUM_INDUSTRYTYPES; it++) { @@ -2383,7 +2383,7 @@ void GenerateIndustries() /* Add the remaining industries according to their probabilities */ for (uint i = 0; i < total_amount; i++) { - uint32 r = RandomRange(total_prob); + uint32_t r = RandomRange(total_prob); IndustryType it = 0; while (r >= industry_probs[it]) { r -= industry_probs[it]; @@ -2450,7 +2450,7 @@ void ClearAllIndustryCachedNames() bool IndustryTypeBuildData::GetIndustryTypeData(IndustryType it) { byte min_number; - uint32 probability = GetIndustryGamePlayProbability(it, &min_number); + uint32_t probability = GetIndustryGamePlayProbability(it, &min_number); bool changed = min_number != this->min_number || probability != this->probability; this->min_number = min_number; this->probability = probability; @@ -2472,7 +2472,7 @@ void IndustryBuildData::SetupTargetCount() /* Initialize the target counts. */ uint force_build = 0; // Number of industries that should always be available. - uint32 total_prob = 0; // Sum of probabilities. + uint32_t total_prob = 0; // Sum of probabilities. for (IndustryType it = 0; it < NUM_INDUSTRYTYPES; it++) { IndustryTypeBuildData *ibd = this->builddata + it; force_build += ibd->min_number; @@ -2487,7 +2487,7 @@ void IndustryBuildData::SetupTargetCount() /* Assign number of industries that should be aimed for, by using the probability as a weight. */ while (total_amount > 0) { - uint32 r = RandomRange(total_prob); + uint32_t r = RandomRange(total_prob); IndustryType it = 0; while (r >= this->builddata[it].probability) { r -= this->builddata[it].probability; @@ -2509,7 +2509,7 @@ void IndustryBuildData::TryBuildNewIndustry() int missing = 0; // Number of industries that need to be build. uint count = 0; // Number of industry types eligible for build. - uint32 total_prob = 0; // Sum of probabilities. + uint32_t total_prob = 0; // Sum of probabilities. IndustryType forced_build = NUM_INDUSTRYTYPES; // Industry type that should be forcibly build. for (IndustryType it = 0; it < NUM_INDUSTRYTYPES; it++) { int difference = this->builddata[it].target_count - Industry::GetIndustryTypeCount(it); @@ -2538,7 +2538,7 @@ void IndustryBuildData::TryBuildNewIndustry() it = forced_build; } else { /* Non-forced, select an industry type to build (weighted random). */ - uint32 r = 0; // Initialized to silence the compiler. + uint32_t r = 0; // Initialized to silence the compiler. if (count > 1) r = RandomRange(total_prob); for (it = 0; it < NUM_INDUSTRYTYPES; it++) { if (this->builddata[it].wait_count > 0) continue; // Type may not be built now. @@ -2711,11 +2711,11 @@ static void ChangeIndustryProduction(Industry *i, bool monthly) bool original_economy = indspec->UsesOriginalEconomy(); byte div = 0; byte mul = 0; - int8 increment = 0; + int8_t increment = 0; bool callback_enabled = HasBit(indspec->callback_mask, monthly ? CBM_IND_MONTHLYPROD_CHANGE : CBM_IND_PRODUCTION_CHANGE); if (callback_enabled) { - uint16 res = GetIndustryCallback(monthly ? CBID_INDUSTRY_MONTHLYPROD_CHANGE : CBID_INDUSTRY_PRODUCTION_CHANGE, 0, Random(), i, i->type, i->location.tile); + uint16_t res = GetIndustryCallback(monthly ? CBID_INDUSTRY_MONTHLYPROD_CHANGE : CBID_INDUSTRY_PRODUCTION_CHANGE, 0, Random(), i, i->type, i->location.tile); if (res != CALLBACK_FAILED) { // failed callback means "do nothing" suppress_message = HasBit(res, 7); /* Get the custom message if any */ @@ -2765,7 +2765,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly) closeit = !(i->ctlflags & (INDCTL_NO_CLOSURE | INDCTL_NO_PRODUCTION_DECREASE)); for (auto &p : i->produced) { if (!IsValidCargoID(p.cargo)) continue; - uint32 r = Random(); + uint32_t r = Random(); int old_prod, new_prod, percent; /* If over 60% is transported, mult is 1, else mult is -1. */ int mult = (p.history[LAST_MONTH].PctTransported() > PERCENT_TRANSPORTED_60) ? 1 : -1; @@ -2917,7 +2917,7 @@ static IntervalTimer _industries_daily({TimerGameCalendar::DA /* Bits 16-31 of industry_construction_counter contain the number of industries to change/create today, * the lower 16 bit are a fractional part that might accumulate over several days until it * is sufficient for an industry. */ - uint16 change_loop = _economy.industry_daily_change_counter >> 16; + uint16_t change_loop = _economy.industry_daily_change_counter >> 16; /* Reset the active part of the counter, just keeping the "fractional part" */ _economy.industry_daily_change_counter &= 0xFFFF; @@ -2934,7 +2934,7 @@ static IntervalTimer _industries_daily({TimerGameCalendar::DA if ((_industry_builder.wanted_inds >> 16) > GetCurrentTotalNumberOfIndustries()) { perc = std::min(9u, perc + (_industry_builder.wanted_inds >> 16) - GetCurrentTotalNumberOfIndustries()); } - for (uint16 j = 0; j < change_loop; j++) { + for (uint16_t j = 0; j < change_loop; j++) { if (Chance16(perc, 100)) { _industry_builder.TryBuildNewIndustry(); } else { @@ -2991,7 +2991,7 @@ void CheckIndustries() if (Industry::GetIndustryTypeCount(it) > 0) continue; // Types of existing industries can be skipped. bool force_at_least_one; - uint32 chance = GetScaledIndustryGenerationProbability(it, &force_at_least_one); + uint32_t chance = GetScaledIndustryGenerationProbability(it, &force_at_least_one); if (chance == 0 || !force_at_least_one) continue; // Types that are not available can be skipped. const IndustrySpec *is = GetIndustrySpec(it); @@ -3081,7 +3081,7 @@ static CommandCost TerraformTile_Industry(TileIndex tile, DoCommandFlag flags, i /* Call callback 3C 'disable autosloping for industry tiles'. */ if (HasBit(itspec->callback_mask, CBM_INDT_AUTOSLOPE)) { /* If the callback fails, allow autoslope. */ - uint16 res = GetIndustryTileCallback(CBID_INDTILE_AUTOSLOPE, 0, 0, gfx, Industry::GetByTile(tile), tile); + uint16_t res = GetIndustryTileCallback(CBID_INDTILE_AUTOSLOPE, 0, 0, gfx, Industry::GetByTile(tile), tile); if (res == CALLBACK_FAILED || !ConvertBooleanCallback(itspec->grf_prop.grffile, CBID_INDTILE_AUTOSLOPE, res)) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]); } else { /* allow autoslope */ diff --git a/src/industry_cmd.h b/src/industry_cmd.h index 16de6b8331..d58b09678a 100644 --- a/src/industry_cmd.h +++ b/src/industry_cmd.h @@ -16,7 +16,7 @@ enum IndustryControlFlags : byte; -CommandCost CmdBuildIndustry(DoCommandFlag flags, TileIndex tile, IndustryType it, uint32 first_layout, bool fund, uint32 seed); +CommandCost CmdBuildIndustry(DoCommandFlag flags, TileIndex tile, IndustryType it, uint32_t first_layout, bool fund, uint32_t seed); CommandCost CmdIndustrySetFlags(DoCommandFlag flags, IndustryID ind_id, IndustryControlFlags ctlflags); CommandCost CmdIndustrySetExclusivity(DoCommandFlag flags, IndustryID ind_id, Owner company_id, bool consumer); CommandCost CmdIndustrySetText(DoCommandFlag flags, IndustryID ind_id, const std::string &text); @@ -26,6 +26,6 @@ DEF_CMD_TRAIT(CMD_INDUSTRY_SET_FLAGS, CmdIndustrySetFlags, CMD_DEITY, CMDT_OTHER DEF_CMD_TRAIT(CMD_INDUSTRY_SET_EXCLUSIVITY, CmdIndustrySetExclusivity, CMD_DEITY, CMDT_OTHER_MANAGEMENT) DEF_CMD_TRAIT(CMD_INDUSTRY_SET_TEXT, CmdIndustrySetText, CMD_DEITY | CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT) -void CcBuildIndustry(Commands cmd, const CommandCost &result, TileIndex tile, IndustryType indtype, uint32, bool, uint32); +void CcBuildIndustry(Commands cmd, const CommandCost &result, TileIndex tile, IndustryType indtype, uint32_t, bool, uint32_t); #endif /* INDUSTRY_CMD_H */ diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 545b51188d..cd72c4bc38 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -94,7 +94,7 @@ static void GetCargoSuffix(uint cargo, CargoSuffixType cst, const Industry *ind, if (HasBit(indspec->callback_mask, CBM_IND_CARGO_SUFFIX)) { TileIndex t = (cst != CST_FUND) ? ind->location.tile : INVALID_TILE; - uint16 callback = GetIndustryCallback(CBID_INDUSTRY_CARGO_SUFFIX, 0, (cst << 8) | cargo, const_cast(ind), ind_type, t); + uint16_t callback = GetIndustryCallback(CBID_INDUSTRY_CARGO_SUFFIX, 0, (cst << 8) | cargo, const_cast(ind), ind_type, t); if (callback == CALLBACK_FAILED) return; if (indspec->grf_prop.grffile->grf_version < 8) { @@ -248,7 +248,7 @@ void SortIndustryTypes() * @param tile Tile where the industry is placed. * @param indtype Industry type. */ -void CcBuildIndustry(Commands cmd, const CommandCost &result, TileIndex tile, IndustryType indtype, uint32, bool, uint32) +void CcBuildIndustry(Commands cmd, const CommandCost &result, TileIndex tile, IndustryType indtype, uint32_t, bool, uint32_t) { if (result.Succeeded()) return; @@ -531,7 +531,7 @@ public: icon.top = r.top + (this->resize.step_height - this->legend.height + 1) / 2; icon.bottom = icon.top + this->legend.height - 1; - for (uint16 i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) { + for (uint16_t i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) { IndustryType type = this->list[i]; bool selected = this->selected_type == type; const IndustrySpec *indsp = GetIndustrySpec(type); @@ -579,7 +579,7 @@ public: /* Get the additional purchase info text, if it has not already been queried. */ if (HasBit(indsp->callback_mask, CBM_IND_FUND_MORE_TEXT)) { - uint16 callback_res = GetIndustryCallback(CBID_INDUSTRY_FUND_MORE_TEXT, 0, 0, nullptr, this->selected_type, INVALID_TILE); + uint16_t callback_res = GetIndustryCallback(CBID_INDUSTRY_FUND_MORE_TEXT, 0, 0, nullptr, this->selected_type, INVALID_TILE); if (callback_res != CALLBACK_FAILED && callback_res != 0x400) { if (callback_res > 0x400) { ErrorUnknownCallbackResult(indsp->grf_prop.grffile->grfid, CBID_INDUSTRY_FUND_MORE_TEXT, callback_res); @@ -698,8 +698,8 @@ public: bool success = true; /* We do not need to protect ourselves against "Random Many Industries" in this mode */ const IndustrySpec *indsp = GetIndustrySpec(this->selected_type); - uint32 seed = InteractiveRandom(); - uint32 layout_index = InteractiveRandomRange((uint32)indsp->layouts.size()); + uint32_t seed = InteractiveRandom(); + uint32_t layout_index = InteractiveRandomRange((uint32_t)indsp->layouts.size()); if (_game_mode == GM_EDITOR) { /* Show error if no town exists at all */ @@ -954,7 +954,7 @@ public: /* Get the extra message for the GUI */ if (HasBit(ind->callback_mask, CBM_IND_WINDOW_MORE_TEXT)) { - uint16 callback_res = GetIndustryCallback(CBID_INDUSTRY_WINDOW_MORE_TEXT, 0, 0, i, i->type, i->location.tile); + uint16_t callback_res = GetIndustryCallback(CBID_INDUSTRY_WINDOW_MORE_TEXT, 0, 0, i, i->type, i->location.tile); if (callback_res != CALLBACK_FAILED && callback_res != 0x400) { if (callback_res > 0x400) { ErrorUnknownCallbackResult(ind->grf_prop.grffile->grfid, CBID_INDUSTRY_WINDOW_MORE_TEXT, callback_res); @@ -1329,7 +1329,7 @@ protected: StringFilter string_filter; ///< Filter for industries QueryString industry_editbox; ///< Filter editbox - enum class SorterType : uint8 { + enum class SorterType : uint8_t { ByName, ///< Sorter type to sort by name ByType, ///< Sorter type to sort by type ByProduction, ///< Sorter type to sort by production amount @@ -1549,7 +1549,7 @@ protected: /* Get industry productions (CargoID, production, suffix, transported) */ struct CargoInfo { CargoID cargo_id; - uint16 production; + uint16_t production; const char *suffix; uint transported; }; diff --git a/src/industry_map.h b/src/industry_map.h index f1e6182755..8d680b5a10 100644 --- a/src/industry_map.h +++ b/src/industry_map.h @@ -275,7 +275,7 @@ static inline void SetIndustryTriggers(Tile tile, byte triggers) * @param random the random value * @param wc the water class for this industry; only useful when build on water */ -static inline void MakeIndustry(Tile t, IndustryID index, IndustryGfx gfx, uint8 random, WaterClass wc) +static inline void MakeIndustry(Tile t, IndustryID index, IndustryGfx gfx, uint8_t random, WaterClass wc) { SetTileType(t, MP_INDUSTRY); t.m1() = 0; diff --git a/src/industry_type.h b/src/industry_type.h index cac99043e0..185e1f3a79 100644 --- a/src/industry_type.h +++ b/src/industry_type.h @@ -10,9 +10,9 @@ #ifndef INDUSTRY_TYPE_H #define INDUSTRY_TYPE_H -typedef uint16 IndustryID; -typedef uint16 IndustryGfx; -typedef uint8 IndustryType; +typedef uint16_t IndustryID; +typedef uint16_t IndustryGfx; +typedef uint8_t IndustryType; struct Industry; struct IndustrySpec; diff --git a/src/industrytype.h b/src/industrytype.h index 8d151e2100..153e4a0ff1 100644 --- a/src/industrytype.h +++ b/src/industrytype.h @@ -104,9 +104,9 @@ using IndustryTileLayout = std::vector; */ struct IndustrySpec { std::vector layouts; ///< List of possible tile layouts for the industry - uint8 cost_multiplier; ///< Base construction cost multiplier. - uint32 removal_cost_multiplier; ///< Base removal cost multiplier. - uint32 prospecting_chance; ///< Chance prospecting succeeds + uint8_t cost_multiplier; ///< Base construction cost multiplier. + uint32_t removal_cost_multiplier; ///< Base removal cost multiplier. + uint32_t prospecting_chance; ///< Chance prospecting succeeds IndustryType conflicting[3]; ///< Industries this industry cannot be close to byte check_proc; ///< Index to a procedure to check for conflicting circumstances CargoID produced_cargo[INDUSTRY_NUM_OUTPUTS]; @@ -117,7 +117,7 @@ struct IndustrySpec { */ byte minimal_cargo; CargoID accepts_cargo[INDUSTRY_NUM_INPUTS]; ///< 16 accepted cargoes. - uint16 input_cargo_multiplier[INDUSTRY_NUM_INPUTS][INDUSTRY_NUM_OUTPUTS]; ///< Input cargo multipliers (multiply amount of incoming cargo for the produced cargoes) + uint16_t input_cargo_multiplier[INDUSTRY_NUM_INPUTS][INDUSTRY_NUM_OUTPUTS]; ///< Input cargo multipliers (multiply amount of incoming cargo for the produced cargoes) IndustryLifeType life_type; ///< This is also known as Industry production flag, in newgrf specs byte climate_availability; ///< Bitmask, giving landscape enums as bit position IndustryBehaviour behaviour; ///< How this industry will behave, and how others entities can use it @@ -130,11 +130,11 @@ struct IndustrySpec { StringID station_name; ///< Default name for nearby station byte appear_ingame[NUM_LANDSCAPE]; ///< Probability of appearance in game byte appear_creation[NUM_LANDSCAPE]; ///< Probability of appearance during map creation - uint8 number_of_sounds; ///< Number of sounds available in the sounds array - const uint8 *random_sounds; ///< array of random sounds. + uint8_t number_of_sounds; ///< Number of sounds available in the sounds array + const uint8_t *random_sounds; ///< array of random sounds. /* Newgrf data */ - uint16 callback_mask; ///< Bitmask of industry callbacks that have to be called - uint8 cleanup_flag; ///< flags indicating which data should be freed upon cleaning up + uint16_t callback_mask; ///< Bitmask of industry callbacks that have to be called + uint8_t cleanup_flag; ///< flags indicating which data should be freed upon cleaning up bool enabled; ///< entity still available (by default true).newgrf can disable it, though GRFFileProps grf_prop; ///< properties related to the grf file @@ -153,7 +153,7 @@ struct IndustrySpec { */ struct IndustryTileSpec { CargoID accepts_cargo[INDUSTRY_NUM_INPUTS]; ///< Cargo accepted by this tile - int8 acceptance[INDUSTRY_NUM_INPUTS]; ///< Level of acceptance per cargo type (signed, may be negative!) + int8_t acceptance[INDUSTRY_NUM_INPUTS]; ///< Level of acceptance per cargo type (signed, may be negative!) Slope slopes_refused; ///< slope pattern on which this tile cannot be built byte anim_production; ///< Animation frame to start when goods are produced byte anim_next; ///< Next frame in an animation @@ -163,7 +163,7 @@ struct IndustryTileSpec { */ bool anim_state; /* Newgrf data */ - uint8 callback_mask; ///< Bitmask of industry tile callbacks that have to be called + uint8_t callback_mask; ///< Bitmask of industry tile callbacks that have to be called AnimationInfo animation; ///< Information about the animation (is it looping, how many loops etc) IndustryTileSpecialFlags special_flags; ///< Bitmask of extra flags used by the tile bool enabled; ///< entity still available (by default true).newgrf can disable it, though @@ -205,6 +205,6 @@ static inline IndustryGfx GetTranslatedIndustryTileID(IndustryGfx gfx) } } -static const uint8 IT_INVALID = 255; +static const uint8_t IT_INVALID = 255; #endif /* INDUSTRYTYPE_H */ diff --git a/src/landscape.cpp b/src/landscape.cpp index b151365858..b43b09e599 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -764,11 +764,11 @@ void RunTileLoop() /* Maximal length LFSR feedback terms, from 12-bit (for 64x64 maps) to 24-bit (for 4096x4096 maps). * Extracted from http://www.ece.cmu.edu/~koopman/lfsr/ */ - static const uint32 feedbacks[] = { + static const uint32_t feedbacks[] = { 0xD8F, 0x1296, 0x2496, 0x4357, 0x8679, 0x1030E, 0x206CD, 0x403FE, 0x807B8, 0x1004B2, 0x2006A8, 0x4004B2, 0x800B87 }; static_assert(lengthof(feedbacks) == 2 * MAX_MAP_SIZE_BITS - 2 * MIN_MAP_SIZE_BITS + 1); - const uint32 feedback = feedbacks[Map::LogX() + Map::LogY() - 2 * MIN_MAP_SIZE_BITS]; + const uint32_t feedback = feedbacks[Map::LogX() + Map::LogY() - 2 * MIN_MAP_SIZE_BITS]; /* We update every tile every 256 ticks, so divide the map size by 2^8 = 256 */ uint count = 1 << (Map::LogX() + Map::LogY() - 8); @@ -787,7 +787,7 @@ void RunTileLoop() _tile_type_procs[GetTileType(tile)]->tile_loop_proc(tile); /* Get the next tile in sequence using a Galois LFSR. */ - tile = (tile >> 1) ^ (-(int32)(tile & 1) & feedback); + tile = (tile >> 1) ^ (-(int32_t)(tile & 1) & feedback); } _cur_tileloop_tile = tile; @@ -813,7 +813,7 @@ static const byte _genterrain_tbl_2[5] = { 0, 0, 0, 0, 33 }; static void GenerateTerrain(int type, uint flag) { - uint32 r = Random(); + uint32_t r = Random(); /* Choose one of the templates from the graphics file. */ const Sprite *templ = GetSprite((((r >> 24) * _genterrain_tbl_1[type]) >> 8) + _genterrain_tbl_2[type] + SPR_MAPGEN_BEGIN, SpriteType::MapGen); @@ -1210,19 +1210,19 @@ struct River_UserData { }; /* AyStar callback for checking whether we reached our destination. */ -static int32 River_EndNodeCheck(const AyStar *aystar, const OpenListNode *current) +static int32_t River_EndNodeCheck(const AyStar *aystar, const OpenListNode *current) { return current->path.node.tile == *(TileIndex*)aystar->user_target ? AYSTAR_FOUND_END_NODE : AYSTAR_DONE; } /* AyStar callback for getting the cost of the current node. */ -static int32 River_CalculateG(AyStar *aystar, AyStarNode *current, OpenListNode *parent) +static int32_t River_CalculateG(AyStar *aystar, AyStarNode *current, OpenListNode *parent) { return 1 + RandomRange(_settings_game.game_creation.river_route_random); } /* AyStar callback for getting the estimated cost to the destination. */ -static int32 River_CalculateH(AyStar *aystar, AyStarNode *current, OpenListNode *parent) +static int32_t River_CalculateH(AyStar *aystar, AyStarNode *current, OpenListNode *parent) { return DistanceManhattan(*(TileIndex*)aystar->user_target, current->tile); } @@ -1551,7 +1551,7 @@ static void CalculateSnowLine() * Calculate the line (in height) between desert and tropic. * @return The height of the line between desert and tropic. */ -static uint8 CalculateDesertLine() +static uint8_t CalculateDesertLine() { /* CalculateCoverageLine() runs from top to bottom, so we need to invert the coverage. */ return CalculateCoverageLine(100 - _settings_game.game_creation.desert_coverage, 4); @@ -1584,7 +1584,7 @@ void GenerateLandscape(byte mode) } switch (_settings_game.game_creation.landscape) { case LT_ARCTIC: { - uint32 r = Random(); + uint32_t r = Random(); for (uint i = Map::ScaleBySize(GB(r, 0, 7) + 950); i != 0; --i) { GenerateTerrain(2, 0); @@ -1598,7 +1598,7 @@ void GenerateLandscape(byte mode) } case LT_TROPIC: { - uint32 r = Random(); + uint32_t r = Random(); for (uint i = Map::ScaleBySize(GB(r, 0, 7) + 170); i != 0; --i) { GenerateTerrain(0, 0); @@ -1618,7 +1618,7 @@ void GenerateLandscape(byte mode) } default: { - uint32 r = Random(); + uint32_t r = Random(); assert(_settings_game.difficulty.quantity_sea_lakes != CUSTOM_SEA_LEVEL_NUMBER_DIFFICULTY); uint i = Map::ScaleBySize(GB(r, 0, 7) + (3 - _settings_game.difficulty.quantity_sea_lakes) * 256 + 100); diff --git a/src/language.h b/src/language.h index 79dda356b3..8068bdb328 100644 --- a/src/language.h +++ b/src/language.h @@ -16,20 +16,20 @@ #include "strings_type.h" #include -static const uint8 CASE_GENDER_LEN = 16; ///< The (maximum) length of a case/gender string. -static const uint8 MAX_NUM_GENDERS = 8; ///< Maximum number of supported genders. -static const uint8 MAX_NUM_CASES = 16; ///< Maximum number of supported cases. +static const uint8_t CASE_GENDER_LEN = 16; ///< The (maximum) length of a case/gender string. +static const uint8_t MAX_NUM_GENDERS = 8; ///< Maximum number of supported genders. +static const uint8_t MAX_NUM_CASES = 16; ///< Maximum number of supported cases. /** Header of a language file. */ struct LanguagePackHeader { - static const uint32 IDENT = 0x474E414C; ///< Identifier for OpenTTD language files, big endian for "LANG" + static const uint32_t IDENT = 0x474E414C; ///< Identifier for OpenTTD language files, big endian for "LANG" - uint32 ident; ///< 32-bits identifier - uint32 version; ///< 32-bits of auto generated version info which is basically a hash of strings.h + uint32_t ident; ///< 32-bits identifier + uint32_t version; ///< 32-bits of auto generated version info which is basically a hash of strings.h char name[32]; ///< the international name of this language char own_name[32]; ///< the localized name of this language char isocode[16]; ///< the ISO code for the language (not country code) - uint16 offsets[TEXT_TAB_END]; ///< the offsets + uint16_t offsets[TEXT_TAB_END]; ///< the offsets /** Thousand separator used for anything not currencies */ char digit_group_separator[8]; @@ -37,7 +37,7 @@ struct LanguagePackHeader { char digit_group_separator_currency[8]; /** Decimal separator */ char digit_decimal_separator[8]; - uint16 missing; ///< number of missing strings. + uint16_t missing; ///< number of missing strings. byte plural_form; ///< plural form index byte text_dir; ///< default direction of the text /** @@ -48,10 +48,10 @@ struct LanguagePackHeader { * what language it is in "Windows". The ID is the 'locale identifier' on: * http://msdn.microsoft.com/en-us/library/ms776294.aspx */ - uint16 winlangid; ///< windows language id - uint8 newgrflangid; ///< newgrf language id - uint8 num_genders; ///< the number of genders of this language - uint8 num_cases; ///< the number of cases of this language + uint16_t winlangid; ///< windows language id + uint8_t newgrflangid; ///< newgrf language id + uint8_t num_genders; ///< the number of genders of this language + uint8_t num_cases; ///< the number of cases of this language byte pad[3]; ///< pad header to be a multiple of 4 char genders[MAX_NUM_GENDERS][CASE_GENDER_LEN]; ///< the genders used by this translation @@ -65,9 +65,9 @@ struct LanguagePackHeader { * @param gender_str The string representation of the gender. * @return The index of the gender, or MAX_NUM_GENDERS when the gender is unknown. */ - uint8 GetGenderIndex(const char *gender_str) const + uint8_t GetGenderIndex(const char *gender_str) const { - for (uint8 i = 0; i < MAX_NUM_GENDERS; i++) { + for (uint8_t i = 0; i < MAX_NUM_GENDERS; i++) { if (strcmp(gender_str, this->genders[i]) == 0) return i; } return MAX_NUM_GENDERS; @@ -78,9 +78,9 @@ struct LanguagePackHeader { * @param case_str The string representation of the case. * @return The index of the case, or MAX_NUM_CASES when the case is unknown. */ - uint8 GetCaseIndex(const char *case_str) const + uint8_t GetCaseIndex(const char *case_str) const { - for (uint8 i = 0; i < MAX_NUM_CASES; i++) { + for (uint8_t i = 0; i < MAX_NUM_CASES; i++) { if (strcmp(case_str, this->cases[i]) == 0) return i; } return MAX_NUM_CASES; diff --git a/src/league_base.h b/src/league_base.h index 6195d2c3ee..b43db4ac1f 100644 --- a/src/league_base.h +++ b/src/league_base.h @@ -30,7 +30,7 @@ extern LeagueTablePool _league_table_pool; **/ struct LeagueTableElement : LeagueTableElementPool::PoolItem<&_league_table_element_pool> { LeagueTableID table; ///< Id of the table which this element belongs to - int64 rating; ///< Value that determines ordering of elements in the table (higher=better) + int64_t rating; ///< Value that determines ordering of elements in the table (higher=better) CompanyID company; ///< Company Id to show the color blob for or INVALID_COMPANY std::string text; ///< Text of the element std::string score; ///< String representation of the score associated with the element diff --git a/src/league_cmd.cpp b/src/league_cmd.cpp index 6e715fd030..8c1e862dd2 100644 --- a/src/league_cmd.cpp +++ b/src/league_cmd.cpp @@ -83,7 +83,7 @@ std::tuple CmdCreateLeagueTable(DoCommandFlag flags, * @param link_target Id of the referenced object * @return the cost of this operation or an error */ -std::tuple CmdCreateLeagueTableElement(DoCommandFlag flags, LeagueTableID table, int64 rating, CompanyID company, const std::string &text, const std::string &score, LinkType link_type, LinkTargetID link_target) +std::tuple CmdCreateLeagueTableElement(DoCommandFlag flags, LeagueTableID table, int64_t rating, CompanyID company, const std::string &text, const std::string &score, LinkType link_type, LinkTargetID link_target) { if (_current_company != OWNER_DEITY) return { CMD_ERROR, INVALID_LEAGUE_TABLE_ELEMENT }; if (!LeagueTableElement::CanAllocateItem()) return { CMD_ERROR, INVALID_LEAGUE_TABLE_ELEMENT }; @@ -141,7 +141,7 @@ CommandCost CmdUpdateLeagueTableElementData(DoCommandFlag flags, LeagueTableElem * @param score String representation of the score associated with the element * @return the cost of this operation or an error */ -CommandCost CmdUpdateLeagueTableElementScore(DoCommandFlag flags, LeagueTableElementID element, int64 rating, const std::string &score) +CommandCost CmdUpdateLeagueTableElementScore(DoCommandFlag flags, LeagueTableElementID element, int64_t rating, const std::string &score) { if (_current_company != OWNER_DEITY) return CMD_ERROR; auto lte = LeagueTableElement::GetIfValid(element); diff --git a/src/league_cmd.h b/src/league_cmd.h index 39adb4aee4..21956dba99 100644 --- a/src/league_cmd.h +++ b/src/league_cmd.h @@ -15,9 +15,9 @@ #include "company_type.h" std::tuple CmdCreateLeagueTable(DoCommandFlag flags, const std::string &title, const std::string &header, const std::string &footer); -std::tuple CmdCreateLeagueTableElement(DoCommandFlag flags, LeagueTableID table, int64 rating, CompanyID company, const std::string &text, const std::string &score, LinkType link_type, LinkTargetID link_target); +std::tuple CmdCreateLeagueTableElement(DoCommandFlag flags, LeagueTableID table, int64_t rating, CompanyID company, const std::string &text, const std::string &score, LinkType link_type, LinkTargetID link_target); CommandCost CmdUpdateLeagueTableElementData(DoCommandFlag flags, LeagueTableElementID element, CompanyID company, const std::string &text, LinkType link_type, LinkTargetID link_target); -CommandCost CmdUpdateLeagueTableElementScore(DoCommandFlag flags, LeagueTableElementID element, int64 rating, const std::string &score); +CommandCost CmdUpdateLeagueTableElementScore(DoCommandFlag flags, LeagueTableElementID element, int64_t rating, const std::string &score); CommandCost CmdRemoveLeagueTableElement(DoCommandFlag flags, LeagueTableElementID element); DEF_CMD_TRAIT(CMD_CREATE_LEAGUE_TABLE, CmdCreateLeagueTable, CMD_DEITY | CMD_STR_CTRL, CMDT_OTHER_MANAGEMENT) diff --git a/src/league_type.h b/src/league_type.h index 3344bc206e..335edd78b3 100644 --- a/src/league_type.h +++ b/src/league_type.h @@ -20,7 +20,7 @@ enum LinkType : byte { LT_STORY_PAGE = 5, ///< Link a story page }; -typedef uint32 LinkTargetID; ///< Contains either tile, industry ID, town ID, story page ID or company ID +typedef uint32_t LinkTargetID; ///< Contains either tile, industry ID, town ID, story page ID or company ID struct Link { LinkType type; @@ -29,11 +29,11 @@ struct Link { Link(): Link(LT_NONE, 0) {} }; -typedef uint8 LeagueTableID; ///< ID of a league table +typedef uint8_t LeagueTableID; ///< ID of a league table struct LeagueTable; static const LeagueTableID INVALID_LEAGUE_TABLE = 0xFF; ///< Invalid/unknown index of LeagueTable -typedef uint16 LeagueTableElementID; ///< ID of a league table element +typedef uint16_t LeagueTableElementID; ///< ID of a league table element struct LeagueTableElement; static const LeagueTableElementID INVALID_LEAGUE_TABLE_ELEMENT = 0xFFFF; ///< Invalid/unknown index of LeagueTableElement diff --git a/src/linkgraph/demands.cpp b/src/linkgraph/demands.cpp index 7d7e182132..b164f46ae6 100644 --- a/src/linkgraph/demands.cpp +++ b/src/linkgraph/demands.cpp @@ -204,16 +204,16 @@ void DemandCalculator::CalcDemand(LinkGraphJob &job, Tscaler scaler) continue; } - int32 supply = scaler.EffectiveSupply(job[from_id], job[to_id]); + int32_t supply = scaler.EffectiveSupply(job[from_id], job[to_id]); assert(supply > 0); /* Scale the distance by mod_dist around max_distance */ - int32 distance = this->max_distance - (this->max_distance - - (int32)DistanceMaxPlusManhattan(job[from_id].base.xy, job[to_id].base.xy)) * + int32_t distance = this->max_distance - (this->max_distance - + (int32_t)DistanceMaxPlusManhattan(job[from_id].base.xy, job[to_id].base.xy)) * this->mod_dist / 100; /* Scale the accuracy by distance around accuracy / 2 */ - int32 divisor = this->accuracy * (this->mod_dist - 50) / 100 + + int32_t divisor = this->accuracy * (this->mod_dist - 50) / 100 + this->accuracy * distance / this->max_distance + 1; assert(divisor > 0); diff --git a/src/linkgraph/demands.h b/src/linkgraph/demands.h index 4b2eec12a7..a81079528a 100644 --- a/src/linkgraph/demands.h +++ b/src/linkgraph/demands.h @@ -14,9 +14,9 @@ public: DemandCalculator(LinkGraphJob &job); private: - int32 max_distance; ///< Maximum distance possible on the map. - int32 mod_dist; ///< Distance modifier, determines how much demands decrease with distance. - int32 accuracy; ///< Accuracy of the calculation. + int32_t max_distance; ///< Maximum distance possible on the map. + int32_t mod_dist; ///< Distance modifier, determines how much demands decrease with distance. + int32_t accuracy; ///< Accuracy of the calculation. template void CalcDemand(LinkGraphJob &job, Tscaler scaler); diff --git a/src/linkgraph/linkgraph.cpp b/src/linkgraph/linkgraph.cpp index c639bdc59f..015e167955 100644 --- a/src/linkgraph/linkgraph.cpp +++ b/src/linkgraph/linkgraph.cpp @@ -74,7 +74,7 @@ void LinkGraph::Compress() if (edge.capacity < (1 << 16)) { edge.travel_time_sum = edge.travel_time_sum * new_capacity / edge.capacity; } else if (edge.travel_time_sum != 0) { - edge.travel_time_sum = std::max(1, edge.travel_time_sum / 2); + edge.travel_time_sum = std::max(1, edge.travel_time_sum / 2); } edge.capacity = new_capacity; edge.usage /= 2; @@ -164,14 +164,14 @@ NodeID LinkGraph::AddNode(const Station *st) * @param usage Usage to be added. * @param mode Update mode to be used. */ -void LinkGraph::BaseNode::AddEdge(NodeID to, uint capacity, uint usage, uint32 travel_time, EdgeUpdateMode mode) +void LinkGraph::BaseNode::AddEdge(NodeID to, uint capacity, uint usage, uint32_t travel_time, EdgeUpdateMode mode) { assert(!this->HasEdgeTo(to)); BaseEdge &edge = *this->edges.emplace(std::upper_bound(this->edges.begin(), this->edges.end(), to), to); edge.capacity = capacity; edge.usage = usage; - edge.travel_time_sum = static_cast(travel_time) * capacity; + edge.travel_time_sum = static_cast(travel_time) * capacity; if (mode & EUM_UNRESTRICTED) edge.last_unrestricted_update = TimerGameCalendar::date; if (mode & EUM_RESTRICTED) edge.last_restricted_update = TimerGameCalendar::date; } @@ -183,7 +183,7 @@ void LinkGraph::BaseNode::AddEdge(NodeID to, uint capacity, uint usage, uint32 t * @param usage Usage to be added. * @param mode Update mode to be used. */ -void LinkGraph::BaseNode::UpdateEdge(NodeID to, uint capacity, uint usage, uint32 travel_time, EdgeUpdateMode mode) +void LinkGraph::BaseNode::UpdateEdge(NodeID to, uint capacity, uint usage, uint32_t travel_time, EdgeUpdateMode mode) { assert(capacity > 0); assert(usage <= capacity); @@ -214,25 +214,25 @@ void LinkGraph::BaseNode::RemoveEdge(NodeID to) * @param travel_time Travel time to be added, in ticks. * @param mode Update mode to be applied. */ -void LinkGraph::BaseEdge::Update(uint capacity, uint usage, uint32 travel_time, EdgeUpdateMode mode) +void LinkGraph::BaseEdge::Update(uint capacity, uint usage, uint32_t travel_time, EdgeUpdateMode mode) { assert(this->capacity > 0); assert(capacity >= usage); if (mode & EUM_INCREASE) { if (this->travel_time_sum == 0) { - this->travel_time_sum = static_cast(this->capacity + capacity) * travel_time; + this->travel_time_sum = static_cast(this->capacity + capacity) * travel_time; } else if (travel_time == 0) { this->travel_time_sum += this->travel_time_sum / this->capacity * capacity; } else { - this->travel_time_sum += static_cast(travel_time) * capacity; + this->travel_time_sum += static_cast(travel_time) * capacity; } this->capacity += capacity; this->usage += usage; } else if (mode & EUM_REFRESH) { if (this->travel_time_sum == 0) { this->capacity = std::max(this->capacity, capacity); - this->travel_time_sum = static_cast(travel_time) * this->capacity; + this->travel_time_sum = static_cast(travel_time) * this->capacity; } else if (capacity > this->capacity) { this->travel_time_sum = this->travel_time_sum / this->capacity * capacity; this->capacity = capacity; diff --git a/src/linkgraph/linkgraph.h b/src/linkgraph/linkgraph.h index 521684c8a1..106af79ab1 100644 --- a/src/linkgraph/linkgraph.h +++ b/src/linkgraph/linkgraph.h @@ -43,7 +43,7 @@ public: struct BaseEdge { uint capacity; ///< Capacity of the link. uint usage; ///< Usage of the link. - uint64 travel_time_sum; ///< Sum of the travel times of the link, in ticks. + uint64_t travel_time_sum; ///< Sum of the travel times of the link, in ticks. TimerGameCalendar::Date last_unrestricted_update; ///< When the unrestricted part of the link was last updated. TimerGameCalendar::Date last_restricted_update; ///< When the restricted part of the link was last updated. NodeID dest_node; ///< Destination of the edge. @@ -54,7 +54,7 @@ public: * Get edge's average travel time. * @return Travel time, in ticks. */ - uint32 TravelTime() const { return this->travel_time_sum / this->capacity; } + uint32_t TravelTime() const { return this->travel_time_sum / this->capacity; } /** * Get the date of the last update to any part of the edge's capacity. @@ -62,7 +62,7 @@ public: */ TimerGameCalendar::Date LastUpdate() const { return std::max(this->last_unrestricted_update, this->last_restricted_update); } - void Update(uint capacity, uint usage, uint32 time, EdgeUpdateMode mode); + void Update(uint capacity, uint usage, uint32_t time, EdgeUpdateMode mode); void Restrict() { this->last_unrestricted_update = INVALID_DATE; } void Release() { this->last_restricted_update = INVALID_DATE; } @@ -127,8 +127,8 @@ public: this->demand = demand; } - void AddEdge(NodeID to, uint capacity, uint usage, uint32 time, EdgeUpdateMode mode); - void UpdateEdge(NodeID to, uint capacity, uint usage, uint32 time, EdgeUpdateMode mode); + void AddEdge(NodeID to, uint capacity, uint usage, uint32_t time, EdgeUpdateMode mode); + void UpdateEdge(NodeID to, uint capacity, uint usage, uint32_t time, EdgeUpdateMode mode); void RemoveEdge(NodeID to); /** diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index 2742c51370..4289389519 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -27,7 +27,7 @@ * Colours for the various "load" states of links. Ordered from "unused" to * "overloaded". */ -const uint8 LinkGraphOverlay::LINK_COLOURS[][12] = { +const uint8_t LinkGraphOverlay::LINK_COLOURS[][12] = { { 0x0f, 0xd1, 0xd0, 0x57, 0x55, 0x53, 0xbf, 0xbd, @@ -149,19 +149,19 @@ inline bool LinkGraphOverlay::IsLinkVisible(Point pta, Point ptb, const DrawPixe * See: https://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm */ - const uint8 INSIDE = 0; // 0000 - const uint8 LEFT = 1; // 0001 - const uint8 RIGHT = 2; // 0010 - const uint8 BOTTOM = 4; // 0100 - const uint8 TOP = 8; // 1000 + const uint8_t INSIDE = 0; // 0000 + const uint8_t LEFT = 1; // 0001 + const uint8_t RIGHT = 2; // 0010 + const uint8_t BOTTOM = 4; // 0100 + const uint8_t TOP = 8; // 1000 int x0 = pta.x; int y0 = pta.y; int x1 = ptb.x; int y1 = ptb.y; - auto out_code = [&](int x, int y) -> uint8 { - uint8 out = INSIDE; + auto out_code = [&](int x, int y) -> uint8_t { + uint8_t out = INSIDE; if (x < left) { out |= LEFT; } else if (x > right) { @@ -175,24 +175,24 @@ inline bool LinkGraphOverlay::IsLinkVisible(Point pta, Point ptb, const DrawPixe return out; }; - uint8 c0 = out_code(x0, y0); - uint8 c1 = out_code(x1, y1); + uint8_t c0 = out_code(x0, y0); + uint8_t c1 = out_code(x1, y1); while (true) { if (c0 == 0 || c1 == 0) return true; if ((c0 & c1) != 0) return false; if (c0 & TOP) { // point 0 is above the clip window - x0 = x0 + (int)(((int64) (x1 - x0)) * ((int64) (top - y0)) / ((int64) (y1 - y0))); + x0 = x0 + (int)(((int64_t) (x1 - x0)) * ((int64_t) (top - y0)) / ((int64_t) (y1 - y0))); y0 = top; } else if (c0 & BOTTOM) { // point 0 is below the clip window - x0 = x0 + (int)(((int64) (x1 - x0)) * ((int64) (bottom - y0)) / ((int64) (y1 - y0))); + x0 = x0 + (int)(((int64_t) (x1 - x0)) * ((int64_t) (bottom - y0)) / ((int64_t) (y1 - y0))); y0 = bottom; } else if (c0 & RIGHT) { // point 0 is to the right of clip window - y0 = y0 + (int)(((int64) (y1 - y0)) * ((int64) (right - x0)) / ((int64) (x1 - x0))); + y0 = y0 + (int)(((int64_t) (y1 - y0)) * ((int64_t) (right - x0)) / ((int64_t) (x1 - x0))); x0 = right; } else if (c0 & LEFT) { // point 0 is to the left of clip window - y0 = y0 + (int)(((int64) (y1 - y0)) * ((int64) (left - x0)) / ((int64) (x1 - x0))); + y0 = y0 + (int)(((int64_t) (y1 - y0)) * ((int64_t) (left - x0)) / ((int64_t) (x1 - x0))); x0 = left; } @@ -238,7 +238,7 @@ void LinkGraphOverlay::AddLinks(const Station *from, const Station *to) * @param new_shared If the new link is shared. * @param cargo LinkProperties to write the information to. */ -/* static */ void LinkGraphOverlay::AddStats(CargoID new_cargo, uint new_cap, uint new_usg, uint new_plan, uint32 time, bool new_shared, LinkProperties &cargo) +/* static */ void LinkGraphOverlay::AddStats(CargoID new_cargo, uint new_cap, uint new_usg, uint new_plan, uint32_t time, bool new_shared, LinkProperties &cargo) { /* multiply the numbers by 32 in order to avoid comparing to 0 too often. */ if (cargo.capacity == 0 || @@ -369,8 +369,8 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond) /* Check the distance from the cursor to the line defined by the two stations. */ Point ptb = this->GetStationMiddle(Station::Get(j->first)); - float dist = std::abs((int64)(ptb.x - pta.x) * (int64)(pta.y - pt.y) - (int64)(pta.x - pt.x) * (int64)(ptb.y - pta.y)) / - std::sqrt((int64)(ptb.x - pta.x) * (int64)(ptb.x - pta.x) + (int64)(ptb.y - pta.y) * (int64)(ptb.y - pta.y)); + float dist = std::abs((int64_t)(ptb.x - pta.x) * (int64_t)(pta.y - pt.y) - (int64_t)(pta.x - pt.x) * (int64_t)(ptb.y - pta.y)) / + std::sqrt((int64_t)(ptb.x - pta.x) * (int64_t)(ptb.x - pta.x) + (int64_t)(ptb.y - pta.y) * (int64_t)(ptb.y - pta.y)); const auto &link = j->second; if (dist <= 4 && link.Usage() > 0 && pt.x + 2 >= std::min(pta.x, ptb.x) && @@ -380,7 +380,7 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond) static std::string tooltip_extension; tooltip_extension.clear(); /* Fill buf with more information if this is a bidirectional link. */ - uint32 back_time = 0; + uint32_t back_time = 0; auto k = this->cached_links[j->first].find(i->first); if (k != this->cached_links[j->first].end()) { const auto &back = k->second; @@ -617,7 +617,7 @@ void LinkGraphLegendWindow::DrawWidget(const Rect &r, int widget) const DrawCompanyIcon(cid, CenterBounds(br.left, br.right, sprite_size.width), CenterBounds(br.top, br.bottom, sprite_size.height)); } if (IsInsideMM(widget, WID_LGL_SATURATION_FIRST, WID_LGL_SATURATION_LAST + 1)) { - uint8 colour = LinkGraphOverlay::LINK_COLOURS[_settings_client.gui.linkgraph_colours][widget - WID_LGL_SATURATION_FIRST]; + uint8_t colour = LinkGraphOverlay::LINK_COLOURS[_settings_client.gui.linkgraph_colours][widget - WID_LGL_SATURATION_FIRST]; GfxFillRect(br, colour); StringID str = STR_NULL; if (widget == WID_LGL_SATURATION_FIRST) { @@ -663,7 +663,7 @@ bool LinkGraphLegendWindow::OnTooltip(Point pt, int widget, TooltipCloseConditio */ void LinkGraphLegendWindow::UpdateOverlayCompanies() { - uint32 mask = 0; + uint32_t mask = 0; for (uint c = 0; c < MAX_COMPANIES; c++) { if (this->IsWidgetDisabled(c + WID_LGL_COMPANY_FIRST)) continue; if (!this->IsWidgetLowered(c + WID_LGL_COMPANY_FIRST)) continue; diff --git a/src/linkgraph/linkgraph_gui.h b/src/linkgraph/linkgraph_gui.h index b84527c223..17b4731136 100644 --- a/src/linkgraph/linkgraph_gui.h +++ b/src/linkgraph/linkgraph_gui.h @@ -30,7 +30,7 @@ struct LinkProperties { uint capacity; ///< Capacity of the link. uint usage; ///< Actual usage of the link. uint planned; ///< Planned usage of the link. - uint32 time; ///< Travel time of the link. + uint32_t time; ///< Travel time of the link. bool shared; ///< If this is a shared link to be drawn dashed. }; @@ -44,7 +44,7 @@ public: typedef std::map LinkMap; typedef std::vector > StationSupplyList; - static const uint8 LINK_COLOURS[][12]; + static const uint8_t LINK_COLOURS[][12]; /** * Create a link graph overlay for the specified window. @@ -94,7 +94,7 @@ protected: void GetWidgetDpi(DrawPixelInfo *dpi) const; void RebuildCache(); - static void AddStats(CargoID new_cargo, uint new_cap, uint new_usg, uint new_flow, uint32 time, bool new_shared, LinkProperties &cargo); + static void AddStats(CargoID new_cargo, uint new_cap, uint new_usg, uint new_flow, uint32_t time, bool new_shared, LinkProperties &cargo); static void DrawVertex(int x, int y, int size, int colour, int border_colour); }; diff --git a/src/linkgraph/linkgraph_type.h b/src/linkgraph/linkgraph_type.h index 89abef4e43..1627767ed4 100644 --- a/src/linkgraph/linkgraph_type.h +++ b/src/linkgraph/linkgraph_type.h @@ -10,13 +10,13 @@ #ifndef LINKGRAPH_TYPE_H #define LINKGRAPH_TYPE_H -typedef uint16 LinkGraphID; +typedef uint16_t LinkGraphID; static const LinkGraphID INVALID_LINK_GRAPH = UINT16_MAX; -typedef uint16 LinkGraphJobID; +typedef uint16_t LinkGraphJobID; static const LinkGraphJobID INVALID_LINK_GRAPH_JOB = UINT16_MAX; -typedef uint16 NodeID; +typedef uint16_t NodeID; static const NodeID INVALID_NODE = UINT16_MAX; enum DistributionType : byte { diff --git a/src/linkgraph/linkgraphjob.cpp b/src/linkgraph/linkgraphjob.cpp index 6551a9559e..98e329ea79 100644 --- a/src/linkgraph/linkgraphjob.cpp +++ b/src/linkgraph/linkgraphjob.cpp @@ -101,7 +101,7 @@ LinkGraphJob::~LinkGraphJob() /* Link graph has been merged into another one. */ if (!LinkGraph::IsValidID(this->link_graph.index)) return; - uint16 size = this->Size(); + uint16_t size = this->Size(); for (NodeID node_id = 0; node_id < size; ++node_id) { NodeAnnotation &from = this->nodes[node_id]; diff --git a/src/linkgraph/mcf.cpp b/src/linkgraph/mcf.cpp index 508e9616b9..21db2464e9 100644 --- a/src/linkgraph/mcf.cpp +++ b/src/linkgraph/mcf.cpp @@ -258,7 +258,7 @@ void MultiCommodityFlow::Dijkstra(NodeID source_node, PathVector &paths) { typedef std::set AnnoSet; Tedge_iterator iter(this->job); - uint16 size = this->job.Size(); + uint16_t size = this->job.Size(); AnnoSet annos; paths.resize(size, nullptr); for (NodeID node = 0; node < size; ++node) { @@ -481,7 +481,7 @@ bool MCF1stPass::EliminateCycles(PathVector &path, NodeID origin_id, NodeID next bool MCF1stPass::EliminateCycles() { bool cycles_found = false; - uint16 size = this->job.Size(); + uint16_t size = this->job.Size(); PathVector path(size, nullptr); for (NodeID node = 0; node < size; ++node) { /* Starting at each node in the graph find all cycles involving this @@ -499,7 +499,7 @@ bool MCF1stPass::EliminateCycles() MCF1stPass::MCF1stPass(LinkGraphJob &job) : MultiCommodityFlow(job) { PathVector paths; - uint16 size = job.Size(); + uint16_t size = job.Size(); uint accuracy = job.Settings().accuracy; bool more_loops; std::vector finished_sources(size); @@ -548,7 +548,7 @@ MCF2ndPass::MCF2ndPass(LinkGraphJob &job) : MultiCommodityFlow(job) { this->max_saturation = UINT_MAX; // disable artificial cap on saturation PathVector paths; - uint16 size = job.Size(); + uint16_t size = job.Size(); uint accuracy = job.Settings().accuracy; bool demand_left = true; std::vector finished_sources(size); diff --git a/src/linkgraph/refresh.cpp b/src/linkgraph/refresh.cpp index 5ebe157ef8..8a9551a82a 100644 --- a/src/linkgraph/refresh.cpp +++ b/src/linkgraph/refresh.cpp @@ -106,7 +106,7 @@ bool LinkRefresher::HandleRefit(CargoID refit_cargo) v->cargo_type = this->cargo; v->cargo_subtype = GetBestFittingSubType(v, v, this->cargo); - uint16 mail_capacity = 0; + uint16_t mail_capacity = 0; uint amount = e->DetermineCapacity(v, &mail_capacity); /* Restore the original cargo type */ @@ -160,7 +160,7 @@ void LinkRefresher::ResetRefit() * @param num_hops Number of hops already taken by recursive calls to this method. * @return new next Order. */ -const Order *LinkRefresher::PredictNextOrder(const Order *cur, const Order *next, uint8 flags, uint num_hops) +const Order *LinkRefresher::PredictNextOrder(const Order *cur, const Order *next, uint8_t flags, uint num_hops) { /* next is good if it's either nullptr (then the caller will stop the * evaluation) or if it's not conditional and the caller allows it to be @@ -224,7 +224,7 @@ void LinkRefresher::RefreshStats(const Order *cur, const Order *next) /* This estimates the travel time of the link as the time needed * to travel between the stations at half the max speed of the consist. * The result is in tiles/tick (= 2048 km-ish/h). */ - uint32 time_estimate = DistanceManhattan(st->xy, st_to->xy) * 4096U / this->vehicle->GetDisplayMaxSpeed(); + uint32_t time_estimate = DistanceManhattan(st->xy, st_to->xy) * 4096U / this->vehicle->GetDisplayMaxSpeed(); /* If the vehicle is currently full loading, increase the capacities at the station * where it is loading by an estimate of what it would have transported if it wasn't @@ -263,7 +263,7 @@ void LinkRefresher::RefreshStats(const Order *cur, const Order *next) * @param flags RefreshFlags to give hints about the previous link and state carried over from that. * @param num_hops Number of hops already taken by recursive calls to this method. */ -void LinkRefresher::RefreshLinks(const Order *cur, const Order *next, uint8 flags, uint num_hops) +void LinkRefresher::RefreshLinks(const Order *cur, const Order *next, uint8_t flags, uint num_hops) { while (next != nullptr) { diff --git a/src/linkgraph/refresh.h b/src/linkgraph/refresh.h index 15a9796e5e..3c1fe40ecf 100644 --- a/src/linkgraph/refresh.h +++ b/src/linkgraph/refresh.h @@ -38,9 +38,9 @@ protected: */ struct RefitDesc { CargoID cargo; ///< Cargo type the vehicle will be carrying. - uint16 capacity; ///< Capacity the vehicle will have. - uint16 remaining; ///< Capacity remaining from before the previous refit. - RefitDesc(CargoID cargo, uint16 capacity, uint16 remaining) : + uint16_t capacity; ///< Capacity the vehicle will have. + uint16_t remaining; ///< Capacity remaining from before the previous refit. + RefitDesc(CargoID cargo, uint16_t capacity, uint16_t remaining) : cargo(cargo), capacity(capacity), remaining(remaining) {} }; @@ -90,9 +90,9 @@ protected: bool HandleRefit(CargoID refit_cargo); void ResetRefit(); void RefreshStats(const Order *cur, const Order *next); - const Order *PredictNextOrder(const Order *cur, const Order *next, uint8 flags, uint num_hops = 0); + const Order *PredictNextOrder(const Order *cur, const Order *next, uint8_t flags, uint num_hops = 0); - void RefreshLinks(const Order *cur, const Order *next, uint8 flags, uint num_hops = 0); + void RefreshLinks(const Order *cur, const Order *next, uint8_t flags, uint num_hops = 0); }; #endif /* REFRESH_H */ diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 5961b90fd2..05ec1a5de0 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -520,7 +520,7 @@ static WindowDesc _main_window_desc( * @param keycode The keycode that was pressed by the user. * @return True iff the keycode matches one of the hotkeys for 'quit'. */ -bool IsQuitKey(uint16 keycode) +bool IsQuitKey(uint16_t keycode) { int num = MainWindow::hotkeys.CheckMatch(keycode); return num == GHK_QUIT; diff --git a/src/map.cpp b/src/map.cpp index 347af92c3a..2fea8ae36c 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -83,7 +83,7 @@ TileIndex TileAdd(TileIndex tile, TileIndexDiff add, if (x >= Map::SizeX() || y >= Map::SizeY()) { std::string message = fmt::format("TILE_ADD({}) when adding 0x{:04X} and 0x{%04X} failed", - exp, (uint32)tile, add); + exp, (uint32_t)tile, add); #if !defined(_MSC_VER) fmt::print(stderr, "{}:{} {}\n", file, line, message); #else @@ -356,8 +356,8 @@ uint GetClosestWaterDistance(TileIndex tile, bool water) /* going counter-clockwise around this square */ for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) { - static const int8 ddx[DIAGDIR_END] = { -1, 1, 1, -1}; - static const int8 ddy[DIAGDIR_END] = { 1, 1, -1, -1}; + static const int8_t ddx[DIAGDIR_END] = { -1, 1, 1, -1}; + static const int8_t ddy[DIAGDIR_END] = { 1, 1, -1, -1}; int dx = ddx[dir]; int dy = ddy[dir]; diff --git a/src/map_func.h b/src/map_func.h index c04796ff8b..f879e00cb9 100644 --- a/src/map_func.h +++ b/src/map_func.h @@ -32,7 +32,7 @@ private: struct TileBase { byte type; ///< The type (bits 4..7), bridges (2..3), rainforest/desert (0..1) byte height; ///< The height of the northern corner. - uint16 m2; ///< Primarily used for indices to towns, industries and stations + uint16_t m2; ///< Primarily used for indices to towns, industries and stations byte m1; ///< Primarily used for ownership information byte m3; ///< General purpose byte m4; ///< General purpose @@ -48,7 +48,7 @@ private: struct TileExtended { byte m6; ///< General purpose byte m7; ///< Primarily used for newgrf support - uint16 m8; ///< General purpose + uint16_t m8; ///< General purpose }; static TileBase *base_tiles; ///< Pointer to the tile-array. @@ -120,9 +120,9 @@ public: * * Look at docs/landscape.html for the exact meaning of the data. * @param tile The tile to get the data for. - * @return reference to the uint16 holding the data. + * @return reference to the uint16_t holding the data. */ - debug_inline uint16 &m2() + debug_inline uint16_t &m2() { return base_tiles[tile].m2; } @@ -192,9 +192,9 @@ public: * * Look at docs/landscape.html for the exact meaning of the data. * @param tile The tile to get the data for. - * @return reference to the uint16 holding the data. + * @return reference to the uint16_t holding the data. */ - debug_inline uint16 &m8() + debug_inline uint16_t &m8() { return extended_tiles[tile].m8; } @@ -373,7 +373,7 @@ public: * * @see TileDiffXY(int, int) */ -typedef int32 TileIndexDiff; +typedef int32_t TileIndexDiff; /** * Returns the TileIndex of a coordinate. @@ -643,7 +643,7 @@ bool CircularTileSearch(TileIndex *tile, uint radius, uint w, uint h, TestTileOn * @param r the random 'seed' * @return a valid tile */ -static inline TileIndex RandomTileSeed(uint32 r) +static inline TileIndex RandomTileSeed(uint32_t r) { return Map::WrapToMap(r); } diff --git a/src/map_type.h b/src/map_type.h index 1b5c0fc975..3ff770d15d 100644 --- a/src/map_type.h +++ b/src/map_type.h @@ -20,7 +20,7 @@ * * @see TileDiffXY(int, int) */ -typedef int32 TileIndexDiff; +typedef int32_t TileIndexDiff; /** * A pair-construct of a TileIndexDiff. @@ -29,8 +29,8 @@ typedef int32 TileIndexDiff; * tiles as a pair of x and y value. */ struct TileIndexDiffC { - int16 x; ///< The x value of the coordinate - int16 y; ///< The y value of the coordinate + int16_t x; ///< The x value of the coordinate + int16_t y; ///< The y value of the coordinate }; /** Minimal and maximal map width and height */ diff --git a/src/misc/countedobj.cpp b/src/misc/countedobj.cpp index d9b66b83da..563ae3f4bb 100644 --- a/src/misc/countedobj.cpp +++ b/src/misc/countedobj.cpp @@ -13,14 +13,14 @@ #include "../safeguards.h" -int32 SimpleCountedObject::AddRef() +int32_t SimpleCountedObject::AddRef() { return ++m_ref_cnt; } -int32 SimpleCountedObject::Release() +int32_t SimpleCountedObject::Release() { - int32 res = --m_ref_cnt; + int32_t res = --m_ref_cnt; assert(res >= 0); if (res == 0) { try { diff --git a/src/misc/countedptr.hpp b/src/misc/countedptr.hpp index ee0edea67c..625b124200 100644 --- a/src/misc/countedptr.hpp +++ b/src/misc/countedptr.hpp @@ -196,7 +196,7 @@ template struct AdaptT { * @see misc/countedobj.cpp for implementation. */ struct SimpleCountedObject { - int32 m_ref_cnt; + int32_t m_ref_cnt; SimpleCountedObject() : m_ref_cnt(0) @@ -205,8 +205,8 @@ struct SimpleCountedObject { virtual ~SimpleCountedObject() {} - virtual int32 AddRef(); - virtual int32 Release(); + virtual int32_t AddRef(); + virtual int32_t Release(); virtual void FinalRelease() {}; }; diff --git a/src/misc/getoptdata.h b/src/misc/getoptdata.h index 5b1b05d75d..f578769df5 100644 --- a/src/misc/getoptdata.h +++ b/src/misc/getoptdata.h @@ -22,7 +22,7 @@ enum OptionDataFlags { struct OptionData { byte id; ///< Unique identification of this option data, often the same as #shortname. char shortname; ///< Short option letter if available, else use \c '\0'. - uint16 flags; ///< Option data flags. @see OptionDataFlags + uint16_t flags; ///< Option data flags. @see OptionDataFlags const char *longname; ///< Long option name including '-'/'--' prefix, use \c nullptr if not available. }; diff --git a/src/misc/hashtable.hpp b/src/misc/hashtable.hpp index 13dadc01ac..0fd744777a 100644 --- a/src/misc/hashtable.hpp +++ b/src/misc/hashtable.hpp @@ -159,7 +159,7 @@ protected: /** static helper - return hash for the given key modulo number of slots */ inline static int CalcHash(const Tkey &key) { - uint32 hash = key.CalcHash(); + uint32_t hash = key.CalcHash(); hash -= (hash >> 17); // hash * 131071 / 131072 hash -= (hash >> 5); // * 31 / 32 hash &= (1 << Thash_bits) - 1; // modulo slots diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 5806efbcb5..ac971c284f 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -611,7 +611,7 @@ void ShowFeederIncomeAnimation(int x, int y, int z, Money transfer, Money income * @param string String which is drawn on the map. * @return TextEffectID to be used for future updates of the loading indicators. */ -TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent, StringID string) +TextEffectID ShowFillingPercent(int x, int y, int z, uint8_t percent, StringID string) { Point pt = RemapCoords(x, y, z); @@ -626,7 +626,7 @@ TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent, StringID str * @param te_id TextEffectID to be updated. * @param string String which is printed. */ -void UpdateFillingPercent(TextEffectID te_id, uint8 percent, StringID string) +void UpdateFillingPercent(TextEffectID te_id, uint8_t percent, StringID string) { assert(string != STR_NULL); @@ -676,7 +676,7 @@ struct TooltipsWindow : public Window CLRBITS(this->flags, WF_WHITE_BORDER); } - Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override + Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override { /* Find the free screen space between the main toolbar at the top, and the statusbar at the bottom. * Add a fixed distance 2 so the tooltip floats free from both bars. @@ -1174,7 +1174,7 @@ struct QueryWindow : public Window { } } - EventState OnKeyPress(WChar key, uint16 keycode) override + EventState OnKeyPress(char32_t key, uint16_t keycode) override { /* ESC closes the window, Enter confirms the action */ switch (keycode) { diff --git a/src/mixer.cpp b/src/mixer.cpp index eefff9dd8d..10a9ac8933 100644 --- a/src/mixer.cpp +++ b/src/mixer.cpp @@ -19,13 +19,13 @@ struct MixerChannel { /* pointer to allocated buffer memory */ - int8 *memory; + int8_t *memory; /* current position in memory */ - uint32 pos; - uint32 frac_pos; - uint32 frac_speed; - uint32 samples_left; + uint32_t pos; + uint32_t frac_pos; + uint32_t frac_speed; + uint32_t samples_left; /* Mixing volume */ int volume_left; @@ -34,13 +34,13 @@ struct MixerChannel { bool is16bit; }; -static std::atomic _active_channels; +static std::atomic _active_channels; static MixerChannel _channels[8]; -static uint32 _play_rate = 11025; -static uint32 _max_size = UINT_MAX; +static uint32_t _play_rate = 11025; +static uint32_t _max_size = UINT_MAX; static MxStreamCallback _music_stream = nullptr; static std::mutex _music_stream_mutex; -static std::atomic _effect_vol; +static std::atomic _effect_vol; /** * The theoretical maximum volume for a single sound sample. Multiple sound @@ -63,15 +63,15 @@ static int RateConversion(T *b, int frac_pos) return ((b[0] * ((1 << 16) - frac_pos)) + (b[1] * frac_pos)) >> 16; } -static void mix_int16(MixerChannel *sc, int16 *buffer, uint samples, uint8 effect_vol) +static void mix_int16(MixerChannel *sc, int16_t *buffer, uint samples, uint8_t effect_vol) { if (samples > sc->samples_left) samples = sc->samples_left; sc->samples_left -= samples; assert(samples > 0); - const int16 *b = (const int16 *)sc->memory + sc->pos; - uint32 frac_pos = sc->frac_pos; - uint32 frac_speed = sc->frac_speed; + const int16_t *b = (const int16_t *)sc->memory + sc->pos; + uint32_t frac_pos = sc->frac_pos; + uint32_t frac_speed = sc->frac_speed; int volume_left = sc->volume_left * effect_vol / 255; int volume_right = sc->volume_right * effect_vol / 255; @@ -96,18 +96,18 @@ static void mix_int16(MixerChannel *sc, int16 *buffer, uint samples, uint8 effec } sc->frac_pos = frac_pos; - sc->pos = b - (const int16 *)sc->memory; + sc->pos = b - (const int16_t *)sc->memory; } -static void mix_int8_to_int16(MixerChannel *sc, int16 *buffer, uint samples, uint8 effect_vol) +static void mix_int8_to_int16(MixerChannel *sc, int16_t *buffer, uint samples, uint8_t effect_vol) { if (samples > sc->samples_left) samples = sc->samples_left; sc->samples_left -= samples; assert(samples > 0); - const int8 *b = sc->memory + sc->pos; - uint32 frac_pos = sc->frac_pos; - uint32 frac_speed = sc->frac_speed; + const int8_t *b = sc->memory + sc->pos; + uint32_t frac_pos = sc->frac_pos; + uint32_t frac_speed = sc->frac_speed; int volume_left = sc->volume_left * effect_vol / 255; int volume_right = sc->volume_right * effect_vol / 255; @@ -135,7 +135,7 @@ static void mix_int8_to_int16(MixerChannel *sc, int16 *buffer, uint samples, uin sc->pos = b - sc->memory; } -static void MxCloseChannel(uint8 channel_index) +static void MxCloseChannel(uint8_t channel_index) { _active_channels.fetch_and(~(1 << channel_index), std::memory_order_release); } @@ -150,31 +150,31 @@ void MxMixSamples(void *buffer, uint samples) } /* Clear the buffer */ - memset(buffer, 0, sizeof(int16) * 2 * samples); + memset(buffer, 0, sizeof(int16_t) * 2 * samples); { std::lock_guard lock{ _music_stream_mutex }; /* Fetch music if a sampled stream is available */ - if (_music_stream) _music_stream((int16*)buffer, samples); + if (_music_stream) _music_stream((int16_t*)buffer, samples); } /* Apply simple x^3 scaling to master effect volume. This increases the * perceived difference in loudness to better match expectations. effect_vol * is expected to be in the range 0-127 hence the division by 127 * 127 to * get back into range. */ - uint8 effect_vol_setting = _effect_vol.load(std::memory_order_relaxed); - uint8 effect_vol = (effect_vol_setting * + uint8_t effect_vol_setting = _effect_vol.load(std::memory_order_relaxed); + uint8_t effect_vol = (effect_vol_setting * effect_vol_setting * effect_vol_setting) / (127 * 127); /* Mix each channel */ - uint8 active = _active_channels.load(std::memory_order_acquire); - for (uint8 idx : SetBitIterator(active)) { + uint8_t active = _active_channels.load(std::memory_order_acquire); + for (uint8_t idx : SetBitIterator(active)) { MixerChannel *mc = &_channels[idx]; if (mc->is16bit) { - mix_int16(mc, (int16*)buffer, samples, effect_vol); + mix_int16(mc, (int16_t*)buffer, samples, effect_vol); } else { - mix_int8_to_int16(mc, (int16*)buffer, samples, effect_vol); + mix_int8_to_int16(mc, (int16_t*)buffer, samples, effect_vol); } if (mc->samples_left == 0) MxCloseChannel(idx); } @@ -182,11 +182,11 @@ void MxMixSamples(void *buffer, uint samples) MixerChannel *MxAllocateChannel() { - uint8 currently_active = _active_channels.load(std::memory_order_acquire); - uint8 available = ~currently_active; + uint8_t currently_active = _active_channels.load(std::memory_order_acquire); + uint8_t available = ~currently_active; if (available == 0) return nullptr; - uint8 channel_index = FindFirstBit(available); + uint8_t channel_index = FindFirstBit(available); MixerChannel *mc = &_channels[channel_index]; free(mc->memory); @@ -194,7 +194,7 @@ MixerChannel *MxAllocateChannel() return mc; } -void MxSetChannelRawSrc(MixerChannel *mc, int8 *mem, size_t size, uint rate, bool is16bit) +void MxSetChannelRawSrc(MixerChannel *mc, int8_t *mem, size_t size, uint rate, bool is16bit) { mc->memory = mem; mc->frac_pos = 0; @@ -231,7 +231,7 @@ void MxSetChannelVolume(MixerChannel *mc, uint volume, float pan) void MxActivateChannel(MixerChannel *mc) { - uint8 channel_index = mc - _channels; + uint8_t channel_index = mc - _channels; _active_channels.fetch_or((1 << channel_index), std::memory_order_release); } @@ -240,7 +240,7 @@ void MxActivateChannel(MixerChannel *mc) * @param music_callback Function that will be called to fill sample buffers with music data. * @return Sample rate of mixer, which the buffers supplied to the callback must be rendered at. */ -uint32 MxSetMusicSource(MxStreamCallback music_callback) +uint32_t MxSetMusicSource(MxStreamCallback music_callback) { std::lock_guard lock{ _music_stream_mutex }; _music_stream = music_callback; @@ -257,7 +257,7 @@ bool MxInitialize(uint rate) return true; } -void SetEffectVolume(uint8 volume) +void SetEffectVolume(uint8_t volume) { _effect_vol.store(volume, std::memory_order_relaxed); } diff --git a/src/mixer.h b/src/mixer.h index 51669da71c..ad94f5440c 100644 --- a/src/mixer.h +++ b/src/mixer.h @@ -18,18 +18,18 @@ struct MixerChannel; * @param buffer Pointer to interleaved 2-channel signed 16 bit PCM data buffer, guaranteed to be 0-initialized. * @param samples number of samples that must be filled into \c buffer. */ -typedef void(*MxStreamCallback)(int16 *buffer, size_t samples); +typedef void(*MxStreamCallback)(int16_t *buffer, size_t samples); bool MxInitialize(uint rate); void MxMixSamples(void *buffer, uint samples); MixerChannel *MxAllocateChannel(); -void MxSetChannelRawSrc(MixerChannel *mc, int8 *mem, size_t size, uint rate, bool is16bit); +void MxSetChannelRawSrc(MixerChannel *mc, int8_t *mem, size_t size, uint rate, bool is16bit); void MxSetChannelVolume(MixerChannel *mc, uint volume, float pan); void MxActivateChannel(MixerChannel*); -uint32 MxSetMusicSource(MxStreamCallback music_callback); +uint32_t MxSetMusicSource(MxStreamCallback music_callback); -void SetEffectVolume(uint8 volume); +void SetEffectVolume(uint8_t volume); #endif /* MIXER_H */ diff --git a/src/music.cpp b/src/music.cpp index bd224fb7fe..d642f9b4cc 100644 --- a/src/music.cpp +++ b/src/music.cpp @@ -30,7 +30,7 @@ char *GetMusicCatEntryName(const std::string &filename, size_t entrynum) if (!FioCheckFileExists(filename, BASESET_DIR)) return nullptr; RandomAccessFile file(filename, BASESET_DIR); - uint32 ofs = file.ReadDword(); + uint32_t ofs = file.ReadDword(); size_t entry_count = ofs / 8; if (entrynum < entry_count) { file.SeekTo(entrynum * 8, SEEK_SET); @@ -58,7 +58,7 @@ byte *GetMusicCatEntryData(const std::string &filename, size_t entrynum, size_t if (!FioCheckFileExists(filename, BASESET_DIR)) return nullptr; RandomAccessFile file(filename, BASESET_DIR); - uint32 ofs = file.ReadDword(); + uint32_t ofs = file.ReadDword(); size_t entry_count = ofs / 8; if (entrynum < entry_count) { file.SeekTo(entrynum * 8, SEEK_SET); diff --git a/src/music/dmusic.cpp b/src/music/dmusic.cpp index d614758274..346374d37f 100644 --- a/src/music/dmusic.cpp +++ b/src/music/dmusic.cpp @@ -115,7 +115,7 @@ PACK_N(struct WAVE_DOWNLOAD { }, 2); struct PlaybackSegment { - uint32 start, end; + uint32_t start, end; size_t start_block; bool loop; }; @@ -722,7 +722,7 @@ static void MidiThreadProc() REFERENCE_TIME playback_time = current_time - playback_start_time; if (block.realtime * MIDITIME_TO_REFTIME > playback_time + 3 *_playback.preload_time * MS_TO_REFTIME) { /* Stop the thread loop until we are at the preload time of the next block. */ - next_timeout = Clamp(((int64)block.realtime * MIDITIME_TO_REFTIME - playback_time) / MS_TO_REFTIME - _playback.preload_time, 0, 1000); + next_timeout = Clamp(((int64_t)block.realtime * MIDITIME_TO_REFTIME - playback_time) / MS_TO_REFTIME - _playback.preload_time, 0, 1000); Debug(driver, 9, "DMusic thread: Next event in {} ms (music {}, ref {})", next_timeout, block.realtime * MIDITIME_TO_REFTIME, playback_time); break; } diff --git a/src/music/fluidsynth.cpp b/src/music/fluidsynth.cpp index 211bc959eb..7a900579e2 100644 --- a/src/music/fluidsynth.cpp +++ b/src/music/fluidsynth.cpp @@ -50,7 +50,7 @@ static const char *default_sf[] = { nullptr }; -static void RenderMusicStream(int16 *buffer, size_t samples) +static void RenderMusicStream(int16_t *buffer, size_t samples) { std::unique_lock lock{ _midi.synth_mutex, std::try_to_lock }; @@ -74,7 +74,7 @@ const char *MusicDriver_FluidSynth::Start(const StringList ¶m) fluid_settings_setint(_midi.settings, "synth.lock-memory", 0); /* Install the music render routine and set up the samplerate */ - uint32 samplerate = MxSetMusicSource(RenderMusicStream); + uint32_t samplerate = MxSetMusicSource(RenderMusicStream); fluid_settings_setnum(_midi.settings, "synth.sample-rate", samplerate); Debug(driver, 1, "Fluidsynth: samplerate {:.0f}", (float)samplerate); diff --git a/src/music/midi.h b/src/music/midi.h index 6de8b856c9..7408cd52d0 100644 --- a/src/music/midi.h +++ b/src/music/midi.h @@ -14,9 +14,9 @@ /** Header of a Stanard MIDI File */ struct SMFHeader { - uint16 format; - uint16 tracks; - uint16 tickdiv; + uint16_t format; + uint16_t tracks; + uint16_t tickdiv; }; /** MIDI status byte codes */ diff --git a/src/music/midifile.cpp b/src/music/midifile.cpp index 6f849247c0..1caf8c1c65 100644 --- a/src/music/midifile.cpp +++ b/src/music/midifile.cpp @@ -118,7 +118,7 @@ public: * @param[out] res returns the read value * @return true if there was data available */ - bool ReadVariableLength(uint32 &res) + bool ReadVariableLength(uint32_t &res) { res = 0; byte b = 0; @@ -199,7 +199,7 @@ static bool ReadTrackChunk(FILE *file, MidiFile &target) } /* Read chunk length and then the whole chunk */ - uint32 chunk_length; + uint32_t chunk_length; if (fread(&chunk_length, 1, 4, file) != 4) { return false; } @@ -217,7 +217,7 @@ static bool ReadTrackChunk(FILE *file, MidiFile &target) bool running_sysex = false; while (!chunk.IsEnd()) { /* Read deltatime for event, start new block */ - uint32 deltatime = 0; + uint32_t deltatime = 0; if (!chunk.ReadVariableLength(deltatime)) { return false; } @@ -271,7 +271,7 @@ static bool ReadTrackChunk(FILE *file, MidiFile &target) if (!chunk.ReadByte(buf[0])) { return false; } - uint32 length = 0; + uint32_t length = 0; if (!chunk.ReadVariableLength(length)) { return false; } @@ -294,7 +294,7 @@ static bool ReadTrackChunk(FILE *file, MidiFile &target) } } else if (status == MIDIST_SYSEX || (status == MIDIST_SMF_ESCAPE && running_sysex)) { /* System exclusive message */ - uint32 length = 0; + uint32_t length = 0; if (!chunk.ReadVariableLength(length)) { return false; } @@ -311,7 +311,7 @@ static bool ReadTrackChunk(FILE *file, MidiFile &target) } } else if (status == MIDIST_SMF_ESCAPE) { /* Escape sequence */ - uint32 length = 0; + uint32_t length = 0; if (!chunk.ReadVariableLength(length)) { return false; } @@ -356,7 +356,7 @@ static bool FixupMidiData(MidiFile &target) /* Merge blocks with identical tick times */ std::vector merged_blocks; - uint32 last_ticktime = 0; + uint32_t last_ticktime = 0; for (size_t i = 0; i < target.blocks.size(); i++) { MidiFile::DataBlock &block = target.blocks[i]; if (block.data.size() == 0) { @@ -372,7 +372,7 @@ static bool FixupMidiData(MidiFile &target) /* Annotate blocks with real time */ last_ticktime = 0; - uint32 last_realtime = 0; + uint32_t last_realtime = 0; size_t cur_tempo = 0, cur_block = 0; while (cur_block < target.blocks.size()) { MidiFile::DataBlock &block = target.blocks[cur_block]; @@ -380,16 +380,16 @@ static bool FixupMidiData(MidiFile &target) MidiFile::TempoChange &next_tempo = target.tempos[cur_tempo+1]; if (block.ticktime <= next_tempo.ticktime) { /* block is within the current tempo */ - int64 tickdiff = block.ticktime - last_ticktime; + int64_t tickdiff = block.ticktime - last_ticktime; last_ticktime = block.ticktime; - last_realtime += uint32(tickdiff * tempo.tempo / target.tickdiv); + last_realtime += uint32_t(tickdiff * tempo.tempo / target.tickdiv); block.realtime = last_realtime; cur_block++; } else { /* tempo change occurs before this block */ - int64 tickdiff = next_tempo.ticktime - last_ticktime; + int64_t tickdiff = next_tempo.ticktime - last_ticktime; last_ticktime = next_tempo.ticktime; - last_realtime += uint32(tickdiff * tempo.tempo / target.tickdiv); // current tempo until the tempo change + last_realtime += uint32_t(tickdiff * tempo.tempo / target.tickdiv); // current tempo until the tempo change cur_tempo++; } } @@ -507,17 +507,17 @@ struct MpsMachine { struct Channel { byte cur_program; ///< program selected, used for velocity scaling (lookup into programvelocities array) byte running_status; ///< last midi status code seen - uint16 delay; ///< frames until next command - uint32 playpos; ///< next byte to play this channel from - uint32 startpos; ///< start position of master track - uint32 returnpos; ///< next return position after playing a segment + uint16_t delay; ///< frames until next command + uint32_t playpos; ///< next byte to play this channel from + uint32_t startpos; ///< start position of master track + uint32_t returnpos; ///< next return position after playing a segment Channel() : cur_program(0xFF), running_status(0), delay(0), playpos(0), startpos(0), returnpos(0) { } }; Channel channels[16]; ///< playback status for each MIDI channel - std::vector segments; ///< pointers into songdata to repeatable data segments - int16 tempo_ticks; ///< ticker that increments when playing a frame, decrements before playing a frame - int16 current_tempo; ///< threshold for actually playing a frame - int16 initial_tempo; ///< starting tempo of song + std::vector segments; ///< pointers into songdata to repeatable data segments + int16_t tempo_ticks; ///< ticker that increments when playing a frame, decrements before playing a frame + int16_t current_tempo; ///< threshold for actually playing a frame + int16_t initial_tempo; ///< starting tempo of song bool shouldplayflag; ///< not-end-of-song flag static const int TEMPO_RATE; @@ -555,7 +555,7 @@ struct MpsMachine { MpsMachine(const byte *data, size_t length, MidiFile &target) : songdata(data), songdatalen(length), target(target) { - uint32 pos = 0; + uint32_t pos = 0; int loopmax; int loopidx; @@ -570,7 +570,7 @@ struct MpsMachine { * Two bytes between offset to next and start of data * are unaccounted for. */ this->segments.push_back(pos + 4); - pos += FROM_LE16(*(const int16 *)(this->songdata + pos)); + pos += FROM_LE16(*(const int16_t *)(this->songdata + pos)); } /* After segments follows list of master tracks for each channel, @@ -582,7 +582,7 @@ struct MpsMachine { * to next track. */ byte ch = this->songdata[pos++]; this->channels[ch].startpos = pos + 4; - pos += FROM_LE16(*(const int16 *)(this->songdata + pos)); + pos += FROM_LE16(*(const int16_t *)(this->songdata + pos)); } } @@ -591,10 +591,10 @@ struct MpsMachine { * @param pos Position to read from, updated to point to next byte after the value read * @return Value read from data stream */ - uint16 ReadVariableLength(uint32 &pos) + uint16_t ReadVariableLength(uint32_t &pos) { byte b = 0; - uint16 res = 0; + uint16_t res = 0; do { b = this->songdata[pos++]; res = (res << 7) + (b & 0x7F); @@ -624,9 +624,9 @@ struct MpsMachine { /** * Play one frame of data from one channel */ - uint16 PlayChannelFrame(MidiFile::DataBlock &outblock, int channel) + uint16_t PlayChannelFrame(MidiFile::DataBlock &outblock, int channel) { - uint16 newdelay = 0; + uint16_t newdelay = 0; byte b1, b2; Channel &chandata = this->channels[channel]; @@ -677,10 +677,10 @@ struct MpsMachine { b2 = this->songdata[chandata.playpos++]; if (b2 != 0) { /* Note on, read velocity and scale according to rules */ - int16 velocity; + int16_t velocity; if (channel == 9) { /* Percussion channel, fixed velocity scaling not in the table */ - velocity = (int16)b2 * 0x50; + velocity = (int16_t)b2 * 0x50; } else { /* Regular channel, use scaling from table */ velocity = b2 * programvelocities[chandata.cur_program]; @@ -787,7 +787,7 @@ struct MpsMachine { /* Initialize playback simulation */ this->RestartSong(); this->shouldplayflag = true; - this->current_tempo = (int32)this->initial_tempo * 24 / 60; + this->current_tempo = (int32_t)this->initial_tempo * 24 / 60; this->tempo_ticks = this->current_tempo; /* Always reset percussion channel to program 0 */ @@ -797,7 +797,7 @@ struct MpsMachine { /* Technically should be an endless loop, but having * a maximum (about 10 minutes) avoids getting stuck, * in case of corrupted data. */ - for (uint32 tick = 0; tick < 100000; tick+=1) { + for (uint32_t tick = 0; tick < 100000; tick+=1) { this->target.blocks.push_back(MidiFile::DataBlock()); auto &block = this->target.blocks.back(); block.ticktime = tick; @@ -875,7 +875,7 @@ void MidiFile::MoveFrom(MidiFile &other) other.tickdiv = 0; } -static void WriteVariableLen(FILE *f, uint32 value) +static void WriteVariableLen(FILE *f, uint32_t value) { if (value <= 0x7F) { byte tb = value; @@ -933,13 +933,13 @@ bool MidiFile::WriteSMF(const std::string &filename) size_t tracksizepos = ftell(f) - 4; /* Write blocks in sequence */ - uint32 lasttime = 0; + uint32_t lasttime = 0; size_t nexttempoindex = 0; for (size_t bi = 0; bi < this->blocks.size(); bi++) { DataBlock &block = this->blocks[bi]; TempoChange &nexttempo = this->tempos[nexttempoindex]; - uint32 timediff = block.ticktime - lasttime; + uint32_t timediff = block.ticktime - lasttime; /* Check if there is a tempo change before this block */ if (nexttempo.ticktime < block.ticktime) { @@ -1021,7 +1021,7 @@ bool MidiFile::WriteSMF(const std::string &filename) /* Fill out the RIFF block length */ size_t trackendpos = ftell(f); fseek(f, tracksizepos, SEEK_SET); - uint32 tracksize = (uint32)(trackendpos - tracksizepos - 4); // blindly assume we never produce files larger than 2 GB + uint32_t tracksize = (uint32_t)(trackendpos - tracksizepos - 4); // blindly assume we never produce files larger than 2 GB tracksize = TO_BE32(tracksize); fwrite(&tracksize, 4, 1, f); diff --git a/src/music/midifile.hpp b/src/music/midifile.hpp index ccc5a71623..fcbe5abcce 100644 --- a/src/music/midifile.hpp +++ b/src/music/midifile.hpp @@ -17,20 +17,20 @@ struct MusicSongInfo; struct MidiFile { struct DataBlock { - uint32 ticktime; ///< tick number since start of file this block should be triggered at - uint32 realtime; ///< real-time (microseconds) since start of file this block should be triggered at + uint32_t ticktime; ///< tick number since start of file this block should be triggered at + uint32_t realtime; ///< real-time (microseconds) since start of file this block should be triggered at std::vector data; ///< raw midi data contained in block - DataBlock(uint32 _ticktime = 0) : ticktime(_ticktime) { } + DataBlock(uint32_t _ticktime = 0) : ticktime(_ticktime) { } }; struct TempoChange { - uint32 ticktime; ///< tick number since start of file this tempo change occurs at - uint32 tempo; ///< new tempo in microseconds per tick - TempoChange(uint32 _ticktime, uint32 _tempo) : ticktime(_ticktime), tempo(_tempo) { } + uint32_t ticktime; ///< tick number since start of file this tempo change occurs at + uint32_t tempo; ///< new tempo in microseconds per tick + TempoChange(uint32_t _ticktime, uint32_t _tempo) : ticktime(_ticktime), tempo(_tempo) { } }; std::vector blocks; ///< sequential time-annotated data of file, merged to a single track std::vector tempos; ///< list of tempo changes in file - uint16 tickdiv; ///< ticks per quarter note + uint16_t tickdiv; ///< ticks per quarter note MidiFile(); ~MidiFile(); diff --git a/src/music/win32_m.cpp b/src/music/win32_m.cpp index 0f2ee1652a..c72e8a47e3 100644 --- a/src/music/win32_m.cpp +++ b/src/music/win32_m.cpp @@ -23,7 +23,7 @@ #include "../safeguards.h" struct PlaybackSegment { - uint32 start, end; + uint32_t start, end; size_t start_block; bool loop; }; diff --git a/src/network/core/address.cpp b/src/network/core/address.cpp index 478aab3ad0..fdff89544b 100644 --- a/src/network/core/address.cpp +++ b/src/network/core/address.cpp @@ -35,7 +35,7 @@ const std::string &NetworkAddress::GetHostname() * Get the port. * @return the port. */ -uint16 NetworkAddress::GetPort() const +uint16_t NetworkAddress::GetPort() const { switch (this->address.ss_family) { case AF_UNSPEC: @@ -54,7 +54,7 @@ uint16 NetworkAddress::GetPort() const * Set the port. * @param port set the port number. */ -void NetworkAddress::SetPort(uint16 port) +void NetworkAddress::SetPort(uint16_t port) { switch (this->address.ss_family) { case AF_UNSPEC: @@ -77,7 +77,7 @@ void NetworkAddress::SetPort(uint16 port) * @param with_family Whether to add the familty to the address (e.g. IPv4). * @return The format string for the address. */ -static const char *GetAddressFormatString(uint16 family, bool with_family) +static const char *GetAddressFormatString(uint16_t family, bool with_family) { switch (family) { case AF_INET: return with_family ? "{}:{} (IPv4)" : "{}:{}"; @@ -169,17 +169,17 @@ bool NetworkAddress::IsInNetmask(const std::string &netmask) if (mask_address.GetAddressLength() == 0) return false; - uint32 *ip; - uint32 *mask; + uint32_t *ip; + uint32_t *mask; switch (this->address.ss_family) { case AF_INET: - ip = (uint32*)&((struct sockaddr_in*)&this->address)->sin_addr.s_addr; - mask = (uint32*)&((struct sockaddr_in*)&mask_address.address)->sin_addr.s_addr; + ip = (uint32_t*)&((struct sockaddr_in*)&this->address)->sin_addr.s_addr; + mask = (uint32_t*)&((struct sockaddr_in*)&mask_address.address)->sin_addr.s_addr; break; case AF_INET6: - ip = (uint32*)&((struct sockaddr_in6*)&this->address)->sin6_addr; - mask = (uint32*)&((struct sockaddr_in6*)&mask_address.address)->sin6_addr; + ip = (uint32_t*)&((struct sockaddr_in6*)&this->address)->sin6_addr; + mask = (uint32_t*)&((struct sockaddr_in6*)&mask_address.address)->sin6_addr; break; default: @@ -187,7 +187,7 @@ bool NetworkAddress::IsInNetmask(const std::string &netmask) } while (cidr > 0) { - uint32 msk = cidr >= 32 ? (uint32)-1 : htonl(-(1 << (32 - cidr))); + uint32_t msk = cidr >= 32 ? (uint32_t)-1 : htonl(-(1 << (32 - cidr))); if ((*mask++ & msk) != (*ip++ & msk)) return false; cidr -= 32; @@ -448,14 +448,14 @@ void NetworkAddress::Listen(int socktype, SocketList *sockets) * @param company Pointer to the company variable to set iff indicated. * @return A valid ServerAddress of the parsed information. */ -/* static */ ServerAddress ServerAddress::Parse(const std::string &connection_string, uint16 default_port, CompanyID *company_id) +/* static */ ServerAddress ServerAddress::Parse(const std::string &connection_string, uint16_t default_port, CompanyID *company_id) { if (StrStartsWith(connection_string, "+")) { std::string_view invite_code = ParseCompanyFromConnectionString(connection_string, company_id); return ServerAddress(SERVER_ADDRESS_INVITE_CODE, std::string(invite_code)); } - uint16 port = default_port; + uint16_t port = default_port; std::string_view ip = ParseFullConnectionString(connection_string, port, company_id); return ServerAddress(SERVER_ADDRESS_DIRECT, std::string(ip) + ":" + std::to_string(port)); } diff --git a/src/network/core/address.h b/src/network/core/address.h index 3c9088013c..3dbffc6c23 100644 --- a/src/network/core/address.h +++ b/src/network/core/address.h @@ -72,7 +72,7 @@ public: * @param port the port * @param family the address family */ - NetworkAddress(std::string_view hostname = "", uint16 port = 0, int family = AF_UNSPEC) : + NetworkAddress(std::string_view hostname = "", uint16_t port = 0, int family = AF_UNSPEC) : address_length(0), resolved(false) { @@ -102,8 +102,8 @@ public: return this->address_length; } - uint16 GetPort() const; - void SetPort(uint16 port); + uint16_t GetPort() const; + void SetPort(uint16_t port); /** * Check whether the IP address has been resolved already @@ -209,7 +209,7 @@ public: ServerAddressType type; ///< The type of this ServerAddress. std::string connection_string; ///< The connection string for this ServerAddress. - static ServerAddress Parse(const std::string &connection_string, uint16 default_port, CompanyID *company_id = nullptr); + static ServerAddress Parse(const std::string &connection_string, uint16_t default_port, CompanyID *company_id = nullptr); }; #endif /* NETWORK_CORE_ADDRESS_H */ diff --git a/src/network/core/config.h b/src/network/core/config.h index 023b96a044..7657a88d06 100644 --- a/src/network/core/config.h +++ b/src/network/core/config.h @@ -18,15 +18,15 @@ const char *NetworkContentServerConnectionString(); const char *NetworkContentMirrorUriString(); const char *NetworkSurveyUriString(); -static const uint16 NETWORK_COORDINATOR_SERVER_PORT = 3976; ///< The default port of the Game Coordinator server (TCP) -static const uint16 NETWORK_STUN_SERVER_PORT = 3975; ///< The default port of the STUN server (TCP) -static const uint16 NETWORK_TURN_SERVER_PORT = 3974; ///< The default port of the TURN server (TCP) -static const uint16 NETWORK_CONTENT_SERVER_PORT = 3978; ///< The default port of the content server (TCP) -static const uint16 NETWORK_DEFAULT_PORT = 3979; ///< The default port of the game server (TCP & UDP) -static const uint16 NETWORK_ADMIN_PORT = 3977; ///< The default port for admin network -static const uint16 NETWORK_DEFAULT_DEBUGLOG_PORT = 3982; ///< The default port debug-log is sent to (TCP) +static const uint16_t NETWORK_COORDINATOR_SERVER_PORT = 3976; ///< The default port of the Game Coordinator server (TCP) +static const uint16_t NETWORK_STUN_SERVER_PORT = 3975; ///< The default port of the STUN server (TCP) +static const uint16_t NETWORK_TURN_SERVER_PORT = 3974; ///< The default port of the TURN server (TCP) +static const uint16_t NETWORK_CONTENT_SERVER_PORT = 3978; ///< The default port of the content server (TCP) +static const uint16_t NETWORK_DEFAULT_PORT = 3979; ///< The default port of the game server (TCP & UDP) +static const uint16_t NETWORK_ADMIN_PORT = 3977; ///< The default port for admin network +static const uint16_t NETWORK_DEFAULT_DEBUGLOG_PORT = 3982; ///< The default port debug-log is sent to (TCP) -static const uint16 UDP_MTU = 1460; ///< Number of bytes we can pack in a single UDP packet +static const uint16_t UDP_MTU = 1460; ///< Number of bytes we can pack in a single UDP packet static const std::string NETWORK_SURVEY_DETAILS_LINK = "https://survey.openttd.org/participate"; ///< Link with more details & privacy statement of the survey. /* @@ -37,14 +37,14 @@ static const std::string NETWORK_SURVEY_DETAILS_LINK = "https://survey.openttd.o * 00000000 00000000 0bbbbbbb aaaaaaaa -> aaaaaaaa 0bbbbbbb * Send_uint16(GB(size, 0, 15) * - * Packets up to 1 GiB, first uint16 has high bit set so it knows to read a - * next uint16 for the remaining bits of the size. + * Packets up to 1 GiB, first uint16_t has high bit set so it knows to read a + * next uint16_t for the remaining bits of the size. * 00dddddd cccccccc bbbbbbbb aaaaaaaa -> cccccccc 10dddddd aaaaaaaa bbbbbbbb * Send_uint16(GB(size, 16, 14) | 0b10 << 14) * Send_uint16(GB(size, 0, 16)) */ -static const uint16 TCP_MTU = 32767; ///< Number of bytes we can pack in a single TCP packet -static const uint16 COMPAT_MTU = 1460; ///< Number of bytes we can pack in a single packet for backward compatibility +static const uint16_t TCP_MTU = 32767; ///< Number of bytes we can pack in a single TCP packet +static const uint16_t COMPAT_MTU = 1460; ///< Number of bytes we can pack in a single packet for backward compatibility static const byte NETWORK_GAME_ADMIN_VERSION = 3; ///< What version of the admin network do we use? static const byte NETWORK_GAME_INFO_VERSION = 6; ///< What version of game-info do we use? diff --git a/src/network/core/game_info.cpp b/src/network/core/game_info.cpp index 97071d4cc1..bfbfc25716 100644 --- a/src/network/core/game_info.cpp +++ b/src/network/core/game_info.cpp @@ -199,7 +199,7 @@ void SerializeNetworkGameInfo(Packet *p, const NetworkServerGameInfo *info, bool /* NETWORK_GAME_INFO_VERSION = 5 */ GameInfo *game_info = Game::GetInfo(); - p->Send_uint32(game_info == nullptr ? -1 : (uint32)game_info->GetVersion()); + p->Send_uint32(game_info == nullptr ? -1 : (uint32_t)game_info->GetVersion()); p->Send_string(game_info == nullptr ? "" : game_info->GetName()); /* NETWORK_GAME_INFO_VERSION = 4 */ @@ -284,7 +284,7 @@ void DeserializeNetworkGameInfo(Packet *p, NetworkGameInfo *info, const GameInfo /* Ensure that the maximum number of NewGRFs and the field in the network * protocol are matched to eachother. If that is not the case anymore a * check must be added to ensure the received data is still valid. */ - static_assert(std::numeric_limits::max() == NETWORK_MAX_GRF_COUNT); + static_assert(std::numeric_limits::max() == NETWORK_MAX_GRF_COUNT); uint num_grfs = p->Recv_uint8(); GRFConfig **dst = &info->grfconfig; diff --git a/src/network/core/game_info.h b/src/network/core/game_info.h index 6efc23215a..f91efce132 100644 --- a/src/network/core/game_info.h +++ b/src/network/core/game_info.h @@ -94,8 +94,8 @@ struct NetworkServerGameInfo { GRFConfig *grfconfig; ///< List of NewGRF files used TimerGameCalendar::Date start_date; ///< When the game started TimerGameCalendar::Date game_date; ///< Current date - uint16 map_width; ///< Map width - uint16 map_height; ///< Map height + uint16_t map_width; ///< Map width + uint16_t map_height; ///< Map height std::string server_name; ///< Server name std::string server_revision; ///< The version number the server is using (e.g.: 'r304' or 0.5.0) bool dedicated; ///< Is this a dedicated server? @@ -128,7 +128,7 @@ struct NamedGRFIdentifier { std::string name; ///< The name of the NewGRF. }; /** Lookup table for the GameInfo in case of #NST_LOOKUP_ID. */ -typedef std::unordered_map GameInfoNewGRFLookupTable; +typedef std::unordered_map GameInfoNewGRFLookupTable; extern NetworkServerGameInfo _network_game_info; diff --git a/src/network/core/packet.cpp b/src/network/core/packet.cpp index ec0919757f..42de5c2653 100644 --- a/src/network/core/packet.cpp +++ b/src/network/core/packet.cpp @@ -103,13 +103,13 @@ bool Packet::CanWriteToPacket(size_t bytes_to_write) /* * The next couple of functions make sure we can send - * uint8, uint16, uint32 and uint64 endian-safe + * uint8_t, uint16_t, uint32_t and uint64_t endian-safe * over the network. The least significant bytes are * sent first. * * So 0x01234567 would be sent as 67 45 23 01. * - * A bool is sent as a uint8 where zero means false + * A bool is sent as a uint8_t where zero means false * and non-zero means true. */ @@ -126,7 +126,7 @@ void Packet::Send_bool(bool data) * Package a 8 bits integer in the packet. * @param data The data to send. */ -void Packet::Send_uint8(uint8 data) +void Packet::Send_uint8(uint8_t data) { assert(this->CanWriteToPacket(sizeof(data))); this->buffer.emplace_back(data); @@ -136,7 +136,7 @@ void Packet::Send_uint8(uint8 data) * Package a 16 bits integer in the packet. * @param data The data to send. */ -void Packet::Send_uint16(uint16 data) +void Packet::Send_uint16(uint16_t data) { assert(this->CanWriteToPacket(sizeof(data))); this->buffer.emplace_back(GB(data, 0, 8)); @@ -147,7 +147,7 @@ void Packet::Send_uint16(uint16 data) * Package a 32 bits integer in the packet. * @param data The data to send. */ -void Packet::Send_uint32(uint32 data) +void Packet::Send_uint32(uint32_t data) { assert(this->CanWriteToPacket(sizeof(data))); this->buffer.emplace_back(GB(data, 0, 8)); @@ -160,7 +160,7 @@ void Packet::Send_uint32(uint32 data) * Package a 64 bits integer in the packet. * @param data The data to send. */ -void Packet::Send_uint64(uint64 data) +void Packet::Send_uint64(uint64_t data) { assert(this->CanWriteToPacket(sizeof(data))); this->buffer.emplace_back(GB(data, 0, 8)); @@ -191,8 +191,8 @@ void Packet::Send_string(const std::string_view data) */ void Packet::Send_buffer(const std::vector &data) { - assert(this->CanWriteToPacket(sizeof(uint16) + data.size())); - this->Send_uint16((uint16)data.size()); + assert(this->CanWriteToPacket(sizeof(uint16_t) + data.size())); + this->Send_uint16((uint16_t)data.size()); this->buffer.insert(this->buffer.end(), data.begin(), data.end()); } @@ -314,9 +314,9 @@ bool Packet::Recv_bool() * Read a 8 bits integer from the packet. * @return The read data. */ -uint8 Packet::Recv_uint8() +uint8_t Packet::Recv_uint8() { - uint8 n; + uint8_t n; if (!this->CanReadFromPacket(sizeof(n), true)) return 0; @@ -328,14 +328,14 @@ uint8 Packet::Recv_uint8() * Read a 16 bits integer from the packet. * @return The read data. */ -uint16 Packet::Recv_uint16() +uint16_t Packet::Recv_uint16() { - uint16 n; + uint16_t n; if (!this->CanReadFromPacket(sizeof(n), true)) return 0; - n = (uint16)this->buffer[this->pos++]; - n += (uint16)this->buffer[this->pos++] << 8; + n = (uint16_t)this->buffer[this->pos++]; + n += (uint16_t)this->buffer[this->pos++] << 8; return n; } @@ -343,16 +343,16 @@ uint16 Packet::Recv_uint16() * Read a 32 bits integer from the packet. * @return The read data. */ -uint32 Packet::Recv_uint32() +uint32_t Packet::Recv_uint32() { - uint32 n; + uint32_t n; if (!this->CanReadFromPacket(sizeof(n), true)) return 0; - n = (uint32)this->buffer[this->pos++]; - n += (uint32)this->buffer[this->pos++] << 8; - n += (uint32)this->buffer[this->pos++] << 16; - n += (uint32)this->buffer[this->pos++] << 24; + n = (uint32_t)this->buffer[this->pos++]; + n += (uint32_t)this->buffer[this->pos++] << 8; + n += (uint32_t)this->buffer[this->pos++] << 16; + n += (uint32_t)this->buffer[this->pos++] << 24; return n; } @@ -360,20 +360,20 @@ uint32 Packet::Recv_uint32() * Read a 64 bits integer from the packet. * @return The read data. */ -uint64 Packet::Recv_uint64() +uint64_t Packet::Recv_uint64() { - uint64 n; + uint64_t n; if (!this->CanReadFromPacket(sizeof(n), true)) return 0; - n = (uint64)this->buffer[this->pos++]; - n += (uint64)this->buffer[this->pos++] << 8; - n += (uint64)this->buffer[this->pos++] << 16; - n += (uint64)this->buffer[this->pos++] << 24; - n += (uint64)this->buffer[this->pos++] << 32; - n += (uint64)this->buffer[this->pos++] << 40; - n += (uint64)this->buffer[this->pos++] << 48; - n += (uint64)this->buffer[this->pos++] << 56; + n = (uint64_t)this->buffer[this->pos++]; + n += (uint64_t)this->buffer[this->pos++] << 8; + n += (uint64_t)this->buffer[this->pos++] << 16; + n += (uint64_t)this->buffer[this->pos++] << 24; + n += (uint64_t)this->buffer[this->pos++] << 32; + n += (uint64_t)this->buffer[this->pos++] << 40; + n += (uint64_t)this->buffer[this->pos++] << 48; + n += (uint64_t)this->buffer[this->pos++] << 56; return n; } @@ -383,7 +383,7 @@ uint64 Packet::Recv_uint64() */ std::vector Packet::Recv_buffer() { - uint16 size = this->Recv_uint16(); + uint16_t size = this->Recv_uint16(); if (size == 0 || !this->CanReadFromPacket(size, true)) return {}; std::vector data; diff --git a/src/network/core/packet.h b/src/network/core/packet.h index 8056ca00fa..8a1931e971 100644 --- a/src/network/core/packet.h +++ b/src/network/core/packet.h @@ -17,8 +17,8 @@ #include "core.h" #include "../../string_type.h" -typedef uint16 PacketSize; ///< Size of the whole packet. -typedef uint8 PacketType; ///< Identifier for the packet +typedef uint16_t PacketSize; ///< Size of the whole packet. +typedef uint8_t PacketType; ///< Identifier for the packet /** * Internal entity of a packet. As everything is sent as a packet, @@ -65,10 +65,10 @@ public: bool CanWriteToPacket(size_t bytes_to_write); void Send_bool (bool data); - void Send_uint8 (uint8 data); - void Send_uint16(uint16 data); - void Send_uint32(uint32 data); - void Send_uint64(uint64 data); + void Send_uint8 (uint8_t data); + void Send_uint16(uint16_t data); + void Send_uint32(uint32_t data); + void Send_uint64(uint64_t data); void Send_string(const std::string_view data); void Send_buffer(const std::vector &data); size_t Send_bytes (const byte *begin, const byte *end); @@ -82,10 +82,10 @@ public: bool CanReadFromPacket(size_t bytes_to_read, bool close_connection = false); bool Recv_bool (); - uint8 Recv_uint8 (); - uint16 Recv_uint16(); - uint32 Recv_uint32(); - uint64 Recv_uint64(); + uint8_t Recv_uint8 (); + uint16_t Recv_uint16(); + uint32_t Recv_uint32(); + uint64_t Recv_uint64(); std::vector Recv_buffer(); std::string Recv_string(size_t length, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK); diff --git a/src/network/core/tcp.h b/src/network/core/tcp.h index 0a770d30eb..74171ed86c 100644 --- a/src/network/core/tcp.h +++ b/src/network/core/tcp.h @@ -114,7 +114,7 @@ private: public: TCPConnecter() {}; - TCPConnecter(const std::string &connection_string, uint16 default_port, const NetworkAddress &bind_address = {}, int family = AF_UNSPEC); + TCPConnecter(const std::string &connection_string, uint16_t default_port, const NetworkAddress &bind_address = {}, int family = AF_UNSPEC); virtual ~TCPConnecter(); /** @@ -143,7 +143,7 @@ private: public: ServerAddress server_address; ///< Address we are connecting to. - TCPServerConnecter(const std::string &connection_string, uint16 default_port); + TCPServerConnecter(const std::string &connection_string, uint16_t default_port); void SetConnected(SOCKET sock); void SetFailure(); diff --git a/src/network/core/tcp_admin.h b/src/network/core/tcp_admin.h index 971ea46d0f..567a791496 100644 --- a/src/network/core/tcp_admin.h +++ b/src/network/core/tcp_admin.h @@ -136,8 +136,8 @@ protected: /** * Register updates to be sent at certain frequencies (as announced in the PROTOCOL packet): - * uint16 Update type (see #AdminUpdateType). Note integer type - see "Certain Packet Information" in docs/admin_network.md. - * uint16 Update frequency (see #AdminUpdateFrequency), setting #ADMIN_FREQUENCY_POLL is always ignored. + * uint16_t Update type (see #AdminUpdateType). Note integer type - see "Certain Packet Information" in docs/admin_network.md. + * uint16_t Update frequency (see #AdminUpdateFrequency), setting #ADMIN_FREQUENCY_POLL is always ignored. * @param p The packet that was just received. * @return The state the network should have. */ @@ -145,8 +145,8 @@ protected: /** * Poll the server for certain updates, an invalid poll (e.g. not existent id) gets silently dropped: - * uint8 #AdminUpdateType the server should answer for, only if #AdminUpdateFrequency #ADMIN_FREQUENCY_POLL is advertised in the PROTOCOL packet. Note integer type - see "Certain Packet Information" in docs/admin_network.md. - * uint32 ID relevant to the packet type, e.g. + * uint8_t #AdminUpdateType the server should answer for, only if #AdminUpdateFrequency #ADMIN_FREQUENCY_POLL is advertised in the PROTOCOL packet. Note integer type - see "Certain Packet Information" in docs/admin_network.md. + * uint32_t ID relevant to the packet type, e.g. * - the client ID for #ADMIN_UPDATE_CLIENT_INFO. Use UINT32_MAX to show all clients. * - the company ID for #ADMIN_UPDATE_COMPANY_INFO. Use UINT32_MAX to show all companies. * @param p The packet that was just received. @@ -156,9 +156,9 @@ protected: /** * Send chat as the server: - * uint8 Action such as NETWORK_ACTION_CHAT_CLIENT (see #NetworkAction). - * uint8 Destination type such as DESTTYPE_BROADCAST (see #DestType). - * uint32 ID of the destination such as company or client id. + * uint8_t Action such as NETWORK_ACTION_CHAT_CLIENT (see #NetworkAction). + * uint8_t Destination type such as DESTTYPE_BROADCAST (see #DestType). + * uint32_t ID of the destination such as company or client id. * string Message. * @param p The packet that was just received. * @return The state the network should have. @@ -168,7 +168,7 @@ protected: /** * Send chat from the external source: * string Name of the source this message came from. - * uint16 TextColour to use for the message. + * uint16_t TextColour to use for the message. * string Name of the user who sent the messsage. * string Message. * @param p The packet that was just received. @@ -194,7 +194,7 @@ protected: /** * Ping the server, requiring the server to reply with a pong packet. - * uint32 Integer value to pass to the server, which is quoted in the reply. + * uint32_t Integer value to pass to the server, which is quoted in the reply. * @param p The packet that was just received. * @return The state the network should have. */ @@ -216,7 +216,7 @@ protected: /** * An error was caused by this admin connection (connection gets closed). - * uint8 NetworkErrorCode the error caused. + * uint8_t NetworkErrorCode the error caused. * @param p The packet that was just received. * @return The state the network should have. */ @@ -224,10 +224,10 @@ protected: /** * Inform a just joined admin about the protocol specifics: - * uint8 Protocol version. + * uint8_t Protocol version. * bool Further protocol data follows (repeats through all update packet types). - * uint16 Update packet type. - * uint16 Frequencies allowed for this update packet (bitwise). + * uint16_t Update packet type. + * uint16_t Frequencies allowed for this update packet (bitwise). * @param p The packet that was just received. * @return The state the network should have. */ @@ -239,11 +239,11 @@ protected: * string OpenTTD version string. * bool Server is dedicated. * string Name of the Map. - * uint32 Random seed of the Map. - * uint8 Landscape of the Map. - * uint32 Start date of the Map. - * uint16 Map width. - * uint16 Map height. + * uint32_t Random seed of the Map. + * uint8_t Landscape of the Map. + * uint32_t Start date of the Map. + * uint16_t Map width. + * uint16_t Map height. * @param p The packet that was just received. * @return The state the network should have. */ @@ -265,7 +265,7 @@ protected: /** * Send the current date of the game: - * uint32 Current game date. + * uint32_t Current game date. * @param p The packet that was just received. * @return The state the network should have. */ @@ -273,7 +273,7 @@ protected: /** * Notification of a new client: - * uint32 ID of the new client. + * uint32_t ID of the new client. * @param p The packet that was just received. * @return The state the network should have. */ @@ -281,12 +281,12 @@ protected: /** * Client information of a specific client: - * uint32 ID of the client. + * uint32_t ID of the client. * string Network address of the client. * string Name of the client. - * uint8 Language of the client. - * uint32 Date the client joined the game. - * uint8 ID of the company the client is playing as (255 for spectators). + * uint8_t Language of the client. + * uint32_t Date the client joined the game. + * uint8_t ID of the company the client is playing as (255 for spectators). * @param p The packet that was just received. * @return The state the network should have. */ @@ -294,9 +294,9 @@ protected: /** * Client update details on a specific client (e.g. after rename or move): - * uint32 ID of the client. + * uint32_t ID of the client. * string Name of the client. - * uint8 ID of the company the client is playing as (255 for spectators). + * uint8_t ID of the company the client is playing as (255 for spectators). * @param p The packet that was just received. * @return The state the network should have. */ @@ -304,7 +304,7 @@ protected: /** * Notification about a client leaving the game. - * uint32 ID of the client that just left. + * uint32_t ID of the client that just left. * @param p The packet that was just received. * @return The state the network should have. */ @@ -312,8 +312,8 @@ protected: /** * Notification about a client error (and thus the clients disconnection). - * uint32 ID of the client that made the error. - * uint8 Error the client made (see NetworkErrorCode). + * uint32_t ID of the client that made the error. + * uint8_t Error the client made (see NetworkErrorCode). * @param p The packet that was just received. * @return The state the network should have. */ @@ -321,7 +321,7 @@ protected: /** * Notification of a new company: - * uint8 ID of the new company. + * uint8_t ID of the new company. * @param p The packet that was just received. * @return The state the network should have. */ @@ -329,12 +329,12 @@ protected: /** * Company information on a specific company: - * uint8 ID of the company. + * uint8_t ID of the company. * string Name of the company. * string Name of the companies manager. - * uint8 Main company colour. + * uint8_t Main company colour. * bool Company is password protected. - * uint32 Year the company was inaugurated. + * uint32_t Year the company was inaugurated. * bool Company is an AI. * @param p The packet that was just received. * @return The state the network should have. @@ -343,16 +343,16 @@ protected: /** * Company information of a specific company: - * uint8 ID of the company. + * uint8_t ID of the company. * string Name of the company. * string Name of the companies manager. - * uint8 Main company colour. + * uint8_t Main company colour. * bool Company is password protected. - * uint8 Quarters of bankruptcy. - * uint8 Owner of share 1. - * uint8 Owner of share 2. - * uint8 Owner of share 3. - * uint8 Owner of share 4. + * uint8_t Quarters of bankruptcy. + * uint8_t Owner of share 1. + * uint8_t Owner of share 2. + * uint8_t Owner of share 3. + * uint8_t Owner of share 4. * @param p The packet that was just received. * @return The state the network should have. */ @@ -360,8 +360,8 @@ protected: /** * Notification about a removed company (e.g. due to bankruptcy). - * uint8 ID of the company. - * uint8 Reason for being removed (see #AdminCompanyRemoveReason). + * uint8_t ID of the company. + * uint8_t Reason for being removed (see #AdminCompanyRemoveReason). * @param p The packet that was just received. * @return The state the network should have. */ @@ -369,17 +369,17 @@ protected: /** * Economy update of a specific company: - * uint8 ID of the company. - * uint64 Money. - * uint64 Loan. - * int64 Income. - * uint16 Delivered cargo (this quarter). - * uint64 Company value (last quarter). - * uint16 Performance (last quarter). - * uint16 Delivered cargo (last quarter). - * uint64 Company value (previous quarter). - * uint16 Performance (previous quarter). - * uint16 Delivered cargo (previous quarter). + * uint8_t ID of the company. + * uint64_t Money. + * uint64_t Loan. + * int64_t Income. + * uint16_t Delivered cargo (this quarter). + * uint64_t Company value (last quarter). + * uint16_t Performance (last quarter). + * uint16_t Delivered cargo (last quarter). + * uint64_t Company value (previous quarter). + * uint16_t Performance (previous quarter). + * uint16_t Delivered cargo (previous quarter). * @param p The packet that was just received. * @return The state the network should have. */ @@ -387,17 +387,17 @@ protected: /** * Company statistics on stations and vehicles: - * uint8 ID of the company. - * uint16 Number of trains. - * uint16 Number of lorries. - * uint16 Number of busses. - * uint16 Number of planes. - * uint16 Number of ships. - * uint16 Number of train stations. - * uint16 Number of lorry stations. - * uint16 Number of bus stops. - * uint16 Number of airports and heliports. - * uint16 Number of harbours. + * uint8_t ID of the company. + * uint16_t Number of trains. + * uint16_t Number of lorries. + * uint16_t Number of busses. + * uint16_t Number of planes. + * uint16_t Number of ships. + * uint16_t Number of train stations. + * uint16_t Number of lorry stations. + * uint16_t Number of bus stops. + * uint16_t Number of airports and heliports. + * uint16_t Number of harbours. * @param p The packet that was just received. * @return The state the network should have. */ @@ -405,11 +405,11 @@ protected: /** * Send chat from the game into the admin network: - * uint8 Action such as NETWORK_ACTION_CHAT_CLIENT (see #NetworkAction). - * uint8 Destination type such as DESTTYPE_BROADCAST (see #DestType). - * uint32 ID of the client who sent this message. + * uint8_t Action such as NETWORK_ACTION_CHAT_CLIENT (see #NetworkAction). + * uint8_t Destination type such as DESTTYPE_BROADCAST (see #DestType). + * uint32_t ID of the client who sent this message. * string Message. - * uint64 Money (only when it is a 'give money' action). + * uint64_t Money (only when it is a 'give money' action). * @param p The packet that was just received. * @return The state the network should have. */ @@ -417,7 +417,7 @@ protected: /** * Result of an rcon command: - * uint16 Colour as it would be used on the server or a client. + * uint16_t Colour as it would be used on the server or a client. * string Output of the executed command. * @param p The packet that was just received. * @return The state the network should have. @@ -445,7 +445,7 @@ protected: * * These three fields are repeated until the packet is full: * bool Data to follow. - * uint16 ID of the DoCommand. + * uint16_t ID of the DoCommand. * string Name of DoCommand. * @param p The packet that was just received. * @return The state the network should have. @@ -461,12 +461,12 @@ protected: * across different versions / revisions of OpenTTD. * Data provided in this packet is for logging purposes only. * - * uint32 ID of the client sending the command. - * uint8 ID of the company (0..MAX_COMPANIES-1). - * uint16 ID of the command. + * uint32_t ID of the client sending the command. + * uint8_t ID of the company (0..MAX_COMPANIES-1). + * uint16_t ID of the command. * Command specific buffer with encoded parameters of variable length. * The content differs per command and can change without notification. - * uint32 Frame of execution. + * uint32_t Frame of execution. * @param p The packet that was just received. * @return The state the network should have. */ @@ -474,7 +474,7 @@ protected: /** * Send a ping-reply (pong) to the admin that sent us the ping packet. - * uint32 Integer identifier - should be the same as read from the admins ping packet. + * uint32_t Integer identifier - should be the same as read from the admins ping packet. * @param p The packet that was just received. * @return The state the network should have. */ diff --git a/src/network/core/tcp_connect.cpp b/src/network/core/tcp_connect.cpp index b9d033f1e7..446023c50f 100644 --- a/src/network/core/tcp_connect.cpp +++ b/src/network/core/tcp_connect.cpp @@ -27,7 +27,7 @@ static std::vector _tcp_connecters; * @param default_port If not indicated in connection_string, what port to use. * @param bind_address The local bind address to use. Defaults to letting the OS find one. */ -TCPConnecter::TCPConnecter(const std::string &connection_string, uint16 default_port, const NetworkAddress &bind_address, int family) : +TCPConnecter::TCPConnecter(const std::string &connection_string, uint16_t default_port, const NetworkAddress &bind_address, int family) : bind_address(bind_address), family(family) { @@ -41,7 +41,7 @@ TCPConnecter::TCPConnecter(const std::string &connection_string, uint16 default_ * @param connection_string The address to connect to. * @param default_port If not indicated in connection_string, what port to use. */ -TCPServerConnecter::TCPServerConnecter(const std::string &connection_string, uint16 default_port) : +TCPServerConnecter::TCPServerConnecter(const std::string &connection_string, uint16_t default_port) : server_address(ServerAddress::Parse(connection_string, default_port)) { switch (this->server_address.type) { diff --git a/src/network/core/tcp_content.h b/src/network/core/tcp_content.h index 00e58d6f07..05924f05e4 100644 --- a/src/network/core/tcp_content.h +++ b/src/network/core/tcp_content.h @@ -26,9 +26,9 @@ protected: /** * Client requesting a list of content info: * byte type - * uint32 openttd version (or 0xFFFFFFFF if using a list) + * uint32_t openttd version (or 0xFFFFFFFF if using a list) * Only if the above value is 0xFFFFFFFF: - * uint8 count + * uint8_t count * string branch-name ("vanilla" for upstream OpenTTD) * string release version (like "12.0") * @param p The packet that was just received. @@ -38,8 +38,8 @@ protected: /** * Client requesting a list of content info: - * uint16 count of ids - * uint32 id (count times) + * uint16_t count of ids + * uint32_t id (count times) * @param p The packet that was just received. * @return True upon success, otherwise false. */ @@ -50,10 +50,10 @@ protected: * 'unique' id; GRF ID for NewGRFS, shortname and for base * graphics and AIs. * Scenarios and AI libraries are not supported - * uint8 count of requests + * uint8_t count of requests * for each request: - * uint8 type - * unique id (uint32) + * uint8_t type + * unique id (uint32_t) * @param p The packet that was just received. * @return True upon success, otherwise false. */ @@ -64,10 +64,10 @@ protected: * 'unique' id; GRF ID + MD5 checksum for NewGRFS, shortname and * xor-ed MD5 checksums for base graphics and AIs. * Scenarios and AI libraries are not supported - * uint8 count of requests + * uint8_t count of requests * for each request: - * uint8 type - * unique id (uint32) + * uint8_t type + * unique id (uint32_t) * md5 (16 bytes) * @param p The packet that was just received. * @return True upon success, otherwise false. @@ -77,15 +77,15 @@ protected: /** * Server sending list of content info: * byte type (invalid ID == does not exist) - * uint32 id - * uint32 file_size + * uint32_t id + * uint32_t file_size * string name (max 32 characters) * string version (max 16 characters) - * uint32 unique id - * uint8 md5sum (16 bytes) - * uint8 dependency count - * uint32 unique id of dependency (dependency count times) - * uint8 tag count + * uint32_t unique id + * uint8_t md5sum (16 bytes) + * uint8_t dependency count + * uint32_t unique id of dependency (dependency count times) + * uint8_t tag count * string tag (max 32 characters for tag count times) * @param p The packet that was just received. * @return True upon success, otherwise false. @@ -94,8 +94,8 @@ protected: /** * Client requesting the actual content: - * uint16 count of unique ids - * uint32 unique id (count times) + * uint16_t count of unique ids + * uint32_t unique id (count times) * @param p The packet that was just received. * @return True upon success, otherwise false. */ @@ -103,8 +103,8 @@ protected: /** * Server sending list of content info: - * uint32 unique id - * uint32 file size (0 == does not exist) + * uint32_t unique id + * uint32_t file size (0 == does not exist) * string file name (max 48 characters) * After this initial packet, packets with the actual data are send using * the same packet type. diff --git a/src/network/core/tcp_content_type.h b/src/network/core/tcp_content_type.h index 03a5ba8cc6..bc903bf234 100644 --- a/src/network/core/tcp_content_type.h +++ b/src/network/core/tcp_content_type.h @@ -62,13 +62,13 @@ struct ContentInfo { ContentType type = INVALID_CONTENT_TYPE; ///< Type of content ContentID id = INVALID_CONTENT_ID; ///< Unique (server side) ID for the content - uint32 filesize = 0; ///< Size of the file + uint32_t filesize = 0; ///< Size of the file std::string filename; ///< Filename (for the .tar.gz; only valid on download) std::string name; ///< Name of the content std::string version; ///< Version of the content std::string url; ///< URL related to the content std::string description; ///< Description of the content - uint32 unique_id = 0; ///< Unique ID; either GRF ID or shortname + uint32_t unique_id = 0; ///< Unique ID; either GRF ID or shortname MD5Hash md5sum; ///< The MD5 checksum std::vector dependencies; ///< The dependencies (unique server side ids) StringList tags; ///< Tags associated with the content diff --git a/src/network/core/tcp_coordinator.h b/src/network/core/tcp_coordinator.h index 9f2731b7c8..545cdb281d 100644 --- a/src/network/core/tcp_coordinator.h +++ b/src/network/core/tcp_coordinator.h @@ -77,7 +77,7 @@ protected: * permanent error causing the connection to be dropped, or in response * to a request that is invalid. * - * uint8 Type of error (see NetworkCoordinatorErrorType). + * uint8_t Type of error (see NetworkCoordinatorErrorType). * string Details of the error. * * @param p The packet that was just received. @@ -89,9 +89,9 @@ protected: * Server is starting a multiplayer game and wants to let the * Game Coordinator know. * - * uint8 Game Coordinator protocol version. - * uint8 Type of game (see ServerGameType). - * uint16 Local port of the server. + * uint8_t Game Coordinator protocol version. + * uint8_t Type of game (see ServerGameType). + * uint16_t Local port of the server. * string Invite code the server wants to use (can be empty; coordinator will assign a new invite code). * string Secret that belongs to the invite code (empty if invite code is empty). * @@ -105,7 +105,7 @@ protected: * * string Invite code that can be used to join this server. * string Secret that belongs to the invite code (only needed if reusing the invite code on next SERVER_REGISTER). - * uint8 Type of connection was detected (see ConnectionType). + * uint8_t Type of connection was detected (see ConnectionType). * * @param p The packet that was just received. * @return True upon success, otherwise false. @@ -115,7 +115,7 @@ protected: /** * Send an update of the current state of the server to the Game Coordinator. * - * uint8 Game Coordinator protocol version. + * uint8_t Game Coordinator protocol version. * Serialized NetworkGameInfo. See game_info.hpp for details. * * @param p The packet that was just received. @@ -126,10 +126,10 @@ protected: /** * Client requests a list of all public servers. * - * uint8 Game Coordinator protocol version. - * uint8 Game-info version used by this client. + * uint8_t Game Coordinator protocol version. + * uint8_t Game-info version used by this client. * string Revision of the client. - * uint32 (Game Coordinator protocol >= 4) Cursor as received from GC_NEWGRF_LOOKUP, or zero. + * uint32_t (Game Coordinator protocol >= 4) Cursor as received from GC_NEWGRF_LOOKUP, or zero. * * @param p The packet that was just received. * @return True upon success, otherwise false. @@ -141,7 +141,7 @@ protected: * of these packets are received after a request till all servers are * sent over. Last packet will have server count of 0. * - * uint16 Amount of public servers in this packet. + * uint16_t Amount of public servers in this packet. * For each server: * string Connection string for this server. * Serialized NetworkGameInfo. See game_info.hpp for details. @@ -154,7 +154,7 @@ protected: /** * Client wants to connect to a Server. * - * uint8 Game Coordinator protocol version. + * uint8_t Game Coordinator protocol version. * string Invite code of the Server to join. * * @param p The packet that was just received. @@ -177,9 +177,9 @@ protected: /** * Client or Server failed to connect to the remote side. * - * uint8 Game Coordinator protocol version. + * uint8_t Game Coordinator protocol version. * string Token to track the current connect request. - * uint8 Tracking number to track current connect request. + * uint8_t Tracking number to track current connect request. * * @param p The packet that was just received. * @return True upon success, otherwise false. @@ -202,7 +202,7 @@ protected: * Client informs the Game Coordinator the connection with the Server is * established. The Client will disconnect from the Game Coordinator next. * - * uint8 Game Coordinator protocol version. + * uint8_t Game Coordinator protocol version. * string Token to track the current connect request. * * @param p The packet that was just received. @@ -215,9 +215,9 @@ protected: * the indicated peer, which is a Server. * * string Token to track the current connect request. - * uint8 Tracking number to track current connect request. + * uint8_t Tracking number to track current connect request. * string Hostname of the peer. - * uint16 Port of the peer. + * uint16_t Port of the peer. * * @param p The packet that was just received. * @return True upon success, otherwise false. @@ -242,9 +242,9 @@ protected: /** * Client/server informs the Game Coordinator the result of a STUN request. * - * uint8 Game Coordinator protocol version. + * uint8_t Game Coordinator protocol version. * string Token to track the current connect request. - * uint8 Interface number, as given during STUN request. + * uint8_t Interface number, as given during STUN request. * bool Whether the STUN connection was successful. * * @param p The packet that was just received. @@ -258,10 +258,10 @@ protected: * the local address as used with the STUN request. * * string Token to track the current connect request. - * uint8 Tracking number to track current connect request. - * uint8 Interface number, as given during STUN request. + * uint8_t Tracking number to track current connect request. + * uint8_t Interface number, as given during STUN request. * string Host of the peer. - * uint16 Port of the peer. + * uint16_t Port of the peer. * * @param p The packet that was just received. * @return True upon success, otherwise false. @@ -273,10 +273,10 @@ protected: * as used by the NewGRF deserialization in GC_LISTING. * This packet is sent after a CLIENT_LISTING request, but before GC_LISTING. * - * uint32 Lookup table cursor. - * uint16 Number of NewGRFs in the packet, with for each of the NewGRFs: - * uint32 Lookup table index for the NewGRF. - * uint32 Unique NewGRF ID. + * uint32_t Lookup table cursor. + * uint16_t Number of NewGRFs in the packet, with for each of the NewGRFs: + * uint32_t Lookup table index for the NewGRF. + * uint32_t Unique NewGRF ID. * byte[16] MD5 checksum of the NewGRF * string Name of the NewGRF. * @@ -296,7 +296,7 @@ protected: * peer, which is a TURN server. * * string Token to track the current connect request. - * uint8 Tracking number to track current connect request. + * uint8_t Tracking number to track current connect request. * string Ticket to hand over to the TURN server. * string Connection string of the TURN server. * diff --git a/src/network/core/tcp_game.h b/src/network/core/tcp_game.h index e158ac3eb8..86705a0723 100644 --- a/src/network/core/tcp_game.h +++ b/src/network/core/tcp_game.h @@ -176,15 +176,15 @@ protected: * Try to join the server: * string OpenTTD revision (norev000 if no revision). * string Name of the client (max NETWORK_NAME_LENGTH). - * uint8 ID of the company to play as (1..MAX_COMPANIES). - * uint8 ID of the clients Language. + * uint8_t ID of the company to play as (1..MAX_COMPANIES). + * uint8_t ID of the clients Language. * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_CLIENT_JOIN(Packet *p); /** * The client made an error: - * uint8 Error code caused (see NetworkErrorCode). + * uint8_t Error code caused (see NetworkErrorCode). * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_ERROR(Packet *p); @@ -204,8 +204,8 @@ protected: /** * Send information about a client: - * uint32 ID of the client (always unique on a server. 1 = server, 0 is invalid). - * uint8 ID of the company the client is playing as (255 for spectators). + * uint32_t ID of the client (always unique on a server. 1 = server, 0 is invalid). + * uint8_t ID of the company the client is playing as (255 for spectators). * string Name of the client. * @param p The packet that was just received. */ @@ -219,7 +219,7 @@ protected: /** * Indication to the client that the server needs a company password: - * uint32 Generation seed. + * uint32_t Generation seed. * string Network ID of the server. * @param p The packet that was just received. */ @@ -227,7 +227,7 @@ protected: /** * Send a password to the server to authorize: - * uint8 Password type (see NetworkPasswordType). + * uint8_t Password type (see NetworkPasswordType). * string The password. * @param p The packet that was just received. */ @@ -235,7 +235,7 @@ protected: /** * Send a password to the server to authorize - * uint8 Password type (see NetworkPasswordType). + * uint8_t Password type (see NetworkPasswordType). * string The password. * @param p The packet that was just received. */ @@ -243,8 +243,8 @@ protected: /** * The client is joined and ready to receive their map: - * uint32 Own client ID. - * uint32 Generation seed. + * uint32_t Own client ID. + * uint32_t Generation seed. * string Network ID of the server. * @param p The packet that was just received. */ @@ -252,28 +252,28 @@ protected: /** * Request the map from the server. - * uint32 NewGRF version (release versions of OpenTTD only). + * uint32_t NewGRF version (release versions of OpenTTD only). * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_CLIENT_GETMAP(Packet *p); /** * Notification that another client is currently receiving the map: - * uint8 Number of clients waiting in front of you. + * uint8_t Number of clients waiting in front of you. * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_WAIT(Packet *p); /** * Sends that the server will begin with sending the map to the client: - * uint32 Current frame. + * uint32_t Current frame. * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_MAP_BEGIN(Packet *p); /** * Sends the size of the map to the client. - * uint32 Size of the (compressed) map (in bytes). + * uint32_t Size of the (compressed) map (in bytes). * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_MAP_SIZE(Packet *p); @@ -299,79 +299,79 @@ protected: /** * A client joined (PACKET_CLIENT_MAP_OK), what usually directly follows is a PACKET_SERVER_CLIENT_INFO: - * uint32 ID of the client that just joined the game. + * uint32_t ID of the client that just joined the game. * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_JOIN(Packet *p); /** * Sends the current frame counter to the client: - * uint32 Frame counter - * uint32 Frame counter max (how far may the client walk before the server?) - * uint32 General seed 1 (dependent on compile settings, not default). - * uint32 General seed 2 (dependent on compile settings, not default). - * uint8 Random token to validate the client is actually listening (only occasionally present). + * uint32_t Frame counter + * uint32_t Frame counter max (how far may the client walk before the server?) + * uint32_t General seed 1 (dependent on compile settings, not default). + * uint32_t General seed 2 (dependent on compile settings, not default). + * uint8_t Random token to validate the client is actually listening (only occasionally present). * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_FRAME(Packet *p); /** * Sends a sync-check to the client: - * uint32 Frame counter. - * uint32 General seed 1. - * uint32 General seed 2 (dependent on compile settings, not default). + * uint32_t Frame counter. + * uint32_t General seed 1. + * uint32_t General seed 2 (dependent on compile settings, not default). * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_SYNC(Packet *p); /** * Tell the server we are done with this frame: - * uint32 Current frame counter of the client. - * uint8 The random token that the server sent in the PACKET_SERVER_FRAME packet. + * uint32_t Current frame counter of the client. + * uint8_t The random token that the server sent in the PACKET_SERVER_FRAME packet. * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_CLIENT_ACK(Packet *p); /** * Send a DoCommand to the Server: - * uint8 ID of the company (0..MAX_COMPANIES-1). - * uint32 ID of the command (see command.h). + * uint8_t ID of the company (0..MAX_COMPANIES-1). + * uint32_t ID of the command (see command.h). * Command specific buffer with encoded parameters of variable length. * The content differs per command and can change without notification. - * uint8 ID of the callback. + * uint8_t ID of the callback. * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_CLIENT_COMMAND(Packet *p); /** * Sends a DoCommand to the client: - * uint8 ID of the company (0..MAX_COMPANIES-1). - * uint32 ID of the command (see command.h). + * uint8_t ID of the company (0..MAX_COMPANIES-1). + * uint32_t ID of the command (see command.h). * Command specific buffer with encoded parameters of variable length. * The content differs per command and can change without notification. - * uint8 ID of the callback. - * uint32 Frame of execution. + * uint8_t ID of the callback. + * uint32_t Frame of execution. * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_COMMAND(Packet *p); /** * Sends a chat-packet to the server: - * uint8 ID of the action (see NetworkAction). - * uint8 ID of the destination type (see DestType). - * uint32 ID of the client or company (destination of the chat). + * uint8_t ID of the action (see NetworkAction). + * uint8_t ID of the destination type (see DestType). + * uint32_t ID of the client or company (destination of the chat). * string Message (max NETWORK_CHAT_LENGTH). - * uint64 data (used e.g. for 'give money' actions). + * uint64_t data (used e.g. for 'give money' actions). * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_CLIENT_CHAT(Packet *p); /** * Sends a chat-packet to the client: - * uint8 ID of the action (see NetworkAction). - * uint32 ID of the client (origin of the chat). + * uint8_t ID of the action (see NetworkAction). + * uint32_t ID of the client (origin of the chat). * string Message (max NETWORK_CHAT_LENGTH). - * uint64 data (used e.g. for 'give money' actions). + * uint64_t data (used e.g. for 'give money' actions). * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_CHAT(Packet *p); @@ -379,7 +379,7 @@ protected: /** * Sends a chat-packet for external source to the client: * string Name of the source this message came from. - * uint16 TextColour to use for the message. + * uint16_t TextColour to use for the message. * string Name of the user who sent the messsage. * string Message (max NETWORK_CHAT_LENGTH). * @param p The packet that was just received. @@ -408,22 +408,22 @@ protected: /** * The client made an error and is quitting the game. - * uint8 Error of the code caused (see NetworkErrorCode). + * uint8_t Error of the code caused (see NetworkErrorCode). * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_CLIENT_ERROR(Packet *p); /** * Notification that a client left the game: - * uint32 ID of the client. + * uint32_t ID of the client. * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_QUIT(Packet *p); /** * Inform all clients that one client made an error and thus has quit/been disconnected: - * uint32 ID of the client that caused the error. - * uint8 Code of the error caused (see NetworkErrorCode). + * uint32_t ID of the client that caused the error. + * uint8_t Code of the error caused (see NetworkErrorCode). * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_ERROR_QUIT(Packet *p); @@ -442,7 +442,7 @@ protected: /** * Send the result of an issues RCon command back to the client: - * uint16 Colour code. + * uint16_t Colour code. * string Output of the RCon command * @param p The packet that was just received. */ @@ -458,9 +458,9 @@ protected: /** * Sends information about all used GRFs to the client: - * uint8 Amount of GRFs (the following data is repeated this many times, i.e. per GRF data). - * uint32 GRF ID - * 16 * uint8 MD5 checksum of the GRF + * uint8_t Amount of GRFs (the following data is repeated this many times, i.e. per GRF data). + * uint32_t GRF ID + * 16 * uint8_t MD5 checksum of the GRF * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_CHECK_NEWGRFS(Packet *p); @@ -473,15 +473,15 @@ protected: /** * Move a client from one company into another: - * uint32 ID of the client. - * uint8 ID of the new company. + * uint32_t ID of the client. + * uint8_t ID of the new company. * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_MOVE(Packet *p); /** * Request the server to move this client into another company: - * uint8 ID of the company the client wants to join. + * uint8_t ID of the company the client wants to join. * string Password, if the company is password protected. * @param p The packet that was just received. */ @@ -489,15 +489,15 @@ protected: /** * Update the clients knowledge of which company is password protected: - * uint16 Bitwise representation of each company + * uint16_t Bitwise representation of each company * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_COMPANY_UPDATE(Packet *p); /** * Update the clients knowledge of the max settings: - * uint8 Maximum number of companies allowed. - * uint8 Maximum number of spectators allowed. + * uint8_t Maximum number of companies allowed. + * uint8_t Maximum number of spectators allowed. * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_CONFIG_UPDATE(Packet *p); @@ -507,8 +507,8 @@ protected: NetworkGameSocketHandler(SOCKET s); public: ClientID client_id; ///< Client identifier - uint32 last_frame; ///< Last frame we have executed - uint32 last_frame_server; ///< Last frame the server has executed + uint32_t last_frame; ///< Last frame we have executed + uint32_t last_frame_server; ///< Last frame the server has executed CommandQueue incoming_queue; ///< The command-queue awaiting handling std::chrono::steady_clock::time_point last_packet; ///< Time we received the last frame. diff --git a/src/network/core/tcp_listen.h b/src/network/core/tcp_listen.h index 4df240ae6a..508dc8d687 100644 --- a/src/network/core/tcp_listen.h +++ b/src/network/core/tcp_listen.h @@ -140,7 +140,7 @@ public: * @param port The port to listen on. * @return true if listening succeeded. */ - static bool Listen(uint16 port) + static bool Listen(uint16_t port) { assert(sockets.size() == 0); diff --git a/src/network/core/tcp_stun.h b/src/network/core/tcp_stun.h index e96a97ef36..2eca700181 100644 --- a/src/network/core/tcp_stun.h +++ b/src/network/core/tcp_stun.h @@ -31,9 +31,9 @@ protected: * Send a STUN request to the STUN server letting the Game Coordinator know * what our actually public IP:port is. * - * uint8 Game Coordinator protocol version. + * uint8_t Game Coordinator protocol version. * string Token to track the current STUN request. - * uint8 Which interface number this is (for example, IPv4 or IPv6). + * uint8_t Which interface number this is (for example, IPv4 or IPv6). * The Game Coordinator relays this number back in later packets. * * @param p The packet that was just received. diff --git a/src/network/core/tcp_turn.h b/src/network/core/tcp_turn.h index 0823731993..b35d26ad7b 100644 --- a/src/network/core/tcp_turn.h +++ b/src/network/core/tcp_turn.h @@ -44,7 +44,7 @@ protected: * Client or servers wants to connect to the TURN server (on request by * the Game Coordinator). * - * uint8 Game Coordinator protocol version. + * uint8_t Game Coordinator protocol version. * string Token to track the current TURN request. * * @param p The packet that was just received. diff --git a/src/network/network.cpp b/src/network/network.cpp index 9d84107a5e..bad43bc0d5 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -63,20 +63,20 @@ bool _is_network_server; ///< Does this client wants to be a network-server? NetworkCompanyState *_network_company_states = nullptr; ///< Statistics about some companies. ClientID _network_own_client_id; ///< Our client identifier. ClientID _redirect_console_to_client; ///< If not invalid, redirect the console output to a client. -uint8 _network_reconnect; ///< Reconnect timeout +uint8_t _network_reconnect; ///< Reconnect timeout StringList _network_bind_list; ///< The addresses to bind on. StringList _network_host_list; ///< The servers we know. StringList _network_ban_list; ///< The banned clients. -uint32 _frame_counter_server; ///< The frame_counter of the server, if in network-mode -uint32 _frame_counter_max; ///< To where we may go with our clients -uint32 _frame_counter; ///< The current frame. -uint32 _last_sync_frame; ///< Used in the server to store the last time a sync packet was sent to clients. +uint32_t _frame_counter_server; ///< The frame_counter of the server, if in network-mode +uint32_t _frame_counter_max; ///< To where we may go with our clients +uint32_t _frame_counter; ///< The current frame. +uint32_t _last_sync_frame; ///< Used in the server to store the last time a sync packet was sent to clients. NetworkAddressList _broadcast_list; ///< List of broadcast addresses. -uint32 _sync_seed_1; ///< Seed to compare during sync checks. +uint32_t _sync_seed_1; ///< Seed to compare during sync checks. #ifdef NETWORK_SEND_DOUBLE_SEED -uint32 _sync_seed_2; ///< Second part of the seed. +uint32_t _sync_seed_2; ///< Second part of the seed. #endif -uint32 _sync_frame; ///< The frame to perform the sync check. +uint32_t _sync_frame; ///< The frame to perform the sync check. bool _network_first_time; ///< Whether we have finished joining or not. CompanyMask _network_company_passworded; ///< Bitmask of the password status of all companies. @@ -173,7 +173,7 @@ std::string NetworkChangeCompanyPassword(CompanyID company_id, std::string passw * @param password_game_seed Game seed. * @return The hashed password. */ -std::string GenerateCompanyPasswordHash(const std::string &password, const std::string &password_server_id, uint32 password_game_seed) +std::string GenerateCompanyPasswordHash(const std::string &password, const std::string &password_server_id, uint32_t password_game_seed) { if (password.empty()) return password; @@ -213,7 +213,7 @@ bool NetworkCompanyIsPassworded(CompanyID company_id) /* This puts a text-message to the console, or in the future, the chat-box, * (to keep it all a bit more general) * If 'self_send' is true, this is the client who is sending the message */ -void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const std::string &name, const std::string &str, int64 data, const std::string &data_str) +void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const std::string &name, const std::string &str, int64_t data, const std::string &data_str) { StringID strid; switch (action) { @@ -466,7 +466,7 @@ std::string_view ParseCompanyFromConnectionString(const std::string &connection_ std::string_view company_string = ip.substr(offset + 1); ip = ip.substr(0, offset); - uint8 company_value; + uint8_t company_value; auto [_, err] = std::from_chars(company_string.data(), company_string.data() + company_string.size(), company_value); if (err == std::errc()) { if (company_value != COMPANY_NEW_COMPANY && company_value != COMPANY_SPECTATOR) { @@ -500,7 +500,7 @@ std::string_view ParseCompanyFromConnectionString(const std::string &connection_ * @param company_id The company ID to set, if available. * @return A std::string_view into the connection string with the (IP) address part. */ -std::string_view ParseFullConnectionString(const std::string &connection_string, uint16 &port, CompanyID *company_id) +std::string_view ParseFullConnectionString(const std::string &connection_string, uint16_t &port, CompanyID *company_id) { std::string_view ip = ParseCompanyFromConnectionString(connection_string, company_id); @@ -520,9 +520,9 @@ std::string_view ParseFullConnectionString(const std::string &connection_string, * @param default_port The port to use if none is given. * @return The normalized connection string. */ -std::string NormalizeConnectionString(const std::string &connection_string, uint16 default_port) +std::string NormalizeConnectionString(const std::string &connection_string, uint16_t default_port) { - uint16 port = default_port; + uint16_t port = default_port; std::string_view ip = ParseFullConnectionString(connection_string, port); return std::string(ip) + ":" + std::to_string(port); } @@ -535,9 +535,9 @@ std::string NormalizeConnectionString(const std::string &connection_string, uint * @param default_port The default port to set port to if not in connection_string. * @return A valid NetworkAddress of the parsed information. */ -NetworkAddress ParseConnectionString(const std::string &connection_string, uint16 default_port) +NetworkAddress ParseConnectionString(const std::string &connection_string, uint16_t default_port) { - uint16 port = default_port; + uint16_t port = default_port; std::string_view ip = ParseFullConnectionString(connection_string, port); return NetworkAddress(ip, port); } @@ -695,7 +695,7 @@ NetworkGameList *NetworkAddServer(const std::string &connection_string, bool man * @param addresses the list to write to. * @param port the port to bind to. */ -void GetBindAddresses(NetworkAddressList *addresses, uint16 port) +void GetBindAddresses(NetworkAddressList *addresses, uint16_t port) { for (const auto &iter : _network_bind_list) { addresses->emplace_back(iter.c_str(), port); @@ -1056,10 +1056,10 @@ void NetworkGameLoop() /* Loading of the debug commands from -ddesync>=1 */ static FILE *f = FioFOpenFile("commands.log", "rb", SAVE_DIR); static Date next_date = 0; - static uint32 next_date_fract; + static uint32_t next_date_fract; static CommandPacket *cp = nullptr; static bool check_sync_state = false; - static uint32 sync_state[2]; + static uint32_t sync_state[2]; if (f == nullptr && next_date == 0) { Debug(desync, 0, "Cannot open commands.log"); next_date = 1; diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp index a016ad4430..f92ec0920a 100644 --- a/src/network/network_admin.cpp +++ b/src/network/network_admin.cpp @@ -396,13 +396,13 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyEconomy() p->Send_uint64(company->money); p->Send_uint64(company->current_loan); p->Send_uint64(income); - p->Send_uint16(static_cast(std::min(UINT16_MAX, company->cur_economy.delivered_cargo.GetSum()))); + p->Send_uint16(static_cast(std::min(UINT16_MAX, company->cur_economy.delivered_cargo.GetSum()))); /* Send stats for the last 2 quarters. */ for (uint i = 0; i < 2; i++) { p->Send_uint64(company->old_economy[i].company_value); p->Send_uint16(company->old_economy[i].performance_history); - p->Send_uint16(static_cast(std::min(UINT16_MAX, company->old_economy[i].delivered_cargo.GetSum()))); + p->Send_uint16(static_cast(std::min(UINT16_MAX, company->old_economy[i].delivered_cargo.GetSum()))); } this->SendPacket(p); @@ -448,7 +448,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCompanyStats() * @param msg The actual message. * @param data Arbitrary extra data. */ -NetworkRecvStatus ServerNetworkAdminSocketHandler::SendChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64 data) +NetworkRecvStatus ServerNetworkAdminSocketHandler::SendChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data) { Packet *p = new Packet(ADMIN_PACKET_SERVER_CHAT); @@ -481,7 +481,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendRconEnd(const std::string * @param colour The colour of the text. * @param result The result of the command. */ -NetworkRecvStatus ServerNetworkAdminSocketHandler::SendRcon(uint16 colour, const std::string_view result) +NetworkRecvStatus ServerNetworkAdminSocketHandler::SendRcon(uint16_t colour, const std::string_view result) { Packet *p = new Packet(ADMIN_PACKET_SERVER_RCON); @@ -522,7 +522,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_PING(Packet *p) { if (this->status == ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED); - uint32 d1 = p->Recv_uint32(); + uint32_t d1 = p->Recv_uint32(); Debug(net, 6, "[admin] Ping from '{}' ({}): {}", this->admin_name, this->admin_version, d1); @@ -571,7 +571,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendGameScript(const std::str } /** Send ping-reply (pong) to admin **/ -NetworkRecvStatus ServerNetworkAdminSocketHandler::SendPong(uint32 d1) +NetworkRecvStatus ServerNetworkAdminSocketHandler::SendPong(uint32_t d1) { Packet *p = new Packet(ADMIN_PACKET_SERVER_PONG); @@ -586,11 +586,11 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCmdNames() { Packet *p = new Packet(ADMIN_PACKET_SERVER_CMD_NAMES); - for (uint16 i = 0; i < CMD_END; i++) { + for (uint16_t i = 0; i < CMD_END; i++) { const char *cmdname = GetCommandName(static_cast(i)); /* Should COMPAT_MTU be exceeded, start a new packet - * (magic 5: 1 bool "more data" and one uint16 "command id", one + * (magic 5: 1 bool "more data" and one uint16_t "command id", one * byte for string '\0' termination and 1 bool "no more data" */ if (!p->CanWriteToPacket(strlen(cmdname) + 5)) { p->Send_bool(false); @@ -693,7 +693,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_POLL(Packet *p) if (this->status == ADMIN_STATUS_INACTIVE) return this->SendError(NETWORK_ERROR_NOT_EXPECTED); AdminUpdateType type = (AdminUpdateType)p->Recv_uint8(); - uint32 d1 = p->Recv_uint32(); + uint32_t d1 = p->Recv_uint32(); switch (type) { case ADMIN_UPDATE_DATE: @@ -790,7 +790,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_EXTERNAL_CHAT(P std::string msg = p->Recv_string(NETWORK_CHAT_LENGTH); if (!IsValidConsoleColour(colour)) { - Debug(net, 1, "[admin] Not supported chat colour {} ({}, {}, {}) from '{}' ({}).", (uint16)colour, source, user, msg, this->admin_name, this->admin_version); + Debug(net, 1, "[admin] Not supported chat colour {} ({}, {}, {}) from '{}' ({}).", (uint16_t)colour, source, user, msg, this->admin_name, this->admin_version); return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET); } @@ -913,7 +913,7 @@ void NetworkAdminCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bc /** * Send chat to the admin network (if they did opt in for the respective update). */ -void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64 data, bool from_admin) +void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data, bool from_admin) { if (from_admin) return; diff --git a/src/network/network_admin.h b/src/network/network_admin.h index 6739f83374..0d39a313df 100644 --- a/src/network/network_admin.h +++ b/src/network/network_admin.h @@ -35,7 +35,7 @@ protected: NetworkRecvStatus Receive_ADMIN_PING(Packet *p) override; NetworkRecvStatus SendProtocol(); - NetworkRecvStatus SendPong(uint32 d1); + NetworkRecvStatus SendPong(uint32_t d1); public: AdminUpdateFrequency update_frequency[ADMIN_UPDATE_END]; ///< Admin requested update intervals. std::chrono::steady_clock::time_point connect_time; ///< Time of connection. @@ -62,8 +62,8 @@ public: NetworkRecvStatus SendCompanyEconomy(); NetworkRecvStatus SendCompanyStats(); - NetworkRecvStatus SendChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64 data); - NetworkRecvStatus SendRcon(uint16 colour, const std::string_view command); + NetworkRecvStatus SendChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data); + NetworkRecvStatus SendRcon(uint16_t colour, const std::string_view command); NetworkRecvStatus SendConsole(const std::string_view origin, const std::string_view command); NetworkRecvStatus SendGameScript(const std::string_view json); NetworkRecvStatus SendCmdNames(); @@ -107,7 +107,7 @@ void NetworkAdminCompanyInfo(const Company *company, bool new_company); void NetworkAdminCompanyUpdate(const Company *company); void NetworkAdminCompanyRemove(CompanyID company_id, AdminCompanyRemoveReason bcrr); -void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64 data = 0, bool from_admin = false); +void NetworkAdminChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, int64_t data = 0, bool from_admin = false); void NetworkAdminUpdate(AdminUpdateFrequency freq); void NetworkServerSendAdminRcon(AdminIndex admin_index, TextColour colour_code, const std::string_view string); void NetworkAdminConsole(const std::string_view origin, const std::string_view string); diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index ca196a4d2b..c9f0835c62 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -58,7 +58,7 @@ static std::chrono::steady_clock::time_point _chatmessage_dirty_time; * the left and pixels from the bottom. The height is the maximum height. */ static PointDimension _chatmsg_box; -static uint8 *_chatmessage_backup = nullptr; ///< Backup in case text is moved. +static uint8_t *_chatmessage_backup = nullptr; ///< Backup in case text is moved. /** * Test if there are any chat messages to display. @@ -436,7 +436,7 @@ struct NetworkChatWindow : public Window { } } - Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override + Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override { Point pt = { 0, _screen.height - sm_height - FindWindowById(WC_STATUS_BAR, 0)->height }; return pt; @@ -464,7 +464,7 @@ struct NetworkChatWindow : public Window { } } - EventState OnKeyPress(WChar key, uint16 keycode) override + EventState OnKeyPress(char32_t key, uint16_t keycode) override { EventState state = ES_NOT_HANDLED; if (keycode == WKC_TAB) { diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index 6464e714a3..41d0f9376f 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -310,15 +310,15 @@ void ClientNetworkGameSocketHandler::ClientError(NetworkRecvStatus res) ClientNetworkGameSocketHandler * ClientNetworkGameSocketHandler::my_client = nullptr; /** Last frame we performed an ack. */ -static uint32 last_ack_frame; +static uint32_t last_ack_frame; /** One bit of 'entropy' used to generate a salt for the company passwords. */ -static uint32 _password_game_seed; +static uint32_t _password_game_seed; /** The other bit of 'entropy' used to generate a salt for the company passwords. */ static std::string _password_server_id; /** Maximum number of companies of the currently joined server. */ -static uint8 _network_server_max_companies; +static uint8_t _network_server_max_companies; /** The current name of the server you are on. */ std::string _network_server_name; @@ -427,7 +427,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendCommand(const CommandPacke } /** Send a chat-packet over the network */ -NetworkRecvStatus ClientNetworkGameSocketHandler::SendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64 data) +NetworkRecvStatus ClientNetworkGameSocketHandler::SendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64_t data) { Packet *p = new Packet(PACKET_CLIENT_CHAT); @@ -783,7 +783,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DATA(Packet /* We are still receiving data, put it to the file */ this->savegame->AddPacket(p); - _network_join_bytes = (uint32)this->savegame->written_bytes; + _network_join_bytes = (uint32_t)this->savegame->written_bytes; SetWindowDirty(WC_NETWORK_STATUS_WINDOW, WN_NETWORK_STATUS_WINDOW_JOIN); return NETWORK_RECV_STATUS_OKAY; @@ -857,9 +857,9 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_FRAME(Packet *p /* Test if the server supports this option * and if we are at the frame the server is */ #ifdef NETWORK_SEND_DOUBLE_SEED - if (p->CanReadFromPacket(sizeof(uint32) + sizeof(uint32))) { + if (p->CanReadFromPacket(sizeof(uint32_t) + sizeof(uint32_t))) { #else - if (p->CanReadFromPacket(sizeof(uint32))) { + if (p->CanReadFromPacket(sizeof(uint32_t))) { #endif _sync_frame = _frame_counter_server; _sync_seed_1 = p->Recv_uint32(); @@ -869,7 +869,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_FRAME(Packet *p } #endif /* Receive the token. */ - if (p->CanReadFromPacket(sizeof(uint8))) this->token = p->Recv_uint8(); + if (p->CanReadFromPacket(sizeof(uint8_t))) this->token = p->Recv_uint8(); Debug(net, 7, "Received FRAME {}", _frame_counter_server); @@ -927,7 +927,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CHAT(Packet *p) ClientID client_id = (ClientID)p->Recv_uint32(); bool self_send = p->Recv_bool(); std::string msg = p->Recv_string(NETWORK_CHAT_LENGTH); - int64 data = p->Recv_uint64(); + int64_t data = p->Recv_uint64(); ci_to = NetworkClientInfo::GetByClientID(client_id); if (ci_to == nullptr) return NETWORK_RECV_STATUS_OKAY; @@ -1121,7 +1121,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_COMPANY_UPDATE( { if (this->status < STATUS_ACTIVE) return NETWORK_RECV_STATUS_MALFORMED_PACKET; - static_assert(sizeof(_network_company_passworded) <= sizeof(uint16)); + static_assert(sizeof(_network_company_passworded) <= sizeof(uint16_t)); _network_company_passworded = p->Recv_uint16(); SetWindowClassesDirty(WC_COMPANY); @@ -1291,7 +1291,7 @@ void NetworkUpdateClientName(const std::string &client_name) * @param msg The actual message. * @param data Arbitrary extra data. */ -void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64 data) +void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64_t data) { MyClient::SendChat(action, type, dest, msg, data); } diff --git a/src/network/network_client.h b/src/network/network_client.h index 9a3c854915..42caac9289 100644 --- a/src/network/network_client.h +++ b/src/network/network_client.h @@ -88,7 +88,7 @@ public: static NetworkRecvStatus SendGamePassword(const std::string &password); static NetworkRecvStatus SendCompanyPassword(const std::string &password); - static NetworkRecvStatus SendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64 data); + static NetworkRecvStatus SendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64_t data); static NetworkRecvStatus SendSetPassword(const std::string &password); static NetworkRecvStatus SendSetName(const std::string &name); static NetworkRecvStatus SendRCon(const std::string &password, const std::string &command); diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp index 27477ea9a4..b5dc3e6b6a 100644 --- a/src/network/network_command.cpp +++ b/src/network/network_command.cpp @@ -457,7 +457,7 @@ void NetworkGameSocketHandler::SendCommand(Packet *p, const CommandPacket *cp) Debug(net, 0, "Unknown callback for command; no callback sent (command: {})", cp->cmd); callback = 0; // _callback_table[0] == nullptr } - p->Send_uint8 ((uint8)callback); + p->Send_uint8 ((uint8_t)callback); } /** Helper to process a single ClientID argument. */ diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index e30bbbff98..cb0561369b 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -236,9 +236,9 @@ void ClientNetworkContentSocketHandler::RequestContentList(uint count, const Con while (count > 0) { /* We can "only" send a limited number of IDs in a single packet. * A packet begins with the packet size and a byte for the type. - * Then this packet adds a uint16 for the count in this packet. + * Then this packet adds a uint16_t for the count in this packet. * The rest of the packet can be used for the IDs. */ - uint p_count = std::min(count, (TCP_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint16)) / sizeof(uint32)); + uint p_count = std::min(count, (TCP_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint16_t)) / sizeof(uint32_t)); Packet *p = new Packet(PACKET_CONTENT_CLIENT_INFO_ID, TCP_MTU); p->Send_uint16(p_count); @@ -265,11 +265,11 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo this->Connect(); assert(cv->size() < 255); - assert(cv->size() < (TCP_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) / - (sizeof(uint8) + sizeof(uint32) + (send_md5sum ? MD5_HASH_BYTES : 0))); + assert(cv->size() < (TCP_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8_t)) / + (sizeof(uint8_t) + sizeof(uint32_t) + (send_md5sum ? MD5_HASH_BYTES : 0))); Packet *p = new Packet(send_md5sum ? PACKET_CONTENT_CLIENT_INFO_EXTID_MD5 : PACKET_CONTENT_CLIENT_INFO_EXTID, TCP_MTU); - p->Send_uint8((uint8)cv->size()); + p->Send_uint8((uint8_t)cv->size()); for (const ContentInfo *ci : *cv) { p->Send_uint8((byte)ci->type); @@ -361,9 +361,9 @@ void ClientNetworkContentSocketHandler::DownloadSelectedContentFallback(const Co while (count > 0) { /* We can "only" send a limited number of IDs in a single packet. * A packet begins with the packet size and a byte for the type. - * Then this packet adds a uint16 for the count in this packet. + * Then this packet adds a uint16_t for the count in this packet. * The rest of the packet can be used for the IDs. */ - uint p_count = std::min(count, (TCP_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint16)) / sizeof(uint32)); + uint p_count = std::min(count, (TCP_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint16_t)) / sizeof(uint32_t)); Packet *p = new Packet(PACKET_CONTENT_CLIENT_CONTENT, TCP_MTU); p->Send_uint16(p_count); diff --git a/src/network/network_content.h b/src/network/network_content.h index 3172564a7c..d329dd90f0 100644 --- a/src/network/network_content.h +++ b/src/network/network_content.h @@ -136,7 +136,7 @@ public: /** Get the begin of the content inf iterator. */ ConstContentIterator Begin() const { return this->infos.data(); } /** Get the nth position of the content inf iterator. */ - ConstContentIterator Get(uint32 index) const { return this->infos.data() + index; } + ConstContentIterator Get(uint32_t index) const { return this->infos.data() + index; } /** Get the end of the content inf iterator. */ ConstContentIterator End() const { return this->Begin() + this->Length(); } diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index 7f48a7b581..4b752c62f7 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -140,7 +140,7 @@ void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, int widge /* Draw the % complete with a bar and a text */ DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY | FR_LOWERED); Rect ir = r.Shrink(WidgetDimensions::scaled.bevel); - DrawFrameRect(ir.WithWidth((uint64)ir.Width() * this->downloaded_bytes / this->total_bytes, false), COLOUR_MAUVE, FR_NONE); + DrawFrameRect(ir.WithWidth((uint64_t)ir.Width() * this->downloaded_bytes / this->total_bytes, false), COLOUR_MAUVE, FR_NONE); SetDParam(0, this->downloaded_bytes); SetDParam(1, this->total_bytes); SetDParam(2, this->downloaded_bytes * 100LL / this->total_bytes); @@ -873,7 +873,7 @@ public: } } - EventState OnKeyPress(WChar key, uint16 keycode) override + EventState OnKeyPress(char32_t key, uint16_t keycode) override { if (this->vscroll->UpdateListPositionOnKeyPress(this->list_pos, keycode) == ES_NOT_HANDLED) { switch (keycode) { diff --git a/src/network/network_content_gui.h b/src/network/network_content_gui.h index 570f15462f..adf074e794 100644 --- a/src/network/network_content_gui.h +++ b/src/network/network_content_gui.h @@ -22,7 +22,7 @@ protected: uint total_files; ///< Number of files to download uint downloaded_files; ///< Number of files downloaded - uint32 cur_id; ///< The current ID of the downloaded file + uint32_t cur_id; ///< The current ID of the downloaded file std::string name; ///< The current name of the downloaded file public: diff --git a/src/network/network_coordinator.cpp b/src/network/network_coordinator.cpp index a52ac638ea..7d4b81b931 100644 --- a/src/network/network_coordinator.cpp +++ b/src/network/network_coordinator.cpp @@ -35,7 +35,7 @@ std::string _network_server_invite_code = ""; ///< Our invite code as indicated class NetworkDirectConnecter : public TCPConnecter { private: std::string token; ///< Token of this connection. - uint8 tracking_number; ///< Tracking number of this connection. + uint8_t tracking_number; ///< Tracking number of this connection. public: /** @@ -45,7 +45,7 @@ public: * @param token The token as given by the Game Coordinator to track this connection attempt. * @param tracking_number The tracking number as given by the Game Coordinator to track this connection attempt. */ - NetworkDirectConnecter(const std::string &hostname, uint16 port, const std::string &token, uint8 tracking_number) : TCPConnecter(hostname, port), token(token), tracking_number(tracking_number) {} + NetworkDirectConnecter(const std::string &hostname, uint16_t port, const std::string &token, uint8_t tracking_number) : TCPConnecter(hostname, port), token(token), tracking_number(tracking_number) {} void OnFailure() override { @@ -63,8 +63,8 @@ public: class NetworkReuseStunConnecter : public TCPConnecter { private: std::string token; ///< Token of this connection. - uint8 tracking_number; ///< Tracking number of this connection. - uint8 family; ///< Family of this connection. + uint8_t tracking_number; ///< Tracking number of this connection. + uint8_t family; ///< Family of this connection. public: /** @@ -76,7 +76,7 @@ public: * @param tracking_number The tracking number of the connection. * @param family The family this connection is using. */ - NetworkReuseStunConnecter(const std::string &hostname, uint16 port, const NetworkAddress &bind_address, std::string token, uint8 tracking_number, uint8 family) : + NetworkReuseStunConnecter(const std::string &hostname, uint16_t port, const NetworkAddress &bind_address, std::string token, uint8_t tracking_number, uint8_t family) : TCPConnecter(hostname, port, bind_address), token(token), tracking_number(tracking_number), @@ -232,7 +232,7 @@ bool ClientNetworkCoordinatorSocketHandler::Receive_GC_REGISTER_ACK(Packet *p) bool ClientNetworkCoordinatorSocketHandler::Receive_GC_LISTING(Packet *p) { - uint8 servers = p->Recv_uint16(); + uint8_t servers = p->Recv_uint16(); /* End of list; we can now remove all expired items from the list. */ if (servers == 0) { @@ -296,9 +296,9 @@ bool ClientNetworkCoordinatorSocketHandler::Receive_GC_CONNECT_FAILED(Packet *p) bool ClientNetworkCoordinatorSocketHandler::Receive_GC_DIRECT_CONNECT(Packet *p) { std::string token = p->Recv_string(NETWORK_TOKEN_LENGTH); - uint8 tracking_number = p->Recv_uint8(); + uint8_t tracking_number = p->Recv_uint8(); std::string hostname = p->Recv_string(NETWORK_HOSTNAME_LENGTH); - uint16 port = p->Recv_uint16(); + uint16_t port = p->Recv_uint16(); /* Ensure all other pending connection attempts are killed. */ if (this->game_connecter != nullptr) { @@ -322,10 +322,10 @@ bool ClientNetworkCoordinatorSocketHandler::Receive_GC_STUN_REQUEST(Packet *p) bool ClientNetworkCoordinatorSocketHandler::Receive_GC_STUN_CONNECT(Packet *p) { std::string token = p->Recv_string(NETWORK_TOKEN_LENGTH); - uint8 tracking_number = p->Recv_uint8(); - uint8 family = p->Recv_uint8(); + uint8_t tracking_number = p->Recv_uint8(); + uint8_t family = p->Recv_uint8(); std::string host = p->Recv_string(NETWORK_HOSTNAME_PORT_LENGTH); - uint16 port = p->Recv_uint16(); + uint16_t port = p->Recv_uint16(); /* Check if we know this token. */ auto stun_it = this->stun_handlers.find(token); @@ -357,9 +357,9 @@ bool ClientNetworkCoordinatorSocketHandler::Receive_GC_NEWGRF_LOOKUP(Packet *p) { this->newgrf_lookup_table_cursor = p->Recv_uint32(); - uint16 newgrfs = p->Recv_uint16(); + uint16_t newgrfs = p->Recv_uint16(); for (; newgrfs> 0; newgrfs--) { - uint32 index = p->Recv_uint32(); + uint32_t index = p->Recv_uint32(); DeserializeGRFIdentifierWithName(p, &this->newgrf_lookup_table[index]); } return true; @@ -368,7 +368,7 @@ bool ClientNetworkCoordinatorSocketHandler::Receive_GC_NEWGRF_LOOKUP(Packet *p) bool ClientNetworkCoordinatorSocketHandler::Receive_GC_TURN_CONNECT(Packet *p) { std::string token = p->Recv_string(NETWORK_TOKEN_LENGTH); - uint8 tracking_number = p->Recv_uint8(); + uint8_t tracking_number = p->Recv_uint8(); std::string ticket = p->Recv_string(NETWORK_TOKEN_LENGTH); std::string connection_string = p->Recv_string(NETWORK_HOSTNAME_PORT_LENGTH); @@ -542,7 +542,7 @@ void ClientNetworkCoordinatorSocketHandler::ConnectToServer(const std::string &i * @param token Token of the connecter that failed. * @param tracking_number Tracking number of the connecter that failed. */ -void ClientNetworkCoordinatorSocketHandler::ConnectFailure(const std::string &token, uint8 tracking_number) +void ClientNetworkCoordinatorSocketHandler::ConnectFailure(const std::string &token, uint8_t tracking_number) { /* Connecter will destroy itself. */ this->game_connecter = nullptr; @@ -604,7 +604,7 @@ void ClientNetworkCoordinatorSocketHandler::ConnectSuccess(const std::string &to * This helps the Game Coordinator not to wait for a timeout on its end, but * rather react as soon as the client/server knows the result. */ -void ClientNetworkCoordinatorSocketHandler::StunResult(const std::string &token, uint8 family, bool result) +void ClientNetworkCoordinatorSocketHandler::StunResult(const std::string &token, uint8_t family, bool result) { Packet *p = new Packet(PACKET_COORDINATOR_SERCLI_STUN_RESULT); p->Send_uint8(NETWORK_COORDINATOR_VERSION); @@ -619,7 +619,7 @@ void ClientNetworkCoordinatorSocketHandler::StunResult(const std::string &token, * @param token The token used for the STUN handlers. * @param family The family of STUN handlers to close. AF_UNSPEC to close all STUN handlers for this token. */ -void ClientNetworkCoordinatorSocketHandler::CloseStunHandler(const std::string &token, uint8 family) +void ClientNetworkCoordinatorSocketHandler::CloseStunHandler(const std::string &token, uint8_t family) { auto stun_it = this->stun_handlers.find(token); if (stun_it == this->stun_handlers.end()) return; diff --git a/src/network/network_coordinator.h b/src/network/network_coordinator.h index 453ee938c5..71fc599457 100644 --- a/src/network/network_coordinator.h +++ b/src/network/network_coordinator.h @@ -59,7 +59,7 @@ private: std::map> turn_handlers; ///< Pending TURN handler (if any), stored by token. TCPConnecter *game_connecter = nullptr; ///< Pending connecter to the game server. - uint32 newgrf_lookup_table_cursor = 0; ///< Last received cursor for the #GameInfoNewGRFLookupTable updates. + uint32_t newgrf_lookup_table_cursor = 0; ///< Last received cursor for the #GameInfoNewGRFLookupTable updates. GameInfoNewGRFLookupTable newgrf_lookup_table; ///< Table to look up NewGRFs in the GC_LISTING packets. protected: @@ -86,14 +86,14 @@ public: NetworkRecvStatus CloseConnection(bool error = true) override; void SendReceive(); - void ConnectFailure(const std::string &token, uint8 tracking_number); + void ConnectFailure(const std::string &token, uint8_t tracking_number); void ConnectSuccess(const std::string &token, SOCKET sock, NetworkAddress &address); - void StunResult(const std::string &token, uint8 family, bool result); + void StunResult(const std::string &token, uint8_t family, bool result); void Connect(); void CloseToken(const std::string &token); void CloseAllConnections(); - void CloseStunHandler(const std::string &token, uint8 family = AF_UNSPEC); + void CloseStunHandler(const std::string &token, uint8_t family = AF_UNSPEC); void CloseTurnHandler(const std::string &token); void Register(); diff --git a/src/network/network_func.h b/src/network/network_func.h index 73050737ea..9531e6d0fb 100644 --- a/src/network/network_func.h +++ b/src/network/network_func.h @@ -28,7 +28,7 @@ extern NetworkCompanyState *_network_company_states; extern ClientID _network_own_client_id; extern ClientID _redirect_console_to_client; -extern uint8 _network_reconnect; +extern uint8_t _network_reconnect; extern StringList _network_bind_list; extern StringList _network_host_list; extern StringList _network_ban_list; @@ -46,7 +46,7 @@ void NetworkReboot(); void NetworkDisconnect(bool blocking = false, bool close_admins = true); void NetworkGameLoop(); void NetworkBackgroundLoop(); -std::string_view ParseFullConnectionString(const std::string &connection_string, uint16 &port, CompanyID *company_id = nullptr); +std::string_view ParseFullConnectionString(const std::string &connection_string, uint16_t &port, CompanyID *company_id = nullptr); void NetworkStartDebugLog(const std::string &connection_string); void NetworkPopulateCompanyStats(NetworkCompanyStats *stats); @@ -56,7 +56,7 @@ bool NetworkClientConnectGame(const std::string &connection_string, CompanyID de void NetworkClientJoinGame(); void NetworkClientRequestMove(CompanyID company, const std::string &pass = ""); void NetworkClientSendRcon(const std::string &password, const std::string &command); -void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64 data = 0); +void NetworkClientSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, int64_t data = 0); bool NetworkClientPreferTeamChat(const NetworkClientInfo *cio); bool NetworkCompanyIsPassworded(CompanyID company_id); uint NetworkMaxCompaniesAllowed(); @@ -75,7 +75,7 @@ bool NetworkServerChangeClientName(ClientID client_id, const std::string &new_na void NetworkServerDoMove(ClientID client_id, CompanyID company_id); void NetworkServerSendRcon(ClientID client_id, TextColour colour_code, const std::string &string); -void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, ClientID from_id, int64 data = 0, bool from_admin = false); +void NetworkServerSendChat(NetworkAction action, DestType type, int dest, const std::string &msg, ClientID from_id, int64_t data = 0, bool from_admin = false); void NetworkServerSendExternalChat(const std::string &source, TextColour colour, const std::string &user, const std::string &msg); void NetworkServerKickClient(ClientID client_id, const std::string &reason); diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index cbd057e18e..01fba02ef1 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -565,7 +565,7 @@ public: { switch (widget) { case WID_NG_MATRIX: { - uint16 y = r.top; + uint16_t y = r.top; const int max = std::min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), (int)this->servers.size()); @@ -824,7 +824,7 @@ public: this->SetDirty(); } - EventState OnKeyPress(WChar key, uint16 keycode) override + EventState OnKeyPress(char32_t key, uint16_t keycode) override { EventState state = ES_NOT_HANDLED; @@ -1196,7 +1196,7 @@ struct NetworkStartServerWindow : public Window { if (this->widget_id == WID_NSS_SETPWD) { _settings_client.network.server_password = str; } else { - int32 value = atoi(str); + int32_t value = atoi(str); this->SetWidgetDirty(this->widget_id); switch (this->widget_id) { default: NOT_REACHED(); @@ -2145,9 +2145,9 @@ void ShowClientList() } NetworkJoinStatus _network_join_status; ///< The status of joining. -uint8 _network_join_waiting; ///< The number of clients waiting in front of us. -uint32 _network_join_bytes; ///< The number of bytes we already downloaded. -uint32 _network_join_bytes_total; ///< The total number of bytes to download. +uint8_t _network_join_waiting; ///< The number of clients waiting in front of us. +uint32_t _network_join_bytes; ///< The number of bytes we already downloaded. +uint32_t _network_join_bytes_total; ///< The total number of bytes to download. struct NetworkJoinStatusWindow : Window { NetworkPasswordType password_type; @@ -2165,7 +2165,7 @@ struct NetworkJoinStatusWindow : Window { /* Draw the % complete with a bar and a text */ DrawFrameRect(r, COLOUR_GREY, FR_BORDERONLY | FR_LOWERED); Rect ir = r.Shrink(WidgetDimensions::scaled.bevel); - uint8 progress; // used for progress bar + uint8_t progress; // used for progress bar switch (_network_join_status) { case NETWORK_JOIN_STATUS_CONNECTING: case NETWORK_JOIN_STATUS_AUTHORIZING: diff --git a/src/network/network_gui.h b/src/network/network_gui.h index 4cd6ef4f19..dc97818d02 100644 --- a/src/network/network_gui.h +++ b/src/network/network_gui.h @@ -34,7 +34,7 @@ struct NetworkCompanyInfo : NetworkCompanyStats { Money company_value; ///< The company value Money money; ///< The amount of money the company has Money income; ///< How much did the company earn last year - uint16 performance; ///< What was his performance last month? + uint16_t performance; ///< What was his performance last month? bool use_password; ///< Is there a password std::string clients; ///< The clients that control this company (Name1, name2, ..) }; diff --git a/src/network/network_internal.h b/src/network/network_internal.h index 3ea63570f3..395e12194f 100644 --- a/src/network/network_internal.h +++ b/src/network/network_internal.h @@ -65,39 +65,39 @@ enum NetworkJoinStatus { NETWORK_JOIN_STATUS_END, }; -extern uint32 _frame_counter_server; // The frame_counter of the server, if in network-mode -extern uint32 _frame_counter_max; // To where we may go with our clients -extern uint32 _frame_counter; +extern uint32_t _frame_counter_server; // The frame_counter of the server, if in network-mode +extern uint32_t _frame_counter_max; // To where we may go with our clients +extern uint32_t _frame_counter; -extern uint32 _last_sync_frame; // Used in the server to store the last time a sync packet was sent to clients. +extern uint32_t _last_sync_frame; // Used in the server to store the last time a sync packet was sent to clients. /* networking settings */ extern NetworkAddressList _broadcast_list; -extern uint32 _sync_seed_1; +extern uint32_t _sync_seed_1; #ifdef NETWORK_SEND_DOUBLE_SEED -extern uint32 _sync_seed_2; +extern uint32_t _sync_seed_2; #endif -extern uint32 _sync_frame; +extern uint32_t _sync_frame; extern bool _network_first_time; /* Vars needed for the join-GUI */ extern NetworkJoinStatus _network_join_status; -extern uint8 _network_join_waiting; -extern uint32 _network_join_bytes; -extern uint32 _network_join_bytes_total; +extern uint8_t _network_join_waiting; +extern uint32_t _network_join_bytes; +extern uint32_t _network_join_bytes_total; extern ConnectionType _network_server_connection_type; extern std::string _network_server_invite_code; /* Variable available for clients. */ extern std::string _network_server_name; -extern uint8 _network_reconnect; +extern uint8_t _network_reconnect; extern CompanyMask _network_company_passworded; void NetworkQueryServer(const std::string &connection_string); -void GetBindAddresses(NetworkAddressList *addresses, uint16 port); +void GetBindAddresses(NetworkAddressList *addresses, uint16_t port); struct NetworkGameList *NetworkAddServer(const std::string &connection_string, bool manually = true, bool never_expire = false); void NetworkRebuildHostList(); void UpdateNetworkGameWindow(); @@ -111,7 +111,7 @@ struct CommandPacket { CommandPacket() : next(nullptr), company(INVALID_COMPANY), frame(0), my_cmd(false) {} CommandPacket *next; ///< the next command packet (if in queue) CompanyID company; ///< company that is executing the command - uint32 frame; ///< the frame in which this packet is executed + uint32_t frame; ///< the frame in which this packet is executed bool my_cmd; ///< did the command originate from "me" Commands cmd; ///< command being executed. @@ -127,15 +127,15 @@ void NetworkSyncCommandQueue(NetworkClientSocket *cs); void NetworkReplaceCommandClientId(CommandPacket &cp, ClientID client_id); void ShowNetworkError(StringID error_string); -void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const std::string &name, const std::string &str = "", int64 data = 0, const std::string &data_str = ""); +void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, const std::string &name, const std::string &str = "", int64_t data = 0, const std::string &data_str = ""); uint NetworkCalculateLag(const NetworkClientSocket *cs); StringID GetNetworkErrorMsg(NetworkErrorCode err); bool NetworkMakeClientNameUnique(std::string &new_name); -std::string GenerateCompanyPasswordHash(const std::string &password, const std::string &password_server_id, uint32 password_game_seed); +std::string GenerateCompanyPasswordHash(const std::string &password, const std::string &password_server_id, uint32_t password_game_seed); std::string_view ParseCompanyFromConnectionString(const std::string &connection_string, CompanyID *company_id); -NetworkAddress ParseConnectionString(const std::string &connection_string, uint16 default_port); -std::string NormalizeConnectionString(const std::string &connection_string, uint16 default_port); +NetworkAddress ParseConnectionString(const std::string &connection_string, uint16_t default_port); +std::string NormalizeConnectionString(const std::string &connection_string, uint16_t default_port); void ClientNetworkEmergencySave(); diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 86c908cf89..ad87c21835 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -197,7 +197,7 @@ struct PacketWriter : SaveFilter { /* Fast-track the size to the client. */ this->current = new Packet(PACKET_SERVER_MAP_SIZE); - this->current->Send_uint32((uint32)this->total_size); + this->current->Send_uint32((uint32_t)this->total_size); this->PrependQueue(); } }; @@ -658,7 +658,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendCommand(const CommandPacke * @param msg The actual message. * @param data Arbitrary extra data. */ -NetworkRecvStatus ServerNetworkGameSocketHandler::SendChat(NetworkAction action, ClientID client_id, bool self_send, const std::string &msg, int64 data) +NetworkRecvStatus ServerNetworkGameSocketHandler::SendChat(NetworkAction action, ClientID client_id, bool self_send, const std::string &msg, int64_t data) { if (this->status < STATUS_PRE_ACTIVE) return NETWORK_RECV_STATUS_OKAY; @@ -747,7 +747,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendNewGame() * @param colour The colour of the result. * @param command The command that was executed. */ -NetworkRecvStatus ServerNetworkGameSocketHandler::SendRConResult(uint16 colour, const std::string &command) +NetworkRecvStatus ServerNetworkGameSocketHandler::SendRConResult(uint16_t colour, const std::string &command) { Packet *p = new Packet(PACKET_SERVER_RCON); @@ -777,7 +777,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendCompanyUpdate() { Packet *p = new Packet(PACKET_SERVER_COMPANY_UPDATE); - static_assert(sizeof(_network_company_passworded) <= sizeof(uint16)); + static_assert(sizeof(_network_company_passworded) <= sizeof(uint16_t)); p->Send_uint16(_network_company_passworded); this->SendPacket(p); return NETWORK_RECV_STATUS_OKAY; @@ -838,7 +838,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p) } std::string client_revision = p->Recv_string(NETWORK_REVISION_LENGTH); - uint32 newgrf_version = p->Recv_uint32(); + uint32_t newgrf_version = p->Recv_uint32(); /* Check if the client has revision control enabled */ if (!IsNetworkCompatibleVersion(client_revision) || _openttd_newgrf_version != newgrf_version) { @@ -1136,7 +1136,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ACK(Packet *p) return this->SendError(NETWORK_ERROR_NOT_AUTHORIZED); } - uint32 frame = p->Recv_uint32(); + uint32_t frame = p->Recv_uint32(); /* The client is trying to catch up with the server */ if (this->status == STATUS_PRE_ACTIVE) { @@ -1152,7 +1152,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ACK(Packet *p) } /* Get, and validate the token. */ - uint8 token = p->Recv_uint8(); + uint8_t token = p->Recv_uint8(); if (token == this->last_token) { /* We differentiate between last_token_frame and last_frame so the lag * test uses the actual lag of the client instead of the lag for getting @@ -1185,7 +1185,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ACK(Packet *p) * @param data Arbitrary data. * @param from_admin Whether the origin is an admin or not. */ -void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, const std::string &msg, ClientID from_id, int64 data, bool from_admin) +void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, const std::string &msg, ClientID from_id, int64_t data, bool from_admin) { const NetworkClientInfo *ci, *ci_own, *ci_to; @@ -1323,7 +1323,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_CHAT(Packet *p) int dest = p->Recv_uint32(); std::string msg = p->Recv_string(NETWORK_CHAT_LENGTH); - int64 data = p->Recv_uint64(); + int64_t data = p->Recv_uint64(); NetworkClientInfo *ci = this->GetInfo(); switch (action) { diff --git a/src/network/network_server.h b/src/network/network_server.h index aaa83b962d..96a2e52475 100644 --- a/src/network/network_server.h +++ b/src/network/network_server.h @@ -64,7 +64,7 @@ public: byte lag_test; ///< Byte used for lag-testing the client byte last_token; ///< The last random token we did send to verify the client is listening - uint32 last_token_frame; ///< The last frame we received the right token + uint32_t last_token_frame; ///< The last frame we received the right token ClientStatus status; ///< Status of this client CommandQueue outgoing_queue; ///< The command-queue awaiting delivery size_t receive_limit; ///< Amount of bytes that we can receive at this moment @@ -87,12 +87,12 @@ public: NetworkRecvStatus SendQuit(ClientID client_id); NetworkRecvStatus SendShutdown(); NetworkRecvStatus SendNewGame(); - NetworkRecvStatus SendRConResult(uint16 colour, const std::string &command); + NetworkRecvStatus SendRConResult(uint16_t colour, const std::string &command); NetworkRecvStatus SendMove(ClientID client_id, CompanyID company_id); NetworkRecvStatus SendClientInfo(NetworkClientInfo *ci); NetworkRecvStatus SendError(NetworkErrorCode error, const std::string &reason = {}); - NetworkRecvStatus SendChat(NetworkAction action, ClientID client_id, bool self_send, const std::string &msg, int64 data); + NetworkRecvStatus SendChat(NetworkAction action, ClientID client_id, bool self_send, const std::string &msg, int64_t data); NetworkRecvStatus SendExternalChat(const std::string &source, TextColour colour, const std::string &user, const std::string &msg); NetworkRecvStatus SendJoin(ClientID client_id); NetworkRecvStatus SendFrame(); diff --git a/src/network/network_stun.cpp b/src/network/network_stun.cpp index 8964972250..d49c8ebbf8 100644 --- a/src/network/network_stun.cpp +++ b/src/network/network_stun.cpp @@ -20,7 +20,7 @@ class NetworkStunConnecter : public TCPConnecter { private: ClientNetworkStunSocketHandler *stun_handler; std::string token; - uint8 family; + uint8_t family; public: /** @@ -28,7 +28,7 @@ public: * @param stun_handler The handler for this request. * @param connection_string The address of the server. */ - NetworkStunConnecter(ClientNetworkStunSocketHandler *stun_handler, const std::string &connection_string, const std::string &token, uint8 family) : + NetworkStunConnecter(ClientNetworkStunSocketHandler *stun_handler, const std::string &connection_string, const std::string &token, uint8_t family) : TCPConnecter(connection_string, NETWORK_STUN_SERVER_PORT, NetworkAddress(), family), stun_handler(stun_handler), token(token), @@ -66,7 +66,7 @@ public: * @param token The token as received from the Game Coordinator. * @param family What IP family to use. */ -void ClientNetworkStunSocketHandler::Connect(const std::string &token, uint8 family) +void ClientNetworkStunSocketHandler::Connect(const std::string &token, uint8_t family) { this->token = token; this->family = family; @@ -80,7 +80,7 @@ void ClientNetworkStunSocketHandler::Connect(const std::string &token, uint8 fam * @param family What IP family this STUN request is for. * @return The handler for this STUN request. */ -std::unique_ptr ClientNetworkStunSocketHandler::Stun(const std::string &token, uint8 family) +std::unique_ptr ClientNetworkStunSocketHandler::Stun(const std::string &token, uint8_t family) { auto stun_handler = std::make_unique(); diff --git a/src/network/network_stun.h b/src/network/network_stun.h index d896c991be..0ad69d4abe 100644 --- a/src/network/network_stun.h +++ b/src/network/network_stun.h @@ -16,7 +16,7 @@ class ClientNetworkStunSocketHandler : public NetworkStunSocketHandler { private: std::string token; ///< Token of this STUN handler. - uint8 family = AF_UNSPEC; ///< Family of this STUN handler. + uint8_t family = AF_UNSPEC; ///< Family of this STUN handler. bool sent_result = false; ///< Did we sent the result of the STUN connection? public: @@ -27,9 +27,9 @@ public: ~ClientNetworkStunSocketHandler() override; void SendReceive(); - void Connect(const std::string &token, uint8 family); + void Connect(const std::string &token, uint8_t family); - static std::unique_ptr Stun(const std::string &token, uint8 family); + static std::unique_ptr Stun(const std::string &token, uint8_t family); }; #endif /* NETWORK_STUN_H */ diff --git a/src/network/network_survey.cpp b/src/network/network_survey.cpp index 97b0c43f41..211f48e809 100644 --- a/src/network/network_survey.cpp +++ b/src/network/network_survey.cpp @@ -272,7 +272,7 @@ static void SurveyGrfs(nlohmann::json &survey) grf["is_static"] = HasBit(c->flags, GCF_STATIC); - std::vector parameters; + std::vector parameters; for (int i = 0; i < c->num_params; i++) { parameters.push_back(c->param[i]); } diff --git a/src/network/network_turn.cpp b/src/network/network_turn.cpp index bfc4919e59..f47f8b9326 100644 --- a/src/network/network_turn.cpp +++ b/src/network/network_turn.cpp @@ -86,7 +86,7 @@ void ClientNetworkTurnSocketHandler::Connect() * @param connection_string Connection string of the TURN server. * @return The handler for this TURN connection. */ -/* static */ std::unique_ptr ClientNetworkTurnSocketHandler::Turn(const std::string &token, uint8 tracking_number, const std::string &ticket, const std::string &connection_string) +/* static */ std::unique_ptr ClientNetworkTurnSocketHandler::Turn(const std::string &token, uint8_t tracking_number, const std::string &ticket, const std::string &connection_string) { auto turn_handler = std::make_unique(token, tracking_number, connection_string); diff --git a/src/network/network_turn.h b/src/network/network_turn.h index fba25447aa..9ff8980157 100644 --- a/src/network/network_turn.h +++ b/src/network/network_turn.h @@ -16,7 +16,7 @@ class ClientNetworkTurnSocketHandler : public NetworkTurnSocketHandler { private: std::string token; ///< Token of this connection. - uint8 tracking_number; ///< Tracking number of this connection. + uint8_t tracking_number; ///< Tracking number of this connection. std::string connection_string; ///< The connection string of the TURN server we are connecting to. protected: @@ -27,7 +27,7 @@ public: TCPConnecter *connecter = nullptr; ///< Connecter instance. bool connect_started = false; ///< Whether we started the connection. - ClientNetworkTurnSocketHandler(const std::string &token, uint8 tracking_number, const std::string &connection_string) : token(token), tracking_number(tracking_number), connection_string(connection_string) {} + ClientNetworkTurnSocketHandler(const std::string &token, uint8_t tracking_number, const std::string &connection_string) : token(token), tracking_number(tracking_number), connection_string(connection_string) {} NetworkRecvStatus CloseConnection(bool error = true) override; ~ClientNetworkTurnSocketHandler() override; @@ -36,7 +36,7 @@ public: void Connect(); void ConnectFailure(); - static std::unique_ptr Turn(const std::string &token, uint8 tracking_number, const std::string &ticket, const std::string &connection_string); + static std::unique_ptr Turn(const std::string &token, uint8_t tracking_number, const std::string &ticket, const std::string &connection_string); }; #endif /* NETWORK_TURN_H */ diff --git a/src/network/network_type.h b/src/network/network_type.h index 534f42c038..86cb877bbb 100644 --- a/src/network/network_type.h +++ b/src/network/network_type.h @@ -37,24 +37,24 @@ enum NetworkVehicleType { * Game type the server can be using. * Used on the network protocol to communicate with Game Coordinator. */ -enum ServerGameType : uint8 { +enum ServerGameType : uint8_t { SERVER_GAME_TYPE_LOCAL = 0, SERVER_GAME_TYPE_PUBLIC, SERVER_GAME_TYPE_INVITE_ONLY, }; /** 'Unique' identifier to be given to clients */ -enum ClientID : uint32 { +enum ClientID : uint32_t { INVALID_CLIENT_ID = 0, ///< Client is not part of anything CLIENT_ID_SERVER = 1, ///< Servers always have this ID CLIENT_ID_FIRST = 2, ///< The first client ID }; /** Indices into the client tables */ -typedef uint8 ClientIndex; +typedef uint8_t ClientIndex; /** Indices into the admin tables. */ -typedef uint8 AdminIndex; +typedef uint8_t AdminIndex; /** Maximum number of allowed admins. */ static const AdminIndex MAX_ADMINS = 16; @@ -63,15 +63,15 @@ static const AdminIndex INVALID_ADMIN_ID = UINT8_MAX; /** Simple calculated statistics of a company */ struct NetworkCompanyStats { - uint16 num_vehicle[NETWORK_VEH_END]; ///< How many vehicles are there of this type? - uint16 num_station[NETWORK_VEH_END]; ///< How many stations are there of this type? + uint16_t num_vehicle[NETWORK_VEH_END]; ///< How many vehicles are there of this type? + uint16_t num_station[NETWORK_VEH_END]; ///< How many stations are there of this type? bool ai; ///< Is this company an AI }; /** Some state information of a company, especially for servers */ struct NetworkCompanyState { std::string password; ///< The password for the company - uint16 months_empty; ///< How many months the company is empty + uint16_t months_empty; ///< How many months the company is empty }; struct NetworkClientInfo; diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp index 4f4c1b8b98..6975d1c767 100644 --- a/src/network/network_udp.cpp +++ b/src/network/network_udp.cpp @@ -33,7 +33,7 @@ #include "../safeguards.h" static bool _network_udp_server; ///< Is the UDP server started? -static uint16 _network_udp_broadcast; ///< Timeout for the UDP broadcasts. +static uint16_t _network_udp_broadcast; ///< Timeout for the UDP broadcasts. /** Some information about a socket, which exists before the actual socket has been created to provide locking and the likes. */ struct UDPSocket { diff --git a/src/newgrf.cpp b/src/newgrf.cpp index d2ed738c00..d882ebbe4a 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -76,7 +76,7 @@ const std::vector &GetAllGRFFiles() byte _misc_grf_features = 0; /** 32 * 8 = 256 flags. Apparently TTDPatch uses this many.. */ -static uint32 _ttdpatch_flags[8]; +static uint32_t _ttdpatch_flags[8]; /** Indicates which are the newgrf features currently loaded ingame */ GRFLoadedFeatures _loaded_newgrf_features; @@ -104,7 +104,7 @@ public: SpriteFile *file; ///< File of currently processed GRF file. GRFFile *grffile; ///< Currently processed GRF file. GRFConfig *grfconfig; ///< Config of the currently processed GRF file. - uint32 nfo_line; ///< Currently processed pseudo sprite number in the GRF. + uint32_t nfo_line; ///< Currently processed pseudo sprite number in the GRF. /* Kind of return values when processing certain actions */ int skip_sprites; ///< Number of pseudo sprites to skip before processing the next one. (-1 to skip to end of file) @@ -203,7 +203,7 @@ static GrfProcessingState _cur; * @return True iff the image index is valid, or 0xFD (use new graphics). */ template -static inline bool IsValidNewGRFImageIndex(uint8 image_index) +static inline bool IsValidNewGRFImageIndex(uint8_t image_index) { return image_index == 0xFD || IsValidImageIndex(image_index); } @@ -238,25 +238,25 @@ public: throw OTTDByteReaderSignal(); } - uint16 ReadWord() + uint16_t ReadWord() { - uint16 val = ReadByte(); + uint16_t val = ReadByte(); return val | (ReadByte() << 8); } - uint16 ReadExtendedByte() + uint16_t ReadExtendedByte() { - uint16 val = ReadByte(); + uint16_t val = ReadByte(); return val == 0xFF ? ReadWord() : val; } - uint32 ReadDWord() + uint32_t ReadDWord() { - uint32 val = ReadWord(); + uint32_t val = ReadWord(); return val | (ReadWord() << 16); } - uint32 ReadVarSize(byte size) + uint32_t ReadVarSize(byte size) { switch (size) { case 1: return ReadByte(); @@ -324,13 +324,13 @@ struct GRFTempEngineData { NONEMPTY, ///< GRF defined the vehicle as refittable. If the refitmask is empty after translation (cargotypes not available), disable the vehicle. }; - uint16 cargo_allowed; - uint16 cargo_disallowed; + uint16_t cargo_allowed; + uint16_t cargo_disallowed; RailTypeLabel railtypelabel; - uint8 roadtramtype; + uint8_t roadtramtype; const GRFFile *defaultcargo_grf; ///< GRF defining the cargo translation table to use if the default cargo is the 'first refittable'. Refittability refittability; ///< Did the newgrf set any refittability property? If not, default refittability will be applied. - uint8 rv_max_speed; ///< Temporary storage of RV prop 15, maximum speed in mph/0.8 + uint8_t rv_max_speed; ///< Temporary storage of RV prop 15, maximum speed in mph/0.8 CargoTypes ctt_include_mask; ///< Cargo types always included in the refit mask. CargoTypes ctt_exclude_mask; ///< Cargo types always excluded from the refit mask. @@ -354,16 +354,16 @@ static std::vector _gted; ///< Temporary engine data used du * Contains the GRF ID of the owner of a vehicle if it has been reserved. * GRM for vehicles is only used if dynamic engine allocation is disabled, * so 256 is the number of original engines. */ -static uint32 _grm_engines[256]; +static uint32_t _grm_engines[256]; /** Contains the GRF ID of the owner of a cargo if it has been reserved */ -static uint32 _grm_cargoes[NUM_CARGO * 2]; +static uint32_t _grm_cargoes[NUM_CARGO * 2]; struct GRFLocation { - uint32 grfid; - uint32 nfoline; + uint32_t grfid; + uint32_t nfoline; - GRFLocation(uint32 grfid, uint32 nfoline) : grfid(grfid), nfoline(nfoline) { } + GRFLocation(uint32_t grfid, uint32_t nfoline) : grfid(grfid), nfoline(nfoline) { } bool operator<(const GRFLocation &other) const { @@ -400,7 +400,7 @@ void GrfMsgI(int severity, const std::string &msg) * @param grfid The grfID to obtain the file for * @return The file. */ -static GRFFile *GetFileByGRFID(uint32 grfid) +static GRFFile *GetFileByGRFID(uint32_t grfid) { for (GRFFile * const file : _grf_files) { if (file->grfid == grfid) return file; @@ -458,7 +458,7 @@ static GRFError *DisableGrf(StringID message = STR_NULL, GRFConfig *config = nul * Information for mapping static StringIDs. */ struct StringIDMapping { - uint32 grfid; ///< Source NewGRF. + uint32_t grfid; ///< Source NewGRF. StringID source; ///< Source StringID (GRF local). StringID *target; ///< Destination for mapping result. }; @@ -547,7 +547,7 @@ static StringID TTDPStringIDToOTTDStringIDMapping(StringID str) * @param str StringID that we want to have the equivalent in OoenTTD. * @return The properly adjusted StringID. */ -StringID MapGRFStringID(uint32 grfid, StringID str) +StringID MapGRFStringID(uint32_t grfid, StringID str) { if (IsInsideMM(str, 0xD800, 0x10000)) { /* General text provided by NewGRF. @@ -574,14 +574,14 @@ StringID MapGRFStringID(uint32 grfid, StringID str) } } -static std::map _grf_id_overrides; +static std::map _grf_id_overrides; /** * Set the override for a NewGRF * @param source_grfid The grfID which wants to override another NewGRF. * @param target_grfid The grfID which is being overridden. */ -static void SetNewGRFOverride(uint32 source_grfid, uint32 target_grfid) +static void SetNewGRFOverride(uint32_t source_grfid, uint32_t target_grfid) { _grf_id_overrides[source_grfid] = target_grfid; GrfMsg(5, "SetNewGRFOverride: Added override of 0x{:X} to 0x{:X}", BSWAP32(source_grfid), BSWAP32(target_grfid)); @@ -595,15 +595,15 @@ static void SetNewGRFOverride(uint32 source_grfid, uint32 target_grfid) * @param static_access If the engine is not present, return nullptr instead of allocating a new engine. (Used for static Action 0x04). * @return The requested engine. */ -static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 internal_id, bool static_access = false) +static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16_t internal_id, bool static_access = false) { /* Hack for add-on GRFs that need to modify another GRF's engines. This lets * them use the same engine slots. */ - uint32 scope_grfid = INVALID_GRFID; // If not using dynamic_engines, all newgrfs share their ID range + uint32_t scope_grfid = INVALID_GRFID; // If not using dynamic_engines, all newgrfs share their ID range if (_settings_game.vehicle.dynamic_engines) { /* If dynamic_engies is enabled, there can be multiple independent ID ranges. */ scope_grfid = file->grfid; - uint32 override = _grf_id_overrides[file->grfid]; + uint32_t override = _grf_id_overrides[file->grfid]; if (override != 0) { scope_grfid = override; const GRFFile *grf_match = GetFileByGRFID(override); @@ -661,7 +661,7 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 intern scope_grfid, // Note: this is INVALID_GRFID if dynamic_engines is disabled, so no reservation internal_id, type, - std::min(internal_id, _engine_counts[type]) // substitute_id == _engine_counts[subtype] means "no substitute" + std::min(internal_id, _engine_counts[type]) // substitute_id == _engine_counts[subtype] means "no substitute" }); if (engine_pool_size != Engine::GetPoolSize()) { @@ -687,12 +687,12 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 intern * property the grfID may be unique or overwriting or partially re-defining * properties of an existing engine. */ -EngineID GetNewEngineID(const GRFFile *file, VehicleType type, uint16 internal_id) +EngineID GetNewEngineID(const GRFFile *file, VehicleType type, uint16_t internal_id) { - uint32 scope_grfid = INVALID_GRFID; // If not using dynamic_engines, all newgrfs share their ID range + uint32_t scope_grfid = INVALID_GRFID; // If not using dynamic_engines, all newgrfs share their ID range if (_settings_game.vehicle.dynamic_engines) { scope_grfid = file->grfid; - uint32 override = _grf_id_overrides[file->grfid]; + uint32_t override = _grf_id_overrides[file->grfid]; if (override != 0) scope_grfid = override; } @@ -734,7 +734,7 @@ static void MapSpriteMappingRecolour(PalSpriteID *grf_sprite) * @param[out] max_palette_offset Optionally returns the number of sprites in the spriteset of the palette. (0 if no spritset) * @return Read TileLayoutFlags. */ -static TileLayoutFlags ReadSpriteLayoutSprite(ByteReader *buf, bool read_flags, bool invert_action1_flag, bool use_cur_spritesets, int feature, PalSpriteID *grf_sprite, uint16 *max_sprite_offset = nullptr, uint16 *max_palette_offset = nullptr) +static TileLayoutFlags ReadSpriteLayoutSprite(ByteReader *buf, bool read_flags, bool invert_action1_flag, bool use_cur_spritesets, int feature, PalSpriteID *grf_sprite, uint16_t *max_sprite_offset = nullptr, uint16_t *max_palette_offset = nullptr) { grf_sprite->sprite = buf->ReadWord(); grf_sprite->pal = buf->ReadWord(); @@ -853,8 +853,8 @@ static bool ReadSpriteLayout(ByteReader *buf, uint num_building_sprites, bool us if (!allow_var10) valid_flags &= ~TLF_VAR10_FLAGS; dts->Allocate(num_building_sprites); // allocate before reading groundsprite flags - std::vector max_sprite_offset(num_building_sprites + 1, 0); - std::vector max_palette_offset(num_building_sprites + 1, 0); + std::vector max_sprite_offset(num_building_sprites + 1, 0); + std::vector max_palette_offset(num_building_sprites + 1, 0); /* Groundsprite */ TileLayoutFlags flags = ReadSpriteLayoutSprite(buf, has_flags, false, use_cur_spritesets, feature, &dts->ground, max_sprite_offset.data(), max_palette_offset.data()); @@ -936,12 +936,12 @@ static bool ReadSpriteLayout(ByteReader *buf, uint num_building_sprites, bool us } /** - * Translate the refit mask. refit_mask is uint32 as it has not been mapped to CargoTypes. + * Translate the refit mask. refit_mask is uint32_t as it has not been mapped to CargoTypes. */ -static CargoTypes TranslateRefitMask(uint32 refit_mask) +static CargoTypes TranslateRefitMask(uint32_t refit_mask) { CargoTypes result = 0; - for (uint8 bit : SetBitIterator(refit_mask)) { + for (uint8_t bit : SetBitIterator(refit_mask)) { CargoID cargo = GetCargoTranslation(bit, _cur.grffile, true); if (IsValidCargoID(cargo)) SetBit(result, cargo); } @@ -955,7 +955,7 @@ static CargoTypes TranslateRefitMask(uint32 refit_mask) * @param error_location Function name for grf error messages * @param[out] index If \a base_pointer is valid, \a index is assigned to the matching price; else it is left unchanged */ -static void ConvertTTDBasePrice(uint32 base_pointer, const char *error_location, Price *index) +static void ConvertTTDBasePrice(uint32_t base_pointer, const char *error_location, Price *index) { /* Special value for 'none' */ if (base_pointer == 0) { @@ -963,8 +963,8 @@ static void ConvertTTDBasePrice(uint32 base_pointer, const char *error_location, return; } - static const uint32 start = 0x4B34; ///< Position of first base price - static const uint32 size = 6; ///< Size of each base price record + static const uint32_t start = 0x4B34; ///< Position of first base price + static const uint32_t size = 6; ///< Size of each base price record if (base_pointer < start || (base_pointer - start) % size != 0 || (base_pointer - start) / size >= PR_END) { GrfMsg(1, "{}: Unsupported running cost base 0x{:04X}, ignoring", error_location, base_pointer); @@ -1048,7 +1048,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop switch (prop) { case 0x05: { // Track type - uint8 tracktype = buf->ReadByte(); + uint8_t tracktype = buf->ReadByte(); if (tracktype < _cur.grffile->railtype_list.size()) { _gted[e->index].railtypelabel = _cur.grffile->railtype_list[tracktype]; @@ -1073,7 +1073,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop break; case PROP_TRAIN_SPEED: { // 0x09 Speed (1 unit is 1 km-ish/h) - uint16 speed = buf->ReadWord(); + uint16_t speed = buf->ReadWord(); if (speed == 0xFFFF) speed = 0; rvi->max_speed = speed; @@ -1102,8 +1102,8 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop break; case 0x12: { // Sprite ID - uint8 spriteid = buf->ReadByte(); - uint8 orig_spriteid = spriteid; + uint8_t spriteid = buf->ReadByte(); + uint8_t orig_spriteid = spriteid; /* TTD sprite IDs point to a location in a 16bit array, but we use it * as an array index, so we need it to be half the original value. */ @@ -1119,7 +1119,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop } case 0x13: { // Dual-headed - uint8 dual = buf->ReadByte(); + uint8_t dual = buf->ReadByte(); if (dual != 0) { rvi->railveh_type = RAILVEH_MULTIHEAD; @@ -1136,7 +1136,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop case 0x15: { // Cargo type _gted[e->index].defaultcargo_grf = _cur.grffile; - uint8 ctype = buf->ReadByte(); + uint8_t ctype = buf->ReadByte(); if (ctype == 0xFF) { /* 0xFF is specified as 'use first refittable' */ @@ -1175,7 +1175,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop * 0x32 .. 0x37: Monorail * 0x38 .. 0x41: Maglev */ - uint8 traction = buf->ReadByte(); + uint8_t traction = buf->ReadByte(); EngineClass engclass; if (traction <= 0x07) { @@ -1216,7 +1216,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop break; case 0x1D: { // Refit cargo - uint32 mask = buf->ReadDWord(); + uint32_t mask = buf->ReadDWord(); _gted[e->index].UpdateRefittability(mask != 0); ei->refit_mask = TranslateRefitMask(mask); _gted[e->index].defaultcargo_grf = _cur.grffile; @@ -1298,7 +1298,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop case 0x2C: // CTT refit include list case 0x2D: { // CTT refit exclude list - uint8 count = buf->ReadByte(); + uint8_t count = buf->ReadByte(); _gted[e->index].UpdateRefittability(prop == 0x2C && count != 0); if (prop == 0x2C) _gted[e->index].defaultcargo_grf = _cur.grffile; CargoTypes &ctt = prop == 0x2C ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; @@ -1374,8 +1374,8 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop break; case 0x0E: { // Sprite ID - uint8 spriteid = buf->ReadByte(); - uint8 orig_spriteid = spriteid; + uint8_t spriteid = buf->ReadByte(); + uint8_t orig_spriteid = spriteid; /* cars have different custom id in the GRF file */ if (spriteid == 0xFF) spriteid = 0xFD; @@ -1397,7 +1397,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop case 0x10: { // Cargo type _gted[e->index].defaultcargo_grf = _cur.grffile; - uint8 ctype = buf->ReadByte(); + uint8_t ctype = buf->ReadByte(); if (ctype == 0xFF) { /* 0xFF is specified as 'use first refittable' */ @@ -1436,7 +1436,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop break; case 0x16: { // Cargoes available for refitting - uint32 mask = buf->ReadDWord(); + uint32_t mask = buf->ReadDWord(); _gted[e->index].UpdateRefittability(mask != 0); ei->refit_mask = TranslateRefitMask(mask); _gted[e->index].defaultcargo_grf = _cur.grffile; @@ -1507,7 +1507,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop case 0x24: // CTT refit include list case 0x25: { // CTT refit exclude list - uint8 count = buf->ReadByte(); + uint8_t count = buf->ReadByte(); _gted[e->index].UpdateRefittability(prop == 0x24 && count != 0); if (prop == 0x24) _gted[e->index].defaultcargo_grf = _cur.grffile; CargoTypes &ctt = prop == 0x24 ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; @@ -1561,8 +1561,8 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop switch (prop) { case 0x08: { // Sprite ID - uint8 spriteid = buf->ReadByte(); - uint8 orig_spriteid = spriteid; + uint8_t spriteid = buf->ReadByte(); + uint8_t orig_spriteid = spriteid; /* ships have different custom id in the GRF file */ if (spriteid == 0xFF) spriteid = 0xFD; @@ -1592,7 +1592,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop case 0x0C: { // Cargo type _gted[e->index].defaultcargo_grf = _cur.grffile; - uint8 ctype = buf->ReadByte(); + uint8_t ctype = buf->ReadByte(); if (ctype == 0xFF) { /* 0xFF is specified as 'use first refittable' */ @@ -1623,7 +1623,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop break; case 0x11: { // Cargoes available for refitting - uint32 mask = buf->ReadDWord(); + uint32_t mask = buf->ReadDWord(); _gted[e->index].UpdateRefittability(mask != 0); ei->refit_mask = TranslateRefitMask(mask); _gted[e->index].defaultcargo_grf = _cur.grffile; @@ -1690,7 +1690,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop case 0x1E: // CTT refit include list case 0x1F: { // CTT refit exclude list - uint8 count = buf->ReadByte(); + uint8_t count = buf->ReadByte(); _gted[e->index].UpdateRefittability(prop == 0x1E && count != 0); if (prop == 0x1E) _gted[e->index].defaultcargo_grf = _cur.grffile; CargoTypes &ctt = prop == 0x1E ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; @@ -1744,8 +1744,8 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int switch (prop) { case 0x08: { // Sprite ID - uint8 spriteid = buf->ReadByte(); - uint8 orig_spriteid = spriteid; + uint8_t spriteid = buf->ReadByte(); + uint8_t orig_spriteid = spriteid; /* aircraft have different custom id in the GRF file */ if (spriteid == 0xFF) spriteid = 0xFD; @@ -1802,7 +1802,7 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int break; case 0x13: { // Cargoes available for refitting - uint32 mask = buf->ReadDWord(); + uint32_t mask = buf->ReadDWord(); _gted[e->index].UpdateRefittability(mask != 0); ei->refit_mask = TranslateRefitMask(mask); _gted[e->index].defaultcargo_grf = _cur.grffile; @@ -1851,7 +1851,7 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int case 0x1D: // CTT refit include list case 0x1E: { // CTT refit exclude list - uint8 count = buf->ReadByte(); + uint8_t count = buf->ReadByte(); _gted[e->index].UpdateRefittability(prop == 0x1D && count != 0); if (prop == 0x1D) _gted[e->index].defaultcargo_grf = _cur.grffile; CargoTypes &ctt = prop == 0x1D ? _gted[e->index].ctt_include_mask : _gted[e->index].ctt_exclude_mask; @@ -1926,13 +1926,13 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte } /* Swap classid because we read it in BE meaning WAYP or DFLT */ - uint32 classid = buf->ReadDWord(); + uint32_t classid = buf->ReadDWord(); statspec->cls_id = StationClass::Allocate(BSWAP32(classid)); break; } case 0x09: { // Define sprite layout - uint16 tiles = buf->ReadExtendedByte(); + uint16_t tiles = buf->ReadExtendedByte(); statspec->renderdata.clear(); // delete earlier loaded stuff statspec->renderdata.reserve(tiles); @@ -1940,7 +1940,7 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte NewGRFSpriteLayout *dts = &statspec->renderdata.emplace_back(); dts->consistent_max_offset = UINT16_MAX; // Spritesets are unknown, so no limit. - if (buf->HasData(4) && *(uint32*)buf->Data() == 0) { + if (buf->HasData(4) && *(uint32_t*)buf->Data() == 0) { buf->Skip(4); extern const DrawTileSprites _station_display_datas_rail[8]; dts->Clone(&_station_display_datas_rail[t % 8]); @@ -2092,7 +2092,7 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, Byte /* 0x19 road routing (not implemented) */ case 0x1A: { // Advanced sprite layout - uint16 tiles = buf->ReadExtendedByte(); + uint16_t tiles = buf->ReadExtendedByte(); statspec->renderdata.clear(); // delete earlier loaded stuff statspec->renderdata.reserve(tiles); @@ -2429,7 +2429,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, Byt break; case 0x0A: { // Availability years - uint16 years = buf->ReadWord(); + uint16_t years = buf->ReadWord(); housespec->min_year = GB(years, 0, 8) > 150 ? MAX_YEAR : ORIGINAL_BASE_YEAR + GB(years, 0, 8); housespec->max_year = GB(years, 8, 8) > 150 ? MAX_YEAR : ORIGINAL_BASE_YEAR + GB(years, 8, 8); break; @@ -2449,7 +2449,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, Byt break; case 0x0F: { // Goods/candy, food/fizzy drinks acceptance - int8 goods = buf->ReadByte(); + int8_t goods = buf->ReadByte(); /* If value of goods is negative, it means in fact food or, if in toyland, fizzy_drink acceptance. * Else, we have "standard" 3rd cargo type, goods or candy, for toyland once more */ @@ -2532,14 +2532,14 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, Byt break; case 0x1E: { // Accepted cargo types - uint32 cargotypes = buf->ReadDWord(); + uint32_t cargotypes = buf->ReadDWord(); /* Check if the cargo types should not be changed */ if (cargotypes == 0xFFFFFFFF) break; for (uint j = 0; j < 3; j++) { /* Get the cargo number from the 'list' */ - uint8 cargo_part = GB(cargotypes, 8 * j, 8); + uint8_t cargo_part = GB(cargotypes, 8 * j, 8); CargoID cargo = GetCargoTranslation(cargo_part, _cur.grffile); if (!IsValidCargoID(cargo)) { @@ -2610,7 +2610,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, Byt * @param language_id The (NewGRF) language ID to get the map for. * @return The LanguageMap, or nullptr if it couldn't be found. */ -/* static */ const LanguageMap *LanguageMap::GetLanguageMap(uint32 grfid, uint8 language_id) +/* static */ const LanguageMap *LanguageMap::GetLanguageMap(uint32_t grfid, uint8_t language_id) { /* LanguageID "MAX_LANG", i.e. 7F is any. This language can't have a gender/case mapping, but has to be handled gracefully. */ const GRFFile *grffile = GetFileByGRFID(grfid); @@ -2636,7 +2636,7 @@ static ChangeInfoResult LoadTranslationTable(uint gvid, int numinfo, ByteReader translation_table.clear(); for (int i = 0; i < numinfo; i++) { - uint32 item = buf->ReadDWord(); + uint32_t item = buf->ReadDWord(); translation_table.push_back(BSWAP32(item)); } @@ -2713,7 +2713,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, By case 0x0B: { // Currency multipliers uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); - uint32 rate = buf->ReadDWord(); + uint32_t rate = buf->ReadDWord(); if (curidx < CURRENCY_END) { /* TTDPatch uses a multiple of 1000 for its conversion calculations, @@ -2728,7 +2728,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, By case 0x0C: { // Currency options uint curidx = GetNewgrfCurrencyIdConverted(gvid + i); - uint16 options = buf->ReadWord(); + uint16_t options = buf->ReadWord(); if (curidx < CURRENCY_END) { _currency_specs[curidx].separator.clear(); @@ -2849,7 +2849,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, By * safe as OpenTTD's strings gender/cases are usually in ASCII which * is just a subset of UTF8, or they need the bigger UTF8 characters * such as Cyrillic. Thus we will simply assume they're all UTF8. */ - WChar c; + char32_t c; size_t len = Utf8Decode(&c, name); if (c == NFO_UTF8_IDENTIFIER) name += len; @@ -2930,8 +2930,8 @@ static ChangeInfoResult GlobalVarReserveInfo(uint gvid, int numinfo, int prop, B break; case 0x11: { // GRF match for engine allocation - uint32 s = buf->ReadDWord(); - uint32 t = buf->ReadDWord(); + uint32_t s = buf->ReadDWord(); + uint32_t t = buf->ReadDWord(); SetNewGRFOverride(s, t); break; } @@ -3054,7 +3054,7 @@ static ChangeInfoResult CargoChangeInfo(uint cid, int numinfo, int prop, ByteRea break; case 0x18: { // Town growth substitute type - uint8 substitute_type = buf->ReadByte(); + uint8_t substitute_type = buf->ReadByte(); switch (substitute_type) { case 0x00: cs->town_effect = TE_PASSENGERS; break; @@ -3079,7 +3079,7 @@ static ChangeInfoResult CargoChangeInfo(uint cid, int numinfo, int prop, ByteRea break; case 0x1D: // Vehicle capacity muliplier - cs->multiplier = std::max(1u, buf->ReadWord()); + cs->multiplier = std::max(1u, buf->ReadWord()); break; default: @@ -3262,7 +3262,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint indtid, int numinfo, int pr case 0x0A: // Tile acceptance case 0x0B: case 0x0C: { - uint16 acctp = buf->ReadWord(); + uint16_t acctp = buf->ReadWord(); tsp->accepts_cargo[prop - 0x0A] = GetCargoTranslation(GB(acctp, 0, 8), _cur.grffile); tsp->acceptance[prop - 0x0A] = Clamp(GB(acctp, 8, 8), 0, 16); break; @@ -3304,7 +3304,7 @@ static ChangeInfoResult IndustrytilesChangeInfo(uint indtid, int numinfo, int pr if (i < num_cargoes) { tsp->accepts_cargo[i] = GetCargoTranslation(buf->ReadByte(), _cur.grffile); /* Tile acceptance can be negative to counteract the INDTILE_SPECIAL_ACCEPTS_ALL_CARGO flag */ - tsp->acceptance[i] = (int8)buf->ReadByte(); + tsp->acceptance[i] = (int8_t)buf->ReadByte(); } else { tsp->accepts_cargo[i] = CT_INVALID; tsp->acceptance[i] = 0; @@ -3519,8 +3519,8 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, case 0x0A: { // Set industry layout(s) byte new_num_layouts = buf->ReadByte(); - uint32 definition_size = buf->ReadDWord(); - uint32 bytes_read = 0; + uint32_t definition_size = buf->ReadDWord(); + uint32_t bytes_read = 0; std::vector new_layouts; IndustryTileLayout layout; @@ -3587,10 +3587,10 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, it.gfx = tempid; } } else if (it.gfx == GFX_WATERTILE_SPECIALCHECK) { - it.ti.x = (int8)GB(it.ti.x, 0, 8); - it.ti.y = (int8)GB(it.ti.y, 0, 8); + it.ti.x = (int8_t)GB(it.ti.x, 0, 8); + it.ti.y = (int8_t)GB(it.ti.y, 0, 8); - /* When there were only 256x256 maps, TileIndex was a uint16 and + /* When there were only 256x256 maps, TileIndex was a uint16_t and * it.ti was just a TileIndexDiff that was added to it. * As such negative "x" values were shifted into the "y" position. * x = -1, y = 1 -> x = 255, y = 0 @@ -3660,10 +3660,10 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, case 0x15: { // Random sound effects indsp->number_of_sounds = buf->ReadByte(); - uint8 *sounds = MallocT(indsp->number_of_sounds); + uint8_t *sounds = MallocT(indsp->number_of_sounds); try { - for (uint8 j = 0; j < indsp->number_of_sounds; j++) { + for (uint8_t j = 0; j < indsp->number_of_sounds; j++) { sounds[j] = buf->ReadByte(); } } catch (...) { @@ -3706,7 +3706,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, case 0x1C: // Input cargo multipliers for the three input cargo types case 0x1D: case 0x1E: { - uint32 multiples = buf->ReadDWord(); + uint32_t multiples = buf->ReadDWord(); indsp->input_cargo_multiplier[prop - 0x1C][0] = GB(multiples, 0, 16); indsp->input_cargo_multiplier[prop - 0x1C][1] = GB(multiples, 16, 16); break; @@ -3732,7 +3732,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, break; case 0x24: { // name for nearby station - uint16 str = buf->ReadWord(); + uint16_t str = buf->ReadWord(); if (str == 0) { indsp->station_name = STR_NULL; } else { @@ -3804,7 +3804,7 @@ static ChangeInfoResult IndustriesChangeInfo(uint indid, int numinfo, int prop, } for (uint i = 0; i < lengthof(indsp->accepts_cargo); i++) { for (uint j = 0; j < lengthof(indsp->produced_cargo); j++) { - uint16 mult = 0; + uint16_t mult = 0; if (i < num_inputs && j < num_outputs) mult = buf->ReadWord(); indsp->input_cargo_multiplier[i][j] = mult; } @@ -3913,7 +3913,7 @@ static ChangeInfoResult AirportChangeInfo(uint airport, int numinfo, int prop, B free(as->rotation); as->num_table = buf->ReadByte(); // Number of layaouts as->rotation = MallocT(as->num_table); - uint32 defsize = buf->ReadDWord(); // Total size of the definition + uint32_t defsize = buf->ReadDWord(); // Total size of the definition AirportTileTable **tile_table = CallocT(as->num_table); // Table with tiles to compose the airport AirportTileTable *att = CallocT(defsize); // Temporary array to read the tile layouts from the GRF int size; @@ -3944,7 +3944,7 @@ static ChangeInfoResult AirportChangeInfo(uint airport, int numinfo, int prop, B int local_tile_id = buf->ReadWord(); /* Read the ID from the _airporttile_mngr. */ - uint16 tempid = _airporttile_mngr.GetID(local_tile_id, _cur.grffile->grfid); + uint16_t tempid = _airporttile_mngr.GetID(local_tile_id, _cur.grffile->grfid); if (tempid == INVALID_AIRPORTTILE) { GrfMsg(2, "AirportChangeInfo: Attempt to use airport tile {} with airport id {}, not yet defined. Ignoring.", local_tile_id, airport + i); @@ -3953,8 +3953,8 @@ static ChangeInfoResult AirportChangeInfo(uint airport, int numinfo, int prop, B att[k].gfx = tempid; } } else if (att[k].gfx == 0xFF) { - att[k].ti.x = (int8)GB(att[k].ti.x, 0, 8); - att[k].ti.y = (int8)GB(att[k].ti.y, 0, 8); + att[k].ti.x = (int8_t)GB(att[k].ti.x, 0, 8); + att[k].ti.y = (int8_t)GB(att[k].ti.y, 0, 8); } if (as->rotation[j] == DIR_E || as->rotation[j] == DIR_W) { @@ -4109,7 +4109,7 @@ static ChangeInfoResult ObjectChangeInfo(uint id, int numinfo, int prop, ByteRea } /* Swap classid because we read it in BE. */ - uint32 classid = buf->ReadDWord(); + uint32_t classid = buf->ReadDWord(); spec->cls_id = ObjectClass::Allocate(BSWAP32(classid)); break; } @@ -4232,7 +4232,7 @@ static ChangeInfoResult RailTypeChangeInfo(uint id, int numinfo, int prop, ByteR break; case 0x09: { // Toolbar caption of railtype (sets name as well for backwards compatibility for grf ver < 8) - uint16 str = buf->ReadWord(); + uint16_t str = buf->ReadWord(); AddStringForMapping(str, &rti->strings.toolbar_caption); if (_cur.grffile->grf_version < 8) { AddStringForMapping(str, &rti->strings.name); @@ -4451,7 +4451,7 @@ static ChangeInfoResult RoadTypeChangeInfo(uint id, int numinfo, int prop, ByteR break; case 0x09: { // Toolbar caption of roadtype (sets name as well for backwards compatibility for grf ver < 8) - uint16 str = buf->ReadWord(); + uint16_t str = buf->ReadWord(); AddStringForMapping(str, &rti->strings.toolbar_caption); break; } @@ -4791,7 +4791,7 @@ static ChangeInfoResult RoadStopChangeInfo(uint id, int numinfo, int prop, ByteR rs = _cur.grffile->roadstops[id + i].get(); } - uint32 classid = buf->ReadDWord(); + uint32_t classid = buf->ReadDWord(); rs->cls_id = RoadStopClass::Allocate(BSWAP32(classid)); rs->spec_id = id + i; break; @@ -4835,7 +4835,7 @@ static ChangeInfoResult RoadStopChangeInfo(uint id, int numinfo, int prop, ByteR break; case 0x12: // General flags - rs->flags = (uint8)buf->ReadDWord(); // Future-proofing, size this as 4 bytes, but we only need one byte's worth of flags at present + rs->flags = (uint8_t)buf->ReadDWord(); // Future-proofing, size this as 4 bytes, but we only need one byte's worth of flags at present break; case 0x15: // Cost multipliers @@ -4852,7 +4852,7 @@ static ChangeInfoResult RoadStopChangeInfo(uint id, int numinfo, int prop, ByteR return ret; } -static bool HandleChangeInfoResult(const char *caller, ChangeInfoResult cir, uint8 feature, uint8 property) +static bool HandleChangeInfoResult(const char *caller, ChangeInfoResult cir, uint8_t feature, uint8_t property) { switch (cir) { default: NOT_REACHED(); @@ -4920,8 +4920,8 @@ static void FeatureChangeInfo(ByteReader *buf) }; static_assert(GSF_END == lengthof(handler)); - uint8 feature = buf->ReadByte(); - uint8 numprops = buf->ReadByte(); + uint8_t feature = buf->ReadByte(); + uint8_t numprops = buf->ReadByte(); uint numinfo = buf->ReadByte(); uint engine = buf->ReadExtendedByte(); @@ -4942,7 +4942,7 @@ static void FeatureChangeInfo(ByteReader *buf) SetBit(_cur.grffile->grf_features, feature); while (numprops-- && buf->HasData()) { - uint8 prop = buf->ReadByte(); + uint8_t prop = buf->ReadByte(); ChangeInfoResult cir = handler[feature](engine, numinfo, prop, buf); if (HandleChangeInfoResult("FeatureChangeInfo", cir, feature, prop)) return; @@ -4952,23 +4952,23 @@ static void FeatureChangeInfo(ByteReader *buf) /* Action 0x00 (GLS_SAFETYSCAN) */ static void SafeChangeInfo(ByteReader *buf) { - uint8 feature = buf->ReadByte(); - uint8 numprops = buf->ReadByte(); + uint8_t feature = buf->ReadByte(); + uint8_t numprops = buf->ReadByte(); uint numinfo = buf->ReadByte(); buf->ReadExtendedByte(); // id if (feature == GSF_BRIDGES && numprops == 1) { - uint8 prop = buf->ReadByte(); + uint8_t prop = buf->ReadByte(); /* Bridge property 0x0D is redefinition of sprite layout tables, which * is considered safe. */ if (prop == 0x0D) return; } else if (feature == GSF_GLOBALVAR && numprops == 1) { - uint8 prop = buf->ReadByte(); + uint8_t prop = buf->ReadByte(); /* Engine ID Mappings are safe, if the source is static */ if (prop == 0x11) { bool is_safe = true; for (uint i = 0; i < numinfo; i++) { - uint32 s = buf->ReadDWord(); + uint32_t s = buf->ReadDWord(); buf->ReadDWord(); // dest const GRFConfig *grfconfig = GetGRFConfig(s); if (grfconfig != nullptr && !HasBit(grfconfig->flags, GCF_STATIC)) { @@ -4989,16 +4989,16 @@ static void SafeChangeInfo(ByteReader *buf) /* Action 0x00 (GLS_RESERVE) */ static void ReserveChangeInfo(ByteReader *buf) { - uint8 feature = buf->ReadByte(); + uint8_t feature = buf->ReadByte(); if (feature != GSF_CARGOES && feature != GSF_GLOBALVAR && feature != GSF_RAILTYPES && feature != GSF_ROADTYPES && feature != GSF_TRAMTYPES) return; - uint8 numprops = buf->ReadByte(); - uint8 numinfo = buf->ReadByte(); - uint8 index = buf->ReadExtendedByte(); + uint8_t numprops = buf->ReadByte(); + uint8_t numinfo = buf->ReadByte(); + uint8_t index = buf->ReadExtendedByte(); while (numprops-- && buf->HasData()) { - uint8 prop = buf->ReadByte(); + uint8_t prop = buf->ReadByte(); ChangeInfoResult cir = CIR_SUCCESS; switch (feature) { @@ -5045,9 +5045,9 @@ static void NewSpriteSet(ByteReader *buf) * In that case, use num-dirs=4. */ - uint8 feature = buf->ReadByte(); - uint16 num_sets = buf->ReadByte(); - uint16 first_set = 0; + uint8_t feature = buf->ReadByte(); + uint16_t num_sets = buf->ReadByte(); + uint16_t first_set = 0; if (num_sets == 0 && buf->HasData(3)) { /* Extended Action1 format. @@ -5055,7 +5055,7 @@ static void NewSpriteSet(ByteReader *buf) first_set = buf->ReadExtendedByte(); num_sets = buf->ReadExtendedByte(); } - uint16 num_ents = buf->ReadExtendedByte(); + uint16_t num_ents = buf->ReadExtendedByte(); if (feature >= GSF_END) { _cur.skip_sprites = num_sets * num_ents; @@ -5079,7 +5079,7 @@ static void NewSpriteSet(ByteReader *buf) static void SkipAct1(ByteReader *buf) { buf->ReadByte(); - uint16 num_sets = buf->ReadByte(); + uint16_t num_sets = buf->ReadByte(); if (num_sets == 0 && buf->HasData(3)) { /* Extended Action1 format. @@ -5087,7 +5087,7 @@ static void SkipAct1(ByteReader *buf) buf->ReadExtendedByte(); // first_set num_sets = buf->ReadExtendedByte(); } - uint16 num_ents = buf->ReadExtendedByte(); + uint16_t num_ents = buf->ReadExtendedByte(); _cur.skip_sprites = num_sets * num_ents; @@ -5096,7 +5096,7 @@ static void SkipAct1(ByteReader *buf) /* Helper function to either create a callback or link to a previously * defined spritegroup. */ -static const SpriteGroup *GetGroupFromGroupID(byte setid, byte type, uint16 groupid) +static const SpriteGroup *GetGroupFromGroupID(byte setid, byte type, uint16_t groupid) { if (HasBit(groupid, 15)) { assert(CallbackResultSpriteGroup::CanAllocateItem()); @@ -5119,7 +5119,7 @@ static const SpriteGroup *GetGroupFromGroupID(byte setid, byte type, uint16 grou * @param spriteid Raw value from the GRF for the new spritegroup; describes either the return value or the referenced spritegroup. * @return Created spritegroup. */ -static const SpriteGroup *CreateGroupFromGroupID(byte feature, byte setid, byte type, uint16 spriteid) +static const SpriteGroup *CreateGroupFromGroupID(byte feature, byte setid, byte type, uint16_t spriteid) { if (HasBit(spriteid, 15)) { assert(CallbackResultSpriteGroup::CanAllocateItem()); @@ -5156,14 +5156,14 @@ static void NewSpriteGroup(ByteReader *buf) * V feature-specific-data (huge mess, don't even look it up --pasky) */ const SpriteGroup *act_group = nullptr; - uint8 feature = buf->ReadByte(); + uint8_t feature = buf->ReadByte(); if (feature >= GSF_END) { GrfMsg(1, "NewSpriteGroup: Unsupported feature 0x{:02X}, skipping", feature); return; } - uint8 setid = buf->ReadByte(); - uint8 type = buf->ReadByte(); + uint8_t setid = buf->ReadByte(); + uint8_t type = buf->ReadByte(); /* Sprite Groups are created here but they are allocated from a pool, so * we do not need to delete anything if there is an exception from the @@ -5239,7 +5239,7 @@ static void NewSpriteGroup(ByteReader *buf) group->calculated_result = ranges.size() == 0; /* Sort ranges ascending. When ranges overlap, this may required clamping or splitting them */ - std::vector bounds; + std::vector bounds; for (uint i = 0; i < ranges.size(); i++) { bounds.push_back(ranges[i].low); if (ranges[i].high != UINT32_MAX) bounds.push_back(ranges[i].high + 1); @@ -5249,7 +5249,7 @@ static void NewSpriteGroup(ByteReader *buf) std::vector target; for (uint j = 0; j < bounds.size(); ++j) { - uint32 v = bounds[j]; + uint32_t v = bounds[j]; const SpriteGroup *t = group->default_group; for (uint i = 0; i < ranges.size(); i++) { if (ranges[i].low <= v && v <= ranges[i].high) { @@ -5294,7 +5294,7 @@ static void NewSpriteGroup(ByteReader *buf) group->count = buf->ReadByte(); } - uint8 triggers = buf->ReadByte(); + uint8_t triggers = buf->ReadByte(); group->triggers = GB(triggers, 0, 7); group->cmp_mode = HasBit(triggers, 7) ? RSG_CMP_ALL : RSG_CMP_ANY; group->lowest_randbit = buf->ReadByte(); @@ -5345,14 +5345,14 @@ static void NewSpriteGroup(ByteReader *buf) if (num_loaded + num_loading == 1) { /* Avoid creating 'Real' sprite group if only one option. */ - uint16 spriteid = buf->ReadWord(); + uint16_t spriteid = buf->ReadWord(); act_group = CreateGroupFromGroupID(feature, setid, type, spriteid); GrfMsg(8, "NewSpriteGroup: one result, skipping RealSpriteGroup = subset {}", spriteid); break; } - std::vector loaded; - std::vector loading; + std::vector loaded; + std::vector loading; for (uint i = 0; i < num_loaded; i++) { loaded.push_back(buf->ReadWord()); @@ -5379,12 +5379,12 @@ static void NewSpriteGroup(ByteReader *buf) group->nfo_line = _cur.nfo_line; act_group = group; - for (uint16 spriteid : loaded) { + for (uint16_t spriteid : loaded) { const SpriteGroup *t = CreateGroupFromGroupID(feature, setid, type, spriteid); group->loaded.push_back(t); } - for (uint16 spriteid : loading) { + for (uint16_t spriteid : loading) { const SpriteGroup *t = CreateGroupFromGroupID(feature, setid, type, spriteid); group->loading.push_back(t); } @@ -5397,7 +5397,7 @@ static void NewSpriteGroup(ByteReader *buf) case GSF_OBJECTS: case GSF_INDUSTRYTILES: case GSF_ROADSTOPS: { - byte num_building_sprites = std::max((uint8)1, type); + byte num_building_sprites = std::max((uint8_t)1, type); assert(TileLayoutSpriteGroup::CanAllocateItem()); TileLayoutSpriteGroup *group = new TileLayoutSpriteGroup(); @@ -5423,7 +5423,7 @@ static void NewSpriteGroup(ByteReader *buf) if (type == 0) { group->num_input = 3; for (uint i = 0; i < 3; i++) { - group->subtract_input[i] = (int16)buf->ReadWord(); // signed + group->subtract_input[i] = (int16_t)buf->ReadWord(); // signed } group->num_output = 2; for (uint i = 0; i < 2; i++) { @@ -5499,7 +5499,7 @@ static void NewSpriteGroup(ByteReader *buf) _cur.spritegroups[setid] = act_group; } -static CargoID TranslateCargo(uint8 feature, uint8 ctype) +static CargoID TranslateCargo(uint8_t feature, uint8_t ctype) { /* Special cargo types for purchase list and stations */ if ((feature == GSF_STATIONS || feature == GSF_ROADSTOPS) && ctype == 0xFE) return CT_DEFAULT_NA; @@ -5547,7 +5547,7 @@ static CargoID TranslateCargo(uint8 feature, uint8 ctype) } -static bool IsValidGroupID(uint16 groupid, const char *function) +static bool IsValidGroupID(uint16_t groupid, const char *function) { if (groupid > MAX_SPRITEGROUP || _cur.spritegroups[groupid] == nullptr) { GrfMsg(1, "{}: Spritegroup 0x{:04X} out of range or empty, skipping.", function, groupid); @@ -5557,7 +5557,7 @@ static bool IsValidGroupID(uint16 groupid, const char *function) return true; } -static void VehicleMapSpriteGroup(ByteReader *buf, byte feature, uint8 idcount) +static void VehicleMapSpriteGroup(ByteReader *buf, byte feature, uint8_t idcount) { static EngineID *last_engines; static uint last_engines_count; @@ -5598,10 +5598,10 @@ static void VehicleMapSpriteGroup(ByteReader *buf, byte feature, uint8 idcount) if (!wagover) last_engines[i] = engines[i]; } - uint8 cidcount = buf->ReadByte(); + uint8_t cidcount = buf->ReadByte(); for (uint c = 0; c < cidcount; c++) { - uint8 ctype = buf->ReadByte(); - uint16 groupid = buf->ReadWord(); + uint8_t ctype = buf->ReadByte(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "VehicleMapSpriteGroup")) continue; GrfMsg(8, "VehicleMapSpriteGroup: * [{}] Cargo type 0x{:X}, group id 0x{:02X}", c, ctype, groupid); @@ -5622,7 +5622,7 @@ static void VehicleMapSpriteGroup(ByteReader *buf, byte feature, uint8 idcount) } } - uint16 groupid = buf->ReadWord(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "VehicleMapSpriteGroup")) return; GrfMsg(8, "-- Default group id 0x{:04X}", groupid); @@ -5640,7 +5640,7 @@ static void VehicleMapSpriteGroup(ByteReader *buf, byte feature, uint8 idcount) } -static void CanalMapSpriteGroup(ByteReader *buf, uint8 idcount) +static void CanalMapSpriteGroup(ByteReader *buf, uint8_t idcount) { std::vector cfs; cfs.reserve(idcount); @@ -5648,10 +5648,10 @@ static void CanalMapSpriteGroup(ByteReader *buf, uint8 idcount) cfs.push_back(buf->ReadExtendedByte()); } - uint8 cidcount = buf->ReadByte(); + uint8_t cidcount = buf->ReadByte(); buf->Skip(cidcount * 3); - uint16 groupid = buf->ReadWord(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "CanalMapSpriteGroup")) return; for (auto &cf : cfs) { @@ -5666,7 +5666,7 @@ static void CanalMapSpriteGroup(ByteReader *buf, uint8 idcount) } -static void StationMapSpriteGroup(ByteReader *buf, uint8 idcount) +static void StationMapSpriteGroup(ByteReader *buf, uint8_t idcount) { if (_cur.grffile->stations.empty()) { GrfMsg(1, "StationMapSpriteGroup: No stations defined, skipping"); @@ -5679,10 +5679,10 @@ static void StationMapSpriteGroup(ByteReader *buf, uint8 idcount) stations.push_back(buf->ReadExtendedByte()); } - uint8 cidcount = buf->ReadByte(); + uint8_t cidcount = buf->ReadByte(); for (uint c = 0; c < cidcount; c++) { - uint8 ctype = buf->ReadByte(); - uint16 groupid = buf->ReadWord(); + uint8_t ctype = buf->ReadByte(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "StationMapSpriteGroup")) continue; ctype = TranslateCargo(GSF_STATIONS, ctype); @@ -5700,7 +5700,7 @@ static void StationMapSpriteGroup(ByteReader *buf, uint8 idcount) } } - uint16 groupid = buf->ReadWord(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "StationMapSpriteGroup")) return; for (auto &station : stations) { @@ -5724,7 +5724,7 @@ static void StationMapSpriteGroup(ByteReader *buf, uint8 idcount) } -static void TownHouseMapSpriteGroup(ByteReader *buf, uint8 idcount) +static void TownHouseMapSpriteGroup(ByteReader *buf, uint8_t idcount) { if (_cur.grffile->housespec.empty()) { GrfMsg(1, "TownHouseMapSpriteGroup: No houses defined, skipping"); @@ -5738,10 +5738,10 @@ static void TownHouseMapSpriteGroup(ByteReader *buf, uint8 idcount) } /* Skip the cargo type section, we only care about the default group */ - uint8 cidcount = buf->ReadByte(); + uint8_t cidcount = buf->ReadByte(); buf->Skip(cidcount * 3); - uint16 groupid = buf->ReadWord(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "TownHouseMapSpriteGroup")) return; for (auto &house : houses) { @@ -5756,7 +5756,7 @@ static void TownHouseMapSpriteGroup(ByteReader *buf, uint8 idcount) } } -static void IndustryMapSpriteGroup(ByteReader *buf, uint8 idcount) +static void IndustryMapSpriteGroup(ByteReader *buf, uint8_t idcount) { if (_cur.grffile->industryspec.empty()) { GrfMsg(1, "IndustryMapSpriteGroup: No industries defined, skipping"); @@ -5770,10 +5770,10 @@ static void IndustryMapSpriteGroup(ByteReader *buf, uint8 idcount) } /* Skip the cargo type section, we only care about the default group */ - uint8 cidcount = buf->ReadByte(); + uint8_t cidcount = buf->ReadByte(); buf->Skip(cidcount * 3); - uint16 groupid = buf->ReadWord(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "IndustryMapSpriteGroup")) return; for (auto &industry : industries) { @@ -5788,7 +5788,7 @@ static void IndustryMapSpriteGroup(ByteReader *buf, uint8 idcount) } } -static void IndustrytileMapSpriteGroup(ByteReader *buf, uint8 idcount) +static void IndustrytileMapSpriteGroup(ByteReader *buf, uint8_t idcount) { if (_cur.grffile->indtspec.empty()) { GrfMsg(1, "IndustrytileMapSpriteGroup: No industry tiles defined, skipping"); @@ -5802,10 +5802,10 @@ static void IndustrytileMapSpriteGroup(ByteReader *buf, uint8 idcount) } /* Skip the cargo type section, we only care about the default group */ - uint8 cidcount = buf->ReadByte(); + uint8_t cidcount = buf->ReadByte(); buf->Skip(cidcount * 3); - uint16 groupid = buf->ReadWord(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "IndustrytileMapSpriteGroup")) return; for (auto &indtile : indtiles) { @@ -5820,7 +5820,7 @@ static void IndustrytileMapSpriteGroup(ByteReader *buf, uint8 idcount) } } -static void CargoMapSpriteGroup(ByteReader *buf, uint8 idcount) +static void CargoMapSpriteGroup(ByteReader *buf, uint8_t idcount) { std::vector cargoes; cargoes.reserve(idcount); @@ -5829,10 +5829,10 @@ static void CargoMapSpriteGroup(ByteReader *buf, uint8 idcount) } /* Skip the cargo type section, we only care about the default group */ - uint8 cidcount = buf->ReadByte(); + uint8_t cidcount = buf->ReadByte(); buf->Skip(cidcount * 3); - uint16 groupid = buf->ReadWord(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "CargoMapSpriteGroup")) return; for (auto &cid : cargoes) { @@ -5847,7 +5847,7 @@ static void CargoMapSpriteGroup(ByteReader *buf, uint8 idcount) } } -static void ObjectMapSpriteGroup(ByteReader *buf, uint8 idcount) +static void ObjectMapSpriteGroup(ByteReader *buf, uint8_t idcount) { if (_cur.grffile->objectspec.empty()) { GrfMsg(1, "ObjectMapSpriteGroup: No object tiles defined, skipping"); @@ -5860,10 +5860,10 @@ static void ObjectMapSpriteGroup(ByteReader *buf, uint8 idcount) objects.push_back(buf->ReadExtendedByte()); } - uint8 cidcount = buf->ReadByte(); + uint8_t cidcount = buf->ReadByte(); for (uint c = 0; c < cidcount; c++) { - uint8 ctype = buf->ReadByte(); - uint16 groupid = buf->ReadWord(); + uint8_t ctype = buf->ReadByte(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "ObjectMapSpriteGroup")) continue; /* The only valid option here is purchase list sprite groups. */ @@ -5884,7 +5884,7 @@ static void ObjectMapSpriteGroup(ByteReader *buf, uint8 idcount) } } - uint16 groupid = buf->ReadWord(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "ObjectMapSpriteGroup")) return; for (auto &object : objects) { @@ -5906,19 +5906,19 @@ static void ObjectMapSpriteGroup(ByteReader *buf, uint8 idcount) } } -static void RailTypeMapSpriteGroup(ByteReader *buf, uint8 idcount) +static void RailTypeMapSpriteGroup(ByteReader *buf, uint8_t idcount) { - std::vector railtypes; + std::vector railtypes; railtypes.reserve(idcount); for (uint i = 0; i < idcount; i++) { uint16_t id = buf->ReadExtendedByte(); railtypes.push_back(id < RAILTYPE_END ? _cur.grffile->railtype_map[id] : INVALID_RAILTYPE); } - uint8 cidcount = buf->ReadByte(); + uint8_t cidcount = buf->ReadByte(); for (uint c = 0; c < cidcount; c++) { - uint8 ctype = buf->ReadByte(); - uint16 groupid = buf->ReadWord(); + uint8_t ctype = buf->ReadByte(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "RailTypeMapSpriteGroup")) continue; if (ctype >= RTSG_END) continue; @@ -5938,21 +5938,21 @@ static void RailTypeMapSpriteGroup(ByteReader *buf, uint8 idcount) buf->ReadWord(); } -static void RoadTypeMapSpriteGroup(ByteReader *buf, uint8 idcount, RoadTramType rtt) +static void RoadTypeMapSpriteGroup(ByteReader *buf, uint8_t idcount, RoadTramType rtt) { RoadType *type_map = (rtt == RTT_TRAM) ? _cur.grffile->tramtype_map : _cur.grffile->roadtype_map; - std::vector roadtypes; + std::vector roadtypes; roadtypes.reserve(idcount); for (uint i = 0; i < idcount; i++) { uint16_t id = buf->ReadExtendedByte(); roadtypes.push_back(id < ROADTYPE_END ? type_map[id] : INVALID_ROADTYPE); } - uint8 cidcount = buf->ReadByte(); + uint8_t cidcount = buf->ReadByte(); for (uint c = 0; c < cidcount; c++) { - uint8 ctype = buf->ReadByte(); - uint16 groupid = buf->ReadWord(); + uint8_t ctype = buf->ReadByte(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "RoadTypeMapSpriteGroup")) continue; if (ctype >= ROTSG_END) continue; @@ -5972,7 +5972,7 @@ static void RoadTypeMapSpriteGroup(ByteReader *buf, uint8 idcount, RoadTramType buf->ReadWord(); } -static void AirportMapSpriteGroup(ByteReader *buf, uint8 idcount) +static void AirportMapSpriteGroup(ByteReader *buf, uint8_t idcount) { if (_cur.grffile->airportspec.empty()) { GrfMsg(1, "AirportMapSpriteGroup: No airports defined, skipping"); @@ -5986,10 +5986,10 @@ static void AirportMapSpriteGroup(ByteReader *buf, uint8 idcount) } /* Skip the cargo type section, we only care about the default group */ - uint8 cidcount = buf->ReadByte(); + uint8_t cidcount = buf->ReadByte(); buf->Skip(cidcount * 3); - uint16 groupid = buf->ReadWord(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "AirportMapSpriteGroup")) return; for (auto &airport : airports) { @@ -6004,7 +6004,7 @@ static void AirportMapSpriteGroup(ByteReader *buf, uint8 idcount) } } -static void AirportTileMapSpriteGroup(ByteReader *buf, uint8 idcount) +static void AirportTileMapSpriteGroup(ByteReader *buf, uint8_t idcount) { if (_cur.grffile->airtspec.empty()) { GrfMsg(1, "AirportTileMapSpriteGroup: No airport tiles defined, skipping"); @@ -6018,10 +6018,10 @@ static void AirportTileMapSpriteGroup(ByteReader *buf, uint8 idcount) } /* Skip the cargo type section, we only care about the default group */ - uint8 cidcount = buf->ReadByte(); + uint8_t cidcount = buf->ReadByte(); buf->Skip(cidcount * 3); - uint16 groupid = buf->ReadWord(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "AirportTileMapSpriteGroup")) return; for (auto &airptile : airptiles) { @@ -6036,7 +6036,7 @@ static void AirportTileMapSpriteGroup(ByteReader *buf, uint8 idcount) } } -static void RoadStopMapSpriteGroup(ByteReader *buf, uint8 idcount) +static void RoadStopMapSpriteGroup(ByteReader *buf, uint8_t idcount) { if (_cur.grffile->roadstops.empty()) { GrfMsg(1, "RoadStopMapSpriteGroup: No roadstops defined, skipping"); @@ -6049,10 +6049,10 @@ static void RoadStopMapSpriteGroup(ByteReader *buf, uint8 idcount) roadstops.push_back(buf->ReadExtendedByte()); } - uint8 cidcount = buf->ReadByte(); + uint8_t cidcount = buf->ReadByte(); for (uint c = 0; c < cidcount; c++) { - uint8 ctype = buf->ReadByte(); - uint16 groupid = buf->ReadWord(); + uint8_t ctype = buf->ReadByte(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "RoadStopMapSpriteGroup")) continue; ctype = TranslateCargo(GSF_ROADSTOPS, ctype); @@ -6070,7 +6070,7 @@ static void RoadStopMapSpriteGroup(ByteReader *buf, uint8 idcount) } } - uint16 groupid = buf->ReadWord(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "RoadStopMapSpriteGroup")) return; for (auto &roadstop : roadstops) { @@ -6110,8 +6110,8 @@ static void FeatureMapSpriteGroup(ByteReader *buf) * W cid cargo ID (sprite group ID) for this type of cargo * W def-cid default cargo ID (sprite group ID) */ - uint8 feature = buf->ReadByte(); - uint8 idcount = buf->ReadByte(); + uint8_t feature = buf->ReadByte(); + uint8_t idcount = buf->ReadByte(); if (feature >= GSF_END) { GrfMsg(1, "FeatureMapSpriteGroup: Unsupported feature 0x{:02X}, skipping", feature); @@ -6122,7 +6122,7 @@ static void FeatureMapSpriteGroup(ByteReader *buf) if (idcount == 0) { /* Skip number of cargo ids? */ buf->ReadByte(); - uint16 groupid = buf->ReadWord(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "FeatureMapSpriteGroup")) return; GrfMsg(6, "FeatureMapSpriteGroup: Adding generic feature callback for feature 0x{:02X}", feature); @@ -6223,16 +6223,16 @@ static void FeatureNewName(ByteReader *buf) bool new_scheme = _cur.grffile->grf_version >= 7; - uint8 feature = buf->ReadByte(); + uint8_t feature = buf->ReadByte(); if (feature >= GSF_END && feature != 0x48) { GrfMsg(1, "FeatureNewName: Unsupported feature 0x{:02X}, skipping", feature); return; } - uint8 lang = buf->ReadByte(); - uint8 num = buf->ReadByte(); + uint8_t lang = buf->ReadByte(); + uint8_t num = buf->ReadByte(); bool generic = HasBit(lang, 7); - uint16 id; + uint16_t id; if (generic) { id = buf->ReadWord(); } else if (feature <= GSF_AIRCRAFT) { @@ -6243,7 +6243,7 @@ static void FeatureNewName(ByteReader *buf) ClrBit(lang, 7); - uint16 endid = id + num; + uint16_t endid = id + num; GrfMsg(6, "FeatureNewName: About to rename engines {}..{} (feature 0x{:02X}) in language 0x{:02X}", id, endid, feature, lang); @@ -6324,7 +6324,7 @@ static void FeatureNewName(ByteReader *buf) * @param name Used for error warnings. * @return The number of sprites that is going to be skipped. */ -static uint16 SanitizeSpriteOffset(uint16& num, uint16 offset, int max_sprites, const char *name) +static uint16_t SanitizeSpriteOffset(uint16_t &num, uint16_t offset, int max_sprites, const char *name) { if (offset >= max_sprites) { @@ -6355,8 +6355,8 @@ enum Action5BlockType { struct Action5Type { Action5BlockType block_type; ///< How is this Action5 type processed? SpriteID sprite_base; ///< Load the sprites starting from this sprite. - uint16 min_sprites; ///< If the Action5 contains less sprites, the whole block will be ignored. - uint16 max_sprites; ///< If the Action5 contains more sprites, only the first max_sprites sprites will be used. + uint16_t min_sprites; ///< If the Action5 contains less sprites, the whole block will be ignored. + uint16_t max_sprites; ///< If the Action5 contains more sprites, only the first max_sprites sprites will be used. const char *name; ///< Name for error messages. }; @@ -6399,9 +6399,9 @@ static void GraphicsNew(ByteReader *buf) * E num-sprites How many sprites are in this set? * V other data Graphics type specific data. Currently unused. */ - uint8 type = buf->ReadByte(); - uint16 num = buf->ReadExtendedByte(); - uint16 offset = HasBit(type, 7) ? buf->ReadExtendedByte() : 0; + uint8_t type = buf->ReadByte(); + uint16_t num = buf->ReadExtendedByte(); + uint16_t offset = HasBit(type, 7) ? buf->ReadExtendedByte() : 0; ClrBit(type, 7); // Clear the high bit as that only indicates whether there is an offset. if ((type == 0x0D) && (num == 10) && HasBit(_cur.grfconfig->flags, GCF_SYSTEM)) { @@ -6448,7 +6448,7 @@ static void GraphicsNew(ByteReader *buf) } /* Load at most max_sprites sprites. Skip remaining sprites. (for compatibility with TTDP and future extensions) */ - uint16 skip_num = SanitizeSpriteOffset(num, offset, action5_type->max_sprites, action5_type->name); + uint16_t skip_num = SanitizeSpriteOffset(num, offset, action5_type->max_sprites, action5_type->name); SpriteID replace = action5_type->sprite_base + offset; /* Load sprites starting from , then skip sprites. */ @@ -6502,7 +6502,7 @@ static void SkipAct5(ByteReader *buf) * @param grffile NewGRF querying the variable * @return true iff the variable is known and the value is returned in 'value'. */ -bool GetGlobalVariable(byte param, uint32 *value, const GRFFile *grffile) +bool GetGlobalVariable(byte param, uint32_t *value, const GRFFile *grffile) { switch (param) { case 0x00: // current date @@ -6634,16 +6634,16 @@ bool GetGlobalVariable(byte param, uint32 *value, const GRFFile *grffile) } } -static uint32 GetParamVal(byte param, uint32 *cond_val) +static uint32_t GetParamVal(byte param, uint32_t *cond_val) { /* First handle variable common with VarAction2 */ - uint32 value; + uint32_t value; if (GetGlobalVariable(param - 0x80, &value, _cur.grffile)) return value; /* Non-common variable */ switch (param) { case 0x84: { // GRF loading stage - uint32 res = 0; + uint32_t res = 0; if (_cur.stage > GLS_INIT) SetBit(res, 0); if (_cur.stage == GLS_RESERVE) SetBit(res, 8); @@ -6656,8 +6656,8 @@ static uint32 GetParamVal(byte param, uint32 *cond_val) /* Supported in Action 0x07 and 0x09, not 0x0D */ return 0; } else { - uint32 index = *cond_val / 0x20; - uint32 param_val = index < lengthof(_ttdpatch_flags) ? _ttdpatch_flags[index] : 0; + uint32_t index = *cond_val / 0x20; + uint32_t param_val = index < lengthof(_ttdpatch_flags) ? _ttdpatch_flags[index] : 0; *cond_val %= 0x20; return param_val; } @@ -6694,8 +6694,8 @@ static void CfgApply(ByteReader *buf) /* Preload the next sprite */ SpriteFile &file = *_cur.file; size_t pos = file.GetPos(); - uint32 num = file.GetContainerVersion() >= 2 ? file.ReadDword() : file.ReadWord(); - uint8 type = file.ReadByte(); + uint32_t num = file.GetContainerVersion() >= 2 ? file.ReadDword() : file.ReadWord(); + uint8_t type = file.ReadByte(); /* Check if the sprite is a pseudo sprite. We can't operate on real sprites. */ if (type != 0xFF) { @@ -6754,7 +6754,7 @@ static void CfgApply(ByteReader *buf) bool carry = false; for (i = 0; i < param_size && offset + i < num; i++) { - uint32 value = GetParamVal(param_num + i / 4, nullptr); + uint32_t value = GetParamVal(param_num + i / 4, nullptr); /* Reset carry flag for each iteration of the variable (only really * matters if param_size is greater than 4) */ if (i % 4 == 0) carry = false; @@ -6797,13 +6797,13 @@ static void SkipIf(ByteReader *buf) * B condition-type * V value * B num-sprites */ - uint32 cond_val = 0; - uint32 mask = 0; + uint32_t cond_val = 0; + uint32_t mask = 0; bool result; - uint8 param = buf->ReadByte(); - uint8 paramsize = buf->ReadByte(); - uint8 condtype = buf->ReadByte(); + uint8_t param = buf->ReadByte(); + uint8_t paramsize = buf->ReadByte(); + uint8_t condtype = buf->ReadByte(); if (condtype < 2) { /* Always 1 for bit tests, the given value should be ignored. */ @@ -6903,7 +6903,7 @@ static void SkipIf(ByteReader *buf) } } else { /* Tests that use 'param' and are not GRF ID checks. */ - uint32 param_val = GetParamVal(param, &cond_val); // cond_val is modified for param == 0x85 + uint32_t param_val = GetParamVal(param, &cond_val); // cond_val is modified for param == 0x85 switch (condtype) { case 0x00: result = !!(param_val & (1 << cond_val)); break; @@ -6926,7 +6926,7 @@ static void SkipIf(ByteReader *buf) return; } - uint8 numsprites = buf->ReadByte(); + uint8_t numsprites = buf->ReadByte(); /* numsprites can be a GOTO label if it has been defined in the GRF * file. The jump will always be the first matching label that follows @@ -6971,8 +6971,8 @@ static void SkipIf(ByteReader *buf) /* Action 0x08 (GLS_FILESCAN) */ static void ScanInfo(ByteReader *buf) { - uint8 grf_version = buf->ReadByte(); - uint32 grfid = buf->ReadDWord(); + uint8_t grf_version = buf->ReadByte(); + uint32_t grfid = buf->ReadDWord(); const char *name = buf->ReadString(); _cur.grfconfig->ident.grfid = grfid; @@ -7006,8 +7006,8 @@ static void GRFInfo(ByteReader *buf) * S name name of this .grf set * S info string describing the set, and e.g. author and copyright */ - uint8 version = buf->ReadByte(); - uint32 grfid = buf->ReadDWord(); + uint8_t version = buf->ReadByte(); + uint32_t grfid = buf->ReadDWord(); const char *name = buf->ReadString(); if (_cur.stage < GLS_RESERVE && _cur.grfconfig->status != GCS_UNKNOWN) { @@ -7038,11 +7038,11 @@ static void SpriteReplace(ByteReader *buf) * B num-sprites How many sprites are in this set * W first-sprite First sprite number to replace */ - uint8 num_sets = buf->ReadByte(); + uint8_t num_sets = buf->ReadByte(); for (uint i = 0; i < num_sets; i++) { - uint8 num_sprites = buf->ReadByte(); - uint16 first_sprite = buf->ReadWord(); + uint8_t num_sprites = buf->ReadByte(); + uint16_t first_sprite = buf->ReadWord(); GrfMsg(2, "SpriteReplace: [Set {}] Changing {} sprites, beginning with {}", i, num_sprites, first_sprite @@ -7065,7 +7065,7 @@ static void SpriteReplace(ByteReader *buf) /* Action 0x0A (SKIP) */ static void SkipActA(ByteReader *buf) { - uint8 num_sets = buf->ReadByte(); + uint8_t num_sets = buf->ReadByte(); for (uint i = 0; i < num_sets; i++) { /* Skip the sprites this replaces */ @@ -7201,7 +7201,7 @@ static void GRFComment(ByteReader *buf) /* Action 0x0D (GLS_SAFETYSCAN) */ static void SafeParamSet(ByteReader *buf) { - uint8 target = buf->ReadByte(); + uint8_t target = buf->ReadByte(); /* Writing GRF parameters and some bits of 'misc GRF features' are safe. */ if (target < 0x80 || target == 0x9E) return; @@ -7218,7 +7218,7 @@ static void SafeParamSet(ByteReader *buf) } -static uint32 GetPatchVariable(uint8 param) +static uint32_t GetPatchVariable(uint8_t param) { switch (param) { /* start year - 1920 */ @@ -7296,7 +7296,7 @@ static uint32 GetPatchVariable(uint8 param) } -static uint32 PerformGRM(uint32 *grm, uint16 num_ids, uint16 count, uint8 op, uint8 target, const char *type) +static uint32_t PerformGRM(uint32_t *grm, uint16_t num_ids, uint16_t count, uint8_t op, uint8_t target, const char *type) { uint start = 0; uint size = 0; @@ -7368,12 +7368,12 @@ static void ParamSet(ByteReader *buf) * (source2 like in 05, and source1 as well) */ - uint8 target = buf->ReadByte(); - uint8 oper = buf->ReadByte(); - uint32 src1 = buf->ReadByte(); - uint32 src2 = buf->ReadByte(); + uint8_t target = buf->ReadByte(); + uint8_t oper = buf->ReadByte(); + uint32_t src1 = buf->ReadByte(); + uint32_t src2 = buf->ReadByte(); - uint32 data = 0; + uint32_t data = 0; if (buf->Remaining() >= 4) data = buf->ReadDWord(); /* You can add 80 to the operation to make it apply only if the target @@ -7398,9 +7398,9 @@ static void ParamSet(ByteReader *buf) src1 = GetPatchVariable(src1); } else { /* GRF Resource Management */ - uint8 op = src1; - uint8 feature = GB(data, 8, 8); - uint16 count = GB(data, 16, 16); + uint8_t op = src1; + uint8_t feature = GB(data, 8, 8); + uint16_t count = GB(data, 16, 16); if (_cur.stage == GLS_RESERVE) { if (feature == 0x08) { @@ -7502,7 +7502,7 @@ static void ParamSet(ByteReader *buf) src2 = (src2 == 0xFF) ? data : GetParamVal(src2, nullptr); } - uint32 res; + uint32_t res; switch (oper) { case 0x00: res = src1; @@ -7521,22 +7521,22 @@ static void ParamSet(ByteReader *buf) break; case 0x04: - res = (int32)src1 * (int32)src2; + res = (int32_t)src1 * (int32_t)src2; break; case 0x05: - if ((int32)src2 < 0) { - res = src1 >> -(int32)src2; + if ((int32_t)src2 < 0) { + res = src1 >> -(int32_t)src2; } else { res = src1 << (src2 & 0x1F); // Same behaviour as in EvalAdjustT, mask 'value' to 5 bits, which should behave the same on all architectures. } break; case 0x06: - if ((int32)src2 < 0) { - res = (int32)src1 >> -(int32)src2; + if ((int32_t)src2 < 0) { + res = (int32_t)src1 >> -(int32_t)src2; } else { - res = (int32)src1 << (src2 & 0x1F); // Same behaviour as in EvalAdjustT, mask 'value' to 5 bits, which should behave the same on all architectures. + res = (int32_t)src1 << (src2 & 0x1F); // Same behaviour as in EvalAdjustT, mask 'value' to 5 bits, which should behave the same on all architectures. } break; @@ -7560,7 +7560,7 @@ static void ParamSet(ByteReader *buf) if (src2 == 0) { res = src1; } else { - res = (int32)src1 / (int32)src2; + res = (int32_t)src1 / (int32_t)src2; } break; @@ -7576,7 +7576,7 @@ static void ParamSet(ByteReader *buf) if (src2 == 0) { res = src1; } else { - res = (int32)src1 % (int32)src2; + res = (int32_t)src1 % (int32_t)src2; } break; @@ -7620,7 +7620,7 @@ static void ParamSet(ByteReader *buf) /* Only copy safe bits for static grfs */ if (HasBit(_cur.grfconfig->flags, GCF_STATIC)) { - uint32 safe_bits = 0; + uint32_t safe_bits = 0; SetBit(safe_bits, GMB_SECOND_ROCKY_TILE_SET); _misc_grf_features = (_misc_grf_features & ~safe_bits) | (res & safe_bits); @@ -7653,10 +7653,10 @@ static void SafeGRFInhibit(ByteReader *buf) * B num Number of GRFIDs that follow * D grfids GRFIDs of the files to deactivate */ - uint8 num = buf->ReadByte(); + uint8_t num = buf->ReadByte(); for (uint i = 0; i < num; i++) { - uint32 grfid = buf->ReadDWord(); + uint32_t grfid = buf->ReadDWord(); /* GRF is unsafe it if tries to deactivate other GRFs */ if (grfid != _cur.grfconfig->ident.grfid) { @@ -7678,10 +7678,10 @@ static void GRFInhibit(ByteReader *buf) * B num Number of GRFIDs that follow * D grfids GRFIDs of the files to deactivate */ - uint8 num = buf->ReadByte(); + uint8_t num = buf->ReadByte(); for (uint i = 0; i < num; i++) { - uint32 grfid = buf->ReadDWord(); + uint32_t grfid = buf->ReadDWord(); GRFConfig *file = GetGRFConfig(grfid); /* Unset activation flag */ @@ -7703,7 +7703,7 @@ static void FeatureTownName(ByteReader *buf) * B num-parts Number of parts in this definition * V parts The parts */ - uint32 grfid = _cur.grffile->grfid; + uint32_t grfid = _cur.grffile->grfid; GRFTownName *townname = AddGRFTownName(grfid); @@ -7733,13 +7733,13 @@ static void FeatureTownName(ByteReader *buf) townname->styles.emplace_back(style, id); } - uint8 parts = buf->ReadByte(); + uint8_t parts = buf->ReadByte(); GrfMsg(6, "FeatureTownName: {} parts", parts); townname->partlists[id].reserve(parts); for (uint partnum = 0; partnum < parts; partnum++) { NamePartList &partlist = townname->partlists[id].emplace_back(); - uint8 texts = buf->ReadByte(); + uint8_t texts = buf->ReadByte(); partlist.bitstart = buf->ReadByte(); partlist.bitcount = buf->ReadByte(); partlist.maxprob = 0; @@ -7793,7 +7793,7 @@ static void DefineGotoLabel(ByteReader *buf) static void ImportGRFSound(SoundEntry *sound) { const GRFFile *file; - uint32 grfid = _cur.file->ReadDword(); + uint32_t grfid = _cur.file->ReadDword(); SoundID sound_id = _cur.file->ReadWord(); file = GetFileByGRFID(grfid); @@ -7842,7 +7842,7 @@ static void GRFSound(ByteReader *buf) * * W num Number of sound files that follow */ - uint16 num = buf->ReadWord(); + uint16_t num = buf->ReadWord(); if (num == 0) return; SoundEntry *sound; @@ -7865,7 +7865,7 @@ static void GRFSound(ByteReader *buf) size_t offs = file.GetPos(); - uint32 len = grf_container_version >= 2 ? file.ReadDword() : file.ReadWord(); + uint32_t len = grf_container_version >= 2 ? file.ReadDword() : file.ReadWord(); byte type = file.ReadByte(); if (grf_container_version >= 2 && type == 0xFD) { @@ -7877,7 +7877,7 @@ static void GRFSound(ByteReader *buf) GrfMsg(1, "GRFSound: Invalid sprite section import"); file.SkipBytes(len); } else { - uint32 id = file.ReadDword(); + uint32_t id = file.ReadDword(); if (_cur.stage == GLS_INIT) LoadGRFSound(GetGRFSpriteOffset(id), sound + i); } continue; @@ -7950,12 +7950,12 @@ static void LoadFontGlyph(ByteReader *buf) * B num_char Number of consecutive glyphs * W base_char First character index */ - uint8 num_def = buf->ReadByte(); + uint8_t num_def = buf->ReadByte(); for (uint i = 0; i < num_def; i++) { FontSize size = (FontSize)buf->ReadByte(); - uint8 num_char = buf->ReadByte(); - uint16 base_char = buf->ReadWord(); + uint8_t num_char = buf->ReadByte(); + uint16_t base_char = buf->ReadWord(); if (size >= FS_END) { GrfMsg(1, "LoadFontGlyph: Size {} is not supported, ignoring", size); @@ -7981,7 +7981,7 @@ static void SkipAct12(ByteReader *buf) * B num_char Number of consecutive glyphs * W base_char First character index */ - uint8 num_def = buf->ReadByte(); + uint8_t num_def = buf->ReadByte(); for (uint i = 0; i < num_def; i++) { /* Ignore 'size' byte */ @@ -8007,7 +8007,7 @@ static void TranslateGRFStrings(ByteReader *buf) * W offset First text ID * S text... Zero-terminated strings */ - uint32 grfid = buf->ReadDWord(); + uint32_t grfid = buf->ReadDWord(); const GRFConfig *c = GetGRFConfig(grfid); if (c == nullptr || (c->status != GCS_INITIALISED && c->status != GCS_ACTIVATED)) { GrfMsg(7, "TranslateGRFStrings: GRFID 0x{:08X} unknown, skipping action 13", BSWAP32(grfid)); @@ -8031,7 +8031,7 @@ static void TranslateGRFStrings(ByteReader *buf) * not change anything if a string has been provided specifically for this language. */ byte language = _cur.grffile->grf_version >= 8 ? buf->ReadByte() : 0x7F; byte num_strings = buf->ReadByte(); - uint16 first_id = buf->ReadWord(); + uint16_t first_id = buf->ReadWord(); if (!((first_id >= 0xD000 && first_id + num_strings <= 0xD400) || (first_id >= 0xD800 && first_id + num_strings <= 0xE000))) { GrfMsg(7, "TranslateGRFStrings: Attempting to set out-of-range string IDs in action 13 (first: 0x{:04X}, number: 0x{:02X})", first_id, num_strings); @@ -8207,8 +8207,8 @@ static bool ChangeGRFParamLimits(size_t len, ByteReader *buf) GrfMsg(2, "StaticGRFInfo: expected 8 bytes for 'INFO'->'PARA'->'LIMI' but got {}, ignoring this field", len); buf->Skip(len); } else { - uint32 min_value = buf->ReadDWord(); - uint32 max_value = buf->ReadDWord(); + uint32_t min_value = buf->ReadDWord(); + uint32_t max_value = buf->ReadDWord(); if (min_value <= max_value) { _cur_parameter->min_value = min_value; _cur_parameter->max_value = max_value; @@ -8276,7 +8276,7 @@ struct AllowedSubtags { * @param id The id for this node. * @param handler The callback function to call. */ - AllowedSubtags(uint32 id, DataHandler handler) : + AllowedSubtags(uint32_t id, DataHandler handler) : id(id), type('B') { @@ -8288,7 +8288,7 @@ struct AllowedSubtags { * @param id The id for this node. * @param handler The callback function to call. */ - AllowedSubtags(uint32 id, TextHandler handler) : + AllowedSubtags(uint32_t id, TextHandler handler) : id(id), type('T') { @@ -8300,7 +8300,7 @@ struct AllowedSubtags { * @param id The id for this node. * @param handler The callback function to call. */ - AllowedSubtags(uint32 id, BranchHandler handler) : + AllowedSubtags(uint32_t id, BranchHandler handler) : id(id), type('C') { @@ -8313,7 +8313,7 @@ struct AllowedSubtags { * @param id The id for this node. * @param subtags Array with all valid subtags. */ - AllowedSubtags(uint32 id, AllowedSubtags *subtags) : + AllowedSubtags(uint32_t id, AllowedSubtags *subtags) : id(id), type('C') { @@ -8321,7 +8321,7 @@ struct AllowedSubtags { this->handler.u.subtags = subtags; } - uint32 id; ///< The identifier for this node + uint32_t id; ///< The identifier for this node byte type; ///< The type of the node, must be one of 'C', 'B' or 'T'. union { DataHandler data; ///< Callback function for a binary node, only valid if type == 'B'. @@ -8349,7 +8349,7 @@ static bool ChangeGRFParamValueNames(ByteReader *buf) { byte type = buf->ReadByte(); while (type != 0) { - uint32 id = buf->ReadDWord(); + uint32_t id = buf->ReadDWord(); if (type != 'T' || id > _cur_parameter->max_value) { GrfMsg(2, "StaticGRFInfo: all child nodes of 'INFO'->'PARA'->param_num->'VALU' should have type 't' and the value/bit number as id"); if (!SkipUnknownInfo(buf, type)) return false; @@ -8396,7 +8396,7 @@ static bool HandleParameterInfo(ByteReader *buf) { byte type = buf->ReadByte(); while (type != 0) { - uint32 id = buf->ReadDWord(); + uint32_t id = buf->ReadDWord(); if (type != 'C' || id >= _cur.grfconfig->num_valid_params) { GrfMsg(2, "StaticGRFInfo: all child nodes of 'INFO'->'PARA' should have type 'C' and their parameter number as id"); if (!SkipUnknownInfo(buf, type)) return false; @@ -8465,7 +8465,7 @@ static bool SkipUnknownInfo(ByteReader *buf, byte type) break; case 'B': { - uint16 size = buf->ReadWord(); + uint16_t size = buf->ReadWord(); buf->Skip(size); break; } @@ -8485,7 +8485,7 @@ static bool SkipUnknownInfo(ByteReader *buf, byte type) * @param subtags Allowed subtags. * @return Whether all tags could be handled. */ -static bool HandleNode(byte type, uint32 id, ByteReader *buf, AllowedSubtags subtags[]) +static bool HandleNode(byte type, uint32_t id, ByteReader *buf, AllowedSubtags subtags[]) { uint i = 0; AllowedSubtags *tag; @@ -8527,7 +8527,7 @@ static bool HandleNodes(ByteReader *buf, AllowedSubtags subtags[]) { byte type = buf->ReadByte(); while (type != 0) { - uint32 id = buf->ReadDWord(); + uint32_t id = buf->ReadDWord(); if (!HandleNode(type, id, buf, subtags)) return false; type = buf->ReadByte(); } @@ -9063,7 +9063,7 @@ static void CalculateRefitMasks() * cargo type. Finally disable the vehicle, if there is still no cargo. */ if (!IsValidCargoID(ei->cargo_type) && ei->refit_mask != 0) { /* Figure out which CTT to use for the default cargo, if it is 'first refittable'. */ - const uint8 *cargo_map_for_first_refittable = nullptr; + const uint8_t *cargo_map_for_first_refittable = nullptr; { const GRFFile *file = _gted[engine].defaultcargo_grf; if (file == nullptr) file = e->GetGRF(); @@ -9546,7 +9546,7 @@ static void LoadNewGRFFileFromFile(GRFConfig *config, GrfLoadingStage stage, Spr /* Skip the first sprite; we don't care about how many sprites this * does contain; newest TTDPatches and George's longvehicles don't * neither, apparently. */ - uint32 num = grf_container_version >= 2 ? file.ReadDword() : file.ReadWord(); + uint32_t num = grf_container_version >= 2 ? file.ReadDword() : file.ReadWord(); if (num == 4 && file.ReadByte() == 0xFF) { file.ReadDword(); } else { @@ -9693,14 +9693,14 @@ static void FinalisePriceBaseMultipliers() { extern const PriceBaseSpec _price_base_specs[]; /** Features, to which '_grf_id_overrides' applies. Currently vehicle features only. */ - static const uint32 override_features = (1 << GSF_TRAINS) | (1 << GSF_ROADVEHICLES) | (1 << GSF_SHIPS) | (1 << GSF_AIRCRAFT); + static const uint32_t override_features = (1 << GSF_TRAINS) | (1 << GSF_ROADVEHICLES) | (1 << GSF_SHIPS) | (1 << GSF_AIRCRAFT); /* Evaluate grf overrides */ int num_grfs = (uint)_grf_files.size(); std::vector grf_overrides(num_grfs, -1); for (int i = 0; i < num_grfs; i++) { GRFFile *source = _grf_files[i]; - uint32 override = _grf_id_overrides[source->grfid]; + uint32_t override = _grf_id_overrides[source->grfid]; if (override == 0) continue; GRFFile *dest = GetFileByGRFID(override); @@ -9716,7 +9716,7 @@ static void FinalisePriceBaseMultipliers() GRFFile *source = _grf_files[i]; GRFFile *dest = _grf_files[grf_overrides[i]]; - uint32 features = (source->grf_features | dest->grf_features) & override_features; + uint32_t features = (source->grf_features | dest->grf_features) & override_features; source->grf_features |= features; dest->grf_features |= features; @@ -9734,7 +9734,7 @@ static void FinalisePriceBaseMultipliers() GRFFile *source = _grf_files[i]; GRFFile *dest = _grf_files[grf_overrides[i]]; - uint32 features = (source->grf_features | dest->grf_features) & override_features; + uint32_t features = (source->grf_features | dest->grf_features) & override_features; source->grf_features |= features; dest->grf_features |= features; @@ -9752,7 +9752,7 @@ static void FinalisePriceBaseMultipliers() GRFFile *source = _grf_files[i]; GRFFile *dest = _grf_files[grf_overrides[i]]; - uint32 features = (source->grf_features | dest->grf_features) & override_features; + uint32_t features = (source->grf_features | dest->grf_features) & override_features; source->grf_features |= features; dest->grf_features |= features; @@ -9932,7 +9932,7 @@ void LoadNewGRF(uint load_index, uint num_baseset) TimerGameCalendar::Date date = TimerGameCalendar::date; TimerGameCalendar::Year year = TimerGameCalendar::year; TimerGameCalendar::DateFract date_fract = TimerGameCalendar::date_fract; - uint64 tick_counter = TimerGameTick::counter; + uint64_t tick_counter = TimerGameTick::counter; byte display_opt = _display_opt; if (_networking) { @@ -9971,7 +9971,7 @@ void LoadNewGRF(uint load_index, uint num_baseset) } if (stage == GLS_RESERVE) { - static const uint32 overrides[][2] = { + static const uint32_t overrides[][2] = { { 0x44442202, 0x44440111 }, // UKRS addons modifies UKRS { 0x6D620402, 0x6D620401 }, // DBSetXL ECS extension modifies DBSetXL { 0x4D656f20, 0x4D656F17 }, // LV4cut modifies LV4 diff --git a/src/newgrf.h b/src/newgrf.h index af7bb4b85c..e1412e9dd1 100644 --- a/src/newgrf.h +++ b/src/newgrf.h @@ -37,8 +37,8 @@ enum CanalFeature { /** Canal properties local to the NewGRF */ struct CanalProperties { - uint8 callback_mask; ///< Bitmask of canal callbacks that have to be called. - uint8 flags; ///< Flags controlling display. + uint8_t callback_mask; ///< Bitmask of canal callbacks that have to be called. + uint8_t flags; ///< Flags controlling display. }; enum GrfLoadingStage { @@ -93,24 +93,24 @@ enum GrfSpecFeature { GSF_INVALID = 0xFF, ///< An invalid spec feature }; -static const uint32 INVALID_GRFID = 0xFFFFFFFF; +static const uint32_t INVALID_GRFID = 0xFFFFFFFF; struct GRFLabel { byte label; - uint32 nfo_line; + uint32_t nfo_line; size_t pos; - GRFLabel(byte label, uint32 nfo_line, size_t pos) : label(label), nfo_line(nfo_line), pos(pos) {} + GRFLabel(byte label, uint32_t nfo_line, size_t pos) : label(label), nfo_line(nfo_line), pos(pos) {} }; /** Dynamic data of a loaded NewGRF */ struct GRFFile : ZeroedMemoryAllocator { std::string filename; - uint32 grfid; + uint32_t grfid; byte grf_version; uint sound_offset; - uint16 num_sounds; + uint16_t num_sounds; std::vector> stations; std::vector> housespec; @@ -127,7 +127,7 @@ struct GRFFile : ZeroedMemoryAllocator { std::vector labels; ///< List of labels std::vector cargo_list; ///< Cargo translation table (local ID -> label) - uint8 cargo_map[NUM_CARGO]; ///< Inverse cargo translation table (CargoID -> local ID) + uint8_t cargo_map[NUM_CARGO]; ///< Inverse cargo translation table (CargoID -> local ID) std::vector railtype_list; ///< Railtype translation table RailType railtype_map[RAILTYPE_END]; @@ -145,14 +145,14 @@ struct GRFFile : ZeroedMemoryAllocator { int traininfo_vehicle_pitch; ///< Vertical offset for drawing train images in depot GUI and vehicle details uint traininfo_vehicle_width; ///< Width (in pixels) of a 8/8 train vehicle in depot GUI and vehicle details - uint32 grf_features; ///< Bitset of GrfSpecFeature the grf uses + uint32_t grf_features; ///< Bitset of GrfSpecFeature the grf uses PriceMultipliers price_base_multipliers; ///< Price base multipliers as set by the grf. GRFFile(const struct GRFConfig *config); ~GRFFile(); /** Get GRF Parameter with range checking */ - uint32 GetParam(uint number) const + uint32_t GetParam(uint number) const { /* Note: We implicitly test for number < this->param.size() and return 0 for invalid parameters. * In fact this is the more important test, as param is zeroed anyway. */ @@ -176,7 +176,7 @@ enum TramReplacement { struct GRFLoadedFeatures { bool has_2CC; ///< Set if any vehicle is loaded which uses 2cc (two company colours). - uint64 used_liveries; ///< Bitmask of #LiveryScheme used by the defined engines. + uint64_t used_liveries; ///< Bitmask of #LiveryScheme used by the defined engines. ShoreReplacement shore; ///< In which way shore sprites were replaced. TramReplacement tram; ///< In which way tram depots were replaced. }; @@ -204,9 +204,9 @@ void ResetPersistentNewGRFData(); void GrfMsgI(int severity, const std::string &msg); #define GrfMsg(severity, format_string, ...) GrfMsgI(severity, fmt::format(FMT_STRING(format_string), ## __VA_ARGS__)) -bool GetGlobalVariable(byte param, uint32 *value, const GRFFile *grffile); +bool GetGlobalVariable(byte param, uint32_t *value, const GRFFile *grffile); -StringID MapGRFStringID(uint32 grfid, StringID str); +StringID MapGRFStringID(uint32_t grfid, StringID str); void ShowNewGRFError(); #endif /* NEWGRF_H */ diff --git a/src/newgrf_airport.cpp b/src/newgrf_airport.cpp index 2dc2f2d847..81801739a9 100644 --- a/src/newgrf_airport.cpp +++ b/src/newgrf_airport.cpp @@ -37,9 +37,9 @@ struct AirportScopeResolver : public ScopeResolver { { } - uint32 GetRandomBits() const override; - uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; - void StorePSA(uint pos, int32 value) override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(byte variable, uint32_t parameter, bool *available) const override; + void StorePSA(uint pos, int32_t value) override; }; /** Resolver object for airports. */ @@ -47,7 +47,7 @@ struct AirportResolverObject : public ResolverObject { AirportScopeResolver airport_scope; AirportResolverObject(TileIndex tile, Station *st, byte airport_id, byte layout, - CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0); + CallbackID callback = CBID_NO_CALLBACK, uint32_t callback_param1 = 0, uint32_t callback_param2 = 0); ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { @@ -58,7 +58,7 @@ struct AirportResolverObject : public ResolverObject { } GrfSpecFeature GetFeature() const override; - uint32 GetDebugID() const override; + uint32_t GetDebugID() const override; }; /** @@ -196,7 +196,7 @@ void AirportOverrideManager::SetEntitySpec(AirportSpec *as) } } -/* virtual */ uint32 AirportScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const +/* virtual */ uint32_t AirportScopeResolver::GetVariable(byte variable, uint32_t parameter, bool *available) const { switch (variable) { case 0x40: return this->layout; @@ -223,12 +223,12 @@ GrfSpecFeature AirportResolverObject::GetFeature() const return GSF_AIRPORTS; } -uint32 AirportResolverObject::GetDebugID() const +uint32_t AirportResolverObject::GetDebugID() const { return AirportSpec::Get(this->airport_scope.airport_id)->grf_prop.local_id; } -/* virtual */ uint32 AirportScopeResolver::GetRandomBits() const +/* virtual */ uint32_t AirportScopeResolver::GetRandomBits() const { return this->st == nullptr ? 0 : this->st->random_bits; } @@ -238,7 +238,7 @@ uint32 AirportResolverObject::GetDebugID() const * @param pos Position in the persistent storage to use. * @param value Value to store. */ -/* virtual */ void AirportScopeResolver::StorePSA(uint pos, int32 value) +/* virtual */ void AirportScopeResolver::StorePSA(uint pos, int32_t value) { if (this->st == nullptr) return; @@ -247,7 +247,7 @@ uint32 AirportResolverObject::GetDebugID() const if (value == 0) return; /* Create storage on first modification. */ - uint32 grfid = (this->ro.grffile != nullptr) ? this->ro.grffile->grfid : 0; + uint32_t grfid = (this->ro.grffile != nullptr) ? this->ro.grffile->grfid : 0; assert(PersistentStorage::CanAllocateItem()); this->st->airport.psa = new PersistentStorage(grfid, GSF_AIRPORTS, this->st->airport.tile); } @@ -265,7 +265,7 @@ uint32 AirportResolverObject::GetDebugID() const * @param param2 Second parameter (var 18) of the callback. */ AirportResolverObject::AirportResolverObject(TileIndex tile, Station *st, byte airport_id, byte layout, - CallbackID callback, uint32 param1, uint32 param2) + CallbackID callback, uint32_t param1, uint32_t param2) : ResolverObject(AirportSpec::Get(airport_id)->grf_prop.grffile, callback, param1, param2), airport_scope(*this, tile, st, airport_id, layout) { this->root_spritegroup = AirportSpec::Get(airport_id)->grf_prop.spritegroup[0]; @@ -280,7 +280,7 @@ SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout) return group->GetResult(); } -uint16 GetAirportCallback(CallbackID callback, uint32 param1, uint32 param2, Station *st, TileIndex tile) +uint16_t GetAirportCallback(CallbackID callback, uint32_t param1, uint32_t param2, Station *st, TileIndex tile) { AirportResolverObject object(tile, st, st->airport.type, st->airport.layout, callback, param1, param2); return object.ResolveCallback(); @@ -293,10 +293,10 @@ uint16 GetAirportCallback(CallbackID callback, uint32 param1, uint32 param2, Sta * @param callback The callback to call. * @return The custom text. */ -StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback) +StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16_t callback) { AirportResolverObject object(INVALID_TILE, nullptr, as->GetIndex(), layout, (CallbackID)callback); - uint16 cb_res = object.ResolveCallback(); + uint16_t cb_res = object.ResolveCallback(); if (cb_res == CALLBACK_FAILED || cb_res == 0x400) return STR_UNDEFINED; if (cb_res > 0x400) { ErrorUnknownCallbackResult(as->grf_prop.grffile->grfid, callback, cb_res); diff --git a/src/newgrf_airport.h b/src/newgrf_airport.h index de3bdb4ea4..944c9cf19c 100644 --- a/src/newgrf_airport.h +++ b/src/newgrf_airport.h @@ -113,7 +113,7 @@ struct AirportSpec { TTDPAirportType ttd_airport_type; ///< ttdpatch airport type (Small/Large/Helipad/Oilrig) AirportClassID cls_id; ///< the class to which this airport type belongs SpriteID preview_sprite; ///< preview sprite for this airport - uint16 maintenance_cost; ///< maintenance cost multiplier + uint16_t maintenance_cost; ///< maintenance cost multiplier /* Newgrf data */ bool enabled; ///< Entity still available (by default true). Newgrf can disable it, though. struct GRFFileProps grf_prop; ///< Properties related to the grf file. @@ -144,6 +144,6 @@ typedef NewGRFClass AirportClass; void BindAirportSpecs(); -StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16 callback); +StringID GetAirportTextCallback(const AirportSpec *as, byte layout, uint16_t callback); #endif /* NEWGRF_AIRPORT_H */ diff --git a/src/newgrf_airporttiles.cpp b/src/newgrf_airporttiles.cpp index 08ee6a5237..0f817d3b07 100644 --- a/src/newgrf_airporttiles.cpp +++ b/src/newgrf_airporttiles.cpp @@ -23,7 +23,7 @@ #include "safeguards.h" -extern uint32 GetRelativePosition(TileIndex tile, TileIndex ind_tile); +extern uint32_t GetRelativePosition(TileIndex tile, TileIndex ind_tile); AirportTileSpec AirportTileSpec::tiles[NUM_AIRPORTTILES]; @@ -107,7 +107,7 @@ StationGfx GetTranslatedAirportTileID(StationGfx gfx) * @param grf_version8 True, if we are dealing with a new NewGRF which uses GRF version >= 8. * @return a construction of bits obeying the newgrf format */ -static uint32 GetNearbyAirportTileInformation(byte parameter, TileIndex tile, StationID index, bool grf_version8) +static uint32_t GetNearbyAirportTileInformation(byte parameter, TileIndex tile, StationID index, bool grf_version8) { if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required bool is_same_airport = (IsTileType(tile, MP_STATION) && IsAirport(tile) && GetStationIndex(tile) == index); @@ -124,7 +124,7 @@ static uint32 GetNearbyAirportTileInformation(byte parameter, TileIndex tile, St * @param cur_grfid GRFID of the current callback * @return value encoded as per NFO specs */ -static uint32 GetAirportTileIDAtOffset(TileIndex tile, const Station *st, uint32 cur_grfid) +static uint32_t GetAirportTileIDAtOffset(TileIndex tile, const Station *st, uint32_t cur_grfid) { if (!st->TileBelongsToAirport(tile)) { return 0xFFFF; @@ -159,7 +159,7 @@ static uint32 GetAirportTileIDAtOffset(TileIndex tile, const Station *st, uint32 return 0xFF << 8 | ats->grf_prop.subst_id; // so just give it the substitute } -/* virtual */ uint32 AirportTileScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const +/* virtual */ uint32_t AirportTileScopeResolver::GetVariable(byte variable, uint32_t parameter, bool *available) const { assert(this->st != nullptr); @@ -198,7 +198,7 @@ static uint32 GetAirportTileIDAtOffset(TileIndex tile, const Station *st, uint32 return UINT_MAX; } -/* virtual */ uint32 AirportTileScopeResolver::GetRandomBits() const +/* virtual */ uint32_t AirportTileScopeResolver::GetRandomBits() const { return (this->st == nullptr ? 0 : this->st->random_bits) | (this->tile == INVALID_TILE ? 0 : GetStationTileRandomBits(this->tile) << 16); } @@ -213,7 +213,7 @@ static uint32 GetAirportTileIDAtOffset(TileIndex tile, const Station *st, uint32 * @param callback_param2 Second parameter (var 18) of the callback. */ AirportTileResolverObject::AirportTileResolverObject(const AirportTileSpec *ats, TileIndex tile, Station *st, - CallbackID callback, uint32 callback_param1, uint32 callback_param2) + CallbackID callback, uint32_t callback_param1, uint32_t callback_param2) : ResolverObject(ats->grf_prop.grffile, callback, callback_param1, callback_param2), tiles_scope(*this, ats, tile, st) { this->root_spritegroup = ats->grf_prop.spritegroup[0]; @@ -224,12 +224,12 @@ GrfSpecFeature AirportTileResolverObject::GetFeature() const return GSF_AIRPORTTILES; } -uint32 AirportTileResolverObject::GetDebugID() const +uint32_t AirportTileResolverObject::GetDebugID() const { return this->tiles_scope.ats->grf_prop.local_id; } -uint16 GetAirportTileCallback(CallbackID callback, uint32 param1, uint32 param2, const AirportTileSpec *ats, Station *st, TileIndex tile, int extra_data = 0) +uint16_t GetAirportTileCallback(CallbackID callback, uint32_t param1, uint32_t param2, const AirportTileSpec *ats, Station *st, TileIndex tile, int extra_data = 0) { AirportTileResolverObject object(ats, tile, st, callback, param1, param2); return object.ResolveCallback(); @@ -259,7 +259,7 @@ bool DrawNewAirportTile(TileInfo *ti, Station *st, StationGfx gfx, const Airport bool draw_old_one = true; if (HasBit(airts->callback_mask, CBM_AIRT_DRAW_FOUNDATIONS)) { /* Called to determine the type (if any) of foundation to draw */ - uint32 callback_res = GetAirportTileCallback(CBID_AIRPTILE_DRAW_FOUNDATIONS, 0, 0, airts, st, ti->tile); + uint32_t callback_res = GetAirportTileCallback(CBID_AIRPTILE_DRAW_FOUNDATIONS, 0, 0, airts, st, ti->tile); if (callback_res != CALLBACK_FAILED) draw_old_one = ConvertBooleanCallback(airts->grf_prop.grffile, CBID_AIRPTILE_DRAW_FOUNDATIONS, callback_res); } @@ -299,7 +299,7 @@ void AirportTileAnimationTrigger(Station *st, TileIndex tile, AirpAnimationTrigg const AirportTileSpec *ats = AirportTileSpec::GetByTile(tile); if (!HasBit(ats->animation.triggers, trigger)) return; - AirportTileAnimationBase::ChangeAnimationFrame(CBID_AIRPTILE_ANIM_START_STOP, ats, st, tile, Random(), (uint8)trigger | (cargo_type << 8)); + AirportTileAnimationBase::ChangeAnimationFrame(CBID_AIRPTILE_ANIM_START_STOP, ats, st, tile, Random(), (uint8_t)trigger | (cargo_type << 8)); } void AirportAnimationTrigger(Station *st, AirpAnimationTrigger trigger, CargoID cargo_type) diff --git a/src/newgrf_airporttiles.h b/src/newgrf_airporttiles.h index e8b40468ec..90a1457b0b 100644 --- a/src/newgrf_airporttiles.h +++ b/src/newgrf_airporttiles.h @@ -37,8 +37,8 @@ struct AirportTileScopeResolver : public ScopeResolver { this->airport_id = st->airport.type; } - uint32 GetRandomBits() const override; - uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(byte variable, uint32_t parameter, bool *available) const override; }; /** Resolver for tiles of an airport. */ @@ -46,7 +46,7 @@ struct AirportTileResolverObject : public ResolverObject { AirportTileScopeResolver tiles_scope; ///< Scope resolver for the tiles. AirportTileResolverObject(const AirportTileSpec *ats, TileIndex tile, Station *st, - CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0); + CallbackID callback = CBID_NO_CALLBACK, uint32_t callback_param1 = 0, uint32_t callback_param2 = 0); ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { @@ -57,7 +57,7 @@ struct AirportTileResolverObject : public ResolverObject { } GrfSpecFeature GetFeature() const override; - uint32 GetDebugID() const override; + uint32_t GetDebugID() const override; }; /** @@ -66,8 +66,8 @@ struct AirportTileResolverObject : public ResolverObject { struct AirportTileSpec { AnimationInfo animation; ///< Information about the animation. StringID name; ///< Tile Subname string, land information on this tile will give you "AirportName (TileSubname)" - uint8 callback_mask; ///< Bitmask telling which grf callback is set - uint8 animation_special_flags; ///< Extra flags to influence the animation + uint8_t callback_mask; ///< Bitmask telling which grf callback is set + uint8_t animation_special_flags; ///< Extra flags to influence the animation bool enabled; ///< entity still available (by default true). newgrf can disable it, though GRFFileProps grf_prop; ///< properties related the the grf file diff --git a/src/newgrf_animation_base.h b/src/newgrf_animation_base.h index 92502069f9..e7ef4297e7 100644 --- a/src/newgrf_animation_base.h +++ b/src/newgrf_animation_base.h @@ -32,7 +32,7 @@ struct TileAnimationFrameAnimationHelper { * @tparam GetCallback The callback function pointer. * @tparam Tframehelper The animation frame get/set helper. */ -template +template struct AnimationBase { /** * Animate a single tile. @@ -47,9 +47,9 @@ struct AnimationBase { assert(spec != nullptr); /* Acquire the animation speed from the NewGRF. */ - uint8 animation_speed = spec->animation.speed; + uint8_t animation_speed = spec->animation.speed; if (HasBit(spec->callback_mask, Tbase::cbm_animation_speed)) { - uint16 callback = GetCallback(Tbase::cb_animation_speed, 0, 0, spec, obj, tile, extra_data); + uint16_t callback = GetCallback(Tbase::cb_animation_speed, 0, 0, spec, obj, tile, extra_data); if (callback != CALLBACK_FAILED) { if (callback >= 0x100 && spec->grf_prop.grffile->grf_version >= 8) ErrorUnknownCallbackResult(spec->grf_prop.grffile->grfid, Tbase::cb_animation_speed, callback); animation_speed = Clamp(callback & 0xFF, 0, 16); @@ -62,13 +62,13 @@ struct AnimationBase { * maximum, corresponding to around 33 minutes. */ if (TimerGameTick::counter % (1ULL << animation_speed) != 0) return; - uint8 frame = Tframehelper::Get(obj, tile); - uint8 num_frames = spec->animation.frames; + uint8_t frame = Tframehelper::Get(obj, tile); + uint8_t num_frames = spec->animation.frames; bool frame_set_by_callback = false; if (HasBit(spec->callback_mask, Tbase::cbm_animation_next_frame)) { - uint16 callback = GetCallback(Tbase::cb_animation_next_frame, random_animation ? Random() : 0, 0, spec, obj, tile, extra_data); + uint16_t callback = GetCallback(Tbase::cb_animation_next_frame, random_animation ? Random() : 0, 0, spec, obj, tile, extra_data); if (callback != CALLBACK_FAILED) { frame_set_by_callback = true; @@ -121,9 +121,9 @@ struct AnimationBase { * @param trigger What triggered this update? To be passed as parameter to the NewGRF. * @param extra_data Custom extra data for callback processing. */ - static void ChangeAnimationFrame(CallbackID cb, const Tspec *spec, Tobj *obj, TileIndex tile, uint32 random_bits, uint32 trigger, Textra extra_data = 0) + static void ChangeAnimationFrame(CallbackID cb, const Tspec *spec, Tobj *obj, TileIndex tile, uint32_t random_bits, uint32_t trigger, Textra extra_data = 0) { - uint16 callback = GetCallback(cb, random_bits, trigger, spec, obj, tile, extra_data); + uint16_t callback = GetCallback(cb, random_bits, trigger, spec, obj, tile, extra_data); if (callback == CALLBACK_FAILED) return; switch (callback & 0xFF) { diff --git a/src/newgrf_animation_type.h b/src/newgrf_animation_type.h index 699a633152..04ad501148 100644 --- a/src/newgrf_animation_type.h +++ b/src/newgrf_animation_type.h @@ -10,16 +10,16 @@ #ifndef NEWGRF_ANIMATION_TYPE_H #define NEWGRF_ANIMATION_TYPE_H -static const uint8 ANIM_STATUS_NON_LOOPING = 0x00; ///< Animation is not looping. -static const uint8 ANIM_STATUS_LOOPING = 0x01; ///< Animation is looping. -static const uint8 ANIM_STATUS_NO_ANIMATION = 0xFF; ///< There is no animation. +static const uint8_t ANIM_STATUS_NON_LOOPING = 0x00; ///< Animation is not looping. +static const uint8_t ANIM_STATUS_LOOPING = 0x01; ///< Animation is looping. +static const uint8_t ANIM_STATUS_NO_ANIMATION = 0xFF; ///< There is no animation. /** Information about animation. */ struct AnimationInfo { - uint8 frames; ///< The number of frames. - uint8 status; ///< Status; 0: no looping, 1: looping, 0xFF: no animation. - uint8 speed; ///< The speed, i.e. the amount of time between frames. - uint16 triggers; ///< The triggers that trigger animation. + uint8_t frames; ///< The number of frames. + uint8_t status; ///< Status; 0: no looping, 1: looping, 0xFF: no animation. + uint8_t speed; ///< The speed, i.e. the amount of time between frames. + uint16_t triggers; ///< The triggers that trigger animation. }; /** Animation triggers for station. */ diff --git a/src/newgrf_canal.cpp b/src/newgrf_canal.cpp index e79dd9593a..99f2ec13ca 100644 --- a/src/newgrf_canal.cpp +++ b/src/newgrf_canal.cpp @@ -29,8 +29,8 @@ struct CanalScopeResolver : public ScopeResolver { { } - uint32 GetRandomBits() const override; - uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(byte variable, uint32_t parameter, bool *available) const override; }; /** Resolver object for canals. */ @@ -39,7 +39,7 @@ struct CanalResolverObject : public ResolverObject { CanalFeature feature; CanalResolverObject(CanalFeature feature, TileIndex tile, - CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0); + CallbackID callback = CBID_NO_CALLBACK, uint32_t callback_param1 = 0, uint32_t callback_param2 = 0); ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { @@ -50,16 +50,16 @@ struct CanalResolverObject : public ResolverObject { } GrfSpecFeature GetFeature() const override; - uint32 GetDebugID() const override; + uint32_t GetDebugID() const override; }; -/* virtual */ uint32 CanalScopeResolver::GetRandomBits() const +/* virtual */ uint32_t CanalScopeResolver::GetRandomBits() const { /* Return random bits only for water tiles, not station tiles */ return IsTileType(this->tile, MP_WATER) ? GetWaterTileRandomBits(this->tile) : 0; } -/* virtual */ uint32 CanalScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const +/* virtual */ uint32_t CanalScopeResolver::GetVariable(byte variable, uint32_t parameter, bool *available) const { switch (variable) { /* Height of tile */ @@ -84,7 +84,7 @@ struct CanalResolverObject : public ResolverObject { * 5 */ case 0x82: { - uint32 connectivity = + uint32_t connectivity = (!IsWateredTile(TILE_ADDXY(tile, -1, 0), DIR_SW) << 0) // NE + (!IsWateredTile(TILE_ADDXY(tile, 0, 1), DIR_NW) << 1) // SE + (!IsWateredTile(TILE_ADDXY(tile, 1, 0), DIR_NE) << 2) // SW @@ -111,7 +111,7 @@ GrfSpecFeature CanalResolverObject::GetFeature() const return GSF_CANALS; } -uint32 CanalResolverObject::GetDebugID() const +uint32_t CanalResolverObject::GetDebugID() const { return this->feature; } @@ -125,7 +125,7 @@ uint32 CanalResolverObject::GetDebugID() const * @param callback_param2 Second parameter (var 18) of the callback. */ CanalResolverObject::CanalResolverObject(CanalFeature feature, TileIndex tile, - CallbackID callback, uint32 callback_param1, uint32 callback_param2) + CallbackID callback, uint32_t callback_param1, uint32_t callback_param2) : ResolverObject(_water_feature[feature].grffile, callback, callback_param1, callback_param2), canal_scope(*this, tile), feature(feature) { this->root_spritegroup = _water_feature[feature].group; @@ -155,7 +155,7 @@ SpriteID GetCanalSprite(CanalFeature feature, TileIndex tile) * @param tile Tile index of canal. * @return Callback result or #CALLBACK_FAILED if the callback failed. */ -static uint16 GetCanalCallback(CallbackID callback, uint32 param1, uint32 param2, CanalFeature feature, TileIndex tile) +static uint16_t GetCanalCallback(CallbackID callback, uint32_t param1, uint32_t param2, CanalFeature feature, TileIndex tile) { CanalResolverObject object(feature, tile, callback, param1, param2); return object.ResolveCallback(); @@ -171,7 +171,7 @@ static uint16 GetCanalCallback(CallbackID callback, uint32 param1, uint32 param2 uint GetCanalSpriteOffset(CanalFeature feature, TileIndex tile, uint cur_offset) { if (HasBit(_water_feature[feature].callback_mask, CBM_CANAL_SPRITE_OFFSET)) { - uint16 cb = GetCanalCallback(CBID_CANALS_SPRITE_OFFSET, cur_offset, 0, feature, tile); + uint16_t cb = GetCanalCallback(CBID_CANALS_SPRITE_OFFSET, cur_offset, 0, feature, tile); if (cb != CALLBACK_FAILED) return cur_offset + cb; } return cur_offset; diff --git a/src/newgrf_canal.h b/src/newgrf_canal.h index 05631216fa..7214499b5f 100644 --- a/src/newgrf_canal.h +++ b/src/newgrf_canal.h @@ -22,8 +22,8 @@ enum CanalFeatureFlag { struct WaterFeature { const SpriteGroup *group; ///< Sprite group to start resolving. const GRFFile *grffile; ///< NewGRF where 'group' belongs to. - uint8 callback_mask; ///< Bitmask of canal callbacks that have to be called. - uint8 flags; ///< Flags controlling display. + uint8_t callback_mask; ///< Bitmask of canal callbacks that have to be called. + uint8_t flags; ///< Flags controlling display. }; diff --git a/src/newgrf_cargo.cpp b/src/newgrf_cargo.cpp index 70b1a18d94..734c1ff025 100644 --- a/src/newgrf_cargo.cpp +++ b/src/newgrf_cargo.cpp @@ -17,10 +17,10 @@ struct CargoResolverObject : public ResolverObject { const CargoSpec *cargospec; - CargoResolverObject(const CargoSpec *cs, CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0); + CargoResolverObject(const CargoSpec *cs, CallbackID callback = CBID_NO_CALLBACK, uint32_t callback_param1 = 0, uint32_t callback_param2 = 0); GrfSpecFeature GetFeature() const override; - uint32 GetDebugID() const override; + uint32_t GetDebugID() const override; }; GrfSpecFeature CargoResolverObject::GetFeature() const @@ -28,7 +28,7 @@ GrfSpecFeature CargoResolverObject::GetFeature() const return GSF_CARGOES; } -uint32 CargoResolverObject::GetDebugID() const +uint32_t CargoResolverObject::GetDebugID() const { return this->cargospec->label; } @@ -40,7 +40,7 @@ uint32 CargoResolverObject::GetDebugID() const * @param callback_param1 First parameter (var 10) of the callback. * @param callback_param2 Second parameter (var 18) of the callback. */ -CargoResolverObject::CargoResolverObject(const CargoSpec *cs, CallbackID callback, uint32 callback_param1, uint32 callback_param2) +CargoResolverObject::CargoResolverObject(const CargoSpec *cs, CallbackID callback, uint32_t callback_param1, uint32_t callback_param2) : ResolverObject(cs->grffile, callback, callback_param1, callback_param2), cargospec(cs) { this->root_spritegroup = cs->group; @@ -61,7 +61,7 @@ SpriteID GetCustomCargoSprite(const CargoSpec *cs) } -uint16 GetCargoCallback(CallbackID callback, uint32 param1, uint32 param2, const CargoSpec *cs) +uint16_t GetCargoCallback(CallbackID callback, uint32_t param1, uint32_t param2, const CargoSpec *cs) { CargoResolverObject object(cs, callback, param1, param2); return object.ResolveCallback(); @@ -76,7 +76,7 @@ uint16 GetCargoCallback(CallbackID callback, uint32 param1, uint32 param2, const * For GRF version >= 7 \a cargo is always a translated cargo bit. * @return CargoID or CT_INVALID if the cargo is not available. */ -CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile, bool usebit) +CargoID GetCargoTranslation(uint8_t cargo, const GRFFile *grffile, bool usebit) { /* Pre-version 7 uses the 'climate dependent' ID in callbacks and properties, i.e. cargo is the cargo ID */ if (grffile->grf_version < 7 && !usebit) { diff --git a/src/newgrf_cargo.h b/src/newgrf_cargo.h index ec0e2f019e..54c9e6e834 100644 --- a/src/newgrf_cargo.h +++ b/src/newgrf_cargo.h @@ -23,7 +23,7 @@ struct CargoSpec; struct GRFFile; SpriteID GetCustomCargoSprite(const CargoSpec *cs); -uint16 GetCargoCallback(CallbackID callback, uint32 param1, uint32 param2, const CargoSpec *cs); -CargoID GetCargoTranslation(uint8 cargo, const GRFFile *grffile, bool usebit = false); +uint16_t GetCargoCallback(CallbackID callback, uint32_t param1, uint32_t param2, const CargoSpec *cs); +CargoID GetCargoTranslation(uint8_t cargo, const GRFFile *grffile, bool usebit = false); #endif /* NEWGRF_CARGO_H */ diff --git a/src/newgrf_class.h b/src/newgrf_class.h index fe94b173c5..6e375e5515 100644 --- a/src/newgrf_class.h +++ b/src/newgrf_class.h @@ -35,7 +35,7 @@ private: static void InsertDefaults(); public: - uint32 global_id; ///< Global ID for class, e.g. 'DFLT', 'WAYP', etc. + uint32_t global_id; ///< Global ID for class, e.g. 'DFLT', 'WAYP', etc. StringID name; ///< Name of this class. void Insert(Tspec *spec); @@ -53,14 +53,14 @@ public: bool IsUIAvailable(uint index) const; static void Reset(); - static Tid Allocate(uint32 global_id); + static Tid Allocate(uint32_t global_id); static void Assign(Tspec *spec); static uint GetClassCount(); static uint GetUIClassCount(); static Tid GetUIClass(uint index); static NewGRFClass *Get(Tid cls_id); - static const Tspec *GetByGrf(uint32 grfid, uint16_t local_id, int *index); + static const Tspec *GetByGrf(uint32_t grfid, uint16_t local_id, int *index); }; #endif /* NEWGRF_CLASS_H */ diff --git a/src/newgrf_class_func.h b/src/newgrf_class_func.h index 8b09a5dfa4..4e41915916 100644 --- a/src/newgrf_class_func.h +++ b/src/newgrf_class_func.h @@ -50,7 +50,7 @@ DEFINE_NEWGRF_CLASS_METHOD(void)::Reset() * @note Upon allocating the same global class ID for a * second time, this first allocation will be given. */ -DEFINE_NEWGRF_CLASS_METHOD(Tid)::Allocate(uint32 global_id) +DEFINE_NEWGRF_CLASS_METHOD(Tid)::Allocate(uint32_t global_id) { for (Tid i = (Tid)0; i < Tmax; i++) { if (classes[i].global_id == global_id) { @@ -187,7 +187,7 @@ DEFINE_NEWGRF_CLASS_METHOD(int)::GetUIFromIndex(int index) const * @param index Pointer to return the index of the spec in its class. If nullptr then not used. * @return The spec. */ -DEFINE_NEWGRF_CLASS_METHOD(const Tspec *)::GetByGrf(uint32 grfid, uint16_t local_id, int *index) +DEFINE_NEWGRF_CLASS_METHOD(const Tspec *)::GetByGrf(uint32_t grfid, uint16_t local_id, int *index) { uint j; @@ -212,7 +212,7 @@ DEFINE_NEWGRF_CLASS_METHOD(const Tspec *)::GetByGrf(uint32 grfid, uint16_t local #define INSTANTIATE_NEWGRF_CLASS_METHODS(name, Tspec, Tid, Tmax) \ template void name::ResetClass(); \ template void name::Reset(); \ - template Tid name::Allocate(uint32 global_id); \ + template Tid name::Allocate(uint32_t global_id); \ template void name::Insert(Tspec *spec); \ template void name::Assign(Tspec *spec); \ template NewGRFClass *name::Get(Tid cls_id); \ @@ -222,4 +222,4 @@ DEFINE_NEWGRF_CLASS_METHOD(const Tspec *)::GetByGrf(uint32 grfid, uint16_t local template const Tspec *name::GetSpec(uint index) const; \ template int name::GetUIFromIndex(int index) const; \ template int name::GetIndexFromUI(int ui_index) const; \ - template const Tspec *name::GetByGrf(uint32 grfid, uint16_t local_id, int *index); + template const Tspec *name::GetByGrf(uint32_t grfid, uint16_t local_id, int *index); diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp index 2b25487981..cf83224830 100644 --- a/src/newgrf_commons.cpp +++ b/src/newgrf_commons.cpp @@ -39,7 +39,7 @@ * @param maximum of entities this manager can deal with. i.e: houses = 512 * @param invalid is the ID used to identify an invalid entity id */ -OverrideManagerBase::OverrideManagerBase(uint16 offset, uint16 maximum, uint16 invalid) +OverrideManagerBase::OverrideManagerBase(uint16_t offset, uint16_t maximum, uint16_t invalid) { this->max_offset = offset; this->max_entities = maximum; @@ -59,7 +59,7 @@ OverrideManagerBase::OverrideManagerBase(uint16 offset, uint16 maximum, uint16 i * @param grfid ID of the grf file * @param entity_type original entity type */ -void OverrideManagerBase::Add(uint16_t local_id, uint32 grfid, uint entity_type) +void OverrideManagerBase::Add(uint16_t local_id, uint32_t grfid, uint entity_type) { assert(entity_type < this->max_offset); /* An override can be set only once */ @@ -78,7 +78,7 @@ void OverrideManagerBase::ResetMapping() void OverrideManagerBase::ResetOverride() { std::fill(this->entity_overrides.begin(), this->entity_overrides.end(), this->invalid_id); - std::fill(this->grfid_overrides.begin(), this->grfid_overrides.end(), uint32()); + std::fill(this->grfid_overrides.begin(), this->grfid_overrides.end(), uint32_t()); } /** @@ -87,9 +87,9 @@ void OverrideManagerBase::ResetOverride() * @param grfid ID of the grf file * @return the ID of the candidate, of the Invalid flag item ID */ -uint16 OverrideManagerBase::GetID(uint16_t grf_local_id, uint32 grfid) const +uint16_t OverrideManagerBase::GetID(uint16_t grf_local_id, uint32_t grfid) const { - for (uint16 id = 0; id < this->max_entities; id++) { + for (uint16_t id = 0; id < this->max_entities; id++) { const EntityIDMapping *map = &this->mappings[id]; if (map->entity_id == grf_local_id && map->grfid == grfid) { return id; @@ -106,9 +106,9 @@ uint16 OverrideManagerBase::GetID(uint16_t grf_local_id, uint32 grfid) const * @param substitute_id is the original entity from which data is copied for the new one * @return the proper usable slot id, or invalid marker if none is found */ -uint16 OverrideManagerBase::AddEntityID(uint16_t grf_local_id, uint32 grfid, uint16_t substitute_id) +uint16_t OverrideManagerBase::AddEntityID(uint16_t grf_local_id, uint32_t grfid, uint16_t substitute_id) { - uint16 id = this->GetID(grf_local_id, grfid); + uint16_t id = this->GetID(grf_local_id, grfid); /* Look to see if this entity has already been added. This is done * separately from the loop below in case a GRF has been deleted, and there @@ -136,7 +136,7 @@ uint16 OverrideManagerBase::AddEntityID(uint16_t grf_local_id, uint32 grfid, uin * @param entity_id ID of the entity being queried. * @return GRFID. */ -uint32 OverrideManagerBase::GetGRFID(uint16 entity_id) const +uint32_t OverrideManagerBase::GetGRFID(uint16_t entity_id) const { return this->mappings[entity_id].grfid; } @@ -146,7 +146,7 @@ uint32 OverrideManagerBase::GetGRFID(uint16 entity_id) const * @param entity_id of the entity being queried * @return mapped id */ -uint16 OverrideManagerBase::GetSubstituteID(uint16 entity_id) const +uint16_t OverrideManagerBase::GetSubstituteID(uint16_t entity_id) const { return this->mappings[entity_id].substitute_id; } @@ -185,9 +185,9 @@ void HouseOverrideManager::SetEntitySpec(const HouseSpec *hs) * @param grfid ID of the grf file * @return the ID of the candidate, of the Invalid flag item ID */ -uint16 IndustryOverrideManager::GetID(uint16_t grf_local_id, uint32 grfid) const +uint16_t IndustryOverrideManager::GetID(uint16_t grf_local_id, uint32_t grfid) const { - uint16 id = OverrideManagerBase::GetID(grf_local_id, grfid); + uint16_t id = OverrideManagerBase::GetID(grf_local_id, grfid); if (id != this->invalid_id) return id; /* No mapping found, try the overrides */ @@ -205,10 +205,10 @@ uint16 IndustryOverrideManager::GetID(uint16_t grf_local_id, uint32 grfid) const * @param substitute_id industry from which data has been copied * @return a free entity id (slotid) if ever one has been found, or Invalid_ID marker otherwise */ -uint16 IndustryOverrideManager::AddEntityID(uint16_t grf_local_id, uint32 grfid, uint16 substitute_id) +uint16_t IndustryOverrideManager::AddEntityID(uint16_t grf_local_id, uint32_t grfid, uint16_t substitute_id) { /* This entity hasn't been defined before, so give it an ID now. */ - for (uint16 id = 0; id < this->max_entities; id++) { + for (uint16_t id = 0; id < this->max_entities; id++) { /* Skip overridden industries */ if (id < this->max_offset && this->entity_overrides[id] != this->invalid_id) continue; @@ -328,7 +328,7 @@ void ObjectOverrideManager::SetEntitySpec(ObjectSpec *spec) * @return value corresponding to the grf expected format: * Terrain type: 0 normal, 1 desert, 2 rainforest, 4 on or above snowline */ -uint32 GetTerrainType(TileIndex tile, TileContext context) +uint32_t GetTerrainType(TileIndex tile, TileContext context) { switch (_settings_game.game_creation.landscape) { case LT_TROPIC: return GetTropicZone(tile); @@ -405,8 +405,8 @@ uint32 GetTerrainType(TileIndex tile, TileContext context) */ TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets, Axis axis) { - int8 x = GB(parameter, 0, 4); - int8 y = GB(parameter, 4, 4); + int8_t x = GB(parameter, 0, 4); + int8_t y = GB(parameter, 4, 4); if (signed_offsets && x >= 8) x -= 16; if (signed_offsets && y >= 8) y -= 16; @@ -426,7 +426,7 @@ TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets, Axi * @param grf_version8 True, if we are dealing with a new NewGRF which uses GRF version >= 8. * @return 0czzbbss: c = TileType; zz = TileZ; bb: 7-3 zero, 4-2 TerrainType, 1 water/shore, 0 zero; ss = TileSlope */ -uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8) +uint32_t GetNearbyTileInformation(TileIndex tile, bool grf_version8) { TileType tile_type = GetTileType(tile); @@ -447,7 +447,7 @@ uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8) * @param l Livery of the object; nullptr to use default. * @return NewGRF company information. */ -uint32 GetCompanyInfo(CompanyID owner, const Livery *l) +uint32_t GetCompanyInfo(CompanyID owner, const Livery *l) { if (l == nullptr && Company::IsValidID(owner)) l = &Company::Get(owner)->livery[LS_DEFAULT]; return owner | (Company::IsValidAiID(owner) ? 0x10000 : 0) | (l != nullptr ? (l->colour1 << 24) | (l->colour2 << 28) : 0); @@ -460,7 +460,7 @@ uint32 GetCompanyInfo(CompanyID owner, const Livery *l) * @param default_error Error message to use for the generic error. * @return CommandCost indicating success or the error message. */ -CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, const GRFFile *grffile, StringID default_error) +CommandCost GetErrorMessageFromLocationCallbackResult(uint16_t cb_res, const GRFFile *grffile, StringID default_error) { CommandCost res; @@ -496,7 +496,7 @@ CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, const GRFFi * @param cbid Callback causing the problem. * @param cb_res Invalid result returned by the callback. */ -void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res) +void ErrorUnknownCallbackResult(uint32_t grfid, uint16_t cbid, uint16_t cb_res) { GRFConfig *grfconfig = GetGRFConfig(grfid); @@ -526,7 +526,7 @@ void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res) * @param cb_res Callback result. * @return Boolean value. True if cb_res != 0. */ -bool ConvertBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res) +bool ConvertBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res) { assert(cb_res != CALLBACK_FAILED); // We do not know what to return @@ -545,7 +545,7 @@ bool ConvertBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res) * @param cb_res Callback result. * @return Boolean value. True if cb_res != 0. */ -bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res) +bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res) { assert(cb_res != CALLBACK_FAILED); // We do not know what to return @@ -636,10 +636,10 @@ void NewGRFSpriteLayout::AllocateRegisters() * @param separate_ground Whether the ground sprite shall be resolved by a separate action-1-2-3 chain by default. * @return Bitmask of values for variable 10 to resolve action-1-2-3 chains for. */ -uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_ground_offset, uint32 newgrf_offset, uint constr_stage, bool separate_ground) const +uint32_t NewGRFSpriteLayout::PrepareLayout(uint32_t orig_offset, uint32_t newgrf_ground_offset, uint32_t newgrf_offset, uint constr_stage, bool separate_ground) const { result_seq.clear(); - uint32 var10_values = 0; + uint32_t var10_values = 0; /* Create a copy of the spritelayout, so we can modify some values. * Also include the groundsprite into the sequence for easier processing. */ @@ -647,7 +647,7 @@ uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_groun result->image = ground; result->delta_x = 0; result->delta_y = 0; - result->delta_z = (int8)0x80; + result->delta_z = (int8_t)0x80; const DrawTileSeqStruct *dtss; foreach_draw_tile_seq(dtss, this->seq) { @@ -664,7 +664,7 @@ uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_groun /* Record var10 value for the sprite */ if (HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE) || (flags & TLF_SPRITE_REG_FLAGS)) { - uint8 var10 = (flags & TLF_SPRITE_VAR10) ? regs->sprite_var10 : (ground && separate_ground ? 1 : 0); + uint8_t var10 = (flags & TLF_SPRITE_VAR10) ? regs->sprite_var10 : (ground && separate_ground ? 1 : 0); SetBit(var10_values, var10); } @@ -680,7 +680,7 @@ uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_groun /* Record var10 value for the palette */ if (HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE) || (flags & TLF_PALETTE_REG_FLAGS)) { - uint8 var10 = (flags & TLF_PALETTE_VAR10) ? regs->palette_var10 : (ground && separate_ground ? 1 : 0); + uint8_t var10 = (flags & TLF_PALETTE_VAR10) ? regs->palette_var10 : (ground && separate_ground ? 1 : 0); SetBit(var10_values, var10); } @@ -707,7 +707,7 @@ uint32 NewGRFSpriteLayout::PrepareLayout(uint32 orig_offset, uint32 newgrf_groun * @param separate_ground Whether the ground sprite is resolved by a separate action-1-2-3 chain. * @return Resulting spritelayout after processing the registers. */ -void NewGRFSpriteLayout::ProcessRegisters(uint8 resolved_var10, uint32 resolved_sprite, bool separate_ground) const +void NewGRFSpriteLayout::ProcessRegisters(uint8_t resolved_var10, uint32_t resolved_sprite, bool separate_ground) const { DrawTileSeqStruct *result; const TileLayoutRegisters *regs = this->registers; @@ -719,7 +719,7 @@ void NewGRFSpriteLayout::ProcessRegisters(uint8 resolved_var10, uint32 resolved_ /* Is the sprite or bounding box affected by an action-1-2-3 chain? */ if (HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE) || (flags & TLF_SPRITE_REG_FLAGS)) { /* Does the var10 value apply to this sprite? */ - uint8 var10 = (flags & TLF_SPRITE_VAR10) ? regs->sprite_var10 : (ground && separate_ground ? 1 : 0); + uint8_t var10 = (flags & TLF_SPRITE_VAR10) ? regs->sprite_var10 : (ground && separate_ground ? 1 : 0); if (var10 == resolved_var10) { /* Apply registers */ if ((flags & TLF_DODRAW) && GetRegister(regs->dodraw) == 0) { @@ -727,7 +727,7 @@ void NewGRFSpriteLayout::ProcessRegisters(uint8 resolved_var10, uint32 resolved_ } else { if (HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE)) result->image.sprite += resolved_sprite; if (flags & TLF_SPRITE) { - int16 offset = (int16)GetRegister(regs->sprite); // mask to 16 bits to avoid trouble + int16_t offset = (int16_t)GetRegister(regs->sprite); // mask to 16 bits to avoid trouble if (!HasBit(result->image.sprite, SPRITE_MODIFIER_CUSTOM_SPRITE) || (offset >= 0 && offset < regs->max_sprite_offset)) { result->image.sprite += offset; } else { @@ -737,13 +737,13 @@ void NewGRFSpriteLayout::ProcessRegisters(uint8 resolved_var10, uint32 resolved_ if (result->IsParentSprite()) { if (flags & TLF_BB_XY_OFFSET) { - result->delta_x += (int32)GetRegister(regs->delta.parent[0]); - result->delta_y += (int32)GetRegister(regs->delta.parent[1]); + result->delta_x += (int32_t)GetRegister(regs->delta.parent[0]); + result->delta_y += (int32_t)GetRegister(regs->delta.parent[1]); } - if (flags & TLF_BB_Z_OFFSET) result->delta_z += (int32)GetRegister(regs->delta.parent[2]); + if (flags & TLF_BB_Z_OFFSET) result->delta_z += (int32_t)GetRegister(regs->delta.parent[2]); } else { - if (flags & TLF_CHILD_X_OFFSET) result->delta_x += (int32)GetRegister(regs->delta.child[0]); - if (flags & TLF_CHILD_Y_OFFSET) result->delta_y += (int32)GetRegister(regs->delta.child[1]); + if (flags & TLF_CHILD_X_OFFSET) result->delta_x += (int32_t)GetRegister(regs->delta.child[0]); + if (flags & TLF_CHILD_Y_OFFSET) result->delta_y += (int32_t)GetRegister(regs->delta.child[1]); } } } @@ -752,12 +752,12 @@ void NewGRFSpriteLayout::ProcessRegisters(uint8 resolved_var10, uint32 resolved_ /* Is the palette affected by an action-1-2-3 chain? */ if (result->image.sprite != 0 && (HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE) || (flags & TLF_PALETTE_REG_FLAGS))) { /* Does the var10 value apply to this sprite? */ - uint8 var10 = (flags & TLF_PALETTE_VAR10) ? regs->palette_var10 : (ground && separate_ground ? 1 : 0); + uint8_t var10 = (flags & TLF_PALETTE_VAR10) ? regs->palette_var10 : (ground && separate_ground ? 1 : 0); if (var10 == resolved_var10) { /* Apply registers */ if (HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE)) result->image.pal += resolved_sprite; if (flags & TLF_PALETTE) { - int16 offset = (int16)GetRegister(regs->palette); // mask to 16 bits to avoid trouble + int16_t offset = (int16_t)GetRegister(regs->palette); // mask to 16 bits to avoid trouble if (!HasBit(result->image.pal, SPRITE_MODIFIER_CUSTOM_SPRITE) || (offset >= 0 && offset < regs->max_palette_offset)) { result->image.pal += offset; } else { diff --git a/src/newgrf_commons.h b/src/newgrf_commons.h index c83653ccf0..27cb74dba5 100644 --- a/src/newgrf_commons.h +++ b/src/newgrf_commons.h @@ -89,17 +89,17 @@ static inline uint GetConstructionStageOffset(uint construction_stage, uint num_ */ struct TileLayoutRegisters { TileLayoutFlags flags; ///< Flags defining which members are valid and to be used. - uint8 dodraw; ///< Register deciding whether the sprite shall be drawn at all. Non-zero means drawing. - uint8 sprite; ///< Register specifying a signed offset for the sprite. - uint8 palette; ///< Register specifying a signed offset for the palette. - uint16 max_sprite_offset; ///< Maximum offset to add to the sprite. (limited by size of the spriteset) - uint16 max_palette_offset; ///< Maximum offset to add to the palette. (limited by size of the spriteset) + uint8_t dodraw; ///< Register deciding whether the sprite shall be drawn at all. Non-zero means drawing. + uint8_t sprite; ///< Register specifying a signed offset for the sprite. + uint8_t palette; ///< Register specifying a signed offset for the palette. + uint16_t max_sprite_offset; ///< Maximum offset to add to the sprite. (limited by size of the spriteset) + uint16_t max_palette_offset; ///< Maximum offset to add to the palette. (limited by size of the spriteset) union { - uint8 parent[3]; ///< Registers for signed offsets for the bounding box position of parent sprites. - uint8 child[2]; ///< Registers for signed offsets for the position of child sprites. + uint8_t parent[3]; ///< Registers for signed offsets for the bounding box position of parent sprites. + uint8_t child[2]; ///< Registers for signed offsets for the position of child sprites. } delta; - uint8 sprite_var10; ///< Value for variable 10 when resolving the sprite. - uint8 palette_var10; ///< Value for variable 10 when resolving the palette. + uint8_t sprite_var10; ///< Value for variable 10 when resolving the sprite. + uint8_t palette_var10; ///< Value for variable 10 when resolving the palette. }; static const uint TLR_MAX_VAR10 = 7; ///< Maximum value for var 10. @@ -151,8 +151,8 @@ struct NewGRFSpriteLayout : ZeroedMemoryAllocator, DrawTileSprites { return this->registers != nullptr; } - uint32 PrepareLayout(uint32 orig_offset, uint32 newgrf_ground_offset, uint32 newgrf_offset, uint constr_stage, bool separate_ground) const; - void ProcessRegisters(uint8 resolved_var10, uint32 resolved_sprite, bool separate_ground) const; + uint32_t PrepareLayout(uint32_t orig_offset, uint32_t newgrf_ground_offset, uint32_t newgrf_offset, uint constr_stage, bool separate_ground) const; + void ProcessRegisters(uint8_t resolved_var10, uint32_t resolved_sprite, bool separate_ground) const; /** * Returns the result spritelayout after preprocessing. @@ -183,47 +183,47 @@ private: * if the GRF containing the new entity is not available. */ struct EntityIDMapping { - uint32 grfid; ///< The GRF ID of the file the entity belongs to + uint32_t grfid; ///< The GRF ID of the file the entity belongs to uint16_t entity_id; ///< The entity ID within the GRF file uint16_t substitute_id; ///< The (original) entity ID to use if this GRF is not available }; class OverrideManagerBase { protected: - std::vector entity_overrides; - std::vector grfid_overrides; + std::vector entity_overrides; + std::vector grfid_overrides; - uint16 max_offset; ///< what is the length of the original entity's array of specs - uint16 max_entities; ///< what is the amount of entities, old and new summed + uint16_t max_offset; ///< what is the length of the original entity's array of specs + uint16_t max_entities; ///< what is the amount of entities, old and new summed - uint16 invalid_id; ///< ID used to detected invalid entities - virtual bool CheckValidNewID(uint16 testid) { return true; } + uint16_t invalid_id; ///< ID used to detected invalid entities + virtual bool CheckValidNewID(uint16_t testid) { return true; } public: std::vector mappings; ///< mapping of ids from grf files. Public out of convenience - OverrideManagerBase(uint16 offset, uint16 maximum, uint16 invalid); + OverrideManagerBase(uint16_t offset, uint16_t maximum, uint16_t invalid); virtual ~OverrideManagerBase() = default; void ResetOverride(); void ResetMapping(); - void Add(uint16_t local_id, uint32 grfid, uint entity_type); - virtual uint16 AddEntityID(uint16_t grf_local_id, uint32 grfid, uint16_t substitute_id); + void Add(uint16_t local_id, uint32_t grfid, uint entity_type); + virtual uint16_t AddEntityID(uint16_t grf_local_id, uint32_t grfid, uint16_t substitute_id); - uint32 GetGRFID(uint16 entity_id) const; - uint16 GetSubstituteID(uint16 entity_id) const; - virtual uint16 GetID(uint16_t grf_local_id, uint32 grfid) const; + uint32_t GetGRFID(uint16_t entity_id) const; + uint16_t GetSubstituteID(uint16_t entity_id) const; + virtual uint16_t GetID(uint16_t grf_local_id, uint32_t grfid) const; - inline uint16 GetMaxMapping() const { return this->max_entities; } - inline uint16 GetMaxOffset() const { return this->max_offset; } + inline uint16_t GetMaxMapping() const { return this->max_entities; } + inline uint16_t GetMaxOffset() const { return this->max_offset; } }; struct HouseSpec; class HouseOverrideManager : public OverrideManagerBase { public: - HouseOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) : + HouseOverrideManager(uint16_t offset, uint16_t maximum, uint16_t invalid) : OverrideManagerBase(offset, maximum, invalid) {} void SetEntitySpec(const HouseSpec *hs); @@ -233,11 +233,11 @@ public: struct IndustrySpec; class IndustryOverrideManager : public OverrideManagerBase { public: - IndustryOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) : + IndustryOverrideManager(uint16_t offset, uint16_t maximum, uint16_t invalid) : OverrideManagerBase(offset, maximum, invalid) {} - uint16 AddEntityID(uint16_t grf_local_id, uint32 grfid, uint16_t substitute_id) override; - uint16 GetID(uint16_t grf_local_id, uint32 grfid) const override; + uint16_t AddEntityID(uint16_t grf_local_id, uint32_t grfid, uint16_t substitute_id) override; + uint16_t GetID(uint16_t grf_local_id, uint32_t grfid) const override; void SetEntitySpec(IndustrySpec *inds); }; @@ -246,9 +246,9 @@ public: struct IndustryTileSpec; class IndustryTileOverrideManager : public OverrideManagerBase { protected: - virtual bool CheckValidNewID(uint16 testid) { return testid != 0xFF; } + virtual bool CheckValidNewID(uint16_t testid) { return testid != 0xFF; } public: - IndustryTileOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) : + IndustryTileOverrideManager(uint16_t offset, uint16_t maximum, uint16_t invalid) : OverrideManagerBase(offset, maximum, invalid) {} void SetEntitySpec(const IndustryTileSpec *indts); @@ -257,7 +257,7 @@ public: struct AirportSpec; class AirportOverrideManager : public OverrideManagerBase { public: - AirportOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) : + AirportOverrideManager(uint16_t offset, uint16_t maximum, uint16_t invalid) : OverrideManagerBase(offset, maximum, invalid) {} void SetEntitySpec(AirportSpec *inds); @@ -266,9 +266,9 @@ public: struct AirportTileSpec; class AirportTileOverrideManager : public OverrideManagerBase { protected: - virtual bool CheckValidNewID(uint16 testid) override { return testid != 0xFF; } + virtual bool CheckValidNewID(uint16_t testid) override { return testid != 0xFF; } public: - AirportTileOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) : + AirportTileOverrideManager(uint16_t offset, uint16_t maximum, uint16_t invalid) : OverrideManagerBase(offset, maximum, invalid) {} void SetEntitySpec(const AirportTileSpec *ats); @@ -277,9 +277,9 @@ public: struct ObjectSpec; class ObjectOverrideManager : public OverrideManagerBase { protected: - virtual bool CheckValidNewID(uint16 testid) override { return testid != 0xFF; } + virtual bool CheckValidNewID(uint16_t testid) override { return testid != 0xFF; } public: - ObjectOverrideManager(uint16 offset, uint16 maximum, uint16 invalid) : + ObjectOverrideManager(uint16_t offset, uint16_t maximum, uint16_t invalid) : OverrideManagerBase(offset, maximum, invalid) {} void SetEntitySpec(ObjectSpec *spec); @@ -292,15 +292,15 @@ extern AirportOverrideManager _airport_mngr; extern AirportTileOverrideManager _airporttile_mngr; extern ObjectOverrideManager _object_mngr; -uint32 GetTerrainType(TileIndex tile, TileContext context = TCX_NORMAL); +uint32_t GetTerrainType(TileIndex tile, TileContext context = TCX_NORMAL); TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets = true, Axis axis = INVALID_AXIS); -uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8); -uint32 GetCompanyInfo(CompanyID owner, const struct Livery *l = nullptr); -CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, const GRFFile *grffile, StringID default_error); +uint32_t GetNearbyTileInformation(TileIndex tile, bool grf_version8); +uint32_t GetCompanyInfo(CompanyID owner, const struct Livery *l = nullptr); +CommandCost GetErrorMessageFromLocationCallbackResult(uint16_t cb_res, const GRFFile *grffile, StringID default_error); -void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res); -bool ConvertBooleanCallback(const struct GRFFile *grffile, uint16 cbid, uint16 cb_res); -bool Convert8bitBooleanCallback(const struct GRFFile *grffile, uint16 cbid, uint16 cb_res); +void ErrorUnknownCallbackResult(uint32_t grfid, uint16_t cbid, uint16_t cb_res); +bool ConvertBooleanCallback(const struct GRFFile *grffile, uint16_t cbid, uint16_t cb_res); +bool Convert8bitBooleanCallback(const struct GRFFile *grffile, uint16_t cbid, uint16_t cb_res); /** * Data related to the handling of grf files. @@ -315,7 +315,7 @@ struct GRFFilePropsBase { memset(spritegroup, 0, sizeof(spritegroup)); } - uint16 local_id; ///< id defined by the grf file for this entity + uint16_t local_id; ///< id defined by the grf file for this entity const struct GRFFile *grffile; ///< grf file that introduced this entity const struct SpriteGroup *spritegroup[Tcnt]; ///< pointer to the different sprites of the entity }; @@ -323,13 +323,13 @@ struct GRFFilePropsBase { /** Data related to the handling of grf files. */ struct GRFFileProps : GRFFilePropsBase<1> { /** Set all default data constructor for the props. */ - GRFFileProps(uint16 subst_id = 0) : + GRFFileProps(uint16_t subst_id = 0) : GRFFilePropsBase<1>(), subst_id(subst_id), override(subst_id) { } - uint16 subst_id; - uint16 override; ///< id of the entity been replaced by + uint16_t subst_id; + uint16_t override; ///< id of the entity been replaced by }; #endif /* NEWGRF_COMMONS_H */ diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index 012da78ba8..5c6e16576e 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -185,7 +185,7 @@ GRFParameterInfo::GRFParameterInfo(uint nr) : * @param config The GRFConfig to get the value from. * @return The value of this parameter. */ -uint32 GRFParameterInfo::GetValue(struct GRFConfig *config) const +uint32_t GRFParameterInfo::GetValue(struct GRFConfig *config) const { /* GB doesn't work correctly with nbits == 32, so handle that case here. */ if (this->num_bit == 32) return config->param[this->param_nr]; @@ -197,7 +197,7 @@ uint32 GRFParameterInfo::GetValue(struct GRFConfig *config) const * @param config The GRFConfig to set the value in. * @param value The new value. */ -void GRFParameterInfo::SetValue(struct GRFConfig *config, uint32 value) +void GRFParameterInfo::SetValue(struct GRFConfig *config, uint32_t value) { /* SB doesn't work correctly with nbits == 32, so handle that case here. */ if (this->num_bit == 32) { @@ -215,7 +215,7 @@ void GRFParameterInfo::SetValue(struct GRFConfig *config, uint32 value) void GRFParameterInfo::Finalize() { this->complete_labels = true; - for (uint32 value = this->min_value; value <= this->max_value; value++) { + for (uint32_t value = this->min_value; value <= this->max_value; value++) { if (this->value_names.count(value) == 0) { this->complete_labels = false; break; @@ -228,7 +228,7 @@ void GRFParameterInfo::Finalize() * Called when changing the default palette in advanced settings. * @param new_value Unused. */ -void UpdateNewGRFConfigPalette(int32 new_value) +void UpdateNewGRFConfigPalette(int32_t new_value) { for (GRFConfig *c = _grfconfig_newgame; c != nullptr; c = c->next) c->SetSuitablePalette(); for (GRFConfig *c = _grfconfig_static; c != nullptr; c = c->next) c->SetSuitablePalette(); @@ -274,7 +274,7 @@ static bool CalcGRFMD5Sum(GRFConfig *config, Subdirectory subdir) { FILE *f; Md5 checksum; - uint8 buffer[1024]; + uint8_t buffer[1024]; size_t len, size; /* open the file */ @@ -675,7 +675,7 @@ void ScanNewGRFFiles(NewGRFScanCallback *callback) * @param desired_version Requested version * @return The matching grf, if it exists in #_all_grfs, else \c nullptr. */ -const GRFConfig *FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const MD5Hash *md5sum, uint32 desired_version) +const GRFConfig *FindGRFConfig(uint32_t grfid, FindGRFConfigMode mode, const MD5Hash *md5sum, uint32_t desired_version) { assert((mode == FGCM_EXACT) != (md5sum == nullptr)); const GRFConfig *best = nullptr; @@ -701,7 +701,7 @@ const GRFConfig *FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const MD5Ha * @param mask GRFID mask to allow for partial matching. * @return The grf config, if it exists, else \c nullptr. */ -GRFConfig *GetGRFConfig(uint32 grfid, uint32 mask) +GRFConfig *GetGRFConfig(uint32_t grfid, uint32_t mask) { GRFConfig *c; diff --git a/src/newgrf_config.h b/src/newgrf_config.h index 9706f79fbc..22706ce025 100644 --- a/src/newgrf_config.h +++ b/src/newgrf_config.h @@ -81,13 +81,13 @@ enum GRFPalette { /** Basic data to distinguish a GRF. Used in the server list window */ struct GRFIdentifier { - uint32 grfid; ///< GRF ID (defined by Action 0x08) + uint32_t grfid; ///< GRF ID (defined by Action 0x08) MD5Hash md5sum; ///< MD5 checksum of file to distinguish files with the same GRF ID (eg. newer version of GRF) GRFIdentifier() = default; GRFIdentifier(const GRFIdentifier &other) = default; GRFIdentifier(GRFIdentifier &&other) = default; - GRFIdentifier(uint32 grfid, const MD5Hash &md5sum) : grfid(grfid), md5sum(md5sum) {} + GRFIdentifier(uint32_t grfid, const MD5Hash &md5sum) : grfid(grfid), md5sum(md5sum) {} GRFIdentifier& operator =(const GRFIdentifier &other) = default; @@ -97,7 +97,7 @@ struct GRFIdentifier { * @param md5sum Expected md5sum, may be \c nullptr (in which case, do not check it). * @return the object has the provided grfid and md5sum. */ - inline bool HasGrfIdentifier(uint32 grfid, const MD5Hash *md5sum) const + inline bool HasGrfIdentifier(uint32_t grfid, const MD5Hash *md5sum) const { if (this->grfid != grfid) return false; if (md5sum == nullptr) return true; @@ -129,17 +129,17 @@ struct GRFParameterInfo { GRFTextList name; ///< The name of this parameter GRFTextList desc; ///< The description of this parameter GRFParameterType type; ///< The type of this parameter - uint32 min_value; ///< The minimal value this parameter can have - uint32 max_value; ///< The maximal value of this parameter - uint32 def_value; ///< Default value of this parameter + uint32_t min_value; ///< The minimal value this parameter can have + uint32_t max_value; ///< The maximal value of this parameter + uint32_t def_value; ///< Default value of this parameter byte param_nr; ///< GRF parameter to store content in byte first_bit; ///< First bit to use in the GRF parameter byte num_bit; ///< Number of bits to use for this parameter std::map value_names; ///< Names for each value. bool complete_labels; ///< True if all values have a label. - uint32 GetValue(struct GRFConfig *config) const; - void SetValue(struct GRFConfig *config, uint32 value); + uint32_t GetValue(struct GRFConfig *config) const; + void SetValue(struct GRFConfig *config, uint32_t value); void Finalize(); }; @@ -159,15 +159,15 @@ struct GRFConfig : ZeroedMemoryAllocator { GRFTextWrapper url; ///< NOSAVE: URL belonging to this GRF. std::optional error; ///< NOSAVE: Error/Warning during GRF loading (Action 0x0B) - uint32 version; ///< NOSAVE: Version a NewGRF can set so only the newest NewGRF is shown - uint32 min_loadable_version; ///< NOSAVE: Minimum compatible version a NewGRF can define - uint8 flags; ///< NOSAVE: GCF_Flags, bitset + uint32_t version; ///< NOSAVE: Version a NewGRF can set so only the newest NewGRF is shown + uint32_t min_loadable_version; ///< NOSAVE: Minimum compatible version a NewGRF can define + uint8_t flags; ///< NOSAVE: GCF_Flags, bitset GRFStatus status; ///< NOSAVE: GRFStatus, enum - uint32 grf_bugs; ///< NOSAVE: bugs in this GRF in this run, @see enum GRFBugs + uint32_t grf_bugs; ///< NOSAVE: bugs in this GRF in this run, @see enum GRFBugs std::array param; ///< GRF parameters - uint8 num_params; ///< Number of used parameters - uint8 num_valid_params; ///< NOSAVE: Number of valid parameters (action 0x14) - uint8 palette; ///< GRFPalette, bitset + uint8_t num_params; ///< Number of used parameters + uint8_t num_valid_params; ///< NOSAVE: Number of valid parameters (action 0x14) + uint8_t palette; ///< GRFPalette, bitset std::vector> param_info; ///< NOSAVE: extra information about the parameters bool has_param_defaults; ///< NOSAVE: did this newgrf specify any defaults for it's parameters @@ -211,8 +211,8 @@ struct NewGRFScanCallback { size_t GRFGetSizeOfDataSection(FILE *f); void ScanNewGRFFiles(NewGRFScanCallback *callback); -const GRFConfig *FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const MD5Hash *md5sum = nullptr, uint32 desired_version = 0); -GRFConfig *GetGRFConfig(uint32 grfid, uint32 mask = 0xFFFFFFFF); +const GRFConfig *FindGRFConfig(uint32_t grfid, FindGRFConfigMode mode, const MD5Hash *md5sum = nullptr, uint32_t desired_version = 0); +GRFConfig *GetGRFConfig(uint32_t grfid, uint32_t mask = 0xFFFFFFFF); GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_only); void AppendStaticGRFConfigs(GRFConfig **dst); void AppendToGRFConfigList(GRFConfig **dst, GRFConfig *el); @@ -226,6 +226,6 @@ std::string GRFBuildParamList(const GRFConfig *c); void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFConfig **config); void UpdateNewGRFScanStatus(uint num, const char *name); -void UpdateNewGRFConfigPalette(int32 new_value = 0); +void UpdateNewGRFConfigPalette(int32_t new_value = 0); #endif /* NEWGRF_CONFIG_H */ diff --git a/src/newgrf_debug.h b/src/newgrf_debug.h index 56a9c60117..dfec7ce7f5 100644 --- a/src/newgrf_debug.h +++ b/src/newgrf_debug.h @@ -31,7 +31,7 @@ struct NewGrfDebugSpritePicker { extern NewGrfDebugSpritePicker _newgrf_debug_sprite_picker; bool IsNewGRFInspectable(GrfSpecFeature feature, uint index); -void ShowNewGRFInspectWindow(GrfSpecFeature feature, uint index, const uint32 grfid = 0); +void ShowNewGRFInspectWindow(GrfSpecFeature feature, uint index, const uint32_t grfid = 0); void InvalidateNewGRFInspectWindow(GrfSpecFeature feature, uint index); void DeleteNewGRFInspectWindow(GrfSpecFeature feature, uint index); diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index 86f45bfd16..adfce85da9 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -100,7 +100,7 @@ struct NICallback { NIOffsetProc *offset_proc; ///< Callback proc to get the actual variable address in memory byte read_size; ///< The number of bytes (i.e. byte, word, dword etc) to read byte cb_bit; ///< The bit that needs to be set for this callback to be enabled - uint16 cb_id; ///< The number of the callback + uint16_t cb_id; ///< The number of the callback }; /** Mask to show no bit needs to be enabled for the callback. */ static const int CBM_NO_BIT = UINT8_MAX; @@ -156,7 +156,7 @@ public: * @param index index to check. * @return GRFID of the item. 0 means that the item is not inspectable. */ - virtual uint32 GetGRFID(uint index) const = 0; + virtual uint32_t GetGRFID(uint index) const = 0; /** * Resolve (action2) variable for a given index. @@ -183,7 +183,7 @@ public: * @param grfid Parameter for the PSA. Only required for items with parameters. * @return Size of the persistent storage in indices. */ - virtual uint GetPSASize(uint index, uint32 grfid) const + virtual uint GetPSASize(uint index, uint32_t grfid) const { return 0; } @@ -194,7 +194,7 @@ public: * @param grfid Parameter for the PSA. Only required for items with parameters. * @return Pointer to the first position of the storage array or nullptr if not present. */ - virtual const int32 *GetPSAFirstPosition(uint index, uint32 grfid) const + virtual const int32_t *GetPSAFirstPosition(uint index, uint32_t grfid) const { return nullptr; } @@ -205,7 +205,7 @@ protected: * @param string the string to actually draw. * @param index the (instance) index for the string. */ - void SetSimpleStringParameters(StringID string, uint32 index) const + void SetSimpleStringParameters(StringID string, uint32_t index) const { SetDParam(0, string); SetDParam(1, index); @@ -218,7 +218,7 @@ protected: * @param index the (instance) index for the string. * @param tile the tile the object is at */ - void SetObjectAtStringParameters(StringID string, uint32 index, TileIndex tile) const + void SetObjectAtStringParameters(StringID string, uint32_t index, TileIndex tile) const { SetDParam(0, STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT); SetDParam(1, string); @@ -274,10 +274,10 @@ static inline const NIHelper *GetFeatureHelper(uint window_number) /** Window used for inspecting NewGRFs. */ struct NewGRFInspectWindow : Window { /** The value for the variable 60 parameters. */ - static uint32 var60params[GSF_FAKE_END][0x20]; + static uint32_t var60params[GSF_FAKE_END][0x20]; /** GRFID of the caller of this window, 0 if it has no caller. */ - uint32 caller_grfid; + uint32_t caller_grfid; /** For ground vehicles: Index in vehicle chain. */ uint chain_index; @@ -301,7 +301,7 @@ struct NewGRFInspectWindow : Window { * Set the GRFID of the item opening this window. * @param grfid GRFID of the item opening this window, or 0 if not opened by other window. */ - void SetCallerGRFID(uint32 grfid) + void SetCallerGRFID(uint32_t grfid) { this->caller_grfid = grfid; this->SetDirty(); @@ -470,7 +470,7 @@ struct NewGRFInspectWindow : Window { } uint psa_size = nih->GetPSASize(index, this->caller_grfid); - const int32 *psa = nih->GetPSAFirstPosition(index, this->caller_grfid); + const int32_t *psa = nih->GetPSAFirstPosition(index, this->caller_grfid); if (psa_size != 0 && psa != nullptr) { if (nih->PSAWithParameter()) { this->DrawString(r, i++, fmt::format("Persistent storage [{:08X}]:", BSWAP32(this->caller_grfid))); @@ -489,9 +489,9 @@ struct NewGRFInspectWindow : Window { const void *ptr = nip->offset_proc(base); uint value; switch (nip->read_size) { - case 1: value = *(const uint8 *)ptr; break; - case 2: value = *(const uint16 *)ptr; break; - case 4: value = *(const uint32 *)ptr; break; + case 1: value = *(const uint8_t *)ptr; break; + case 2: value = *(const uint16_t *)ptr; break; + case 4: value = *(const uint32_t *)ptr; break; default: NOT_REACHED(); } @@ -521,9 +521,9 @@ struct NewGRFInspectWindow : Window { const void *ptr = nic->offset_proc(base_spec); uint value; switch (nic->read_size) { - case 1: value = *(const uint8 *)ptr; break; - case 2: value = *(const uint16 *)ptr; break; - case 4: value = *(const uint32 *)ptr; break; + case 1: value = *(const uint8_t *)ptr; break; + case 2: value = *(const uint16_t *)ptr; break; + case 4: value = *(const uint32_t *)ptr; break; default: NOT_REACHED(); } @@ -634,7 +634,7 @@ struct NewGRFInspectWindow : Window { } }; -/* static */ uint32 NewGRFInspectWindow::var60params[GSF_FAKE_END][0x20] = { {0} }; // Use spec to have 0s in whole array +/* static */ uint32_t NewGRFInspectWindow::var60params[GSF_FAKE_END][0x20] = { {0} }; // Use spec to have 0s in whole array static const NWidgetPart _nested_newgrf_inspect_chain_widgets[] = { NWidget(NWID_HORIZONTAL), @@ -701,7 +701,7 @@ static WindowDesc _newgrf_inspect_desc( * @param index The index/identifier of the feature to inspect. * @param grfid GRFID of the item opening this window, or 0 if not opened by other window. */ -void ShowNewGRFInspectWindow(GrfSpecFeature feature, uint index, const uint32 grfid) +void ShowNewGRFInspectWindow(GrfSpecFeature feature, uint index, const uint32_t grfid) { if (!IsNewGRFInspectable(feature, index)) return; @@ -812,7 +812,7 @@ GrfSpecFeature GetGrfSpecFeature(VehicleType type) /** Window used for aligning sprites. */ struct SpriteAlignerWindow : Window { - typedef std::pair XyOffs; ///< Pair for x and y offsets of the sprite before alignment. First value contains the x offset, second value y offset. + typedef std::pair XyOffs; ///< Pair for x and y offsets of the sprite before alignment. First value contains the x offset, second value y offset. SpriteID current_sprite; ///< The currently shown sprite. Scrollbar *vscroll; diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index ea6512c3a7..e1e7e7a0bd 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -136,7 +136,7 @@ static byte MapAircraftMovementState(const Aircraft *v) if (st == nullptr) return AMS_TTDP_FLIGHT_TO_TOWER; const AirportFTAClass *afc = st->airport.GetFTA(); - uint16 amdflag = afc->MovingData(v->pos)->flag; + uint16_t amdflag = afc->MovingData(v->pos)->flag; switch (v->state) { case HANGAR: @@ -304,12 +304,12 @@ static byte MapAircraftMovementAction(const Aircraft *v) } -/* virtual */ uint32 VehicleScopeResolver::GetRandomBits() const +/* virtual */ uint32_t VehicleScopeResolver::GetRandomBits() const { return this->v == nullptr ? 0 : this->v->random_bits; } -/* virtual */ uint32 VehicleScopeResolver::GetTriggers() const +/* virtual */ uint32_t VehicleScopeResolver::GetTriggers() const { return this->v == nullptr ? 0 : this->v->waiting_triggers; } @@ -321,7 +321,7 @@ static byte MapAircraftMovementAction(const Aircraft *v) case VSG_SCOPE_SELF: return &this->self_scope; case VSG_SCOPE_PARENT: return &this->parent_scope; case VSG_SCOPE_RELATIVE: { - int32 count = GB(relative, 0, 4); + int32_t count = GB(relative, 0, 4); if (this->self_scope.v != nullptr && (relative != this->cached_relative_count || count == 0)) { /* Note: This caching only works as long as the VSG_SCOPE_RELATIVE cannot be used in * VarAct2 with procedure calls. */ @@ -393,7 +393,7 @@ static const Livery *LiveryHelper(EngineID engine, const Vehicle *v) * with the same 'engine type'. * @return the position in the chain from front and tail and chain length. */ -static uint32 PositionHelper(const Vehicle *v, bool consecutive) +static uint32_t PositionHelper(const Vehicle *v, bool consecutive) { const Vehicle *u; byte chain_before = 0; @@ -412,7 +412,7 @@ static uint32 PositionHelper(const Vehicle *v, bool consecutive) return chain_before | chain_after << 8 | (chain_before + chain_after + consecutive) << 16; } -static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, byte variable, uint32 parameter, bool *available) +static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, byte variable, uint32_t parameter, bool *available) { /* Calculated vehicle parameters */ switch (variable) { @@ -437,11 +437,11 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, if (!HasBit(v->grf_cache.cache_valid, NCVV_CONSIST_CARGO_INFORMATION)) { const Vehicle *u; byte cargo_classes = 0; - uint8 common_cargoes[NUM_CARGO]; - uint8 common_subtypes[256]; + uint8_t common_cargoes[NUM_CARGO]; + uint8_t common_subtypes[256]; byte user_def_data = 0; CargoID common_cargo_type = CT_INVALID; - uint8 common_subtype = 0xFF; // Return 0xFF if nothing is carried + uint8_t common_subtype = 0xFF; // Return 0xFF if nothing is carried /* Reset our arrays */ memset(common_cargoes, 0, sizeof(common_cargoes)); @@ -501,7 +501,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, * And this is only done by CheckCaches(). */ const GRFFile *grffile = object->ro.grffile; - uint8 common_bitnum = (common_cargo_type == CT_INVALID) ? 0xFF : + uint8_t common_bitnum = (common_cargo_type == CT_INVALID) ? 0xFF : (grffile == nullptr || grffile->grf_version < 8) ? CargoSpec::Get(common_cargo_type)->bitnum : grffile->cargo_map[common_cargo_type]; return (v->grf_cache.consist_cargo_information & 0xFFFF00FF) | common_bitnum << 8; @@ -520,7 +520,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, { const Vehicle *w = v->Next(); assert(w != nullptr); - uint16 altitude = ClampTo(v->z_pos - w->z_pos); // Aircraft height - shadow height + uint16_t altitude = ClampTo(v->z_pos - w->z_pos); // Aircraft height - shadow height byte airporttype = ATP_TTDP_LARGE; const Station *st = GetTargetAirportIfValid(Aircraft::From(v)); @@ -636,7 +636,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, if (object->ro.callback == CBID_NO_CALLBACK || object->ro.callback == CBID_RANDOM_TRIGGER || object->ro.callback == CBID_TRAIN_ALLOW_WAGON_ATTACH || object->ro.callback == CBID_VEHICLE_START_STOP_CHECK || object->ro.callback == CBID_VEHICLE_32DAY_CALLBACK || object->ro.callback == CBID_VEHICLE_COLOUR_MAPPING || object->ro.callback == CBID_VEHICLE_SPAWN_VISUAL_EFFECT) { - Vehicle *u = v->Move((int32)GetRegister(0x10F)); + Vehicle *u = v->Move((int32_t)GetRegister(0x10F)); if (u == nullptr) return 0; // available, but zero if (parameter == 0x5F) { @@ -659,12 +659,12 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, */ if (!v->IsGroundVehicle()) return 0; - const Vehicle *u = v->Move((int8)parameter); + const Vehicle *u = v->Move((int8_t)parameter); if (u == nullptr) return 0; /* Get direction difference. */ - bool prev = (int8)parameter < 0; - uint32 ret = prev ? DirDifference(u->direction, v->direction) : DirDifference(v->direction, u->direction); + bool prev = (int8_t)parameter < 0; + uint32_t ret = prev ? DirDifference(u->direction, v->direction) : DirDifference(v->direction, u->direction); if (ret > DIRDIFF_REVERSE) ret |= 0x08; if (u->vehstatus & VS_HIDDEN) ret |= 0x80; @@ -709,7 +709,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, case 0xFE: case 0xFF: { - uint16 modflags = 0; + uint16_t modflags = 0; if (v->type == VEH_TRAIN) { const Train *t = Train::From(v); @@ -954,7 +954,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, return UINT_MAX; } -/* virtual */ uint32 VehicleScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const +/* virtual */ uint32_t VehicleScopeResolver::GetVariable(byte variable, uint32_t parameter, bool *available) const { if (this->v == nullptr) { /* Vehicle does not exist, so we're in a purchase list */ @@ -1007,7 +1007,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, if (totalsets == 0) return nullptr; - uint set = (v->cargo.StoredCount() * totalsets) / std::max(1u, v->cargo_cap); + uint set = (v->cargo.StoredCount() * totalsets) / std::max(1u, v->cargo_cap); set = std::min(set, totalsets - 1); return in_motion ? group->loaded[set] : group->loading[set]; @@ -1024,7 +1024,7 @@ GrfSpecFeature VehicleResolverObject::GetFeature() const } } -uint32 VehicleResolverObject::GetDebugID() const +uint32_t VehicleResolverObject::GetDebugID() const { return Engine::Get(this->self_scope.self_type)->grf_prop.local_id; } @@ -1051,7 +1051,7 @@ static const GRFFile *GetEngineGrfFile(EngineID engine_type) * @param callback_param2 Second parameter (var 18) of the callback. */ VehicleResolverObject::VehicleResolverObject(EngineID engine_type, const Vehicle *v, WagonOverride wagon_override, bool rotor_in_gui, - CallbackID callback, uint32 callback_param1, uint32 callback_param2) + CallbackID callback, uint32_t callback_param1, uint32_t callback_param2) : ResolverObject(GetEngineGrfFile(engine_type), callback, callback_param1, callback_param2), self_scope(*this, engine_type, v, rotor_in_gui), parent_scope(*this, engine_type, ((v != nullptr) ? v->First() : v), rotor_in_gui), @@ -1096,7 +1096,7 @@ void GetCustomEngineSprite(EngineID engine, const Vehicle *v, Direction directio object.ResetState(); object.callback_param1 = image_type | (stack << 8); const SpriteGroup *group = object.Resolve(); - uint32 reg100 = sprite_stack ? GetRegister(0x100) : 0; + uint32_t reg100 = sprite_stack ? GetRegister(0x100) : 0; if (group != nullptr && group->GetNumResults() != 0) { result->seq[result->count].sprite = group->GetResult() + (direction % group->GetNumResults()); result->seq[result->count].pal = GB(reg100, 0, 16); // zero means default recolouring @@ -1130,7 +1130,7 @@ void GetRotorOverrideSprite(EngineID engine, const struct Aircraft *v, EngineIma object.ResetState(); object.callback_param1 = image_type | (stack << 8); const SpriteGroup *group = object.Resolve(); - uint32 reg100 = sprite_stack ? GetRegister(0x100) : 0; + uint32_t reg100 = sprite_stack ? GetRegister(0x100) : 0; if (group != nullptr && group->GetNumResults() != 0) { result->seq[result->count].sprite = group->GetResult() + (rotor_pos % group->GetNumResults()); result->seq[result->count].pal = GB(reg100, 0, 16); // zero means default recolouring @@ -1161,7 +1161,7 @@ bool UsesWagonOverride(const Vehicle *v) * @param v The vehicle to evaluate the callback for, or nullptr if it doesn't exist yet * @return The value the callback returned, or CALLBACK_FAILED if it failed */ -uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v) +uint16_t GetVehicleCallback(CallbackID callback, uint32_t param1, uint32_t param2, EngineID engine, const Vehicle *v) { VehicleResolverObject object(engine, v, VehicleResolverObject::WO_UNCACHED, false, callback, param1, param2); return object.ResolveCallback(); @@ -1177,7 +1177,7 @@ uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, Eng * @param parent The vehicle to use for parent scope * @return The value the callback returned, or CALLBACK_FAILED if it failed */ -uint16 GetVehicleCallbackParent(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v, const Vehicle *parent) +uint16_t GetVehicleCallbackParent(CallbackID callback, uint32_t param1, uint32_t param2, EngineID engine, const Vehicle *v, const Vehicle *parent) { VehicleResolverObject object(engine, v, VehicleResolverObject::WO_NONE, false, callback, param1, param2); object.parent_scope.SetVehicle(parent); @@ -1194,11 +1194,11 @@ int GetVehicleProperty(const Vehicle *v, PropertyID property, int orig_value, bo int GetEngineProperty(EngineID engine, PropertyID property, int orig_value, const Vehicle *v, bool is_signed) { - uint16 callback = GetVehicleCallback(CBID_VEHICLE_MODIFY_PROPERTY, property, 0, engine, v); + uint16_t callback = GetVehicleCallback(CBID_VEHICLE_MODIFY_PROPERTY, property, 0, engine, v); if (callback != CALLBACK_FAILED) { if (is_signed) { /* Sign extend 15 bit integer */ - return static_cast(callback << 1) / 2; + return static_cast(callback << 1) / 2; } else { return callback; } @@ -1225,7 +1225,7 @@ static void DoTriggerVehicle(Vehicle *v, VehicleTrigger trigger, uint16_t base_r /* Rerandomise bits. Scopes other than SELF are invalid for rerandomisation. For bug-to-bug-compatibility with TTDP we ignore the scope. */ uint16_t new_random_bits = Random(); - uint32 reseed = object.GetReseedSum(); + uint32_t reseed = object.GetReseedSum(); v->random_bits &= ~reseed; v->random_bits |= (first ? new_random_bits : base_random_bits) & reseed; diff --git a/src/newgrf_engine.h b/src/newgrf_engine.h index 2b721ebcb1..8b7d2654fe 100644 --- a/src/newgrf_engine.h +++ b/src/newgrf_engine.h @@ -38,9 +38,9 @@ struct VehicleScopeResolver : public ScopeResolver { void SetVehicle(const Vehicle *v) { this->v = v; } - uint32 GetRandomBits() const override; - uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; - uint32 GetTriggers() const override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(byte variable, uint32_t parameter, bool *available) const override; + uint32_t GetTriggers() const override; }; /** Resolver for a vehicle (chain) */ @@ -60,14 +60,14 @@ struct VehicleResolverObject : public ResolverObject { byte cached_relative_count; ///< Relative position of the other vehicle. VehicleResolverObject(EngineID engine_type, const Vehicle *v, WagonOverride wagon_override, bool rotor_in_gui = false, - CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0); + CallbackID callback = CBID_NO_CALLBACK, uint32_t callback_param1 = 0, uint32_t callback_param2 = 0); ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override; const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override; GrfSpecFeature GetFeature() const override; - uint32 GetDebugID() const override; + uint32_t GetDebugID() const override; }; static const uint TRAININFO_DEFAULT_VEHICLE_WIDTH = 29; @@ -94,8 +94,8 @@ struct GRFFile; void SetEngineGRF(EngineID engine, const struct GRFFile *file); -uint16 GetVehicleCallback(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v); -uint16 GetVehicleCallbackParent(CallbackID callback, uint32 param1, uint32 param2, EngineID engine, const Vehicle *v, const Vehicle *parent); +uint16_t GetVehicleCallback(CallbackID callback, uint32_t param1, uint32_t param2, EngineID engine, const Vehicle *v); +uint16_t GetVehicleCallbackParent(CallbackID callback, uint32_t param1, uint32_t param2, EngineID engine, const Vehicle *v, const Vehicle *parent); bool UsesWagonOverride(const Vehicle *v); /* Handler to Evaluate callback 36. If the callback fails (i.e. most of the @@ -119,7 +119,7 @@ void TriggerVehicle(Vehicle *veh, VehicleTrigger trigger); void AlterVehicleListOrder(EngineID engine, uint target); void CommitVehicleListOrderChanges(); -EngineID GetNewEngineID(const GRFFile *file, VehicleType type, uint16 internal_id); +EngineID GetNewEngineID(const GRFFile *file, VehicleType type, uint16_t internal_id); void FillNewGRFVehicleCache(const Vehicle *v); diff --git a/src/newgrf_generic.cpp b/src/newgrf_generic.cpp index 32543a3388..6c8fc95487 100644 --- a/src/newgrf_generic.cpp +++ b/src/newgrf_generic.cpp @@ -20,15 +20,15 @@ /** Scope resolver for generic objects and properties. */ struct GenericScopeResolver : public ScopeResolver { CargoID cargo_type; - uint8 default_selection; - uint8 src_industry; ///< Source industry substitute type. 0xFF for "town", 0xFE for "unknown". - uint8 dst_industry; ///< Destination industry substitute type. 0xFF for "town", 0xFE for "unknown". - uint8 distance; + uint8_t default_selection; + uint8_t src_industry; ///< Source industry substitute type. 0xFF for "town", 0xFE for "unknown". + uint8_t dst_industry; ///< Destination industry substitute type. 0xFF for "town", 0xFE for "unknown". + uint8_t distance; AIConstructionEvent event; - uint8 count; - uint8 station_size; + uint8_t count; + uint8_t station_size; - uint8 feature; + uint8_t feature; /** * Generic scope resolver. @@ -41,7 +41,7 @@ struct GenericScopeResolver : public ScopeResolver { { } - uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; + uint32_t GetVariable(byte variable, uint32_t parameter, bool *available) const override; private: bool ai_callback; ///< Callback comes from the AI. @@ -67,7 +67,7 @@ struct GenericResolverObject : public ResolverObject { return (GrfSpecFeature)this->generic_scope.feature; } - uint32 GetDebugID() const override + uint32_t GetDebugID() const override { return 0; } @@ -93,7 +93,7 @@ static GenericCallbackList _gcl[GSF_END]; */ void ResetGenericCallbacks() { - for (uint8 feature = 0; feature < lengthof(_gcl); feature++) { + for (uint8_t feature = 0; feature < lengthof(_gcl); feature++) { _gcl[feature].clear(); } } @@ -105,7 +105,7 @@ void ResetGenericCallbacks() * @param file The GRF of the callback. * @param group The sprite group of the callback. */ -void AddGenericCallback(uint8 feature, const GRFFile *file, const SpriteGroup *group) +void AddGenericCallback(uint8_t feature, const GRFFile *file, const SpriteGroup *group) { if (feature >= lengthof(_gcl)) { GrfMsg(5, "AddGenericCallback: Unsupported feature 0x{:02X}", feature); @@ -118,7 +118,7 @@ void AddGenericCallback(uint8 feature, const GRFFile *file, const SpriteGroup *g _gcl[feature].push_front(GenericCallback(file, group)); } -/* virtual */ uint32 GenericScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const +/* virtual */ uint32_t GenericScopeResolver::GetVariable(byte variable, uint32_t parameter, bool *available) const { if (this->ai_callback) { switch (variable) { @@ -164,7 +164,7 @@ GenericResolverObject::GenericResolverObject(bool ai_callback, CallbackID callba * @param[out] file Optionally returns the GRFFile which made the final decision for the callback result. May be nullptr if not required. * @return callback value if successful or CALLBACK_FAILED */ -static uint16 GetGenericCallbackResult(uint8 feature, ResolverObject &object, uint32 param1_grfv7, uint32 param1_grfv8, const GRFFile **file) +static uint16_t GetGenericCallbackResult(uint8_t feature, ResolverObject &object, uint32_t param1_grfv7, uint32_t param1_grfv8, const GRFFile **file) { assert(feature < lengthof(_gcl)); @@ -174,7 +174,7 @@ static uint16 GetGenericCallbackResult(uint8 feature, ResolverObject &object, ui object.root_spritegroup = it.group; /* Set callback param based on GRF version. */ object.callback_param1 = it.file->grf_version >= 8 ? param1_grfv8 : param1_grfv7; - uint16 result = object.ResolveCallback(); + uint16_t result = object.ResolveCallback(); if (result == CALLBACK_FAILED) continue; /* Return NewGRF file if necessary */ @@ -203,7 +203,7 @@ static uint16 GetGenericCallbackResult(uint8 feature, ResolverObject &object, ui * @param[out] file Optionally returns the GRFFile which made the final decision for the callback result. May be nullptr if not required. * @return callback value if successful or CALLBACK_FAILED */ -uint16 GetAiPurchaseCallbackResult(uint8 feature, CargoID cargo_type, uint8 default_selection, IndustryType src_industry, IndustryType dst_industry, uint8 distance, AIConstructionEvent event, uint8 count, uint8 station_size, const GRFFile **file) +uint16_t GetAiPurchaseCallbackResult(uint8_t feature, CargoID cargo_type, uint8_t default_selection, IndustryType src_industry, IndustryType dst_industry, uint8_t distance, AIConstructionEvent event, uint8_t count, uint8_t station_size, const GRFFile **file) { GenericResolverObject object(true, CBID_GENERIC_AI_PURCHASE_SELECTION); @@ -229,7 +229,7 @@ uint16 GetAiPurchaseCallbackResult(uint8 feature, CargoID cargo_type, uint8 defa object.generic_scope.station_size = station_size; object.generic_scope.feature = feature; - uint16 callback = GetGenericCallbackResult(feature, object, 0, 0, file); + uint16_t callback = GetGenericCallbackResult(feature, object, 0, 0, file); if (callback != CALLBACK_FAILED) callback = GB(callback, 0, 8); return callback; } @@ -244,19 +244,19 @@ void AmbientSoundEffectCallback(TileIndex tile) assert(IsTileType(tile, MP_CLEAR) || IsTileType(tile, MP_TREES) || IsTileType(tile, MP_WATER)); /* Only run every 1/200-th time. */ - uint32 r; // Save for later + uint32_t r; // Save for later if (!Chance16R(1, 200, r) || !_settings_client.sound.ambient) return; /* Prepare resolver object. */ GenericResolverObject object(false, CBID_SOUNDS_AMBIENT_EFFECT); object.generic_scope.feature = GSF_SOUNDFX; - uint32 param1_v7 = GetTileType(tile) << 28 | Clamp(TileHeight(tile), 0, 15) << 24 | GB(r, 16, 8) << 16 | GetTerrainType(tile); - uint32 param1_v8 = GetTileType(tile) << 24 | GetTileZ(tile) << 16 | GB(r, 16, 8) << 8 | (HasTileWaterClass(tile) ? GetWaterClass(tile) : 0) << 3 | GetTerrainType(tile); + uint32_t param1_v7 = GetTileType(tile) << 28 | Clamp(TileHeight(tile), 0, 15) << 24 | GB(r, 16, 8) << 16 | GetTerrainType(tile); + uint32_t param1_v8 = GetTileType(tile) << 24 | GetTileZ(tile) << 16 | GB(r, 16, 8) << 8 | (HasTileWaterClass(tile) ? GetWaterClass(tile) : 0) << 3 | GetTerrainType(tile); /* Run callback. */ const GRFFile *grf_file; - uint16 callback = GetGenericCallbackResult(GSF_SOUNDFX, object, param1_v7, param1_v8, &grf_file); + uint16_t callback = GetGenericCallbackResult(GSF_SOUNDFX, object, param1_v7, param1_v8, &grf_file); if (callback != CALLBACK_FAILED) PlayTileSound(grf_file, callback, tile); } diff --git a/src/newgrf_generic.h b/src/newgrf_generic.h index 9837a3692c..a027dd1e68 100644 --- a/src/newgrf_generic.h +++ b/src/newgrf_generic.h @@ -45,9 +45,9 @@ static const IndustryType IT_AI_UNKNOWN = 0xFE; ///< The AI has no specific indu static const IndustryType IT_AI_TOWN = 0xFF; ///< The AI actually wants to transport to/from a town, not an industry. void ResetGenericCallbacks(); -void AddGenericCallback(uint8 feature, const GRFFile *file, const SpriteGroup *group); +void AddGenericCallback(uint8_t feature, const GRFFile *file, const SpriteGroup *group); -uint16 GetAiPurchaseCallbackResult(uint8 feature, CargoID cargo_type, uint8 default_selection, IndustryType src_industry, IndustryType dst_industry, uint8 distance, AIConstructionEvent event, uint8 count, uint8 station_size, const GRFFile **file); +uint16_t GetAiPurchaseCallbackResult(uint8_t feature, CargoID cargo_type, uint8_t default_selection, IndustryType src_industry, IndustryType dst_industry, uint8_t distance, AIConstructionEvent event, uint8_t count, uint8_t station_size, const GRFFile **file); void AmbientSoundEffectCallback(TileIndex tile); /** Play an ambient sound effect for an empty tile. */ diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index fbaf7b162d..f6aa841972 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -282,7 +282,7 @@ struct NewGRFParametersWindow : public Window { int text_y_offset = (this->line_height - FONT_HEIGHT_NORMAL) / 2; for (uint i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) { GRFParameterInfo &par_info = this->GetParameterInfo(i); - uint32 current_value = par_info.GetValue(this->grf_config); + uint32_t current_value = par_info.GetValue(this->grf_config); bool selected = (i == this->clicked_row); if (par_info.type == PTYPE_BOOL) { @@ -370,7 +370,7 @@ struct NewGRFParametersWindow : public Window { GRFParameterInfo &par_info = it->has_value() ? it->value() : GetDummyParameterInfo(num); /* One of the arrows is clicked */ - uint32 old_val = par_info.GetValue(this->grf_config); + uint32_t old_val = par_info.GetValue(this->grf_config); if (par_info.type != PTYPE_BOOL && IsInsideMM(x, 0, SETTING_BUTTON_WIDTH) && par_info.complete_labels) { if (this->clicked_dropdown) { /* unclick the dropdown */ @@ -392,7 +392,7 @@ struct NewGRFParametersWindow : public Window { this->closing_dropdown = false; DropDownList list; - for (uint32 i = par_info.min_value; i <= par_info.max_value; i++) { + for (uint32_t i = par_info.min_value; i <= par_info.max_value; i++) { list.emplace_back(new DropDownListStringItem(GetGRFStringFromGRFText(par_info.value_names.find(i)->second), i, false)); } @@ -400,7 +400,7 @@ struct NewGRFParametersWindow : public Window { } } } else if (IsInsideMM(x, 0, SETTING_BUTTON_WIDTH)) { - uint32 val = old_val; + uint32_t val = old_val; if (par_info.type == PTYPE_BOOL) { val = !val; } else { @@ -445,9 +445,9 @@ struct NewGRFParametersWindow : public Window { void OnQueryTextFinished(char *str) override { if (StrEmpty(str)) return; - int32 value = atoi(str); + int32_t value = atoi(str); GRFParameterInfo &par_info = this->GetParameterInfo(this->clicked_row); - uint32 val = Clamp(value, par_info.min_value, par_info.max_value); + uint32_t val = Clamp(value, par_info.min_value, par_info.max_value); par_info.SetValue(this->grf_config, val); this->SetDirty(); } @@ -576,7 +576,7 @@ void ShowNewGRFTextfileWindow(TextfileType file_type, const GRFConfig *c) new NewGRFTextfileWindow(file_type, c); } -typedef std::map GrfIdMap; ///< Map of grfid to the grf config. +typedef std::map GrfIdMap; ///< Map of grfid to the grf config. /** * Add all grf configs from \a c into the map. @@ -586,7 +586,7 @@ typedef std::map GrfIdMap; ///< Map of grfid to the g static void FillGrfidMap(const GRFConfig *c, GrfIdMap *grfid_map) { while (c != nullptr) { - std::pair p(c->ident.grfid, c); + std::pair p(c->ident.grfid, c); grfid_map->insert(p); c = c->next; } @@ -1320,7 +1320,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { has_missing |= c->status == GCS_NOT_FOUND; has_compatible |= HasBit(c->flags, GCF_COMPATIBLE); } - uint32 widget_data; + uint32_t widget_data; StringID tool_tip; if (has_missing || has_compatible) { widget_data = STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON; @@ -1337,7 +1337,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { this->SetWidgetDisabledState(WID_NS_PRESET_SAVE, has_missing); } - EventState OnKeyPress(WChar key, uint16 keycode) override + EventState OnKeyPress(char32_t key, uint16_t keycode) override { if (!this->editable) return ES_NOT_HANDLED; diff --git a/src/newgrf_house.cpp b/src/newgrf_house.cpp index eb53449baa..4520cfaff5 100644 --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -24,7 +24,7 @@ #include "safeguards.h" -static BuildingCounts _building_counts; +static BuildingCounts _building_counts; static HouseClassMapping _class_mapping[HOUSE_CLASS_MAX]; HouseOverrideManager _house_mngr(NEW_HOUSE_OFFSET, NUM_HOUSES, INVALID_HOUSE_ID); @@ -53,8 +53,8 @@ static const GRFFile *GetHouseSpecGrf(HouseID house_id) * @param watched_cargo_triggers Cargo types that triggered the watched cargo callback. */ HouseResolverObject::HouseResolverObject(HouseID house_id, TileIndex tile, Town *town, - CallbackID callback, uint32 param1, uint32 param2, - bool not_yet_constructed, uint8 initial_random_bits, CargoTypes watched_cargo_triggers) + CallbackID callback, uint32_t param1, uint32_t param2, + bool not_yet_constructed, uint8_t initial_random_bits, CargoTypes watched_cargo_triggers) : ResolverObject(GetHouseSpecGrf(house_id), callback, param1, param2), house_scope(*this, house_id, tile, town, not_yet_constructed, initial_random_bits, watched_cargo_triggers), town_scope(*this, town, not_yet_constructed) // Don't access StorePSA if house is not yet constructed. @@ -67,12 +67,12 @@ GrfSpecFeature HouseResolverObject::GetFeature() const return GSF_HOUSES; } -uint32 HouseResolverObject::GetDebugID() const +uint32_t HouseResolverObject::GetDebugID() const { return HouseSpec::Get(this->house_scope.house_id)->grf_prop.local_id; } -HouseClassID AllocateHouseClassID(byte grf_class_id, uint32 grfid) +HouseClassID AllocateHouseClassID(byte grf_class_id, uint32_t grfid) { /* Start from 1 because 0 means that no class has been assigned. */ for (int i = 1; i != lengthof(_class_mapping); i++) { @@ -136,21 +136,21 @@ void DecreaseBuildingCount(Town *t, HouseID house_id) if (_building_counts.class_count[class_id] > 0) _building_counts.class_count[class_id]--; } -/* virtual */ uint32 HouseScopeResolver::GetRandomBits() const +/* virtual */ uint32_t HouseScopeResolver::GetRandomBits() const { /* Note: Towns build houses over houses. So during construction checks 'tile' may be a valid but unrelated house. */ assert(IsValidTile(this->tile) && (this->not_yet_constructed || IsTileType(this->tile, MP_HOUSE))); return this->not_yet_constructed ? this->initial_random_bits : GetHouseRandomBits(this->tile); } -/* virtual */ uint32 HouseScopeResolver::GetTriggers() const +/* virtual */ uint32_t HouseScopeResolver::GetTriggers() const { /* Note: Towns build houses over houses. So during construction checks 'tile' may be a valid but unrelated house. */ assert(IsValidTile(this->tile) && (this->not_yet_constructed || IsTileType(this->tile, MP_HOUSE))); return this->not_yet_constructed ? 0 : GetHouseTriggers(this->tile); } -static uint32 GetNumHouses(HouseID house_id, const Town *town) +static uint32_t GetNumHouses(HouseID house_id, const Town *town) { HouseClassID class_id = HouseSpec::Get(house_id)->class_id; @@ -169,7 +169,7 @@ static uint32 GetNumHouses(HouseID house_id, const Town *town) * @param grf_version8 True, if we are dealing with a new NewGRF which uses GRF version >= 8. * @return a construction of bits obeying the newgrf format */ -static uint32 GetNearbyTileInformation(byte parameter, TileIndex tile, bool grf_version8) +static uint32_t GetNearbyTileInformation(byte parameter, TileIndex tile, bool grf_version8) { tile = GetNearbyTile(parameter, tile); return GetNearbyTileInformation(tile, grf_version8); @@ -262,7 +262,7 @@ static bool SearchNearbyHouseGRFID(TileIndex tile, void *user_data) * @param house the HouseID that is associated to the house, the callback is called for * @return the Manhattan distance from the center tile, if any, and 0 if failure */ -static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseID house) +static uint32_t GetDistanceFromNearbyHouse(uint8_t parameter, TileIndex tile, HouseID house) { static TestTileOnSearchProc * const search_procs[3] = { SearchNearbyHouseID, @@ -270,8 +270,8 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI SearchNearbyHouseGRFID, }; TileIndex found_tile = tile; - uint8 searchtype = GB(parameter, 6, 2); - uint8 searchradius = GB(parameter, 0, 6); + uint8_t searchtype = GB(parameter, 6, 2); + uint8_t searchradius = GB(parameter, 0, 6); if (searchtype >= lengthof(search_procs)) return 0; // do not run on ill-defined code if (searchradius < 1) return 0; // do not use a too low radius @@ -289,7 +289,7 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI /** * @note Used by the resolver to get values for feature 07 deterministic spritegroups. */ -/* virtual */ uint32 HouseScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const +/* virtual */ uint32_t HouseScopeResolver::GetVariable(byte variable, uint32_t parameter, bool *available) const { switch (variable) { /* Construction stage. */ @@ -343,15 +343,15 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI if (!IsValidCargoID(cid)) return 0; /* Extract tile offset. */ - int8 x_offs = GB(GetRegister(0x100), 0, 8); - int8 y_offs = GB(GetRegister(0x100), 8, 8); + int8_t x_offs = GB(GetRegister(0x100), 0, 8); + int8_t y_offs = GB(GetRegister(0x100), 8, 8); TileIndex testtile = Map::WrapToMap(this->tile + TileDiffXY(x_offs, y_offs)); StationFinder stations(TileArea(testtile, 1, 1)); const StationList *sl = stations.GetStations(); /* Collect acceptance stats. */ - uint32 res = 0; + uint32_t res = 0; for (Station *st : *sl) { if (HasBit(st->goods[cid].status, GoodsEntry::GES_EVER_ACCEPTED)) SetBit(res, 0); if (HasBit(st->goods[cid].status, GoodsEntry::GES_LAST_MONTH)) SetBit(res, 1); @@ -409,8 +409,8 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI return UINT_MAX; } -uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile, - bool not_yet_constructed, uint8 initial_random_bits, CargoTypes watched_cargo_triggers) +uint16_t GetHouseCallback(CallbackID callback, uint32_t param1, uint32_t param2, HouseID house_id, Town *town, TileIndex tile, + bool not_yet_constructed, uint8_t initial_random_bits, CargoTypes watched_cargo_triggers) { assert(IsValidTile(tile) && (not_yet_constructed || IsTileType(tile, MP_HOUSE))); @@ -426,7 +426,7 @@ static void DrawTileLayout(const TileInfo *ti, const TileLayoutSpriteGroup *grou const HouseSpec *hs = HouseSpec::Get(house_id); PaletteID palette = hs->random_colour[TileHash2Bit(ti->x, ti->y)] + PALETTE_RECOLOUR_START; if (HasBit(hs->callback_mask, CBM_HOUSE_COLOUR)) { - uint16 callback = GetHouseCallback(CBID_HOUSE_COLOUR, 0, 0, house_id, Town::GetByTile(ti->tile), ti->tile); + uint16_t callback = GetHouseCallback(CBID_HOUSE_COLOUR, 0, 0, house_id, Town::GetByTile(ti->tile), ti->tile); if (callback != CALLBACK_FAILED) { /* If bit 14 is set, we should use a 2cc colour map, else use the callback value. */ palette = HasBit(callback, 14) ? GB(callback, 0, 8) + SPR_2CCMAP_BASE : callback; @@ -454,7 +454,7 @@ void DrawNewHouseTile(TileInfo *ti, HouseID house_id) bool draw_old_one = true; if (HasBit(hs->callback_mask, CBM_HOUSE_DRAW_FOUNDATIONS)) { /* Called to determine the type (if any) of foundation to draw for the house tile */ - uint32 callback_res = GetHouseCallback(CBID_HOUSE_DRAW_FOUNDATIONS, 0, 0, house_id, Town::GetByTile(ti->tile), ti->tile); + uint32_t callback_res = GetHouseCallback(CBID_HOUSE_DRAW_FOUNDATIONS, 0, 0, house_id, Town::GetByTile(ti->tile), ti->tile); if (callback_res != CALLBACK_FAILED) draw_old_one = ConvertBooleanCallback(hs->grf_prop.grffile, CBID_HOUSE_DRAW_FOUNDATIONS, callback_res); } @@ -473,7 +473,7 @@ void DrawNewHouseTile(TileInfo *ti, HouseID house_id) } /* Simple wrapper for GetHouseCallback to keep the animation unified. */ -uint16 GetSimpleHouseCallback(CallbackID callback, uint32 param1, uint32 param2, const HouseSpec *spec, Town *town, TileIndex tile, CargoTypes extra_data) +uint16_t GetSimpleHouseCallback(CallbackID callback, uint32_t param1, uint32_t param2, const HouseSpec *spec, Town *town, TileIndex tile, CargoTypes extra_data) { return GetHouseCallback(callback, param1, param2, spec - HouseSpec::Get(0), town, tile, false, 0, extra_data); } @@ -515,19 +515,19 @@ bool CanDeleteHouse(TileIndex tile) } if (HasBit(hs->callback_mask, CBM_HOUSE_DENY_DESTRUCTION)) { - uint16 callback_res = GetHouseCallback(CBID_HOUSE_DENY_DESTRUCTION, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile); + uint16_t callback_res = GetHouseCallback(CBID_HOUSE_DENY_DESTRUCTION, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile); return (callback_res == CALLBACK_FAILED || !ConvertBooleanCallback(hs->grf_prop.grffile, CBID_HOUSE_DENY_DESTRUCTION, callback_res)); } else { return !(hs->extra_flags & BUILDING_IS_PROTECTED); } } -static void AnimationControl(TileIndex tile, uint16 random_bits) +static void AnimationControl(TileIndex tile, uint16_t random_bits) { const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile)); if (HasBit(hs->callback_mask, CBM_HOUSE_ANIMATION_START_STOP)) { - uint32 param = (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) ? (GB(Random(), 0, 16) | random_bits << 16) : Random(); + uint32_t param = (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) ? (GB(Random(), 0, 16) | random_bits << 16) : Random(); HouseAnimationBase::ChangeAnimationFrame(CBID_HOUSE_ANIMATION_START_STOP, hs, Town::GetByTile(tile), tile, param, 0); } } @@ -550,7 +550,7 @@ bool NewHouseTileLoop(TileIndex tile) * tile loop reaches them. This should only be enabled for the northern * tile, or strange things will happen (here, and in TTDPatch). */ if (hs->extra_flags & SYNCHRONISED_CALLBACK_1B) { - uint16 random = GB(Random(), 0, 16); + uint16_t random = GB(Random(), 0, 16); if (hs->building_flags & BUILDING_HAS_1_TILE) AnimationControl(tile, random); if (hs->building_flags & BUILDING_2_TILES_Y) AnimationControl(TILE_ADDXY(tile, 0, 1), random); @@ -563,7 +563,7 @@ bool NewHouseTileLoop(TileIndex tile) /* Check callback 21, which determines if a house should be destroyed. */ if (HasBit(hs->callback_mask, CBM_HOUSE_DESTRUCTION)) { - uint16 callback_res = GetHouseCallback(CBID_HOUSE_DESTRUCTION, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile); + uint16_t callback_res = GetHouseCallback(CBID_HOUSE_DESTRUCTION, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile); if (callback_res != CALLBACK_FAILED && Convert8bitBooleanCallback(hs->grf_prop.grffile, CBID_HOUSE_DESTRUCTION, callback_res)) { ClearTownHouse(Town::GetByTile(tile), tile); return false; @@ -598,7 +598,7 @@ static void DoTriggerHouse(TileIndex tile, HouseTrigger trigger, byte base_rando /* Rerandomise bits. Scopes other than SELF are invalid for houses. For bug-to-bug-compatibility with TTDP we ignore the scope. */ byte new_random_bits = Random(); byte random_bits = GetHouseRandomBits(tile); - uint32 reseed = object.GetReseedSum(); + uint32_t reseed = object.GetReseedSum(); random_bits &= ~reseed; random_bits |= (first ? new_random_bits : base_random) & reseed; SetHouseRandomBits(tile, random_bits); @@ -634,10 +634,10 @@ void TriggerHouse(TileIndex t, HouseTrigger trigger) * @param trigger_cargoes Cargo types that triggered the callback. * @param random Random bits. */ -void DoWatchedCargoCallback(TileIndex tile, TileIndex origin, CargoTypes trigger_cargoes, uint16 random) +void DoWatchedCargoCallback(TileIndex tile, TileIndex origin, CargoTypes trigger_cargoes, uint16_t random) { TileIndexDiffC diff = TileIndexToTileIndexDiffC(origin, tile); - uint32 cb_info = random << 16 | (uint8)diff.y << 8 | (uint8)diff.x; + uint32_t cb_info = random << 16 | (uint8_t)diff.y << 8 | (uint8_t)diff.x; HouseAnimationBase::ChangeAnimationFrame(CBID_HOUSE_WATCHED_CARGO_ACCEPTED, HouseSpec::Get(GetHouseType(tile)), Town::GetByTile(tile), tile, 0, cb_info, trigger_cargoes); } @@ -658,7 +658,7 @@ void WatchedCargoCallback(TileIndex tile, CargoTypes trigger_cargoes) if (trigger_cargoes == 0) return; /* Same random value for all tiles of a multi-tile house. */ - uint16 r = Random(); + uint16_t r = Random(); /* Do the callback, start at northern tile. */ TileIndex north = tile + GetHouseNorthPart(id); diff --git a/src/newgrf_house.h b/src/newgrf_house.h index b4c1f61de3..e44906d3e8 100644 --- a/src/newgrf_house.h +++ b/src/newgrf_house.h @@ -22,7 +22,7 @@ struct HouseScopeResolver : public ScopeResolver { TileIndex tile; ///< Tile of this house. Town *town; ///< Town of this house. bool not_yet_constructed; ///< True for construction check. - uint16 initial_random_bits; ///< Random bits during construction checks. + uint16_t initial_random_bits; ///< Random bits during construction checks. CargoTypes watched_cargo_triggers; ///< Cargo types that triggered the watched cargo callback. /** @@ -36,15 +36,15 @@ struct HouseScopeResolver : public ScopeResolver { * @param watched_cargo_triggers Cargo types that triggered the watched cargo callback. */ HouseScopeResolver(ResolverObject &ro, HouseID house_id, TileIndex tile, Town *town, - bool not_yet_constructed, uint8 initial_random_bits, CargoTypes watched_cargo_triggers) + bool not_yet_constructed, uint8_t initial_random_bits, CargoTypes watched_cargo_triggers) : ScopeResolver(ro), house_id(house_id), tile(tile), town(town), not_yet_constructed(not_yet_constructed), initial_random_bits(initial_random_bits), watched_cargo_triggers(watched_cargo_triggers) { } - uint32 GetRandomBits() const override; - uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; - uint32 GetTriggers() const override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(byte variable, uint32_t parameter, bool *available) const override; + uint32_t GetTriggers() const override; }; /** Resolver object to be used for houses (feature 07 spritegroups). */ @@ -53,8 +53,8 @@ struct HouseResolverObject : public ResolverObject { TownScopeResolver town_scope; HouseResolverObject(HouseID house_id, TileIndex tile, Town *town, - CallbackID callback = CBID_NO_CALLBACK, uint32 param1 = 0, uint32 param2 = 0, - bool not_yet_constructed = false, uint8 initial_random_bits = 0, CargoTypes watched_cargo_triggers = 0); + CallbackID callback = CBID_NO_CALLBACK, uint32_t param1 = 0, uint32_t param2 = 0, + bool not_yet_constructed = false, uint8_t initial_random_bits = 0, CargoTypes watched_cargo_triggers = 0); ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { @@ -66,7 +66,7 @@ struct HouseResolverObject : public ResolverObject { } GrfSpecFeature GetFeature() const override; - uint32 GetDebugID() const override; + uint32_t GetDebugID() const override; }; /** @@ -83,11 +83,11 @@ struct HouseResolverObject : public ResolverObject { * need to be persistent; it just needs to keep class ids unique. */ struct HouseClassMapping { - uint32 grfid; ///< The GRF ID of the file this class belongs to - uint8 class_id; ///< The class id within the grf file + uint32_t grfid; ///< The GRF ID of the file this class belongs to + uint8_t class_id; ///< The class id within the grf file }; -HouseClassID AllocateHouseClassID(byte grf_class_id, uint32 grfid); +HouseClassID AllocateHouseClassID(byte grf_class_id, uint32_t grfid); void InitializeBuildingCounts(); void IncreaseBuildingCount(Town *t, HouseID house_id); @@ -97,8 +97,8 @@ void DrawNewHouseTile(TileInfo *ti, HouseID house_id); void AnimateNewHouseTile(TileIndex tile); void AnimateNewHouseConstruction(TileIndex tile); -uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile, - bool not_yet_constructed = false, uint8 initial_random_bits = 0, CargoTypes watched_cargo_triggers = 0); +uint16_t GetHouseCallback(CallbackID callback, uint32_t param1, uint32_t param2, HouseID house_id, Town *town, TileIndex tile, + bool not_yet_constructed = false, uint8_t initial_random_bits = 0, CargoTypes watched_cargo_triggers = 0); void WatchedCargoCallback(TileIndex tile, CargoTypes trigger_cargoes); bool CanDeleteHouse(TileIndex tile); diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 8e8dab8b19..b9612fb311 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -37,7 +37,7 @@ IndustryTileOverrideManager _industile_mngr(NEW_INDUSTRYTILEOFFSET, NUM_INDUSTRY * @param grf_id The GRF of the local type. * @return The industry type in the global scope. */ -IndustryType MapNewGRFIndustryType(IndustryType grf_type, uint32 grf_id) +IndustryType MapNewGRFIndustryType(IndustryType grf_type, uint32_t grf_id) { if (grf_type == IT_INVALID) return IT_INVALID; if (!HasBit(grf_type, 7)) return GB(grf_type, 0, 7); @@ -53,7 +53,7 @@ IndustryType MapNewGRFIndustryType(IndustryType grf_type, uint32 grf_id) * @param cur_grfid GRFID of the current callback chain * @return value encoded as per NFO specs */ -uint32 GetIndustryIDAtOffset(TileIndex tile, const Industry *i, uint32 cur_grfid) +uint32_t GetIndustryIDAtOffset(TileIndex tile, const Industry *i, uint32_t cur_grfid) { if (!i->TileBelongsToIndustry(tile)) { /* No industry and/or the tile does not have the same industry as the one we match it with */ @@ -89,9 +89,9 @@ uint32 GetIndustryIDAtOffset(TileIndex tile, const Industry *i, uint32 cur_grfid return 0xFF << 8 | indtsp->grf_prop.subst_id; // so just give it the substitute } -static uint32 GetClosestIndustry(TileIndex tile, IndustryType type, const Industry *current) +static uint32_t GetClosestIndustry(TileIndex tile, IndustryType type, const Industry *current) { - uint32 best_dist = UINT32_MAX; + uint32_t best_dist = UINT32_MAX; for (const Industry *i : Industry::Iterate()) { if (i->type != type || i == current) continue; @@ -111,11 +111,11 @@ static uint32 GetClosestIndustry(TileIndex tile, IndustryType type, const Indust * @param current Industry for which the inquiry is made * @return the formatted answer to the callback : rr(reserved) cc(count) dddd(manhattan distance of closest sister) */ -static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout_filter, bool town_filter, const Industry *current) +static uint32_t GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout_filter, bool town_filter, const Industry *current) { - uint32 GrfID = GetRegister(0x100); ///< Get the GRFID of the definition to look for in register 100h + uint32_t GrfID = GetRegister(0x100); ///< Get the GRFID of the definition to look for in register 100h IndustryType ind_index; - uint32 closest_dist = UINT32_MAX; + uint32_t closest_dist = UINT32_MAX; byte count = 0; /* Determine what will be the industry type to look for */ @@ -156,7 +156,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout return count << 16 | GB(closest_dist, 0, 16); } -/* virtual */ uint32 IndustriesScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const +/* virtual */ uint32_t IndustriesScopeResolver::GetVariable(byte variable, uint32_t parameter, bool *available) const { if (this->ro.callback == CBID_INDUSTRY_LOCATION) { /* Variables available during construction check. */ @@ -210,13 +210,13 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout case 0x40: case 0x41: case 0x42: { // waiting cargo, but only if those two callback flags are set - uint16 callback = indspec->callback_mask; + uint16_t callback = indspec->callback_mask; if (HasBit(callback, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(callback, CBM_IND_PRODUCTION_256_TICKS)) { if ((indspec->behaviour & INDUSTRYBEH_PROD_MULTI_HNDLING) != 0) { if (this->industry->prod_level == 0) return 0; - return ClampTo(this->industry->accepted[variable - 0x40].waiting / this->industry->prod_level); + return ClampTo(this->industry->accepted[variable - 0x40].waiting / this->industry->prod_level); } else { - return ClampTo(this->industry->accepted[variable - 0x40].waiting); + return ClampTo(this->industry->accepted[variable - 0x40].waiting); } } else { return 0; @@ -301,7 +301,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout byte layout_filter = 0; bool town_filter = false; if (variable == 0x68) { - uint32 reg = GetRegister(0x101); + uint32_t reg = GetRegister(0x101); layout_filter = GB(reg, 0, 8); town_filter = HasBit(reg, 8); } @@ -415,17 +415,17 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout return UINT_MAX; } -/* virtual */ uint32 IndustriesScopeResolver::GetRandomBits() const +/* virtual */ uint32_t IndustriesScopeResolver::GetRandomBits() const { return this->industry != nullptr ? this->industry->random : 0; } -/* virtual */ uint32 IndustriesScopeResolver::GetTriggers() const +/* virtual */ uint32_t IndustriesScopeResolver::GetTriggers() const { return 0; } -/* virtual */ void IndustriesScopeResolver::StorePSA(uint pos, int32 value) +/* virtual */ void IndustriesScopeResolver::StorePSA(uint pos, int32_t value) { if (this->industry->index == INVALID_INDUSTRY) return; @@ -435,7 +435,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout /* Create storage on first modification. */ const IndustrySpec *indsp = GetIndustrySpec(this->industry->type); - uint32 grfid = (indsp->grf_prop.grffile != nullptr) ? indsp->grf_prop.grffile->grfid : 0; + uint32_t grfid = (indsp->grf_prop.grffile != nullptr) ? indsp->grf_prop.grffile->grfid : 0; assert(PersistentStorage::CanAllocateItem()); this->industry->psa = new PersistentStorage(grfid, GSF_INDUSTRIES, this->industry->location.tile); } @@ -464,8 +464,8 @@ static const GRFFile *GetGrffile(IndustryType type) * @param callback_param1 First parameter (var 10) of the callback. * @param callback_param2 Second parameter (var 18) of the callback. */ -IndustriesResolverObject::IndustriesResolverObject(TileIndex tile, Industry *indus, IndustryType type, uint32 random_bits, - CallbackID callback, uint32 callback_param1, uint32 callback_param2) +IndustriesResolverObject::IndustriesResolverObject(TileIndex tile, Industry *indus, IndustryType type, uint32_t random_bits, + CallbackID callback, uint32_t callback_param1, uint32_t callback_param2) : ResolverObject(GetGrffile(type), callback, callback_param1, callback_param2), industries_scope(*this, tile, indus, type, random_bits), town_scope(nullptr) @@ -504,7 +504,7 @@ GrfSpecFeature IndustriesResolverObject::GetFeature() const return GSF_INDUSTRIES; } -uint32 IndustriesResolverObject::GetDebugID() const +uint32_t IndustriesResolverObject::GetDebugID() const { return GetIndustrySpec(this->industries_scope.type)->grf_prop.local_id; } @@ -519,7 +519,7 @@ uint32 IndustriesResolverObject::GetDebugID() const * @param tile The tile associated with the callback. * @return The callback result. */ -uint16 GetIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile) +uint16_t GetIndustryCallback(CallbackID callback, uint32_t param1, uint32_t param2, Industry *industry, IndustryType type, TileIndex tile) { IndustriesResolverObject object(tile, industry, type, 0, callback, param1, param2); return object.ResolveCallback(); @@ -536,7 +536,7 @@ uint16 GetIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, In * @param creation_type The circumstances the industry is created under. * @return Succeeded or failed command. */ -CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, size_t layout, uint32 seed, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type) +CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, size_t layout, uint32_t seed, uint16_t initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type) { const IndustrySpec *indspec = GetIndustrySpec(type); @@ -552,7 +552,7 @@ CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, siz ind.psa = nullptr; IndustriesResolverObject object(tile, &ind, type, seed, CBID_INDUSTRY_LOCATION, 0, creation_type); - uint16 result = object.ResolveCallback(); + uint16_t result = object.ResolveCallback(); /* Unlike the "normal" cases, not having a valid result means we allow * the building of the industry, as that's how it's done in TTDP. */ @@ -567,12 +567,12 @@ CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, siz * @param creation_type Reason to construct a new industry. * @return If the industry has no callback or allows building, \c true is returned. Otherwise, \c false is returned. */ -uint32 GetIndustryProbabilityCallback(IndustryType type, IndustryAvailabilityCallType creation_type, uint32 default_prob) +uint32_t GetIndustryProbabilityCallback(IndustryType type, IndustryAvailabilityCallType creation_type, uint32_t default_prob) { const IndustrySpec *indspec = GetIndustrySpec(type); if (HasBit(indspec->callback_mask, CBM_IND_PROBABILITY)) { - uint16 res = GetIndustryCallback(CBID_INDUSTRY_PROBABILITY, 0, creation_type, nullptr, type, INVALID_TILE); + uint16_t res = GetIndustryCallback(CBID_INDUSTRY_PROBABILITY, 0, creation_type, nullptr, type, INVALID_TILE); if (res != CALLBACK_FAILED) { if (indspec->grf_prop.grffile->grf_version < 8) { /* Disallow if result != 0 */ @@ -590,9 +590,9 @@ uint32 GetIndustryProbabilityCallback(IndustryType type, IndustryAvailabilityCal return default_prob; } -static int32 DerefIndProd(int field, bool use_register) +static int32_t DerefIndProd(int field, bool use_register) { - return use_register ? (int32)GetRegister(field) : field; + return use_register ? (int32_t)GetRegister(field) : field; } /** @@ -662,7 +662,7 @@ void IndustryProductionCallback(Industry *ind, int reason) } } - int32 again = DerefIndProd(group->again, deref); + int32_t again = DerefIndProd(group->again, deref); if (again == 0) break; SB(object.callback_param2, 24, 8, again); @@ -684,7 +684,7 @@ bool IndustryTemporarilyRefusesCargo(Industry *ind, CargoID cargo_type) const IndustrySpec *indspec = GetIndustrySpec(ind->type); if (HasBit(indspec->callback_mask, CBM_IND_REFUSE_CARGO)) { - uint16 res = GetIndustryCallback(CBID_INDUSTRY_REFUSE_CARGO, + uint16_t res = GetIndustryCallback(CBID_INDUSTRY_REFUSE_CARGO, 0, indspec->grf_prop.grffile->cargo_map[cargo_type], ind, ind->type, ind->location.tile); if (res != CALLBACK_FAILED) return !ConvertBooleanCallback(indspec->grf_prop.grffile, CBID_INDUSTRY_REFUSE_CARGO, res); diff --git a/src/newgrf_industries.h b/src/newgrf_industries.h index 01a185aa19..d4be4bad68 100644 --- a/src/newgrf_industries.h +++ b/src/newgrf_industries.h @@ -17,7 +17,7 @@ struct IndustriesScopeResolver : public ScopeResolver { TileIndex tile; ///< Tile owned by the industry. Industry *industry; ///< %Industry being resolved. IndustryType type; ///< Type of the industry. - uint32 random_bits; ///< Random bits of the new industry. + uint32_t random_bits; ///< Random bits of the new industry. /** * Scope resolver for industries. @@ -27,15 +27,15 @@ struct IndustriesScopeResolver : public ScopeResolver { * @param type Type of the industry. * @param random_bits Random bits of the new industry. */ - IndustriesScopeResolver(ResolverObject &ro, TileIndex tile, Industry *industry, IndustryType type, uint32 random_bits = 0) + IndustriesScopeResolver(ResolverObject &ro, TileIndex tile, Industry *industry, IndustryType type, uint32_t random_bits = 0) : ScopeResolver(ro), tile(tile), industry(industry), type(type), random_bits(random_bits) { } - uint32 GetRandomBits() const override; - uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; - uint32 GetTriggers() const override; - void StorePSA(uint pos, int32 value) override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(byte variable, uint32_t parameter, bool *available) const override; + uint32_t GetTriggers() const override; + void StorePSA(uint pos, int32_t value) override; }; /** Resolver for industries. */ @@ -43,8 +43,8 @@ struct IndustriesResolverObject : public ResolverObject { IndustriesScopeResolver industries_scope; ///< Scope resolver for the industry. TownScopeResolver *town_scope; ///< Scope resolver for the associated town (if needed and available, else \c nullptr). - IndustriesResolverObject(TileIndex tile, Industry *indus, IndustryType type, uint32 random_bits = 0, - CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0); + IndustriesResolverObject(TileIndex tile, Industry *indus, IndustryType type, uint32_t random_bits = 0, + CallbackID callback = CBID_NO_CALLBACK, uint32_t callback_param1 = 0, uint32_t callback_param2 = 0); ~IndustriesResolverObject(); TownScopeResolver *GetTown(); @@ -65,7 +65,7 @@ struct IndustriesResolverObject : public ResolverObject { } GrfSpecFeature GetFeature() const override; - uint32 GetDebugID() const override; + uint32_t GetDebugID() const override; }; /** When should the industry(tile) be triggered for random bits? */ @@ -87,16 +87,16 @@ enum IndustryAvailabilityCallType { }; /* in newgrf_industry.cpp */ -uint16 GetIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile); -uint32 GetIndustryIDAtOffset(TileIndex new_tile, const Industry *i, uint32 cur_grfid); +uint16_t GetIndustryCallback(CallbackID callback, uint32_t param1, uint32_t param2, Industry *industry, IndustryType type, TileIndex tile); +uint32_t GetIndustryIDAtOffset(TileIndex new_tile, const Industry *i, uint32_t cur_grfid); void IndustryProductionCallback(Industry *ind, int reason); -CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, size_t layout, uint32 seed, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type); -uint32 GetIndustryProbabilityCallback(IndustryType type, IndustryAvailabilityCallType creation_type, uint32 default_prob); +CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, size_t layout, uint32_t seed, uint16_t initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type); +uint32_t GetIndustryProbabilityCallback(IndustryType type, IndustryAvailabilityCallType creation_type, uint32_t default_prob); bool IndustryTemporarilyRefusesCargo(Industry *ind, CargoID cargo_type); -IndustryType MapNewGRFIndustryType(IndustryType grf_type, uint32 grf_id); +IndustryType MapNewGRFIndustryType(IndustryType grf_type, uint32_t grf_id); /* in newgrf_industrytiles.cpp*/ -uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8); +uint32_t GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8); #endif /* NEWGRF_INDUSTRIES_H */ diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp index 72241fb120..e24f5e0f80 100644 --- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -31,7 +31,7 @@ * @param grf_version8 True, if we are dealing with a new NewGRF which uses GRF version >= 8. * @return a construction of bits obeying the newgrf format */ -uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8) +uint32_t GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8) { if (parameter != 0) tile = GetNearbyTile(parameter, tile, signed_offsets); // only perform if it is required bool is_same_industry = (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == index); @@ -50,7 +50,7 @@ uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, Industry * @param tile TileIndex of the tile to evaluate * @param ind_tile northernmost tile of the industry */ -uint32 GetRelativePosition(TileIndex tile, TileIndex ind_tile) +uint32_t GetRelativePosition(TileIndex tile, TileIndex ind_tile) { byte x = TileX(tile) - TileX(ind_tile); byte y = TileY(tile) - TileY(ind_tile); @@ -58,7 +58,7 @@ uint32 GetRelativePosition(TileIndex tile, TileIndex ind_tile) return ((y & 0xF) << 20) | ((x & 0xF) << 16) | (y << 8) | x; } -/* virtual */ uint32 IndustryTileScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const +/* virtual */ uint32_t IndustryTileScopeResolver::GetVariable(byte variable, uint32_t parameter, bool *available) const { switch (variable) { /* Construction state of the tile: a value between 0 and 3 */ @@ -99,7 +99,7 @@ uint32 GetRelativePosition(TileIndex tile, TileIndex ind_tile) return UINT_MAX; } -/* virtual */ uint32 IndustryTileScopeResolver::GetRandomBits() const +/* virtual */ uint32_t IndustryTileScopeResolver::GetRandomBits() const { assert(this->industry != nullptr && IsValidTile(this->tile)); assert(this->industry->index == INVALID_INDUSTRY || IsTileType(this->tile, MP_INDUSTRY)); @@ -107,7 +107,7 @@ uint32 GetRelativePosition(TileIndex tile, TileIndex ind_tile) return (this->industry->index != INVALID_INDUSTRY) ? GetIndustryRandomBits(this->tile) : 0; } -/* virtual */ uint32 IndustryTileScopeResolver::GetTriggers() const +/* virtual */ uint32_t IndustryTileScopeResolver::GetTriggers() const { assert(this->industry != nullptr && IsValidTile(this->tile)); assert(this->industry->index == INVALID_INDUSTRY || IsTileType(this->tile, MP_INDUSTRY)); @@ -136,7 +136,7 @@ static const GRFFile *GetIndTileGrffile(IndustryGfx gfx) * @param callback_param2 Second parameter (var 18) of the callback. */ IndustryTileResolverObject::IndustryTileResolverObject(IndustryGfx gfx, TileIndex tile, Industry *indus, - CallbackID callback, uint32 callback_param1, uint32 callback_param2) + CallbackID callback, uint32_t callback_param1, uint32_t callback_param2) : ResolverObject(GetIndTileGrffile(gfx), callback, callback_param1, callback_param2), indtile_scope(*this, indus, tile), ind_scope(*this, tile, indus, indus->type), @@ -150,7 +150,7 @@ GrfSpecFeature IndustryTileResolverObject::GetFeature() const return GSF_INDUSTRYTILES; } -uint32 IndustryTileResolverObject::GetDebugID() const +uint32_t IndustryTileResolverObject::GetDebugID() const { return GetIndustryTileSpec(gfx)->grf_prop.local_id; } @@ -178,7 +178,7 @@ static void IndustryDrawTileLayout(const TileInfo *ti, const TileLayoutSpriteGro DrawNewGRFTileSeq(ti, dts, TO_INDUSTRIES, stage, GENERAL_SPRITE_COLOUR(rnd_colour)); } -uint16 GetIndustryTileCallback(CallbackID callback, uint32 param1, uint32 param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile) +uint16_t GetIndustryTileCallback(CallbackID callback, uint32_t param1, uint32_t param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile) { assert(industry != nullptr && IsValidTile(tile)); assert(industry->index == INVALID_INDUSTRY || IsTileType(tile, MP_INDUSTRY)); @@ -193,7 +193,7 @@ bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const Indus bool draw_old_one = true; if (HasBit(inds->callback_mask, CBM_INDT_DRAW_FOUNDATIONS)) { /* Called to determine the type (if any) of foundation to draw for industry tile */ - uint32 callback_res = GetIndustryTileCallback(CBID_INDTILE_DRAW_FOUNDATIONS, 0, 0, gfx, i, ti->tile); + uint32_t callback_res = GetIndustryTileCallback(CBID_INDTILE_DRAW_FOUNDATIONS, 0, 0, gfx, i, ti->tile); if (callback_res != CALLBACK_FAILED) draw_old_one = ConvertBooleanCallback(inds->grf_prop.grffile, CBID_INDTILE_DRAW_FOUNDATIONS, callback_res); } @@ -227,7 +227,7 @@ extern bool IsSlopeRefused(Slope current, Slope refused); * @param creation_type The circumstances the industry is created under. * @return Succeeded or failed command. */ -CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, size_t layout_index, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type) +CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, size_t layout_index, uint16_t initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type) { Industry ind; ind.index = INVALID_INDUSTRY; @@ -237,7 +237,7 @@ CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind ind.random = initial_random_bits; ind.founder = founder; - uint16 callback_res = GetIndustryTileCallback(CBID_INDTILE_SHAPE_CHECK, 0, creation_type << 8 | (uint32)layout_index, gfx, &ind, ind_tile); + uint16_t callback_res = GetIndustryTileCallback(CBID_INDTILE_SHAPE_CHECK, 0, creation_type << 8 | (uint32_t)layout_index, gfx, &ind, ind_tile); if (callback_res == CALLBACK_FAILED) { if (!IsSlopeRefused(GetTileSlope(ind_tile), its->slopes_refused)) return CommandCost(); return_cmd_error(STR_ERROR_SITE_UNSUITABLE); @@ -251,7 +251,7 @@ CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind } /* Simple wrapper for GetHouseCallback to keep the animation unified. */ -uint16 GetSimpleIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, const IndustryTileSpec *spec, Industry *ind, TileIndex tile, int extra_data) +uint16_t GetSimpleIndustryCallback(CallbackID callback, uint32_t param1, uint32_t param2, const IndustryTileSpec *spec, Industry *ind, TileIndex tile, int extra_data) { return GetIndustryTileCallback(callback, param1, param2, spec - GetIndustryTileSpec(0), ind, tile); } @@ -273,7 +273,7 @@ void AnimateNewIndustryTile(TileIndex tile) IndustryAnimationBase::AnimateTile(itspec, Industry::GetByTile(tile), tile, (itspec->special_flags & INDTILE_SPECIAL_NEXTFRAME_RANDOMBITS) != 0); } -bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32 random) +bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32_t random) { const IndustryTileSpec *itspec = GetIndustryTileSpec(GetIndustryGfx(tile)); @@ -286,7 +286,7 @@ bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigger iat) { bool ret = true; - uint32 random = Random(); + uint32_t random = Random(); for (TileIndex tile : ind->location) { if (ind->TileBelongsToIndustry(tile)) { if (StartStopIndustryTileAnimation(tile, iat, random)) { @@ -307,7 +307,7 @@ bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigge * @param ind Industry of the tile. * @param[in,out] reseed_industry Collects bits to reseed for the industry. */ -static void DoTriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger, Industry *ind, uint32 &reseed_industry) +static void DoTriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger, Industry *ind, uint32_t &reseed_industry) { assert(IsValidTile(tile) && IsTileType(tile, MP_INDUSTRY)); @@ -342,11 +342,11 @@ static void DoTriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger, I * @param ind Industry. * @param reseed Bits to reseed. */ -static void DoReseedIndustry(Industry *ind, uint32 reseed) +static void DoReseedIndustry(Industry *ind, uint32_t reseed) { if (reseed == 0 || ind == nullptr) return; - uint16 random_bits = Random(); + uint16_t random_bits = Random(); ind->random &= reseed; ind->random |= random_bits & reseed; } @@ -358,7 +358,7 @@ static void DoReseedIndustry(Industry *ind, uint32 reseed) */ void TriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger) { - uint32 reseed_industry = 0; + uint32_t reseed_industry = 0; Industry *ind = Industry::GetByTile(tile); DoTriggerIndustryTile(tile, trigger, ind, reseed_industry); DoReseedIndustry(ind, reseed_industry); @@ -371,7 +371,7 @@ void TriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger) */ void TriggerIndustry(Industry *ind, IndustryTileTrigger trigger) { - uint32 reseed_industry = 0; + uint32_t reseed_industry = 0; for (TileIndex tile : ind->location) { if (ind->TileBelongsToIndustry(tile)) { DoTriggerIndustryTile(tile, trigger, ind, reseed_industry); diff --git a/src/newgrf_industrytiles.h b/src/newgrf_industrytiles.h index e5494ea302..79bc38d0ac 100644 --- a/src/newgrf_industrytiles.h +++ b/src/newgrf_industrytiles.h @@ -30,9 +30,9 @@ struct IndustryTileScopeResolver : public ScopeResolver { { } - uint32 GetRandomBits() const override; - uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; - uint32 GetTriggers() const override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(byte variable, uint32_t parameter, bool *available) const override; + uint32_t GetTriggers() const override; }; /** Resolver for industry tiles. */ @@ -42,7 +42,7 @@ struct IndustryTileResolverObject : public ResolverObject { IndustryGfx gfx; IndustryTileResolverObject(IndustryGfx gfx, TileIndex tile, Industry *indus, - CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0); + CallbackID callback = CBID_NO_CALLBACK, uint32_t callback_param1 = 0, uint32_t callback_param2 = 0); ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { @@ -54,15 +54,15 @@ struct IndustryTileResolverObject : public ResolverObject { } GrfSpecFeature GetFeature() const override; - uint32 GetDebugID() const override; + uint32_t GetDebugID() const override; }; bool DrawNewIndustryTile(TileInfo *ti, Industry *i, IndustryGfx gfx, const IndustryTileSpec *inds); -uint16 GetIndustryTileCallback(CallbackID callback, uint32 param1, uint32 param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile); -CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, size_t layout_index, uint16 initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type); +uint16_t GetIndustryTileCallback(CallbackID callback, uint32_t param1, uint32_t param2, IndustryGfx gfx_id, Industry *industry, TileIndex tile); +CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, size_t layout_index, uint16_t initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type); void AnimateNewIndustryTile(TileIndex tile); -bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32 random = Random()); +bool StartStopIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32_t random = Random()); bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigger iat); diff --git a/src/newgrf_object.cpp b/src/newgrf_object.cpp index cc418df29b..ee65ac6359 100644 --- a/src/newgrf_object.cpp +++ b/src/newgrf_object.cpp @@ -126,7 +126,7 @@ void ResetObjects() /* And add our originals. */ _object_specs.reserve(lengthof(_original_objects)); - for (uint16 i = 0; i < lengthof(_original_objects); i++) { + for (uint16_t i = 0; i < lengthof(_original_objects); i++) { ObjectSpec &spec = _object_specs.emplace_back(_original_objects[i]); spec.grf_prop.local_id = i; } @@ -151,7 +151,7 @@ bool NewGRFClass::IsUIAvailable(uint index) const INSTANTIATE_NEWGRF_CLASS_METHODS(ObjectClass, ObjectSpec, ObjectClassID, OBJECT_CLASS_MAX) -/* virtual */ uint32 ObjectScopeResolver::GetRandomBits() const +/* virtual */ uint32_t ObjectScopeResolver::GetRandomBits() const { return IsValidTile(this->tile) && IsTileType(this->tile, MP_OBJECT) ? GetObjectRandomBits(this->tile) : 0; } @@ -162,7 +162,7 @@ INSTANTIATE_NEWGRF_CLASS_METHODS(ObjectClass, ObjectSpec, ObjectClassID, OBJECT_ * @param cur_grfid GRFID of the current callback chain * @return value encoded as per NFO specs */ -static uint32 GetObjectIDAtOffset(TileIndex tile, uint32 cur_grfid) +static uint32_t GetObjectIDAtOffset(TileIndex tile, uint32_t cur_grfid) { if (!IsTileType(tile, MP_OBJECT)) { return 0xFFFF; @@ -191,7 +191,7 @@ static uint32 GetObjectIDAtOffset(TileIndex tile, uint32 cur_grfid) * @param grf_version8 True, if we are dealing with a new NewGRF which uses GRF version >= 8. * @return a construction of bits obeying the newgrf format */ -static uint32 GetNearbyObjectTileInformation(byte parameter, TileIndex tile, ObjectID index, bool grf_version8) +static uint32_t GetNearbyObjectTileInformation(byte parameter, TileIndex tile, ObjectID index, bool grf_version8) { if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required bool is_same_object = (IsTileType(tile, MP_OBJECT) && GetObjectIndex(tile) == index); @@ -206,9 +206,9 @@ static uint32 GetNearbyObjectTileInformation(byte parameter, TileIndex tile, Obj * @param current The current object (to ignore). * @return The distance to the closest object. */ -static uint32 GetClosestObject(TileIndex tile, ObjectType type, const Object *current) +static uint32_t GetClosestObject(TileIndex tile, ObjectType type, const Object *current) { - uint32 best_dist = UINT32_MAX; + uint32_t best_dist = UINT32_MAX; for (const Object *o : Object::Iterate()) { if (o->type != type || o == current) continue; @@ -226,10 +226,10 @@ static uint32 GetClosestObject(TileIndex tile, ObjectType type, const Object *cu * @param current Object for which the inquiry is made * @return The formatted answer to the callback : rr(reserved) cc(count) dddd(manhattan distance of closest sister) */ -static uint32 GetCountAndDistanceOfClosestInstance(byte local_id, uint32 grfid, TileIndex tile, const Object *current) +static uint32_t GetCountAndDistanceOfClosestInstance(byte local_id, uint32_t grfid, TileIndex tile, const Object *current) { - uint32 grf_id = GetRegister(0x100); // Get the GRFID of the definition to look for in register 100h - uint32 idx; + uint32_t grf_id = GetRegister(0x100); // Get the GRFID of the definition to look for in register 100h + uint32_t idx; /* Determine what will be the object type to look for */ switch (grf_id) { @@ -253,7 +253,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte local_id, uint32 grfid, } /** Used by the resolver to get values for feature 0F deterministic spritegroups. */ -/* virtual */ uint32 ObjectScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const +/* virtual */ uint32_t ObjectScopeResolver::GetVariable(byte variable, uint32_t parameter, bool *available) const { /* We get the town from the object, or we calculate the closest * town if we need to when there's no object. */ @@ -373,8 +373,8 @@ unhandled: * @param param1 First parameter (var 10) of the callback. * @param param2 Second parameter (var 18) of the callback. */ -ObjectResolverObject::ObjectResolverObject(const ObjectSpec *spec, Object *obj, TileIndex tile, uint8 view, - CallbackID callback, uint32 param1, uint32 param2) +ObjectResolverObject::ObjectResolverObject(const ObjectSpec *spec, Object *obj, TileIndex tile, uint8_t view, + CallbackID callback, uint32_t param1, uint32_t param2) : ResolverObject(spec->grf_prop.grffile, callback, param1, param2), object_scope(*this, obj, spec, tile, view) { this->town_scope = nullptr; @@ -412,7 +412,7 @@ GrfSpecFeature ObjectResolverObject::GetFeature() const return GSF_OBJECTS; } -uint32 ObjectResolverObject::GetDebugID() const +uint32_t ObjectResolverObject::GetDebugID() const { return this->object_scope.spec->grf_prop.local_id; } @@ -428,7 +428,7 @@ uint32 ObjectResolverObject::GetDebugID() const * @param view The view of the object (only used when o == nullptr). * @return The result of the callback. */ -uint16 GetObjectCallback(CallbackID callback, uint32 param1, uint32 param2, const ObjectSpec *spec, Object *o, TileIndex tile, uint8 view) +uint16_t GetObjectCallback(CallbackID callback, uint32_t param1, uint32_t param2, const ObjectSpec *spec, Object *o, TileIndex tile, uint8_t view) { ObjectResolverObject object(spec, o, tile, view, callback, param1, param2); return object.ResolveCallback(); @@ -484,7 +484,7 @@ void DrawNewObjectTile(TileInfo *ti, const ObjectSpec *spec) * @param spec Object spec to draw. * @param view The object's view. */ -void DrawNewObjectTileInGUI(int x, int y, const ObjectSpec *spec, uint8 view) +void DrawNewObjectTileInGUI(int x, int y, const ObjectSpec *spec, uint8_t view) { ObjectResolverObject object(spec, nullptr, INVALID_TILE, view); const SpriteGroup *group = object.Resolve(); @@ -527,7 +527,7 @@ void DrawNewObjectTileInGUI(int x, int y, const ObjectSpec *spec, uint8 view) * @param extra_data Ignored. * @return The result of the callback. */ -uint16 StubGetObjectCallback(CallbackID callback, uint32 param1, uint32 param2, const ObjectSpec *spec, Object *o, TileIndex tile, int extra_data) +uint16_t StubGetObjectCallback(CallbackID callback, uint32_t param1, uint32_t param2, const ObjectSpec *spec, Object *o, TileIndex tile, int extra_data) { return GetObjectCallback(callback, param1, param2, spec, o, tile); } diff --git a/src/newgrf_object.h b/src/newgrf_object.h index e82f916cb8..2940f96440 100644 --- a/src/newgrf_object.h +++ b/src/newgrf_object.h @@ -21,7 +21,7 @@ #include "newgrf_commons.h" /** Various object behaviours. */ -enum ObjectFlags : uint16 { +enum ObjectFlags : uint16_t { OBJECT_FLAG_NONE = 0, ///< Just nothing. OBJECT_FLAG_ONLY_IN_SCENEDIT = 1 << 0, ///< Object can only be constructed in the scenario editor. OBJECT_FLAG_CANNOT_REMOVE = 1 << 1, ///< Object can not be removed. @@ -40,12 +40,12 @@ enum ObjectFlags : uint16 { }; DECLARE_ENUM_AS_BIT_SET(ObjectFlags) -static const uint8 OBJECT_SIZE_1X1 = 0x11; ///< The value of a NewGRF's size property when the object is 1x1 tiles: low nibble for X, high nibble for Y. +static const uint8_t OBJECT_SIZE_1X1 = 0x11; ///< The value of a NewGRF's size property when the object is 1x1 tiles: low nibble for X, high nibble for Y. void ResetObjects(); /** Class IDs for objects. */ -enum ObjectClassID : uint8 { +enum ObjectClassID : uint8_t { OBJECT_CLASS_BEGIN = 0, ///< The lowest valid value OBJECT_CLASS_MAX = 0xFF, ///< Maximum number of classes. INVALID_OBJECT_CLASS = 0xFF, ///< Class for the less fortunate. @@ -64,17 +64,17 @@ struct ObjectSpec { ObjectClassID cls_id; ///< The class to which this spec belongs. StringID name; ///< The name for this object. - uint8 climate; ///< In which climates is this object available? - uint8 size; ///< The size of this objects; low nibble for X, high nibble for Y. - uint8 build_cost_multiplier; ///< Build cost multiplier per tile. - uint8 clear_cost_multiplier; ///< Clear cost multiplier per tile. + uint8_t climate; ///< In which climates is this object available? + uint8_t size; ///< The size of this objects; low nibble for X, high nibble for Y. + uint8_t build_cost_multiplier; ///< Build cost multiplier per tile. + uint8_t clear_cost_multiplier; ///< Clear cost multiplier per tile. TimerGameCalendar::Date introduction_date; ///< From when can this object be built. TimerGameCalendar::Date end_of_life_date; ///< When can't this object be built anymore. ObjectFlags flags; ///< Flags/settings related to the object. - uint16 callback_mask; ///< Bitmask of requested/allowed callbacks. - uint8 height; ///< The height of this structure, in heightlevels; max MAX_TILE_HEIGHT. - uint8 views; ///< The number of views. - uint8 generate_amount; ///< Number of objects which are attempted to be generated per 256^2 map during world generation. + uint16_t callback_mask; ///< Bitmask of requested/allowed callbacks. + uint8_t height; ///< The height of this structure, in heightlevels; max MAX_TILE_HEIGHT. + uint8_t views; ///< The number of views. + uint8_t generate_amount; ///< Number of objects which are attempted to be generated per 256^2 map during world generation. /** * Test if this object is enabled. @@ -112,7 +112,7 @@ struct ObjectScopeResolver : public ScopeResolver { struct Object *obj; ///< The object the callback is ran for. const ObjectSpec *spec; ///< Specification of the object type. TileIndex tile; ///< The tile related to the object. - uint8 view; ///< The view of the object. + uint8_t view; ///< The view of the object. /** * Constructor of an object scope resolver. @@ -121,13 +121,13 @@ struct ObjectScopeResolver : public ScopeResolver { * @param tile %Tile of the object. * @param view View of the object. */ - ObjectScopeResolver(ResolverObject &ro, Object *obj, const ObjectSpec *spec, TileIndex tile, uint8 view = 0) + ObjectScopeResolver(ResolverObject &ro, Object *obj, const ObjectSpec *spec, TileIndex tile, uint8_t view = 0) : ScopeResolver(ro), obj(obj), spec(spec), tile(tile), view(view) { } - uint32 GetRandomBits() const override; - uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(byte variable, uint32_t parameter, bool *available) const override; }; /** A resolver object to be used with feature 0F spritegroups. */ @@ -135,8 +135,8 @@ struct ObjectResolverObject : public ResolverObject { ObjectScopeResolver object_scope; ///< The object scope resolver. TownScopeResolver *town_scope; ///< The town scope resolver (created on the first call). - ObjectResolverObject(const ObjectSpec *spec, Object *o, TileIndex tile, uint8 view = 0, - CallbackID callback = CBID_NO_CALLBACK, uint32 param1 = 0, uint32 param2 = 0); + ObjectResolverObject(const ObjectSpec *spec, Object *o, TileIndex tile, uint8_t view = 0, + CallbackID callback = CBID_NO_CALLBACK, uint32_t param1 = 0, uint32_t param2 = 0); ~ObjectResolverObject(); ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override @@ -157,7 +157,7 @@ struct ObjectResolverObject : public ResolverObject { } GrfSpecFeature GetFeature() const override; - uint32 GetDebugID() const override; + uint32_t GetDebugID() const override; private: TownScopeResolver *GetTown(); @@ -169,10 +169,10 @@ typedef NewGRFClass ObjectClass; static const size_t OBJECT_SPRITE_GROUP_DEFAULT = 0; static const size_t OBJECT_SPRITE_GROUP_PURCHASE = 1; -uint16 GetObjectCallback(CallbackID callback, uint32 param1, uint32 param2, const ObjectSpec *spec, Object *o, TileIndex tile, uint8 view = 0); +uint16_t GetObjectCallback(CallbackID callback, uint32_t param1, uint32_t param2, const ObjectSpec *spec, Object *o, TileIndex tile, uint8_t view = 0); void DrawNewObjectTile(TileInfo *ti, const ObjectSpec *spec); -void DrawNewObjectTileInGUI(int x, int y, const ObjectSpec *spec, uint8 view); +void DrawNewObjectTileInGUI(int x, int y, const ObjectSpec *spec, uint8_t view); void AnimateNewObjectTile(TileIndex tile); void TriggerObjectTileAnimation(Object *o, TileIndex tile, ObjectAnimationTrigger trigger, const ObjectSpec *spec); void TriggerObjectAnimation(Object *o, ObjectAnimationTrigger trigger, const ObjectSpec *spec); diff --git a/src/newgrf_profiling.cpp b/src/newgrf_profiling.cpp index 54ca5f782f..221d07f2f8 100644 --- a/src/newgrf_profiling.cpp +++ b/src/newgrf_profiling.cpp @@ -47,7 +47,7 @@ void NewGRFProfiler::BeginResolve(const ResolverObject &resolver) using namespace std::chrono; this->cur_call.root_sprite = resolver.root_spritegroup->nfo_line; this->cur_call.subs = 0; - this->cur_call.time = (uint32)time_point_cast(high_resolution_clock::now()).time_since_epoch().count(); + this->cur_call.time = (uint32_t)time_point_cast(high_resolution_clock::now()).time_since_epoch().count(); this->cur_call.tick = TimerGameTick::counter; this->cur_call.cb = resolver.callback; this->cur_call.feat = resolver.GetFeature(); @@ -60,7 +60,7 @@ void NewGRFProfiler::BeginResolve(const ResolverObject &resolver) void NewGRFProfiler::EndResolve(const SpriteGroup *result) { using namespace std::chrono; - this->cur_call.time = (uint32)time_point_cast(high_resolution_clock::now()).time_since_epoch().count() - this->cur_call.time; + this->cur_call.time = (uint32_t)time_point_cast(high_resolution_clock::now()).time_since_epoch().count() - this->cur_call.time; if (result == nullptr) { this->cur_call.result = 0; @@ -90,7 +90,7 @@ void NewGRFProfiler::Start() this->start_tick = TimerGameTick::counter; } -uint32 NewGRFProfiler::Finish() +uint32_t NewGRFProfiler::Finish() { if (!this->active) return 0; @@ -107,7 +107,7 @@ uint32 NewGRFProfiler::Finish() FILE *f = FioFOpenFile(filename, "wt", Subdirectory::NO_DIRECTORY); FileCloser fcloser(f); - uint32 total_microseconds = 0; + uint32_t total_microseconds = 0; fmt::print(f, "Tick,Sprite,Feature,Item,CallbackID,Microseconds,Depth,Result\n"); for (const Call &c : this->calls) { @@ -134,12 +134,12 @@ std::string NewGRFProfiler::GetOutputFilename() const return fmt::format("{}grfprofile-{%Y%m%d-%H%M}-{:08X}.csv", FiosGetScreenshotDir(), fmt::localtime(time(nullptr)), BSWAP32(this->grffile->grfid)); } -/* static */ uint32 NewGRFProfiler::FinishAll() +/* static */ uint32_t NewGRFProfiler::FinishAll() { NewGRFProfiler::AbortTimer(); - uint64 max_ticks = 0; - uint32 total_microseconds = 0; + uint64_t max_ticks = 0; + uint32_t total_microseconds = 0; for (NewGRFProfiler &pr : _newgrf_profilers) { if (pr.active) { total_microseconds += pr.Finish(); @@ -165,7 +165,7 @@ static TimeoutTimer _profiling_finish_timeout(0, []() /** * Start the timeout timer that will finish all profiling sessions. */ -/* static */ void NewGRFProfiler::StartTimer(uint64 ticks) +/* static */ void NewGRFProfiler::StartTimer(uint64_t ticks) { _profiling_finish_timeout.Reset(ticks); } diff --git a/src/newgrf_profiling.h b/src/newgrf_profiling.h index 09b504fe18..d67f069377 100644 --- a/src/newgrf_profiling.h +++ b/src/newgrf_profiling.h @@ -30,29 +30,29 @@ struct NewGRFProfiler { void RecursiveResolve(); void Start(); - uint32 Finish(); + uint32_t Finish(); void Abort(); std::string GetOutputFilename() const; - static void StartTimer(uint64 ticks); + static void StartTimer(uint64_t ticks); static void AbortTimer(); - static uint32 FinishAll(); + static uint32_t FinishAll(); /** Measurement of a single sprite group resolution */ struct Call { - uint32 root_sprite; ///< Pseudo-sprite index in GRF file - uint32 item; ///< Local ID of item being resolved for - uint32 result; ///< Result of callback - uint32 subs; ///< Sub-calls to other sprite groups - uint32 time; ///< Time taken for resolution (microseconds) - uint64 tick; ///< Game tick + uint32_t root_sprite; ///< Pseudo-sprite index in GRF file + uint32_t item; ///< Local ID of item being resolved for + uint32_t result; ///< Result of callback + uint32_t subs; ///< Sub-calls to other sprite groups + uint32_t time; ///< Time taken for resolution (microseconds) + uint64_t tick; ///< Game tick CallbackID cb; ///< Callback ID GrfSpecFeature feat; ///< GRF feature being resolved for }; const GRFFile *grffile; ///< Which GRF is being profiled bool active; ///< Is this profiler collecting data - uint64 start_tick; ///< Tick number this profiler was started on + uint64_t start_tick; ///< Tick number this profiler was started on Call cur_call; ///< Data for current call in progress std::vector calls; ///< All calls collected so far }; diff --git a/src/newgrf_railtype.cpp b/src/newgrf_railtype.cpp index 7309df603b..9f074e4b4d 100644 --- a/src/newgrf_railtype.cpp +++ b/src/newgrf_railtype.cpp @@ -17,13 +17,13 @@ #include "safeguards.h" -/* virtual */ uint32 RailTypeScopeResolver::GetRandomBits() const +/* virtual */ uint32_t RailTypeScopeResolver::GetRandomBits() const { - uint tmp = CountBits(static_cast(this->tile + (TileX(this->tile) + TileY(this->tile)) * TILE_SIZE)); + uint tmp = CountBits(static_cast(this->tile + (TileX(this->tile) + TileY(this->tile)) * TILE_SIZE)); return GB(tmp, 0, 2); } -/* virtual */ uint32 RailTypeScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const +/* virtual */ uint32_t RailTypeScopeResolver::GetVariable(byte variable, uint32_t parameter, bool *available) const { if (this->tile == INVALID_TILE) { switch (variable) { @@ -64,7 +64,7 @@ GrfSpecFeature RailTypeResolverObject::GetFeature() const return GSF_RAILTYPES; } -uint32 RailTypeResolverObject::GetDebugID() const +uint32_t RailTypeResolverObject::GetDebugID() const { return this->railtype_scope.rti->label; } @@ -78,7 +78,7 @@ uint32 RailTypeResolverObject::GetDebugID() const * @param param1 Extra parameter (first parameter of the callback, except railtypes do not have callbacks). * @param param2 Extra parameter (second parameter of the callback, except railtypes do not have callbacks). */ -RailTypeResolverObject::RailTypeResolverObject(const RailtypeInfo *rti, TileIndex tile, TileContext context, RailTypeSpriteGroup rtsg, uint32 param1, uint32 param2) +RailTypeResolverObject::RailTypeResolverObject(const RailtypeInfo *rti, TileIndex tile, TileContext context, RailTypeSpriteGroup rtsg, uint32_t param1, uint32_t param2) : ResolverObject(rti != nullptr ? rti->grffile[rtsg] : nullptr, CBID_NO_CALLBACK, param1, param2), railtype_scope(*this, rti, tile, context) { this->root_spritegroup = rti != nullptr ? rti->group[rtsg] : nullptr; @@ -122,8 +122,8 @@ SpriteID GetCustomSignalSprite(const RailtypeInfo *rti, TileIndex tile, SignalTy { if (rti->group[RTSG_SIGNALS] == nullptr) return 0; - uint32 param1 = gui ? 0x10 : 0x00; - uint32 param2 = (type << 16) | (var << 8) | state; + uint32_t param1 = gui ? 0x10 : 0x00; + uint32_t param2 = (type << 16) | (var << 8) | state; RailTypeResolverObject object(rti, tile, TCX_NORMAL, RTSG_SIGNALS, param1, param2); const SpriteGroup *group = object.Resolve(); @@ -138,7 +138,7 @@ SpriteID GetCustomSignalSprite(const RailtypeInfo *rti, TileIndex tile, SignalTy * @param grffile Originating GRF file. * @return RailType or INVALID_RAILTYPE if the railtype is unknown. */ -RailType GetRailTypeTranslation(uint8 railtype, const GRFFile *grffile) +RailType GetRailTypeTranslation(uint8_t railtype, const GRFFile *grffile) { if (grffile == nullptr || grffile->railtype_list.size() == 0) { /* No railtype table present. Return railtype as-is (if valid), so it works for original railtypes. */ @@ -160,7 +160,7 @@ RailType GetRailTypeTranslation(uint8 railtype, const GRFFile *grffile) * @param grffile The GRF to do the lookup for. * @return the GRF internal ID. */ -uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile) +uint8_t GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile) { /* No rail type table present, return rail type as-is */ if (grffile == nullptr || grffile->railtype_list.size() == 0) return railtype; diff --git a/src/newgrf_railtype.h b/src/newgrf_railtype.h index d33504e364..0d599fc976 100644 --- a/src/newgrf_railtype.h +++ b/src/newgrf_railtype.h @@ -31,15 +31,15 @@ struct RailTypeScopeResolver : public ScopeResolver { { } - uint32 GetRandomBits() const override; - uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(byte variable, uint32_t parameter, bool *available) const override; }; /** Resolver object for rail types. */ struct RailTypeResolverObject : public ResolverObject { RailTypeScopeResolver railtype_scope; ///< Resolver for the railtype scope. - RailTypeResolverObject(const RailtypeInfo *rti, TileIndex tile, TileContext context, RailTypeSpriteGroup rtsg, uint32 param1 = 0, uint32 param2 = 0); + RailTypeResolverObject(const RailtypeInfo *rti, TileIndex tile, TileContext context, RailTypeSpriteGroup rtsg, uint32_t param1 = 0, uint32_t param2 = 0); ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { @@ -50,13 +50,13 @@ struct RailTypeResolverObject : public ResolverObject { } GrfSpecFeature GetFeature() const override; - uint32 GetDebugID() const override; + uint32_t GetDebugID() const override; }; SpriteID GetCustomRailSprite(const RailtypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context = TCX_NORMAL, uint *num_results = nullptr); SpriteID GetCustomSignalSprite(const RailtypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, SignalState state, bool gui = false); -RailType GetRailTypeTranslation(uint8 railtype, const GRFFile *grffile); -uint8 GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile); +RailType GetRailTypeTranslation(uint8_t railtype, const GRFFile *grffile); +uint8_t GetReverseRailTypeTranslation(RailType railtype, const GRFFile *grffile); #endif /* NEWGRF_RAILTYPE_H */ diff --git a/src/newgrf_roadstop.cpp b/src/newgrf_roadstop.cpp index 097747a948..5b0eb6f735 100644 --- a/src/newgrf_roadstop.cpp +++ b/src/newgrf_roadstop.cpp @@ -47,25 +47,25 @@ INSTANTIATE_NEWGRF_CLASS_METHODS(RoadStopClass, RoadStopSpec, RoadStopClassID, R static const uint NUM_ROADSTOPSPECS_PER_STATION = 63; ///< Maximum number of parts per station. -uint32 RoadStopScopeResolver::GetRandomBits() const +uint32_t RoadStopScopeResolver::GetRandomBits() const { if (this->st == nullptr) return 0; - uint32 bits = this->st->random_bits; + uint32_t bits = this->st->random_bits; if (this->tile != INVALID_TILE && Station::IsExpected(this->st)) { bits |= Station::From(this->st)->GetRoadStopRandomBits(this->tile) << 16; } return bits; } -uint32 RoadStopScopeResolver::GetTriggers() const +uint32_t RoadStopScopeResolver::GetTriggers() const { return this->st == nullptr ? 0 : this->st->waiting_triggers; } -uint32 RoadStopScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const +uint32_t RoadStopScopeResolver::GetVariable(byte variable, uint32_t parameter, bool *available) const { - auto get_road_type_variable = [&](RoadTramType rtt) -> uint32 { + auto get_road_type_variable = [&](RoadTramType rtt) -> uint32_t { RoadType rt; if (this->tile == INVALID_TILE) { rt = (GetRoadTramType(this->roadtype) == rtt) ? this->roadtype : INVALID_ROADTYPE; @@ -144,10 +144,10 @@ uint32 RoadStopScopeResolver::GetVariable(byte variable, uint32 parameter, bool if (!IsRoadStopTile(nearby_tile)) return 0xFFFFFFFF; - uint32 grfid = this->st->roadstop_speclist[GetCustomRoadStopSpecIndex(this->tile)].grfid; + uint32_t grfid = this->st->roadstop_speclist[GetCustomRoadStopSpecIndex(this->tile)].grfid; bool same_orientation = GetStationGfx(this->tile) == GetStationGfx(nearby_tile); bool same_station = GetStationIndex(nearby_tile) == this->st->index; - uint32 res = GetStationGfx(nearby_tile) << 12 | !same_orientation << 11 | !!same_station << 10; + uint32_t res = GetStationGfx(nearby_tile) << 12 | !same_orientation << 11 | !!same_station << 10; StationType type = GetStationType(nearby_tile); if (type == STATION_TRUCK) res |= (1 << 16); if (type == this->type) SetBit(res, 20); @@ -189,8 +189,8 @@ const SpriteGroup *RoadStopResolverObject::ResolveReal(const RealSpriteGroup *gr return group->loading[0]; } -RoadStopResolverObject::RoadStopResolverObject(const RoadStopSpec *roadstopspec, BaseStation *st, TileIndex tile, RoadType roadtype, StationType type, uint8 view, - CallbackID callback, uint32 param1, uint32 param2) +RoadStopResolverObject::RoadStopResolverObject(const RoadStopSpec *roadstopspec, BaseStation *st, TileIndex tile, RoadType roadtype, StationType type, uint8_t view, + CallbackID callback, uint32_t param1, uint32_t param2) : ResolverObject(roadstopspec->grf_prop.grffile, callback, param1, param2), roadstop_scope(*this, st, roadstopspec, tile, roadtype, type, view) { @@ -242,7 +242,7 @@ TownScopeResolver* RoadStopResolverObject::GetTown() return this->town_scope; } -uint16 GetRoadStopCallback(CallbackID callback, uint32 param1, uint32 param2, const RoadStopSpec *roadstopspec, BaseStation *st, TileIndex tile, RoadType roadtype, StationType type, uint8 view) +uint16_t GetRoadStopCallback(CallbackID callback, uint32_t param1, uint32_t param2, const RoadStopSpec *roadstopspec, BaseStation *st, TileIndex tile, RoadType roadtype, StationType type, uint8_t view) { RoadStopResolverObject object(roadstopspec, st, tile, roadtype, type, view, callback, param1, param2); return object.ResolveCallback(); @@ -305,7 +305,7 @@ void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec, } /** Wrapper for animation control, see GetRoadStopCallback. */ -uint16 GetAnimRoadStopCallback(CallbackID callback, uint32 param1, uint32 param2, const RoadStopSpec *roadstopspec, BaseStation *st, TileIndex tile, int extra_data) +uint16_t GetAnimRoadStopCallback(CallbackID callback, uint32_t param1, uint32_t param2, const RoadStopSpec *roadstopspec, BaseStation *st, TileIndex tile, int extra_data) { return GetRoadStopCallback(callback, param1, param2, roadstopspec, st, tile, INVALID_ROADTYPE, GetStationType(tile), GetStationGfx(tile)); } @@ -341,7 +341,7 @@ void TriggerRoadStopAnimation(BaseStation *st, TileIndex trigger_tile, StationAn * to bother with any further processing. */ if (!HasBit(st->cached_roadstop_anim_triggers, trigger)) return; - uint16 random_bits = Random(); + uint16_t random_bits = Random(); auto process_tile = [&](TileIndex cur_tile) { const RoadStopSpec *ss = GetRoadStopSpec(cur_tile); if (ss != nullptr && HasBit(ss->animation.triggers, trigger)) { @@ -351,7 +351,7 @@ void TriggerRoadStopAnimation(BaseStation *st, TileIndex trigger_tile, StationAn } else { cargo = ss->grf_prop.grffile->cargo_map[cargo_type]; } - RoadStopAnimationBase::ChangeAnimationFrame(CBID_STATION_ANIM_START_STOP, ss, st, cur_tile, (random_bits << 16) | Random(), (uint8)trigger | (cargo << 8)); + RoadStopAnimationBase::ChangeAnimationFrame(CBID_STATION_ANIM_START_STOP, ss, st, cur_tile, (random_bits << 16) | Random(), (uint8_t)trigger | (cargo << 8)); } }; @@ -383,7 +383,7 @@ void TriggerRoadStopRandomisation(Station *st, TileIndex tile, RoadStopRandomTri SetBit(st->waiting_triggers, trigger); - uint32 whole_reseed = 0; + uint32_t whole_reseed = 0; CargoTypes empty_mask = 0; if (trigger == RSRT_CARGO_TAKEN) { @@ -395,7 +395,7 @@ void TriggerRoadStopRandomisation(Station *st, TileIndex tile, RoadStopRandomTri } } - uint32 used_triggers = 0; + uint32_t used_triggers = 0; auto process_tile = [&](TileIndex cur_tile) { const RoadStopSpec *ss = GetRoadStopSpec(cur_tile); if (ss == nullptr) return; @@ -415,13 +415,13 @@ void TriggerRoadStopRandomisation(Station *st, TileIndex tile, RoadStopRandomTri used_triggers |= object.used_triggers; - uint32 reseed = object.GetReseedSum(); + uint32_t reseed = object.GetReseedSum(); if (reseed != 0) { whole_reseed |= reseed; reseed >>= 16; /* Set individual tile random bits */ - uint8 random_bits = st->GetRoadStopRandomBits(cur_tile); + uint8_t random_bits = st->GetRoadStopRandomBits(cur_tile); random_bits &= ~reseed; random_bits |= Random() & reseed; st->SetRoadStopRandomBits(cur_tile, random_bits); diff --git a/src/newgrf_roadstop.h b/src/newgrf_roadstop.h index f0d7975d53..0e453a76e3 100644 --- a/src/newgrf_roadstop.h +++ b/src/newgrf_roadstop.h @@ -78,18 +78,18 @@ struct RoadStopScopeResolver : public ScopeResolver { const struct RoadStopSpec *roadstopspec; ///< Station (type) specification. CargoID cargo_type; ///< Type of cargo of the station. StationType type; ///< Station type. - uint8 view; ///< Station axis. + uint8_t view; ///< Station axis. RoadType roadtype; ///< Road type (used when no tile) - RoadStopScopeResolver(ResolverObject& ro, BaseStation* st, const RoadStopSpec *roadstopspec, TileIndex tile, RoadType roadtype, StationType type, uint8 view = 0) + RoadStopScopeResolver(ResolverObject& ro, BaseStation* st, const RoadStopSpec *roadstopspec, TileIndex tile, RoadType roadtype, StationType type, uint8_t view = 0) : ScopeResolver(ro), tile(tile), st(st), roadstopspec(roadstopspec), type(type), view(view), roadtype(roadtype) { } - uint32 GetRandomBits() const override; - uint32 GetTriggers() const override; + uint32_t GetRandomBits() const override; + uint32_t GetTriggers() const override; - uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; + uint32_t GetVariable(byte variable, uint32_t parameter, bool *available) const override; }; /** Road stop resolver. */ @@ -97,7 +97,7 @@ struct RoadStopResolverObject : public ResolverObject { RoadStopScopeResolver roadstop_scope; ///< The stop scope resolver. TownScopeResolver *town_scope; ///< The town scope resolver (created on the first call). - RoadStopResolverObject(const RoadStopSpec* roadstopspec, BaseStation* st, TileIndex tile, RoadType roadtype, StationType type, uint8 view, CallbackID callback = CBID_NO_CALLBACK, uint32 param1 = 0, uint32 param2 = 0); + RoadStopResolverObject(const RoadStopSpec* roadstopspec, BaseStation* st, TileIndex tile, RoadType roadtype, StationType type, uint8_t view, CallbackID callback = CBID_NO_CALLBACK, uint32_t param1 = 0, uint32_t param2 = 0); ~RoadStopResolverObject(); ScopeResolver* GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override @@ -133,8 +133,8 @@ struct RoadStopSpec { RoadStopAvailabilityType stop_type = ROADSTOPTYPE_ALL; RoadStopDrawMode draw_mode = ROADSTOP_DRAW_MODE_ROAD | ROADSTOP_DRAW_MODE_OVERLAY; - uint8 callback_mask = 0; - uint8 flags = 0; + uint8_t callback_mask = 0; + uint8_t flags = 0; CargoTypes cargo_triggers = 0; ///< Bitmask of cargo types which cause trigger re-randomizing @@ -143,8 +143,8 @@ struct RoadStopSpec { byte bridge_height[6]; ///< Minimum height for a bridge above, 0 for none byte bridge_disallowed_pillars[6]; ///< Disallowed pillar flags for a bridge above - uint8 build_cost_multiplier = 16; ///< Build cost multiplier per tile. - uint8 clear_cost_multiplier = 16; ///< Clear cost multiplier per tile. + uint8_t build_cost_multiplier = 16; ///< Build cost multiplier per tile. + uint8_t clear_cost_multiplier = 16; ///< Clear cost multiplier per tile. /** * Get the cost for building a road stop of this type. @@ -158,17 +158,17 @@ struct RoadStopSpec { */ Money GetClearCost(Price category) const { return GetPrice(category, this->clear_cost_multiplier, this->grf_prop.grffile, -4); } - static const RoadStopSpec *Get(uint16 index); + static const RoadStopSpec *Get(uint16_t index); }; typedef NewGRFClass RoadStopClass; void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec, StationType type, int view); -uint16 GetRoadStopCallback(CallbackID callback, uint32 param1, uint32 param2, const RoadStopSpec *roadstopspec, BaseStation *st, TileIndex tile, RoadType roadtype, StationType type, uint8 view); +uint16_t GetRoadStopCallback(CallbackID callback, uint32_t param1, uint32_t param2, const RoadStopSpec *roadstopspec, BaseStation *st, TileIndex tile, RoadType roadtype, StationType type, uint8_t view); void AnimateRoadStopTile(TileIndex tile); -uint8 GetRoadStopTileAnimationSpeed(TileIndex tile); +uint8_t GetRoadStopTileAnimationSpeed(TileIndex tile); void TriggerRoadStopAnimation(BaseStation *st, TileIndex tile, StationAnimationTrigger trigger, CargoID cargo_type = CT_INVALID); void TriggerRoadStopRandomisation(Station *st, TileIndex tile, RoadStopRandomTrigger trigger, CargoID cargo_type = CT_INVALID); diff --git a/src/newgrf_roadtype.cpp b/src/newgrf_roadtype.cpp index c51963d171..1be5b7585a 100644 --- a/src/newgrf_roadtype.cpp +++ b/src/newgrf_roadtype.cpp @@ -17,13 +17,13 @@ #include "safeguards.h" -/* virtual */ uint32 RoadTypeScopeResolver::GetRandomBits() const +/* virtual */ uint32_t RoadTypeScopeResolver::GetRandomBits() const { - uint tmp = CountBits(static_cast(this->tile + (TileX(this->tile) + TileY(this->tile)) * TILE_SIZE)); + uint tmp = CountBits(static_cast(this->tile + (TileX(this->tile) + TileY(this->tile)) * TILE_SIZE)); return GB(tmp, 0, 2); } -/* virtual */ uint32 RoadTypeScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const +/* virtual */ uint32_t RoadTypeScopeResolver::GetVariable(byte variable, uint32_t parameter, bool *available) const { if (this->tile == INVALID_TILE) { switch (variable) { @@ -69,7 +69,7 @@ GrfSpecFeature RoadTypeResolverObject::GetFeature() const } } -uint32 RoadTypeResolverObject::GetDebugID() const +uint32_t RoadTypeResolverObject::GetDebugID() const { return this->roadtype_scope.rti->label; } @@ -83,7 +83,7 @@ uint32 RoadTypeResolverObject::GetDebugID() const * @param param1 Extra parameter (first parameter of the callback, except roadtypes do not have callbacks). * @param param2 Extra parameter (second parameter of the callback, except roadtypes do not have callbacks). */ -RoadTypeResolverObject::RoadTypeResolverObject(const RoadTypeInfo *rti, TileIndex tile, TileContext context, RoadTypeSpriteGroup rtsg, uint32 param1, uint32 param2) +RoadTypeResolverObject::RoadTypeResolverObject(const RoadTypeInfo *rti, TileIndex tile, TileContext context, RoadTypeSpriteGroup rtsg, uint32_t param1, uint32_t param2) : ResolverObject(rti != nullptr ? rti->grffile[rtsg] : nullptr, CBID_NO_CALLBACK, param1, param2), roadtype_scope(*this, rti, tile, context) { this->root_spritegroup = rti != nullptr ? rti->group[rtsg] : nullptr; @@ -120,7 +120,7 @@ SpriteID GetCustomRoadSprite(const RoadTypeInfo *rti, TileIndex tile, RoadTypeSp * @param grffile Originating GRF file. * @return RoadType or INVALID_ROADTYPE if the roadtype is unknown. */ -RoadType GetRoadTypeTranslation(RoadTramType rtt, uint8 tracktype, const GRFFile *grffile) +RoadType GetRoadTypeTranslation(RoadTramType rtt, uint8_t tracktype, const GRFFile *grffile) { /* Because OpenTTD mixes RoadTypes and TramTypes into the same type, * the mapping of the original road- and tramtypes does not match the default GRF-local mapping. @@ -150,7 +150,7 @@ RoadType GetRoadTypeTranslation(RoadTramType rtt, uint8 tracktype, const GRFFile * @param grffile The GRF to do the lookup for. * @return the GRF internal ID. */ -uint8 GetReverseRoadTypeTranslation(RoadType roadtype, const GRFFile *grffile) +uint8_t GetReverseRoadTypeTranslation(RoadType roadtype, const GRFFile *grffile) { /* No road type table present, return road type as-is */ if (grffile == nullptr) return roadtype; diff --git a/src/newgrf_roadtype.h b/src/newgrf_roadtype.h index 3314db345b..dc7acf636d 100644 --- a/src/newgrf_roadtype.h +++ b/src/newgrf_roadtype.h @@ -32,15 +32,15 @@ struct RoadTypeScopeResolver : public ScopeResolver { { } - /* virtual */ uint32 GetRandomBits() const; - /* virtual */ uint32 GetVariable(byte variable, uint32 parameter, bool *available) const; + /* virtual */ uint32_t GetRandomBits() const; + /* virtual */ uint32_t GetVariable(byte variable, uint32_t parameter, bool *available) const; }; /** Resolver object for road types. */ struct RoadTypeResolverObject : public ResolverObject { RoadTypeScopeResolver roadtype_scope; ///< Resolver for the roadtype scope. - RoadTypeResolverObject(const RoadTypeInfo *rti, TileIndex tile, TileContext context, RoadTypeSpriteGroup rtsg, uint32 param1 = 0, uint32 param2 = 0); + RoadTypeResolverObject(const RoadTypeInfo *rti, TileIndex tile, TileContext context, RoadTypeSpriteGroup rtsg, uint32_t param1 = 0, uint32_t param2 = 0); ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, byte relative = 0) override { @@ -51,12 +51,12 @@ struct RoadTypeResolverObject : public ResolverObject { } GrfSpecFeature GetFeature() const override; - uint32 GetDebugID() const override; + uint32_t GetDebugID() const override; }; SpriteID GetCustomRoadSprite(const RoadTypeInfo *rti, TileIndex tile, RoadTypeSpriteGroup rtsg, TileContext context = TCX_NORMAL, uint *num_results = nullptr); -RoadType GetRoadTypeTranslation(RoadTramType rtt, uint8 tracktype, const GRFFile *grffile); -uint8 GetReverseRoadTypeTranslation(RoadType roadtype, const GRFFile *grffile); +RoadType GetRoadTypeTranslation(RoadTramType rtt, uint8_t tracktype, const GRFFile *grffile); +uint8_t GetReverseRoadTypeTranslation(RoadType roadtype, const GRFFile *grffile); #endif /* NEWGRF_ROADTYPE_H */ diff --git a/src/newgrf_sound.cpp b/src/newgrf_sound.cpp index f47f9f023b..c79ca59ffb 100644 --- a/src/newgrf_sound.cpp +++ b/src/newgrf_sound.cpp @@ -76,11 +76,11 @@ bool LoadNewGRFSound(SoundEntry *sound) /* Format: '\0' */ - uint32 num = sound->grf_container_ver >= 2 ? file.ReadDword() : file.ReadWord(); + uint32_t num = sound->grf_container_ver >= 2 ? file.ReadDword() : file.ReadWord(); if (file.ReadByte() != 0xFF) return false; if (file.ReadByte() != 0xFF) return false; - uint8 name_len = file.ReadByte(); + uint8_t name_len = file.ReadByte(); std::string name(name_len + 1, '\0'); file.ReadBlock(name.data(), name_len + 1); @@ -97,7 +97,7 @@ bool LoadNewGRFSound(SoundEntry *sound) return false; } - uint32 total_size = file.ReadDword(); + uint32_t total_size = file.ReadDword(); uint header_size = 11; if (sound->grf_container_ver >= 2) header_size++; // The first FF in the sprite is only counted for container version >= 2. if (total_size + name_len + header_size > num) { @@ -111,8 +111,8 @@ bool LoadNewGRFSound(SoundEntry *sound) } while (total_size >= 8) { - uint32 tag = file.ReadDword(); - uint32 size = file.ReadDword(); + uint32_t tag = file.ReadDword(); + uint32_t size = file.ReadDword(); total_size -= 8; if (total_size < size) { Debug(grf, 1, "LoadNewGRFSound [{}]: Invalid RIFF", file.GetSimplifiedFilename()); @@ -189,7 +189,7 @@ bool PlayVehicleSound(const Vehicle *v, VehicleSoundEvent event, bool force) if (!_settings_client.sound.vehicle && !force) return true; const GRFFile *file = v->GetGRF(); - uint16 callback; + uint16_t callback; /* If the engine has no GRF ID associated it can't ever play any new sounds */ if (file == nullptr) return false; diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp index 8454b869b8..e8ab9e6cba 100644 --- a/src/newgrf_spritegroup.cpp +++ b/src/newgrf_spritegroup.cpp @@ -18,7 +18,7 @@ SpriteGroupPool _spritegroup_pool("SpriteGroup"); INSTANTIATE_POOL_METHODS(SpriteGroup) -TemporaryStorageArray _temp_store; +TemporaryStorageArray _temp_store; /** @@ -53,9 +53,9 @@ TemporaryStorageArray _temp_store; } } -static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *scope, byte variable, uint32 parameter, bool *available) +static inline uint32_t GetVariable(const ResolverObject &object, ScopeResolver *scope, byte variable, uint32_t parameter, bool *available) { - uint32 value; + uint32_t value; switch (variable) { case 0x0C: return object.callback; case 0x10: return object.callback_param1; @@ -82,7 +82,7 @@ static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *sc * Get a few random bits. Default implementation has no random bits. * @return Random bits. */ -/* virtual */ uint32 ScopeResolver::GetRandomBits() const +/* virtual */ uint32_t ScopeResolver::GetRandomBits() const { return 0; } @@ -91,7 +91,7 @@ static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *sc * Get the triggers. Base class returns \c 0 to prevent trouble. * @return The triggers. */ -/* virtual */ uint32 ScopeResolver::GetTriggers() const +/* virtual */ uint32_t ScopeResolver::GetTriggers() const { return 0; } @@ -103,7 +103,7 @@ static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *sc * @param[out] available Set to false, in case the variable does not exist. * @return Value */ -/* virtual */ uint32 ScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const +/* virtual */ uint32_t ScopeResolver::GetVariable(byte variable, uint32_t parameter, bool *available) const { Debug(grf, 1, "Unhandled scope variable 0x{:X}", variable); *available = false; @@ -115,7 +115,7 @@ static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *sc * @param reg Position to store into. * @param value Value to store. */ -/* virtual */ void ScopeResolver::StorePSA(uint reg, int32 value) {} +/* virtual */ void ScopeResolver::StorePSA(uint reg, int32_t value) {} /** * Get the real sprites of the grf. @@ -144,7 +144,7 @@ static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *sc /* Evaluate an adjustment for a variable of the given size. * U is the unsigned type and S is the signed type to use. */ template -static U EvalAdjustT(const DeterministicSpriteGroupAdjust &adjust, ScopeResolver *scope, U last_value, uint32 value) +static U EvalAdjustT(const DeterministicSpriteGroupAdjust &adjust, ScopeResolver *scope, U last_value, uint32_t value) { value >>= adjust.shift_num; value &= adjust.and_mask; @@ -173,26 +173,26 @@ static U EvalAdjustT(const DeterministicSpriteGroupAdjust &adjust, ScopeResolver case DSGA_OP_STO: _temp_store.StoreValue((U)value, (S)last_value); return last_value; case DSGA_OP_RST: return value; case DSGA_OP_STOP: scope->StorePSA((U)value, (S)last_value); return last_value; - case DSGA_OP_ROR: return ROR((U)last_value, (U)value & 0x1F); // mask 'value' to 5 bits, which should behave the same on all architectures. + case DSGA_OP_ROR: return ROR((U)last_value, (U)value & 0x1F); // mask 'value' to 5 bits, which should behave the same on all architectures. case DSGA_OP_SCMP: return ((S)last_value == (S)value) ? 1 : ((S)last_value < (S)value ? 0 : 2); case DSGA_OP_UCMP: return ((U)last_value == (U)value) ? 1 : ((U)last_value < (U)value ? 0 : 2); - case DSGA_OP_SHL: return (uint32)(U)last_value << ((U)value & 0x1F); // Same behaviour as in ParamSet, mask 'value' to 5 bits, which should behave the same on all architectures. - case DSGA_OP_SHR: return (uint32)(U)last_value >> ((U)value & 0x1F); - case DSGA_OP_SAR: return (int32)(S)last_value >> ((U)value & 0x1F); + case DSGA_OP_SHL: return (uint32_t)(U)last_value << ((U)value & 0x1F); // Same behaviour as in ParamSet, mask 'value' to 5 bits, which should behave the same on all architectures. + case DSGA_OP_SHR: return (uint32_t)(U)last_value >> ((U)value & 0x1F); + case DSGA_OP_SAR: return (int32_t)(S)last_value >> ((U)value & 0x1F); default: return value; } } -static bool RangeHighComparator(const DeterministicSpriteGroupRange& range, uint32 value) +static bool RangeHighComparator(const DeterministicSpriteGroupRange& range, uint32_t value) { return range.high < value; } const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject &object) const { - uint32 last_value = 0; - uint32 value = 0; + uint32_t last_value = 0; + uint32_t value = 0; ScopeResolver *scope = object.GetScope(this->var_scope); @@ -221,9 +221,9 @@ const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject &object) con } switch (this->size) { - case DSG_SIZE_BYTE: value = EvalAdjustT (adjust, scope, last_value, value); break; - case DSG_SIZE_WORD: value = EvalAdjustT(adjust, scope, last_value, value); break; - case DSG_SIZE_DWORD: value = EvalAdjustT(adjust, scope, last_value, value); break; + case DSG_SIZE_BYTE: value = EvalAdjustT (adjust, scope, last_value, value); break; + case DSG_SIZE_WORD: value = EvalAdjustT(adjust, scope, last_value, value); break; + case DSG_SIZE_DWORD: value = EvalAdjustT(adjust, scope, last_value, value); break; default: NOT_REACHED(); } last_value = value; @@ -271,7 +271,7 @@ const SpriteGroup *RandomizedSpriteGroup::Resolve(ResolverObject &object) const } } - uint32 mask = ((uint)this->groups.size() - 1) << this->lowest_randbit; + uint32_t mask = ((uint)this->groups.size() - 1) << this->lowest_randbit; byte index = (scope->GetRandomBits() & mask) >> this->lowest_randbit; return SpriteGroup::Resolve(this->groups[index], object, false); @@ -290,7 +290,7 @@ const SpriteGroup *RealSpriteGroup::Resolve(ResolverObject &object) const * @param[in,out] stage Construction stage (0-3), or nullptr if not applicable. * @return sprite layout to draw. */ -const DrawTileSprites *TileLayoutSpriteGroup::ProcessRegisters(uint8 *stage) const +const DrawTileSprites *TileLayoutSpriteGroup::ProcessRegisters(uint8_t *stage) const { if (!this->dts.NeedsPreprocessing()) { if (stage != nullptr && this->dts.consistent_max_offset > 0) *stage = GetConstructionStageOffset(*stage, this->dts.consistent_max_offset); @@ -298,7 +298,7 @@ const DrawTileSprites *TileLayoutSpriteGroup::ProcessRegisters(uint8 *stage) con } static DrawTileSprites result; - uint8 actual_stage = stage != nullptr ? *stage : 0; + uint8_t actual_stage = stage != nullptr ? *stage : 0; this->dts.PrepareLayout(0, 0, 0, actual_stage, false); this->dts.ProcessRegisters(0, 0, false); result.seq = this->dts.GetLayout(&result.ground); diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h index edd5af1bab..9940cea163 100644 --- a/src/newgrf_spritegroup.h +++ b/src/newgrf_spritegroup.h @@ -26,9 +26,9 @@ * @pre i < 0x110 * @return the value of the register */ -static inline uint32 GetRegister(uint i) +static inline uint32_t GetRegister(uint i) { - extern TemporaryStorageArray _temp_store; + extern TemporaryStorageArray _temp_store; return _temp_store.GetValue(i); } @@ -44,7 +44,7 @@ enum SpriteGroupType { }; struct SpriteGroup; -typedef uint32 SpriteGroupID; +typedef uint32_t SpriteGroupID; struct ResolverObject; /* SPRITE_WIDTH is 24. ECS has roughly 30 sprite groups per real sprite. @@ -63,12 +63,12 @@ protected: public: virtual ~SpriteGroup() = default; - uint32 nfo_line; + uint32_t nfo_line; SpriteGroupType type; virtual SpriteID GetResult() const { return 0; } virtual byte GetNumResults() const { return 0; } - virtual uint16 GetCallbackResult() const { return CALLBACK_FAILED; } + virtual uint16_t GetCallbackResult() const { return CALLBACK_FAILED; } static const SpriteGroup *Resolve(const SpriteGroup *group, ResolverObject &object, bool top_level = true); }; @@ -150,17 +150,17 @@ struct DeterministicSpriteGroupAdjust { byte variable; byte parameter; ///< Used for variables between 0x60 and 0x7F inclusive. byte shift_num; - uint32 and_mask; - uint32 add_val; - uint32 divmod_val; + uint32_t and_mask; + uint32_t add_val; + uint32_t divmod_val; const SpriteGroup *subroutine; }; struct DeterministicSpriteGroupRange { const SpriteGroup *group; - uint32 low; - uint32 high; + uint32_t low; + uint32_t high; }; @@ -213,7 +213,7 @@ struct CallbackResultSpriteGroup : SpriteGroup { * @param value The value that was used to represent this callback result * @param grf_version8 True, if we are dealing with a new NewGRF which uses GRF version >= 8. */ - CallbackResultSpriteGroup(uint16 value, bool grf_version8) : + CallbackResultSpriteGroup(uint16_t value, bool grf_version8) : SpriteGroup(SGT_CALLBACK), result(value) { @@ -226,8 +226,8 @@ struct CallbackResultSpriteGroup : SpriteGroup { } } - uint16 result; - uint16 GetCallbackResult() const { return this->result; } + uint16_t result; + uint16_t GetCallbackResult() const { return this->result; } }; @@ -262,20 +262,20 @@ struct TileLayoutSpriteGroup : SpriteGroup { NewGRFSpriteLayout dts; - const DrawTileSprites *ProcessRegisters(uint8 *stage) const; + const DrawTileSprites *ProcessRegisters(uint8_t *stage) const; }; struct IndustryProductionSpriteGroup : SpriteGroup { IndustryProductionSpriteGroup() : SpriteGroup(SGT_INDUSTRY_PRODUCTION) {} - uint8 version; ///< Production callback version used, or 0xFF if marked invalid - uint8 num_input; ///< How many subtract_input values are valid - int16 subtract_input[INDUSTRY_NUM_INPUTS]; ///< Take this much of the input cargo (can be negative, is indirect in cb version 1+) + uint8_t version; ///< Production callback version used, or 0xFF if marked invalid + uint8_t num_input; ///< How many subtract_input values are valid + int16_t subtract_input[INDUSTRY_NUM_INPUTS]; ///< Take this much of the input cargo (can be negative, is indirect in cb version 1+) CargoID cargo_input[INDUSTRY_NUM_INPUTS]; ///< Which input cargoes to take from (only cb version 2) - uint8 num_output; ///< How many add_output values are valid - uint16 add_output[INDUSTRY_NUM_OUTPUTS]; ///< Add this much output cargo when successful (unsigned, is indirect in cb version 1+) + uint8_t num_output; ///< How many add_output values are valid + uint16_t add_output[INDUSTRY_NUM_OUTPUTS]; ///< Add this much output cargo when successful (unsigned, is indirect in cb version 1+) CargoID cargo_output[INDUSTRY_NUM_OUTPUTS]; ///< Which output cargoes to add to (only cb version 2) - uint8 again; + uint8_t again; }; @@ -291,11 +291,11 @@ struct ScopeResolver { ScopeResolver(ResolverObject &ro) : ro(ro) {} virtual ~ScopeResolver() = default; - virtual uint32 GetRandomBits() const; - virtual uint32 GetTriggers() const; + virtual uint32_t GetRandomBits() const; + virtual uint32_t GetTriggers() const; - virtual uint32 GetVariable(byte variable, uint32 parameter, bool *available) const; - virtual void StorePSA(uint reg, int32 value); + virtual uint32_t GetVariable(byte variable, uint32_t parameter, bool *available) const; + virtual void StorePSA(uint reg, int32_t value); }; /** @@ -312,7 +312,7 @@ struct ResolverObject { * @param callback_param1 First parameter (var 10) of the callback (only used when \a callback is also set). * @param callback_param2 Second parameter (var 18) of the callback (only used when \a callback is also set). */ - ResolverObject(const GRFFile *grffile, CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0) + ResolverObject(const GRFFile *grffile, CallbackID callback = CBID_NO_CALLBACK, uint32_t callback_param1 = 0, uint32_t callback_param2 = 0) : default_scope(*this), callback(callback), callback_param1(callback_param1), callback_param2(callback_param2), grffile(grffile), root_spritegroup(nullptr) { this->ResetState(); @@ -323,14 +323,14 @@ struct ResolverObject { ScopeResolver default_scope; ///< Default implementation of the grf scope. CallbackID callback; ///< Callback being resolved. - uint32 callback_param1; ///< First parameter (var 10) of the callback. - uint32 callback_param2; ///< Second parameter (var 18) of the callback. + uint32_t callback_param1; ///< First parameter (var 10) of the callback. + uint32_t callback_param2; ///< Second parameter (var 18) of the callback. - uint32 last_value; ///< Result of most recent DeterministicSpriteGroup (including procedure calls) + uint32_t last_value; ///< Result of most recent DeterministicSpriteGroup (including procedure calls) - uint32 waiting_triggers; ///< Waiting triggers to be used by any rerandomisation. (scope independent) - uint32 used_triggers; ///< Subset of cur_triggers, which actually triggered some rerandomisation. (scope independent) - uint32 reseed[VSG_END]; ///< Collects bits to rerandomise while triggering triggers. + uint32_t waiting_triggers; ///< Waiting triggers to be used by any rerandomisation. (scope independent) + uint32_t used_triggers; ///< Subset of cur_triggers, which actually triggered some rerandomisation. (scope independent) + uint32_t reseed[VSG_END]; ///< Collects bits to rerandomise while triggering triggers. const GRFFile *grffile; ///< GRFFile the resolved SpriteGroup belongs to const SpriteGroup *root_spritegroup; ///< Root SpriteGroup to use for resolving @@ -348,7 +348,7 @@ struct ResolverObject { * Resolve callback. * @return Callback result. */ - uint16 ResolveCallback() + uint16_t ResolveCallback() { const SpriteGroup *result = Resolve(); return result != nullptr ? result->GetCallbackResult() : CALLBACK_FAILED; @@ -361,7 +361,7 @@ struct ResolverObject { /** * Returns the waiting triggers that did not trigger any rerandomisation. */ - uint32 GetRemainingTriggers() const + uint32_t GetRemainingTriggers() const { return this->waiting_triggers & ~this->used_triggers; } @@ -371,9 +371,9 @@ struct ResolverObject { * independent of the scope they were accessed with. * @return OR-sum of the bits. */ - uint32 GetReseedSum() const + uint32_t GetReseedSum() const { - uint32 sum = 0; + uint32_t sum = 0; for (VarSpriteGroupScope vsg = VSG_BEGIN; vsg < VSG_END; vsg++) { sum |= this->reseed[vsg]; } @@ -402,7 +402,7 @@ struct ResolverObject { * This function is mainly intended for the callback profiling feature, * and should return an identifier recognisable by the NewGRF developer. */ - virtual uint32 GetDebugID() const { return 0; } + virtual uint32_t GetDebugID() const { return 0; } }; #endif /* NEWGRF_SPRITEGROUP_H */ diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index cc618e8f2f..9bf3bca665 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -100,9 +100,9 @@ struct ETileArea : TileArea { * if centered, C/P start from the centre and c/p are not available. * @return Platform information in bit-stuffed format. */ -uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred) +uint32_t GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred) { - uint32 retval = 0; + uint32_t retval = 0; if (axis == AXIS_X) { Swap(platforms, length); @@ -161,7 +161,7 @@ static TileIndex FindRailStationEnd(TileIndex tile, TileIndexDiff delta, bool ch } -static uint32 GetPlatformInfoHelper(TileIndex tile, bool check_type, bool check_axis, bool centred) +static uint32_t GetPlatformInfoHelper(TileIndex tile, bool check_type, bool check_axis, bool centred) { int tx = TileX(tile); int ty = TileY(tile); @@ -177,7 +177,7 @@ static uint32 GetPlatformInfoHelper(TileIndex tile, bool check_type, bool check_ } -static uint32 GetRailContinuationInfo(TileIndex tile) +static uint32_t GetRailContinuationInfo(TileIndex tile) { /* Tile offsets and exit dirs for X axis */ static const Direction x_dir[8] = { DIR_SW, DIR_NE, DIR_SE, DIR_NW, DIR_S, DIR_E, DIR_W, DIR_N }; @@ -193,7 +193,7 @@ static uint32 GetRailContinuationInfo(TileIndex tile) const Direction *dir = axis == AXIS_X ? x_dir : y_dir; const DiagDirection *diagdir = axis == AXIS_X ? x_exits : y_exits; - uint32 res = 0; + uint32_t res = 0; uint i; for (i = 0; i < lengthof(x_dir); i++, dir++, diagdir++) { @@ -219,13 +219,13 @@ static uint32 GetRailContinuationInfo(TileIndex tile) /* Station Resolver Functions */ -/* virtual */ uint32 StationScopeResolver::GetRandomBits() const +/* virtual */ uint32_t StationScopeResolver::GetRandomBits() const { return (this->st == nullptr ? 0 : this->st->random_bits) | (this->tile == INVALID_TILE ? 0 : GetStationTileRandomBits(this->tile) << 16); } -/* virtual */ uint32 StationScopeResolver::GetTriggers() const +/* virtual */ uint32_t StationScopeResolver::GetTriggers() const { return this->st == nullptr ? 0 : this->st->waiting_triggers; } @@ -237,13 +237,13 @@ static uint32 GetRailContinuationInfo(TileIndex tile) * several tiles that may be called multiple times per Resolve(). */ static struct { - uint32 v40; - uint32 v41; - uint32 v45; - uint32 v46; - uint32 v47; - uint32 v49; - uint8 valid; ///< Bits indicating what variable is valid (for each bit, \c 0 is invalid, \c 1 is valid). + uint32_t v40; + uint32_t v41; + uint32_t v45; + uint32_t v46; + uint32_t v47; + uint32_t v49; + uint8_t valid; ///< Bits indicating what variable is valid (for each bit, \c 0 is invalid, \c 1 is valid). } _svc; /** @@ -266,7 +266,7 @@ TownScopeResolver *StationResolverObject::GetTown() return this->town_scope; } -/* virtual */ uint32 StationScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const +/* virtual */ uint32_t StationScopeResolver::GetVariable(byte variable, uint32_t parameter, bool *available) const { if (this->st == nullptr) { /* Station does not exist, so we're in a purchase list or the land slope check callback. */ @@ -354,10 +354,10 @@ TownScopeResolver *StationResolverObject::GetTown() if (!HasStationTileRail(nearby_tile)) return 0xFFFFFFFF; - uint32 grfid = this->st->speclist[GetCustomStationSpecIndex(this->tile)].grfid; + uint32_t grfid = this->st->speclist[GetCustomStationSpecIndex(this->tile)].grfid; bool perpendicular = GetRailStationAxis(this->tile) != GetRailStationAxis(nearby_tile); bool same_station = this->st->TileBelongsToRailStation(nearby_tile); - uint32 res = GB(GetStationGfx(nearby_tile), 1, 2) << 12 | !!perpendicular << 11 | !!same_station << 10; + uint32_t res = GB(GetStationGfx(nearby_tile), 1, 2) << 12 | !!perpendicular << 11 | !!same_station << 10; if (IsCustomStationSpecIndex(nearby_tile)) { const StationSpecList ssl = BaseStation::GetByTile(nearby_tile)->speclist[GetCustomStationSpecIndex(nearby_tile)]; @@ -387,12 +387,12 @@ TownScopeResolver *StationResolverObject::GetTown() return this->st->GetNewGRFVariable(this->ro, variable, parameter, available); } -uint32 Station::GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const +uint32_t Station::GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const { switch (variable) { case 0x48: { // Accepted cargo types CargoID cargo_type; - uint32 value = 0; + uint32_t value = 0; for (cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) { if (HasBit(this->goods[cargo_type].status, GoodsEntry::GES_ACCEPTANCE)) SetBit(value, cargo_type); @@ -458,7 +458,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject &object, byte variable, b return UINT_MAX; } -uint32 Waypoint::GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const +uint32_t Waypoint::GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const { switch (variable) { case 0x48: return 0; // Accepted cargo types @@ -540,7 +540,7 @@ GrfSpecFeature StationResolverObject::GetFeature() const return GSF_STATIONS; } -uint32 StationResolverObject::GetDebugID() const +uint32_t StationResolverObject::GetDebugID() const { return this->station_scope.statspec->grf_prop.local_id; } @@ -555,7 +555,7 @@ uint32 StationResolverObject::GetDebugID() const * @param callback_param2 Second parameter (var 18) of the callback. */ StationResolverObject::StationResolverObject(const StationSpec *statspec, BaseStation *base_station, TileIndex tile, - CallbackID callback, uint32 callback_param1, uint32 callback_param2) + CallbackID callback, uint32_t callback_param1, uint32_t callback_param2) : ResolverObject(statspec->grf_prop.grffile, callback, callback_param1, callback_param2), station_scope(*this, statspec, base_station, tile), town_scope(nullptr) { @@ -601,7 +601,7 @@ StationResolverObject::~StationResolverObject() * @param var10 Value to put in variable 10; normally 0; 1 when resolving the groundsprite and SSF_SEPARATE_GROUND is set. * @return First sprite of the Action 1 spriteset to use, minus an offset of 0x42D to accommodate for weird NewGRF specs. */ -SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32 var10) +SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32_t var10) { StationResolverObject object(statspec, st, tile, CBID_NO_CALLBACK, var10); const SpriteGroup *group = object.Resolve(); @@ -631,7 +631,7 @@ SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseS } -uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile) +uint16_t GetStationCallback(CallbackID callback, uint32_t param1, uint32_t param2, const StationSpec *statspec, BaseStation *st, TileIndex tile) { StationResolverObject object(statspec, st, tile, callback, param1, param2); return object.ResolveCallback(); @@ -657,7 +657,7 @@ CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_til (numtracks << 24) | (plat_len << 16) | (axis == AXIS_Y ? TileX(diff) << 8 | TileY(diff) : TileY(diff) << 8 | TileX(diff))); object.station_scope.axis = axis; - uint16 cb_res = object.ResolveCallback(); + uint16_t cb_res = object.ResolveCallback(); /* Failed callback means success. */ if (cb_res == CALLBACK_FAILED) return CommandCost(); @@ -776,13 +776,13 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID if (statspec == nullptr) return false; if (HasBit(statspec->callback_mask, CBM_STATION_SPRITE_LAYOUT)) { - uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0, 0, statspec, nullptr, INVALID_TILE); + uint16_t callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0, 0, statspec, nullptr, INVALID_TILE); if (callback != CALLBACK_FAILED) tile = callback & ~1; } - uint32 total_offset = rti->GetRailtypeSpriteOffset(); - uint32 relocation = 0; - uint32 ground_relocation = 0; + uint32_t total_offset = rti->GetRailtypeSpriteOffset(); + uint32_t relocation = 0; + uint32_t ground_relocation = 0; const NewGRFSpriteLayout *layout = nullptr; DrawTileSprites tmp_rail_layout; @@ -799,9 +799,9 @@ bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID if (layout != nullptr) { /* Sprite layout which needs preprocessing */ bool separate_ground = HasBit(statspec->flags, SSF_SEPARATE_GROUND); - uint32 var10_values = layout->PrepareLayout(total_offset, rti->fallback_railtype, 0, 0, separate_ground); - for (uint8 var10 : SetBitIterator(var10_values)) { - uint32 var10_relocation = GetCustomStationRelocation(statspec, nullptr, INVALID_TILE, var10); + uint32_t var10_values = layout->PrepareLayout(total_offset, rti->fallback_railtype, 0, 0, separate_ground); + for (uint8_t var10 : SetBitIterator(var10_values)) { + uint32_t var10_relocation = GetCustomStationRelocation(statspec, nullptr, INVALID_TILE, var10); layout->ProcessRegisters(var10, var10_relocation, separate_ground); } @@ -886,7 +886,7 @@ bool CanStationTileHaveWires(TileIndex tile) } /** Wrapper for animation control, see GetStationCallback. */ -uint16 GetAnimStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, int extra_data) +uint16_t GetAnimStationCallback(CallbackID callback, uint32_t param1, uint32_t param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, int extra_data) { return GetStationCallback(callback, param1, param2, statspec, st, tile); } @@ -922,7 +922,7 @@ void TriggerStationAnimation(BaseStation *st, TileIndex trigger_tile, StationAni * to bother with any further processing. */ if (!HasBit(st->cached_anim_triggers, trigger)) return; - uint16 random_bits = Random(); + uint16_t random_bits = Random(); ETileArea area = ETileArea(st, trigger_tile, tas[trigger]); /* Check all tiles over the station to check if the specindex is still in use */ @@ -936,7 +936,7 @@ void TriggerStationAnimation(BaseStation *st, TileIndex trigger_tile, StationAni } else { cargo = ss->grf_prop.grffile->cargo_map[cargo_type]; } - StationAnimationBase::ChangeAnimationFrame(CBID_STATION_ANIM_START_STOP, ss, st, tile, (random_bits << 16) | GB(Random(), 0, 16), (uint8)trigger | (cargo << 8)); + StationAnimationBase::ChangeAnimationFrame(CBID_STATION_ANIM_START_STOP, ss, st, tile, (random_bits << 16) | GB(Random(), 0, 16), (uint8_t)trigger | (cargo << 8)); } } } @@ -964,7 +964,7 @@ void TriggerStationRandomisation(Station *st, TileIndex trigger_tile, StationRan if (st->cached_cargo_triggers == 0) return; if (IsValidCargoID(cargo_type) && !HasBit(st->cached_cargo_triggers, cargo_type)) return; - uint32 whole_reseed = 0; + uint32_t whole_reseed = 0; ETileArea area = ETileArea(st, trigger_tile, tas[trigger]); CargoTypes empty_mask = 0; @@ -979,7 +979,7 @@ void TriggerStationRandomisation(Station *st, TileIndex trigger_tile, StationRan /* Store triggers now for var 5F */ SetBit(st->waiting_triggers, trigger); - uint32 used_triggers = 0; + uint32_t used_triggers = 0; /* Check all tiles over the station to check if the specindex is still in use */ for (TileIndex tile : area) { @@ -1002,13 +1002,13 @@ void TriggerStationRandomisation(Station *st, TileIndex trigger_tile, StationRan used_triggers |= object.used_triggers; - uint32 reseed = object.GetReseedSum(); + uint32_t reseed = object.GetReseedSum(); if (reseed != 0) { whole_reseed |= reseed; reseed >>= 16; /* Set individual tile random bits */ - uint8 random_bits = GetStationTileRandomBits(tile); + uint8_t random_bits = GetStationTileRandomBits(tile); random_bits &= ~reseed; random_bits |= Random() & reseed; SetStationTileRandomBits(tile, random_bits); diff --git a/src/newgrf_station.h b/src/newgrf_station.h index c1f7235cdd..b8be9935b8 100644 --- a/src/newgrf_station.h +++ b/src/newgrf_station.h @@ -40,10 +40,10 @@ struct StationScopeResolver : public ScopeResolver { { } - uint32 GetRandomBits() const override; - uint32 GetTriggers() const override; + uint32_t GetRandomBits() const override; + uint32_t GetTriggers() const override; - uint32 GetVariable(byte variable, uint32 parameter, bool *available) const override; + uint32_t GetVariable(byte variable, uint32_t parameter, bool *available) const override; }; /** Station resolver. */ @@ -52,7 +52,7 @@ struct StationResolverObject : public ResolverObject { TownScopeResolver *town_scope; ///< The town scope resolver (created on the first call). StationResolverObject(const StationSpec *statspec, BaseStation *st, TileIndex tile, - CallbackID callback = CBID_NO_CALLBACK, uint32 callback_param1 = 0, uint32 callback_param2 = 0); + CallbackID callback = CBID_NO_CALLBACK, uint32_t callback_param1 = 0, uint32_t callback_param2 = 0); ~StationResolverObject(); TownScopeResolver *GetTown(); @@ -77,7 +77,7 @@ struct StationResolverObject : public ResolverObject { const SpriteGroup *ResolveReal(const RealSpriteGroup *group) const override; GrfSpecFeature GetFeature() const override; - uint32 GetDebugID() const override; + uint32_t GetDebugID() const override; }; enum StationClassID : byte { @@ -150,7 +150,7 @@ struct StationSpec { * Cargo threshold for choosing between little and lots of cargo * @note little/lots are equivalent to the moving/loading states for vehicles */ - uint16 cargo_threshold; + uint16_t cargo_threshold; CargoTypes cargo_triggers; ///< Bitmask of cargo types which cause trigger re-randomizing @@ -181,11 +181,11 @@ typedef NewGRFClass StationClass; const StationSpec *GetStationSpec(TileIndex t); /* Evaluate a tile's position within a station, and return the result a bitstuffed format. */ -uint32 GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred); +uint32_t GetPlatformInfo(Axis axis, byte tile, int platforms, int length, int x, int y, bool centred); -SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32 var10 = 0); +SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint32_t var10 = 0); SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, uint layout, uint edge_info); -uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile); +uint16_t GetStationCallback(CallbackID callback, uint32_t param1, uint32_t param2, const StationSpec *statspec, BaseStation *st, TileIndex tile); CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_tile, const StationSpec *statspec, Axis axis, byte plat_len, byte numtracks); /* Allocate a StationSpec to a Station. This is called once per build operation. */ diff --git a/src/newgrf_storage.h b/src/newgrf_storage.h index 0c2f0e33a0..1461581fd2 100644 --- a/src/newgrf_storage.h +++ b/src/newgrf_storage.h @@ -31,7 +31,7 @@ enum PersistentStorageMode { * so we have a generalised access to the virtual methods. */ struct BasePersistentStorageArray { - uint32 grfid; ///< GRFID associated to this persistent storage. A value of zero means "default". + uint32_t grfid; ///< GRFID associated to this persistent storage. A value of zero means "default". byte feature; ///< NOSAVE: Used to identify in the owner of the array in debug output. TileIndex tile; ///< NOSAVE: Used to identify in the owner of the array in debug output. @@ -93,7 +93,7 @@ struct PersistentStorageArray : BasePersistentStorageArray { * @param pos the position to write at * @param value the value to write */ - void StoreValue(uint pos, int32 value) + void StoreValue(uint pos, int32_t value) { /* Out of the scope of the array */ if (pos >= SIZE) return; @@ -150,8 +150,8 @@ struct PersistentStorageArray : BasePersistentStorageArray { template struct TemporaryStorageArray { TYPE storage[SIZE]; ///< Memory to for the storage array - uint16 init[SIZE]; ///< Storage has been assigned, if this equals 'init_key'. - uint16 init_key; ///< Magic key to 'init'. + uint16_t init[SIZE]; ///< Storage has been assigned, if this equals 'init_key'. + uint16_t init_key; ///< Magic key to 'init'. /** Simply construct the array */ TemporaryStorageArray() @@ -166,7 +166,7 @@ struct TemporaryStorageArray { * @param pos the position to write at * @param value the value to write */ - void StoreValue(uint pos, int32 value) + void StoreValue(uint pos, int32_t value) { /* Out of the scope of the array */ if (pos >= SIZE) return; @@ -207,9 +207,9 @@ struct TemporaryStorageArray { void AddChangedPersistentStorage(BasePersistentStorageArray *storage); -typedef PersistentStorageArray OldPersistentStorage; +typedef PersistentStorageArray OldPersistentStorage; -typedef uint32 PersistentStorageID; +typedef uint32_t PersistentStorageID; struct PersistentStorage; typedef Pool PersistentStoragePool; @@ -219,9 +219,9 @@ extern PersistentStoragePool _persistent_storage_pool; /** * Class for pooled persistent storage of data. */ -struct PersistentStorage : PersistentStorageArray, PersistentStoragePool::PoolItem<&_persistent_storage_pool> { +struct PersistentStorage : PersistentStorageArray, PersistentStoragePool::PoolItem<&_persistent_storage_pool> { /** We don't want GCC to zero our struct! It already is zeroed and has an index! */ - PersistentStorage(const uint32 new_grfid, byte feature, TileIndex tile) + PersistentStorage(const uint32_t new_grfid, byte feature, TileIndex tile) { this->grfid = new_grfid; this->feature = feature; diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp index 26020e60bb..e33a679a71 100644 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -64,8 +64,8 @@ enum GRFExtendedLanguages { * since it is NOT SUPPOSED to happen. */ struct GRFTextEntry { - uint32 grfid; - uint16 stringid; + uint32_t grfid; + uint16_t stringid; StringID def_string; GRFTextList textholder; }; @@ -158,13 +158,13 @@ struct UnmappedChoiceList { /* "" */ int count = 0; - for (uint8 i = 0; i < _current_language->num_cases; i++) { + for (uint8_t i = 0; i < _current_language->num_cases; i++) { /* Count the ones we have a mapped string for. */ if (this->strings.find(lm->GetReverseMapping(i, false)) != this->strings.end()) count++; } *d++ = count; - for (uint8 i = 0; i < _current_language->num_cases; i++) { + for (uint8_t i = 0; i < _current_language->num_cases; i++) { /* Resolve the string we're looking for. */ int idx = lm->GetReverseMapping(i, false); if (this->strings.find(idx) == this->strings.end()) continue; @@ -234,7 +234,7 @@ struct UnmappedChoiceList { * @param byte80 The control code to use as replacement for the 0x80-value. * @return The translated string. */ -std::string TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_newlines, const std::string &str, StringControlCode byte80) +std::string TranslateTTDPatchCodes(uint32_t grfid, uint8_t language_id, bool allow_newlines, const std::string &str, StringControlCode byte80) { /* Empty input string? Nothing to do here. */ if (str.empty()) return str; @@ -243,7 +243,7 @@ std::string TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_n /* Is this an unicode string? */ bool unicode = false; - WChar marker; + char32_t marker; size_t len = Utf8Decode(&marker, &*src); if (marker == NFO_UTF8_IDENTIFIER) { @@ -257,7 +257,7 @@ std::string TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_n std::ostringstream dest; std::ostreambuf_iterator d(dest); while (src != str.cend()) { - WChar c; + char32_t c; if (unicode && Utf8EncodedCharLen(*src) != 0) { c = Utf8Consume(src); @@ -306,8 +306,8 @@ std::string TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_n { if (src[0] == '\0' || src[1] == '\0') goto string_end; StringID string; - string = ((uint8)* src++); - string |= ((uint8)* src++) << 8; + string = ((uint8_t)* src++); + string |= ((uint8_t)* src++) << 8; Utf8Encode(d, SCC_NEWGRF_STRINL); Utf8Encode(d, MapGRFStringID(grfid, string)); break; @@ -351,8 +351,8 @@ std::string TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_n case 0x03: { if (src[0] == '\0' || src[1] == '\0') goto string_end; - uint16 tmp = ((uint8)* src++); - tmp |= ((uint8)* src++) << 8; + uint16_t tmp = ((uint8_t)* src++); + tmp |= ((uint8_t)* src++) << 8; Utf8Encode(d, SCC_NEWGRF_PUSH_WORD); Utf8Encode(d, tmp); break; @@ -506,7 +506,7 @@ static void AddGRFTextToList(GRFTextList &list, byte langid, const std::string & * @param text_to_add The text to add to the list. * @note All text-codes will be translated. */ -void AddGRFTextToList(GRFTextList &list, byte langid, uint32 grfid, bool allow_newlines, const char *text_to_add) +void AddGRFTextToList(GRFTextList &list, byte langid, uint32_t grfid, bool allow_newlines, const char *text_to_add) { AddGRFTextToList(list, langid, TranslateTTDPatchCodes(grfid, langid, allow_newlines, text_to_add)); } @@ -520,7 +520,7 @@ void AddGRFTextToList(GRFTextList &list, byte langid, uint32 grfid, bool allow_n * @param text_to_add The text to add to the list. * @note All text-codes will be translated. */ -void AddGRFTextToList(GRFTextWrapper &list, byte langid, uint32 grfid, bool allow_newlines, const char *text_to_add) +void AddGRFTextToList(GRFTextWrapper &list, byte langid, uint32_t grfid, bool allow_newlines, const char *text_to_add) { if (!list) list.reset(new GRFTextList()); AddGRFTextToList(*list, langid, grfid, allow_newlines, text_to_add); @@ -541,7 +541,7 @@ void AddGRFTextToList(GRFTextWrapper &list, const std::string &text_to_add) /** * Add the new read string into our structure. */ -StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool new_scheme, bool allow_newlines, const char *text_to_add, StringID def_string) +StringID AddGRFString(uint32_t grfid, uint16_t stringid, byte langid_to_add, bool new_scheme, bool allow_newlines, const char *text_to_add, StringID def_string) { /* When working with the old language scheme (grf_version is less than 7) and * English or American is among the set bits, simply add it as English in @@ -591,7 +591,7 @@ StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool ne /** * Returns the index for this stringid associated with its grfID */ -StringID GetGRFStringID(uint32 grfid, StringID stringid) +StringID GetGRFStringID(uint32_t grfid, StringID stringid) { for (uint id = 0; id < _num_grf_texts; id++) { if (_grf_text[id].grfid == grfid && _grf_text[id].stringid == stringid) { @@ -643,7 +643,7 @@ const char *GetGRFStringFromGRFText(const GRFTextWrapper &text) /** * Get a C-string from a stringid set by a newgrf. */ -const char *GetGRFStringPtr(uint16 stringid) +const char *GetGRFStringPtr(uint16_t stringid) { assert(_grf_text[stringid].grfid != 0); @@ -706,29 +706,29 @@ struct TextRefStack { TextRefStack() : position(0), grffile(nullptr), used(false) {} - uint8 PopUnsignedByte() { assert(this->position < this->stack.size()); return this->stack[this->position++]; } - int8 PopSignedByte() { return (int8)this->PopUnsignedByte(); } + uint8_t PopUnsignedByte() { assert(this->position < this->stack.size()); return this->stack[this->position++]; } + int8_t PopSignedByte() { return (int8_t)this->PopUnsignedByte(); } - uint16 PopUnsignedWord() + uint16_t PopUnsignedWord() { - uint16 val = this->PopUnsignedByte(); + uint16_t val = this->PopUnsignedByte(); return val | (this->PopUnsignedByte() << 8); } - int16 PopSignedWord() { return (int32)this->PopUnsignedWord(); } + int16_t PopSignedWord() { return (int32_t)this->PopUnsignedWord(); } - uint32 PopUnsignedDWord() + uint32_t PopUnsignedDWord() { - uint32 val = this->PopUnsignedWord(); + uint32_t val = this->PopUnsignedWord(); return val | (this->PopUnsignedWord() << 16); } - int32 PopSignedDWord() { return (int32)this->PopUnsignedDWord(); } + int32_t PopSignedDWord() { return (int32_t)this->PopUnsignedDWord(); } - uint64 PopUnsignedQWord() + uint64_t PopUnsignedQWord() { - uint64 val = this->PopUnsignedDWord(); - return val | (((uint64)this->PopUnsignedDWord()) << 32); + uint64_t val = this->PopUnsignedDWord(); + return val | (((uint64_t)this->PopUnsignedDWord()) << 32); } - int64 PopSignedQWord() { return (int64)this->PopUnsignedQWord(); } + int64_t PopSignedQWord() { return (int64_t)this->PopUnsignedQWord(); } /** Rotate the top four words down: W1, W2, W3, W4 -> W4, W1, W2, W3 */ void RotateTop4Words() @@ -739,7 +739,7 @@ struct TextRefStack { for (int i = 0; i < 2; i++) this->stack[this->position + i] = tmp[i]; } - void PushWord(uint16 word) + void PushWord(uint16_t word) { if (this->position >= 2) { this->position -= 2; @@ -811,15 +811,15 @@ void RestoreTextRefStackBackup(struct TextRefStack *backup) * @param numEntries number of entries to copy from the registers * @param values values to copy onto the stack; if nullptr the temporary NewGRF registers will be used instead */ -void StartTextRefStackUsage(const GRFFile *grffile, byte numEntries, const uint32 *values) +void StartTextRefStackUsage(const GRFFile *grffile, byte numEntries, const uint32_t *values) { - extern TemporaryStorageArray _temp_store; + extern TemporaryStorageArray _temp_store; _newgrf_textrefstack.ResetStack(grffile); auto stack_it = _newgrf_textrefstack.stack.begin(); for (uint i = 0; i < numEntries; i++) { - uint32 value = values != nullptr ? values[i] : _temp_store.GetValue(0x100 + i); + uint32_t value = values != nullptr ? values[i] : _temp_store.GetValue(0x100 + i); for (uint j = 0; j < 32; j += 8) { *stack_it = GB(value, j, 8); stack_it++; diff --git a/src/newgrf_text.h b/src/newgrf_text.h index 0963a6dde4..21273e3d5e 100644 --- a/src/newgrf_text.h +++ b/src/newgrf_text.h @@ -16,7 +16,7 @@ #include /** This character, the thorn ('þ'), indicates a unicode string to NFO. */ -static const WChar NFO_UTF8_IDENTIFIER = 0x00DE; +static const char32_t NFO_UTF8_IDENTIFIER = 0x00DE; /** A GRF text with associated language ID. */ struct GRFText { @@ -29,21 +29,21 @@ typedef std::vector GRFTextList; /** Reference counted wrapper around a GRFText pointer. */ typedef std::shared_ptr GRFTextWrapper; -StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid, bool new_scheme, bool allow_newlines, const char *text_to_add, StringID def_string); -StringID GetGRFStringID(uint32 grfid, StringID stringid); +StringID AddGRFString(uint32_t grfid, uint16_t stringid, byte langid, bool new_scheme, bool allow_newlines, const char *text_to_add, StringID def_string); +StringID GetGRFStringID(uint32_t grfid, StringID stringid); const char *GetGRFStringFromGRFText(const GRFTextList &text_list); const char *GetGRFStringFromGRFText(const GRFTextWrapper &text); -const char *GetGRFStringPtr(uint16 stringid); +const char *GetGRFStringPtr(uint16_t stringid); void CleanUpStrings(); void SetCurrentGrfLangID(byte language_id); -std::string TranslateTTDPatchCodes(uint32 grfid, uint8 language_id, bool allow_newlines, const std::string &str, StringControlCode byte80 = SCC_NEWGRF_PRINT_WORD_STRING_ID); -void AddGRFTextToList(GRFTextList &list, byte langid, uint32 grfid, bool allow_newlines, const char *text_to_add); -void AddGRFTextToList(GRFTextWrapper &list, byte langid, uint32 grfid, bool allow_newlines, const char *text_to_add); +std::string TranslateTTDPatchCodes(uint32_t grfid, uint8_t language_id, bool allow_newlines, const std::string &str, StringControlCode byte80 = SCC_NEWGRF_PRINT_WORD_STRING_ID); +void AddGRFTextToList(GRFTextList &list, byte langid, uint32_t grfid, bool allow_newlines, const char *text_to_add); +void AddGRFTextToList(GRFTextWrapper &list, byte langid, uint32_t grfid, bool allow_newlines, const char *text_to_add); void AddGRFTextToList(GRFTextWrapper &list, const std::string &text_to_add); bool CheckGrfLangID(byte lang_id, byte grf_version); -void StartTextRefStackUsage(const struct GRFFile *grffile, byte numEntries, const uint32 *values = nullptr); +void StartTextRefStackUsage(const struct GRFFile *grffile, byte numEntries, const uint32_t *values = nullptr); void StopTextRefStackUsage(); void RewindTextRefStack(); bool UsingNewGRFTextStack(); @@ -70,7 +70,7 @@ struct LanguageMap { int GetMapping(int newgrf_id, bool gender) const; int GetReverseMapping(int openttd_id, bool gender) const; - static const LanguageMap *GetLanguageMap(uint32 grfid, uint8 language_id); + static const LanguageMap *GetLanguageMap(uint32_t grfid, uint8_t language_id); }; #endif /* NEWGRF_TEXT_H */ diff --git a/src/newgrf_town.cpp b/src/newgrf_town.cpp index c13f37eae4..f8fae8d2f0 100644 --- a/src/newgrf_town.cpp +++ b/src/newgrf_town.cpp @@ -14,7 +14,7 @@ #include "safeguards.h" -/* virtual */ uint32 TownScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const +/* virtual */ uint32_t TownScopeResolver::GetVariable(byte variable, uint32_t parameter, bool *available) const { switch (variable) { /* Larger towns */ @@ -29,7 +29,7 @@ /* Get a variable from the persistent storage */ case 0x7C: { /* Check the persistent storage for the GrfID stored in register 100h. */ - uint32 grfid = GetRegister(0x100); + uint32_t grfid = GetRegister(0x100); if (grfid == 0xFFFFFFFF) { if (this->ro.grffile == nullptr) return 0; grfid = this->ro.grffile->grfid; @@ -116,7 +116,7 @@ return UINT_MAX; } -/* virtual */ void TownScopeResolver::StorePSA(uint pos, int32 value) +/* virtual */ void TownScopeResolver::StorePSA(uint pos, int32_t value) { if (this->readonly) return; @@ -125,7 +125,7 @@ if (this->ro.grffile == nullptr) return; /* Check the persistent storage for the GrfID stored in register 100h. */ - uint32 grfid = GetRegister(0x100); + uint32_t grfid = GetRegister(0x100); /* A NewGRF can only write in the persistent storage associated to its own GRFID. */ if (grfid == 0xFFFFFFFF) grfid = this->ro.grffile->grfid; diff --git a/src/newgrf_town.h b/src/newgrf_town.h index c5970d2976..976243c074 100644 --- a/src/newgrf_town.h +++ b/src/newgrf_town.h @@ -34,8 +34,8 @@ struct TownScopeResolver : public ScopeResolver { { } - virtual uint32 GetVariable(byte variable, uint32 parameter, bool *available) const; - virtual void StorePSA(uint reg, int32 value); + virtual uint32_t GetVariable(byte variable, uint32_t parameter, bool *available) const; + virtual void StorePSA(uint reg, int32_t value); }; /** Resolver of town properties. */ diff --git a/src/newgrf_townname.cpp b/src/newgrf_townname.cpp index a5f67ba3e1..bc89dbc6f1 100644 --- a/src/newgrf_townname.cpp +++ b/src/newgrf_townname.cpp @@ -25,14 +25,14 @@ static std::vector _grf_townnames; static std::vector _grf_townname_names; -GRFTownName *GetGRFTownName(uint32 grfid) +GRFTownName *GetGRFTownName(uint32_t grfid) { auto found = std::find_if(std::begin(_grf_townnames), std::end(_grf_townnames), [&grfid](const GRFTownName &t){ return t.grfid == grfid; }); if (found != std::end(_grf_townnames)) return &*found; return nullptr; } -GRFTownName *AddGRFTownName(uint32 grfid) +GRFTownName *AddGRFTownName(uint32_t grfid) { GRFTownName *t = GetGRFTownName(grfid); if (t == nullptr) { @@ -42,18 +42,18 @@ GRFTownName *AddGRFTownName(uint32 grfid) return t; } -void DelGRFTownName(uint32 grfid) +void DelGRFTownName(uint32_t grfid) { _grf_townnames.erase(std::find_if(std::begin(_grf_townnames), std::end(_grf_townnames), [&grfid](const GRFTownName &t){ return t.grfid == grfid; })); } -static void RandomPart(StringBuilder &builder, const GRFTownName *t, uint32 seed, byte id) +static void RandomPart(StringBuilder &builder, const GRFTownName *t, uint32_t seed, byte id) { assert(t != nullptr); for (const auto &partlist : t->partlists[id]) { byte count = partlist.bitcount; - uint16 maxprob = partlist.maxprob; - uint32 r = (GB(seed, partlist.bitstart, count) * maxprob) >> count; + uint16_t maxprob = partlist.maxprob; + uint32_t r = (GB(seed, partlist.bitstart, count) * maxprob) >> count; for (const auto &part : partlist.parts) { maxprob -= GB(part.prob, 0, 7); if (maxprob > r) continue; @@ -67,7 +67,7 @@ static void RandomPart(StringBuilder &builder, const GRFTownName *t, uint32 seed } } -void GRFTownNameGenerate(StringBuilder &builder, uint32 grfid, uint16 gen, uint32 seed) +void GRFTownNameGenerate(StringBuilder &builder, uint32_t grfid, uint16_t gen, uint32_t seed) { const GRFTownName *t = GetGRFTownName(grfid); if (t != nullptr) { @@ -93,7 +93,7 @@ const std::vector& GetGRFTownNameList() return _grf_townname_names; } -StringID GetGRFTownNameName(uint16 gen) +StringID GetGRFTownNameName(uint16_t gen) { return gen < _grf_townname_names.size() ? _grf_townname_names[gen] : STR_UNDEFINED; } @@ -103,21 +103,21 @@ void CleanUpGRFTownNames() _grf_townnames.clear(); } -uint32 GetGRFTownNameId(uint16 gen) +uint32_t GetGRFTownNameId(uint16_t gen) { for (const auto &t : _grf_townnames) { if (gen < t.styles.size()) return t.grfid; - gen -= static_cast(t.styles.size()); + gen -= static_cast(t.styles.size()); } /* Fallback to no NewGRF */ return 0; } -uint16 GetGRFTownNameType(uint16 gen) +uint16_t GetGRFTownNameType(uint16_t gen) { for (const auto &t : _grf_townnames) { if (gen < t.styles.size()) return gen; - gen -= static_cast(t.styles.size()); + gen -= static_cast(t.styles.size()); } /* Fallback to english original */ return SPECSTR_TOWNNAME_ENGLISH; diff --git a/src/newgrf_townname.h b/src/newgrf_townname.h index ec5356d9ce..1ca54cdb48 100644 --- a/src/newgrf_townname.h +++ b/src/newgrf_townname.h @@ -24,7 +24,7 @@ struct NamePart { struct NamePartList { byte bitstart; ///< Start of random seed bits to use. byte bitcount; ///< Number of bits of random seed to use. - uint16 maxprob; ///< Total probability of all parts. + uint16_t maxprob; ///< Total probability of all parts. std::vector parts; ///< List of parts to choose from. }; @@ -38,18 +38,18 @@ struct TownNameStyle { struct GRFTownName { static const uint MAX_LISTS = 128; ///< Maximum number of town name lists that can be defined per GRF. - uint32 grfid; ///< GRF ID of NewGRF. + uint32_t grfid; ///< GRF ID of NewGRF. std::vector styles; ///< Style names defined by the Town Name NewGRF. std::vector partlists[MAX_LISTS]; ///< Lists of town name parts. }; -GRFTownName *AddGRFTownName(uint32 grfid); -GRFTownName *GetGRFTownName(uint32 grfid); -void DelGRFTownName(uint32 grfid); +GRFTownName *AddGRFTownName(uint32_t grfid); +GRFTownName *GetGRFTownName(uint32_t grfid); +void DelGRFTownName(uint32_t grfid); void CleanUpGRFTownNames(); -uint32 GetGRFTownNameId(uint16 gen); -uint16 GetGRFTownNameType(uint16 gen); -StringID GetGRFTownNameName(uint16 gen); +uint32_t GetGRFTownNameId(uint16_t gen); +uint16_t GetGRFTownNameType(uint16_t gen); +StringID GetGRFTownNameName(uint16_t gen); const std::vector& GetGRFTownNameList(); diff --git a/src/news_cmd.h b/src/news_cmd.h index 6ebb1b84d9..59904875db 100644 --- a/src/news_cmd.h +++ b/src/news_cmd.h @@ -14,7 +14,7 @@ #include "company_type.h" #include "news_type.h" -CommandCost CmdCustomNewsItem(DoCommandFlag flags, NewsType type, NewsReferenceType reftype1, CompanyID company, uint32 reference, const std::string &text); +CommandCost CmdCustomNewsItem(DoCommandFlag flags, NewsType type, NewsReferenceType reftype1, CompanyID company, uint32_t reference, const std::string &text); DEF_CMD_TRAIT(CMD_CUSTOM_NEWS_ITEM, CmdCustomNewsItem, CMD_STR_CTRL | CMD_DEITY, CMDT_OTHER_MANAGEMENT) diff --git a/src/news_func.h b/src/news_func.h index 3f21f3dca1..465bab7243 100644 --- a/src/news_func.h +++ b/src/news_func.h @@ -15,7 +15,7 @@ #include "station_type.h" #include "industry_type.h" -void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceType reftype1 = NR_NONE, uint32 ref1 = UINT32_MAX, NewsReferenceType reftype2 = NR_NONE, uint32 ref2 = UINT32_MAX, const NewsAllocatedData *data = nullptr); +void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceType reftype1 = NR_NONE, uint32_t ref1 = UINT32_MAX, NewsReferenceType reftype2 = NR_NONE, uint32_t ref2 = UINT32_MAX, const NewsAllocatedData *data = nullptr); static inline void AddCompanyNewsItem(StringID string, CompanyNewsInformation *cni) { diff --git a/src/news_gui.cpp b/src/news_gui.cpp index a030672533..e52dc18bf0 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -70,7 +70,7 @@ static const NewsItem *_current_news = nullptr; * @param ref The reference. * @return A tile for the referenced object, or INVALID_TILE if none. */ -static TileIndex GetReferenceTile(NewsReferenceType reftype, uint32 ref) +static TileIndex GetReferenceTile(NewsReferenceType reftype, uint32_t ref) { switch (reftype) { case NR_TILE: return (TileIndex)ref; @@ -263,8 +263,8 @@ NewsDisplay NewsTypeData::GetDisplay() const /** Window class displaying a news item. */ struct NewsWindow : Window { - uint16 chat_height; ///< Height of the chat window. - uint16 status_height; ///< Height of the status bar window + uint16_t chat_height; ///< Height of the chat window. + uint16_t status_height; ///< Height of the status bar window const NewsItem *ni; ///< News item to display. static int duration; ///< Remaining time for showing the current news message (may only be access while a news item is displayed). @@ -308,7 +308,7 @@ struct NewsWindow : Window { /* Initialize viewport if it exists. */ NWidgetViewport *nvp = this->GetWidget(WID_N_VIEWPORT); if (nvp != nullptr) { - nvp->InitializeViewport(this, ni->reftype1 == NR_VEHICLE ? 0x80000000 | ni->ref1 : (uint32)GetReferenceTile(ni->reftype1, ni->ref1),ScaleZoomGUI(ZOOM_LVL_NEWS)); + nvp->InitializeViewport(this, ni->reftype1 == NR_VEHICLE ? 0x80000000 | ni->ref1 : (uint32_t)GetReferenceTile(ni->reftype1, ni->ref1),ScaleZoomGUI(ZOOM_LVL_NEWS)); if (this->ni->flags & NF_NO_TRANSPARENT) nvp->disp_flags |= ND_NO_TRANSPARENCY; if ((this->ni->flags & NF_INCOLOUR) == 0) { nvp->disp_flags |= ND_SHADE_GREY; @@ -332,7 +332,7 @@ struct NewsWindow : Window { GfxFillRect( r.left, ir.bottom, r.right, r.bottom, PC_BLACK); } - Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override + Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override { Point pt = { 0, _screen.height }; return pt; @@ -799,7 +799,7 @@ static void DeleteNewsItem(NewsItem *ni) * * @see NewsSubtype */ -NewsItem::NewsItem(StringID string_id, NewsType type, NewsFlag flags, NewsReferenceType reftype1, uint32 ref1, NewsReferenceType reftype2, uint32 ref2, const NewsAllocatedData *data) : +NewsItem::NewsItem(StringID string_id, NewsType type, NewsFlag flags, NewsReferenceType reftype1, uint32_t ref1, NewsReferenceType reftype2, uint32_t ref2, const NewsAllocatedData *data) : string_id(string_id), date(TimerGameCalendar::date), type(type), flags(flags), reftype1(reftype1), reftype2(reftype2), ref1(ref1), ref2(ref2), data(data) { /* show this news message in colour? */ @@ -820,7 +820,7 @@ NewsItem::NewsItem(StringID string_id, NewsType type, NewsFlag flags, NewsRefere * * @see NewsSubtype */ -void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceType reftype1, uint32 ref1, NewsReferenceType reftype2, uint32 ref2, const NewsAllocatedData *data) +void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceType reftype1, uint32_t ref1, NewsReferenceType reftype2, uint32_t ref2, const NewsAllocatedData *data) { if (_game_mode == GM_MENU) return; @@ -858,7 +858,7 @@ void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceTy * @param text The text of the news message. * @return the cost of this operation or an error */ -CommandCost CmdCustomNewsItem(DoCommandFlag flags, NewsType type, NewsReferenceType reftype1, CompanyID company, uint32 reference, const std::string &text) +CommandCost CmdCustomNewsItem(DoCommandFlag flags, NewsType type, NewsReferenceType reftype1, CompanyID company, uint32_t reference, const std::string &text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; diff --git a/src/news_type.h b/src/news_type.h index c4b6076b24..e2d32a5ae7 100644 --- a/src/news_type.h +++ b/src/news_type.h @@ -133,14 +133,14 @@ struct NewsItem { NewsReferenceType reftype1; ///< Type of ref1 NewsReferenceType reftype2; ///< Type of ref2 - uint32 ref1; ///< Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news, and for deleting the news when the object is deleted. - uint32 ref2; ///< Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news when the object is deleted. + uint32_t ref1; ///< Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news, and for deleting the news when the object is deleted. + uint32_t ref2; ///< Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news when the object is deleted. std::unique_ptr data; ///< Custom data for the news item that will be deallocated (deleted) when the news item has reached its end. std::vector params; ///< Parameters for string resolving. - NewsItem(StringID string_id, NewsType type, NewsFlag flags, NewsReferenceType reftype1, uint32 ref1, NewsReferenceType reftype2, uint32 ref2, const NewsAllocatedData *data); + NewsItem(StringID string_id, NewsType type, NewsFlag flags, NewsReferenceType reftype1, uint32_t ref1, NewsReferenceType reftype2, uint32_t ref2, const NewsAllocatedData *data); }; /** Container for a single string to be passed as NewsAllocatedData. */ @@ -160,7 +160,7 @@ struct CompanyNewsInformation : NewsAllocatedData { std::string president_name; ///< The name of the president std::string other_company_name; ///< The name of the company taking over this one - uint32 face; ///< The face of the president + uint32_t face; ///< The face of the president byte colour; ///< The colour related to the company CompanyNewsInformation(const struct Company *c, const struct Company *other = nullptr); diff --git a/src/object.h b/src/object.h index c374ba9501..0a6c33423c 100644 --- a/src/object.h +++ b/src/object.h @@ -16,7 +16,7 @@ void UpdateCompanyHQ(TileIndex tile, uint score); -void BuildObject(ObjectType type, TileIndex tile, CompanyID owner = OWNER_NONE, struct Town *town = nullptr, uint8 view = 0); +void BuildObject(ObjectType type, TileIndex tile, CompanyID owner = OWNER_NONE, struct Town *town = nullptr, uint8_t view = 0); Window *ShowBuildObjectPicker(); diff --git a/src/object_base.h b/src/object_base.h index 123063aa85..b54f0344e5 100644 --- a/src/object_base.h +++ b/src/object_base.h @@ -62,7 +62,7 @@ struct Object : ObjectPool::PoolItem<&_object_pool> { * @param type ObjectType to query * @pre type < NUM_OBJECTS */ - static inline uint16 GetTypeCount(ObjectType type) + static inline uint16_t GetTypeCount(ObjectType type) { assert(type < NUM_OBJECTS); return counts[type]; @@ -75,7 +75,7 @@ struct Object : ObjectPool::PoolItem<&_object_pool> { } protected: - static uint16 counts[NUM_OBJECTS]; ///< Number of objects per type ingame + static uint16_t counts[NUM_OBJECTS]; ///< Number of objects per type ingame }; /** diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp index f0f37f52f6..89df861c36 100644 --- a/src/object_cmd.cpp +++ b/src/object_cmd.cpp @@ -43,7 +43,7 @@ ObjectPool _object_pool("Object"); INSTANTIATE_POOL_METHODS(Object) -uint16 Object::counts[NUM_OBJECTS]; +uint16_t Object::counts[NUM_OBJECTS]; /** * Get the object associated with a tile. @@ -83,7 +83,7 @@ void InitializeObjects() * @pre All preconditions for building the object at that location * are met, e.g. slope and clearness of tiles are checked. */ -void BuildObject(ObjectType type, TileIndex tile, CompanyID owner, Town *town, uint8 view) +void BuildObject(ObjectType type, TileIndex tile, CompanyID owner, Town *town, uint8_t view) { const ObjectSpec *spec = ObjectSpec::Get(type); @@ -108,7 +108,7 @@ void BuildObject(ObjectType type, TileIndex tile, CompanyID owner, Town *town, u if ((spec->flags & OBJECT_FLAG_2CC_COLOUR) == 0) o->colour &= 0xF; if (HasBit(spec->callback_mask, CBM_OBJ_COLOUR)) { - uint16 res = GetObjectCallback(CBID_OBJECT_COLOUR, o->colour, 0, spec, o, tile); + uint16_t res = GetObjectCallback(CBID_OBJECT_COLOUR, o->colour, 0, spec, o, tile); if (res != CALLBACK_FAILED) { if (res >= 0x100) ErrorUnknownCallbackResult(spec->grf_prop.grffile->grfid, CBID_OBJECT_COLOUR, res); o->colour = GB(res, 0, 8); @@ -203,7 +203,7 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags); * @param view the view for the object * @return the cost of this operation or an error */ -CommandCost CmdBuildObject(DoCommandFlag flags, TileIndex tile, ObjectType type, uint8 view) +CommandCost CmdBuildObject(DoCommandFlag flags, TileIndex tile, ObjectType type, uint8_t view) { CommandCost cost(EXPENSES_CONSTRUCTION); @@ -269,7 +269,7 @@ CommandCost CmdBuildObject(DoCommandFlag flags, TileIndex tile, ObjectType type, if (GetTileSlope(tile, &allowed_z) != SLOPE_FLAT) allowed_z++; for (TileIndex t : ta) { - uint16 callback = CALLBACK_FAILED; + uint16_t callback = CALLBACK_FAILED; if (HasBit(spec->callback_mask, CBM_OBJ_SLOPE_CHECK)) { TileIndex diff = t - tile; callback = GetObjectCallback(CBID_OBJECT_LAND_SLOPE_CHECK, GetTileSlope(t), TileY(diff) << 4 | TileX(diff), spec, nullptr, t, view); @@ -384,7 +384,7 @@ CommandCost CmdBuildObject(DoCommandFlag flags, TileIndex tile, ObjectType type, * @param diagonal Whether to use the Orthogonal (0) or Diagonal (1) iterator. * @return the cost of this operation or an error */ -CommandCost CmdBuildObjectArea(DoCommandFlag flags, TileIndex tile, TileIndex start_tile, ObjectType type, uint8 view, bool diagonal) +CommandCost CmdBuildObjectArea(DoCommandFlag flags, TileIndex tile, TileIndex start_tile, ObjectType type, uint8_t view, bool diagonal) { if (start_tile >= Map::Size()) return CMD_ERROR; @@ -813,7 +813,7 @@ void GenerateObjects() /* Continue, if the object was never available till now or shall not be placed */ if (!spec.WasEverAvailable() || spec.generate_amount == 0) continue; - uint16 amount = spec.generate_amount; + uint16_t amount = spec.generate_amount; /* Scale by map size */ if ((spec.flags & OBJECT_FLAG_SCALE_BY_WATER) && _settings_game.construction.freeform_edges) { @@ -839,7 +839,7 @@ void GenerateObjects() break; default: - uint8 view = RandomRange(spec.views); + uint8_t view = RandomRange(spec.views); if (CmdBuildObject(DC_EXEC | DC_AUTO | DC_NO_TEST_TOWN_RATING | DC_NO_MODIFY_TOWN_RATING, RandomTile(), spec.Index(), view).Succeeded()) amount--; break; } @@ -903,7 +903,7 @@ static CommandCost TerraformTile_Object(TileIndex tile, DoCommandFlag flags, int /* Call callback 'disable autosloping for objects'. */ if (HasBit(spec->callback_mask, CBM_OBJ_AUTOSLOPE)) { /* If the callback fails, allow autoslope. */ - uint16 res = GetObjectCallback(CBID_OBJECT_AUTOSLOPE, 0, 0, spec, Object::GetByTile(tile), tile); + uint16_t res = GetObjectCallback(CBID_OBJECT_AUTOSLOPE, 0, 0, spec, Object::GetByTile(tile), tile); if (res == CALLBACK_FAILED || !ConvertBooleanCallback(spec->grf_prop.grffile, CBID_OBJECT_AUTOSLOPE, res)) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]); } else if (spec->IsEnabled()) { /* allow autoslope */ diff --git a/src/object_cmd.h b/src/object_cmd.h index 43ba045925..42b014ca7d 100644 --- a/src/object_cmd.h +++ b/src/object_cmd.h @@ -13,8 +13,8 @@ #include "command_type.h" #include "object_type.h" -CommandCost CmdBuildObject(DoCommandFlag flags, TileIndex tile, ObjectType type, uint8 view); -CommandCost CmdBuildObjectArea(DoCommandFlag flags, TileIndex tile, TileIndex start_tile, ObjectType type, uint8 view, bool diagonal); +CommandCost CmdBuildObject(DoCommandFlag flags, TileIndex tile, ObjectType type, uint8_t view); +CommandCost CmdBuildObjectArea(DoCommandFlag flags, TileIndex tile, TileIndex start_tile, ObjectType type, uint8_t view, bool diagonal); DEF_CMD_TRAIT(CMD_BUILD_OBJECT, CmdBuildObject, CMD_DEITY | CMD_NO_WATER | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION) DEF_CMD_TRAIT(CMD_BUILD_OBJECT_AREA, CmdBuildObjectArea, CMD_DEITY | CMD_NO_WATER | CMD_NO_TEST | CMD_AUTO, CMDT_LANDSCAPE_CONSTRUCTION) diff --git a/src/object_gui.cpp b/src/object_gui.cpp index a6554364ed..f18e1660f1 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -36,7 +36,7 @@ static ObjectClassID _selected_object_class; ///< Currently selected available object class. static int _selected_object_index; ///< Index of the currently selected object if existing, else \c -1. -static uint8 _selected_object_view; ///< the view of the selected object +static uint8_t _selected_object_view; ///< the view of the selected object /** Enum referring to the Hotkeys in the build object window */ enum BuildObjectHotkeys { @@ -393,7 +393,7 @@ public: /* Get the extra message for the GUI */ if (HasBit(spec->callback_mask, CBM_OBJ_FUND_MORE_TEXT)) { - uint16 callback_res = GetObjectCallback(CBID_OBJECT_FUND_MORE_TEXT, 0, 0, spec, nullptr, INVALID_TILE, _selected_object_view); + uint16_t callback_res = GetObjectCallback(CBID_OBJECT_FUND_MORE_TEXT, 0, 0, spec, nullptr, INVALID_TILE, _selected_object_view); if (callback_res != CALLBACK_FAILED && callback_res != 0x400) { if (callback_res > 0x400) { ErrorUnknownCallbackResult(spec->grf_prop.grffile->grfid, CBID_OBJECT_FUND_MORE_TEXT, callback_res); diff --git a/src/object_type.h b/src/object_type.h index a14c8f57f3..75e9ccead7 100644 --- a/src/object_type.h +++ b/src/object_type.h @@ -11,7 +11,7 @@ #define OBJECT_TYPE_H /** Types of objects. */ -typedef uint16 ObjectType; +typedef uint16_t ObjectType; static const ObjectType OBJECT_TRANSMITTER = 0; ///< The large antenna static const ObjectType OBJECT_LIGHTHOUSE = 1; ///< The nice lighthouse @@ -25,7 +25,7 @@ static const ObjectType NUM_OBJECTS_PER_GRF = NUM_OBJECTS; ///< Number of suppor static const ObjectType INVALID_OBJECT_TYPE = 0xFFFF; ///< An invalid object /** Unique identifier for an object. */ -typedef uint32 ObjectID; +typedef uint32_t ObjectID; struct Object; struct ObjectSpec; diff --git a/src/openttd.cpp b/src/openttd.cpp index 5ffe11b4c6..92aa82b63a 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -224,7 +224,7 @@ static void ShowHelp() static void WriteSavegameInfo(const std::string &name) { extern SaveLoadVersion _sl_version; - uint32 last_ottd_rev = 0; + uint32_t last_ottd_rev = 0; byte ever_modified = 0; bool removed_newgrfs = false; @@ -381,9 +381,9 @@ void OpenBrowser(const char *url) /** Callback structure of statements to be executed after the NewGRF scan. */ struct AfterNewGRFScan : NewGRFScanCallback { TimerGameCalendar::Year startyear = INVALID_YEAR; ///< The start year. - uint32 generation_seed = GENERATE_NEW_SEED; ///< Seed for the new game. + uint32_t generation_seed = GENERATE_NEW_SEED; ///< Seed for the new game. std::string dedicated_host; ///< Hostname for the dedicated server. - uint16 dedicated_port = 0; ///< Port for the dedicated server. + uint16_t dedicated_port = 0; ///< Port for the dedicated server. std::string connection_string; ///< Information about the server to connect to std::string join_server_password; ///< The password to join the server with. std::string join_company_password; ///< The password to join the company with. diff --git a/src/order_backup.cpp b/src/order_backup.cpp index 633aa6c06e..f696d8435d 100644 --- a/src/order_backup.cpp +++ b/src/order_backup.cpp @@ -43,7 +43,7 @@ OrderBackup::~OrderBackup() * @param v The vehicle to make a backup of. * @param user The user that is requesting the backup. */ -OrderBackup::OrderBackup(const Vehicle *v, uint32 user) +OrderBackup::OrderBackup(const Vehicle *v, uint32_t user) { this->user = user; this->tile = v->tile; @@ -103,7 +103,7 @@ void OrderBackup::DoRestore(Vehicle *v) * @param user The user that is requesting the backup. * @note Will automatically remove any previous backups of this user. */ -/* static */ void OrderBackup::Backup(const Vehicle *v, uint32 user) +/* static */ void OrderBackup::Backup(const Vehicle *v, uint32_t user) { /* Don't use reset as that broadcasts over the network to reset the variable, * which is what we are doing at the moment. */ @@ -121,7 +121,7 @@ void OrderBackup::DoRestore(Vehicle *v) * @param user The user that built the vehicle, thus wants to restore. * @note After restoration the backup will automatically be removed. */ -/* static */ void OrderBackup::Restore(Vehicle *v, uint32 user) +/* static */ void OrderBackup::Restore(Vehicle *v, uint32_t user) { for (OrderBackup *ob : OrderBackup::Iterate()) { if (v->tile != ob->tile || ob->user != user) continue; @@ -137,7 +137,7 @@ void OrderBackup::DoRestore(Vehicle *v) * @param user The user associated with the OrderBackup. * @note Must not be used from the GUI! */ -/* static */ void OrderBackup::ResetOfUser(TileIndex tile, uint32 user) +/* static */ void OrderBackup::ResetOfUser(TileIndex tile, uint32_t user) { for (OrderBackup *ob : OrderBackup::Iterate()) { if (ob->user == user && (ob->tile == tile || tile == INVALID_TILE)) delete ob; @@ -165,7 +165,7 @@ CommandCost CmdClearOrderBackup(DoCommandFlag flags, TileIndex tile, ClientID us * @pre _network_server. * @note Must not be used from a command. */ -/* static */ void OrderBackup::ResetUser(uint32 user) +/* static */ void OrderBackup::ResetUser(uint32_t user) { assert(_network_server); @@ -190,7 +190,7 @@ CommandCost CmdClearOrderBackup(DoCommandFlag flags, TileIndex tile, ClientID us * but compiled it. A network client has its own variable for the unique * client/user identifier. Finally if networking isn't compiled in the * default is just plain and simple: 0. */ - uint32 user = _networking && !_network_server ? _network_own_client_id : CLIENT_ID_SERVER; + uint32_t user = _networking && !_network_server ? _network_own_client_id : CLIENT_ID_SERVER; for (OrderBackup *ob : OrderBackup::Iterate()) { /* If this is a GUI action, and it's not a backup of us, ignore it. */ diff --git a/src/order_backup.h b/src/order_backup.h index 2795eba69f..8616c564ee 100644 --- a/src/order_backup.h +++ b/src/order_backup.h @@ -18,7 +18,7 @@ #include "saveload/saveload.h" /** Unique identifier for an order backup. */ -typedef uint8 OrderBackupID; +typedef uint8_t OrderBackupID; struct OrderBackup; /** The pool type for order backups. */ @@ -34,7 +34,7 @@ struct OrderBackup : OrderBackupPool::PoolItem<&_order_backup_pool>, BaseConsist private: friend SaveLoadTable GetOrderBackupDescription(); ///< Saving and loading of order backups. friend struct BKORChunkHandler; ///< Creating empty orders upon savegame loading. - uint32 user; ///< The user that requested the backup. + uint32_t user; ///< The user that requested the backup. TileIndex tile; ///< Tile of the depot where the order was changed. GroupID group; ///< The group the vehicle was part of. @@ -43,18 +43,18 @@ private: /** Creation for savegame restoration. */ OrderBackup() {} - OrderBackup(const Vehicle *v, uint32 user); + OrderBackup(const Vehicle *v, uint32_t user); void DoRestore(Vehicle *v); public: ~OrderBackup(); - static void Backup(const Vehicle *v, uint32 user); - static void Restore(Vehicle *v, uint32 user); + static void Backup(const Vehicle *v, uint32_t user); + static void Restore(Vehicle *v, uint32_t user); - static void ResetOfUser(TileIndex tile, uint32 user); - static void ResetUser(uint32 user); + static void ResetOfUser(TileIndex tile, uint32_t user); + static void ResetUser(uint32_t user); static void Reset(TileIndex tile = INVALID_TILE, bool from_gui = true); static void ClearGroup(GroupID group); diff --git a/src/order_base.h b/src/order_base.h index 78b4b1ff60..9cbd2c2995 100644 --- a/src/order_base.h +++ b/src/order_base.h @@ -45,15 +45,15 @@ private: friend EndianBufferWriter &operator <<(EndianBufferWriter &buffer, const Order &data); friend class EndianBufferReader &operator >>(class EndianBufferReader &buffer, Order &order); - uint8 type; ///< The type of order + non-stop flags - uint8 flags; ///< Load/unload types, depot order/action types. + uint8_t type; ///< The type of order + non-stop flags + uint8_t flags; ///< Load/unload types, depot order/action types. DestinationID dest; ///< The destination of the order. CargoID refit_cargo; ///< Refit CargoID - uint16 wait_time; ///< How long in ticks to wait at the destination. - uint16 travel_time; ///< How long in ticks the journey to this destination should take. - uint16 max_speed; ///< How fast the vehicle may go on the way to the destination. + uint16_t wait_time; ///< How long in ticks to wait at the destination. + uint16_t travel_time; ///< How long in ticks the journey to this destination should take. + uint16_t max_speed; ///< How fast the vehicle may go on the way to the destination. public: Order *next; ///< Pointer to next order. If nullptr, end of list @@ -61,7 +61,7 @@ public: Order() : flags(0), refit_cargo(CT_NO_REFIT), wait_time(0), travel_time(0), max_speed(UINT16_MAX) {} ~Order(); - Order(uint32 packed); + Order(uint32_t packed); /** * Check whether this order is of the given type. @@ -152,7 +152,7 @@ public: /** Get the order to skip to. */ inline VehicleOrderID GetConditionSkipToOrder() const { return this->flags; } /** Get the value to base the skip on. */ - inline uint16 GetConditionValue() const { return GB(this->dest, 0, 11); } + inline uint16_t GetConditionValue() const { return GB(this->dest, 0, 11); } /** Set how the consist must be loaded. */ inline void SetLoadType(OrderLoadFlags load_type) { SB(this->flags, 4, 3, load_type); } @@ -173,7 +173,7 @@ public: /** Get the order to skip to. */ inline void SetConditionSkipToOrder(VehicleOrderID order_id) { this->flags = order_id; } /** Set the value to base the skip on. */ - inline void SetConditionValue(uint16 value) { SB(this->dest, 0, 11, value); } + inline void SetConditionValue(uint16_t value) { SB(this->dest, 0, 11, value); } /* As conditional orders write their "skip to" order all over the flags, we cannot check the * flags to find out if timetabling is enabled. However, as conditional orders are never @@ -186,20 +186,20 @@ public: inline bool IsTravelTimetabled() const { return this->IsType(OT_CONDITIONAL) ? this->travel_time > 0 : HasBit(this->flags, 7); } /** Get the time in ticks a vehicle should wait at the destination or 0 if it's not timetabled. */ - inline uint16 GetTimetabledWait() const { return this->IsWaitTimetabled() ? this->wait_time : 0; } + inline uint16_t GetTimetabledWait() const { return this->IsWaitTimetabled() ? this->wait_time : 0; } /** Get the time in ticks a vehicle should take to reach the destination or 0 if it's not timetabled. */ - inline uint16 GetTimetabledTravel() const { return this->IsTravelTimetabled() ? this->travel_time : 0; } + inline uint16_t GetTimetabledTravel() const { return this->IsTravelTimetabled() ? this->travel_time : 0; } /** Get the time in ticks a vehicle will probably wait at the destination (timetabled or not). */ - inline uint16 GetWaitTime() const { return this->wait_time; } + inline uint16_t GetWaitTime() const { return this->wait_time; } /** Get the time in ticks a vehicle will probably take to reach the destination (timetabled or not). */ - inline uint16 GetTravelTime() const { return this->travel_time; } + inline uint16_t GetTravelTime() const { return this->travel_time; } /** * Get the maxmimum speed in km-ish/h a vehicle is allowed to reach on the way to the * destination. * @return maximum speed. */ - inline uint16 GetMaxSpeed() const { return this->max_speed; } + inline uint16_t GetMaxSpeed() const { return this->max_speed; } /** Set if the wait time is explicitly timetabled (unless the order is conditional). */ inline void SetWaitTimetabled(bool timetabled) { if (!this->IsType(OT_CONDITIONAL)) SB(this->flags, 3, 1, timetabled ? 1 : 0); } @@ -210,20 +210,20 @@ public: * Set the time in ticks to wait at the destination. * @param time Time to set as wait time. */ - inline void SetWaitTime(uint16 time) { this->wait_time = time; } + inline void SetWaitTime(uint16_t time) { this->wait_time = time; } /** * Set the time in ticks to take for travelling to the destination. * @param time Time to set as travel time. */ - inline void SetTravelTime(uint16 time) { this->travel_time = time; } + inline void SetTravelTime(uint16_t time) { this->travel_time = time; } /** * Set the maxmimum speed in km-ish/h a vehicle is allowed to reach on the way to the * destination. * @param speed Speed to be set. */ - inline void SetMaxSpeed(uint16 speed) { this->max_speed = speed; } + inline void SetMaxSpeed(uint16_t speed) { this->max_speed = speed; } bool ShouldStopAtStation(const Vehicle *v, StationID station) const; bool CanLoadOrUnload() const; @@ -245,8 +245,8 @@ public: void AssignOrder(const Order &other); bool Equals(const Order &other) const; - uint32 Pack() const; - uint16 MapOldOrder() const; + uint32_t Pack() const; + uint16_t MapOldOrder() const; void ConvertFromOldSavegame(); }; diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index cc7dd9ed9b..038f630126 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -195,7 +195,7 @@ bool Order::Equals(const Order &other) const * @return the packed representation. * @note unpacking is done in the constructor. */ -uint32 Order::Pack() const +uint32_t Order::Pack() const { return this->dest << 16 | this->flags << 8 | this->type; } @@ -205,9 +205,9 @@ uint32 Order::Pack() const * representation as possible. * @return the TTD-like packed representation. */ -uint16 Order::MapOldOrder() const +uint16_t Order::MapOldOrder() const { - uint16 order = this->GetType(); + uint16_t order = this->GetType(); switch (this->type) { case OT_GOTO_STATION: if (this->GetUnloadType() & OUFB_UNLOAD) SetBit(order, 5); @@ -231,7 +231,7 @@ uint16 Order::MapOldOrder() const * Create an order based on a packed representation of that order. * @param packed the packed representation. */ -Order::Order(uint32 packed) +Order::Order(uint32_t packed) { this->type = (OrderType)GB(packed, 0, 8); this->flags = GB(packed, 8, 8); @@ -952,7 +952,7 @@ void InsertOrder(Vehicle *v, Order *new_o, VehicleOrderID sel_ord) /* We are inserting an order just before the current implicit order. * We do not know whether we will reach current implicit or the newly inserted order first. * So, disable creation of implicit orders until we are on track again. */ - uint16 &gv_flags = u->GetGroundVehicleFlags(); + uint16_t &gv_flags = u->GetGroundVehicleFlags(); SetBit(gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS); } if (sel_ord <= u->cur_implicit_order_index) { @@ -1237,7 +1237,7 @@ CommandCost CmdMoveOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID movi * @param data the data to modify * @return the cost of this operation or an error */ -CommandCost CmdModifyOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, ModifyOrderFlags mof, uint16 data) +CommandCost CmdModifyOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, ModifyOrderFlags mof, uint16_t data) { if (mof >= MOF_END) return CMD_ERROR; @@ -1874,7 +1874,7 @@ void DeleteVehicleOrders(Vehicle *v, bool keep_orderlist, bool reset_order_indic * @param interval proposed service interval * @return Clamped service interval */ -uint16 GetServiceIntervalClamped(uint interval, bool ispercent) +uint16_t GetServiceIntervalClamped(uint interval, bool ispercent) { return ispercent ? Clamp(interval, MIN_SERVINT_PERCENT, MAX_SERVINT_PERCENT) : Clamp(interval, MIN_SERVINT_DAYS, MAX_SERVINT_DAYS); } @@ -1934,7 +1934,7 @@ VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle *v) bool skip_order = false; OrderConditionComparator occ = order->GetConditionComparator(); - uint16 value = order->GetConditionValue(); + uint16_t value = order->GetConditionValue(); switch (order->GetConditionVariable()) { case OCV_LOAD_PERCENTAGE: skip_order = OrderConditionCompare(occ, CalcPercentVehicleFilled(v, nullptr), value); break; @@ -2041,7 +2041,7 @@ bool UpdateOrderDest(Vehicle *v, const Order *order, int conditional_depth, bool /* Disable creation of implicit orders. * When inserting them we do not know that we would have to make the conditional orders point to them. */ if (v->IsGroundVehicle()) { - uint16 &gv_flags = v->GetGroundVehicleFlags(); + uint16_t &gv_flags = v->GetGroundVehicleFlags(); SetBit(gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS); } } else { diff --git a/src/order_cmd.h b/src/order_cmd.h index 5faf871056..b0ab888d94 100644 --- a/src/order_cmd.h +++ b/src/order_cmd.h @@ -14,7 +14,7 @@ #include "order_base.h" #include "misc/endian_buffer.hpp" -CommandCost CmdModifyOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, ModifyOrderFlags mof, uint16 data); +CommandCost CmdModifyOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, ModifyOrderFlags mof, uint16_t data); CommandCost CmdSkipToOrder(DoCommandFlag flags, VehicleID veh_id, VehicleOrderID sel_ord); CommandCost CmdDeleteOrder(DoCommandFlag flags, VehicleID veh_id, VehicleOrderID sel_ord); CommandCost CmdInsertOrder(DoCommandFlag flags, VehicleID veh, VehicleOrderID sel_ord, const Order &new_order); diff --git a/src/order_func.h b/src/order_func.h index 2b8a76f920..c879a2a30d 100644 --- a/src/order_func.h +++ b/src/order_func.h @@ -37,6 +37,6 @@ static const uint DEF_SERVINT_PERCENT = 50; static const uint MIN_SERVINT_PERCENT = 5; static const uint MAX_SERVINT_PERCENT = 90; -uint16 GetServiceIntervalClamped(uint interval, bool ispercent); +uint16_t GetServiceIntervalClamped(uint interval, bool ispercent); #endif /* ORDER_FUNC_H */ diff --git a/src/order_type.h b/src/order_type.h index 77fdb714db..2e4717c7f2 100644 --- a/src/order_type.h +++ b/src/order_type.h @@ -13,9 +13,9 @@ #include "core/enum_type.hpp" typedef byte VehicleOrderID; ///< The index of an order within its current vehicle (not pool related) -typedef uint32 OrderID; -typedef uint16 OrderListID; -typedef uint16 DestinationID; +typedef uint32_t OrderID; +typedef uint16_t OrderListID; +typedef uint16_t DestinationID; /** Invalid vehicle order index (sentinel) */ static const VehicleOrderID INVALID_VEH_ORDER_ID = 0xFF; diff --git a/src/os/macosx/font_osx.cpp b/src/os/macosx/font_osx.cpp index 7897d48141..23737fc564 100644 --- a/src/os/macosx/font_osx.cpp +++ b/src/os/macosx/font_osx.cpp @@ -180,7 +180,7 @@ void CoreTextFontCache::SetFontSize(int pixels) Debug(fontcache, 2, "Loaded font '{}' with size {}", this->font_name, pixels); } -GlyphID CoreTextFontCache::MapCharToGlyph(WChar key) +GlyphID CoreTextFontCache::MapCharToGlyph(char32_t key) { assert(IsPrintable(key)); @@ -205,7 +205,7 @@ GlyphID CoreTextFontCache::MapCharToGlyph(WChar key) return 0; } -const void *CoreTextFontCache::InternalGetFontTable(uint32 tag, size_t &length) +const void *CoreTextFontCache::InternalGetFontTable(uint32_t tag, size_t &length) { CFAutoRelease data(CTFontCopyTable(this->font.get(), (CTFontTableTag)tag, kCTFontTableOptionNoOptions)); if (!data) return nullptr; @@ -246,8 +246,8 @@ const Sprite *CoreTextFontCache::InternalGetGlyph(GlyphID key, bool use_aa) sprite.colours = (use_aa ? SCC_PAL | SCC_ALPHA : SCC_PAL); sprite.width = width; sprite.height = height; - sprite.x_offs = (int16)std::round(CGRectGetMinX(bounds)); - sprite.y_offs = this->ascender - (int16)std::ceil(CGRectGetMaxY(bounds)); + sprite.x_offs = (int16_t)std::round(CGRectGetMinX(bounds)); + sprite.y_offs = this->ascender - (int16_t)std::ceil(CGRectGetMaxY(bounds)); if (bounds.size.width > 0) { /* Glyph is not a white-space glyph. Render it to a bitmap context. */ diff --git a/src/os/macosx/font_osx.h b/src/os/macosx/font_osx.h index 72518c5676..ae1cb8feda 100644 --- a/src/os/macosx/font_osx.h +++ b/src/os/macosx/font_osx.h @@ -23,13 +23,13 @@ class CoreTextFontCache : public TrueTypeFontCache { void SetFontSize(int pixels); const Sprite *InternalGetGlyph(GlyphID key, bool use_aa) override; - const void *InternalGetFontTable(uint32 tag, size_t &length) override; + const void *InternalGetFontTable(uint32_t tag, size_t &length) override; public: CoreTextFontCache(FontSize fs, CFAutoRelease &&font, int pixels); ~CoreTextFontCache() {} void ClearFontCache() override; - GlyphID MapCharToGlyph(WChar key) override; + GlyphID MapCharToGlyph(char32_t key) override; std::string GetFontName() override { return font_name; } bool IsBuiltInFont() override { return false; } const void *GetOSHandle() override { return font.get(); } diff --git a/src/os/macosx/macos.h b/src/os/macosx/macos.h index 5dc6b3e095..9e9e4cf560 100644 --- a/src/os/macosx/macos.h +++ b/src/os/macosx/macos.h @@ -38,7 +38,7 @@ bool IsMonospaceFont(CFStringRef name); void MacOSSetThreadName(const char *name); -uint64 MacOSGetPhysicalMemory(); +uint64_t MacOSGetPhysicalMemory(); /** Deleter that calls CFRelease rather than deleting the pointer. */ diff --git a/src/os/macosx/macos.mm b/src/os/macosx/macos.mm index 9c6a7e370b..9baeea9cff 100644 --- a/src/os/macosx/macos.mm +++ b/src/os/macosx/macos.mm @@ -268,7 +268,7 @@ void MacOSSetThreadName(const char *name) } } -uint64 MacOSGetPhysicalMemory() +uint64_t MacOSGetPhysicalMemory() { return [ [ NSProcessInfo processInfo ] physicalMemory ]; } diff --git a/src/os/macosx/string_osx.cpp b/src/os/macosx/string_osx.cpp index 52feb74c9b..99d2b4a623 100644 --- a/src/os/macosx/string_osx.cpp +++ b/src/os/macosx/string_osx.cpp @@ -113,7 +113,7 @@ public: int CountRuns() const override { return this->size(); } const VisualRun &GetVisualRun(int run) const override { return this->at(run); } - int GetInternalCharLength(WChar c) const override + int GetInternalCharLength(char32_t c) const override { /* CoreText uses UTF-16 internally which means we need to account for surrogate pairs. */ return c >= 0x010000U ? 2 : 1; @@ -138,7 +138,7 @@ public: static CGFloat SpriteFontGetWidth(void *ref_con) { FontSize fs = (FontSize)((size_t)ref_con >> 24); - WChar c = (WChar)((size_t)ref_con & 0xFFFFFF); + char32_t c = (char32_t)((size_t)ref_con & 0xFFFFFF); return GetGlyphWidth(fs, c); } @@ -185,7 +185,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = { } CFAttributedStringSetAttribute(str.get(), CFRangeMake(last, i.first - last), kCTFontAttributeName, font); - CGColorRef color = CGColorCreateGenericGray((uint8)i.second->colour / 255.0f, 1.0f); // We don't care about the real colours, just that they are different. + CGColorRef color = CGColorCreateGenericGray((uint8_t)i.second->colour / 255.0f, 1.0f); // We don't care about the real colours, just that they are different. CFAttributedStringSetAttribute(str.get(), CFRangeMake(last, i.first - last), kCTForegroundColorAttributeName, color); CGColorRelease(color); @@ -351,7 +351,7 @@ int MacOSStringCompare(std::string_view s1, std::string_view s2) while (*s != '\0') { size_t idx = s - string_base; - WChar c = Utf8Consume(&s); + char32_t c = Utf8Consume(&s); if (c < 0x10000) { utf16_str.push_back((UniChar)c); } else { diff --git a/src/os/macosx/string_osx.h b/src/os/macosx/string_osx.h index bd6abd6d10..19c8ba5040 100644 --- a/src/os/macosx/string_osx.h +++ b/src/os/macosx/string_osx.h @@ -61,7 +61,7 @@ public: * @param c The character to add. * @return The number of buffer spaces that were used. */ - static size_t AppendToBuffer(CharType *buff, const CharType *buffer_last, WChar c) + static size_t AppendToBuffer(CharType *buff, const CharType *buffer_last, char32_t c) { if (c >= 0x010000U) { /* Character is encoded using surrogates in UTF-16. */ diff --git a/src/os/windows/crashlog_win.cpp b/src/os/windows/crashlog_win.cpp index 391681fd6e..cc08d692af 100644 --- a/src/os/windows/crashlog_win.cpp +++ b/src/os/windows/crashlog_win.cpp @@ -90,16 +90,16 @@ public: } struct DebugFileInfo { - uint32 size; - uint32 crc32; + uint32_t size; + uint32_t crc32; SYSTEMTIME file_time; }; -static uint32 _crc_table[256]; +static uint32_t _crc_table[256]; static void MakeCRCTable() { - uint32 crc, poly = 0xEDB88320L; + uint32_t crc, poly = 0xEDB88320L; int i; int j; @@ -112,7 +112,7 @@ static void MakeCRCTable() } } -static uint32 CalcCRC(byte *data, uint size, uint32 crc) +static uint32_t CalcCRC(byte *data, uint size, uint32_t crc) { for (; size > 0; size--) { crc = ((crc >> 8) & 0x00FFFFFF) ^ _crc_table[(crc ^ *data++) & 0xFF]; @@ -129,9 +129,9 @@ static void GetFileInfo(DebugFileInfo *dfi, const wchar_t *filename) if (file != INVALID_HANDLE_VALUE) { byte buffer[1024]; DWORD numread; - uint32 filesize = 0; + uint32_t filesize = 0; FILETIME write_time; - uint32 crc = (uint32)-1; + uint32_t crc = (uint32_t)-1; for (;;) { if (ReadFile(file, buffer, sizeof(buffer), &numread, nullptr) == 0 || numread == 0) { @@ -141,7 +141,7 @@ static void GetFileInfo(DebugFileInfo *dfi, const wchar_t *filename) crc = CalcCRC(buffer, numread, crc); } dfi->size = filesize; - dfi->crc32 = crc ^ (uint32)-1; + dfi->crc32 = crc ^ (uint32_t)-1; if (GetFileTime(file, nullptr, nullptr, &write_time)) { FileTimeToSystemTime(&write_time, &dfi->file_time); @@ -308,15 +308,15 @@ static void PrintModuleInfo(std::back_insert_iterator &output_itera { fmt::format_to(output_iterator, "Stack trace:\n"); #ifdef _M_AMD64 - uint32 *b = (uint32*)ep->ContextRecord->Rsp; + uint32_t *b = (uint32_t*)ep->ContextRecord->Rsp; #elif defined(_M_IX86) - uint32 *b = (uint32*)ep->ContextRecord->Esp; + uint32_t *b = (uint32_t*)ep->ContextRecord->Esp; #elif defined(_M_ARM64) - uint32 *b = (uint32*)ep->ContextRecord->Sp; + uint32_t *b = (uint32_t*)ep->ContextRecord->Sp; #endif for (int j = 0; j != 24; j++) { for (int i = 0; i != 8; i++) { - if (IsBadReadPtr(b, sizeof(uint32))) { + if (IsBadReadPtr(b, sizeof(uint32_t))) { fmt::format_to(output_iterator, " ????????"); // OCR: WAS - , 0); } else { fmt::format_to(output_iterator, " {:08X}", *b); @@ -658,7 +658,7 @@ static INT_PTR CALLBACK CrashDialogFunc(HWND wnd, UINT msg, WPARAM wParam, LPARA const char *unix_nl = CrashLogWindows::current->crashlog.data(); char dos_nl[65536]; char *p = dos_nl; - WChar c; + char32_t c; while ((c = Utf8Consume(&unix_nl)) && p < lastof(dos_nl) - 4) { // 4 is max number of bytes per character if (c == '\n') p += Utf8Encode(p, '\r'); p += Utf8Encode(p, c); diff --git a/src/os/windows/font_win32.cpp b/src/os/windows/font_win32.cpp index 7379c09206..286702e0e9 100644 --- a/src/os/windows/font_win32.cpp +++ b/src/os/windows/font_win32.cpp @@ -279,7 +279,7 @@ void Win32FontCache::ClearFontCache() return new_glyph.sprite; } -/* virtual */ GlyphID Win32FontCache::MapCharToGlyph(WChar key) +/* virtual */ GlyphID Win32FontCache::MapCharToGlyph(char32_t key) { assert(IsPrintable(key)); @@ -302,7 +302,7 @@ void Win32FontCache::ClearFontCache() return glyphs[0] != 0xFFFF ? glyphs[0] : 0; } -/* virtual */ const void *Win32FontCache::InternalGetFontTable(uint32 tag, size_t &length) +/* virtual */ const void *Win32FontCache::InternalGetFontTable(uint32_t tag, size_t &length) { DWORD len = GetFontData(this->dc, tag, 0, nullptr, 0); diff --git a/src/os/windows/font_win32.h b/src/os/windows/font_win32.h index 7f5f62a7f2..527caffd46 100644 --- a/src/os/windows/font_win32.h +++ b/src/os/windows/font_win32.h @@ -26,14 +26,14 @@ private: void SetFontSize(FontSize fs, int pixels); protected: - const void *InternalGetFontTable(uint32 tag, size_t &length) override; + const void *InternalGetFontTable(uint32_t tag, size_t &length) override; const Sprite *InternalGetGlyph(GlyphID key, bool aa) override; public: Win32FontCache(FontSize fs, const LOGFONT &logfont, int pixels); ~Win32FontCache(); void ClearFontCache() override; - GlyphID MapCharToGlyph(WChar key) override; + GlyphID MapCharToGlyph(char32_t key) override; std::string GetFontName() override { return this->fontname; } const void *GetOSHandle() override { return &this->logfont; } }; diff --git a/src/os/windows/string_uniscribe.cpp b/src/os/windows/string_uniscribe.cpp index 47975af7ad..8615c0db03 100644 --- a/src/os/windows/string_uniscribe.cpp +++ b/src/os/windows/string_uniscribe.cpp @@ -54,7 +54,7 @@ struct UniscribeRun { }; /** Break a string into language formatting ranges. */ -static std::vector UniscribeItemizeString(UniscribeParagraphLayoutFactory::CharType *buff, int32 length); +static std::vector UniscribeItemizeString(UniscribeParagraphLayoutFactory::CharType *buff, int32_t length); /** Generate and place glyphs for a run of characters. */ static bool UniscribeShapeRun(const UniscribeParagraphLayoutFactory::CharType *buff, UniscribeRun &range); @@ -110,7 +110,7 @@ public: int CountRuns() const override { return (uint)this->size(); } const VisualRun &GetVisualRun(int run) const override { return this->at(run); } - int GetInternalCharLength(WChar c) const override + int GetInternalCharLength(char32_t c) const override { /* Uniscribe uses UTF-16 internally which means we need to account for surrogate pairs. */ return c >= 0x010000U ? 2 : 1; @@ -247,7 +247,7 @@ static bool UniscribeShapeRun(const UniscribeParagraphLayoutFactory::CharType *b return true; } -static std::vector UniscribeItemizeString(UniscribeParagraphLayoutFactory::CharType *buff, int32 length) +static std::vector UniscribeItemizeString(UniscribeParagraphLayoutFactory::CharType *buff, int32_t length) { /* Itemize text. */ SCRIPT_CONTROL control; @@ -280,7 +280,7 @@ static std::vector UniscribeItemizeString(UniscribeParagraphLayoutF /* static */ ParagraphLayouter *UniscribeParagraphLayoutFactory::GetParagraphLayout(CharType *buff, CharType *buff_end, FontMap &fontMapping) { - int32 length = buff_end - buff; + int32_t length = buff_end - buff; /* Can't layout an empty string. */ if (length == 0) return nullptr; @@ -534,7 +534,7 @@ const int *UniscribeParagraphLayout::UniscribeVisualRun::GetGlyphToCharMap() con while (*s != '\0') { size_t idx = s - string_base; - WChar c = Utf8Consume(&s); + char32_t c = Utf8Consume(&s); if (c < 0x10000) { utf16_str.push_back((wchar_t)c); } else { @@ -552,7 +552,7 @@ const int *UniscribeParagraphLayout::UniscribeVisualRun::GetGlyphToCharMap() con if (utf16_str.size() > 0) { /* Itemize string into language runs. */ - std::vector runs = UniscribeItemizeString(&utf16_str[0], (int32)utf16_str.size()); + std::vector runs = UniscribeItemizeString(&utf16_str[0], (int32_t)utf16_str.size()); for (std::vector::const_iterator run = runs.begin(); runs.size() > 0 && run != runs.end() - 1; run++) { /* Get information on valid word and character break.s */ diff --git a/src/os/windows/string_uniscribe.h b/src/os/windows/string_uniscribe.h index e5fc0a6c59..56537be264 100644 --- a/src/os/windows/string_uniscribe.h +++ b/src/os/windows/string_uniscribe.h @@ -43,7 +43,7 @@ public: * @param c The character to add. * @return The number of buffer spaces that were used. */ - static size_t AppendToBuffer(CharType *buff, const CharType *buffer_last, WChar c) + static size_t AppendToBuffer(CharType *buff, const CharType *buffer_last, char32_t c) { if (c >= 0x010000U) { /* Character is encoded using surrogates in UTF-16. */ diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp index 23d68dc3ed..49693ffe8d 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -193,16 +193,16 @@ void FiosGetDrives(FileList &file_list) bool FiosIsValidFile(const std::string &path, const struct dirent *ent, struct stat *sb) { /* hectonanoseconds between Windows and POSIX epoch */ - static const int64 posix_epoch_hns = 0x019DB1DED53E8000LL; + static const int64_t posix_epoch_hns = 0x019DB1DED53E8000LL; const WIN32_FIND_DATA *fd = &ent->dir->fd; - sb->st_size = ((uint64) fd->nFileSizeHigh << 32) + fd->nFileSizeLow; + sb->st_size = ((uint64_t) fd->nFileSizeHigh << 32) + fd->nFileSizeLow; /* UTC FILETIME to seconds-since-1970 UTC * we just have to subtract POSIX epoch and scale down to units of seconds. * http://www.gamedev.net/community/forums/topic.asp?topic_id=294070&whichpage=1� * XXX - not entirely correct, since filetimes on FAT aren't UTC but local, * this won't entirely be correct, but we use the time only for comparison. */ - sb->st_mtime = (time_t)((*(const uint64*)&fd->ftLastWriteTime - posix_epoch_hns) / 1E7); + sb->st_mtime = (time_t)((*(const uint64_t*)&fd->ftLastWriteTime - posix_epoch_hns) / 1E7); sb->st_mode = (fd->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)? S_IFDIR : S_IFREG; return true; diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp index ebffc51c52..c43d319b75 100644 --- a/src/osk_gui.cpp +++ b/src/osk_gui.cpp @@ -25,7 +25,7 @@ #include "safeguards.h" std::string _keyboard_opt[2]; -static WChar _keyboard[2][OSK_KEYBOARD_ENTRIES]; +static char32_t _keyboard[2][OSK_KEYBOARD_ENTRIES]; enum KeyStateBits { KEYS_NONE, @@ -105,7 +105,7 @@ struct OskWindow : public Window { { /* clicked a letter */ if (widget >= WID_OSK_LETTERS) { - WChar c = _keyboard[this->shift][widget - WID_OSK_LETTERS]; + char32_t c = _keyboard[this->shift][widget - WID_OSK_LETTERS]; if (!IsValidChar(c, this->qs->text.afilter)) return; @@ -221,7 +221,7 @@ static const int KEY_PADDING = 6; // Vertical padding for remaining key rows * @param biggest_index Collected biggest widget index so far. * @note Key width is measured in 1/2 keys to allow for 1/2 key shifting between rows. */ -static void AddKey(NWidgetHorizontal *hor, int pad_y, int num_half, WidgetType widtype, int widnum, uint16 widdata, int *biggest_index) +static void AddKey(NWidgetHorizontal *hor, int pad_y, int num_half, WidgetType widtype, int widnum, uint16_t widdata, int *biggest_index) { int key_width = HALF_KEY_WIDTH + (INTER_KEY_SPACE + HALF_KEY_WIDTH) * (num_half - 1); diff --git a/src/pathfinder/follow_track.hpp b/src/pathfinder/follow_track.hpp index d50ae13d26..ce15790d41 100644 --- a/src/pathfinder/follow_track.hpp +++ b/src/pathfinder/follow_track.hpp @@ -450,12 +450,12 @@ public: } /* Check for speed limit imposed by railtype */ if (IsRailTT()) { - uint16 rail_speed = GetRailTypeInfo(GetRailType(m_old_tile))->max_speed; + uint16_t rail_speed = GetRailTypeInfo(GetRailType(m_old_tile))->max_speed; if (rail_speed > 0) max_speed = std::min(max_speed, rail_speed); } if (IsRoadTT()) { /* max_speed is already in roadvehicle units, no need to further modify (divide by 2) */ - uint16 road_speed = GetRoadTypeInfo(GetRoadType(m_old_tile, GetRoadTramType(RoadVehicle::From(m_veh)->roadtype)))->max_speed; + uint16_t road_speed = GetRoadTypeInfo(GetRoadType(m_old_tile, GetRoadTramType(RoadVehicle::From(m_veh)->roadtype)))->max_speed; if (road_speed > 0) max_speed = std::min(max_speed, road_speed); } diff --git a/src/pathfinder/npf/aystar.h b/src/pathfinder/npf/aystar.h index aa57037d16..7046fcf570 100644 --- a/src/pathfinder/npf/aystar.h +++ b/src/pathfinder/npf/aystar.h @@ -73,7 +73,7 @@ struct AyStar; * - #AYSTAR_FOUND_END_NODE : indicates this is the end tile * - #AYSTAR_DONE : indicates this is not the end tile (or direction was wrong) */ -typedef int32 AyStar_EndNodeCheck(const AyStar *aystar, const OpenListNode *current); +typedef int32_t AyStar_EndNodeCheck(const AyStar *aystar, const OpenListNode *current); /** * Calculate the G-value for the %AyStar algorithm. @@ -81,14 +81,14 @@ typedef int32 AyStar_EndNodeCheck(const AyStar *aystar, const OpenListNode *curr * - #AYSTAR_INVALID_NODE : indicates an item is not valid (e.g.: unwalkable) * - Any value >= 0 : the g-value for this tile */ -typedef int32 AyStar_CalculateG(AyStar *aystar, AyStarNode *current, OpenListNode *parent); +typedef int32_t AyStar_CalculateG(AyStar *aystar, AyStarNode *current, OpenListNode *parent); /** * Calculate the H-value for the %AyStar algorithm. * Mostly, this must return the distance (Manhattan way) between the current point and the end point. * @return The h-value for this tile (any value >= 0) */ -typedef int32 AyStar_CalculateH(AyStar *aystar, AyStarNode *current, OpenListNode *parent); +typedef int32_t AyStar_CalculateH(AyStar *aystar, AyStarNode *current, OpenListNode *parent); /** * This function requests the tiles around the current tile and put them in #neighbours. diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp index befdae0814..b20db3f86c 100644 --- a/src/pathfinder/npf/npf.cpp +++ b/src/pathfinder/npf/npf.cpp @@ -148,7 +148,7 @@ static uint NPFHash(uint key1, uint key2) return ((part1 << NPF_HASH_HALFBITS | part2) + (NPF_HASH_SIZE * key2 / TRACKDIR_END)) % NPF_HASH_SIZE; } -static int32 NPFCalcZero(AyStar *as, AyStarNode *current, OpenListNode *parent) +static int32_t NPFCalcZero(AyStar *as, AyStarNode *current, OpenListNode *parent) { return 0; } @@ -156,7 +156,7 @@ static int32 NPFCalcZero(AyStar *as, AyStarNode *current, OpenListNode *parent) /* Calculates the heuristic to the target station or tile. For train stations, it * takes into account the direction of approach. */ -static int32 NPFCalcStationOrTileHeuristic(AyStar *as, AyStarNode *current, OpenListNode *parent) +static int32_t NPFCalcStationOrTileHeuristic(AyStar *as, AyStarNode *current, OpenListNode *parent) { NPFFindStationOrTileData *fstd = (NPFFindStationOrTileData*)as->user_target; NPFFoundTargetData *ftd = (NPFFoundTargetData*)as->user_path; @@ -312,9 +312,9 @@ static Vehicle *CountShipProc(Vehicle *v, void *data) return nullptr; } -static int32 NPFWaterPathCost(AyStar *as, AyStarNode *current, OpenListNode *parent) +static int32_t NPFWaterPathCost(AyStar *as, AyStarNode *current, OpenListNode *parent) { - int32 cost = 0; + int32_t cost = 0; Trackdir trackdir = current->direction; cost = _trackdir_length[trackdir]; // Should be different for diagonal tracks @@ -340,10 +340,10 @@ static int32 NPFWaterPathCost(AyStar *as, AyStarNode *current, OpenListNode *par } /* Determine the cost of this node, for road tracks */ -static int32 NPFRoadPathCost(AyStar *as, AyStarNode *current, OpenListNode *parent) +static int32_t NPFRoadPathCost(AyStar *as, AyStarNode *current, OpenListNode *parent) { TileIndex tile = current->tile; - int32 cost = 0; + int32_t cost = 0; /* Determine base length */ switch (GetTileType(tile)) { @@ -399,11 +399,11 @@ static int32 NPFRoadPathCost(AyStar *as, AyStarNode *current, OpenListNode *pare /* Determine the cost of this node, for railway tracks */ -static int32 NPFRailPathCost(AyStar *as, AyStarNode *current, OpenListNode *parent) +static int32_t NPFRailPathCost(AyStar *as, AyStarNode *current, OpenListNode *parent) { TileIndex tile = current->tile; Trackdir trackdir = current->direction; - int32 cost = 0; + int32_t cost = 0; /* HACK: We create a OpenListNode manually, so we can call EndNodeCheck */ OpenListNode new_node; @@ -550,7 +550,7 @@ static int32 NPFRailPathCost(AyStar *as, AyStarNode *current, OpenListNode *pare } /* Will find any depot */ -static int32 NPFFindDepot(const AyStar *as, const OpenListNode *current) +static int32_t NPFFindDepot(const AyStar *as, const OpenListNode *current) { AyStarUserData *user = (AyStarUserData *)as->user_data; /* It's not worth caching the result with NPF_FLAG_IS_TARGET here as below, @@ -560,7 +560,7 @@ static int32 NPFFindDepot(const AyStar *as, const OpenListNode *current) } /** Find any safe and free tile. */ -static int32 NPFFindSafeTile(const AyStar *as, const OpenListNode *current) +static int32_t NPFFindSafeTile(const AyStar *as, const OpenListNode *current) { const Train *v = Train::From(((NPFFindStationOrTileData *)as->user_target)->v); @@ -570,7 +570,7 @@ static int32 NPFFindSafeTile(const AyStar *as, const OpenListNode *current) } /* Will find a station identified using the NPFFindStationOrTileData */ -static int32 NPFFindStationOrTile(const AyStar *as, const OpenListNode *current) +static int32_t NPFFindStationOrTile(const AyStar *as, const OpenListNode *current) { NPFFindStationOrTileData *fstd = (NPFFindStationOrTileData*)as->user_target; const AyStarNode *node = ¤t->path.node; diff --git a/src/pathfinder/yapf/yapf_node_rail.hpp b/src/pathfinder/yapf/yapf_node_rail.hpp index 9d33ab7a7a..8aa517e042 100644 --- a/src/pathfinder/yapf/yapf_node_rail.hpp +++ b/src/pathfinder/yapf/yapf_node_rail.hpp @@ -13,7 +13,7 @@ /** key for cached segment cost for rail YAPF */ struct CYapfRailSegmentKey { - uint32 m_value; + uint32_t m_value; inline CYapfRailSegmentKey(const CYapfNodeKeyTrackDir &node_key) { @@ -30,7 +30,7 @@ struct CYapfRailSegmentKey m_value = (((int)node_key.m_tile) << 4) | node_key.m_td; } - inline int32 CalcHash() const + inline int32_t CalcHash() const { return m_value; } @@ -123,9 +123,9 @@ struct CYapfRailNodeT typedef CYapfRailSegment CachedData; CYapfRailSegment *m_segment; - uint16 m_num_signals_passed; + uint16_t m_num_signals_passed; union { - uint32 m_inherited_flags; + uint32_t m_inherited_flags; struct { bool m_targed_seen : 1; bool m_choice_seen : 1; diff --git a/src/querystring_gui.h b/src/querystring_gui.h index bd8ccb7a88..6903e23f6b 100644 --- a/src/querystring_gui.h +++ b/src/querystring_gui.h @@ -35,7 +35,7 @@ struct QueryString { * @param size Maximum size in bytes. * @param chars Maximum size in chars. */ - QueryString(uint16 size, uint16 chars = UINT16_MAX) : ok_button(ACTION_NOTHING), cancel_button(ACTION_DESELECT), text(size, chars) + QueryString(uint16_t size, uint16_t chars = UINT16_MAX) : ok_button(ACTION_NOTHING), cancel_button(ACTION_DESELECT), text(size, chars) { } diff --git a/src/rail.h b/src/rail.h index 087212cf27..6fbcaf3bf1 100644 --- a/src/rail.h +++ b/src/rail.h @@ -211,22 +211,22 @@ public: /** * Cost multiplier for building this rail type */ - uint16 cost_multiplier; + uint16_t cost_multiplier; /** * Cost multiplier for maintenance of this rail type */ - uint16 maintenance_multiplier; + uint16_t maintenance_multiplier; /** * Acceleration type of this rail type */ - uint8 acceleration_type; + uint8_t acceleration_type; /** * Maximum speed for vehicles travelling on this rail type */ - uint16 max_speed; + uint16_t max_speed; /** * Unique 32 bit rail type identifier @@ -425,7 +425,7 @@ static inline Money RailConvertCost(RailType from, RailType to) * @param total_num Total number of track bits of all railtypes. * @return Total cost. */ -static inline Money RailMaintenanceCost(RailType railtype, uint32 num, uint32 total_num) +static inline Money RailMaintenanceCost(RailType railtype, uint32_t num, uint32_t total_num) { assert(railtype < RAILTYPE_END); return (_price[PR_INFRASTRUCTURE_RAIL] * GetRailTypeInfo(railtype)->maintenance_multiplier * num * (1 + IntSqrt(total_num))) >> 11; // 4 bits fraction for the multiplier and 7 bits scaling. @@ -436,7 +436,7 @@ static inline Money RailMaintenanceCost(RailType railtype, uint32 num, uint32 to * @param num Number of signals. * @return Total cost. */ -static inline Money SignalMaintenanceCost(uint32 num) +static inline Money SignalMaintenanceCost(uint32_t num) { return (_price[PR_INFRASTRUCTURE_RAIL] * 15 * num * (1 + IntSqrt(num))) >> 8; // 1 bit fraction for the multiplier and 7 bits scaling. } diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 2e35c19b20..ae5d9769a1 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1055,7 +1055,7 @@ CommandCost CmdBuildTrainDepot(DoCommandFlag flags, TileIndex tile, RailType rai * @return the cost of this operation or an error * @todo p2 should be replaced by two bits for "along" and "against" the track. */ -CommandCost CmdBuildSingleSignal(DoCommandFlag flags, TileIndex tile, Track track, SignalType sigtype, SignalVariant sigvar, bool convert_signal, bool skip_existing_signals, bool ctrl_pressed, SignalType cycle_start, SignalType cycle_stop, uint8 num_dir_cycle, byte signals_copy) +CommandCost CmdBuildSingleSignal(DoCommandFlag flags, TileIndex tile, Track track, SignalType sigtype, SignalVariant sigvar, bool convert_signal, bool skip_existing_signals, bool ctrl_pressed, SignalType cycle_start, SignalType cycle_stop, uint8_t num_dir_cycle, byte signals_copy) { if (sigtype > SIGTYPE_LAST || sigvar > SIG_SEMAPHORE) return CMD_ERROR; if (cycle_start > cycle_stop || cycle_stop > SIGTYPE_LAST) return CMD_ERROR; @@ -1914,7 +1914,7 @@ static void DrawSingleSignal(TileIndex tile, const RailtypeInfo *rti, Track trac AddSortableSpriteToDraw(sprite, PAL_NONE, x, y, 1, 1, BB_HEIGHT_UNDER_BRIDGE, GetSaveSlopeZ(x, y, track)); } -static uint32 _drawtile_track_palette; +static uint32_t _drawtile_track_palette; @@ -2549,7 +2549,7 @@ void DrawTrainDepotSprite(int x, int y, int dir, RailType railtype) const DrawTileSprites *dts = &_depot_gfx_table[dir]; const RailtypeInfo *rti = GetRailTypeInfo(railtype); SpriteID image = rti->UsesOverlay() ? SPR_FLAT_GRASS_TILE : dts->ground.sprite; - uint32 offset = rti->GetRailtypeSpriteOffset(); + uint32_t offset = rti->GetRailtypeSpriteOffset(); if (image != SPR_FLAT_GRASS_TILE) image += offset; PaletteID palette = COMPANY_SPRITE_COLOUR(_local_company); @@ -2864,7 +2864,7 @@ static void GetTileDesc_Track(TileIndex tile, TileDesc *td) td->str = STR_LAI_RAIL_DESCRIPTION_TRAIN_DEPOT; if (_settings_game.vehicle.train_acceleration_model != AM_ORIGINAL) { if (td->rail_speed > 0) { - td->rail_speed = std::min(td->rail_speed, 61); + td->rail_speed = std::min(td->rail_speed, 61); } else { td->rail_speed = 61; } @@ -2907,7 +2907,7 @@ static void ChangeTileOwner_Track(TileIndex tile, Owner old_owner, Owner new_own static const byte _fractcoords_behind[4] = { 0x8F, 0x8, 0x80, 0xF8 }; static const byte _fractcoords_enter[4] = { 0x8A, 0x48, 0x84, 0xA8 }; -static const int8 _deltacoord_leaveoffset[8] = { +static const int8_t _deltacoord_leaveoffset[8] = { -1, 0, 1, 0, /* x */ 0, 1, 0, -1 /* y */ }; diff --git a/src/rail_cmd.h b/src/rail_cmd.h index 8bee52e74c..4d671a1d5d 100644 --- a/src/rail_cmd.h +++ b/src/rail_cmd.h @@ -20,7 +20,7 @@ CommandCost CmdRemoveRailroadTrack(DoCommandFlag flags, TileIndex end_tile, Tile CommandCost CmdBuildSingleRail(DoCommandFlag flags, TileIndex tile, RailType railtype, Track track, bool auto_remove_signals); CommandCost CmdRemoveSingleRail(DoCommandFlag flags, TileIndex tile, Track track); CommandCost CmdBuildTrainDepot(DoCommandFlag flags, TileIndex tile, RailType railtype, DiagDirection dir); -CommandCost CmdBuildSingleSignal(DoCommandFlag flags, TileIndex tile, Track track, SignalType sigtype, SignalVariant sigvar, bool convert_signal, bool skip_existing_signals, bool ctrl_pressed, SignalType cycle_start, SignalType cycle_stop, uint8 num_dir_cycle, byte signals_copy); +CommandCost CmdBuildSingleSignal(DoCommandFlag flags, TileIndex tile, Track track, SignalType sigtype, SignalVariant sigvar, bool convert_signal, bool skip_existing_signals, bool ctrl_pressed, SignalType cycle_start, SignalType cycle_stop, uint8_t num_dir_cycle, byte signals_copy); CommandCost CmdRemoveSingleSignal(DoCommandFlag flags, TileIndex tile, Track track); CommandCost CmdConvertRail(DoCommandFlag flags, TileIndex tile, TileIndex area_start, RailType totype, bool diagonal); CommandCost CmdBuildSignalTrack(DoCommandFlag flags, TileIndex tile, TileIndex end_tile, Track track, SignalType sigtype, SignalVariant sigvar, bool mode, bool autofill, bool minimise_gaps, byte signal_density); diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index b1f451ef3e..e471cf6ec5 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -83,7 +83,7 @@ static bool IsStationAvailable(const StationSpec *statspec) { if (statspec == nullptr || !HasBit(statspec->callback_mask, CBM_STATION_AVAIL)) return true; - uint16 cb_res = GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, nullptr, INVALID_TILE); + uint16_t cb_res = GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, nullptr, INVALID_TILE); if (cb_res == CALLBACK_FAILED) return true; return Convert8bitBooleanCallback(statspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res); @@ -2293,7 +2293,7 @@ static void SetDefaultRailGui() * to the one adequate to current year. * @param new_value needed to be called when a setting changes */ -void ResetSignalVariant(int32 new_value) +void ResetSignalVariant(int32_t new_value) { SignalVariant new_variant = (TimerGameCalendar::year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC); diff --git a/src/rail_gui.h b/src/rail_gui.h index 582176493e..9af41eb82e 100644 --- a/src/rail_gui.h +++ b/src/rail_gui.h @@ -15,18 +15,18 @@ struct Window *ShowBuildRailToolbar(RailType railtype); void ReinitGuiAfterToggleElrail(bool disable); -void ResetSignalVariant(int32 = 0); +void ResetSignalVariant(int32_t = 0); void InitializeRailGUI(); DropDownList GetRailTypeDropDownList(bool for_replacement = false, bool all_option = false); /** Settings for which signals are shown by the signal GUI. */ -enum SignalGUISettings : uint8 { +enum SignalGUISettings : uint8_t { SIGNAL_GUI_PATH = 0, ///< Show path signals only. SIGNAL_GUI_ALL = 1, ///< Show all signals, including block and presignals. }; /** Settings for which signals are cycled through by control-clicking on the signal with the signal tool. */ -enum SignalCycleSettings : uint8 { +enum SignalCycleSettings : uint8_t { SIGNAL_CYCLE_PATH = 0, ///< Cycle through path signals only. SIGNAL_CYCLE_ALL = 1, ///< Cycle through all signals visible. }; diff --git a/src/rail_type.h b/src/rail_type.h index 6824007921..b0796ffd24 100644 --- a/src/rail_type.h +++ b/src/rail_type.h @@ -12,7 +12,7 @@ #include "core/enum_type.hpp" -typedef uint32 RailTypeLabel; +typedef uint32_t RailTypeLabel; static const RailTypeLabel RAILTYPE_RAIL_LABEL = 'RAIL'; static const RailTypeLabel RAILTYPE_ELECTRIC_LABEL = 'ELRL'; @@ -39,9 +39,9 @@ DECLARE_POSTFIX_INCREMENT(RailType) /** * The different railtypes we support, but then a bitmask of them. - * @note Must be treated as a uint64 type, narrowing it causes bit membership tests to give wrong results, as in bug #6951. + * @note Must be treated as a uint64_t type, narrowing it causes bit membership tests to give wrong results, as in bug #6951. */ -enum RailTypes : uint64 { +enum RailTypes : uint64_t { RAILTYPES_NONE = 0, ///< No rail types RAILTYPES_RAIL = 1 << RAILTYPE_RAIL, ///< Non-electrified rails RAILTYPES_ELECTRIC = 1 << RAILTYPE_ELECTRIC, ///< Electrified rails diff --git a/src/random_access_file.cpp b/src/random_access_file.cpp index a22903819f..60df8cdc00 100644 --- a/src/random_access_file.cpp +++ b/src/random_access_file.cpp @@ -115,7 +115,7 @@ byte RandomAccessFile::ReadByte() * Read a word (16 bits) from the file (in low endian format). * @return Read word. */ -uint16 RandomAccessFile::ReadWord() +uint16_t RandomAccessFile::ReadWord() { byte b = this->ReadByte(); return (this->ReadByte() << 8) | b; @@ -125,7 +125,7 @@ uint16 RandomAccessFile::ReadWord() * Read a double word (32 bits) from the file (in low endian format). * @return Read word. */ -uint32 RandomAccessFile::ReadDword() +uint32_t RandomAccessFile::ReadDword() { uint b = this->ReadWord(); return (this->ReadWord() << 16) | b; diff --git a/src/random_access_file_type.h b/src/random_access_file_type.h index 8e66cf0f69..1573855274 100644 --- a/src/random_access_file_type.h +++ b/src/random_access_file_type.h @@ -47,8 +47,8 @@ public: void SeekTo(size_t pos, int mode); byte ReadByte(); - uint16 ReadWord(); - uint32 ReadDword(); + uint16_t ReadWord(); + uint32_t ReadDword(); void ReadBlock(void *ptr, size_t size); void SkipBytes(int n); diff --git a/src/rev.cpp.in b/src/rev.cpp.in index 3b8e68f955..a2270c2c1d 100644 --- a/src/rev.cpp.in +++ b/src/rev.cpp.in @@ -95,4 +95,4 @@ const char _openttd_content_version[] = "${REV_MAJOR}.${REV_MINOR}"; * the "patch" part of the version. To make sure "1.11.0" is smaller than "12.0", we * have to adjust the major by 16. */ -const uint32 _openttd_newgrf_version = (${REV_MAJOR} + 16) << 24 | ${REV_MINOR} << 20 | ${REV_ISSTABLETAG} << 19 | 28004; +const uint32_t _openttd_newgrf_version = (${REV_MAJOR} + 16) << 24 | ${REV_MINOR} << 20 | ${REV_ISSTABLETAG} << 19 | 28004; diff --git a/src/rev.h b/src/rev.h index 38883d1ccc..b7b9c4412f 100644 --- a/src/rev.h +++ b/src/rev.h @@ -17,7 +17,7 @@ extern const char _openttd_revision_year[]; extern const byte _openttd_revision_modified; extern const byte _openttd_revision_tagged; extern const char _openttd_content_version[]; -extern const uint32 _openttd_newgrf_version; +extern const uint32_t _openttd_newgrf_version; bool IsReleasedVersion(); diff --git a/src/road.h b/src/road.h index 6872a8ca5e..3fa95c273e 100644 --- a/src/road.h +++ b/src/road.h @@ -25,7 +25,7 @@ enum RoadTramType : bool { RTT_TRAM, }; -enum RoadTramTypes : uint8 { +enum RoadTramTypes : uint8_t { RTTB_ROAD = 1 << RTT_ROAD, RTTB_TRAM = 1 << RTT_TRAM, }; @@ -126,17 +126,17 @@ public: /** * Cost multiplier for building this road type */ - uint16 cost_multiplier; + uint16_t cost_multiplier; /** * Cost multiplier for maintenance of this road type */ - uint16 maintenance_multiplier; + uint16_t maintenance_multiplier; /** * Maximum speed for vehicles travelling on this road type */ - uint16 max_speed; + uint16_t max_speed; /** * Unique 32 bit road type identifier diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index ed3fbdc392..212f0cd60f 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -1287,7 +1287,7 @@ static CommandCost ClearTile_Road(TileIndex tile, DoCommandFlag flags) struct DrawRoadTileStruct { - uint16 image; + uint16_t image; byte subcoord_x; byte subcoord_y; }; diff --git a/src/road_cmd.h b/src/road_cmd.h index ef3d8f364b..6eb0c997a3 100644 --- a/src/road_cmd.h +++ b/src/road_cmd.h @@ -34,6 +34,6 @@ DEF_CMD_TRAIT(CMD_CONVERT_ROAD, CmdConvertRoad, 0, CommandCallback CcPlaySound_CONSTRUCTION_OTHER; CommandCallback CcBuildRoadTunnel; void CcRoadDepot(Commands cmd, const CommandCost &result, TileIndex tile, RoadType rt, DiagDirection dir); -void CcRoadStop(Commands cmd, const CommandCost &result, TileIndex tile, uint8 width, uint8 length, RoadStopType, bool is_drive_through, DiagDirection dir, RoadType, RoadStopClassID spec_class, uint16_t spec_index, StationID, bool); +void CcRoadStop(Commands cmd, const CommandCost &result, TileIndex tile, uint8_t width, uint8_t length, RoadStopType, bool is_drive_through, DiagDirection dir, RoadType, RoadStopClassID spec_class, uint16_t spec_index, StationID, bool); #endif /* ROAD_CMD_H */ diff --git a/src/road_func.h b/src/road_func.h index 9b66fcc85b..031e2978a5 100644 --- a/src/road_func.h +++ b/src/road_func.h @@ -122,7 +122,7 @@ static inline RoadBits AxisToRoadBits(Axis a) * @param total_num Total number of road bits of all road/tram-types. * @return Total cost. */ -static inline Money RoadMaintenanceCost(RoadType roadtype, uint32 num, uint32 total_num) +static inline Money RoadMaintenanceCost(RoadType roadtype, uint32_t num, uint32_t total_num) { assert(roadtype < ROADTYPE_END); return (_price[PR_INFRASTRUCTURE_ROAD] * GetRoadTypeInfo(roadtype)->maintenance_multiplier * num * (1 + IntSqrt(total_num))) >> 12; diff --git a/src/road_gui.cpp b/src/road_gui.cpp index d565b81c96..01ac10ec75 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -92,7 +92,7 @@ static bool IsRoadStopAvailable(const RoadStopSpec *roadstopspec, StationType ty if (!HasBit(roadstopspec->callback_mask, CBM_ROAD_STOP_AVAIL)) return true; - uint16 cb_res = GetRoadStopCallback(CBID_STATION_AVAILABILITY, 0, 0, roadstopspec, nullptr, INVALID_TILE, _cur_roadtype, type, 0); + uint16_t cb_res = GetRoadStopCallback(CBID_STATION_AVAILABILITY, 0, 0, roadstopspec, nullptr, INVALID_TILE, _cur_roadtype, type, 0); if (cb_res == CALLBACK_FAILED) return true; return Convert8bitBooleanCallback(roadstopspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res); @@ -180,7 +180,7 @@ void CcRoadDepot(Commands cmd, const CommandCost &result, TileIndex tile, RoadTy * @param spec_index Road stop spec index. * @see CmdBuildRoadStop */ -void CcRoadStop(Commands cmd, const CommandCost &result, TileIndex tile, uint8 width, uint8 length, RoadStopType, bool is_drive_through, +void CcRoadStop(Commands cmd, const CommandCost &result, TileIndex tile, uint8_t width, uint8_t length, RoadStopType, bool is_drive_through, DiagDirection dir, RoadType, RoadStopClassID spec_class, uint16_t spec_index, StationID, bool) { if (result.Failed()) return; @@ -1472,7 +1472,7 @@ public: } else { DiagDirection orientation = _roadstop_gui_settings.orientation; if (orientation < DIAGDIR_END && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) orientation = DIAGDIR_END; - DrawRoadStopTile(x, y, _cur_roadtype, spec, st, (uint8)orientation); + DrawRoadStopTile(x, y, _cur_roadtype, spec, st, (uint8_t)orientation); } } break; diff --git a/src/road_type.h b/src/road_type.h index 58ac0a6010..172ea83ed4 100644 --- a/src/road_type.h +++ b/src/road_type.h @@ -12,7 +12,7 @@ #include "core/enum_type.hpp" -typedef uint32 RoadTypeLabel; +typedef uint32_t RoadTypeLabel; /** * The different roadtypes we support @@ -30,9 +30,9 @@ DECLARE_POSTFIX_INCREMENT(RoadType) /** * The different roadtypes we support, but then a bitmask of them. - * @note Must be treated as a uint64 type, narrowing it causes bit membership tests to give wrong results. + * @note Must be treated as a uint64_t type, narrowing it causes bit membership tests to give wrong results. */ -enum RoadTypes : uint64 { +enum RoadTypes : uint64_t { ROADTYPES_NONE = 0, ///< No roadtypes ROADTYPES_ROAD = 1 << ROADTYPE_ROAD, ///< Road ROADTYPES_TRAM = 1 << ROADTYPE_TRAM, ///< Trams diff --git a/src/roadveh.h b/src/roadveh.h index 4881bb6b20..d721170629 100644 --- a/src/roadveh.h +++ b/src/roadveh.h @@ -107,10 +107,10 @@ struct RoadVehicle FINAL : public GroundVehicle { RoadVehPathCache path; ///< Cached path. byte state; ///< @see RoadVehicleStates byte frame; - uint16 blocked_ctr; + uint16_t blocked_ctr; byte overtaking; ///< Set to #RVSB_DRIVE_SIDE when overtaking, otherwise 0. byte overtaking_ctr; ///< The length of the current overtake attempt. - uint16 crashed_ctr; ///< Animation counter when the vehicle has crashed. @see RoadVehIsCrashed + uint16_t crashed_ctr; ///< Animation counter when the vehicle has crashed. @see RoadVehIsCrashed byte reverse_ctr; RoadType roadtype; //!< Roadtype of this vehicle. @@ -152,7 +152,7 @@ protected: // These functions should not be called outside acceleration code. * Allows to know the power value that this vehicle will use. * @return Power value from the engine in HP, or zero if the vehicle is not powered. */ - inline uint16 GetPower() const + inline uint16_t GetPower() const { /* Power is not added for articulated parts */ if (!this->IsArticulatedPart()) { @@ -166,7 +166,7 @@ protected: // These functions should not be called outside acceleration code. * Returns a value if this articulated part is powered. * @return Zero, because road vehicles don't have powered parts. */ - inline uint16 GetPoweredPartPower(const RoadVehicle *head) const + inline uint16_t GetPoweredPartPower(const RoadVehicle *head) const { return 0; } @@ -175,9 +175,9 @@ protected: // These functions should not be called outside acceleration code. * Allows to know the weight value that this vehicle will use. * @return Weight value from the engine in tonnes. */ - inline uint16 GetWeight() const + inline uint16_t GetWeight() const { - uint16 weight = CargoSpec::Get(this->cargo_type)->WeightOfNUnits(this->cargo.StoredCount()); + uint16_t weight = CargoSpec::Get(this->cargo_type)->WeightOfNUnits(this->cargo.StoredCount()); /* Vehicle weight is not added for articulated parts. */ if (!this->IsArticulatedPart()) { @@ -192,7 +192,7 @@ protected: // These functions should not be called outside acceleration code. * Calculates the weight value that this vehicle will have when fully loaded with its current cargo. * @return Weight value in tonnes. */ - uint16 GetMaxWeight() const override; + uint16_t GetMaxWeight() const override; /** * Allows to know the tractive effort value that this vehicle will use. @@ -235,7 +235,7 @@ protected: // These functions should not be called outside acceleration code. * Calculates the current speed of this vehicle. * @return Current speed in km/h-ish. */ - inline uint16 GetCurrentSpeed() const + inline uint16_t GetCurrentSpeed() const { return this->cur_speed / 2; } @@ -244,11 +244,11 @@ protected: // These functions should not be called outside acceleration code. * Returns the rolling friction coefficient of this vehicle. * @return Rolling friction coefficient in [1e-4]. */ - inline uint32 GetRollingFriction() const + inline uint32_t GetRollingFriction() const { /* Trams have a slightly greater friction coefficient than trains. * The rest of road vehicles have bigger values. */ - uint32 coeff = RoadTypeIsTram(this->roadtype) ? 40 : 75; + uint32_t coeff = RoadTypeIsTram(this->roadtype) ? 40 : 75; /* The friction coefficient increases with speed in a way that * it doubles at 128 km/h, triples at 256 km/h and so on. */ return coeff * (128 + this->GetCurrentSpeed()) / 128; @@ -267,7 +267,7 @@ protected: // These functions should not be called outside acceleration code. * Returns the slope steepness used by this vehicle. * @return Slope steepness used by the vehicle. */ - inline uint32 GetSlopeSteepness() const + inline uint32_t GetSlopeSteepness() const { return _settings_game.vehicle.roadveh_slope_steepness; } @@ -276,7 +276,7 @@ protected: // These functions should not be called outside acceleration code. * Gets the maximum speed allowed by the track for this vehicle. * @return Since roads don't limit road vehicle speed, it returns always zero. */ - inline uint16 GetMaxTrackSpeed() const + inline uint16_t GetMaxTrackSpeed() const { return GetRoadTypeInfo(GetRoadType(this->tile, GetRoadTramType(this->roadtype)))->max_speed; } diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index af796f5330..d022e233fe 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -42,7 +42,7 @@ #include "safeguards.h" -static const uint16 _roadveh_images[] = { +static const uint16_t _roadveh_images[] = { 0xCD4, 0xCDC, 0xCE4, 0xCEC, 0xCF4, 0xCFC, 0xD0C, 0xD14, 0xD24, 0xD1C, 0xD2C, 0xD04, 0xD1C, 0xD24, 0xD6C, 0xD74, 0xD7C, 0xC14, 0xC1C, 0xC24, 0xC2C, 0xC34, 0xC3C, 0xC4C, @@ -53,7 +53,7 @@ static const uint16 _roadveh_images[] = { 0xC5C, 0xC64, 0xC6C, 0xC74, 0xC84, 0xC94, 0xCA4 }; -static const uint16 _roadveh_full_adder[] = { +static const uint16_t _roadveh_full_adder[] = { 0, 88, 0, 0, 0, 0, 48, 48, 48, 48, 0, 0, 64, 64, 0, 16, 16, 0, 88, 0, 0, 0, 0, 48, @@ -66,7 +66,7 @@ static const uint16 _roadveh_full_adder[] = { static_assert(lengthof(_roadveh_images) == lengthof(_roadveh_full_adder)); template <> -bool IsValidImageIndex(uint8 image_index) +bool IsValidImageIndex(uint8_t image_index) { return image_index < lengthof(_roadveh_images); } @@ -104,7 +104,7 @@ int RoadVehicle::GetDisplayImageWidth(Point *offset) const static void GetRoadVehIcon(EngineID engine, EngineImageType image_type, VehicleSpriteSeq *result) { const Engine *e = Engine::Get(engine); - uint8 spritenum = e->u.road.image_index; + uint8_t spritenum = e->u.road.image_index; if (is_custom_sprite(spritenum)) { GetCustomVehicleIcon(engine, DIR_W, image_type, result); @@ -119,7 +119,7 @@ static void GetRoadVehIcon(EngineID engine, EngineImageType image_type, VehicleS void RoadVehicle::GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const { - uint8 spritenum = this->spritenum; + uint8_t spritenum = this->spritenum; if (is_custom_sprite(spritenum)) { GetCustomVehicleSprite(this, (Direction)(direction + 4 * IS_CUSTOM_SECONDHEAD_SPRITE(spritenum)), image_type, result); @@ -192,7 +192,7 @@ static uint GetRoadVehLength(const RoadVehicle *v) const Engine *e = v->GetEngine(); uint length = VEHICLE_LENGTH; - uint16 veh_len = CALLBACK_FAILED; + uint16_t veh_len = CALLBACK_FAILED; if (e->GetGRF() != nullptr && e->GetGRF()->grf_version >= 8) { /* Use callback 36 */ veh_len = GetVehicleProperty(v, PROP_ROADVEH_SHORTEN_FACTOR, CALLBACK_FAILED); @@ -402,7 +402,7 @@ void RoadVehicle::MarkDirty() void RoadVehicle::UpdateDeltaXY() { - static const int8 _delta_xy_table[8][10] = { + static const int8_t _delta_xy_table[8][10] = { /* y_extent, x_extent, y_offs, x_offs, y_bb_offs, x_bb_offs, y_extent_shorten, x_extent_shorten, y_bb_offs_shorten, x_bb_offs_shorten */ {3, 3, -1, -1, 0, 0, -1, -1, -1, -1}, // N {3, 7, -1, -3, 0, -1, 0, -1, 0, 0}, // NE @@ -417,7 +417,7 @@ void RoadVehicle::UpdateDeltaXY() int shorten = VEHICLE_LENGTH - this->gcache.cached_veh_length; if (!IsDiagonalDirection(this->direction)) shorten >>= 1; - const int8 *bb = _delta_xy_table[this->direction]; + const int8_t *bb = _delta_xy_table[this->direction]; this->x_bb_offs = bb[5] + bb[9] * shorten; this->y_bb_offs = bb[4] + bb[8] * shorten;; this->x_offs = bb[3]; @@ -480,7 +480,7 @@ static void RoadVehSetRandomDirection(RoadVehicle *v) }; do { - uint32 r = Random(); + uint32_t r = Random(); v->direction = ChangeDir(v->direction, delta[r & 3]); v->UpdateViewport(true, true); @@ -614,8 +614,8 @@ struct RoadVehFindData { static Vehicle *EnumCheckRoadVehClose(Vehicle *v, void *data) { - static const int8 dist_x[] = { -4, -8, -4, -1, 4, 8, 4, 1 }; - static const int8 dist_y[] = { -4, -1, 4, 8, 4, 1, -4, -8 }; + static const int8_t dist_x[] = { -4, -8, -4, -1, 4, 8, 4, 1 }; + static const int8_t dist_y[] = { -4, -1, 4, 8, 4, 1, -4, -8 }; RoadVehFindData *rvf = (RoadVehFindData*)data; @@ -853,7 +853,7 @@ static void RoadZPosAffectSpeed(RoadVehicle *v, int old_z) if (old_z < v->z_pos) { v->cur_speed = v->cur_speed * 232 / 256; // slow down by ~10% } else { - uint16 spd = v->cur_speed + 2; + uint16_t spd = v->cur_speed + 2; if (spd <= v->gcache.cached_max_track_speed) v->cur_speed = spd; } } @@ -1288,7 +1288,7 @@ again: } } - uint32 r = VehicleEnterTile(v, tile, x, y); + uint32_t r = VehicleEnterTile(v, tile, x, y); if (HasBit(r, VETS_CANNOT_ENTER)) { if (!IsTileType(tile, MP_TUNNELBRIDGE)) { v->cur_speed = 0; @@ -1404,7 +1404,7 @@ again: } } - uint32 r = VehicleEnterTile(v, v->tile, x, y); + uint32_t r = VehicleEnterTile(v, v->tile, x, y); if (HasBit(r, VETS_CANNOT_ENTER)) { v->cur_speed = 0; return false; @@ -1542,7 +1542,7 @@ again: /* Check tile position conditions - i.e. stop position in depot, * entry onto bridge or into tunnel */ - uint32 r = VehicleEnterTile(v, v->tile, x, y); + uint32_t r = VehicleEnterTile(v, v->tile, x, y); if (HasBit(r, VETS_CANNOT_ENTER)) { v->cur_speed = 0; return false; @@ -1752,9 +1752,9 @@ Trackdir RoadVehicle::GetVehicleTrackdir() const return (Trackdir)((IsReversingRoadTrackdir((Trackdir)this->state)) ? (this->state - 6) : this->state); } -uint16 RoadVehicle::GetMaxWeight() const +uint16_t RoadVehicle::GetMaxWeight() const { - uint16 weight = CargoSpec::Get(this->cargo_type)->WeightOfNUnits(this->GetEngine()->DetermineCapacity(this)); + uint16_t weight = CargoSpec::Get(this->cargo_type)->WeightOfNUnits(this->GetEngine()->DetermineCapacity(this)); /* Vehicle weight is not added for articulated parts. */ if (!this->IsArticulatedPart()) { diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index af5ab095a4..8d784533db 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -2271,7 +2271,7 @@ bool AfterLoadGame() * So taking the 16 bit fractional part into account there are plenty of bits left * for unmodified savegames ... */ - uint64 aimed_inflation = (_economy.old_max_loan_unround << 16 | _economy.old_max_loan_unround_fract) / _settings_game.difficulty.max_loan; + uint64_t aimed_inflation = (_economy.old_max_loan_unround << 16 | _economy.old_max_loan_unround_fract) / _settings_game.difficulty.max_loan; /* ... well, just clamp it then. */ if (aimed_inflation > MAX_INFLATION) aimed_inflation = MAX_INFLATION; @@ -2708,7 +2708,7 @@ bool AfterLoadGame() _settings_game.pf.reverse_at_signals = IsSavegameVersionBefore(SLV_100) || (_settings_game.pf.wait_oneway_signal != 255 && _settings_game.pf.wait_twoway_signal != 255 && _settings_game.pf.wait_for_pbs_path != 255); for (Train *t : Train::Iterate()) { - _settings_game.vehicle.max_train_length = std::max(_settings_game.vehicle.max_train_length, CeilDiv(t->gcache.cached_total_length, TILE_SIZE)); + _settings_game.vehicle.max_train_length = std::max(_settings_game.vehicle.max_train_length, CeilDiv(t->gcache.cached_total_length, TILE_SIZE)); } } @@ -2851,7 +2851,7 @@ bool AfterLoadGame() } if (IsSavegameVersionBefore(SLV_178)) { - extern uint8 _old_diff_level; + extern uint8_t _old_diff_level; /* Initialise script settings profile */ _settings_game.script.settings_profile = IsInsideMM(_old_diff_level, SP_BEGIN, SP_END) ? _old_diff_level : (uint)SP_MEDIUM; } @@ -2876,7 +2876,7 @@ bool AfterLoadGame() if (IsSavegameVersionBefore(SLV_184)) { /* The global units configuration is split up in multiple configurations. */ - extern uint8 _old_units; + extern uint8_t _old_units; _settings_game.locale.units_velocity = Clamp(_old_units, 0, 2); _settings_game.locale.units_power = Clamp(_old_units, 0, 2); _settings_game.locale.units_weight = Clamp(_old_units, 1, 2); @@ -3134,7 +3134,7 @@ bool AfterLoadGame() if (IsSavegameVersionBefore(SLV_GROUP_REPLACE_WAGON_REMOVAL)) { /* Propagate wagon removal flag for compatibility */ /* Temporary bitmask of company wagon removal setting */ - uint16 wagon_removal = 0; + uint16_t wagon_removal = 0; for (const Company *c : Company::Iterate()) { if (c->settings.renew_keep_length) SetBit(wagon_removal, c->index); } @@ -3151,7 +3151,7 @@ bool AfterLoadGame() /* Use current order time to approximate last loading time */ if (IsSavegameVersionBefore(SLV_LAST_LOADING_TICK)) { for (Vehicle *v : Vehicle::Iterate()) { - v->last_loading_tick = std::max(TimerGameTick::counter, static_cast(v->current_order_time)) - v->current_order_time; + v->last_loading_tick = std::max(TimerGameTick::counter, static_cast(v->current_order_time)) - v->current_order_time; } } diff --git a/src/saveload/cargomonitor_sl.cpp b/src/saveload/cargomonitor_sl.cpp index 80b32f16b6..61f6e0eec4 100644 --- a/src/saveload/cargomonitor_sl.cpp +++ b/src/saveload/cargomonitor_sl.cpp @@ -19,7 +19,7 @@ /** Temporary storage of cargo monitoring data for loading or saving it. */ struct TempStorage { CargoMonitorID number; - uint32 amount; + uint32_t amount; }; /** Description of the #TempStorage structure for the purpose of load and save. */ @@ -81,7 +81,7 @@ struct CMDLChunkHandler : ChunkHandler { if (fix) storage.number = FixupCargoMonitor(storage.number); - std::pair p(storage.number, storage.amount); + std::pair p(storage.number, storage.amount); _cargo_deliveries.insert(p); } } @@ -125,7 +125,7 @@ struct CMPUChunkHandler : ChunkHandler { if (fix) storage.number = FixupCargoMonitor(storage.number); - std::pair p(storage.number, storage.amount); + std::pair p(storage.number, storage.amount); _cargo_pickups.insert(p); } } diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp index 0a474ae839..9f65198f9e 100644 --- a/src/saveload/company_sl.cpp +++ b/src/saveload/company_sl.cpp @@ -42,7 +42,7 @@ * @param face the face in the old format * @return the face in the new format */ -CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32 face) +CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32_t face) { CompanyManagerFace cmf = 0; GenderEthnicity ge = GE_WM; @@ -240,7 +240,7 @@ void AfterLoadCompanyStats() /* We do need to read this single value, as the bigger it gets, the more data is stored */ struct CompanyOldAI { - uint8 num_build_rec; + uint8_t num_build_rec; }; class SlCompanyOldAIBuildRec : public DefaultSaveLoadHandler { @@ -364,7 +364,7 @@ public: void Load(CompanyProperties *c) const override { if (!IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH)) { - c->num_valid_stat_ent = (uint8)SlGetStructListLength(UINT8_MAX); + c->num_valid_stat_ent = (uint8_t)SlGetStructListLength(UINT8_MAX); } if (c->num_valid_stat_ent > lengthof(c->old_economy)) SlErrorCorrupt("Too many old economy entries"); diff --git a/src/saveload/economy_sl.cpp b/src/saveload/economy_sl.cpp index 4625e831a0..fcccebbcf2 100644 --- a/src/saveload/economy_sl.cpp +++ b/src/saveload/economy_sl.cpp @@ -23,7 +23,7 @@ struct PRICChunkHandler : ChunkHandler { void Load() const override { - /* Old games store 49 base prices, very old games store them as int32 */ + /* Old games store 49 base prices, very old games store them as int32_t */ int vt = IsSavegameVersionBefore(SLV_65) ? SLE_FILE_I32 : SLE_FILE_I64; SlCopy(nullptr, 49, vt | SLE_VAR_NULL); SlCopy(nullptr, 49, SLE_FILE_U16 | SLE_VAR_NULL); diff --git a/src/saveload/engine_sl.cpp b/src/saveload/engine_sl.cpp index f5efe9f753..b8ecc89449 100644 --- a/src/saveload/engine_sl.cpp +++ b/src/saveload/engine_sl.cpp @@ -50,7 +50,7 @@ static std::vector _temp_engine; */ static Engine* CallocEngine() { - uint8 *zero = CallocT(sizeof(Engine)); + uint8_t *zero = CallocT(sizeof(Engine)); Engine *engine = new (zero) Engine(); return engine; } diff --git a/src/saveload/game_sl.cpp b/src/saveload/game_sl.cpp index 1eb6539710..8aa4805576 100644 --- a/src/saveload/game_sl.cpp +++ b/src/saveload/game_sl.cpp @@ -119,7 +119,7 @@ struct GSDTChunkHandler : ChunkHandler { extern GameStrings *_current_data; static std::string _game_saveload_string; -static uint32 _game_saveload_strings; +static uint32_t _game_saveload_strings; class SlGameLanguageString : public DefaultSaveLoadHandler { public: @@ -140,9 +140,9 @@ public: void Load(LanguageStrings *ls) const override { - uint32 length = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? _game_saveload_strings : (uint32)SlGetStructListLength(UINT32_MAX); + uint32_t length = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? _game_saveload_strings : (uint32_t)SlGetStructListLength(UINT32_MAX); - for (uint32 i = 0; i < length; i++) { + for (uint32_t i = 0; i < length; i++) { SlObject(nullptr, this->GetLoadDescription()); ls->lines.emplace_back(_game_saveload_string); } diff --git a/src/saveload/labelmaps_sl.cpp b/src/saveload/labelmaps_sl.cpp index 1fcbc21a70..b2d05ddbb1 100644 --- a/src/saveload/labelmaps_sl.cpp +++ b/src/saveload/labelmaps_sl.cpp @@ -92,7 +92,7 @@ void ResetLabelMaps() /** Container for a label for SaveLoad system */ struct LabelObject { - uint32 label; + uint32_t label; }; static const SaveLoad _label_object_desc[] = { diff --git a/src/saveload/linkgraph_sl.cpp b/src/saveload/linkgraph_sl.cpp index 691de0dd5f..8811ef0338 100644 --- a/src/saveload/linkgraph_sl.cpp +++ b/src/saveload/linkgraph_sl.cpp @@ -24,7 +24,7 @@ typedef LinkGraph::BaseNode Node; typedef LinkGraph::BaseEdge Edge; -static uint16 _num_nodes; +static uint16_t _num_nodes; static LinkGraph *_linkgraph; ///< Contains the current linkgraph being saved/loaded. static NodeID _linkgraph_from; ///< Contains the current "from" node being saved/loaded. @@ -52,7 +52,7 @@ public: void Load(Node *bn) const override { if (IsSavegameVersionBefore(SLV_LINKGRAPH_EDGES)) { - uint16 max_size = _linkgraph->Size(); + uint16_t max_size = _linkgraph->Size(); std::vector edges(max_size); if (IsSavegameVersionBefore(SLV_191)) { @@ -120,7 +120,7 @@ public: { _linkgraph = lg; - uint16 length = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? _num_nodes : (uint16)SlGetStructListLength(UINT16_MAX); + uint16_t length = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? _num_nodes : (uint16_t)SlGetStructListLength(UINT16_MAX); lg->Init(length); for (NodeID from = 0; from < length; ++from) { _linkgraph_from = from; diff --git a/src/saveload/map_sl.cpp b/src/saveload/map_sl.cpp index fd0ccaea79..528bd359cb 100644 --- a/src/saveload/map_sl.cpp +++ b/src/saveload/map_sl.cpp @@ -18,8 +18,8 @@ #include "../safeguards.h" -static uint32 _map_dim_x; -static uint32 _map_dim_y; +static uint32_t _map_dim_x; +static uint32_t _map_dim_y; static const SaveLoad _map_desc[] = { SLEG_CONDVAR("dim_x", _map_dim_x, SLE_UINT32, SLV_6, SL_MAX_VERSION), @@ -152,7 +152,7 @@ struct MAP2ChunkHandler : ChunkHandler { void Load() const override { - std::array buf; + std::array buf; TileIndex size = Map::Size(); for (TileIndex i = 0; i != size;) { @@ -166,10 +166,10 @@ struct MAP2ChunkHandler : ChunkHandler { void Save() const override { - std::array buf; + std::array buf; TileIndex size = Map::Size(); - SlSetLength(size * sizeof(uint16)); + SlSetLength(size * sizeof(uint16_t)); for (TileIndex i = 0; i != size;) { for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = Tile(i++).m2(); SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT16); @@ -330,7 +330,7 @@ struct MAP8ChunkHandler : ChunkHandler { void Load() const override { - std::array buf; + std::array buf; TileIndex size = Map::Size(); for (TileIndex i = 0; i != size;) { @@ -341,10 +341,10 @@ struct MAP8ChunkHandler : ChunkHandler { void Save() const override { - std::array buf; + std::array buf; TileIndex size = Map::Size(); - SlSetLength(size * sizeof(uint16)); + SlSetLength(size * sizeof(uint16_t)); for (TileIndex i = 0; i != size;) { for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = Tile(i++).m8(); SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT16); diff --git a/src/saveload/misc_sl.cpp b/src/saveload/misc_sl.cpp index 1a147c25ff..f9d9e4188d 100644 --- a/src/saveload/misc_sl.cpp +++ b/src/saveload/misc_sl.cpp @@ -27,7 +27,7 @@ #include "../safeguards.h" extern TileIndex _cur_tileloop_tile; -extern uint16 _disaster_delay; +extern uint16_t _disaster_delay; extern byte _trees_tick_ctr; extern std::string _savegame_id; diff --git a/src/saveload/newgrf_sl.h b/src/saveload/newgrf_sl.h index c266d90b17..ee6fe98ad3 100644 --- a/src/saveload/newgrf_sl.h +++ b/src/saveload/newgrf_sl.h @@ -15,7 +15,7 @@ struct NewGRFMappingChunkHandler : ChunkHandler { OverrideManagerBase &mapping; - NewGRFMappingChunkHandler(uint32 id, OverrideManagerBase &mapping) : ChunkHandler(id, CH_TABLE), mapping(mapping) {} + NewGRFMappingChunkHandler(uint32_t id, OverrideManagerBase &mapping) : ChunkHandler(id, CH_TABLE), mapping(mapping) {} void Save() const override; void Load() const override; }; diff --git a/src/saveload/oldloader.cpp b/src/saveload/oldloader.cpp index a8d8879846..76e6b4a119 100644 --- a/src/saveload/oldloader.cpp +++ b/src/saveload/oldloader.cpp @@ -27,7 +27,7 @@ static const int TTD_HEADER_SIZE = 49; /** The size of the checksum in the name/header of the TTD/TTO savegames. */ static const int HEADER_CHECKSUM_SIZE = 2; -uint32 _bump_assert_value; +uint32_t _bump_assert_value; static inline OldChunkType GetOldChunkType(OldChunkType type) {return (OldChunkType)GB(type, 0, 4);} static inline OldChunkType GetOldChunkVarType(OldChunkType type) {return (OldChunkType)(GB(type, 8, 8) << 8);} @@ -83,7 +83,7 @@ byte ReadByte(LoadgameState *ls) if (ls->chunk_size == 0) { /* Read new chunk */ - int8 new_byte = ReadByteFromFile(ls); + int8_t new_byte = ReadByteFromFile(ls); if (new_byte < 0) { /* Repeat next char for new_byte times */ @@ -138,15 +138,15 @@ bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks) default: break; } } else { - uint64 res = 0; + uint64_t res = 0; /* Reading from the file: bits 16 to 23 have the FILE type */ switch (GetOldChunkFileType(chunk->type)) { - case OC_FILE_I8: res = (int8)ReadByte(ls); break; + case OC_FILE_I8: res = (int8_t)ReadByte(ls); break; case OC_FILE_U8: res = ReadByte(ls); break; - case OC_FILE_I16: res = (int16)ReadUint16(ls); break; + case OC_FILE_I16: res = (int16_t)ReadUint16(ls); break; case OC_FILE_U16: res = ReadUint16(ls); break; - case OC_FILE_I32: res = (int32)ReadUint32(ls); break; + case OC_FILE_I32: res = (int32_t)ReadUint32(ls); break; case OC_FILE_U32: res = ReadUint32(ls); break; default: NOT_REACHED(); } @@ -159,14 +159,14 @@ bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks) /* Write the data */ switch (GetOldChunkVarType(chunk->type)) { - case OC_VAR_I8: *(int8 *)ptr = GB(res, 0, 8); break; - case OC_VAR_U8: *(uint8 *)ptr = GB(res, 0, 8); break; - case OC_VAR_I16:*(int16 *)ptr = GB(res, 0, 16); break; - case OC_VAR_U16:*(uint16*)ptr = GB(res, 0, 16); break; - case OC_VAR_I32:*(int32 *)ptr = res; break; - case OC_VAR_U32:*(uint32*)ptr = res; break; - case OC_VAR_I64:*(int64 *)ptr = res; break; - case OC_VAR_U64:*(uint64*)ptr = res; break; + case OC_VAR_I8: *(int8_t *)ptr = GB(res, 0, 8); break; + case OC_VAR_U8: *(uint8_t *)ptr = GB(res, 0, 8); break; + case OC_VAR_I16:*(int16_t *)ptr = GB(res, 0, 16); break; + case OC_VAR_U16:*(uint16_t*)ptr = GB(res, 0, 16); break; + case OC_VAR_I32:*(int32_t *)ptr = res; break; + case OC_VAR_U32:*(uint32_t*)ptr = res; break; + case OC_VAR_I64:*(int64_t *)ptr = res; break; + case OC_VAR_U64:*(uint64_t*)ptr = res; break; default: NOT_REACHED(); } @@ -209,7 +209,7 @@ static void InitLoading(LoadgameState *ls) */ static bool VerifyOldNameChecksum(char *title, uint len) { - uint16 sum = 0; + uint16_t sum = 0; for (uint i = 0; i < len - HEADER_CHECKSUM_SIZE; i++) { sum += title[i]; sum = ROL(sum, 1); @@ -217,7 +217,7 @@ static bool VerifyOldNameChecksum(char *title, uint len) sum ^= 0xAAAA; // computed checksum - uint16 sum2 = title[len - HEADER_CHECKSUM_SIZE]; // checksum in file + uint16_t sum2 = title[len - HEADER_CHECKSUM_SIZE]; // checksum in file SB(sum2, 8, 8, title[len - HEADER_CHECKSUM_SIZE + 1]); return sum == sum2; diff --git a/src/saveload/oldloader.h b/src/saveload/oldloader.h index 6879192ecd..d4a2d3d260 100644 --- a/src/saveload/oldloader.h +++ b/src/saveload/oldloader.h @@ -86,7 +86,7 @@ typedef void *OffsetProc(void *base); struct OldChunks { OldChunkType type; ///< Type of field - uint32 amount; ///< Amount of fields + uint32_t amount; ///< Amount of fields void *ptr; ///< Pointer where to save the data (takes precedence over #offset) OffsetProc *offset; ///< Pointer to function that returns the actual memory address of a member (ignored if #ptr is not nullptr) @@ -103,15 +103,15 @@ bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks); bool LoadTTDMain(LoadgameState *ls); bool LoadTTOMain(LoadgameState *ls); -static inline uint16 ReadUint16(LoadgameState *ls) +static inline uint16_t ReadUint16(LoadgameState *ls) { byte x = ReadByte(ls); return x | ReadByte(ls) << 8; } -static inline uint32 ReadUint32(LoadgameState *ls) +static inline uint32_t ReadUint32(LoadgameState *ls) { - uint16 x = ReadUint16(ls); + uint16_t x = ReadUint16(ls); return x | ReadUint16(ls) << 16; } diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp index 5cc434372c..db847cded7 100644 --- a/src/saveload/oldloader_sl.cpp +++ b/src/saveload/oldloader_sl.cpp @@ -40,10 +40,10 @@ #include "../safeguards.h" static bool _read_ttdpatch_flags; ///< Have we (tried to) read TTDPatch extra flags? -static uint16 _old_extra_chunk_nums; ///< Number of extra TTDPatch chunks +static uint16_t _old_extra_chunk_nums; ///< Number of extra TTDPatch chunks static byte _old_vehicle_multiplier; ///< TTDPatch vehicle multiplier -static uint8 *_old_map3; +static uint8_t *_old_map3; void FixOldMapArray() { @@ -121,7 +121,7 @@ static void FixTTDDepots() #define FIXNUM(x, y, z) (((((x) << 16) / (y)) + 1) << z) -static uint32 RemapOldTownName(uint32 townnameparts, byte old_town_name_type) +static uint32_t RemapOldTownName(uint32_t townnameparts, byte old_town_name_type) { switch (old_town_name_type) { case 0: case 3: // English, American @@ -494,9 +494,9 @@ extern std::vector _animated_tiles; extern TimeoutTimer _new_competitor_timeout; extern char *_old_name_array; -static uint32 _old_town_index; -static uint16 _old_string_id; -static uint16 _old_string_id_2; +static uint32_t _old_town_index; +static uint16_t _old_string_id; +static uint16_t _old_string_id_2; static void ReadTTDPatchFlags() { @@ -613,7 +613,7 @@ static bool LoadOldTown(LoadgameState *ls, int num) return true; } -static uint16 _old_order; +static uint16_t _old_order; static const OldChunks order_chunk[] = { OCL_VAR ( OC_UINT16, 1, &_old_order ), OCL_END() @@ -681,9 +681,9 @@ static bool LoadOldDepot(LoadgameState *ls, int num) } static StationID _current_station_id; -static uint16 _waiting_acceptance; -static uint8 _cargo_source; -static uint8 _cargo_periods; +static uint16_t _waiting_acceptance; +static uint8_t _cargo_source; +static uint8_t _cargo_periods; static const OldChunks goods_chunk[] = { OCL_VAR ( OC_UINT16, 1, &_waiting_acceptance ), @@ -860,7 +860,7 @@ static bool LoadOldIndustry(LoadgameState *ls, int num) } static CompanyID _current_company_id; -static int32 _old_yearly; +static int32_t _old_yearly; static const OldChunks _company_yearly_chunk[] = { OCL_VAR( OC_INT32, 1, &_old_yearly ), @@ -1025,8 +1025,8 @@ static bool LoadOldCompany(LoadgameState *ls, int num) return true; } -static uint32 _old_order_ptr; -static uint16 _old_next_ptr; +static uint32_t _old_order_ptr; +static uint16_t _old_next_ptr; static VehicleID _current_vehicle_id; static const OldChunks vehicle_train_chunk[] = { @@ -1126,7 +1126,7 @@ static bool LoadOldVehicleUnion(LoadgameState *ls, int num) return res; } -static uint16 _cargo_count; +static uint16_t _cargo_count; static const OldChunks vehicle_chunk[] = { OCL_SVAR( OC_UINT8, Vehicle, subtype ), @@ -1523,8 +1523,8 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int num) Debug(oldloader, 2, "Found {} extra chunk(s)", _old_extra_chunk_nums); for (int i = 0; i != _old_extra_chunk_nums; i++) { - uint16 id = ReadUint16(ls); - uint32 len = ReadUint32(ls); + uint16_t id = ReadUint16(ls); + uint32_t len = ReadUint32(ls); switch (id) { /* List of GRFIDs, used in the savegame. 0x8004 is the new ID @@ -1536,7 +1536,7 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int num) ClearGRFConfigList(&_grfconfig); while (len != 0) { - uint32 grfid = ReadUint32(ls); + uint32_t grfid = ReadUint32(ls); if (ReadByte(ls) == 1) { GRFConfig *c = new GRFConfig("TTDP game, no information"); @@ -1573,11 +1573,11 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int num) } extern TileIndex _cur_tileloop_tile; -extern uint16 _disaster_delay; +extern uint16_t _disaster_delay; extern byte _trees_tick_ctr; extern byte _age_cargo_skip_counter; // From misc_sl.cpp -extern uint8 _old_diff_level; -extern uint8 _old_units; +extern uint8_t _old_diff_level; +extern uint8_t _old_units; static const OldChunks main_chunk[] = { OCL_ASSERT( OC_TTD, 0 ), OCL_ASSERT( OC_TTO, 0 ), diff --git a/src/saveload/order_sl.cpp b/src/saveload/order_sl.cpp index e94026dfc9..57f0136e26 100644 --- a/src/saveload/order_sl.cpp +++ b/src/saveload/order_sl.cpp @@ -25,7 +25,7 @@ */ void Order::ConvertFromOldSavegame() { - uint8 old_flags = this->flags; + uint8_t old_flags = this->flags; this->flags = 0; /* First handle non-stop - use value from savegame if possible, else use value from config file */ @@ -79,7 +79,7 @@ void Order::ConvertFromOldSavegame() * @param packed packed order * @return unpacked order */ -static Order UnpackVersion4Order(uint16 packed) +static Order UnpackVersion4Order(uint16_t packed) { return Order(GB(packed, 8, 8) << 16 | GB(packed, 4, 4) << 8 | GB(packed, 0, 4)); } @@ -89,7 +89,7 @@ static Order UnpackVersion4Order(uint16 packed) * @param packed packed order * @return unpacked order */ -Order UnpackOldOrder(uint16 packed) +Order UnpackOldOrder(uint16_t packed) { Order order = UnpackVersion4Order(packed); @@ -141,9 +141,9 @@ struct ORDRChunkHandler : ChunkHandler { if (IsSavegameVersionBefore(SLV_5)) { /* Pre-version 5 had another layout for orders - * (uint16 instead of uint32) */ - len /= sizeof(uint16); - std::vector orders(len); + * (uint16_t instead of uint32_t) */ + len /= sizeof(uint16_t); + std::vector orders(len); SlCopy(&orders[0], len, SLE_UINT16); @@ -152,8 +152,8 @@ struct ORDRChunkHandler : ChunkHandler { o->AssignOrder(UnpackVersion4Order(orders[i])); } } else if (IsSavegameVersionBefore(SLV_5, 2)) { - len /= sizeof(uint32); - std::vector orders(len); + len /= sizeof(uint32_t); + std::vector orders(len); SlCopy(&orders[0], len, SLE_UINT32); diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 728ffafaa8..cb2fccc065 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -59,7 +59,7 @@ extern const SaveLoadVersion SAVEGAME_VERSION = (SaveLoadVersion)(SL_MAX_VERSION SavegameType _savegame_type; ///< type of savegame we are loading FileToSaveLoad _file_to_saveload; ///< File to save or load in the openttd loop. -uint32 _ttdp_version; ///< version of TTDP savegame (if applicable) +uint32_t _ttdp_version; ///< version of TTDP savegame (if applicable) SaveLoadVersion _sl_version; ///< the major savegame version identifier byte _sl_minor_version; ///< the minor savegame version, DO NOT USE! std::string _savegame_format; ///< how to compress savegames @@ -418,35 +418,35 @@ static inline int SlReadUint16() return x | SlReadByte(); } -static inline uint32 SlReadUint32() +static inline uint32_t SlReadUint32() { - uint32 x = SlReadUint16() << 16; + uint32_t x = SlReadUint16() << 16; return x | SlReadUint16(); } -static inline uint64 SlReadUint64() +static inline uint64_t SlReadUint64() { - uint32 x = SlReadUint32(); - uint32 y = SlReadUint32(); - return (uint64)x << 32 | y; + uint32_t x = SlReadUint32(); + uint32_t y = SlReadUint32(); + return (uint64_t)x << 32 | y; } -static inline void SlWriteUint16(uint16 v) +static inline void SlWriteUint16(uint16_t v) { SlWriteByte(GB(v, 8, 8)); SlWriteByte(GB(v, 0, 8)); } -static inline void SlWriteUint32(uint32 v) +static inline void SlWriteUint32(uint32_t v) { SlWriteUint16(GB(v, 16, 16)); SlWriteUint16(GB(v, 0, 16)); } -static inline void SlWriteUint64(uint64 x) +static inline void SlWriteUint64(uint64_t x) { - SlWriteUint32((uint32)(x >> 32)); - SlWriteUint32((uint32)x); + SlWriteUint32((uint32_t)(x >> 32)); + SlWriteUint32((uint32_t)x); } /** @@ -558,7 +558,7 @@ static inline uint SlGetArrayLength(size_t length) /** * Return the type as saved/loaded inside the savegame. */ -static uint8 GetSavegameFileType(const SaveLoad &sld) +static uint8_t GetSavegameFileType(const SaveLoad &sld) { switch (sld.cmd) { case SL_VAR: @@ -603,7 +603,7 @@ static inline uint SlCalcConvMemLen(VarType conv) return SlReadArrayLength(); default: - uint8 type = GetVarMemType(conv) >> 4; + uint8_t type = GetVarMemType(conv) >> 4; assert(type < lengthof(conv_mem_size)); return conv_mem_size[type]; } @@ -619,7 +619,7 @@ static inline byte SlCalcConvFileLen(VarType conv) { static const byte conv_file_size[] = {0, 1, 1, 2, 2, 4, 4, 8, 8, 2}; - uint8 type = GetVarFileType(conv); + uint8_t type = GetVarFileType(conv); assert(type < lengthof(conv_file_size)); return conv_file_size[type]; } @@ -715,7 +715,7 @@ void SlSetLength(size_t length) * The lower 24 bits are normal * The uppermost 4 bits are bits 24:27 */ assert(length < (1 << 28)); - SlWriteUint32((uint32)((length & 0xFFFFFF) | ((length >> 24) << 28))); + SlWriteUint32((uint32_t)((length & 0xFFFFFF) | ((length >> 24) << 28))); break; case CH_TABLE: case CH_ARRAY: @@ -777,18 +777,18 @@ size_t SlGetFieldLength() * type, eg one with other flags because it is parsed * @return returns the value of the pointer-setting */ -int64 ReadValue(const void *ptr, VarType conv) +int64_t ReadValue(const void *ptr, VarType conv) { switch (GetVarMemType(conv)) { case SLE_VAR_BL: return (*(const bool *)ptr != 0); - case SLE_VAR_I8: return *(const int8 *)ptr; + case SLE_VAR_I8: return *(const int8_t *)ptr; case SLE_VAR_U8: return *(const byte *)ptr; - case SLE_VAR_I16: return *(const int16 *)ptr; - case SLE_VAR_U16: return *(const uint16*)ptr; - case SLE_VAR_I32: return *(const int32 *)ptr; - case SLE_VAR_U32: return *(const uint32*)ptr; - case SLE_VAR_I64: return *(const int64 *)ptr; - case SLE_VAR_U64: return *(const uint64*)ptr; + case SLE_VAR_I16: return *(const int16_t *)ptr; + case SLE_VAR_U16: return *(const uint16_t*)ptr; + case SLE_VAR_I32: return *(const int32_t *)ptr; + case SLE_VAR_U32: return *(const uint32_t*)ptr; + case SLE_VAR_I64: return *(const int64_t *)ptr; + case SLE_VAR_U64: return *(const uint64_t*)ptr; case SLE_VAR_NULL:return 0; default: NOT_REACHED(); } @@ -801,18 +801,18 @@ int64 ReadValue(const void *ptr, VarType conv) * with other flags. It is parsed upon read * @param val the new value being given to the variable */ -void WriteValue(void *ptr, VarType conv, int64 val) +void WriteValue(void *ptr, VarType conv, int64_t val) { switch (GetVarMemType(conv)) { case SLE_VAR_BL: *(bool *)ptr = (val != 0); break; - case SLE_VAR_I8: *(int8 *)ptr = val; break; + case SLE_VAR_I8: *(int8_t *)ptr = val; break; case SLE_VAR_U8: *(byte *)ptr = val; break; - case SLE_VAR_I16: *(int16 *)ptr = val; break; - case SLE_VAR_U16: *(uint16*)ptr = val; break; - case SLE_VAR_I32: *(int32 *)ptr = val; break; - case SLE_VAR_U32: *(uint32*)ptr = val; break; - case SLE_VAR_I64: *(int64 *)ptr = val; break; - case SLE_VAR_U64: *(uint64*)ptr = val; break; + case SLE_VAR_I16: *(int16_t *)ptr = val; break; + case SLE_VAR_U16: *(uint16_t*)ptr = val; break; + case SLE_VAR_I32: *(int32_t *)ptr = val; break; + case SLE_VAR_U32: *(uint32_t*)ptr = val; break; + case SLE_VAR_I64: *(int64_t *)ptr = val; break; + case SLE_VAR_U64: *(uint64_t*)ptr = val; break; case SLE_VAR_NAME: *reinterpret_cast(ptr) = CopyFromOldName(val); break; case SLE_VAR_NULL: break; default: NOT_REACHED(); @@ -831,7 +831,7 @@ static void SlSaveLoadConv(void *ptr, VarType conv) { switch (_sl.action) { case SLA_SAVE: { - int64 x = ReadValue(ptr, conv); + int64_t x = ReadValue(ptr, conv); /* Write the value to the file and check if its value is in the desired range */ switch (GetVarFileType(conv)) { @@ -841,7 +841,7 @@ static void SlSaveLoadConv(void *ptr, VarType conv) case SLE_FILE_STRINGID: case SLE_FILE_U16:assert(x >= 0 && x <= 65535); SlWriteUint16(x);break; case SLE_FILE_I32: - case SLE_FILE_U32: SlWriteUint32((uint32)x);break; + case SLE_FILE_U32: SlWriteUint32((uint32_t)x);break; case SLE_FILE_I64: case SLE_FILE_U64: SlWriteUint64(x);break; default: NOT_REACHED(); @@ -850,18 +850,18 @@ static void SlSaveLoadConv(void *ptr, VarType conv) } case SLA_LOAD_CHECK: case SLA_LOAD: { - int64 x; + int64_t x; /* Read a value from the file */ switch (GetVarFileType(conv)) { - case SLE_FILE_I8: x = (int8 )SlReadByte(); break; + case SLE_FILE_I8: x = (int8_t )SlReadByte(); break; case SLE_FILE_U8: x = (byte )SlReadByte(); break; - case SLE_FILE_I16: x = (int16 )SlReadUint16(); break; - case SLE_FILE_U16: x = (uint16)SlReadUint16(); break; - case SLE_FILE_I32: x = (int32 )SlReadUint32(); break; - case SLE_FILE_U32: x = (uint32)SlReadUint32(); break; - case SLE_FILE_I64: x = (int64 )SlReadUint64(); break; - case SLE_FILE_U64: x = (uint64)SlReadUint64(); break; - case SLE_FILE_STRINGID: x = RemapOldStringID((uint16)SlReadUint16()); break; + case SLE_FILE_I16: x = (int16_t )SlReadUint16(); break; + case SLE_FILE_U16: x = (uint16_t)SlReadUint16(); break; + case SLE_FILE_I32: x = (int32_t )SlReadUint32(); break; + case SLE_FILE_U32: x = (uint32_t)SlReadUint32(); break; + case SLE_FILE_I64: x = (int64_t )SlReadUint64(); break; + case SLE_FILE_U64: x = (uint64_t)SlReadUint64(); break; + case SLE_FILE_STRINGID: x = RemapOldStringID((uint16_t)SlReadUint16()); break; default: NOT_REACHED(); } @@ -904,7 +904,7 @@ static void FixSCCEncoded(std::string &str) size_t len = Utf8EncodedCharLen(str[i]); if (len == 0 || i + len > str.size()) break; - WChar c; + char32_t c; Utf8Decode(&c, &str[i]); if (c == 0xE028 || c == 0xE02A) Utf8Encode(&str[i], SCC_ENCODED); i += len; @@ -984,7 +984,7 @@ static void SlCopyInternal(void *object, size_t length, VarType conv) /* used for conversion of Money 32bit->64bit */ if (conv == (SLE_FILE_I32 | SLE_VAR_I64)) { for (uint i = 0; i < length; i++) { - ((int64*)object)[i] = (int32)BSWAP32(SlReadUint32()); + ((int64_t*)object)[i] = (int32_t)BSWAP32(SlReadUint32()); } return; } @@ -1041,7 +1041,7 @@ static inline size_t SlCalcArrayLen(size_t length, VarType conv) * Save/Load the length of the array followed by the array of SL_VAR elements. * @param array The array being manipulated * @param length The length of the array in elements - * @param conv VarType type of the atomic array (int, byte, uint64, etc.) + * @param conv VarType type of the atomic array (int, byte, uint64_t, etc.) */ static void SlArray(void *array, size_t length, VarType conv) { @@ -1202,7 +1202,7 @@ void SlSaveLoadRef(void *ptr, VarType conv) { switch (_sl.action) { case SLA_SAVE: - SlWriteUint32((uint32)ReferenceToInt(*(void **)ptr, (SLRefType)conv)); + SlWriteUint32((uint32_t)ReferenceToInt(*(void **)ptr, (SLRefType)conv)); break; case SLA_LOAD_CHECK: case SLA_LOAD: @@ -1341,14 +1341,14 @@ static inline size_t SlCalcDequeLen(const void *deque, VarType conv) { switch (GetVarMemType(conv)) { case SLE_VAR_BL: return SlStorageHelper::SlCalcLen(deque, conv); - case SLE_VAR_I8: return SlStorageHelper::SlCalcLen(deque, conv); - case SLE_VAR_U8: return SlStorageHelper::SlCalcLen(deque, conv); - case SLE_VAR_I16: return SlStorageHelper::SlCalcLen(deque, conv); - case SLE_VAR_U16: return SlStorageHelper::SlCalcLen(deque, conv); - case SLE_VAR_I32: return SlStorageHelper::SlCalcLen(deque, conv); - case SLE_VAR_U32: return SlStorageHelper::SlCalcLen(deque, conv); - case SLE_VAR_I64: return SlStorageHelper::SlCalcLen(deque, conv); - case SLE_VAR_U64: return SlStorageHelper::SlCalcLen(deque, conv); + case SLE_VAR_I8: return SlStorageHelper::SlCalcLen(deque, conv); + case SLE_VAR_U8: return SlStorageHelper::SlCalcLen(deque, conv); + case SLE_VAR_I16: return SlStorageHelper::SlCalcLen(deque, conv); + case SLE_VAR_U16: return SlStorageHelper::SlCalcLen(deque, conv); + case SLE_VAR_I32: return SlStorageHelper::SlCalcLen(deque, conv); + case SLE_VAR_U32: return SlStorageHelper::SlCalcLen(deque, conv); + case SLE_VAR_I64: return SlStorageHelper::SlCalcLen(deque, conv); + case SLE_VAR_U64: return SlStorageHelper::SlCalcLen(deque, conv); default: NOT_REACHED(); } } @@ -1362,14 +1362,14 @@ static void SlDeque(void *deque, VarType conv) { switch (GetVarMemType(conv)) { case SLE_VAR_BL: SlStorageHelper::SlSaveLoad(deque, conv); break; - case SLE_VAR_I8: SlStorageHelper::SlSaveLoad(deque, conv); break; - case SLE_VAR_U8: SlStorageHelper::SlSaveLoad(deque, conv); break; - case SLE_VAR_I16: SlStorageHelper::SlSaveLoad(deque, conv); break; - case SLE_VAR_U16: SlStorageHelper::SlSaveLoad(deque, conv); break; - case SLE_VAR_I32: SlStorageHelper::SlSaveLoad(deque, conv); break; - case SLE_VAR_U32: SlStorageHelper::SlSaveLoad(deque, conv); break; - case SLE_VAR_I64: SlStorageHelper::SlSaveLoad(deque, conv); break; - case SLE_VAR_U64: SlStorageHelper::SlSaveLoad(deque, conv); break; + case SLE_VAR_I8: SlStorageHelper::SlSaveLoad(deque, conv); break; + case SLE_VAR_U8: SlStorageHelper::SlSaveLoad(deque, conv); break; + case SLE_VAR_I16: SlStorageHelper::SlSaveLoad(deque, conv); break; + case SLE_VAR_U16: SlStorageHelper::SlSaveLoad(deque, conv); break; + case SLE_VAR_I32: SlStorageHelper::SlSaveLoad(deque, conv); break; + case SLE_VAR_U32: SlStorageHelper::SlSaveLoad(deque, conv); break; + case SLE_VAR_I64: SlStorageHelper::SlSaveLoad(deque, conv); break; + case SLE_VAR_U64: SlStorageHelper::SlSaveLoad(deque, conv); break; default: NOT_REACHED(); } } @@ -1383,14 +1383,14 @@ static inline size_t SlCalcVectorLen(const void *vector, VarType conv) { switch (GetVarMemType(conv)) { case SLE_VAR_BL: NOT_REACHED(); // Not supported - case SLE_VAR_I8: return SlStorageHelper::SlCalcLen(vector, conv); - case SLE_VAR_U8: return SlStorageHelper::SlCalcLen(vector, conv); - case SLE_VAR_I16: return SlStorageHelper::SlCalcLen(vector, conv); - case SLE_VAR_U16: return SlStorageHelper::SlCalcLen(vector, conv); - case SLE_VAR_I32: return SlStorageHelper::SlCalcLen(vector, conv); - case SLE_VAR_U32: return SlStorageHelper::SlCalcLen(vector, conv); - case SLE_VAR_I64: return SlStorageHelper::SlCalcLen(vector, conv); - case SLE_VAR_U64: return SlStorageHelper::SlCalcLen(vector, conv); + case SLE_VAR_I8: return SlStorageHelper::SlCalcLen(vector, conv); + case SLE_VAR_U8: return SlStorageHelper::SlCalcLen(vector, conv); + case SLE_VAR_I16: return SlStorageHelper::SlCalcLen(vector, conv); + case SLE_VAR_U16: return SlStorageHelper::SlCalcLen(vector, conv); + case SLE_VAR_I32: return SlStorageHelper::SlCalcLen(vector, conv); + case SLE_VAR_U32: return SlStorageHelper::SlCalcLen(vector, conv); + case SLE_VAR_I64: return SlStorageHelper::SlCalcLen(vector, conv); + case SLE_VAR_U64: return SlStorageHelper::SlCalcLen(vector, conv); default: NOT_REACHED(); } } @@ -1404,14 +1404,14 @@ static void SlVector(void *vector, VarType conv) { switch (GetVarMemType(conv)) { case SLE_VAR_BL: NOT_REACHED(); // Not supported - case SLE_VAR_I8: SlStorageHelper::SlSaveLoad(vector, conv); break; - case SLE_VAR_U8: SlStorageHelper::SlSaveLoad(vector, conv); break; - case SLE_VAR_I16: SlStorageHelper::SlSaveLoad(vector, conv); break; - case SLE_VAR_U16: SlStorageHelper::SlSaveLoad(vector, conv); break; - case SLE_VAR_I32: SlStorageHelper::SlSaveLoad(vector, conv); break; - case SLE_VAR_U32: SlStorageHelper::SlSaveLoad(vector, conv); break; - case SLE_VAR_I64: SlStorageHelper::SlSaveLoad(vector, conv); break; - case SLE_VAR_U64: SlStorageHelper::SlSaveLoad(vector, conv); break; + case SLE_VAR_I8: SlStorageHelper::SlSaveLoad(vector, conv); break; + case SLE_VAR_U8: SlStorageHelper::SlSaveLoad(vector, conv); break; + case SLE_VAR_I16: SlStorageHelper::SlSaveLoad(vector, conv); break; + case SLE_VAR_U16: SlStorageHelper::SlSaveLoad(vector, conv); break; + case SLE_VAR_I32: SlStorageHelper::SlSaveLoad(vector, conv); break; + case SLE_VAR_U32: SlStorageHelper::SlSaveLoad(vector, conv); break; + case SLE_VAR_I64: SlStorageHelper::SlSaveLoad(vector, conv); break; + case SLE_VAR_U64: SlStorageHelper::SlSaveLoad(vector, conv); break; default: NOT_REACHED(); } } @@ -1529,16 +1529,16 @@ size_t SlCalcObjMemberLength(const void *object, const SaveLoad &sld) return sld.size == sizeof(bool); case SLE_VAR_I8: case SLE_VAR_U8: - return sld.size == sizeof(int8); + return sld.size == sizeof(int8_t); case SLE_VAR_I16: case SLE_VAR_U16: - return sld.size == sizeof(int16); + return sld.size == sizeof(int16_t); case SLE_VAR_I32: case SLE_VAR_U32: - return sld.size == sizeof(int32); + return sld.size == sizeof(int32_t); case SLE_VAR_I64: case SLE_VAR_U64: - return sld.size == sizeof(int64); + return sld.size == sizeof(int64_t); case SLE_VAR_NAME: return sld.size == sizeof(std::string); default: @@ -1594,7 +1594,7 @@ static bool SlObjectMember(void *object, const SaveLoad &sld) void *ptr = GetVariableAddress(object, sld); switch (_sl.action) { - case SLA_SAVE: SlWriteByte(*(uint8 *)ptr); break; + case SLA_SAVE: SlWriteByte(*(uint8_t *)ptr); break; case SLA_LOAD_CHECK: case SLA_LOAD: case SLA_PTRS: @@ -1767,7 +1767,7 @@ std::vector SlTableHeader(const SaveLoadTable &slt) } while (true) { - uint8 type; + uint8_t type; SlSaveLoadConv(&type, SLE_UINT8); if (type == SLE_FILE_END) break; @@ -1808,7 +1808,7 @@ std::vector SlTableHeader(const SaveLoadTable &slt) * conversion. If this error triggers, that clearly didn't * happen and this is a friendly poke to the developer to bump * the savegame version and add conversion code. */ - uint8 correct_type = GetSavegameFileType(*sld_it->second); + uint8_t correct_type = GetSavegameFileType(*sld_it->second); if (correct_type != type) { Debug(sl, 1, "Field type for '{}' was expected to be 0x{:02x} but 0x{:02x} was found", key, correct_type, type); SlErrorCorrupt("Field type is different than expected"); @@ -1837,7 +1837,7 @@ std::vector SlTableHeader(const SaveLoadTable &slt) /* Make sure we are not storing empty keys. */ assert(!sld.name.empty()); - uint8 type = GetSavegameFileType(sld); + uint8_t type = GetSavegameFileType(sld); assert(type != SLE_FILE_END); SlSaveLoadConv(&type, SLE_UINT8); @@ -1845,7 +1845,7 @@ std::vector SlTableHeader(const SaveLoadTable &slt) } /* Add an end-of-header marker. */ - uint8 type = SLE_FILE_END; + uint8_t type = SLE_FILE_END; SlSaveLoadConv(&type, SLE_UINT8); /* After the table, write down any sub-tables we might have. */ @@ -2151,7 +2151,7 @@ static void SlSaveChunks() * @param id the chunk in question * @return returns the appropriate chunkhandler */ -static const ChunkHandler *SlFindChunkHandler(uint32 id) +static const ChunkHandler *SlFindChunkHandler(uint32_t id) { for (const ChunkHandler &ch : ChunkHandlers()) if (ch.id == id) return &ch; return nullptr; @@ -2160,7 +2160,7 @@ static const ChunkHandler *SlFindChunkHandler(uint32 id) /** Load all chunks */ static void SlLoadChunks() { - uint32 id; + uint32_t id; const ChunkHandler *ch; for (id = SlReadUint32(); id != 0; id = SlReadUint32()) { @@ -2175,7 +2175,7 @@ static void SlLoadChunks() /** Load all chunks for savegame checking */ static void SlLoadCheckChunks() { - uint32 id; + uint32_t id; const ChunkHandler *ch; for (id = SlReadUint32(); id != 0; id = SlReadUint32()) { @@ -2303,16 +2303,16 @@ struct LZOLoadFilter : LoadFilter { assert(ssize >= LZO_BUFFER_SIZE); /* Buffer size is from the LZO docs plus the chunk header size. */ - byte out[LZO_BUFFER_SIZE + LZO_BUFFER_SIZE / 16 + 64 + 3 + sizeof(uint32) * 2]; - uint32 tmp[2]; - uint32 size; + byte out[LZO_BUFFER_SIZE + LZO_BUFFER_SIZE / 16 + 64 + 3 + sizeof(uint32_t) * 2]; + uint32_t tmp[2]; + uint32_t size; lzo_uint len = ssize; /* Read header*/ if (this->chain->Read((byte*)tmp, sizeof(tmp)) != sizeof(tmp)) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE, "File read failed"); /* Check if size is bad */ - ((uint32*)out)[0] = size = tmp[1]; + ((uint32_t*)out)[0] = size = tmp[1]; if (_sl_version != SL_MIN_VERSION) { tmp[0] = TO_BE32(tmp[0]); @@ -2322,13 +2322,13 @@ struct LZOLoadFilter : LoadFilter { if (size >= sizeof(out)) SlErrorCorrupt("Inconsistent size"); /* Read block */ - if (this->chain->Read(out + sizeof(uint32), size) != size) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE); + if (this->chain->Read(out + sizeof(uint32_t), size) != size) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE); /* Verify checksum */ - if (tmp[0] != lzo_adler32(0, out, size + sizeof(uint32))) SlErrorCorrupt("Bad checksum"); + if (tmp[0] != lzo_adler32(0, out, size + sizeof(uint32_t))) SlErrorCorrupt("Bad checksum"); /* Decompress */ - int ret = lzo1x_decompress_safe(out + sizeof(uint32) * 1, size, buf, &len, nullptr); + int ret = lzo1x_decompress_safe(out + sizeof(uint32_t) * 1, size, buf, &len, nullptr); if (ret != LZO_E_OK) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE); return len; } @@ -2350,17 +2350,17 @@ struct LZOSaveFilter : SaveFilter { { const lzo_bytep in = buf; /* Buffer size is from the LZO docs plus the chunk header size. */ - byte out[LZO_BUFFER_SIZE + LZO_BUFFER_SIZE / 16 + 64 + 3 + sizeof(uint32) * 2]; + byte out[LZO_BUFFER_SIZE + LZO_BUFFER_SIZE / 16 + 64 + 3 + sizeof(uint32_t) * 2]; byte wrkmem[LZO1X_1_MEM_COMPRESS]; lzo_uint outlen; do { /* Compress up to LZO_BUFFER_SIZE bytes at once. */ lzo_uint len = size > LZO_BUFFER_SIZE ? LZO_BUFFER_SIZE : (lzo_uint)size; - lzo1x_1_compress(in, len, out + sizeof(uint32) * 2, &outlen, wrkmem); - ((uint32*)out)[1] = TO_BE32((uint32)outlen); - ((uint32*)out)[0] = TO_BE32(lzo_adler32(0, out + sizeof(uint32), outlen + sizeof(uint32))); - this->chain->Write(out, outlen + sizeof(uint32) * 2); + lzo1x_1_compress(in, len, out + sizeof(uint32_t) * 2, &outlen, wrkmem); + ((uint32_t*)out)[1] = TO_BE32((uint32_t)outlen); + ((uint32_t*)out)[0] = TO_BE32(lzo_adler32(0, out + sizeof(uint32_t), outlen + sizeof(uint32_t))); + this->chain->Write(out, outlen + sizeof(uint32_t) * 2); /* Move to next data chunk. */ size -= len; @@ -2655,7 +2655,7 @@ struct LZMASaveFilter : SaveFilter { /** The format for a reader/writer type of a savegame */ struct SaveLoadFormat { const char *name; ///< name of the compressor/decompressor (debug-only) - uint32 tag; ///< the 4-letter tag by which it is identified in the savegame + uint32_t tag; ///< the 4-letter tag by which it is identified in the savegame LoadFilter *(*init_load)(LoadFilter *chain); ///< Constructor for the load filter. SaveFilter *(*init_write)(SaveFilter *chain, byte compression); ///< Constructor for the save filter. @@ -2834,7 +2834,7 @@ static SaveOrLoadResult SaveFileToDisk(bool threaded) const SaveLoadFormat *fmt = GetSavegameFormat(_savegame_format, &compression); /* We have written our stuff to memory, now write it to file! */ - uint32 hdr[2] = { fmt->tag, TO_BE32(SAVEGAME_VERSION << 16) }; + uint32_t hdr[2] = { fmt->tag, TO_BE32(SAVEGAME_VERSION << 16) }; _sl.sf->Write((byte*)hdr, sizeof(hdr)); _sl.sf = fmt->init_write(_sl.sf, compression); @@ -2945,7 +2945,7 @@ static SaveOrLoadResult DoLoad(LoadFilter *reader, bool load_check) _load_check_data.checkable = true; } - uint32 hdr[2]; + uint32_t hdr[2]; if (_sl.lf->Read((byte*)hdr, sizeof(hdr)) != sizeof(hdr)) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE); /* see if we have any loader for this type. */ diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h index e0e8d280dc..3aedfb266f 100644 --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -28,7 +28,7 @@ * * Note that this list must not be reordered. */ -enum SaveLoadVersion : uint16 { +enum SaveLoadVersion : uint16_t { SL_MIN_VERSION, ///< First savegame version SLV_1, ///< 1.0 0.1.x, 0.2.x @@ -282,7 +282,7 @@ enum SaveLoadVersion : uint16 { SLV_198, ///< 198 PR#6763 Switch town growth rate and counter to actual game ticks SLV_EXTEND_CARGOTYPES, ///< 199 PR#6802 Extend cargotypes to 64 - SLV_EXTEND_RAILTYPES, ///< 200 PR#6805 Extend railtypes to 64, adding uint16 to map array. + SLV_EXTEND_RAILTYPES, ///< 200 PR#6805 Extend railtypes to 64, adding uint16_t to map array. SLV_EXTEND_PERSISTENT_STORAGE, ///< 201 PR#6885 Extend NewGRF persistent storages. SLV_EXTEND_INDUSTRY_CARGO_SLOTS, ///< 202 PR#6867 Increase industry cargo slots to 16 in, 16 out SLV_SHIP_PATH_CACHE, ///< 203 PR#7072 Add path cache for ships @@ -342,7 +342,7 @@ enum SaveLoadVersion : uint16 { SLV_LAST_LOADING_TICK, ///< 301 PR#9693 Store tick of last loading for vehicles. SLV_MULTITRACK_LEVEL_CROSSINGS, ///< 302 PR#9931 v13.0 Multi-track level crossings. SLV_NEWGRF_ROAD_STOPS, ///< 303 PR#10144 NewGRF road stops. - SLV_LINKGRAPH_EDGES, ///< 304 PR#10314 Explicitly store link graph edges destination, PR#10471 int64 instead of uint64 league rating + SLV_LINKGRAPH_EDGES, ///< 304 PR#10314 Explicitly store link graph edges destination, PR#10471 int64_t instead of uint64_t league rating SLV_VELOCITY_NAUTICAL, ///< 305 PR#10594 Separation of land and nautical velocity (knots!) SLV_CONSISTENT_PARTIAL_Z, ///< 306 PR#10570 Conversion from an inconsistent partial Z calculation for slopes, to one that is (more) consistent. @@ -423,10 +423,10 @@ enum ChunkType { /** Handlers and description of chunk. */ struct ChunkHandler { - uint32 id; ///< Unique ID (4 letters). + uint32_t id; ///< Unique ID (4 letters). ChunkType type; ///< Type of the chunk. @see ChunkType - ChunkHandler(uint32 id, ChunkType type) : id(id), type(type) {} + ChunkHandler(uint32_t id, ChunkType type) : id(id), type(type) {} virtual ~ChunkHandler() = default; @@ -651,7 +651,7 @@ enum VarTypes { SLF_ALLOW_NEWLINE = 1 << 9, ///< Allow new lines in the strings. }; -typedef uint32 VarType; +typedef uint32_t VarType; /** Type of data saved. */ enum SaveLoadType : byte { @@ -678,7 +678,7 @@ struct SaveLoad { std::string name; ///< Name of this field (optional, used for tables). SaveLoadType cmd; ///< The action to take with the saved/loaded type, All types need different action. VarType conv; ///< Type of the variable to be saved; this field combines both FileVarType and MemVarType. - uint16 length; ///< (Conditional) length of the variable (eg. arrays) (max array size is 65536 elements). + uint16_t length; ///< (Conditional) length of the variable (eg. arrays) (max array size is 65536 elements). SaveLoadVersion version_from; ///< Save/load the variable starting from this savegame version. SaveLoadVersion version_to; ///< Save/load the variable before this savegame version. size_t size; ///< The sizeof size. @@ -697,7 +697,7 @@ struct SaveLoad { */ struct SaveLoadCompat { std::string name; ///< Name of the field. - uint16 length; ///< Length of the NULL field. + uint16_t length; ///< Length of the NULL field. SaveLoadVersion version_from; ///< Save/load the variable starting from this savegame version. SaveLoadVersion version_to; ///< Save/load the variable before this savegame version. }; @@ -1176,8 +1176,8 @@ static inline void *GetVariableAddress(const void *object, const SaveLoad &sld) return sld.address_proc(const_cast(object), sld.extra_data); } -int64 ReadValue(const void *ptr, VarType conv); -void WriteValue(void *ptr, VarType conv, int64 val); +int64_t ReadValue(const void *ptr, VarType conv); +void WriteValue(void *ptr, VarType conv, int64_t val); void SlSetArrayIndex(uint index); int SlIterateArray(); diff --git a/src/saveload/saveload_internal.h b/src/saveload/saveload_internal.h index a7fc54d7d3..e311c5c4aa 100644 --- a/src/saveload/saveload_internal.h +++ b/src/saveload/saveload_internal.h @@ -47,15 +47,15 @@ void ResetTempEngineData(); Engine *GetTempDataEngine(EngineID index); void CopyTempEngineData(); -extern int32 _saved_scrollpos_x; -extern int32 _saved_scrollpos_y; +extern int32_t _saved_scrollpos_x; +extern int32_t _saved_scrollpos_y; extern ZoomLevel _saved_scrollpos_zoom; extern SavegameType _savegame_type; -extern uint32 _ttdp_version; +extern uint32_t _ttdp_version; -CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32 face); +CompanyManagerFace ConvertFromOldCompanyManagerFace(uint32_t face); -Order UnpackOldOrder(uint16 packed); +Order UnpackOldOrder(uint16_t packed); #endif /* SAVELOAD_INTERNAL_H */ diff --git a/src/saveload/settings_sl.cpp b/src/saveload/settings_sl.cpp index 1b1db8fa61..ab8f5cec28 100644 --- a/src/saveload/settings_sl.cpp +++ b/src/saveload/settings_sl.cpp @@ -63,7 +63,7 @@ void HandleOldDiffCustom(bool savegame) continue; } - int32 value = (int32)((name == "max_loan" ? 1000 : 1) * _old_diff_custom[i++]); + int32_t value = (int32_t)((name == "max_loan" ? 1000 : 1) * _old_diff_custom[i++]); sd->AsIntSetting()->MakeValueValidAndWrite(savegame ? &_settings_game : &_settings_newgame, value); } } diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp index fcfcdce66f..76ef03dee4 100644 --- a/src/saveload/station_sl.cpp +++ b/src/saveload/station_sl.cpp @@ -158,21 +158,21 @@ static const SaveLoad _roadstop_desc[] = { SLE_REF(RoadStop, next, REF_ROADSTOPS), }; -static uint16 _waiting_acceptance; -static uint32 _old_num_flows; -static uint16 _cargo_source; -static uint32 _cargo_source_xy; -static uint8 _cargo_periods; +static uint16_t _waiting_acceptance; +static uint32_t _old_num_flows; +static uint16_t _cargo_source; +static uint32_t _cargo_source_xy; +static uint8_t _cargo_periods; static Money _cargo_feeder_share; std::list _packets; -uint32 _old_num_dests; +uint32_t _old_num_dests; struct FlowSaveLoad { FlowSaveLoad() : source(0), via(0), share(0), restricted(false) {} StationID source; StationID via; - uint32 share; + uint32_t share; bool restricted; }; @@ -211,7 +211,7 @@ public: }; inline const static SaveLoadCompatTable compat_description = _station_spec_list_sl_compat; - static uint8 last_num_specs; ///< Number of specs of the last loaded station. + static uint8_t last_num_specs; ///< Number of specs of the last loaded station. void Save(BaseStation *bst) const override { @@ -223,7 +223,7 @@ public: void Load(BaseStation *bst) const override { - uint8 num_specs = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? last_num_specs : (uint8)SlGetStructListLength(UINT8_MAX); + uint8_t num_specs = IsSavegameVersionBefore(SLV_SAVELOAD_LIST_LENGTH) ? last_num_specs : (uint8_t)SlGetStructListLength(UINT8_MAX); bst->speclist.resize(num_specs); for (uint i = 0; i < num_specs; i++) { @@ -232,7 +232,7 @@ public: } }; -uint8 SlStationSpecList::last_num_specs; +uint8_t SlStationSpecList::last_num_specs; class SlRoadStopSpecList : public DefaultSaveLoadHandler { public: @@ -253,7 +253,7 @@ public: void Load(BaseStation *bst) const override { - uint8 num_specs = (uint8)SlGetStructListLength(UINT8_MAX); + uint8_t num_specs = (uint8_t)SlGetStructListLength(UINT8_MAX); bst->roadstop_speclist.resize(num_specs); for (uint i = 0; i < num_specs; i++) { @@ -318,7 +318,7 @@ public: for (const auto &outer_it : ge->flows) { const FlowStat::SharesMap *shares = outer_it.second.GetShares(); - uint32 sum_shares = 0; + uint32_t sum_shares = 0; FlowSaveLoad flow; flow.source = outer_it.first; for (auto &inner_it : *shares) { @@ -339,7 +339,7 @@ public: FlowSaveLoad flow; FlowStat *fs = nullptr; StationID prev_source = INVALID_STATION; - for (uint32 j = 0; j < num_flows; ++j) { + for (uint32_t j = 0; j < num_flows; ++j) { SlObject(&flow, this->GetLoadDescription()); if (fs == nullptr || prev_source != flow.source) { fs = &(ge->flows.insert(std::make_pair(flow.source, FlowStat(flow.via, flow.share, flow.restricted))).first->second); @@ -563,7 +563,7 @@ public: }; inline const static SaveLoadCompatTable compat_description = {}; - static uint8 last_num_specs; ///< Number of specs of the last loaded station. + static uint8_t last_num_specs; ///< Number of specs of the last loaded station. void Save(BaseStation *bst) const override { @@ -575,7 +575,7 @@ public: void Load(BaseStation *bst) const override { - uint32 num_tiles = (uint32)SlGetStructListLength(UINT32_MAX); + uint32_t num_tiles = (uint32_t)SlGetStructListLength(UINT32_MAX); bst->custom_roadstop_tile_data.resize(num_tiles); for (uint i = 0; i < num_tiles; i++) { SlObject(&bst->custom_roadstop_tile_data[i], this->GetLoadDescription()); diff --git a/src/saveload/story_sl.cpp b/src/saveload/story_sl.cpp index c071e7e81d..750af178c9 100644 --- a/src/saveload/story_sl.cpp +++ b/src/saveload/story_sl.cpp @@ -56,7 +56,7 @@ struct STPEChunkHandler : ChunkHandler { const std::vector slt = SlCompatTableHeader(_story_page_elements_desc, _story_page_elements_sl_compat); int index; - uint32 max_sort_value = 0; + uint32_t max_sort_value = 0; while ((index = SlIterateArray()) != -1) { StoryPageElement *s = new (index) StoryPageElement(); SlObject(s, slt); @@ -98,7 +98,7 @@ struct STPAChunkHandler : ChunkHandler { const std::vector slt = SlCompatTableHeader(_story_pages_desc, _story_pages_sl_compat); int index; - uint32 max_sort_value = 0; + uint32_t max_sort_value = 0; while ((index = SlIterateArray()) != -1) { StoryPage *s = new (index) StoryPage(); SlObject(s, slt); diff --git a/src/saveload/strings_sl.cpp b/src/saveload/strings_sl.cpp index 6e4d779687..3d9a315f0d 100644 --- a/src/saveload/strings_sl.cpp +++ b/src/saveload/strings_sl.cpp @@ -70,7 +70,7 @@ std::string CopyFromOldName(StringID id) std::ostringstream tmp; std::ostreambuf_iterator strto(tmp); for (; *strfrom != '\0'; strfrom++) { - WChar c = (byte)*strfrom; + char32_t c = (byte)*strfrom; /* Map from non-ISO8859-15 characters to UTF-8. */ switch (c) { diff --git a/src/saveload/town_sl.cpp b/src/saveload/town_sl.cpp index f458f8a5cf..695a51b0c0 100644 --- a/src/saveload/town_sl.cpp +++ b/src/saveload/town_sl.cpp @@ -118,10 +118,10 @@ void UpdateHousesAndTowns() class SlTownSupplied : public DefaultSaveLoadHandler { public: inline static const SaveLoad description[] = { - SLE_CONDVAR(TransportedCargoStat, old_max, SLE_UINT32, SLV_165, SL_MAX_VERSION), - SLE_CONDVAR(TransportedCargoStat, new_max, SLE_UINT32, SLV_165, SL_MAX_VERSION), - SLE_CONDVAR(TransportedCargoStat, old_act, SLE_UINT32, SLV_165, SL_MAX_VERSION), - SLE_CONDVAR(TransportedCargoStat, new_act, SLE_UINT32, SLV_165, SL_MAX_VERSION), + SLE_CONDVAR(TransportedCargoStat, old_max, SLE_UINT32, SLV_165, SL_MAX_VERSION), + SLE_CONDVAR(TransportedCargoStat, new_max, SLE_UINT32, SLV_165, SL_MAX_VERSION), + SLE_CONDVAR(TransportedCargoStat, old_act, SLE_UINT32, SLV_165, SL_MAX_VERSION), + SLE_CONDVAR(TransportedCargoStat, new_act, SLE_UINT32, SLV_165, SL_MAX_VERSION), }; inline const static SaveLoadCompatTable compat_description = _town_supplied_sl_compat; @@ -157,10 +157,10 @@ public: class SlTownReceived : public DefaultSaveLoadHandler { public: inline static const SaveLoad description[] = { - SLE_CONDVAR(TransportedCargoStat, old_max, SLE_UINT16, SLV_165, SL_MAX_VERSION), - SLE_CONDVAR(TransportedCargoStat, new_max, SLE_UINT16, SLV_165, SL_MAX_VERSION), - SLE_CONDVAR(TransportedCargoStat, old_act, SLE_UINT16, SLV_165, SL_MAX_VERSION), - SLE_CONDVAR(TransportedCargoStat, new_act, SLE_UINT16, SLV_165, SL_MAX_VERSION), + SLE_CONDVAR(TransportedCargoStat, old_max, SLE_UINT16, SLV_165, SL_MAX_VERSION), + SLE_CONDVAR(TransportedCargoStat, new_max, SLE_UINT16, SLV_165, SL_MAX_VERSION), + SLE_CONDVAR(TransportedCargoStat, old_act, SLE_UINT16, SLV_165, SL_MAX_VERSION), + SLE_CONDVAR(TransportedCargoStat, new_act, SLE_UINT16, SLV_165, SL_MAX_VERSION), }; inline const static SaveLoadCompatTable compat_description = _town_received_sl_compat; diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp index 2ab840420a..43c2240d22 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -571,13 +571,13 @@ void FixupTrainLengths() } } -static uint8 _cargo_periods; -static uint16 _cargo_source; -static uint32 _cargo_source_xy; -static uint16 _cargo_count; -static uint16 _cargo_paid_for; +static uint8_t _cargo_periods; +static uint16_t _cargo_source; +static uint32_t _cargo_source_xy; +static uint16_t _cargo_count; +static uint16_t _cargo_paid_for; static Money _cargo_feeder_share; -static uint32 _cargo_loaded_at_xy; +static uint32_t _cargo_loaded_at_xy; class SlVehicleCommon : public DefaultSaveLoadHandler { public: diff --git a/src/saveload/waypoint_sl.cpp b/src/saveload/waypoint_sl.cpp index b491ac6c2f..de57120c98 100644 --- a/src/saveload/waypoint_sl.cpp +++ b/src/saveload/waypoint_sl.cpp @@ -28,13 +28,13 @@ struct OldWaypoint { TileIndex xy; TownID town_index; Town *town; - uint16 town_cn; + uint16_t town_cn; StringID string_id; std::string name; - uint8 delete_ctr; + uint8_t delete_ctr; TimerGameCalendar::Date build_date; - uint8 localidx; - uint32 grfid; + uint8_t localidx; + uint32_t grfid; const StationSpec *spec; Owner owner; diff --git a/src/screenshot.cpp b/src/screenshot.cpp index 7aef660406..386b5e4a27 100644 --- a/src/screenshot.cpp +++ b/src/screenshot.cpp @@ -81,19 +81,19 @@ struct ScreenshotFormat { /** BMP File Header (stored in little endian) */ PACK(struct BitmapFileHeader { - uint16 type; - uint32 size; - uint32 reserved; - uint32 off_bits; + uint16_t type; + uint32_t size; + uint32_t reserved; + uint32_t off_bits; }); static_assert(sizeof(BitmapFileHeader) == 14); /** BMP Info Header (stored in little endian) */ struct BitmapInfoHeader { - uint32 size; - int32 width, height; - uint16 planes, bitcount; - uint32 compression, sizeimage, xpels, ypels, clrused, clrimp; + uint32_t size; + int32_t width, height; + uint16_t planes, bitcount; + uint32_t compression, sizeimage, xpels, ypels, clrused, clrimp; }; static_assert(sizeof(BitmapInfoHeader) == 40); @@ -181,8 +181,8 @@ static bool MakeBMPImage(const char *name, ScreenshotCallback *callb, void *user /* Try to use 64k of memory, store between 16 and 128 lines */ uint maxlines = Clamp(65536 / (w * pixelformat / 8), 16, 128); // number of lines per iteration - uint8 *buff = MallocT(maxlines * w * pixelformat / 8); // buffer which is rendered to - uint8 *line = CallocT(bytewidth); // one line, stored to file + uint8_t *buff = MallocT(maxlines * w * pixelformat / 8); // buffer which is rendered to + uint8_t *line = CallocT(bytewidth); // one line, stored to file /* Start at the bottom, since bitmaps are stored bottom up */ do { @@ -374,7 +374,7 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user maxlines = Clamp(65536 / w, 16, 128); /* now generate the bitmap bits */ - void *buff = CallocT(static_cast(w) * maxlines * bpp); // by default generate 128 lines at a time. + void *buff = CallocT(static_cast(w) * maxlines * bpp); // by default generate 128 lines at a time. y = 0; do { @@ -411,16 +411,16 @@ struct PcxHeader { byte version; byte rle; byte bpp; - uint32 unused; - uint16 xmax, ymax; - uint16 hdpi, vdpi; + uint32_t unused; + uint16_t xmax, ymax; + uint16_t hdpi, vdpi; byte pal_small[16 * 3]; byte reserved; byte planes; - uint16 pitch; - uint16 cpal; - uint16 width; - uint16 height; + uint16_t pitch; + uint16_t cpal; + uint16_t width; + uint16_t height; byte filler[54]; }; static_assert(sizeof(PcxHeader) == 128); @@ -481,7 +481,7 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user maxlines = Clamp(65536 / w, 16, 128); /* now generate the bitmap bits */ - uint8 *buff = CallocT(static_cast(w) * maxlines); // by default generate 128 lines at a time. + uint8_t *buff = CallocT(static_cast(w) * maxlines); // by default generate 128 lines at a time. y = 0; do { @@ -495,14 +495,14 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user /* write them to pcx */ for (i = 0; i != n; i++) { - const uint8 *bufp = buff + i * w; + const uint8_t *bufp = buff + i * w; byte runchar = bufp[0]; uint runcount = 1; uint j; /* for each pixel... */ for (j = 1; j < w; j++) { - uint8 ch = bufp[j]; + uint8_t ch = bufp[j]; if (ch != runchar || runcount >= 0x3f) { if (runcount > 1 || (runchar & 0xC0) == 0xC0) { @@ -718,7 +718,7 @@ static bool MakeSmallScreenshot(bool crashlog) * @param height the height of the screenshot, or 0 for current viewport height (needs to be 0 with SC_VIEWPORT, SC_CRASHLOG, and SC_WORLD). * @param[out] vp Result viewport */ -void SetupScreenshotViewport(ScreenshotType t, Viewport *vp, uint32 width, uint32 height) +void SetupScreenshotViewport(ScreenshotType t, Viewport *vp, uint32_t width, uint32_t height) { switch(t) { case SC_VIEWPORT: @@ -799,7 +799,7 @@ void SetupScreenshotViewport(ScreenshotType t, Viewport *vp, uint32 width, uint3 * @param height the height of the screenshot of, or 0 for current viewport height. * @return true on success */ -static bool MakeLargeWorldScreenshot(ScreenshotType t, uint32 width = 0, uint32 height = 0) +static bool MakeLargeWorldScreenshot(ScreenshotType t, uint32_t width = 0, uint32_t height = 0) { Viewport vp; SetupScreenshotViewport(t, &vp, width, height); @@ -905,7 +905,7 @@ void MakeScreenshotWithConfirm(ScreenshotType t) * @param height the height of the screenshot of, or 0 for current viewport height (only works for SC_ZOOMEDIN and SC_DEFAULTZOOM). * @return true iff the screenshot was made successfully */ -static bool RealMakeScreenshot(ScreenshotType t, std::string name, uint32 width, uint32 height) +static bool RealMakeScreenshot(ScreenshotType t, std::string name, uint32_t width, uint32_t height) { if (t == SC_VIEWPORT) { /* First draw the dirty parts of the screen and only then change the name @@ -979,7 +979,7 @@ static bool RealMakeScreenshot(ScreenshotType t, std::string name, uint32 width, * @return true iff the screenshot was successfully made. * @see MakeScreenshotWithConfirm */ -bool MakeScreenshot(ScreenshotType t, std::string name, uint32 width, uint32 height) +bool MakeScreenshot(ScreenshotType t, std::string name, uint32_t width, uint32_t height) { if (t == SC_CRASHLOG) { /* Video buffer might or might not be locked. */ @@ -998,7 +998,7 @@ bool MakeScreenshot(ScreenshotType t, std::string name, uint32 width, uint32 hei static void MinimapScreenCallback(void *userdata, void *buf, uint y, uint pitch, uint n) { - uint32 *ubuf = (uint32 *)buf; + uint32_t *ubuf = (uint32_t *)buf; uint num = (pitch * n); for (uint i = 0; i < num; i++) { uint row = y + (int)(i / pitch); @@ -1007,7 +1007,7 @@ static void MinimapScreenCallback(void *userdata, void *buf, uint y, uint pitch, TileIndex tile = TileXY(col, row); byte val = GetSmallMapOwnerPixels(tile, GetTileType(tile), IncludeHeightmap::Never) & 0xFF; - uint32 colour_buf = 0; + uint32_t colour_buf = 0; colour_buf = (_cur_palette.palette[val].b << 0); colour_buf |= (_cur_palette.palette[val].g << 8); colour_buf |= (_cur_palette.palette[val].r << 16); diff --git a/src/screenshot.h b/src/screenshot.h index 9ce10c0497..a243050e56 100644 --- a/src/screenshot.h +++ b/src/screenshot.h @@ -25,10 +25,10 @@ enum ScreenshotType { SC_MINIMAP, ///< Minimap screenshot. }; -void SetupScreenshotViewport(ScreenshotType t, struct Viewport *vp, uint32 width = 0, uint32 height = 0); +void SetupScreenshotViewport(ScreenshotType t, struct Viewport *vp, uint32_t width = 0, uint32_t height = 0); bool MakeHeightmapScreenshot(const char *filename); void MakeScreenshotWithConfirm(ScreenshotType t); -bool MakeScreenshot(ScreenshotType t, std::string name, uint32 width = 0, uint32 height = 0); +bool MakeScreenshot(ScreenshotType t, std::string name, uint32_t width = 0, uint32_t height = 0); bool MakeMinimapWorldScreenshot(); extern std::string _screenshot_format_name; diff --git a/src/script/api/script_airport.cpp b/src/script/api/script_airport.cpp index 6513a1d205..b1edbec48d 100644 --- a/src/script/api/script_airport.cpp +++ b/src/script/api/script_airport.cpp @@ -169,5 +169,5 @@ { if (!IsAirportInformationAvailable(type)) return -1; - return (int64)GetMaintenanceCostFactor(type) * _price[PR_INFRASTRUCTURE_AIRPORT] >> 3; + return (int64_t)GetMaintenanceCostFactor(type) * _price[PR_INFRASTRUCTURE_AIRPORT] >> 3; } diff --git a/src/script/api/script_base.hpp b/src/script/api/script_base.hpp index 3b0422a7e2..aaaa3b2340 100644 --- a/src/script/api/script_base.hpp +++ b/src/script/api/script_base.hpp @@ -23,21 +23,21 @@ class ScriptBase : public ScriptObject { public: /** * Get a random value. - * @return A random value between 0 and MAX(uint32). + * @return A random value between 0 and MAX(uint32_t). */ static SQInteger Rand(); /** * Get a random value. * @param unused_param This parameter is not used, but is needed to work with lists. - * @return A random value between 0 and MAX(uint32). + * @return A random value between 0 and MAX(uint32_t). */ static SQInteger RandItem(SQInteger unused_param); /** * Get a random value in a range. * @param max The first number this function will never return (the maximum it returns is max - 1). - * The value will be clamped to 0 .. MAX(uint32). + * The value will be clamped to 0 .. MAX(uint32_t). * @return A random value between 0 .. max - 1. */ static SQInteger RandRange(SQInteger max); @@ -46,7 +46,7 @@ public: * Get a random value in a range. * @param unused_param This parameter is not used, but is needed to work with lists. * @param max The first number this function will never return (the maximum it returns is max - 1). - * The value will be clamped to 0 .. MAX(uint32). + * The value will be clamped to 0 .. MAX(uint32_t). * @return A random value between 0 .. max - 1. */ static SQInteger RandRangeItem(SQInteger unused_param, SQInteger max); @@ -55,9 +55,9 @@ public: * Returns approximately 'out' times true when called 'max' times. * After all, it is a random function. * @param out How many times it should return true. - * The value will be clamped to 0 .. MAX(uint32). + * The value will be clamped to 0 .. MAX(uint32_t). * @param max Out of this many times. - * The value will be clamped to 0 .. MAX(uint32). + * The value will be clamped to 0 .. MAX(uint32_t). * @pre \a out is at most equal to \a max. * @return True if the chance worked out. */ @@ -68,9 +68,9 @@ public: * After all, it is a random function. * @param unused_param This parameter is not used, but is needed to work with lists. * @param out How many times it should return true. - * The value will be clamped to 0 .. MAX(uint32). + * The value will be clamped to 0 .. MAX(uint32_t). * @param max Out of this many times. - * The value will be clamped to 0 .. MAX(uint32). + * The value will be clamped to 0 .. MAX(uint32_t). * @pre \a out is at most equal to \a max. * @return True if the chance worked out. */ diff --git a/src/script/api/script_bridge.hpp b/src/script/api/script_bridge.hpp index d7dc0df043..01f52a55bd 100644 --- a/src/script/api/script_bridge.hpp +++ b/src/script/api/script_bridge.hpp @@ -86,7 +86,7 @@ public: * Get the new cost of a bridge, excluding the road and/or rail. * @param bridge_id The bridge to get the new cost of. * @param length The length of the bridge. - * The value will be clamped to 0 .. MAX(int32). + * The value will be clamped to 0 .. MAX(int32_t). * @pre IsValidBridge(bridge_id). * @return The new cost the bridge has. */ diff --git a/src/script/api/script_cargo.cpp b/src/script/api/script_cargo.cpp index ba0aaf3799..814f7b36c2 100644 --- a/src/script/api/script_cargo.cpp +++ b/src/script/api/script_cargo.cpp @@ -41,11 +41,11 @@ if (!IsValidCargo(cargo_type)) return std::nullopt; const CargoSpec *cargo = ::CargoSpec::Get(cargo_type); - /* cargo->label is a uint32 packing a 4 character non-terminated string, + /* cargo->label is a uint32_t packing a 4 character non-terminated string, * like "PASS", "COAL", "OIL_". New ones can be defined by NewGRFs */ std::string cargo_label; for (uint i = 0; i < sizeof(cargo->label); i++) { - cargo_label.push_back(GB(cargo->label, (uint8)(sizeof(cargo->label) - i - 1) * 8, 8)); + cargo_label.push_back(GB(cargo->label, (uint8_t)(sizeof(cargo->label) - i - 1) * 8, 8)); } return cargo_label; } diff --git a/src/script/api/script_cargo.hpp b/src/script/api/script_cargo.hpp index f44d53dbae..7d4b207ed6 100644 --- a/src/script/api/script_cargo.hpp +++ b/src/script/api/script_cargo.hpp @@ -142,7 +142,7 @@ public: * @param cargo_type The cargo to transport. * @pre ScriptCargo::IsValidCargo(cargo_type). * @param distance The distance the cargo travels from begin to end. - * The value will be clamped to 0 .. MAX(uint32). + * The value will be clamped to 0 .. MAX(uint32_t). * @param days_in_transit Amount of (game) days the cargo is in transit. * The max value of this variable is 637. Any value higher returns the same as 637 would. * @return The amount of money that would be earned by this trip. @@ -161,7 +161,7 @@ public: * cargo for the specified type. * @param cargo_type The cargo to check on. * @param amount The quantity of cargo. - * The value will be clamped to 0 .. MAX(uint32). + * The value will be clamped to 0 .. MAX(uint32_t). * @pre ScriptCargo::IsValidCargo(cargo_type). * @return The weight in tonnes for that quantity of cargo. */ diff --git a/src/script/api/script_client.hpp b/src/script/api/script_client.hpp index dabd956f00..7b5d6f5dc3 100644 --- a/src/script/api/script_client.hpp +++ b/src/script/api/script_client.hpp @@ -24,7 +24,7 @@ class ScriptClient : public ScriptObject { public: /** Different constants related to ClientID. */ - enum ClientID : uint32 { + enum ClientID : uint32_t { CLIENT_INVALID = 0, ///< Client is not part of anything CLIENT_SERVER = 1, ///< Servers always have this ID CLIENT_FIRST = 2, ///< The first client ID diff --git a/src/script/api/script_company.cpp b/src/script/api/script_company.cpp index a50590c09b..b1d5a10d5f 100644 --- a/src/script/api/script_company.cpp +++ b/src/script/api/script_company.cpp @@ -204,7 +204,7 @@ { EnforceCompanyModeValid(false); EnforcePrecondition(false, loan >= 0); - EnforcePrecondition(false, ((int64)loan % GetLoanInterval()) == 0); + EnforcePrecondition(false, ((int64_t)loan % GetLoanInterval()) == 0); EnforcePrecondition(false, loan <= GetMaxLoanAmount()); EnforcePrecondition(false, (loan - GetLoanAmount() + GetBankBalance(COMPANY_SELF)) >= 0); @@ -224,7 +224,7 @@ EnforceCompanyModeValid(false); EnforcePrecondition(false, loan >= 0); - Money over_interval = (int64)loan % GetLoanInterval(); + Money over_interval = (int64_t)loan % GetLoanInterval(); if (over_interval != 0) loan += GetLoanInterval() - over_interval; EnforcePrecondition(false, loan <= GetMaxLoanAmount()); @@ -298,7 +298,7 @@ { EnforceCompanyModeValid(false); EnforcePrecondition(false, money >= 0); - EnforcePrecondition(false, (int64)money <= UINT32_MAX); + EnforcePrecondition(false, (int64_t)money <= UINT32_MAX); return ScriptObject::Command::Do("company.engine_renew_money", money); } diff --git a/src/script/api/script_company.hpp b/src/script/api/script_company.hpp index 2afb47a3ff..6e4ef1e2ae 100644 --- a/src/script/api/script_company.hpp +++ b/src/script/api/script_company.hpp @@ -351,7 +351,7 @@ public: /** * Set the number of months before/after max age to autorenew an engine for your company. * @param months The new months between autorenew. - * The value will be clamped to MIN(int16) .. MAX(int16). + * The value will be clamped to MIN(int16_t) .. MAX(int16_t). * @game @pre ScriptCompanyMode::IsValid(). * @return True if autorenew months has been modified. */ diff --git a/src/script/api/script_event_types.cpp b/src/script/api/script_event_types.cpp index de94ce4a56..ffe4020983 100644 --- a/src/script/api/script_event_types.cpp +++ b/src/script/api/script_event_types.cpp @@ -53,7 +53,7 @@ CargoID ScriptEventEnginePreview::GetCargoType() return most_cargo; } -int32 ScriptEventEnginePreview::GetCapacity() +int32_t ScriptEventEnginePreview::GetCapacity() { if (!this->IsEngineValid()) return -1; const Engine *e = ::Engine::Get(this->engine); @@ -76,11 +76,11 @@ int32 ScriptEventEnginePreview::GetCapacity() } } -int32 ScriptEventEnginePreview::GetMaxSpeed() +int32_t ScriptEventEnginePreview::GetMaxSpeed() { if (!this->IsEngineValid()) return -1; const Engine *e = ::Engine::Get(this->engine); - int32 max_speed = e->GetDisplayMaxSpeed(); // km-ish/h + int32_t max_speed = e->GetDisplayMaxSpeed(); // km-ish/h if (e->type == VEH_AIRCRAFT) max_speed /= _settings_game.vehicle.plane_speed; return max_speed; } @@ -97,7 +97,7 @@ Money ScriptEventEnginePreview::GetRunningCost() return ::Engine::Get(this->engine)->GetRunningCost(); } -int32 ScriptEventEnginePreview::GetVehicleType() +int32_t ScriptEventEnginePreview::GetVehicleType() { if (!this->IsEngineValid()) return ScriptVehicle::VT_INVALID; switch (::Engine::Get(this->engine)->type) { diff --git a/src/script/api/script_event_types.hpp b/src/script/api/script_event_types.hpp index 43eff7dc1b..79902d2668 100644 --- a/src/script/api/script_event_types.hpp +++ b/src/script/api/script_event_types.hpp @@ -253,7 +253,7 @@ public: * returns the first/main. * @return The capacity of the engine. */ - int32 GetCapacity(); + int32_t GetCapacity(); /** * Get the maximum speed of the offered engine. @@ -262,7 +262,7 @@ public: * This is mph / 1.6, which is roughly km/h. * To get km/h multiply this number by 1.00584. */ - int32 GetMaxSpeed(); + int32_t GetMaxSpeed(); /** * Get the new cost of the offered engine. @@ -284,7 +284,7 @@ public: #ifdef DOXYGEN_API ScriptVehicle::VehicleType GetVehicleType(); #else - int32 GetVehicleType(); + int32_t GetVehicleType(); #endif /* DOXYGEN_API */ /** @@ -945,7 +945,7 @@ public: * @param number The windownumber that was clicked. * @param widget The widget in the window that was clicked. */ - ScriptEventWindowWidgetClick(ScriptWindow::WindowClass window, uint32 number, uint8 widget) : + ScriptEventWindowWidgetClick(ScriptWindow::WindowClass window, uint32_t number, uint8_t widget) : ScriptEvent(ET_WINDOW_WIDGET_CLICK), window(window), number(number), @@ -970,18 +970,18 @@ public: * Get the number of the window that was clicked. * @return The clicked identifying number of the widget within the class. */ - uint32 GetWindowNumber() { return this->number; } + uint32_t GetWindowNumber() { return this->number; } /** * Get the number of the widget that was clicked. * @return The number of the clicked widget. */ - uint8 GetWidgetNumber() { return this->widget; } + uint8_t GetWidgetNumber() { return this->widget; } private: ScriptWindow::WindowClass window; ///< Window of the click. - uint32 number; ///< Number of the click. - uint8 widget; ///< Widget of the click. + uint32_t number; ///< Number of the click. + uint8_t widget; ///< Widget of the click. }; /** @@ -998,7 +998,7 @@ public: * @param company The company that is replying. * @param button The button the company pressed. */ - ScriptEventGoalQuestionAnswer(uint16 uniqueid, ScriptCompany::CompanyID company, ScriptGoal::QuestionButton button) : + ScriptEventGoalQuestionAnswer(uint16_t uniqueid, ScriptCompany::CompanyID company, ScriptGoal::QuestionButton button) : ScriptEvent(ET_GOAL_QUESTION_ANSWER), uniqueid(uniqueid), company(company), @@ -1017,7 +1017,7 @@ public: * Get the unique id of the question. * @return The unique id. */ - uint16 GetUniqueID() { return this->uniqueid; } + uint16_t GetUniqueID() { return this->uniqueid; } /** * Get the company that pressed a button. @@ -1032,7 +1032,7 @@ public: ScriptGoal::QuestionButton GetButton() { return this->button; } private: - uint16 uniqueid; ///< The uniqueid of the question. + uint16_t uniqueid; ///< The uniqueid of the question. ScriptCompany::CompanyID company; ///< The company given the answer. ScriptGoal::QuestionButton button; ///< The button that was pressed. }; diff --git a/src/script/api/script_gamesettings.hpp b/src/script/api/script_gamesettings.hpp index d4bbf609de..b706e86d18 100644 --- a/src/script/api/script_gamesettings.hpp +++ b/src/script/api/script_gamesettings.hpp @@ -63,7 +63,7 @@ public: * Sets the value of the game setting. * @param setting The setting to set the value of. * @param value The value to set the setting to. - * The value will be clamped to MIN(int32) .. MAX(int32). + * The value will be clamped to MIN(int32_t) .. MAX(int32_t). * @pre IsValid(setting). * @return True if the action succeeded. * @note Results achieved in the past offer no guarantee for the future. diff --git a/src/script/api/script_goal.cpp b/src/script/api/script_goal.cpp index da19ba464c..8e4970d712 100644 --- a/src/script/api/script_goal.cpp +++ b/src/script/api/script_goal.cpp @@ -117,7 +117,7 @@ return g != nullptr && g->completed; } -/* static */ bool ScriptGoal::DoQuestion(SQInteger uniqueid, uint32 target, bool is_client, Text *question, QuestionType type, SQInteger buttons) +/* static */ bool ScriptGoal::DoQuestion(SQInteger uniqueid, uint32_t target, bool is_client, Text *question, QuestionType type, SQInteger buttons) { CCountedPtr counter(question); @@ -137,7 +137,7 @@ /* static */ bool ScriptGoal::Question(SQInteger uniqueid, ScriptCompany::CompanyID company, Text *question, QuestionType type, SQInteger buttons) { EnforcePrecondition(false, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID); - uint8 c = company; + uint8_t c = company; if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY; return DoQuestion(uniqueid, c, false, question, type, buttons); diff --git a/src/script/api/script_goal.hpp b/src/script/api/script_goal.hpp index 72d61ccba2..d956d75ba7 100644 --- a/src/script/api/script_goal.hpp +++ b/src/script/api/script_goal.hpp @@ -28,7 +28,7 @@ public: /** * The goal IDs. */ - enum GoalID : uint16 { + enum GoalID : uint16_t { /* Note: these values represent part of the in-game GoalID enum */ GOAL_INVALID = ::INVALID_GOAL, ///< An invalid goal id. }; @@ -191,7 +191,7 @@ public: * @pre question != null && len(question) != 0. * @pre company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID. * @pre CountBits(buttons) >= 1 && CountBits(buttons) <= 3. - * @pre uniqueid >= 0 && uniqueid <= MAX(uint16) + * @pre uniqueid >= 0 && uniqueid <= MAX(uint16_t) * @note Replies to the question are given by you via the event ScriptEventGoalQuestionAnswer. * @note There is no guarantee you ever get a reply on your question. */ @@ -210,7 +210,7 @@ public: * @pre question != null && len(question) != 0. * @pre ResolveClientID(client) != CLIENT_INVALID. * @pre CountBits(buttons) >= 1 && CountBits(buttons) <= 3. - * @pre uniqueid >= 0 && uniqueid <= MAX(uint16) + * @pre uniqueid >= 0 && uniqueid <= MAX(uint16_t) * @note Replies to the question are given by you via the event ScriptEventGoalQuestionAnswer. * @note There is no guarantee you ever get a reply on your question. */ @@ -221,7 +221,7 @@ public: * @param uniqueid The uniqueid of the question you want to close. * @return True if the action succeeded. * @pre ScriptCompanyMode::IsDeity(). - * @pre uniqueid >= 0 && uniqueid <= MAX(uint16) + * @pre uniqueid >= 0 && uniqueid <= MAX(uint16_t) * @note If you send a question to a single company, and get a reply for them, * the question is already closed on all clients. Only use this function if * you want to timeout a question, or if you send the question to all @@ -233,7 +233,7 @@ protected: /** * Does common checks and asks the question. */ - static bool DoQuestion(SQInteger uniqueid, uint32 target, bool is_client, Text *question, QuestionType type, SQInteger buttons); + static bool DoQuestion(SQInteger uniqueid, uint32_t target, bool is_client, Text *question, QuestionType type, SQInteger buttons); }; #endif /* SCRIPT_GOAL_HPP */ diff --git a/src/script/api/script_group.cpp b/src/script/api/script_group.cpp index ba4eab3913..62888ac0af 100644 --- a/src/script/api/script_group.cpp +++ b/src/script/api/script_group.cpp @@ -201,8 +201,8 @@ { if (!IsValidGroup(group_id)) return -1; - uint32 occupancy = 0; - uint32 vehicle_count = 0; + uint32_t occupancy = 0; + uint32_t vehicle_count = 0; for (const Vehicle *v : Vehicle::Iterate()) { if (v->group_id != group_id) continue; diff --git a/src/script/api/script_industrytype.cpp b/src/script/api/script_industrytype.cpp index 653f696cf1..7f97f47684 100644 --- a/src/script/api/script_industrytype.cpp +++ b/src/script/api/script_industrytype.cpp @@ -123,8 +123,8 @@ EnforcePrecondition(false, CanBuildIndustry(industry_type)); EnforcePrecondition(false, ScriptMap::IsValidTile(tile)); - uint32 seed = ScriptBase::Rand(); - uint32 layout_index = ScriptBase::RandRange((uint32)::GetIndustrySpec(industry_type)->layouts.size()); + uint32_t seed = ScriptBase::Rand(); + uint32_t layout_index = ScriptBase::RandRange((uint32_t)::GetIndustrySpec(industry_type)->layouts.size()); return ScriptObject::Command::Do(tile, industry_type, layout_index, true, seed); } @@ -133,7 +133,7 @@ EnforceDeityOrCompanyModeValid(false); EnforcePrecondition(false, CanProspectIndustry(industry_type)); - uint32 seed = ScriptBase::Rand(); + uint32_t seed = ScriptBase::Rand(); return ScriptObject::Command::Do(0, industry_type, 0, false, seed); } diff --git a/src/script/api/script_info_docs.hpp b/src/script/api/script_info_docs.hpp index cae5852180..902fc7357a 100644 --- a/src/script/api/script_info_docs.hpp +++ b/src/script/api/script_info_docs.hpp @@ -219,26 +219,26 @@ public: * - description A single line describing the setting. Required. * - min_value The minimum value of this setting. Required for integer * settings and not allowed for boolean settings. The value will be - * clamped in the range [MIN(int32), MAX(int32)] (inclusive). + * clamped in the range [MIN(int32_t), MAX(int32_t)] (inclusive). * - max_value The maximum value of this setting. Required for integer * settings and not allowed for boolean settings. The value will be - * clamped in the range [MIN(int32), MAX(int32)] (inclusive). + * clamped in the range [MIN(int32_t), MAX(int32_t)] (inclusive). * - easy_value The default value if the easy difficulty level * is selected. Required. The value will be clamped in the range - * [MIN(int32), MAX(int32)] (inclusive). + * [MIN(int32_t), MAX(int32_t)] (inclusive). * - medium_value The default value if the medium difficulty level * is selected. Required. The value will be clamped in the range - * [MIN(int32), MAX(int32)] (inclusive). + * [MIN(int32_t), MAX(int32_t)] (inclusive). * - hard_value The default value if the hard difficulty level * is selected. Required. The value will be clamped in the range - * [MIN(int32), MAX(int32)] (inclusive). + * [MIN(int32_t), MAX(int32_t)] (inclusive). * - custom_value The default value if the custom difficulty level * is selected. Required. The value will be clamped in the range - * [MIN(int32), MAX(int32)] (inclusive). + * [MIN(int32_t), MAX(int32_t)] (inclusive). * - random_deviation If this property has a nonzero value, then the * actual value of the setting in game will be randomized in the range * [user_configured_value - random_deviation, user_configured_value + random_deviation] (inclusive). - * random_deviation sign is ignored and the value is clamped in the range [0, MAX(int32)] (inclusive). + * random_deviation sign is ignored and the value is clamped in the range [0, MAX(int32_t)] (inclusive). * Not allowed if the CONFIG_RANDOM flag is set, otherwise optional. * - step_size The increase/decrease of the value every time the user * clicks one of the up/down arrow buttons. Optional, default is 1. diff --git a/src/script/api/script_infrastructure.cpp b/src/script/api/script_infrastructure.cpp index 0a9de4f34e..bfe78a7b58 100644 --- a/src/script/api/script_infrastructure.cpp +++ b/src/script/api/script_infrastructure.cpp @@ -42,7 +42,7 @@ ::Company *c = ::Company::Get((::CompanyID)company); switch (infra_type) { case INFRASTRUCTURE_RAIL: { - uint32 count = 0; + uint32_t count = 0; for (::RailType rt = ::RAILTYPE_BEGIN; rt != ::RAILTYPE_END; rt++) { count += c->infrastructure.rail[rt]; } @@ -53,7 +53,7 @@ return c->infrastructure.signal; case INFRASTRUCTURE_ROAD: { - uint32 count = 0; + uint32_t count = 0; for (::RoadType rt = ::ROADTYPE_BEGIN; rt != ::ROADTYPE_END; rt++) { count += c->infrastructure.road[rt]; } @@ -101,7 +101,7 @@ switch (infra_type) { case INFRASTRUCTURE_RAIL: { Money cost; - uint32 rail_total = c->infrastructure.GetRailTotal(); + uint32_t rail_total = c->infrastructure.GetRailTotal(); for (::RailType rt = ::RAILTYPE_BEGIN; rt != ::RAILTYPE_END; rt++) { cost += RailMaintenanceCost(rt, c->infrastructure.rail[rt], rail_total); } @@ -113,7 +113,7 @@ case INFRASTRUCTURE_ROAD: { Money cost; - uint32 road_total = c->infrastructure.GetRoadTotal(); + uint32_t road_total = c->infrastructure.GetRoadTotal(); for (::RoadType rt = ::ROADTYPE_BEGIN; rt != ::ROADTYPE_END; rt++) { cost += RoadMaintenanceCost(rt, c->infrastructure.road[rt], road_total); } diff --git a/src/script/api/script_news.cpp b/src/script/api/script_news.cpp index 7f0968db90..93462436f0 100644 --- a/src/script/api/script_news.cpp +++ b/src/script/api/script_news.cpp @@ -36,7 +36,7 @@ (ref_type == NR_INDUSTRY && ScriptIndustry::IsValidIndustry(reference)) || (ref_type == NR_TOWN && ScriptTown::IsValidTown(reference))); - uint8 c = company; + uint8_t c = company; if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY; if (ref_type == NR_NONE) reference = 0; diff --git a/src/script/api/script_rail.cpp b/src/script/api/script_rail.cpp index 5f97941ebd..b703b8ce07 100644 --- a/src/script/api/script_rail.cpp +++ b/src/script/api/script_rail.cpp @@ -176,7 +176,7 @@ EnforcePrecondition(false, goal_industry == ScriptIndustryType::INDUSTRYTYPE_UNKNOWN || goal_industry == ScriptIndustryType::INDUSTRYTYPE_TOWN || ScriptIndustryType::IsValidIndustryType(goal_industry)); const GRFFile *file; - uint16 res = GetAiPurchaseCallbackResult( + uint16_t res = GetAiPurchaseCallbackResult( GSF_STATIONS, cargo_id, 0, diff --git a/src/script/api/script_road.cpp b/src/script/api/script_road.cpp index 8eeeb45dfe..d17ba9638f 100644 --- a/src/script/api/script_road.cpp +++ b/src/script/api/script_road.cpp @@ -150,7 +150,7 @@ * @param end The part that will be build second. * @return True if and only if the road bits can be build. */ -static bool CheckAutoExpandedRoadBits(const Array<> &existing, int32 start, int32 end) +static bool CheckAutoExpandedRoadBits(const Array<> &existing, int32_t start, int32_t end) { return (start + end == 0) && (existing.empty() || existing[0] == start || existing[0] == end); } @@ -165,7 +165,7 @@ static bool CheckAutoExpandedRoadBits(const Array<> &existing, int32 start, int3 * they are build or 2 when building the first part automatically * builds the second part. */ -static int32 LookupWithoutBuildOnSlopes(::Slope slope, const Array<> &existing, int32 start, int32 end) +static int32_t LookupWithoutBuildOnSlopes(::Slope slope, const Array<> &existing, int32_t start, int32_t end) { switch (slope) { /* Flat slopes can always be build. */ @@ -192,7 +192,7 @@ static int32 LookupWithoutBuildOnSlopes(::Slope slope, const Array<> &existing, * @param neighbour The neighbour. * @return The rotate neighbour data. */ -static int32 RotateNeighbour(int32 neighbour) +static int32_t RotateNeighbour(int32_t neighbour) { switch (neighbour) { case -2: return -1; @@ -208,7 +208,7 @@ static int32 RotateNeighbour(int32 neighbour) * @param neighbour The neighbour. * @return The bits representing the direction. */ -static RoadBits NeighbourToRoadBits(int32 neighbour) +static RoadBits NeighbourToRoadBits(int32_t neighbour) { switch (neighbour) { case -2: return ROAD_NW; @@ -229,7 +229,7 @@ static RoadBits NeighbourToRoadBits(int32 neighbour) * they are build or 2 when building the first part automatically * builds the second part. */ -static int32 LookupWithBuildOnSlopes(::Slope slope, const Array<> &existing, int32 start, int32 end) +static int32_t LookupWithBuildOnSlopes(::Slope slope, const Array<> &existing, int32_t start, int32_t end) { /* Steep slopes behave the same as slopes with one corner raised. */ if (IsSteepSlope(slope)) { @@ -287,7 +287,7 @@ static int32 LookupWithBuildOnSlopes(::Slope slope, const Array<> &existing, int RoadBits start_roadbits = NeighbourToRoadBits(start); RoadBits new_roadbits = start_roadbits | NeighbourToRoadBits(end); RoadBits existing_roadbits = ROAD_NONE; - for (int32 neighbour : existing) { + for (int32_t neighbour : existing) { for (int j = 0; j < base_rotate; j++) { neighbour = RotateNeighbour(neighbour); } @@ -365,7 +365,7 @@ static int32 LookupWithBuildOnSlopes(::Slope slope, const Array<> &existing, int * @param tile The tile to normalise. * @return True if and only if the tile offset is valid. */ -static bool NormaliseTileOffset(int32 *tile) +static bool NormaliseTileOffset(int32_t *tile) { if (*tile == 1 || *tile == -1) return true; if (*tile == ::TileDiffXY(0, -1)) { @@ -382,8 +382,8 @@ static bool NormaliseTileOffset(int32 *tile) /* static */ SQInteger ScriptRoad::CanBuildConnectedRoadParts(ScriptTile::Slope slope_, Array<> &&existing, TileIndex start_, TileIndex end_) { ::Slope slope = (::Slope)slope_; - int32 start = start_; - int32 end = end_; + int32_t start = start_; + int32_t end = end_; /* The start tile and end tile cannot be the same tile either. */ if (start == end) return -1; @@ -457,7 +457,7 @@ static bool NeighbourHasReachableRoad(::RoadType rt, TileIndex start_tile, DiagD if (!IsRoadTypeAvailable(GetCurrentRoadType())) return -1; ::RoadType rt = (::RoadType)GetCurrentRoadType(); - int32 neighbour = 0; + int32_t neighbour = 0; if (TileX(tile) > 0 && NeighbourHasReachableRoad(rt, tile, DIAGDIR_NE)) neighbour++; if (NeighbourHasReachableRoad(rt, tile, DIAGDIR_SE)) neighbour++; diff --git a/src/script/api/script_road.hpp b/src/script/api/script_road.hpp index 4b5c15236f..007c44adce 100644 --- a/src/script/api/script_road.hpp +++ b/src/script/api/script_road.hpp @@ -61,7 +61,7 @@ public: /** * Road/tram types */ - enum RoadTramTypes : uint8 { + enum RoadTramTypes : uint8_t { ROADTRAMTYPES_ROAD = ::RTTB_ROAD, ///< Road road types. ROADTRAMTYPES_TRAM = ::RTTB_TRAM, ///< Tram road types. }; diff --git a/src/script/api/script_station.cpp b/src/script/api/script_station.cpp index fd837bb717..ed153a4605 100644 --- a/src/script/api/script_station.cpp +++ b/src/script/api/script_station.cpp @@ -62,7 +62,7 @@ template const StationCargoList &cargo_list = ::Station::Get(station_id)->goods[cargo_id].cargo; if (!Tfrom && !Tvia) return cargo_list.TotalCount(); - uint16 cargo_count = 0; + uint16_t cargo_count = 0; std::pair range = Tvia ? cargo_list.Packets()->equal_range(via_station_id) : std::make_pair(StationCargoList::ConstIterator(cargo_list.Packets()->begin()), diff --git a/src/script/api/script_story_page.cpp b/src/script/api/script_story_page.cpp index c86896f30e..bd83125c25 100644 --- a/src/script/api/script_story_page.cpp +++ b/src/script/api/script_story_page.cpp @@ -45,7 +45,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) EnforceDeityMode(STORY_PAGE_INVALID); EnforcePrecondition(STORY_PAGE_INVALID, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID); - uint8 c = company; + uint8_t c = company; if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY; if (!ScriptObject::Command::Do(&ScriptInstance::DoCommandReturnStoryPageID, @@ -73,7 +73,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, type != SPET_GOAL || ScriptGoal::IsValidGoal((ScriptGoal::GoalID)reference)); EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, type != SPET_GOAL || !(StoryPage::Get(story_page_id)->company == INVALID_COMPANY && Goal::Get(reference)->company != INVALID_COMPANY)); - uint32 refid = 0; + uint32_t refid = 0; TileIndex reftile = 0; switch (type) { case SPET_LOCATION: @@ -122,7 +122,7 @@ static inline bool StoryPageElementTypeRequiresText(StoryPageElementType type) EnforcePrecondition(false, type != ::SPET_GOAL || ScriptGoal::IsValidGoal((ScriptGoal::GoalID)reference)); EnforcePrecondition(false, type != ::SPET_GOAL || !(p->company == INVALID_COMPANY && Goal::Get(reference)->company != INVALID_COMPANY)); - uint32 refid = 0; + uint32_t refid = 0; TileIndex reftile = 0; switch (type) { case ::SPET_LOCATION: diff --git a/src/script/api/script_story_page.hpp b/src/script/api/script_story_page.hpp index 2e878ede5e..c51c4c9363 100644 --- a/src/script/api/script_story_page.hpp +++ b/src/script/api/script_story_page.hpp @@ -69,7 +69,7 @@ public: /** * Formatting data for button page elements. */ - typedef uint32 StoryPageButtonFormatting; + typedef uint32_t StoryPageButtonFormatting; /** * Formatting and layout flags for story page buttons. diff --git a/src/script/api/script_storypagelist.cpp b/src/script/api/script_storypagelist.cpp index 63f835ada9..9bff9e4eb7 100644 --- a/src/script/api/script_storypagelist.cpp +++ b/src/script/api/script_storypagelist.cpp @@ -16,7 +16,7 @@ ScriptStoryPageList::ScriptStoryPageList(ScriptCompany::CompanyID company) { - uint8 c = company; + uint8_t c = company; if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY; for (StoryPage *p : StoryPage::Iterate()) { diff --git a/src/script/api/script_text.cpp b/src/script/api/script_text.cpp index b574e8e5fe..834c77e137 100644 --- a/src/script/api/script_text.cpp +++ b/src/script/api/script_text.cpp @@ -133,7 +133,7 @@ SQInteger ScriptText::AddParam(HSQUIRRELVM vm) SQInteger ScriptText::_set(HSQUIRRELVM vm) { - int32 k; + int32_t k; if (sq_gettype(vm, 2) == OT_STRING) { const SQChar *key_string; @@ -146,7 +146,7 @@ SQInteger ScriptText::_set(HSQUIRRELVM vm) } else if (sq_gettype(vm, 2) == OT_INTEGER) { SQInteger key; sq_getinteger(vm, 2, &key); - k = (int32)key; + k = (int32_t)key; } else { return SQ_ERROR; } diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp index b250fa8b65..3e023b92dc 100644 --- a/src/script/api/script_town.cpp +++ b/src/script/api/script_town.cpp @@ -160,7 +160,7 @@ { EnforceDeityMode(false); EnforcePrecondition(false, IsValidTown(town_id)); - uint16 growth_rate; + uint16_t growth_rate; switch (days_between_town_growth) { case TOWN_GROWTH_NORMAL: growth_rate = 0; @@ -206,7 +206,7 @@ if (!IsValidTown(town_id)) return false; const Town *t = ::Town::Get(town_id); - return ((uint32)GetDistanceSquareToTile(town_id, tile) <= t->cache.squared_town_zone_radius[0]); + return ((uint32_t)GetDistanceSquareToTile(town_id, tile) <= t->cache.squared_town_zone_radius[0]); } /* static */ bool ScriptTown::HasStatue(TownID town_id) @@ -243,7 +243,7 @@ EnforceCompanyModeValid(ScriptCompany::COMPANY_INVALID); if (!IsValidTown(town_id)) return ScriptCompany::COMPANY_INVALID; - return (ScriptCompany::CompanyID)(int8)::Town::Get(town_id)->exclusivity; + return (ScriptCompany::CompanyID)(int8_t)::Town::Get(town_id)->exclusivity; } /* static */ SQInteger ScriptTown::GetExclusiveRightsDuration(TownID town_id) @@ -302,7 +302,7 @@ text = name->GetDecodedText(); EnforcePreconditionCustomError(false, ::Utf8StringLength(text) < MAX_LENGTH_TOWN_NAME_CHARS, ScriptError::ERR_PRECONDITION_STRING_TOO_LONG); } - uint32 townnameparts; + uint32_t townnameparts; if (!GenerateTownName(ScriptObject::GetRandomizer(), &townnameparts)) { ScriptObject::SetLastError(ScriptError::ERR_NAME_IS_NOT_UNIQUE); return false; @@ -357,7 +357,7 @@ EnforcePrecondition(false, company != ScriptCompany::COMPANY_INVALID); const Town *t = ::Town::Get(town_id); - int16 new_rating = Clamp(t->ratings[company] + delta, RATING_MINIMUM, RATING_MAXIMUM); + int16_t new_rating = Clamp(t->ratings[company] + delta, RATING_MINIMUM, RATING_MAXIMUM); if (new_rating == t->ratings[company]) return false; return ScriptObject::Command::Do(town_id, (::CompanyID)company_id, new_rating); diff --git a/src/script/api/script_town.hpp b/src/script/api/script_town.hpp index b23840024b..0c13ef8914 100644 --- a/src/script/api/script_town.hpp +++ b/src/script/api/script_town.hpp @@ -235,7 +235,7 @@ public: * @param town_id The index of the town. * @param towneffect_id The index of the towneffect. * @param goal The new goal. - * The value will be clamped to 0 .. MAX(uint32). + * The value will be clamped to 0 .. MAX(uint32_t). * @pre IsValidTown(town_id). * @pre ScriptCargo::IsValidTownEffect(towneffect_id). * @pre ScriptCompanyMode::IsDeity(). @@ -392,7 +392,7 @@ public: * Expand the town. * @param town_id The town to expand. * @param houses The amount of houses to grow the town with. - * The value will be clamped to 0 .. MAX(uint32). + * The value will be clamped to 0 .. MAX(uint32_t). * @pre IsValidTown(town_id). * @pre houses > 0. * @pre ScriptCompanyMode::IsDeity(). diff --git a/src/script/api/script_types.hpp b/src/script/api/script_types.hpp index a570aabf7d..d353cc291d 100644 --- a/src/script/api/script_types.hpp +++ b/src/script/api/script_types.hpp @@ -89,20 +89,20 @@ typedef uint BridgeType; ///< Internal name, not of any use for you. typedef byte CargoID; ///< The ID of a cargo. class CommandCost; ///< The cost of a command. -typedef uint16 EngineID; ///< The ID of an engine. -typedef uint16 GoalID; ///< The ID of a goal. -typedef uint16 GroupID; ///< The ID of a group. -typedef uint16 IndustryID; ///< The ID of an industry. -typedef uint8 IndustryType; ///< The ID of an industry-type. +typedef uint16_t EngineID; ///< The ID of an engine. +typedef uint16_t GoalID; ///< The ID of a goal. +typedef uint16_t GroupID; ///< The ID of a group. +typedef uint16_t IndustryID; ///< The ID of an industry. +typedef uint8_t IndustryType; ///< The ID of an industry-type. typedef OverflowSafeInt64 Money; ///< Money, stored in a 32bit/64bit safe way. For scripts money is always in pounds. -typedef uint16 SignID; ///< The ID of a sign. -typedef uint16 StationID; ///< The ID of a station. -typedef uint32 StringID; ///< The ID of a string. -typedef uint16 SubsidyID; ///< The ID of a subsidy. -typedef uint16 StoryPageID; ///< The ID of a story page. -typedef uint16 StoryPageElementID; ///< The ID of a story page element. -typedef uint16 TownID; ///< The ID of a town. -typedef uint32 VehicleID; ///< The ID of a vehicle. +typedef uint16_t SignID; ///< The ID of a sign. +typedef uint16_t StationID; ///< The ID of a station. +typedef uint32_t StringID; ///< The ID of a string. +typedef uint16_t SubsidyID; ///< The ID of a subsidy. +typedef uint16_t StoryPageID; ///< The ID of a story page. +typedef uint16_t StoryPageElementID; ///< The ID of a story page element. +typedef uint16_t TownID; ///< The ID of a town. +typedef uint32_t VehicleID; ///< The ID of a vehicle. /* Types we defined ourself, as the OpenTTD core doesn't have them (yet) */ typedef uint ScriptErrorType;///< The types of errors inside the script framework. diff --git a/src/script/api/script_vehicle.cpp b/src/script/api/script_vehicle.cpp index e4d6abff2c..7db46acc5d 100644 --- a/src/script/api/script_vehicle.cpp +++ b/src/script/api/script_vehicle.cpp @@ -417,7 +417,7 @@ if (!IsValidVehicle(vehicle_id)) return -1; if (!ScriptCargo::IsValidCargo(cargo)) return -1; - uint32 amount = 0; + uint32_t amount = 0; for (const Vehicle *v = ::Vehicle::Get(vehicle_id); v != nullptr; v = v->Next()) { if (v->cargo_type == cargo) amount += v->cargo_cap; } @@ -430,7 +430,7 @@ if (!IsValidVehicle(vehicle_id)) return -1; if (!ScriptCargo::IsValidCargo(cargo)) return -1; - uint32 amount = 0; + uint32_t amount = 0; for (const Vehicle *v = ::Vehicle::Get(vehicle_id); v != nullptr; v = v->Next()) { if (v->cargo_type == cargo) amount += v->cargo.StoredCount(); } diff --git a/src/script/api/script_window.hpp.in b/src/script/api/script_window.hpp.in index 65356b48eb..889b9dafaf 100644 --- a/src/script/api/script_window.hpp.in +++ b/src/script/api/script_window.hpp.in @@ -81,7 +81,7 @@ public: * Close a window. * @param window The class of the window to close. * @param number The number of the window to close, or NUMBER_ALL to close all of this class. - * The value will be clamped to 0 .. MAX(int32) when value is not NUMBER_ALL. + * The value will be clamped to 0 .. MAX(int32_t) when value is not NUMBER_ALL. * @pre !ScriptGame::IsMultiplayer(). */ static void Close(WindowClass window, SQInteger number); @@ -90,7 +90,7 @@ public: * Check if a window is open. * @param window The class of the window to check for. * @param number The number of the window to check for, or NUMBER_ALL to check for any in the class. - * The value will be clamped to 0 .. MAX(int32) when value is not NUMBER_ALL. + * The value will be clamped to 0 .. MAX(int32_t) when value is not NUMBER_ALL. * @pre !ScriptGame::IsMultiplayer(). * @return True if the window is open. */ @@ -100,9 +100,9 @@ public: * Highlight a widget in a window. * @param window The class of the window to highlight a widget in. * @param number The number of the window to highlight a widget in. - * The value will be clamped to 0 .. MAX(int32) when value is not NUMBER_ALL. + * The value will be clamped to 0 .. MAX(int32_t) when value is not NUMBER_ALL. * @param widget The widget in the window to highlight, or WIDGET_ALL (in combination with TC_INVALID) to disable all widget highlighting on this window. - * The value will be clamped to 0 .. MAX(uint8) when value is not WIDGET_ALL. + * The value will be clamped to 0 .. MAX(uint8_t) when value is not WIDGET_ALL. * @param colour The colour of the highlight, or TC_INVALID for disabling. * @pre !ScriptGame::IsMultiplayer(). * @pre number != NUMBER_ALL. diff --git a/src/script/script_gui.cpp b/src/script/script_gui.cpp index e5001a73b0..cb9c01b01f 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -519,7 +519,7 @@ struct ScriptSettingsWindow : public Window { void OnQueryTextFinished(char *str) override { if (StrEmpty(str)) return; - int32 value = atoi(str); + int32_t value = atoi(str); SetValue(value); } diff --git a/src/script/script_instance.cpp b/src/script/script_instance.cpp index 32b8762e0d..84a9ee3a70 100644 --- a/src/script/script_instance.cpp +++ b/src/script/script_instance.cpp @@ -324,7 +324,7 @@ ScriptLogTypes::LogData &ScriptInstance::GetLogData() * First 1 byte indicating if there is a data blob at all. * 1 byte indicating the type of data. * The data itself, this differs per type: - * - integer: a binary representation of the integer (int32). + * - integer: a binary representation of the integer (int32_t). * - string: First one byte with the string length, then a 0-terminated char * array. The string can't be longer than 255 bytes (including * terminating '\0'). @@ -363,7 +363,7 @@ static const SaveLoad _script_byte[] = { SQInteger res; sq_getinteger(vm, index, &res); if (!test) { - int64 value = (int64)res; + int64_t value = (int64_t)res; SlCopy(&value, 1, SLE_INT64); } return true; @@ -563,7 +563,7 @@ bool ScriptInstance::IsPaused() SlObject(nullptr, _script_byte); switch (_script_sl_byte) { case SQSL_INT: { - int64 value; + int64_t value; SlCopy(&value, 1, IsSavegameVersionBefore(SLV_SCRIPT_INT64) ? SLE_FILE_I32 | SLE_VAR_I64 : SLE_INT64); if (data != nullptr) data->push_back((SQInteger)value); return true; diff --git a/src/script/script_scanner.cpp b/src/script/script_scanner.cpp index bb5bd413fc..52625c6515 100644 --- a/src/script/script_scanner.cpp +++ b/src/script/script_scanner.cpp @@ -164,7 +164,7 @@ struct ScriptFileChecksumCreator : FileScanner { virtual bool AddFile(const std::string &filename, size_t basepath_length, const std::string &tar_filename) { Md5 checksum; - uint8 buffer[1024]; + uint8_t buffer[1024]; size_t len, size; /* Open the file ... */ @@ -199,7 +199,7 @@ struct ScriptFileChecksumCreator : FileScanner { */ static bool IsSameScript(const ContentInfo *ci, bool md5sum, ScriptInfo *info, Subdirectory dir) { - uint32 id = 0; + uint32_t id = 0; const char *str = info->GetShortName().c_str(); for (int j = 0; j < 4 && *str != '\0'; j++, str++) id |= *str << (8 * j); diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp index 2ce61cdd48..b2e62dc727 100644 --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -568,14 +568,14 @@ public: } }; -static WChar _io_file_lexfeed_ASCII(SQUserPointer file) +static char32_t _io_file_lexfeed_ASCII(SQUserPointer file) { unsigned char c; if (((SQFile *)file)->Read(&c, sizeof(c), 1) > 0) return c; return 0; } -static WChar _io_file_lexfeed_UTF8(SQUserPointer file) +static char32_t _io_file_lexfeed_UTF8(SQUserPointer file) { char buffer[5]; @@ -588,25 +588,25 @@ static WChar _io_file_lexfeed_UTF8(SQUserPointer file) if (len > 1 && ((SQFile *)file)->Read(buffer + 1, sizeof(buffer[0]), len - 1) != len - 1) return 0; /* Convert the character, and when definitely invalid, bail out as well. */ - WChar c; + char32_t c; if (Utf8Decode(&c, buffer) != len) return -1; return c; } -static WChar _io_file_lexfeed_UCS2_no_swap(SQUserPointer file) +static char32_t _io_file_lexfeed_UCS2_no_swap(SQUserPointer file) { unsigned short c; - if (((SQFile *)file)->Read(&c, sizeof(c), 1) > 0) return (WChar)c; + if (((SQFile *)file)->Read(&c, sizeof(c), 1) > 0) return (char32_t)c; return 0; } -static WChar _io_file_lexfeed_UCS2_swap(SQUserPointer file) +static char32_t _io_file_lexfeed_UCS2_swap(SQUserPointer file) { unsigned short c; if (((SQFile *)file)->Read(&c, sizeof(c), 1) > 0) { c = ((c >> 8) & 0x00FF)| ((c << 8) & 0xFF00); - return (WChar)c; + return (char32_t)c; } return 0; } diff --git a/src/script/squirrel_helper.hpp b/src/script/squirrel_helper.hpp index c20f76815f..bedf484f62 100644 --- a/src/script/squirrel_helper.hpp +++ b/src/script/squirrel_helper.hpp @@ -29,15 +29,15 @@ namespace SQConvert { */ template struct Return; - template <> struct Return { static inline int Set(HSQUIRRELVM vm, uint8 res) { sq_pushinteger(vm, (int32)res); return 1; } }; - template <> struct Return { static inline int Set(HSQUIRRELVM vm, uint16 res) { sq_pushinteger(vm, (int32)res); return 1; } }; - template <> struct Return { static inline int Set(HSQUIRRELVM vm, uint32 res) { sq_pushinteger(vm, (int32)res); return 1; } }; - template <> struct Return { static inline int Set(HSQUIRRELVM vm, int8 res) { sq_pushinteger(vm, res); return 1; } }; - template <> struct Return { static inline int Set(HSQUIRRELVM vm, int16 res) { sq_pushinteger(vm, res); return 1; } }; - template <> struct Return { static inline int Set(HSQUIRRELVM vm, int32 res) { sq_pushinteger(vm, res); return 1; } }; - template <> struct Return { static inline int Set(HSQUIRRELVM vm, int64 res) { sq_pushinteger(vm, res); return 1; } }; + template <> struct Return { static inline int Set(HSQUIRRELVM vm, uint8_t res) { sq_pushinteger(vm, (int32_t)res); return 1; } }; + template <> struct Return { static inline int Set(HSQUIRRELVM vm, uint16_t res) { sq_pushinteger(vm, (int32_t)res); return 1; } }; + template <> struct Return { static inline int Set(HSQUIRRELVM vm, uint32_t res) { sq_pushinteger(vm, (int32_t)res); return 1; } }; + template <> struct Return { static inline int Set(HSQUIRRELVM vm, int8_t res) { sq_pushinteger(vm, res); return 1; } }; + template <> struct Return { static inline int Set(HSQUIRRELVM vm, int16_t res) { sq_pushinteger(vm, res); return 1; } }; + template <> struct Return { static inline int Set(HSQUIRRELVM vm, int32_t res) { sq_pushinteger(vm, res); return 1; } }; + template <> struct Return { static inline int Set(HSQUIRRELVM vm, int64_t res) { sq_pushinteger(vm, res); return 1; } }; template <> struct Return { static inline int Set(HSQUIRRELVM vm, Money res) { sq_pushinteger(vm, res); return 1; } }; - template <> struct Return { static inline int Set(HSQUIRRELVM vm, TileIndex res) { sq_pushinteger(vm, (int32)res.value); return 1; } }; + template <> struct Return { static inline int Set(HSQUIRRELVM vm, TileIndex res) { sq_pushinteger(vm, (int32_t)res.value); return 1; } }; template <> struct Return { static inline int Set(HSQUIRRELVM vm, bool res) { sq_pushbool (vm, res); return 1; } }; template <> struct Return { /* Do not use char *, use std::optional instead. */ }; template <> struct Return { /* Do not use const char *, use std::optional instead. */ }; @@ -61,14 +61,14 @@ namespace SQConvert { */ template struct Param; - template <> struct Param { static inline uint8 Get(HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } }; - template <> struct Param { static inline uint16 Get(HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } }; - template <> struct Param { static inline uint32 Get(HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } }; - template <> struct Param { static inline int8 Get(HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } }; - template <> struct Param { static inline int16 Get(HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } }; - template <> struct Param { static inline int32 Get(HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } }; - template <> struct Param { static inline int64 Get(HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } }; - template <> struct Param { static inline TileIndex Get(HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return TileIndex((uint32)(int32)tmp); } }; + template <> struct Param { static inline uint8_t Get(HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } }; + template <> struct Param { static inline uint16_t Get(HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } }; + template <> struct Param { static inline uint32_t Get(HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } }; + template <> struct Param { static inline int8_t Get(HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } }; + template <> struct Param { static inline int16_t Get(HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } }; + template <> struct Param { static inline int32_t Get(HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } }; + template <> struct Param { static inline int64_t Get(HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } }; + template <> struct Param { static inline TileIndex Get(HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return TileIndex((uint32_t)(int32_t)tmp); } }; template <> struct Param { static inline Money Get(HSQUIRRELVM vm, int index) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } }; template <> struct Param { static inline bool Get(HSQUIRRELVM vm, int index) { SQBool tmp; sq_getbool (vm, index, &tmp); return tmp != 0; } }; template <> struct Param { /* Do not use const char *, use std::string& instead. */ }; diff --git a/src/script/squirrel_helper_type.hpp b/src/script/squirrel_helper_type.hpp index 3cb2c2a142..9fa6a0aa6e 100644 --- a/src/script/squirrel_helper_type.hpp +++ b/src/script/squirrel_helper_type.hpp @@ -12,7 +12,7 @@ /** Definition of a simple array. */ -template +template using Array = std::vector; #endif /* SQUIRREL_HELPER_TYPE_HPP */ diff --git a/src/settings.cpp b/src/settings.cpp index 75e7d2cf91..2ed44dc339 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -154,7 +154,7 @@ public: * when we have to load/remove it from the old versus reading it from the new * location. These versions assist with situations like that. */ -enum IniFileVersion : uint32 { +enum IniFileVersion : uint32_t { IFV_0, ///< 0 All versions prior to introduction. IFV_PRIVATE_SECRETS, ///< 1 PR#9298 Moving of settings from openttd.cfg to private.cfg / secrets.cfg. IFV_GAME_TYPE, ///< 2 PR#9515 Convert server_advertise to server_game_type. @@ -166,7 +166,7 @@ enum IniFileVersion : uint32 { IFV_MAX_VERSION, ///< Highest possible ini-file version. }; -const uint16 INIFILE_VERSION = (IniFileVersion)(IFV_MAX_VERSION - 1); ///< Current ini-file version of OpenTTD. +const uint16_t INIFILE_VERSION = (IniFileVersion)(IFV_MAX_VERSION - 1); ///< Current ini-file version of OpenTTD. /** * Find the index value of a ONEofMANY type in a string separated by | @@ -227,7 +227,7 @@ static size_t LookupManyOfMany(const std::vector &many, const char r = OneOfManySettingDesc::ParseSingleValue(str, s - str, many); if (r == (size_t)-1) return r; - SetBit(res, (uint8)r); // value found, set it + SetBit(res, (uint8_t)r); // value found, set it if (*s == 0) break; str = s + 1; } @@ -311,12 +311,12 @@ static bool LoadIntList(const char *str, void *array, int nelems, VarType type) case SLE_VAR_I16: case SLE_VAR_U16: - for (i = 0; i != nitems; i++) ((uint16*)array)[i] = items[i]; + for (i = 0; i != nitems; i++) ((uint16_t*)array)[i] = items[i]; break; case SLE_VAR_I32: case SLE_VAR_U32: - for (i = 0; i != nitems; i++) ((uint32*)array)[i] = items[i]; + for (i = 0; i != nitems; i++) ((uint32_t*)array)[i] = items[i]; break; default: NOT_REACHED(); @@ -343,12 +343,12 @@ std::string ListSettingDesc::FormatValue(const void *object) const int64_t v; switch (GetVarMemType(this->save.conv)) { case SLE_VAR_BL: - case SLE_VAR_I8: v = *(const int8 *)p; p += 1; break; - case SLE_VAR_U8: v = *(const uint8 *)p; p += 1; break; - case SLE_VAR_I16: v = *(const int16 *)p; p += 2; break; - case SLE_VAR_U16: v = *(const uint16 *)p; p += 2; break; - case SLE_VAR_I32: v = *(const int32 *)p; p += 4; break; - case SLE_VAR_U32: v = *(const uint32 *)p; p += 4; break; + case SLE_VAR_I8: v = *(const int8_t *)p; p += 1; break; + case SLE_VAR_U8: v = *(const uint8_t *)p; p += 1; break; + case SLE_VAR_I16: v = *(const int16_t *)p; p += 2; break; + case SLE_VAR_U16: v = *(const uint16_t *)p; p += 2; break; + case SLE_VAR_I32: v = *(const int32_t *)p; p += 4; break; + case SLE_VAR_U32: v = *(const uint32_t *)p; p += 4; break; default: NOT_REACHED(); } if (i != 0) result += ','; @@ -454,7 +454,7 @@ size_t BoolSettingDesc::ParseValue(const char *str) const * @param object The object the setting is to be saved in. * @param val Signed version of the new value. */ -void IntSettingDesc::MakeValueValidAndWrite(const void *object, int32 val) const +void IntSettingDesc::MakeValueValidAndWrite(const void *object, int32_t val) const { this->MakeValueValid(val); this->Write(object, val); @@ -469,9 +469,9 @@ void IntSettingDesc::MakeValueValidAndWrite(const void *object, int32 val) const * However, for SF_GUI_DROPDOWN the default is used when the value is not valid. * @param val The value to make valid. */ -void IntSettingDesc::MakeValueValid(int32 &val) const +void IntSettingDesc::MakeValueValid(int32_t &val) const { - /* We need to take special care of the uint32 type as we receive from the function + /* We need to take special care of the uint32_t type as we receive from the function * a signed integer. While here also bail out on 64-bit settings as those are not * supported. Unsigned 8 and 16-bit variables are safe since they fit into a signed * 32-bit variable @@ -489,7 +489,7 @@ void IntSettingDesc::MakeValueValid(int32 &val) const if (!(this->flags & SF_GUI_DROPDOWN)) { /* Clamp value-type setting to its valid range */ val = Clamp(val, this->min, this->max); - } else if (val < this->min || val > (int32)this->max) { + } else if (val < this->min || val > (int32_t)this->max) { /* Reset invalid discrete setting (where different values change gameplay) to its default value */ val = this->def; } @@ -498,17 +498,17 @@ void IntSettingDesc::MakeValueValid(int32 &val) const } case SLE_VAR_U32: { /* Override the minimum value. No value below this->min, except special value 0 */ - uint32 uval = (uint32)val; + uint32_t uval = (uint32_t)val; if (!(this->flags & SF_GUI_0_IS_SPECIAL) || uval != 0) { if (!(this->flags & SF_GUI_DROPDOWN)) { /* Clamp value-type setting to its valid range */ uval = ClampU(uval, this->min, this->max); } else if (uval < (uint)this->min || uval > this->max) { /* Reset invalid discrete setting to its default value */ - uval = (uint32)this->def; + uval = (uint32_t)this->def; } } - val = (int32)uval; + val = (int32_t)uval; return; } case SLE_VAR_I64: @@ -522,10 +522,10 @@ void IntSettingDesc::MakeValueValid(int32 &val) const * @param object The object the setting is to be saved in. * @param val Signed version of the new value. */ -void IntSettingDesc::Write(const void *object, int32 val) const +void IntSettingDesc::Write(const void *object, int32_t val) const { void *ptr = GetVariableAddress(object, this->save); - WriteValue(ptr, this->save.conv, (int64)val); + WriteValue(ptr, this->save.conv, (int64_t)val); } /** @@ -533,10 +533,10 @@ void IntSettingDesc::Write(const void *object, int32 val) const * @param object The object the setting is to be saved in. * @return The value of the saved integer. */ -int32 IntSettingDesc::Read(const void *object) const +int32_t IntSettingDesc::Read(const void *object) const { void *ptr = GetVariableAddress(object, this->save); - return (int32)ReadValue(ptr, this->save.conv); + return (int32_t)ReadValue(ptr, this->save.conv); } /** @@ -626,7 +626,7 @@ static void IniLoadSettings(IniFile &ini, const SettingTable &settings_table, co void IntSettingDesc::ParseValue(const IniItem *item, void *object) const { size_t val = (item == nullptr) ? this->def : this->ParseValue(item->value.has_value() ? item->value->c_str() : ""); - this->MakeValueValidAndWrite(object, (int32)val); + this->MakeValueValidAndWrite(object, (int32_t)val); } void StringSettingDesc::ParseValue(const IniItem *item, void *object) const @@ -712,8 +712,8 @@ std::string BoolSettingDesc::FormatValue(const void *object) const bool IntSettingDesc::IsSameValue(const IniItem *item, void *object) const { - int32 item_value = (int32)this->ParseValue(item->value->c_str()); - int32 object_value = this->Read(object); + int32_t item_value = (int32_t)this->ParseValue(item->value->c_str()); + int32_t object_value = this->Read(object); return item_value == object_value; } @@ -951,7 +951,7 @@ static int DecodeHexNibble(char c) * @param dest_size Number of bytes in \a dest. * @return Whether reading was successful. */ -static bool DecodeHexText(const char *pos, uint8 *dest, size_t dest_size) +static bool DecodeHexText(const char *pos, uint8_t *dest, size_t dest_size) { while (dest_size > 0) { int hi = DecodeHexNibble(pos[0]); @@ -983,7 +983,7 @@ static GRFConfig *GRFLoadConfig(IniFile &ini, const char *grpname, bool is_stati for (item = group->item; item != nullptr; item = item->next) { GRFConfig *c = nullptr; - uint8 grfid_buf[4]; + uint8_t grfid_buf[4]; MD5Hash md5sum; const char *filename = item->name.c_str(); bool has_grfid = false; @@ -996,7 +996,7 @@ static GRFConfig *GRFLoadConfig(IniFile &ini, const char *grpname, bool is_stati has_md5sum = DecodeHexText(filename, md5sum.data(), md5sum.size()); if (has_md5sum) filename += 1 + 2 * md5sum.size(); - uint32 grfid = grfid_buf[0] | (grfid_buf[1] << 8) | (grfid_buf[2] << 16) | (grfid_buf[3] << 24); + uint32_t grfid = grfid_buf[0] | (grfid_buf[1] << 8) | (grfid_buf[2] << 16) | (grfid_buf[3] << 24); if (has_md5sum) { const GRFConfig *s = FindGRFConfig(grfid, FGCM_EXACT, &md5sum); if (s != nullptr) c = new GRFConfig(*s); @@ -1080,7 +1080,7 @@ static IniFileVersion LoadVersionFromConfig(IniFile &ini) /* Older ini-file versions don't have this key yet. */ if (version_number == nullptr || !version_number->value.has_value()) return IFV_0; - uint32 version = 0; + uint32_t version = 0; std::from_chars(version_number->value->data(), version_number->value->data() + version_number->value->size(), version); return static_cast(version); @@ -1483,9 +1483,9 @@ void DeleteGRFPresetFromConfig(const char *config_name) * @param object The object the setting is in. * @param newval The new value for the setting. */ -void IntSettingDesc::ChangeValue(const void *object, int32 newval) const +void IntSettingDesc::ChangeValue(const void *object, int32_t newval) const { - int32 oldval = this->Read(object); + int32_t oldval = this->Read(object); this->MakeValueValid(newval); if (this->pre_check != nullptr && !this->pre_check(newval)) return; if (oldval == newval) return; @@ -1591,7 +1591,7 @@ const SettingDesc *GetSettingFromName(const std::string_view name) * @return the cost of this operation or an error * @see _settings */ -CommandCost CmdChangeSetting(DoCommandFlag flags, const std::string &name, int32 value) +CommandCost CmdChangeSetting(DoCommandFlag flags, const std::string &name, int32_t value) { if (name.empty()) return CMD_ERROR; const SettingDesc *sd = GetSettingFromName(name); @@ -1617,7 +1617,7 @@ CommandCost CmdChangeSetting(DoCommandFlag flags, const std::string &name, int32 * The new value is properly clamped to its minimum/maximum when setting * @return the cost of this operation or an error */ -CommandCost CmdChangeCompanySetting(DoCommandFlag flags, const std::string &name, int32 value) +CommandCost CmdChangeCompanySetting(DoCommandFlag flags, const std::string &name, int32_t value) { if (name.empty()) return CMD_ERROR; const SettingDesc *sd = GetCompanySettingFromName(name); @@ -1639,7 +1639,7 @@ CommandCost CmdChangeCompanySetting(DoCommandFlag flags, const std::string &name * @param value new value of the setting * @param force_newgame force the newgame settings */ -bool SetSettingValue(const IntSettingDesc *sd, int32 value, bool force_newgame) +bool SetSettingValue(const IntSettingDesc *sd, int32_t value, bool force_newgame) { const IntSettingDesc *setting = sd->AsIntSetting(); if ((setting->flags & SF_PER_COMPANY) != 0) { @@ -1696,8 +1696,8 @@ void SyncCompanySettings() const void *new_object = &_settings_client.company; for (auto &desc : _company_settings) { const SettingDesc *sd = GetSettingDesc(desc); - uint32 old_value = (uint32)sd->AsIntSetting()->Read(old_object); - uint32 new_value = (uint32)sd->AsIntSetting()->Read(new_object); + uint32_t old_value = (uint32_t)sd->AsIntSetting()->Read(old_object); + uint32_t new_value = (uint32_t)sd->AsIntSetting()->Read(new_object); if (old_value != new_value) Command::SendNet(STR_NULL, _local_company, sd->GetName(), new_value); } } @@ -1760,7 +1760,7 @@ void IConsoleSetSetting(const char *name, const char *value, bool force_newgame) _settings_error_list.clear(); return; } - success = SetSettingValue(isd, (int32)val, force_newgame); + success = SetSettingValue(isd, (int32_t)val, force_newgame); } if (!success) { diff --git a/src/settings_cmd.h b/src/settings_cmd.h index d41f229e1b..3abb045b50 100644 --- a/src/settings_cmd.h +++ b/src/settings_cmd.h @@ -12,8 +12,8 @@ #include "command_type.h" -CommandCost CmdChangeSetting(DoCommandFlag flags, const std::string &name, int32 value); -CommandCost CmdChangeCompanySetting(DoCommandFlag flags, const std::string &name, int32 value); +CommandCost CmdChangeSetting(DoCommandFlag flags, const std::string &name, int32_t value); +CommandCost CmdChangeCompanySetting(DoCommandFlag flags, const std::string &name, int32_t value); DEF_CMD_TRAIT(CMD_CHANGE_SETTING, CmdChangeSetting, CMD_SERVER, CMDT_SERVER_SETTING) DEF_CMD_TRAIT(CMD_CHANGE_COMPANY_SETTING, CmdChangeCompanySetting, 0, CMDT_COMPANY_SETTING) diff --git a/src/settings_func.h b/src/settings_func.h index 198bab3e7d..490ce9605f 100644 --- a/src/settings_func.h +++ b/src/settings_func.h @@ -16,7 +16,7 @@ struct IniFile; void IConsoleSetSetting(const char *name, const char *value, bool force_newgame = false); -void IConsoleSetSetting(const char *name, int32 value); +void IConsoleSetSetting(const char *name, int32_t value); void IConsoleGetSetting(const char *name, bool force_newgame = false); void IConsoleListSettings(const char *prefilter); diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 95353e275b..e00e8d4a3c 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -206,7 +206,7 @@ struct GameOptionsWindow : Window { switch (widget) { case WID_GO_CURRENCY_DROPDOWN: { // Setup currencies dropdown *selected_index = this->opt->locale.currency; - uint64 disabled = _game_mode == GM_MENU ? 0LL : ~GetMaskOfAllowedCurrencies(); + uint64_t disabled = _game_mode == GM_MENU ? 0LL : ~GetMaskOfAllowedCurrencies(); /* Add non-custom currencies; sorted naturally */ for (const CurrencySpec ¤cy : _currency_specs) { @@ -1033,7 +1033,7 @@ struct SettingEntry : BaseSettingEntry { return this->setting->str_help; } - void SetValueDParams(uint first_param, int32 value) const; + void SetValueDParams(uint first_param, int32_t value) const; protected: virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const; @@ -1268,8 +1268,8 @@ bool SettingEntry::IsVisibleByRestrictionMode(RestrictionMode mode) const /* Read the current value. */ const void *object = ResolveObject(&GetGameSettings(), sd); - int64 current_value = sd->Read(object); - int64 filter_value; + int64_t current_value = sd->Read(object); + int64_t filter_value; if (mode == RM_CHANGED_AGAINST_DEFAULT) { /* This entry shall only be visible, if the value deviates from its default value. */ @@ -1346,7 +1346,7 @@ static const void *ResolveObject(const GameSettings *settings_ptr, const IntSett * @param first_param First DParam to use * @param value Setting value to set params for. */ -void SettingEntry::SetValueDParams(uint first_param, int32 value) const +void SettingEntry::SetValueDParams(uint first_param, int32_t value) const { if (this->setting->IsBoolSetting()) { SetDParam(first_param++, value != 0 ? STR_CONFIG_SETTING_ON : STR_CONFIG_SETTING_OFF); @@ -1386,7 +1386,7 @@ void SettingEntry::DrawSetting(GameSettings *settings_ptr, int left, int right, bool editable = sd->IsEditable(); SetDParam(0, STR_CONFIG_SETTING_VALUE); - int32 value = sd->Read(ResolveObject(settings_ptr, sd)); + int32_t value = sd->Read(ResolveObject(settings_ptr, sd)); if (sd->IsBoolSetting()) { /* Draw checkbox for boolean-value either on/off */ DrawBoolButton(buttons_left, button_y, value != 0, editable); @@ -1396,7 +1396,7 @@ void SettingEntry::DrawSetting(GameSettings *settings_ptr, int left, int right, } else { /* Draw [<][>] boxes for settings of an integer-type */ DrawArrowButtons(buttons_left, button_y, COLOUR_YELLOW, state, - editable && value != (sd->flags & SF_GUI_0_IS_SPECIAL ? 0 : sd->min), editable && (uint32)value != sd->max); + editable && value != (sd->flags & SF_GUI_0_IS_SPECIAL ? 0 : sd->min), editable && (uint32_t)value != sd->max); } this->SetValueDParams(1, value); DrawString(text_left, text_right, y + (SETTING_HEIGHT - FONT_HEIGHT_NORMAL) / 2, sd->str, highlight ? TC_WHITE : TC_LIGHT_BLUE); @@ -2360,7 +2360,7 @@ struct GameSettingsWindow : Window { return; } - int32 value = sd->Read(ResolveObject(settings_ptr, sd)); + int32_t value = sd->Read(ResolveObject(settings_ptr, sd)); /* clicked on the icon on the left side. Either scroller, bool on/off or dropdown */ if (x < SETTING_BUTTON_WIDTH && (sd->flags & SF_GUI_DROPDOWN)) { @@ -2401,7 +2401,7 @@ struct GameSettingsWindow : Window { this->SetDirty(); } else if (x < SETTING_BUTTON_WIDTH) { this->SetDisplayedHelpText(pe); - int32 oldvalue = value; + int32_t oldvalue = value; if (sd->IsBoolSetting()) { value ^= 1; @@ -2410,7 +2410,7 @@ struct GameSettingsWindow : Window { * 50-steps you should be able to get from min to max, * unless specified otherwise in the 'interval' variable * of the current setting. */ - uint32 step = (sd->interval == 0) ? ((sd->max - sd->min) / 50) : sd->interval; + uint32_t step = (sd->interval == 0) ? ((sd->max - sd->min) / 50) : sd->interval; if (step == 0) step = 1; /* don't allow too fast scrolling */ @@ -2423,10 +2423,10 @@ struct GameSettingsWindow : Window { if (x >= SETTING_BUTTON_WIDTH / 2) { value += step; if (sd->min < 0) { - assert((int32)sd->max >= 0); - if (value > (int32)sd->max) value = (int32)sd->max; + assert((int32_t)sd->max >= 0); + if (value > (int32_t)sd->max) value = (int32_t)sd->max; } else { - if ((uint32)value > sd->max) value = (int32)sd->max; + if ((uint32_t)value > sd->max) value = (int32_t)sd->max; } if (value < sd->min) value = sd->min; // skip between "disabled" and minimum } else { @@ -2453,7 +2453,7 @@ struct GameSettingsWindow : Window { } else { /* Only open editbox if clicked for the second time, and only for types where it is sensible for. */ if (this->last_clicked == pe && !sd->IsBoolSetting() && !(sd->flags & SF_GUI_DROPDOWN)) { - int64 value64 = value; + int64_t value64 = value; /* Show the correct currency-translated value */ if (sd->flags & SF_GUI_CURRENCY) value64 *= _currency->rate; @@ -2486,7 +2486,7 @@ struct GameSettingsWindow : Window { assert(this->valuewindow_entry != nullptr); const IntSettingDesc *sd = this->valuewindow_entry->setting; - int32 value; + int32_t value; if (!StrEmpty(str)) { long long llvalue = atoll(str); diff --git a/src/settings_internal.h b/src/settings_internal.h index d88a585076..9e07bacf13 100644 --- a/src/settings_internal.h +++ b/src/settings_internal.h @@ -13,7 +13,7 @@ #include #include "saveload/saveload.h" -enum SettingFlag : uint16 { +enum SettingFlag : uint16_t { SF_NONE = 0, SF_GUI_0_IS_SPECIAL = 1 << 0, ///< A value of zero is possible and has a custom string (the one after "strval"). SF_GUI_NEGATIVE_IS_SPECIAL = 1 << 1, ///< A negative value has another string (the one after "strval"). @@ -142,24 +142,24 @@ struct IntSettingDesc : SettingDesc { * @param value The prospective new value for the setting. * @return True when the setting is accepted. */ - typedef bool PreChangeCheck(int32 &value); + typedef bool PreChangeCheck(int32_t &value); /** * A callback to denote that a setting has been changed. * @param The new value for the setting. */ - typedef void PostChangeCallback(int32 value); + typedef void PostChangeCallback(int32_t value); - IntSettingDesc(const SaveLoad &save, SettingFlag flags, bool startup, int32 def, - int32 min, uint32 max, int32 interval, StringID str, StringID str_help, StringID str_val, + IntSettingDesc(const SaveLoad &save, SettingFlag flags, bool startup, int32_t def, + int32_t min, uint32_t max, int32_t interval, StringID str, StringID str_help, StringID str_val, SettingCategory cat, PreChangeCheck pre_check, PostChangeCallback post_callback) : SettingDesc(save, flags, startup), def(def), min(min), max(max), interval(interval), str(str), str_help(str_help), str_val(str_val), cat(cat), pre_check(pre_check), post_callback(post_callback) {} - int32 def; ///< default value given when none is present - int32 min; ///< minimum values - uint32 max; ///< maximum values - int32 interval; ///< the interval to use between settings in the 'settings' window. If interval is '0' the interval is dynamically determined + int32_t def; ///< default value given when none is present + int32_t min; ///< minimum values + uint32_t max; ///< maximum values + int32_t interval; ///< the interval to use between settings in the 'settings' window. If interval is '0' the interval is dynamically determined StringID str; ///< (translated) string with descriptive text; gui and console StringID str_help; ///< (Translated) string with help text; gui only. StringID str_val; ///< (Translated) first string describing the value. @@ -174,18 +174,18 @@ struct IntSettingDesc : SettingDesc { virtual bool IsBoolSetting() const { return false; } bool IsIntSetting() const override { return true; } - void ChangeValue(const void *object, int32 newvalue) const; - void MakeValueValidAndWrite(const void *object, int32 value) const; + void ChangeValue(const void *object, int32_t newvalue) const; + void MakeValueValidAndWrite(const void *object, int32_t value) const; virtual size_t ParseValue(const char *str) const; std::string FormatValue(const void *object) const override; void ParseValue(const IniItem *item, void *object) const override; bool IsSameValue(const IniItem *item, void *object) const override; - int32 Read(const void *object) const; + int32_t Read(const void *object) const; private: - void MakeValueValid(int32 &value) const; - void Write(const void *object, int32 value) const; + void MakeValueValid(int32_t &value) const; + void Write(const void *object, int32_t value) const; }; /** Boolean setting. */ @@ -207,8 +207,8 @@ struct BoolSettingDesc : IntSettingDesc { struct OneOfManySettingDesc : IntSettingDesc { typedef size_t OnConvert(const char *value); ///< callback prototype for conversion error - OneOfManySettingDesc(const SaveLoad &save, SettingFlag flags, bool startup, int32 def, - int32 max, StringID str, StringID str_help, StringID str_val, SettingCategory cat, + OneOfManySettingDesc(const SaveLoad &save, SettingFlag flags, bool startup, int32_t def, + int32_t max, StringID str, StringID str_help, StringID str_val, SettingCategory cat, PreChangeCheck pre_check, PostChangeCallback post_callback, std::initializer_list many, OnConvert *many_cnvt) : IntSettingDesc(save, flags, startup, def, 0, max, 0, str, str_help, str_val, cat, @@ -230,7 +230,7 @@ struct OneOfManySettingDesc : IntSettingDesc { /** Many of many setting. */ struct ManyOfManySettingDesc : OneOfManySettingDesc { ManyOfManySettingDesc(const SaveLoad &save, SettingFlag flags, bool startup, - int32 def, StringID str, StringID str_help, StringID str_val, SettingCategory cat, + int32_t def, StringID str, StringID str_help, StringID str_val, SettingCategory cat, PreChangeCheck pre_check, PostChangeCallback post_callback, std::initializer_list many, OnConvert *many_cnvt) : OneOfManySettingDesc(save, flags, startup, def, (1 << many.size()) - 1, str, str_help, @@ -258,12 +258,12 @@ struct StringSettingDesc : SettingDesc { typedef void PostChangeCallback(const std::string &value); StringSettingDesc(const SaveLoad &save, SettingFlag flags, bool startup, const char *def, - uint32 max_length, PreChangeCheck pre_check, PostChangeCallback post_callback) : + uint32_t max_length, PreChangeCheck pre_check, PostChangeCallback post_callback) : SettingDesc(save, flags, startup), def(def == nullptr ? "" : def), max_length(max_length), pre_check(pre_check), post_callback(post_callback) {} std::string def; ///< Default value given when none is present - uint32 max_length; ///< Maximum length of the string, 0 means no maximum length + uint32_t max_length; ///< Maximum length of the string, 0 means no maximum length PreChangeCheck *pre_check; ///< Callback to check for the validity of the setting. PostChangeCallback *post_callback; ///< Callback when the setting has been changed. @@ -318,7 +318,7 @@ typedef span SettingTable; const SettingDesc *GetSettingFromName(const std::string_view name); void GetSaveLoadFromSettingTable(SettingTable settings, std::vector &saveloads); -bool SetSettingValue(const IntSettingDesc *sd, int32 value, bool force_newgame = false); +bool SetSettingValue(const IntSettingDesc *sd, int32_t value, bool force_newgame = false); bool SetSettingValue(const StringSettingDesc *sd, const std::string value, bool force_newgame = false); #endif /* SETTINGS_INTERNAL_H */ diff --git a/src/settings_table.cpp b/src/settings_table.cpp index 72c2128810..29fe6c09e2 100644 --- a/src/settings_table.cpp +++ b/src/settings_table.cpp @@ -79,13 +79,13 @@ SettingTable _win32_settings{ _win32_settings_table }; /* Begin - Callback Functions for the various settings. */ /** Reposition the main toolbar as the setting changed. */ -static void v_PositionMainToolbar(int32 new_value) +static void v_PositionMainToolbar(int32_t new_value) { if (_game_mode != GM_MENU) PositionMainToolbar(nullptr); } /** Reposition the statusbar as the setting changed. */ -static void v_PositionStatusbar(int32 new_value) +static void v_PositionStatusbar(int32_t new_value) { if (_game_mode != GM_MENU) { PositionStatusbar(nullptr); @@ -98,7 +98,7 @@ static void v_PositionStatusbar(int32 new_value) * Redraw the smallmap after a colour scheme change. * @param new_value Callback parameter. */ -static void RedrawSmallmap(int32 new_value) +static void RedrawSmallmap(int32_t new_value) { BuildLandLegend(); BuildOwnerLegend(); @@ -106,19 +106,19 @@ static void RedrawSmallmap(int32 new_value) } /** Redraw linkgraph links after a colour scheme change. */ -static void UpdateLinkgraphColours(int32 new_value) +static void UpdateLinkgraphColours(int32_t new_value) { BuildLinkStatsLegend(); MarkWholeScreenDirty(); } -static void StationSpreadChanged(int32 new_value) +static void StationSpreadChanged(int32_t new_value) { InvalidateWindowData(WC_SELECT_STATION, 0); InvalidateWindowData(WC_BUILD_STATION, 0); } -static void UpdateConsists(int32 new_value) +static void UpdateConsists(int32_t new_value) { for (Train *t : Train::Iterate()) { /* Update the consist of all trains so the maximum speed is set correctly. */ @@ -131,7 +131,7 @@ static void UpdateConsists(int32 new_value) * Check and update if needed all vehicle service intervals. * @param new_value Contains 0 if service intervals are in days, otherwise intervals use percents. */ -static void UpdateAllServiceInterval(int32 new_value) +static void UpdateAllServiceInterval(int32_t new_value) { bool update_vehicles; VehicleDefaultSettings *vds; @@ -170,7 +170,7 @@ static void UpdateAllServiceInterval(int32 new_value) SetWindowClassesDirty(WC_VEHICLE_DETAILS); } -static bool CanUpdateServiceInterval(VehicleType type, int32 &new_value) +static bool CanUpdateServiceInterval(VehicleType type, int32_t &new_value) { VehicleDefaultSettings *vds; if (_game_mode == GM_MENU || !Company::IsValidID(_current_company)) { @@ -180,11 +180,11 @@ static bool CanUpdateServiceInterval(VehicleType type, int32 &new_value) } /* Test if the interval is valid */ - int32 interval = GetServiceIntervalClamped(new_value, vds->servint_ispercent); + int32_t interval = GetServiceIntervalClamped(new_value, vds->servint_ispercent); return interval == new_value; } -static void UpdateServiceInterval(VehicleType type, int32 new_value) +static void UpdateServiceInterval(VehicleType type, int32_t new_value) { if (_game_mode != GM_MENU && Company::IsValidID(_current_company)) { for (Vehicle *v : Vehicle::Iterate()) { @@ -197,7 +197,7 @@ static void UpdateServiceInterval(VehicleType type, int32 new_value) SetWindowClassesDirty(WC_VEHICLE_DETAILS); } -static void TrainAccelerationModelChanged(int32 new_value) +static void TrainAccelerationModelChanged(int32_t new_value) { for (Train *t : Train::Iterate()) { if (t->IsFrontEngine()) { @@ -216,7 +216,7 @@ static void TrainAccelerationModelChanged(int32 new_value) * This function updates the train acceleration cache after a steepness change. * @param new_value Unused new value of setting. */ -static void TrainSlopeSteepnessChanged(int32 new_value) +static void TrainSlopeSteepnessChanged(int32_t new_value) { for (Train *t : Train::Iterate()) { if (t->IsFrontEngine()) t->CargoChanged(); @@ -227,7 +227,7 @@ static void TrainSlopeSteepnessChanged(int32 new_value) * This function updates realistic acceleration caches when the setting "Road vehicle acceleration model" is set. * @param new_value Unused new value of setting. */ -static void RoadVehAccelerationModelChanged(int32 new_value) +static void RoadVehAccelerationModelChanged(int32_t new_value) { if (_settings_game.vehicle.roadveh_acceleration_model != AM_ORIGINAL) { for (RoadVehicle *rv : RoadVehicle::Iterate()) { @@ -247,14 +247,14 @@ static void RoadVehAccelerationModelChanged(int32 new_value) * This function updates the road vehicle acceleration cache after a steepness change. * @param new_value Unused new value of setting. */ -static void RoadVehSlopeSteepnessChanged(int32 new_value) +static void RoadVehSlopeSteepnessChanged(int32_t new_value) { for (RoadVehicle *rv : RoadVehicle::Iterate()) { if (rv->IsFrontEngine()) rv->CargoChanged(); } } -static void TownFoundingChanged(int32 new_value) +static void TownFoundingChanged(int32_t new_value) { if (_game_mode != GM_EDITOR && _settings_game.economy.found_town == TF_FORBIDDEN) { CloseWindowById(WC_FOUND_TOWN, 0); @@ -263,7 +263,7 @@ static void TownFoundingChanged(int32 new_value) } } -static void ZoomMinMaxChanged(int32 new_value) +static void ZoomMinMaxChanged(int32_t new_value) { ConstrainAllViewportsZoom(); GfxClearSpriteCache(); @@ -275,7 +275,7 @@ static void ZoomMinMaxChanged(int32 new_value) } } -static void SpriteZoomMinChanged(int32 new_value) +static void SpriteZoomMinChanged(int32_t new_value) { GfxClearSpriteCache(); /* Force all sprites to redraw at the new chosen zoom level */ @@ -288,20 +288,20 @@ static void SpriteZoomMinChanged(int32 new_value) * newgrf debug button. * @param new_value unused. */ -static void InvalidateNewGRFChangeWindows(int32 new_value) +static void InvalidateNewGRFChangeWindows(int32_t new_value) { InvalidateWindowClassesData(WC_SAVELOAD); CloseWindowByClass(WC_GAME_OPTIONS); ReInitAllWindows(false); } -static void InvalidateCompanyLiveryWindow(int32 new_value) +static void InvalidateCompanyLiveryWindow(int32_t new_value) { InvalidateWindowClassesData(WC_COMPANY_COLOUR, -1); ResetVehicleColourMap(); } -static void DifficultyNoiseChange(int32 new_value) +static void DifficultyNoiseChange(int32_t new_value) { if (_game_mode == GM_NORMAL) { UpdateAirportsNoise(); @@ -311,7 +311,7 @@ static void DifficultyNoiseChange(int32 new_value) } } -static void MaxNoAIsChange(int32 new_value) +static void MaxNoAIsChange(int32_t new_value) { if (GetGameSettings().difficulty.max_no_competitors != 0 && AI::GetInfoList()->size() == 0 && @@ -327,7 +327,7 @@ static void MaxNoAIsChange(int32 new_value) * @param new_value unused * @return true if the road side may be changed. */ -static bool CheckRoadSide(int32 &new_value) +static bool CheckRoadSide(int32_t &new_value) { return _game_mode == GM_MENU || !RoadVehiclesAreBuilt(); } @@ -346,7 +346,7 @@ static size_t ConvertLandscape(const char *value) return OneOfManySettingDesc::ParseSingleValue(value, strlen(value), _old_landscape_values); } -static bool CheckFreeformEdges(int32 &new_value) +static bool CheckFreeformEdges(int32_t &new_value) { if (_game_mode == GM_MENU) return true; if (new_value != 0) { @@ -393,7 +393,7 @@ static bool CheckFreeformEdges(int32 &new_value) return true; } -static void UpdateFreeformEdges(int32 new_value) +static void UpdateFreeformEdges(int32_t new_value) { if (_game_mode == GM_MENU) return; @@ -418,7 +418,7 @@ static void UpdateFreeformEdges(int32 new_value) * Changing the setting "allow multiple NewGRF sets" is not allowed * if there are vehicles. */ -static bool CheckDynamicEngines(int32 &new_value) +static bool CheckDynamicEngines(int32_t &new_value) { if (_game_mode == GM_MENU) return true; @@ -430,7 +430,7 @@ static bool CheckDynamicEngines(int32 &new_value) return true; } -static bool CheckMaxHeightLevel(int32 &new_value) +static bool CheckMaxHeightLevel(int32_t &new_value) { if (_game_mode == GM_NORMAL) return false; if (_game_mode != GM_EDITOR) return true; @@ -438,7 +438,7 @@ static bool CheckMaxHeightLevel(int32 &new_value) /* Check if at least one mountain on the map is higher than the new value. * If yes, disallow the change. */ for (TileIndex t = 0; t < Map::Size(); t++) { - if ((int32)TileHeight(t) > new_value) { + if ((int32_t)TileHeight(t) > new_value) { ShowErrorMessage(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN, INVALID_STRING_ID, WL_ERROR); /* Return old, unchanged value */ return false; @@ -448,19 +448,19 @@ static bool CheckMaxHeightLevel(int32 &new_value) return true; } -static void StationCatchmentChanged(int32 new_value) +static void StationCatchmentChanged(int32_t new_value) { Station::RecomputeCatchmentForAll(); MarkWholeScreenDirty(); } -static void MaxVehiclesChanged(int32 new_value) +static void MaxVehiclesChanged(int32_t new_value) { InvalidateWindowClassesData(WC_BUILD_TOOLBAR); MarkWholeScreenDirty(); } -static void InvalidateShipPathCache(int32 new_value) +static void InvalidateShipPathCache(int32_t new_value) { for (Ship *s : Ship::Iterate()) { s->path.clear(); diff --git a/src/settings_table.h b/src/settings_table.h index 062beca07d..372e4739bb 100644 --- a/src/settings_table.h +++ b/src/settings_table.h @@ -39,6 +39,6 @@ extern SettingTable _win32_settings; static const uint GAME_DIFFICULTY_NUM = 18; extern const std::array _old_diff_settings; -extern uint16 _old_diff_custom[GAME_DIFFICULTY_NUM]; +extern uint16_t _old_diff_custom[GAME_DIFFICULTY_NUM]; #endif /* SETTINGS_TABLE_H */ diff --git a/src/settings_type.h b/src/settings_type.h index 354862e86d..070721361e 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -83,16 +83,16 @@ struct DifficultySettings { byte competitor_intelligence; ///< Unused value, used to load old savegames. byte max_no_competitors; ///< the number of competitors (AIs) - uint16 competitors_interval; ///< the interval (in minutes) between adding competitors + uint16_t competitors_interval; ///< the interval (in minutes) between adding competitors byte number_towns; ///< the amount of towns byte industry_density; ///< The industry density. @see IndustryDensity - uint32 max_loan; ///< the maximum initial loan + uint32_t max_loan; ///< the maximum initial loan byte initial_interest; ///< amount of interest (to pay over the loan) byte vehicle_costs; ///< amount of money spent on vehicle running cost byte competitor_speed; ///< the speed at which the AI builds byte vehicle_breakdowns; ///< likelihood of vehicles breaking down byte subsidy_multiplier; ///< payment multiplier for subsidized deliveries - uint16 subsidy_duration; ///< duration of subsidies + uint16_t subsidy_duration; ///< duration of subsidies byte construction_cost; ///< how expensive is building byte terrain_type; ///< the mountainousness of the landscape byte quantity_sea_lakes; ///< the amount of seas/lakes @@ -115,30 +115,30 @@ enum ViewportScrollMode { struct GUISettings { bool sg_full_load_any; ///< new full load calculation, any cargo must be full read from pre v93 savegames bool lost_vehicle_warn; ///< if a vehicle can't find its destination, show a warning - uint8 order_review_system; ///< perform order reviews on vehicles + uint8_t order_review_system; ///< perform order reviews on vehicles bool vehicle_income_warn; ///< if a vehicle isn't generating income, show a warning bool show_finances; ///< show finances at end of year bool sg_new_nonstop; ///< ttdpatch compatible nonstop handling read from pre v93 savegames bool new_nonstop; ///< ttdpatch compatible nonstop handling - uint8 stop_location; ///< what is the default stop location of trains? - uint8 auto_scrolling; ///< scroll when moving mouse to the edge (see #ViewportAutoscrolling) + uint8_t stop_location; ///< what is the default stop location of trains? + uint8_t auto_scrolling; ///< scroll when moving mouse to the edge (see #ViewportAutoscrolling) byte errmsg_duration; ///< duration of error message - uint16 hover_delay_ms; ///< time required to activate a hover event, in milliseconds + uint16_t hover_delay_ms; ///< time required to activate a hover event, in milliseconds bool link_terraform_toolbar; ///< display terraform toolbar when displaying rail, road, water and airport toolbars - uint8 smallmap_land_colour; ///< colour used for land and heightmap at the smallmap - uint8 linkgraph_colours; ///< linkgraph overlay colours - uint8 scroll_mode; ///< viewport scroll mode + uint8_t smallmap_land_colour; ///< colour used for land and heightmap at the smallmap + uint8_t linkgraph_colours; ///< linkgraph overlay colours + uint8_t scroll_mode; ///< viewport scroll mode bool smooth_scroll; ///< smooth scroll viewports bool measure_tooltip; ///< show a permanent tooltip when dragging tools byte liveries; ///< options for displaying company liveries, 0=none, 1=self, 2=all bool prefer_teamchat; ///< choose the chat message target with \, true=all clients, false=your team - uint8 advanced_vehicle_list; ///< use the "advanced" vehicle list - uint8 loading_indicators; ///< show loading indicators - uint8 default_rail_type; ///< the default rail type for the rail GUI - uint8 toolbar_pos; ///< position of toolbars, 0=left, 1=center, 2=right - uint8 statusbar_pos; ///< position of statusbar, 0=left, 1=center, 2=right - uint8 window_snap_radius; ///< windows snap at each other if closer than this - uint8 window_soft_limit; ///< soft limit of maximum number of non-stickied non-vital windows (0 = no limit) + uint8_t advanced_vehicle_list; ///< use the "advanced" vehicle list + uint8_t loading_indicators; ///< show loading indicators + uint8_t default_rail_type; ///< the default rail type for the rail GUI + uint8_t toolbar_pos; ///< position of toolbars, 0=left, 1=center, 2=right + uint8_t statusbar_pos; ///< position of statusbar, 0=left, 1=center, 2=right + uint8_t window_snap_radius; ///< windows snap at each other if closer than this + uint8_t window_soft_limit; ///< soft limit of maximum number of non-stickied non-vital windows (0 = no limit) ZoomLevel zoom_min; ///< minimum zoom out level ZoomLevel zoom_max; ///< maximum zoom out level ZoomLevel sprite_zoom_min; ///< maximum zoom level at which higher-resolution alternative sprites will be used (if available) instead of scaling a lower resolution sprite @@ -147,12 +147,12 @@ struct GUISettings { bool keep_all_autosave; ///< name the autosave in a different way bool autosave_on_exit; ///< save an autosave when you quit the game, but do not ask "Do you really want to quit?" bool autosave_on_network_disconnect; ///< save an autosave when you get disconnected from a network game with an error? - uint8 date_format_in_default_names; ///< should the default savegame/screenshot name use long dates (31th Dec 2008), short dates (31-12-2008) or ISO dates (2008-12-31) + uint8_t date_format_in_default_names; ///< should the default savegame/screenshot name use long dates (31th Dec 2008), short dates (31-12-2008) or ISO dates (2008-12-31) byte max_num_autosaves; ///< controls how many autosavegames are made before the game starts to overwrite (names them 0 to max_num_autosaves - 1) bool population_in_label; ///< show the population of a town in its label? - uint8 right_mouse_btn_emulation; ///< should we emulate right mouse clicking? - uint8 scrollwheel_scrolling; ///< scrolling using the scroll wheel? - uint8 scrollwheel_multiplier; ///< how much 'wheel' per incoming event from the OS? + uint8_t right_mouse_btn_emulation; ///< should we emulate right mouse clicking? + uint8_t scrollwheel_scrolling; ///< scrolling using the scroll wheel? + uint8_t scrollwheel_multiplier; ///< how much 'wheel' per incoming event from the OS? bool timetable_arrival_departure; ///< show arrivals and departures in vehicle timetables bool right_mouse_wnd_close; ///< close window with right click bool pause_on_newgame; ///< whether to start new games paused or not @@ -174,35 +174,35 @@ struct GUISettings { bool station_show_coverage; ///< whether to highlight coverage area bool persistent_buildingtools; ///< keep the building tools active after usage bool expenses_layout; ///< layout of expenses window - uint32 last_newgrf_count; ///< the numbers of NewGRFs we found during the last scan + uint32_t last_newgrf_count; ///< the numbers of NewGRFs we found during the last scan byte missing_strings_threshold; ///< the number of missing strings before showing the warning - uint8 graph_line_thickness; ///< the thickness of the lines in the various graph guis - uint8 osk_activation; ///< Mouse gesture to trigger the OSK. + uint8_t graph_line_thickness; ///< the thickness of the lines in the various graph guis + uint8_t osk_activation; ///< Mouse gesture to trigger the OSK. byte starting_colour; ///< default color scheme for the company to start a new game with bool show_newgrf_name; ///< Show the name of the NewGRF in the build vehicle window bool show_cargo_in_vehicle_lists; ///< Show the cargoes the vehicles can carry in the list windows bool auto_remove_signals; ///< automatically remove signals when in the way during rail construction - uint16 refresh_rate; ///< How often we refresh the screen (time between draw-ticks). - uint16 fast_forward_speed_limit; ///< Game speed to use when fast-forward is enabled. + uint16_t refresh_rate; ///< How often we refresh the screen (time between draw-ticks). + uint16_t fast_forward_speed_limit; ///< Game speed to use when fast-forward is enabled. - uint16 console_backlog_timeout; ///< the minimum amount of time items should be in the console backlog before they will be removed in ~3 seconds granularity. - uint16 console_backlog_length; ///< the minimum amount of items in the console backlog before items will be removed. + uint16_t console_backlog_timeout; ///< the minimum amount of time items should be in the console backlog before they will be removed in ~3 seconds granularity. + uint16_t console_backlog_length; ///< the minimum amount of items in the console backlog before items will be removed. - uint8 station_gui_group_order; ///< the order of grouping cargo entries in the station gui - uint8 station_gui_sort_by; ///< sort cargo entries in the station gui by station name or amount - uint8 station_gui_sort_order; ///< the sort order of entries in the station gui - ascending or descending - uint16 network_chat_box_width_pct; ///< width of the chat box in percent - uint8 network_chat_box_height; ///< height of the chat box in lines - uint16 network_chat_timeout; ///< timeout of chat messages in seconds + uint8_t station_gui_group_order; ///< the order of grouping cargo entries in the station gui + uint8_t station_gui_sort_by; ///< sort cargo entries in the station gui by station name or amount + uint8_t station_gui_sort_order; ///< the sort order of entries in the station gui - ascending or descending + uint16_t network_chat_box_width_pct; ///< width of the chat box in percent + uint8_t network_chat_box_height; ///< height of the chat box in lines + uint16_t network_chat_timeout; ///< timeout of chat messages in seconds - uint8 developer; ///< print non-fatal warnings in console (>= 1), copy debug output to console (== 2) + uint8_t developer; ///< print non-fatal warnings in console (>= 1), copy debug output to console (== 2) bool show_date_in_logs; ///< whether to show dates in console logs bool newgrf_developer_tools; ///< activate NewGRF developer tools and allow modifying NewGRFs in an existing game bool ai_developer_tools; ///< activate AI/GS developer tools bool scenario_developer; ///< activate scenario developer: allow modifying NewGRFs in an existing game - uint8 settings_restriction_mode; ///< selected restriction mode in adv. settings GUI. @see RestrictionMode + uint8_t settings_restriction_mode; ///< selected restriction mode in adv. settings GUI. @see RestrictionMode bool newgrf_show_old_versions; ///< whether to show old versions in the NewGRF list - uint8 newgrf_default_palette; ///< default palette to use for NewGRFs without action 14 palette information + uint8_t newgrf_default_palette; ///< default palette to use for NewGRFs without action 14 palette information bool scale_bevels; ///< bevels are scaled with GUI scale. @@ -256,41 +256,41 @@ struct LocaleSettings { /** Settings related to news */ struct NewsSettings { - uint8 arrival_player; ///< NewsDisplay of vehicles arriving at new stations of current player - uint8 arrival_other; ///< NewsDisplay of vehicles arriving at new stations of other players - uint8 accident; ///< NewsDisplay of accidents that occur - uint8 accident_other; ///< NewsDisplay if a vehicle from another company is involved in an accident - uint8 company_info; ///< NewsDisplay of general company information - uint8 open; ///< NewsDisplay on new industry constructions - uint8 close; ///< NewsDisplay about closing industries - uint8 economy; ///< NewsDisplay on economical changes - uint8 production_player; ///< NewsDisplay of production changes of industries affecting current player - uint8 production_other; ///< NewsDisplay of production changes of industries affecting competitors - uint8 production_nobody; ///< NewsDisplay of production changes of industries affecting no one - uint8 advice; ///< NewsDisplay on advice affecting the player's vehicles - uint8 new_vehicles; ///< NewsDisplay of new vehicles becoming available - uint8 acceptance; ///< NewsDisplay on changes affecting the acceptance of cargo at stations - uint8 subsidies; ///< NewsDisplay of changes on subsidies - uint8 general; ///< NewsDisplay of other topics + uint8_t arrival_player; ///< NewsDisplay of vehicles arriving at new stations of current player + uint8_t arrival_other; ///< NewsDisplay of vehicles arriving at new stations of other players + uint8_t accident; ///< NewsDisplay of accidents that occur + uint8_t accident_other; ///< NewsDisplay if a vehicle from another company is involved in an accident + uint8_t company_info; ///< NewsDisplay of general company information + uint8_t open; ///< NewsDisplay on new industry constructions + uint8_t close; ///< NewsDisplay about closing industries + uint8_t economy; ///< NewsDisplay on economical changes + uint8_t production_player; ///< NewsDisplay of production changes of industries affecting current player + uint8_t production_other; ///< NewsDisplay of production changes of industries affecting competitors + uint8_t production_nobody; ///< NewsDisplay of production changes of industries affecting no one + uint8_t advice; ///< NewsDisplay on advice affecting the player's vehicles + uint8_t new_vehicles; ///< NewsDisplay of new vehicles becoming available + uint8_t acceptance; ///< NewsDisplay on changes affecting the acceptance of cargo at stations + uint8_t subsidies; ///< NewsDisplay of changes on subsidies + uint8_t general; ///< NewsDisplay of other topics }; /** All settings related to the network. */ struct NetworkSettings { - uint16 sync_freq; ///< how often do we check whether we are still in-sync - uint8 frame_freq; ///< how often do we send commands to the clients - uint16 commands_per_frame; ///< how many commands may be sent each frame_freq frames? - uint16 commands_per_frame_server; ///< how many commands may be sent each frame_freq frames? (server-originating commands) - uint16 max_commands_in_queue; ///< how many commands may there be in the incoming queue before dropping the connection? - uint16 bytes_per_frame; ///< how many bytes may, over a long period, be received per frame? - uint16 bytes_per_frame_burst; ///< how many bytes may, over a short period, be received? - uint16 max_init_time; ///< maximum amount of time, in game ticks, a client may take to initiate joining - uint16 max_join_time; ///< maximum amount of time, in game ticks, a client may take to sync up during joining - uint16 max_download_time; ///< maximum amount of time, in game ticks, a client may take to download the map - uint16 max_password_time; ///< maximum amount of time, in game ticks, a client may take to enter the password - uint16 max_lag_time; ///< maximum amount of time, in game ticks, a client may be lagging behind the server + uint16_t sync_freq; ///< how often do we check whether we are still in-sync + uint8_t frame_freq; ///< how often do we send commands to the clients + uint16_t commands_per_frame; ///< how many commands may be sent each frame_freq frames? + uint16_t commands_per_frame_server; ///< how many commands may be sent each frame_freq frames? (server-originating commands) + uint16_t max_commands_in_queue; ///< how many commands may there be in the incoming queue before dropping the connection? + uint16_t bytes_per_frame; ///< how many bytes may, over a long period, be received per frame? + uint16_t bytes_per_frame_burst; ///< how many bytes may, over a short period, be received? + uint16_t max_init_time; ///< maximum amount of time, in game ticks, a client may take to initiate joining + uint16_t max_join_time; ///< maximum amount of time, in game ticks, a client may take to sync up during joining + uint16_t max_download_time; ///< maximum amount of time, in game ticks, a client may take to download the map + uint16_t max_password_time; ///< maximum amount of time, in game ticks, a client may take to enter the password + uint16_t max_lag_time; ///< maximum amount of time, in game ticks, a client may be lagging behind the server bool pause_on_join; ///< pause the game when people join - uint16 server_port; ///< port the server listens on - uint16 server_admin_port; ///< port the server listens on for the admin network + uint16_t server_port; ///< port the server listens on + uint16_t server_admin_port; ///< port the server listens on for the admin network bool server_admin_chat; ///< allow private chat for the server to be distributed to the admin network ServerGameType server_game_type; ///< Server type: local / public / invite-only. std::string server_invite_code; ///< Invite code to use when registering as server. @@ -304,13 +304,13 @@ struct NetworkSettings { std::string connect_to_ip; ///< default for the "Add server" query std::string network_id; ///< network ID for servers bool autoclean_companies; ///< automatically remove companies that are not in use - uint8 autoclean_unprotected; ///< remove passwordless companies after this many months - uint8 autoclean_protected; ///< remove the password from passworded companies after this many months - uint8 autoclean_novehicles; ///< remove companies with no vehicles after this many months - uint8 max_companies; ///< maximum amount of companies - uint8 max_clients; ///< maximum amount of clients + uint8_t autoclean_unprotected; ///< remove passwordless companies after this many months + uint8_t autoclean_protected; ///< remove the password from passworded companies after this many months + uint8_t autoclean_novehicles; ///< remove companies with no vehicles after this many months + uint8_t max_companies; ///< maximum amount of companies + uint8_t max_clients; ///< maximum amount of clients TimerGameCalendar::Year restart_game_year; ///< year the server restarts - uint8 min_active_clients; ///< minimum amount of active clients to unpause the game + uint8_t min_active_clients; ///< minimum amount of active clients to unpause the game bool reload_cfg; ///< reload the config file before restarting std::string last_joined; ///< Last joined server bool no_http_content_downloads; ///< do not do content downloads over HTTP @@ -320,11 +320,11 @@ struct NetworkSettings { /** Settings related to the creation of games. */ struct GameCreationSettings { - uint32 generation_seed; ///< noise seed for world generation + uint32_t generation_seed; ///< noise seed for world generation TimerGameCalendar::Year starting_year; ///< starting date TimerGameCalendar::Year ending_year; ///< scoring end date - uint8 map_x; ///< X size of map - uint8 map_y; ///< Y size of map + uint8_t map_x; ///< X size of map + uint8_t map_y; ///< Y size of map byte land_generator; ///< the landscape generator byte oil_refinery_limit; ///< distance oil refineries allowed from map edge byte snow_line_height; ///< the configured snow line height (deduced from "snow_coverage") @@ -338,8 +338,8 @@ struct GameCreationSettings { byte town_name; ///< the town name generator used for town names byte landscape; ///< the landscape we're currently in byte water_borders; ///< bitset of the borders that are water - uint16 custom_town_number; ///< manually entered number of towns - uint16 custom_industry_number; ///< manually entered number of industries + uint16_t custom_town_number; ///< manually entered number of towns + uint16_t custom_industry_number; ///< manually entered number of industries byte variety; ///< variety level applied to TGP byte custom_terrain_type; ///< manually entered height for TGP to aim for byte custom_sea_level; ///< manually entered percentage of water in the map @@ -350,30 +350,30 @@ struct GameCreationSettings { /** Settings related to construction in-game */ struct ConstructionSettings { - uint8 map_height_limit; ///< the maximum allowed heightlevel + uint8_t map_height_limit; ///< the maximum allowed heightlevel bool build_on_slopes; ///< allow building on slopes bool autoslope; ///< allow terraforming under things - uint16 max_bridge_length; ///< maximum length of bridges + uint16_t max_bridge_length; ///< maximum length of bridges byte max_bridge_height; ///< maximum height of bridges - uint16 max_tunnel_length; ///< maximum length of tunnels + uint16_t max_tunnel_length; ///< maximum length of tunnels byte train_signal_side; ///< show signals on left / driving / right side bool extra_dynamite; ///< extra dynamite bool road_stop_on_town_road; ///< allow building of drive-through road stops on town owned roads bool road_stop_on_competitor_road; ///< allow building of drive-through road stops on roads owned by competitors - uint8 raw_industry_construction; ///< type of (raw) industry construction (none, "normal", prospecting) - uint8 industry_platform; ///< the amount of flat land around an industry + uint8_t raw_industry_construction; ///< type of (raw) industry construction (none, "normal", prospecting) + uint8_t industry_platform; ///< the amount of flat land around an industry bool freeform_edges; ///< allow terraforming the tiles at the map edges - uint8 extra_tree_placement; ///< (dis)allow building extra trees in-game - uint8 command_pause_level; ///< level/amount of commands that can't be executed while paused - - uint32 terraform_per_64k_frames; ///< how many tile heights may, over a long period, be terraformed per 65536 frames? - uint16 terraform_frame_burst; ///< how many tile heights may, over a short period, be terraformed? - uint32 clear_per_64k_frames; ///< how many tiles may, over a long period, be cleared per 65536 frames? - uint16 clear_frame_burst; ///< how many tiles may, over a short period, be cleared? - uint32 tree_per_64k_frames; ///< how many trees may, over a long period, be planted per 65536 frames? - uint16 tree_frame_burst; ///< how many trees may, over a short period, be planted? - uint32 build_object_per_64k_frames; ///< how many tiles may, over a long period, be purchased or have objects built on them per 65536 frames? - uint16 build_object_frame_burst; ///< how many tiles may, over a short period, be purchased or have objects built on them? + uint8_t extra_tree_placement; ///< (dis)allow building extra trees in-game + uint8_t command_pause_level; ///< level/amount of commands that can't be executed while paused + + uint32_t terraform_per_64k_frames; ///< how many tile heights may, over a long period, be terraformed per 65536 frames? + uint16_t terraform_frame_burst; ///< how many tile heights may, over a short period, be terraformed? + uint32_t clear_per_64k_frames; ///< how many tiles may, over a long period, be cleared per 65536 frames? + uint16_t clear_frame_burst; ///< how many tiles may, over a short period, be cleared? + uint32_t tree_per_64k_frames; ///< how many trees may, over a long period, be planted per 65536 frames? + uint16_t tree_frame_burst; ///< how many trees may, over a short period, be planted? + uint32_t build_object_per_64k_frames; ///< how many tiles may, over a long period, be purchased or have objects built on them per 65536 frames? + uint16_t build_object_frame_burst; ///< how many tiles may, over a short period, be purchased or have objects built on them? }; /** Settings related to the AI. */ @@ -387,9 +387,9 @@ struct AISettings { /** Settings related to scripts. */ struct ScriptSettings { - uint8 settings_profile; ///< difficulty profile to set initial settings of scripts, esp. random AIs - uint32 script_max_opcode_till_suspend; ///< max opcode calls till scripts will suspend - uint32 script_max_memory_megabytes; ///< limit on memory a single script instance may have allocated + uint8_t settings_profile; ///< difficulty profile to set initial settings of scripts, esp. random AIs + uint32_t script_max_opcode_till_suspend; ///< max opcode calls till scripts will suspend + uint32_t script_max_memory_megabytes; ///< limit on memory a single script instance may have allocated }; /** Settings related to the new pathfinder. */ @@ -399,74 +399,74 @@ struct NPFSettings { * limit should make sure performance stays at acceptable levels at the cost * of not being perfect anymore. */ - uint32 npf_max_search_nodes; - uint32 maximum_go_to_depot_penalty; ///< What is the maximum penalty that may be endured for going to a depot - - uint32 npf_rail_firstred_penalty; ///< the penalty for when the first signal is red (and it is not an exit or combo signal) - uint32 npf_rail_firstred_exit_penalty; ///< the penalty for when the first signal is red (and it is an exit or combo signal) - uint32 npf_rail_lastred_penalty; ///< the penalty for when the last signal is red - uint32 npf_rail_station_penalty; ///< the penalty for station tiles - uint32 npf_rail_slope_penalty; ///< the penalty for sloping upwards - uint32 npf_rail_curve_penalty; ///< the penalty for curves - uint32 npf_rail_depot_reverse_penalty; ///< the penalty for reversing in depots - uint32 npf_rail_pbs_cross_penalty; ///< the penalty for crossing a reserved rail track - uint32 npf_rail_pbs_signal_back_penalty; ///< the penalty for passing a pbs signal from the backside - uint32 npf_buoy_penalty; ///< the penalty for going over (through) a buoy - uint32 npf_water_curve_penalty; ///< the penalty for curves - uint32 npf_road_curve_penalty; ///< the penalty for curves - uint32 npf_crossing_penalty; ///< the penalty for level crossings - uint32 npf_road_drive_through_penalty; ///< the penalty for going through a drive-through road stop - uint32 npf_road_dt_occupied_penalty; ///< the penalty multiplied by the fill percentage of a drive-through road stop - uint32 npf_road_bay_occupied_penalty; ///< the penalty multiplied by the fill percentage of a road bay + uint32_t npf_max_search_nodes; + uint32_t maximum_go_to_depot_penalty; ///< What is the maximum penalty that may be endured for going to a depot + + uint32_t npf_rail_firstred_penalty; ///< the penalty for when the first signal is red (and it is not an exit or combo signal) + uint32_t npf_rail_firstred_exit_penalty; ///< the penalty for when the first signal is red (and it is an exit or combo signal) + uint32_t npf_rail_lastred_penalty; ///< the penalty for when the last signal is red + uint32_t npf_rail_station_penalty; ///< the penalty for station tiles + uint32_t npf_rail_slope_penalty; ///< the penalty for sloping upwards + uint32_t npf_rail_curve_penalty; ///< the penalty for curves + uint32_t npf_rail_depot_reverse_penalty; ///< the penalty for reversing in depots + uint32_t npf_rail_pbs_cross_penalty; ///< the penalty for crossing a reserved rail track + uint32_t npf_rail_pbs_signal_back_penalty; ///< the penalty for passing a pbs signal from the backside + uint32_t npf_buoy_penalty; ///< the penalty for going over (through) a buoy + uint32_t npf_water_curve_penalty; ///< the penalty for curves + uint32_t npf_road_curve_penalty; ///< the penalty for curves + uint32_t npf_crossing_penalty; ///< the penalty for level crossings + uint32_t npf_road_drive_through_penalty; ///< the penalty for going through a drive-through road stop + uint32_t npf_road_dt_occupied_penalty; ///< the penalty multiplied by the fill percentage of a drive-through road stop + uint32_t npf_road_bay_occupied_penalty; ///< the penalty multiplied by the fill percentage of a road bay }; /** Settings related to the yet another pathfinder. */ struct YAPFSettings { bool disable_node_optimization; ///< whether to use exit-dir instead of trackdir in node key - uint32 max_search_nodes; ///< stop path-finding when this number of nodes visited - uint32 maximum_go_to_depot_penalty; ///< What is the maximum penalty that may be endured for going to a depot + uint32_t max_search_nodes; ///< stop path-finding when this number of nodes visited + uint32_t maximum_go_to_depot_penalty; ///< What is the maximum penalty that may be endured for going to a depot bool ship_use_yapf; ///< use YAPF for ships bool road_use_yapf; ///< use YAPF for road bool rail_use_yapf; ///< use YAPF for rail - uint32 road_slope_penalty; ///< penalty for up-hill slope - uint32 road_curve_penalty; ///< penalty for curves - uint32 road_crossing_penalty; ///< penalty for level crossing - uint32 road_stop_penalty; ///< penalty for going through a drive-through road stop - uint32 road_stop_occupied_penalty; ///< penalty multiplied by the fill percentage of a drive-through road stop - uint32 road_stop_bay_occupied_penalty; ///< penalty multiplied by the fill percentage of a road bay + uint32_t road_slope_penalty; ///< penalty for up-hill slope + uint32_t road_curve_penalty; ///< penalty for curves + uint32_t road_crossing_penalty; ///< penalty for level crossing + uint32_t road_stop_penalty; ///< penalty for going through a drive-through road stop + uint32_t road_stop_occupied_penalty; ///< penalty multiplied by the fill percentage of a drive-through road stop + uint32_t road_stop_bay_occupied_penalty; ///< penalty multiplied by the fill percentage of a road bay bool rail_firstred_twoway_eol; ///< treat first red two-way signal as dead end - uint32 rail_firstred_penalty; ///< penalty for first red signal - uint32 rail_firstred_exit_penalty; ///< penalty for first red exit signal - uint32 rail_lastred_penalty; ///< penalty for last red signal - uint32 rail_lastred_exit_penalty; ///< penalty for last red exit signal - uint32 rail_station_penalty; ///< penalty for non-target station tile - uint32 rail_slope_penalty; ///< penalty for up-hill slope - uint32 rail_curve45_penalty; ///< penalty for curve - uint32 rail_curve90_penalty; ///< penalty for 90-deg curve - uint32 rail_depot_reverse_penalty; ///< penalty for reversing in the depot - uint32 rail_crossing_penalty; ///< penalty for level crossing - uint32 rail_look_ahead_max_signals; ///< max. number of signals taken into consideration in look-ahead load balancer - int32 rail_look_ahead_signal_p0; ///< constant in polynomial penalty function - int32 rail_look_ahead_signal_p1; ///< constant in polynomial penalty function - int32 rail_look_ahead_signal_p2; ///< constant in polynomial penalty function - uint32 rail_pbs_cross_penalty; ///< penalty for crossing a reserved tile - uint32 rail_pbs_station_penalty; ///< penalty for crossing a reserved station tile - uint32 rail_pbs_signal_back_penalty; ///< penalty for passing a pbs signal from the backside - uint32 rail_doubleslip_penalty; ///< penalty for passing a double slip switch - - uint32 rail_longer_platform_penalty; ///< penalty for longer station platform than train - uint32 rail_longer_platform_per_tile_penalty; ///< penalty for longer station platform than train (per tile) - uint32 rail_shorter_platform_penalty; ///< penalty for shorter station platform than train - uint32 rail_shorter_platform_per_tile_penalty; ///< penalty for shorter station platform than train (per tile) - uint32 ship_curve45_penalty; ///< penalty for 45-deg curve for ships - uint32 ship_curve90_penalty; ///< penalty for 90-deg curve for ships + uint32_t rail_firstred_penalty; ///< penalty for first red signal + uint32_t rail_firstred_exit_penalty; ///< penalty for first red exit signal + uint32_t rail_lastred_penalty; ///< penalty for last red signal + uint32_t rail_lastred_exit_penalty; ///< penalty for last red exit signal + uint32_t rail_station_penalty; ///< penalty for non-target station tile + uint32_t rail_slope_penalty; ///< penalty for up-hill slope + uint32_t rail_curve45_penalty; ///< penalty for curve + uint32_t rail_curve90_penalty; ///< penalty for 90-deg curve + uint32_t rail_depot_reverse_penalty; ///< penalty for reversing in the depot + uint32_t rail_crossing_penalty; ///< penalty for level crossing + uint32_t rail_look_ahead_max_signals; ///< max. number of signals taken into consideration in look-ahead load balancer + int32_t rail_look_ahead_signal_p0; ///< constant in polynomial penalty function + int32_t rail_look_ahead_signal_p1; ///< constant in polynomial penalty function + int32_t rail_look_ahead_signal_p2; ///< constant in polynomial penalty function + uint32_t rail_pbs_cross_penalty; ///< penalty for crossing a reserved tile + uint32_t rail_pbs_station_penalty; ///< penalty for crossing a reserved station tile + uint32_t rail_pbs_signal_back_penalty; ///< penalty for passing a pbs signal from the backside + uint32_t rail_doubleslip_penalty; ///< penalty for passing a double slip switch + + uint32_t rail_longer_platform_penalty; ///< penalty for longer station platform than train + uint32_t rail_longer_platform_per_tile_penalty; ///< penalty for longer station platform than train (per tile) + uint32_t rail_shorter_platform_penalty; ///< penalty for shorter station platform than train + uint32_t rail_shorter_platform_per_tile_penalty; ///< penalty for shorter station platform than train (per tile) + uint32_t ship_curve45_penalty; ///< penalty for 45-deg curve for ships + uint32_t ship_curve90_penalty; ///< penalty for 90-deg curve for ships }; /** Settings related to all pathfinders. */ struct PathfinderSettings { - uint8 pathfinder_for_trains; ///< the pathfinder to use for trains - uint8 pathfinder_for_roadvehs; ///< the pathfinder to use for roadvehicles - uint8 pathfinder_for_ships; ///< the pathfinder to use for ships + uint8_t pathfinder_for_trains; ///< the pathfinder to use for trains + uint8_t pathfinder_for_roadvehs; ///< the pathfinder to use for roadvehicles + uint8_t pathfinder_for_ships; ///< the pathfinder to use for ships bool new_pathfinding_all; ///< use the newest pathfinding algorithm for all bool roadveh_queue; ///< buggy road vehicle queueing @@ -495,25 +495,25 @@ struct OrderSettings { /** Settings related to vehicles. */ struct VehicleSettings { - uint8 max_train_length; ///< maximum length for trains - uint8 smoke_amount; ///< amount of smoke/sparks locomotives produce - uint8 train_acceleration_model; ///< realistic acceleration for trains - uint8 roadveh_acceleration_model; ///< realistic acceleration for road vehicles - uint8 train_slope_steepness; ///< Steepness of hills for trains when using realistic acceleration - uint8 roadveh_slope_steepness; ///< Steepness of hills for road vehicles when using realistic acceleration + uint8_t max_train_length; ///< maximum length for trains + uint8_t smoke_amount; ///< amount of smoke/sparks locomotives produce + uint8_t train_acceleration_model; ///< realistic acceleration for trains + uint8_t roadveh_acceleration_model; ///< realistic acceleration for road vehicles + uint8_t train_slope_steepness; ///< Steepness of hills for trains when using realistic acceleration + uint8_t roadveh_slope_steepness; ///< Steepness of hills for road vehicles when using realistic acceleration bool wagon_speed_limits; ///< enable wagon speed limits bool disable_elrails; ///< when true, the elrails are disabled UnitID max_trains; ///< max trains in game per company UnitID max_roadveh; ///< max trucks in game per company UnitID max_aircraft; ///< max planes in game per company UnitID max_ships; ///< max ships in game per company - uint8 plane_speed; ///< divisor for speed of aircraft - uint8 freight_trains; ///< value to multiply the weight of cargo by + uint8_t plane_speed; ///< divisor for speed of aircraft + uint8_t freight_trains; ///< value to multiply the weight of cargo by bool dynamic_engines; ///< enable dynamic allocation of engine data bool never_expire_vehicles; ///< never expire vehicles byte extend_vehicle_life; ///< extend vehicle life by this many years byte road_side; ///< the side of the road vehicles drive on - uint8 plane_crashes; ///< number of plane crashes, 0 = none, 1 = reduced, 2 = normal + uint8_t plane_crashes; ///< number of plane crashes, 0 = none, 1 = reduced, 2 = normal }; /** Settings related to the economy. */ @@ -521,7 +521,7 @@ struct EconomySettings { bool inflation; ///< disable inflation bool bribe; ///< enable bribing the local authority EconomyType type; ///< economy type (original/smooth/frozen) - uint8 feeder_payment_share; ///< percentage of leg payment to virtually pay in feeder systems + uint8_t feeder_payment_share; ///< percentage of leg payment to virtually pay in feeder systems byte dist_local_authority; ///< distance for town local authority, default 20 bool exclusive_rights; ///< allow buying exclusive rights bool fund_buildings; ///< allow funding new buildings @@ -529,30 +529,30 @@ struct EconomySettings { bool give_money; ///< allow giving other companies money bool mod_road_rebuild; ///< roadworks remove unnecessary RoadBits bool multiple_industry_per_town; ///< allow many industries of the same type per town - uint8 town_growth_rate; ///< town growth rate - uint8 larger_towns; ///< the number of cities to build. These start off larger and grow twice as fast - uint8 initial_city_size; ///< multiplier for the initial size of the cities compared to towns + uint8_t town_growth_rate; ///< town growth rate + uint8_t larger_towns; ///< the number of cities to build. These start off larger and grow twice as fast + uint8_t initial_city_size; ///< multiplier for the initial size of the cities compared to towns TownLayout town_layout; ///< select town layout, @see TownLayout TownCargoGenMode town_cargogen_mode; ///< algorithm for generating cargo from houses, @see TownCargoGenMode bool allow_town_roads; ///< towns are allowed to build roads (always allowed when generating world / in SE) TownFounding found_town; ///< town founding. bool station_noise_level; ///< build new airports when the town noise level is still within accepted limits - uint16 town_noise_population[4]; ///< population to base decision on noise evaluation (@see town_council_tolerance) + uint16_t town_noise_population[4]; ///< population to base decision on noise evaluation (@see town_council_tolerance) bool allow_town_level_crossings; ///< towns are allowed to build level crossings bool infrastructure_maintenance; ///< enable monthly maintenance fee for owner infrastructure }; struct LinkGraphSettings { - uint16 recalc_time; ///< time (in days) for recalculating each link graph component. - uint16 recalc_interval; ///< time (in days) between subsequent checks for link graphs to be calculated. + uint16_t recalc_time; ///< time (in days) for recalculating each link graph component. + uint16_t recalc_interval; ///< time (in days) between subsequent checks for link graphs to be calculated. DistributionType distribution_pax; ///< distribution type for passengers DistributionType distribution_mail; ///< distribution type for mail DistributionType distribution_armoured; ///< distribution type for armoured cargo class DistributionType distribution_default; ///< distribution type for all other goods - uint8 accuracy; ///< accuracy when calculating things on the link graph. low accuracy => low running time - uint8 demand_size; ///< influence of supply ("station size") on the demand function - uint8 demand_distance; ///< influence of distance between stations on the demand function - uint8 short_path_saturation; ///< percentage up to which short paths are saturated before saturating most capacious paths + uint8_t accuracy; ///< accuracy when calculating things on the link graph. low accuracy => low running time + uint8_t demand_size; ///< influence of supply ("station size") on the demand function + uint8_t demand_distance; ///< influence of distance between stations on the demand function + uint8_t short_path_saturation; ///< percentage up to which short paths are saturated before saturating most capacious paths inline DistributionType GetDistributionType(CargoID cargo) const { if (IsCargoInClass(cargo, CC_PASSENGERS)) return this->distribution_pax; @@ -575,17 +575,17 @@ struct StationSettings { /** Default settings for vehicles. */ struct VehicleDefaultSettings { bool servint_ispercent; ///< service intervals are in percents - uint16 servint_trains; ///< service interval for trains - uint16 servint_roadveh; ///< service interval for road vehicles - uint16 servint_aircraft; ///< service interval for aircraft - uint16 servint_ships; ///< service interval for ships + uint16_t servint_trains; ///< service interval for trains + uint16_t servint_roadveh; ///< service interval for road vehicles + uint16_t servint_aircraft; ///< service interval for aircraft + uint16_t servint_ships; ///< service interval for ships }; /** Settings that can be set per company. */ struct CompanySettings { bool engine_renew; ///< is autorenew enabled - int16 engine_renew_months; ///< months before/after the maximum vehicle age a vehicle should be renewed - uint32 engine_renew_money; ///< minimum amount of money before autorenew is used + int16_t engine_renew_months; ///< months before/after the maximum vehicle age a vehicle should be renewed + uint32_t engine_renew_money; ///< minimum amount of money before autorenew is used bool renew_keep_length; ///< sell some wagons if after autoreplace the train is longer than before VehicleDefaultSettings vehicle; ///< default settings for vehicles }; diff --git a/src/ship.h b/src/ship.h index 3a9ea806af..7c8fcc89a9 100644 --- a/src/ship.h +++ b/src/ship.h @@ -25,8 +25,8 @@ struct Ship FINAL : public SpecializedVehicle { TrackBits state; ///< The "track" the ship is following. ShipPathCache path; ///< Cached path. Direction rotation; ///< Visible direction. - int16 rotation_x_pos; ///< NOSAVE: X Position before rotation. - int16 rotation_y_pos; ///< NOSAVE: Y Position before rotation. + int16_t rotation_x_pos; ///< NOSAVE: X Position before rotation. + int16_t rotation_y_pos; ///< NOSAVE: Y Position before rotation. /** We don't want GCC to zero our struct! It already is zeroed and has an index! */ Ship() : SpecializedVehicleBase() {} diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index 8662f4ac78..fc44f6f76c 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -59,10 +59,10 @@ WaterClass GetEffectiveWaterClass(TileIndex tile) NOT_REACHED(); } -static const uint16 _ship_sprites[] = {0x0E5D, 0x0E55, 0x0E65, 0x0E6D}; +static const uint16_t _ship_sprites[] = {0x0E5D, 0x0E55, 0x0E65, 0x0E6D}; template <> -bool IsValidImageIndex(uint8 image_index) +bool IsValidImageIndex(uint8_t image_index) { return image_index < lengthof(_ship_sprites); } @@ -75,7 +75,7 @@ static inline TrackBits GetTileShipTrackStatus(TileIndex tile) static void GetShipIcon(EngineID engine, EngineImageType image_type, VehicleSpriteSeq *result) { const Engine *e = Engine::Get(engine); - uint8 spritenum = e->u.ship.image_index; + uint8_t spritenum = e->u.ship.image_index; if (is_custom_sprite(spritenum)) { GetCustomVehicleIcon(engine, DIR_W, image_type, result); @@ -127,7 +127,7 @@ void GetShipSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, i void Ship::GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const { - uint8 spritenum = this->spritenum; + uint8_t spritenum = this->spritenum; if (image_type == EIT_ON_MAP) direction = this->rotation; @@ -293,7 +293,7 @@ TileIndex Ship::GetOrderStationLocation(StationID station) void Ship::UpdateDeltaXY() { - static const int8 _delta_xy_table[8][4] = { + static const int8_t _delta_xy_table[8][4] = { /* y_extent, x_extent, y_offs, x_offs */ { 6, 6, -3, -3}, // N { 6, 32, -3, -16}, // NE @@ -305,7 +305,7 @@ void Ship::UpdateDeltaXY() {32, 6, -16, -3}, // NW }; - const int8 *bb = _delta_xy_table[this->rotation]; + const int8_t *bb = _delta_xy_table[this->rotation]; this->x_offs = bb[3]; this->y_offs = bb[2]; this->x_extent = bb[1]; diff --git a/src/signs_base.h b/src/signs_base.h index 2791afa8a0..718ffac320 100644 --- a/src/signs_base.h +++ b/src/signs_base.h @@ -21,9 +21,9 @@ extern SignPool _sign_pool; struct Sign : SignPool::PoolItem<&_sign_pool> { std::string name; TrackedViewportSign sign; - int32 x; - int32 y; - int32 z; + int32_t x; + int32_t y; + int32_t z; Owner owner; // placed by this company. Anyone can delete them though. OWNER_NONE for gray signs from old games. Sign(Owner owner = INVALID_OWNER); diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index a9d29ab3b2..94a2d2fc9a 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -211,7 +211,7 @@ struct SignListWindow : Window, SignList { tr = tr.Indent(this->text_offset, rtl); /* At least one sign available. */ - for (uint16 i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) + for (uint16_t i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) { const Sign *si = this->signs[i]; diff --git a/src/signs_type.h b/src/signs_type.h index fd73af8fad..5dec4a560e 100644 --- a/src/signs_type.h +++ b/src/signs_type.h @@ -11,7 +11,7 @@ #define SIGNS_TYPE_H /** The type of the IDs of signs. */ -typedef uint16 SignID; +typedef uint16_t SignID; struct Sign; static const SignID INVALID_SIGN = 0xFFFF; ///< Sentinel for an invalid sign. diff --git a/src/slope_type.h b/src/slope_type.h index 86faa7bb68..1870db2272 100644 --- a/src/slope_type.h +++ b/src/slope_type.h @@ -83,7 +83,7 @@ DECLARE_ENUM_AS_BIT_SET(Slope) */ #define M(x) (1U << (x)) /** Constant bitset with safe slopes for building a level crossing. */ -static const uint32 VALID_LEVEL_CROSSING_SLOPES = M(SLOPE_SEN) | M(SLOPE_ENW) | M(SLOPE_NWS) | M(SLOPE_NS) | M(SLOPE_WSE) | M(SLOPE_EW) | M(SLOPE_FLAT); +static const uint32_t VALID_LEVEL_CROSSING_SLOPES = M(SLOPE_SEN) | M(SLOPE_ENW) | M(SLOPE_NWS) | M(SLOPE_NS) | M(SLOPE_WSE) | M(SLOPE_EW) | M(SLOPE_FLAT); #undef M diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index 3917cb6057..c928f08b52 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -37,7 +37,7 @@ static int _smallmap_company_count; ///< Number of entries in the owner legend. static int _smallmap_cargo_count; ///< Number of cargos in the link stats legend. /** Link stat colours shown in legenda. */ -static uint8 _linkstat_colours_in_legenda[] = {0, 1, 3, 5, 7, 9, 11}; +static uint8_t _linkstat_colours_in_legenda[] = {0, 1, 3, 5, 7, 9, 11}; static const int NUM_NO_COMPANY_ENTRIES = 4; ///< Number of entries in the owner legend that are not companies. @@ -256,10 +256,10 @@ static const LegendAndColour * const _legend_table[] = { /** Colour scheme of the smallmap. */ struct SmallMapColourScheme { - uint32 *height_colours; ///< Cached colours for each level in a map. - const uint32 *height_colours_base; ///< Base table for determining the colours + uint32_t *height_colours; ///< Cached colours for each level in a map. + const uint32_t *height_colours_base; ///< Base table for determining the colours size_t colour_count; ///< The number of colours. - uint32 default_colour; ///< Default colour of the land. + uint32_t default_colour; ///< Default colour of the land. }; /** Available colour schemes for height maps. */ @@ -346,11 +346,11 @@ void BuildOwnerLegend() } struct AndOr { - uint32 mor; - uint32 mand; + uint32_t mor; + uint32_t mand; }; -static inline uint32 ApplyMask(uint32 colour, const AndOr *mask) +static inline uint32_t ApplyMask(uint32_t colour, const AndOr *mask) { return (colour & mask->mand) | mask->mor; } @@ -411,7 +411,7 @@ static const byte _tiletype_importance[] = { * @param t Effective tile type of the tile (see #SmallMapWindow::GetTileColours). * @return The colour of tile in the small map in mode "Contour" */ -static inline uint32 GetSmallMapContoursPixels(TileIndex tile, TileType t) +static inline uint32_t GetSmallMapContoursPixels(TileIndex tile, TileType t) { const SmallMapColourScheme *cs = &_heightmap_schemes[_settings_client.gui.smallmap_land_colour]; return ApplyMask(cs->height_colours[TileHeight(tile)], &_smallmap_contours_andor[t]); @@ -424,7 +424,7 @@ static inline uint32 GetSmallMapContoursPixels(TileIndex tile, TileType t) * @param t Effective tile type of the tile (see #SmallMapWindow::GetTileColours). * @return The colour of tile in the small map in mode "Vehicles" */ -static inline uint32 GetSmallMapVehiclesPixels(TileIndex tile, TileType t) +static inline uint32_t GetSmallMapVehiclesPixels(TileIndex tile, TileType t) { const SmallMapColourScheme *cs = &_heightmap_schemes[_settings_client.gui.smallmap_land_colour]; return ApplyMask(cs->default_colour, &_smallmap_vehicles_andor[t]); @@ -437,7 +437,7 @@ static inline uint32 GetSmallMapVehiclesPixels(TileIndex tile, TileType t) * @param t Effective tile type of the tile (see #SmallMapWindow::GetTileColours). * @return The colour of tile in the small map in mode "Industries" */ -static inline uint32 GetSmallMapIndustriesPixels(TileIndex tile, TileType t) +static inline uint32_t GetSmallMapIndustriesPixels(TileIndex tile, TileType t) { const SmallMapColourScheme *cs = &_heightmap_schemes[_settings_client.gui.smallmap_land_colour]; return ApplyMask(_smallmap_show_heightmap ? cs->height_colours[TileHeight(tile)] : cs->default_colour, &_smallmap_vehicles_andor[t]); @@ -450,7 +450,7 @@ static inline uint32 GetSmallMapIndustriesPixels(TileIndex tile, TileType t) * @param t Effective tile type of the tile (see #SmallMapWindow::GetTileColours). * @return The colour of tile in the small map in mode "Routes" */ -static inline uint32 GetSmallMapRoutesPixels(TileIndex tile, TileType t) +static inline uint32_t GetSmallMapRoutesPixels(TileIndex tile, TileType t) { switch (t) { case MP_STATION: @@ -506,12 +506,12 @@ static inline uint32 GetSmallMapRoutesPixels(TileIndex tile, TileType t) * @param t Effective tile type of the tile (see #SmallMapWindow::GetTileColours). * @return The colour of tile in the small map in mode "link stats" */ -static inline uint32 GetSmallMapLinkStatsPixels(TileIndex tile, TileType t) +static inline uint32_t GetSmallMapLinkStatsPixels(TileIndex tile, TileType t) { return _smallmap_show_heightmap ? GetSmallMapContoursPixels(tile, t) : GetSmallMapRoutesPixels(tile, t); } -static const uint32 _vegetation_clear_bits[] = { +static const uint32_t _vegetation_clear_bits[] = { MKCOLOUR_XXXX(PC_GRASS_LAND), ///< full grass MKCOLOUR_XXXX(PC_ROUGH_LAND), ///< rough land MKCOLOUR_XXXX(PC_GREY), ///< rocks @@ -529,7 +529,7 @@ static const uint32 _vegetation_clear_bits[] = { * @param t Effective tile type of the tile (see #SmallMapWindow::GetTileColours). * @return The colour of tile in the smallmap in mode "Vegetation" */ -static inline uint32 GetSmallMapVegetationPixels(TileIndex tile, TileType t) +static inline uint32_t GetSmallMapVegetationPixels(TileIndex tile, TileType t) { switch (t) { case MP_CLEAR: @@ -556,13 +556,13 @@ static inline uint32 GetSmallMapVegetationPixels(TileIndex tile, TileType t) /** * Return the colour a tile would be displayed with in the small map in mode "Owner". * - * @note If include_heightmap is IH_NEVER, the return value can safely be used as a palette colour (by masking it to a uint8) + * @note If include_heightmap is IH_NEVER, the return value can safely be used as a palette colour (by masking it to a uint8_t) * @param tile The tile of which we would like to get the colour. * @param t Effective tile type of the tile (see #SmallMapWindow::GetTileColours). * @param include_heightmap Whether to return the heightmap/contour colour of this tile (instead of the default land tile colour) * @return The colour of tile in the small map in mode "Owner" */ -uint32 GetSmallMapOwnerPixels(TileIndex tile, TileType t, IncludeHeightmap include_heightmap) +uint32_t GetSmallMapOwnerPixels(TileIndex tile, TileType t, IncludeHeightmap include_heightmap) { Owner o; @@ -748,7 +748,7 @@ void SmallMapWindow::SetZoomLevel(ZoomLevelChange change, const Point *zoom_pt) * @param ta Tile area to investigate. * @return Colours to display. */ -inline uint32 SmallMapWindow::GetTileColours(const TileArea &ta) const +inline uint32_t SmallMapWindow::GetTileColours(const TileArea &ta) const { int importance = 0; TileIndex tile = INVALID_TILE; // Position of the most important tile. @@ -861,8 +861,8 @@ void SmallMapWindow::DrawSmallMapColumn(void *dst, uint xc, uint yc, int pitch, } ta.ClampToMap(); // Clamp to map boundaries (may contain MP_VOID tiles!). - uint32 val = this->GetTileColours(ta); - uint8 *val8 = (uint8 *)&val; + uint32_t val = this->GetTileColours(ta); + uint8_t *val8 = (uint8_t *)&val; int idx = std::max(0, -start_pos); for (int pos = std::max(0, start_pos); pos < end_pos; pos++) { blitter->SetPixel(dst, idx, 0, val8[idx]); @@ -1113,7 +1113,7 @@ void SmallMapWindow::RebuildColourIndexIfNecessary() for (uint n = 0; n < lengthof(_heightmap_schemes); n++) { /* The heights go from 0 up to and including maximum. */ int heights = _settings_game.construction.map_height_limit + 1; - _heightmap_schemes[n].height_colours = ReallocT(_heightmap_schemes[n].height_colours, heights); + _heightmap_schemes[n].height_colours = ReallocT(_heightmap_schemes[n].height_colours, heights); for (int z = 0; z < heights; z++) { size_t access_index = (_heightmap_schemes[n].colour_count * z) / heights; @@ -1254,7 +1254,7 @@ void SmallMapWindow::RebuildColourIndexIfNecessary() i = 1; } - uint8 legend_colour = tbl->colour; + uint8_t legend_colour = tbl->colour; switch (this->map_type) { case SMT_INDUSTRY: diff --git a/src/smallmap_gui.h b/src/smallmap_gui.h index 11a08b83a4..f86fbe9948 100644 --- a/src/smallmap_gui.h +++ b/src/smallmap_gui.h @@ -35,14 +35,14 @@ enum class IncludeHeightmap { Always ///< Always include the heightmap }; -uint32 GetSmallMapOwnerPixels(TileIndex tile, TileType t, IncludeHeightmap include_heightmap); +uint32_t GetSmallMapOwnerPixels(TileIndex tile, TileType t, IncludeHeightmap include_heightmap); /** Structure for holding relevant data for legends in small map */ struct LegendAndColour { - uint8 colour; ///< Colour of the item on the map. + uint8_t colour; ///< Colour of the item on the map. StringID legend; ///< String corresponding to the coloured item. IndustryType type; ///< Type of industry. Only valid for industry entries. - uint8 height; ///< Height in tiles. Only valid for height legend entries. + uint8_t height; ///< Height in tiles. Only valid for height legend entries. CompanyID company; ///< Company to display. Only valid for company entries of the owner legend. bool show_on_map; ///< For filtering industries, if \c true, industry is shown on the map in colour. bool end; ///< This is the end of the list. @@ -81,9 +81,9 @@ protected: uint column_width; ///< Width of a column in the #WID_SM_LEGEND widget. uint legend_width; ///< Width of legend 'blob'. - int32 scroll_x; ///< Horizontal world coordinate of the base tile left of the top-left corner of the smallmap display. - int32 scroll_y; ///< Vertical world coordinate of the base tile left of the top-left corner of the smallmap display. - int32 subscroll; ///< Number of pixels (0..3) between the right end of the base tile and the pixel at the top-left corner of the smallmap display. + int32_t scroll_x; ///< Horizontal world coordinate of the base tile left of the top-left corner of the smallmap display. + int32_t scroll_y; ///< Vertical world coordinate of the base tile left of the top-left corner of the smallmap display. + int32_t subscroll; ///< Number of pixels (0..3) between the right end of the base tile and the pixel at the top-left corner of the smallmap display. int zoom; ///< Zoom level. Bigger number means more zoom-out (further away). LinkGraphOverlay *overlay; @@ -182,7 +182,7 @@ protected: void SetZoomLevel(ZoomLevelChange change, const Point *zoom_pt); void SetOverlayCargoMask(); void SetupWidgetData(); - uint32 GetTileColours(const TileArea &ta) const; + uint32_t GetTileColours(const TileArea &ta) const; int GetPositionOnLegend(Point pt); diff --git a/src/sortlist_type.h b/src/sortlist_type.h index 45799cd835..ce60ea6930 100644 --- a/src/sortlist_type.h +++ b/src/sortlist_type.h @@ -52,9 +52,9 @@ protected: SortFunction * const *sort_func_list; ///< the sort criteria functions FilterFunction * const *filter_func_list; ///< the filter criteria functions SortListFlags flags; ///< used to control sorting/resorting/etc. - uint8 sort_type; ///< what criteria to sort on - uint8 filter_type; ///< what criteria to filter on - uint16 resort_timer; ///< resort list after a given amount of ticks if set + uint8_t sort_type; ///< what criteria to sort on + uint8_t filter_type; ///< what criteria to filter on + uint16_t resort_timer; ///< resort list after a given amount of ticks if set /** * Check if the list is sortable @@ -90,7 +90,7 @@ public: * * @return The current sorttype */ - uint8 SortType() const + uint8_t SortType() const { return this->sort_type; } @@ -100,7 +100,7 @@ public: * * @param n_type the new sort type */ - void SetSortType(uint8 n_type) + void SetSortType(uint8_t n_type) { if (this->sort_type != n_type) { SETBITS(this->flags, VL_RESORT); @@ -142,7 +142,7 @@ public: * * @return The current filtertype */ - uint8 FilterType() const + uint8_t FilterType() const { return this->filter_type; } @@ -152,7 +152,7 @@ public: * * @param n_type the new filter type */ - void SetFilterType(uint8 n_type) + void SetFilterType(uint8_t n_type) { if (this->filter_type != n_type) { this->filter_type = n_type; diff --git a/src/sound.cpp b/src/sound.cpp index 0fa435c26c..870df98920 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -75,8 +75,8 @@ static void OpenBankFile(const std::string &filename) /* Read riff tags */ for (;;) { - uint32 tag = original_sound_file->ReadDword(); - uint32 size = original_sound_file->ReadDword(); + uint32_t tag = original_sound_file->ReadDword(); + uint32_t size = original_sound_file->ReadDword(); if (tag == ' tmf') { original_sound_file->ReadWord(); // wFormatTag @@ -119,7 +119,7 @@ static bool SetBankSource(MixerChannel *mc, const SoundEntry *sound) /* Check for valid sound size. */ if (sound->file_size == 0 || sound->file_size > ((size_t)-1) - 2) return false; - int8 *mem = MallocT(sound->file_size + 2); + int8_t *mem = MallocT(sound->file_size + 2); /* Add two extra bytes so rate conversion can read these * without reading out of its input buffer. */ mem[sound->file_size ] = 0; @@ -139,7 +139,7 @@ static bool SetBankSource(MixerChannel *mc, const SoundEntry *sound) #if TTD_ENDIAN == TTD_BIG_ENDIAN if (sound->bits_per_sample == 16) { uint num_samples = sound->file_size / 2; - int16 *samples = (int16 *)mem; + int16_t *samples = (int16_t *)mem; for (uint i = 0; i < num_samples; i++) { samples[i] = BSWAP16(samples[i]); } diff --git a/src/sound/allegro_s.cpp b/src/sound/allegro_s.cpp index 92b5262a92..1b695e8a43 100644 --- a/src/sound/allegro_s.cpp +++ b/src/sound/allegro_s.cpp @@ -37,7 +37,7 @@ void SoundDriver_Allegro::MainLoop() MxMixSamples(data, _buffer_size); /* Allegro sound is always unsigned, so we need to correct that */ - uint16 *snd = (uint16*)data; + uint16_t *snd = (uint16_t*)data; for (int i = 0; i < _buffer_size * 2; i++) snd[i] ^= 0x8000; /* Tell we've filled the stream */ diff --git a/src/sound_type.h b/src/sound_type.h index 02bfc4f835..adc1438e6b 100644 --- a/src/sound_type.h +++ b/src/sound_type.h @@ -14,11 +14,11 @@ struct SoundEntry { class RandomAccessFile *file; size_t file_offset; size_t file_size; - uint16 rate; - uint8 bits_per_sample; - uint8 channels; - uint8 volume; - uint8 priority; + uint16_t rate; + uint8_t bits_per_sample; + uint8_t channels; + uint8_t volume; + uint8_t priority; byte grf_container_ver; ///< NewGRF container version if the sound is from a NewGRF. }; @@ -115,7 +115,7 @@ enum SoundFx { /** The number of sounds in the original sample.cat */ static const uint ORIGINAL_SAMPLE_COUNT = 73; -typedef uint16 SoundID; +typedef uint16_t SoundID; static const SoundID INVALID_SOUND = 0xFFFF; diff --git a/src/sprite.cpp b/src/sprite.cpp index 23dc63448b..eee9d03ae9 100644 --- a/src/sprite.cpp +++ b/src/sprite.cpp @@ -27,7 +27,7 @@ * @param default_palette The default recolour sprite to use (typically company colour) * @param child_offset_is_unsigned Whether child sprite offsets are interpreted signed or unsigned */ -void DrawCommonTileSeq(const TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 orig_offset, uint32 newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned) +void DrawCommonTileSeq(const TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32_t orig_offset, uint32_t newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned) { bool parent_sprite_encountered = false; const DrawTileSeqStruct *dtss; @@ -63,8 +63,8 @@ void DrawCommonTileSeq(const TileInfo *ti, const DrawTileSprites *dts, Transpare !HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(to) ); } else { - int offs_x = child_offset_is_unsigned ? (uint8)dtss->delta_x : dtss->delta_x; - int offs_y = child_offset_is_unsigned ? (uint8)dtss->delta_y : dtss->delta_y; + int offs_x = child_offset_is_unsigned ? (uint8_t)dtss->delta_x : dtss->delta_x; + int offs_y = child_offset_is_unsigned ? (uint8_t)dtss->delta_y : dtss->delta_y; bool transparent = !HasBit(image, SPRITE_MODIFIER_OPAQUE) && IsTransparencySet(to); if (parent_sprite_encountered) { AddChildSpriteScreen(image, pal, offs_x, offs_y, transparent); @@ -89,7 +89,7 @@ void DrawCommonTileSeq(const TileInfo *ti, const DrawTileSprites *dts, Transpare * @param default_palette The default recolour sprite to use (typically company colour) * @param child_offset_is_unsigned Whether child sprite offsets are interpreted signed or unsigned */ -void DrawCommonTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 orig_offset, uint32 newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned) +void DrawCommonTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32_t orig_offset, uint32_t newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned) { const DrawTileSeqStruct *dtss; Point child_offset = {0, 0}; @@ -123,8 +123,8 @@ void DrawCommonTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 orig child_offset.x = UnScaleGUI(pt.x + spr->x_offs); child_offset.y = UnScaleGUI(pt.y + spr->y_offs); } else { - int offs_x = child_offset_is_unsigned ? (uint8)dtss->delta_x : dtss->delta_x; - int offs_y = child_offset_is_unsigned ? (uint8)dtss->delta_y : dtss->delta_y; + int offs_x = child_offset_is_unsigned ? (uint8_t)dtss->delta_x : dtss->delta_x; + int offs_y = child_offset_is_unsigned ? (uint8_t)dtss->delta_y : dtss->delta_y; DrawSprite(image, pal, x + child_offset.x + ScaleSpriteTrad(offs_x), y + child_offset.y + ScaleSpriteTrad(offs_y)); } } diff --git a/src/sprite.h b/src/sprite.h index 44814c09b9..39d8e7f4e1 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -23,9 +23,9 @@ /** A tile child sprite and palette to draw for stations etc, with 3D bounding box */ struct DrawTileSeqStruct { - int8 delta_x; ///< \c 0x80 is sequence terminator - int8 delta_y; - int8 delta_z; ///< \c 0x80 identifies child sprites + int8_t delta_x; ///< \c 0x80 is sequence terminator + int8_t delta_y; + int8_t delta_z; ///< \c 0x80 identifies child sprites byte size_x; byte size_y; byte size_z; @@ -34,7 +34,7 @@ struct DrawTileSeqStruct { /** Make this struct a sequence terminator. */ void MakeTerminator() { - this->delta_x = (int8)0x80; + this->delta_x = (int8_t)0x80; } /** Check whether this is a sequence terminator. */ @@ -78,15 +78,15 @@ struct DrawBuildingsTileStruct { /** Iterate through all DrawTileSeqStructs in DrawTileSprites. */ #define foreach_draw_tile_seq(idx, list) for (idx = list; !idx->IsTerminator(); idx++) -void DrawCommonTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 orig_offset, uint32 newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned); -void DrawCommonTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 orig_offset, uint32 newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned); +void DrawCommonTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32_t orig_offset, uint32_t newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned); +void DrawCommonTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32_t orig_offset, uint32_t newgrf_offset, PaletteID default_palette, bool child_offset_is_unsigned); /** * Draw tile sprite sequence on tile with railroad specifics. * @param total_offset Spriteoffset from normal rail to current railtype. * @param newgrf_offset Startsprite of the Action1 to use. */ -static inline void DrawRailTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32 total_offset, uint32 newgrf_offset, PaletteID default_palette) +static inline void DrawRailTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32_t total_offset, uint32_t newgrf_offset, PaletteID default_palette) { DrawCommonTileSeq(ti, dts, to, total_offset, newgrf_offset, default_palette, false); } @@ -96,7 +96,7 @@ static inline void DrawRailTileSeq(const struct TileInfo *ti, const DrawTileSpri * @param total_offset Spriteoffset from normal rail to current railtype. * @param newgrf_offset Startsprite of the Action1 to use. */ -static inline void DrawRailTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32 total_offset, uint32 newgrf_offset, PaletteID default_palette) +static inline void DrawRailTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32_t total_offset, uint32_t newgrf_offset, PaletteID default_palette) { DrawCommonTileSeqInGUI(x, y, dts, total_offset, newgrf_offset, default_palette, false); } @@ -121,7 +121,7 @@ static inline void DrawOrigTileSeqInGUI(int x, int y, const DrawTileSprites *dts * Draw NewGRF industrytile or house sprite layout * @param stage Sprite inside the Action1 spritesets to use, i.e. construction stage. */ -static inline void DrawNewGRFTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, uint32 stage, PaletteID default_palette) +static inline void DrawNewGRFTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, uint32_t stage, PaletteID default_palette) { DrawCommonTileSeq(ti, dts, to, 0, stage, default_palette, true); } @@ -130,7 +130,7 @@ static inline void DrawNewGRFTileSeq(const struct TileInfo *ti, const DrawTileSp * Draw NewGRF object in GUI * @param stage Sprite inside the Action1 spritesets to use, i.e. construction stage. */ -static inline void DrawNewGRFTileSeqInGUI(int x, int y, const DrawTileSprites *dts, uint32 stage, PaletteID default_palette) +static inline void DrawNewGRFTileSeqInGUI(int x, int y, const DrawTileSprites *dts, uint32_t stage, PaletteID default_palette) { DrawCommonTileSeqInGUI(x, y, dts, 0, stage, default_palette, true); } diff --git a/src/spritecache.cpp b/src/spritecache.cpp index e5acc50b66..a140cf7897 100644 --- a/src/spritecache.cpp +++ b/src/spritecache.cpp @@ -33,8 +33,8 @@ struct SpriteCache { void *ptr; size_t file_pos; SpriteFile *file; ///< The file the sprite in this entry can be found in. - uint32 id; - int16 lru; + uint32_t id; + int16_t lru; SpriteType type; ///< In some cases a single sprite is misused by two NewGRFs. Once as real sprite and once as recolour sprite. If the recolour sprite gets into the cache it might be drawn as real sprite which causes enormous trouble. bool warned; ///< True iff the user has been warned about incorrect use of this sprite byte control_flags; ///< Control flags, see SpriteCacheCtrlFlags @@ -124,13 +124,13 @@ static void *AllocSprite(size_t mem_req); * @param num the amount of sprites to skip * @return true if the data could be correctly skipped. */ -bool SkipSpriteData(SpriteFile &file, byte type, uint16 num) +bool SkipSpriteData(SpriteFile &file, byte type, uint16_t num) { if (type & 2) { file.SkipBytes(num); } else { while (num > 0) { - int8 i = file.ReadByte(); + int8_t i = file.ReadByte(); if (i >= 0) { int size = (i == 0) ? 0x80 : i; if (size > num) return false; @@ -183,7 +183,7 @@ SpriteFile *GetOriginFile(SpriteID sprite) * @param sprite The sprite to look at. * @return The GRF-local sprite id. */ -uint32 GetSpriteLocalID(SpriteID sprite) +uint32_t GetSpriteLocalID(SpriteID sprite) { if (!SpriteExists(sprite)) return 0; return GetSpriteCache(sprite)->id; @@ -229,7 +229,7 @@ uint GetMaxSpriteID() static bool ResizeSpriteIn(SpriteLoader::Sprite *sprite, ZoomLevel src, ZoomLevel tgt) { - uint8 scaled_1 = ScaleByZoom(1, (ZoomLevel)(src - tgt)); + uint8_t scaled_1 = ScaleByZoom(1, (ZoomLevel)(src - tgt)); /* Check for possible memory overflow. */ if (sprite[src].width * scaled_1 > UINT16_MAX || sprite[src].height * scaled_1 > UINT16_MAX) return false; @@ -337,7 +337,7 @@ static bool PadSingleSprite(SpriteLoader::Sprite *sprite, ZoomLevel zoom, uint p return true; } -static bool PadSprites(SpriteLoader::Sprite *sprite, uint8 sprite_avail, SpriteEncoder *encoder) +static bool PadSprites(SpriteLoader::Sprite *sprite, uint8_t sprite_avail, SpriteEncoder *encoder) { /* Get minimum top left corner coordinates. */ int min_xoffs = INT32_MAX; @@ -385,7 +385,7 @@ static bool PadSprites(SpriteLoader::Sprite *sprite, uint8 sprite_avail, SpriteE return true; } -static bool ResizeSprites(SpriteLoader::Sprite *sprite, uint8 sprite_avail, SpriteEncoder *encoder) +static bool ResizeSprites(SpriteLoader::Sprite *sprite, uint8_t sprite_avail, SpriteEncoder *encoder) { /* Create a fully zoomed image if it does not exist */ ZoomLevel first_avail = static_cast(FIND_FIRST_BIT(sprite_avail)); @@ -472,7 +472,7 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty Debug(sprite, 9, "Load sprite {}", id); SpriteLoader::Sprite sprite[ZOOM_LVL_COUNT]; - uint8 sprite_avail = 0; + uint8_t sprite_avail = 0; sprite[ZOOM_LVL_NORMAL].type = sprite_type; SpriteLoaderGrf sprite_loader(file.GetContainerVersion()); @@ -542,14 +542,14 @@ struct GrfSpriteOffset { }; /** Map from sprite numbers to position in the GRF file. */ -static std::map _grf_sprite_offsets; +static std::map _grf_sprite_offsets; /** * Get the file offset for a specific sprite in the sprite section of a GRF. * @param id ID of the sprite to look up. * @return Position of the sprite in the sprite section or SIZE_MAX if no such sprite is present. */ -size_t GetGRFSpriteOffset(uint32 id) +size_t GetGRFSpriteOffset(uint32_t id) { return _grf_sprite_offsets.find(id) != _grf_sprite_offsets.end() ? _grf_sprite_offsets[id].file_pos : SIZE_MAX; } @@ -572,7 +572,7 @@ void ReadGRFSpriteOffsets(SpriteFile &file) /* Loop over all sprite section entries and store the file * offset for each newly encountered ID. */ - uint32 id, prev_id = 0; + uint32_t id, prev_id = 0; while ((id = file.ReadDword()) != 0) { if (id != prev_id) { _grf_sprite_offsets[prev_id] = offset; @@ -619,7 +619,7 @@ bool LoadNextSprite(int load_index, SpriteFile &file, uint file_sprite_id) size_t file_pos = file.GetPos(); /* Read sprite header. */ - uint32 num = file.GetContainerVersion() >= 2 ? file.ReadDword() : file.ReadWord(); + uint32_t num = file.GetContainerVersion() >= 2 ? file.ReadDword() : file.ReadWord(); if (num == 0) return false; byte grf_type = file.ReadByte(); diff --git a/src/spritecache.h b/src/spritecache.h index 52ebe68c25..ea0f607381 100644 --- a/src/spritecache.h +++ b/src/spritecache.h @@ -15,10 +15,10 @@ /** Data structure describing a sprite. */ struct Sprite { - uint16 height; ///< Height of the sprite. - uint16 width; ///< Width of the sprite. - int16 x_offs; ///< Number of pixels to shift the sprite to the right. - int16 y_offs; ///< Number of pixels to shift the sprite downwards. + uint16_t height; ///< Height of the sprite. + uint16_t width; ///< Width of the sprite. + int16_t x_offs; ///< Number of pixels to shift the sprite to the right. + int16_t y_offs; ///< Number of pixels to shift the sprite downwards. byte data[]; ///< Sprite data. }; @@ -39,7 +39,7 @@ bool SpriteExists(SpriteID sprite); SpriteType GetSpriteType(SpriteID sprite); SpriteFile *GetOriginFile(SpriteID sprite); -uint32 GetSpriteLocalID(SpriteID sprite); +uint32_t GetSpriteLocalID(SpriteID sprite); uint GetSpriteCountForFile(const std::string &filename, SpriteID begin, SpriteID end); uint GetMaxSpriteID(); @@ -64,9 +64,9 @@ void IncreaseSpriteLRU(); SpriteFile &OpenCachedSpriteFile(const std::string &filename, Subdirectory subdir, bool palette_remap); void ReadGRFSpriteOffsets(SpriteFile &file); -size_t GetGRFSpriteOffset(uint32 id); +size_t GetGRFSpriteOffset(uint32_t id); bool LoadNextSprite(int load_index, SpriteFile &file, uint file_sprite_id); -bool SkipSpriteData(SpriteFile &file, byte type, uint16 num); +bool SkipSpriteData(SpriteFile &file, byte type, uint16_t num); void DupSprite(SpriteID old_spr, SpriteID new_spr); #endif /* SPRITECACHE_H */ diff --git a/src/spriteloader/grf.cpp b/src/spriteloader/grf.cpp index e1e79e57bd..ce18212886 100644 --- a/src/spriteloader/grf.cpp +++ b/src/spriteloader/grf.cpp @@ -57,7 +57,7 @@ static bool WarnCorruptSprite(const SpriteFile &file, size_t file_pos, int line) * @param container_format Container format of the GRF this sprite is in. * @return True if the sprite was successfully loaded. */ -bool DecodeSingleSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, int64 num, byte type, ZoomLevel zoom_lvl, byte colour_fmt, byte container_format) +bool DecodeSingleSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, int64_t num, byte type, ZoomLevel zoom_lvl, byte colour_fmt, byte container_format) { /* * Original sprite height was max 255 pixels, with 4x extra zoom => 1020 pixels. @@ -70,11 +70,11 @@ bool DecodeSingleSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t f std::unique_ptr dest_orig(new byte[num]); byte *dest = dest_orig.get(); - const int64 dest_size = num; + const int64_t dest_size = num; /* Read the file, which has some kind of compression */ while (num > 0) { - int8 code = file.ReadByte(); + int8_t code = file.ReadByte(); if (code >= 0) { /* Plain bytes to read */ @@ -177,7 +177,7 @@ bool DecodeSingleSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t f } while (!last_item); } } else { - int64 sprite_size = static_cast(sprite->width) * sprite->height * bpp; + int64_t sprite_size = static_cast(sprite->width) * sprite->height * bpp; if (dest_size < sprite_size) { return WarnCorruptSprite(file, file_pos, __LINE__); } @@ -215,7 +215,7 @@ bool DecodeSingleSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t f return true; } -uint8 LoadSpriteV1(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp) +uint8_t LoadSpriteV1(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp) { /* Check the requested colour depth. */ if (load_32bpp) return 0; @@ -252,7 +252,7 @@ uint8 LoadSpriteV1(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_p return 0; } -uint8 LoadSpriteV2(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, byte control_flags) +uint8_t LoadSpriteV2(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, byte control_flags) { static const ZoomLevel zoom_lvl_map[6] = {ZOOM_LVL_OUT_4X, ZOOM_LVL_NORMAL, ZOOM_LVL_OUT_2X, ZOOM_LVL_OUT_8X, ZOOM_LVL_OUT_16X, ZOOM_LVL_OUT_32X}; @@ -262,11 +262,11 @@ uint8 LoadSpriteV2(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_p /* Open the right file and go to the correct position */ file.SeekTo(file_pos, SEEK_SET); - uint32 id = file.ReadDword(); + uint32_t id = file.ReadDword(); - uint8 loaded_sprites = 0; + uint8_t loaded_sprites = 0; do { - int64 num = file.ReadDword(); + int64_t num = file.ReadDword(); size_t start_pos = file.GetPos(); byte type = file.ReadByte(); @@ -350,7 +350,7 @@ uint8 LoadSpriteV2(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_p return loaded_sprites; } -uint8 SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, byte control_flags) +uint8_t SpriteLoaderGrf::LoadSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, byte control_flags) { if (this->container_ver >= 2) { return LoadSpriteV2(sprite, file, file_pos, sprite_type, load_32bpp, control_flags); diff --git a/src/spriteloader/grf.hpp b/src/spriteloader/grf.hpp index 27253bc398..d7d5d66d4e 100644 --- a/src/spriteloader/grf.hpp +++ b/src/spriteloader/grf.hpp @@ -17,7 +17,7 @@ class SpriteLoaderGrf : public SpriteLoader { byte container_ver; public: SpriteLoaderGrf(byte container_ver) : container_ver(container_ver) {} - uint8 LoadSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, byte control_flags); + uint8_t LoadSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, byte control_flags); }; #endif /* SPRITELOADER_GRF_HPP */ diff --git a/src/spriteloader/spriteloader.hpp b/src/spriteloader/spriteloader.hpp index 38b6186eeb..54d229b502 100644 --- a/src/spriteloader/spriteloader.hpp +++ b/src/spriteloader/spriteloader.hpp @@ -32,11 +32,11 @@ class SpriteLoader { public: /** Definition of a common pixel in OpenTTD's realm. */ struct CommonPixel { - uint8 r; ///< Red-channel - uint8 g; ///< Green-channel - uint8 b; ///< Blue-channel - uint8 a; ///< Alpha-channel - uint8 m; ///< Remap-channel + uint8_t r; ///< Red-channel + uint8_t g; ///< Green-channel + uint8_t b; ///< Blue-channel + uint8_t a; ///< Alpha-channel + uint8_t m; ///< Remap-channel }; /** @@ -46,10 +46,10 @@ public: * This to prevent thousands of malloc + frees just to load a sprite. */ struct Sprite { - uint16 height; ///< Height of the sprite - uint16 width; ///< Width of the sprite - int16 x_offs; ///< The x-offset of where the sprite will be drawn - int16 y_offs; ///< The y-offset of where the sprite will be drawn + uint16_t height; ///< Height of the sprite + uint16_t width; ///< Width of the sprite + int16_t x_offs; ///< The x-offset of where the sprite will be drawn + int16_t y_offs; ///< The y-offset of where the sprite will be drawn SpriteType type; ///< The sprite type SpriteColourComponent colours; ///< The colour components of the sprite with useful information. SpriteLoader::CommonPixel *data; ///< The sprite itself @@ -75,7 +75,7 @@ public: * @param control_flags Control flags, see SpriteCacheCtrlFlags. * @return Bit mask of the zoom levels successfully loaded or 0 if no sprite could be loaded. */ - virtual uint8 LoadSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, byte control_flags) = 0; + virtual uint8_t LoadSprite(SpriteLoader::Sprite *sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, byte control_flags) = 0; virtual ~SpriteLoader() = default; }; diff --git a/src/station_base.h b/src/station_base.h index 45c85c04c2..649a34414c 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -30,7 +30,7 @@ static const byte INITIAL_STATION_RATING = 175; */ class FlowStat { public: - typedef std::map SharesMap; + typedef std::map SharesMap; static const SharesMap empty_sharesmap; @@ -300,7 +300,7 @@ struct GoodsEntry { struct Airport : public TileArea { Airport() : TileArea(INVALID_TILE, 0, 0) {} - uint64 flags; ///< stores which blocks on the airport are taken. was 16 bit earlier on, then 32 + uint64_t flags; ///< stores which blocks on the airport are taken. was 16 bit earlier on, then 32 byte type; ///< Type of this airport, @see AirportTypes byte layout; ///< Airport layout number. Direction rotation; ///< How this airport is rotated. @@ -529,7 +529,7 @@ public: return IsAirportTile(tile) && GetStationIndex(tile) == this->index; } - uint32 GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const override; + uint32_t GetNewGRFVariable(const ResolverObject &object, byte variable, byte parameter, bool *available) const override; void GetTileArea(TileArea *ta, StationType type) const override; }; diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 33df1a2c18..10ab53f652 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -215,7 +215,7 @@ enum StationNaming { /** Information to handle station action 0 property 24 correctly */ struct StationNameInformation { - uint32 free_names; ///< Current bitset of free names (we can remove names). + uint32_t free_names; ///< Current bitset of free names (we can remove names). bool *indtypes; ///< Array of bools telling whether an industry type has been found. }; @@ -245,7 +245,7 @@ static bool FindNearIndustryName(TileIndex tile, void *user_data) static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming name_class) { - static const uint32 _gen_station_name_bits[] = { + static const uint32_t _gen_station_name_bits[] = { 0, // STATIONNAMING_RAIL 0, // STATIONNAMING_ROAD 1U << M(STR_SV_STNAME_AIRPORT), // STATIONNAMING_AIRPORT @@ -255,7 +255,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n }; const Town *t = st->town; - uint32 free_names = UINT32_MAX; + uint32_t free_names = UINT32_MAX; bool indtypes[NUM_INDUSTRYTYPES]; memset(indtypes, 0, sizeof(indtypes)); @@ -301,7 +301,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n free_names = sni.free_names; /* check default names */ - uint32 tmp = free_names & _gen_station_name_bits[name_class]; + uint32_t tmp = free_names & _gen_station_name_bits[name_class]; if (tmp != 0) return STR_SV_STNAME + FindFirstBit(tmp); /* check mine? */ @@ -343,7 +343,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n } /* check direction compared to town */ - static const int8 _direction_and_table[] = { + static const int8_t _direction_and_table[] = { ~( (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ), ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_NORTH)) ), ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ), @@ -1374,7 +1374,7 @@ CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailTyp /* Check if the station is buildable */ if (HasBit(statspec->callback_mask, CBM_STATION_AVAIL)) { - uint16 cb_res = GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, nullptr, INVALID_TILE); + uint16_t cb_res = GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, nullptr, INVALID_TILE); if (cb_res != CALLBACK_FAILED && !Convert8bitBooleanCallback(statspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res)) return CMD_ERROR; } } @@ -1442,10 +1442,10 @@ CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailTyp if (statspec != nullptr) { /* Use a fixed axis for GetPlatformInfo as our platforms / numtracks are always the right way around */ - uint32 platinfo = GetPlatformInfo(AXIS_X, GetStationGfx(tile), plat_len, numtracks_orig, plat_len - w, numtracks_orig - numtracks, false); + uint32_t platinfo = GetPlatformInfo(AXIS_X, GetStationGfx(tile), plat_len, numtracks_orig, plat_len - w, numtracks_orig - numtracks, false); /* As the station is not yet completely finished, the station does not yet exist. */ - uint16 callback = GetStationCallback(CBID_STATION_TILE_LAYOUT, platinfo, 0, statspec, nullptr, tile); + uint16_t callback = GetStationCallback(CBID_STATION_TILE_LAYOUT, platinfo, 0, statspec, nullptr, tile); if (callback != CALLBACK_FAILED) { if (callback < 8) { SetStationGfx(tile, (callback & ~1) + axis); @@ -1913,7 +1913,7 @@ static CommandCost CalculateRoadStopCost(TileArea tile_area, DoCommandFlag flags * @param adjacent Allow stations directly adjacent to other stations. * @return The cost of this operation or an error. */ -CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint8 length, RoadStopType stop_type, bool is_drive_through, +CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width, uint8_t length, RoadStopType stop_type, bool is_drive_through, DiagDirection ddir, RoadType rt, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent) { if (!ValParamRoadType(rt) || !IsValidDiagDirection(ddir) || stop_type >= ROADSTOP_END) return CMD_ERROR; @@ -1983,7 +1983,7 @@ CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, u /* Check if the road stop is buildable */ if (HasBit(roadstopspec->callback_mask, CBM_ROAD_STOP_AVAIL)) { - uint16 cb_res = GetRoadStopCallback(CBID_STATION_AVAILABILITY, 0, 0, roadstopspec, nullptr, INVALID_TILE, rt, is_truck_stop ? STATION_TRUCK : STATION_BUS, 0); + uint16_t cb_res = GetRoadStopCallback(CBID_STATION_AVAILABILITY, 0, 0, roadstopspec, nullptr, INVALID_TILE, rt, is_truck_stop ? STATION_TRUCK : STATION_BUS, 0); if (cb_res != CALLBACK_FAILED && !Convert8bitBooleanCallback(roadstopspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res)) return CMD_ERROR; } } @@ -2199,7 +2199,7 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags, int repla * @param remove_road Remove roads of drive-through stops? * @return The cost of this operation or an error. */ -CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint8 height, RoadStopType stop_type, bool remove_road) +CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width, uint8_t height, RoadStopType stop_type, bool remove_road) { if (stop_type >= ROADSTOP_END) return CMD_ERROR; /* Check for incorrect width / height. */ @@ -2265,7 +2265,7 @@ CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, * @param distance minimum distance between town and airport * @return the noise that will be generated, according to distance */ -uint8 GetAirportNoiseLevelForDistance(const AirportSpec *as, uint distance) +uint8_t GetAirportNoiseLevelForDistance(const AirportSpec *as, uint distance) { /* 0 cannot be accounted, and 1 is the lowest that can be reduced from town. * So no need to go any further*/ @@ -2275,7 +2275,7 @@ uint8 GetAirportNoiseLevelForDistance(const AirportSpec *as, uint distance) * adding the town_council_tolerance 4 times, as a way to graduate, depending of the tolerance. * Basically, it says that the less tolerant a town is, the bigger the distance before * an actual decrease can be granted */ - uint8 town_tolerance_distance = 8 + (_settings_game.difficulty.town_council_tolerance * 4); + uint8_t town_tolerance_distance = 8 + (_settings_game.difficulty.town_council_tolerance * 4); /* now, we want to have the distance segmented using the distance judged bareable by town * This will give us the coefficient of reduction the distance provides. */ @@ -2923,10 +2923,10 @@ static void DrawTile_Station(TileInfo *ti) const NewGRFSpriteLayout *layout = nullptr; DrawTileSprites tmp_rail_layout; const DrawTileSprites *t = nullptr; - int32 total_offset; + int32_t total_offset; const RailtypeInfo *rti = nullptr; - uint32 relocation = 0; - uint32 ground_relocation = 0; + uint32_t relocation = 0; + uint32_t ground_relocation = 0; BaseStation *st = nullptr; const StationSpec *statspec = nullptr; uint tile_layout = 0; @@ -2944,7 +2944,7 @@ static void DrawTile_Station(TileInfo *ti) tile_layout = GetStationGfx(ti->tile); if (HasBit(statspec->callback_mask, CBM_STATION_SPRITE_LAYOUT)) { - uint16 callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0, 0, statspec, st, ti->tile); + uint16_t callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0, 0, statspec, st, ti->tile); if (callback != CALLBACK_FAILED) tile_layout = (callback & ~1) + GetRailStationAxis(ti->tile); } @@ -3022,7 +3022,7 @@ static void DrawTile_Station(TileInfo *ti) if (HasBit(statspec->flags, SSF_EXTENDED_FOUNDATIONS)) { /* Station provides extended foundations. */ - static const uint8 foundation_parts[] = { + static const uint8_t foundation_parts[] = { 0, 0, 0, 0, // Invalid, Invalid, Invalid, SLOPE_SW 0, 1, 2, 3, // Invalid, SLOPE_EW, SLOPE_SE, SLOPE_WSE 0, 4, 5, 6, // Invalid, SLOPE_NW, SLOPE_NS, SLOPE_NWS @@ -3035,7 +3035,7 @@ static void DrawTile_Station(TileInfo *ti) /* Each set bit represents one of the eight composite sprites to be drawn. * 'Invalid' entries will not drawn but are included for completeness. */ - static const uint8 composite_foundation_parts[] = { + static const uint8_t composite_foundation_parts[] = { /* Invalid (00000000), Invalid (11010001), Invalid (11100100), SLOPE_SW (11100000) */ 0x00, 0xD1, 0xE4, 0xE0, /* Invalid (11001010), SLOPE_EW (11001001), SLOPE_SE (11000100), SLOPE_WSE (11000000) */ @@ -3046,7 +3046,7 @@ static void DrawTile_Station(TileInfo *ti) 0x4A, 0x09, 0x44 }; - uint8 parts = composite_foundation_parts[ti->tileh]; + uint8_t parts = composite_foundation_parts[ti->tileh]; /* If foundations continue beyond the tile's upper sides then * mask out the last two pieces. */ @@ -3100,9 +3100,9 @@ draw_default_foundation: if (layout != nullptr) { /* Sprite layout which needs preprocessing */ bool separate_ground = HasBit(statspec->flags, SSF_SEPARATE_GROUND); - uint32 var10_values = layout->PrepareLayout(total_offset, rti->fallback_railtype, 0, 0, separate_ground); - for (uint8 var10 : SetBitIterator(var10_values)) { - uint32 var10_relocation = GetCustomStationRelocation(statspec, st, ti->tile, var10); + uint32_t var10_values = layout->PrepareLayout(total_offset, rti->fallback_railtype, 0, 0, separate_ground); + for (uint8_t var10 : SetBitIterator(var10_values)) { + uint32_t var10_relocation = GetCustomStationRelocation(statspec, st, ti->tile, var10); layout->ProcessRegisters(var10, var10_relocation, separate_ground); } tmp_rail_layout.seq = layout->GetLayout(&tmp_rail_layout.ground); @@ -3208,7 +3208,7 @@ draw_default_foundation: void StationPickerDrawSprite(int x, int y, StationType st, RailType railtype, RoadType roadtype, int image) { - int32 total_offset = 0; + int32_t total_offset = 0; PaletteID pal = COMPANY_SPRITE_COLOUR(_local_company); const DrawTileSprites *t = GetStationTileLayout(st, image); const RailtypeInfo *railtype_info = nullptr; @@ -3510,7 +3510,7 @@ static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, i return VETSB_ENTERED_STATION | (VehicleEnterTileStatus)(station_id << VETS_STATION_ID_OFFSET); // enter station } else if (x < stop) { v->vehstatus |= VS_TRAIN_SLOWING; - uint16 spd = std::max(0, (stop - x) * 20 - 15); + uint16_t spd = std::max(0, (stop - x) * 20 - 15); if (spd < v->cur_speed) v->cur_speed = spd; } } @@ -3657,12 +3657,12 @@ static void UpdateStationRating(Station *st) /* NewGRFs expect last speed to be 0xFF when no vehicle has arrived yet. */ uint last_speed = ge->HasVehicleEverTriedLoading() ? ge->last_speed : 0xFF; - uint32 var18 = ClampTo(ge->time_since_pickup) + uint32_t var18 = ClampTo(ge->time_since_pickup) | (ClampTo(ge->max_waiting_cargo) << 8) | (ClampTo(last_speed) << 24); /* Convert to the 'old' vehicle types */ - uint32 var10 = (st->last_vehicle_type == VEH_INVALID) ? 0x0 : (st->last_vehicle_type + 0x10); - uint16 callback = GetCargoCallback(CBID_CARGO_STATION_RATING_CALC, var10, var18, cs); + uint32_t var10 = (st->last_vehicle_type == VEH_INVALID) ? 0x0 : (st->last_vehicle_type + 0x10); + uint16_t callback = GetCargoCallback(CBID_CARGO_STATION_RATING_CALC, var10, var18, cs); if (callback != CALLBACK_FAILED) { skip = true; rating = GB(callback, 0, 14); @@ -3715,7 +3715,7 @@ static void UpdateStationRating(Station *st) /* if rating is <= 127 and there are any items waiting, maybe remove some goods. */ if (rating <= 127 && waiting != 0) { - uint32 r = Random(); + uint32_t r = Random(); if (rating <= (int)GB(r, 0, 7)) { /* Need to have int, otherwise it will just overflow etc. */ waiting = std::max((int)waiting - (int)((GB(r, 8, 2) - 1) * num_dests), 0); @@ -3889,7 +3889,7 @@ void DeleteStaleLinks(Station *from) * @param usage Usage to add to link stat. * @param mode Update mode to be applied. */ -void IncreaseStats(Station *st, CargoID cargo, StationID next_station_id, uint capacity, uint usage, uint32 time, EdgeUpdateMode mode) +void IncreaseStats(Station *st, CargoID cargo, StationID next_station_id, uint capacity, uint usage, uint32_t time, EdgeUpdateMode mode) { GoodsEntry &ge1 = st->goods[cargo]; Station *st2 = Station::Get(next_station_id); @@ -3941,7 +3941,7 @@ void IncreaseStats(Station *st, CargoID cargo, StationID next_station_id, uint c * @param front First vehicle in the consist. * @param next_station_id Station the consist will be travelling to next. */ -void IncreaseStats(Station *st, const Vehicle *front, StationID next_station_id, uint32 time) +void IncreaseStats(Station *st, const Vehicle *front, StationID next_station_id, uint32_t time) { for (const Vehicle *v = front; v != nullptr; v = v->Next()) { if (v->refit_cap > 0) { @@ -4527,7 +4527,7 @@ static CommandCost TerraformTile_Station(TileIndex tile, DoCommandFlag flags, in */ uint FlowStat::GetShare(StationID st) const { - uint32 prev = 0; + uint32_t prev = 0; for (const auto &it : this->shares) { if (it.second == st) { return it.first - prev; diff --git a/src/station_cmd.h b/src/station_cmd.h index 9eb4277301..9359daf453 100644 --- a/src/station_cmd.h +++ b/src/station_cmd.h @@ -17,14 +17,14 @@ enum StationClassID : byte; enum RoadStopClassID : byte; extern Town *AirportGetNearestTown(const struct AirportSpec *as, const TileIterator &it, uint &mindist); -extern uint8 GetAirportNoiseLevelForDistance(const struct AirportSpec *as, uint distance); +extern uint8_t GetAirportNoiseLevelForDistance(const struct AirportSpec *as, uint distance); CommandCost CmdBuildAirport(DoCommandFlag flags, TileIndex tile, byte airport_type, byte layout, StationID station_to_join, bool allow_adjacent); CommandCost CmdBuildDock(DoCommandFlag flags, TileIndex tile, StationID station_to_join, bool adjacent); CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailType rt, Axis axis, byte numtracks, byte plat_len, StationClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent); CommandCost CmdRemoveFromRailStation(DoCommandFlag flags, TileIndex start, TileIndex end, bool keep_rail); -CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint8 length, RoadStopType stop_type, bool is_drive_through, DiagDirection ddir, RoadType rt, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent); -CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8 width, uint8 height, RoadStopType stop_type, bool remove_road); +CommandCost CmdBuildRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width, uint8_t length, RoadStopType stop_type, bool is_drive_through, DiagDirection ddir, RoadType rt, RoadStopClassID spec_class, uint16_t spec_index, StationID station_to_join, bool adjacent); +CommandCost CmdRemoveRoadStop(DoCommandFlag flags, TileIndex tile, uint8_t width, uint8_t height, RoadStopType stop_type, bool remove_road); CommandCost CmdRenameStation(DoCommandFlag flags, StationID station_id, const std::string &text); CommandCost CmdOpenCloseAirport(DoCommandFlag flags, StationID station_id); diff --git a/src/station_func.h b/src/station_func.h index 65b9ac5e62..8d96c473ab 100644 --- a/src/station_func.h +++ b/src/station_func.h @@ -52,8 +52,8 @@ void UpdateAirportsNoise(); bool SplitGroundSpriteForOverlay(const TileInfo *ti, SpriteID *ground, RailTrackOffset *overlay_offset); -void IncreaseStats(Station *st, const Vehicle *v, StationID next_station_id, uint32 time); -void IncreaseStats(Station *st, CargoID cargo, StationID next_station_id, uint capacity, uint usage, uint32 time, EdgeUpdateMode mode); +void IncreaseStats(Station *st, const Vehicle *v, StationID next_station_id, uint32_t time); +void IncreaseStats(Station *st, CargoID cargo, StationID next_station_id, uint capacity, uint usage, uint32_t time, EdgeUpdateMode mode); void RerouteCargo(Station *st, CargoID c, StationID avoid, StationID avoid2); /** @@ -61,7 +61,7 @@ void RerouteCargo(Station *st, CargoID c, StationID avoid, StationID avoid2); * @param num Number of station tiles. * @return Total cost. */ -static inline Money StationMaintenanceCost(uint32 num) +static inline Money StationMaintenanceCost(uint32_t num) { return (_price[PR_INFRASTRUCTURE_STATION] * num * (1 + IntSqrt(num))) >> 7; // 7 bits scaling. } diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 236b8fc7dc..941d309494 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -362,7 +362,7 @@ public: this->FinishInitNested(window_number); this->owner = (Owner)this->window_number; - uint8 index = 0; + uint8_t index = 0; for (const CargoSpec *cs : _sorted_standard_cargo_specs) { if (HasBit(this->cargo_filter, cs->Index())) { this->LowerWidget(WID_STL_CARGOSTART + index); @@ -1485,7 +1485,7 @@ struct StationViewWindow : public Window { for (const auto &it : st->goods[i].flows) { StationID from = it.first; CargoDataEntry *source_entry = cargo_entry->InsertOrRetrieve(from); - uint32 prev_count = 0; + uint32_t prev_count = 0; for (const auto &flow_it : *it.second.GetShares()) { StationID via = flow_it.second; CargoDataEntry *via_entry = source_entry->InsertOrRetrieve(via); @@ -1516,7 +1516,7 @@ struct StationViewWindow : public Window { FlowStatMap::const_iterator map_it = flowmap.find(source); if (map_it != flowmap.end()) { const FlowStat::SharesMap *shares = map_it->second.GetShares(); - uint32 prev_count = 0; + uint32_t prev_count = 0; for (FlowStat::SharesMap::const_iterator i = shares->begin(); i != shares->end(); ++i) { tmp.InsertOrRetrieve(i->second)->Update(i->first - prev_count); prev_count = i->first; diff --git a/src/station_kdtree.h b/src/station_kdtree.h index 63d7c393ec..11dd8b0679 100644 --- a/src/station_kdtree.h +++ b/src/station_kdtree.h @@ -15,8 +15,8 @@ #include "station_base.h" #include "map_func.h" -inline uint16 Kdtree_StationXYFunc(StationID stid, int dim) { return (dim == 0) ? TileX(BaseStation::Get(stid)->xy) : TileY(BaseStation::Get(stid)->xy); } -typedef Kdtree StationKdtree; +inline uint16_t Kdtree_StationXYFunc(StationID stid, int dim) { return (dim == 0) ? TileX(BaseStation::Get(stid)->xy) : TileY(BaseStation::Get(stid)->xy); } +typedef Kdtree StationKdtree; extern StationKdtree _station_kdtree; /** @@ -28,11 +28,11 @@ extern StationKdtree _station_kdtree; template void ForAllStationsRadius(TileIndex center, uint radius, Func func) { - uint16 x1, y1, x2, y2; - x1 = (uint16)std::max(0, TileX(center) - radius); - x2 = (uint16)std::min(TileX(center) + radius + 1, Map::SizeX()); - y1 = (uint16)std::max(0, TileY(center) - radius); - y2 = (uint16)std::min(TileY(center) + radius + 1, Map::SizeY()); + uint16_t x1, y1, x2, y2; + x1 = (uint16_t)std::max(0, TileX(center) - radius); + x2 = (uint16_t)std::min(TileX(center) + radius + 1, Map::SizeX()); + y1 = (uint16_t)std::max(0, TileY(center) - radius); + y2 = (uint16_t)std::min(TileY(center) + radius + 1, Map::SizeY()); _station_kdtree.FindContained(x1, y1, x2, y2, [&](StationID id) { func(Station::Get(id)); diff --git a/src/station_type.h b/src/station_type.h index 8056feb57e..345e900536 100644 --- a/src/station_type.h +++ b/src/station_type.h @@ -13,8 +13,8 @@ #include "core/smallstack_type.hpp" #include "tilearea_type.h" -typedef uint16 StationID; -typedef uint16 RoadStopID; +typedef uint16_t StationID; +typedef uint16_t RoadStopID; struct BaseStation; struct Station; diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index 0a56a0c816..bd80f743d0 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -73,7 +73,7 @@ struct StatusBarWindow : Window { PositionStatusbar(this); } - Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override + Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override { Point pt = { 0, _screen.height - sm_height }; return pt; @@ -94,8 +94,8 @@ struct StatusBarWindow : Window { break; case WID_S_RIGHT: { - int64 max_money = UINT32_MAX; - for (const Company *c : Company::Iterate()) max_money = std::max(c->money, max_money); + int64_t max_money = UINT32_MAX; + for (const Company *c : Company::Iterate()) max_money = std::max(c->money, max_money); SetDParam(0, 100LL * max_money); d = GetStringBoundingBox(STR_JUST_CURRENCY_LONG); break; diff --git a/src/story.cpp b/src/story.cpp index e5758a1b8e..a3d86c59da 100644 --- a/src/story.cpp +++ b/src/story.cpp @@ -29,8 +29,8 @@ #include "safeguards.h" -uint32 _story_page_element_next_sort_value; -uint32 _story_page_next_sort_value; +uint32_t _story_page_element_next_sort_value; +uint32_t _story_page_next_sort_value; StoryPageElementPool _story_page_element_pool("StoryPageElement"); StoryPagePool _story_page_pool("StoryPage"); @@ -47,7 +47,7 @@ INSTANTIATE_POOL_METHODS(StoryPage) * @param text The text parameter of the DoCommand proc * @return true, if and only if the given parameters are valid for the given page element type and page id. */ -static bool VerifyElementContentParameters(StoryPageID page_id, StoryPageElementType type, TileIndex tile, uint32 reference, const std::string &text) +static bool VerifyElementContentParameters(StoryPageID page_id, StoryPageElementType type, TileIndex tile, uint32_t reference, const std::string &text) { StoryPageButtonData button_data{ reference }; @@ -91,7 +91,7 @@ static bool VerifyElementContentParameters(StoryPageID page_id, StoryPageElement * @param reference The reference parameter of the DoCommand proc (p2) * @param text The text parameter of the DoCommand proc */ -static void UpdateElement(StoryPageElement &pe, TileIndex tile, uint32 reference, const std::string &text) +static void UpdateElement(StoryPageElement &pe, TileIndex tile, uint32_t reference, const std::string &text) { switch (pe.type) { case SPET_TEXT: @@ -242,12 +242,12 @@ std::tuple CmdCreateStoryPage(DoCommandFlag flags, Com * @param text Text content in case it is a text or location page element * @return the cost of this operation or an error */ -std::tuple CmdCreateStoryPageElement(DoCommandFlag flags, TileIndex tile, StoryPageID page_id, StoryPageElementType type, uint32 reference, const std::string &text) +std::tuple CmdCreateStoryPageElement(DoCommandFlag flags, TileIndex tile, StoryPageID page_id, StoryPageElementType type, uint32_t reference, const std::string &text) { if (!StoryPageElement::CanAllocateItem()) return { CMD_ERROR, INVALID_STORY_PAGE_ELEMENT }; /* Allow at most 128 elements per page. */ - uint16 element_count = 0; + uint16_t element_count = 0; for (StoryPageElement *iter : StoryPageElement::Iterate()) { if (iter->page == page_id) element_count++; } @@ -288,7 +288,7 @@ std::tuple CmdCreateStoryPageElement(DoCommandF * @param text Text content in case it is a text or location page element * @return the cost of this operation or an error */ -CommandCost CmdUpdateStoryPageElement(DoCommandFlag flags, TileIndex tile, StoryPageElementID page_element_id, uint32 reference, const std::string &text) +CommandCost CmdUpdateStoryPageElement(DoCommandFlag flags, TileIndex tile, StoryPageElementID page_element_id, uint32_t reference, const std::string &text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; if (!StoryPageElement::IsValidID(page_element_id)) return CMD_ERROR; diff --git a/src/story_base.h b/src/story_base.h index 3f4a292c3d..90f5c49d7d 100644 --- a/src/story_base.h +++ b/src/story_base.h @@ -21,8 +21,8 @@ typedef Pool StoryPageElementPo typedef Pool StoryPagePool; extern StoryPageElementPool _story_page_element_pool; extern StoryPagePool _story_page_pool; -extern uint32 _story_page_element_next_sort_value; -extern uint32 _story_page_next_sort_value; +extern uint32_t _story_page_element_next_sort_value; +extern uint32_t _story_page_next_sort_value; /* * Each story page element is one of these types. @@ -120,7 +120,7 @@ static inline bool IsValidStoryPageButtonCursor(StoryPageButtonCursor cursor) /** Helper to construct packed "id" values for button-type StoryPageElement */ struct StoryPageButtonData { - uint32 referenced_id; + uint32_t referenced_id; void SetColour(Colours button_colour); void SetFlags(StoryPageButtonFlags flags); @@ -142,11 +142,11 @@ struct StoryPageButtonData { * page content. Each element only contain one type of content. **/ struct StoryPageElement : StoryPageElementPool::PoolItem<&_story_page_element_pool> { - uint32 sort_value; ///< A number that increases for every created story page element. Used for sorting. The id of a story page element is the pool index. + uint32_t sort_value; ///< A number that increases for every created story page element. Used for sorting. The id of a story page element is the pool index. StoryPageID page; ///< Id of the page which the page element belongs to StoryPageElementType type; ///< Type of page element - uint32 referenced_id; ///< Id of referenced object (location, goal etc.) + uint32_t referenced_id; ///< Id of referenced object (location, goal etc.) std::string text; ///< Static content text of page element /** @@ -162,7 +162,7 @@ struct StoryPageElement : StoryPageElementPool::PoolItem<&_story_page_element_po /** Struct about stories, current and completed */ struct StoryPage : StoryPagePool::PoolItem<&_story_page_pool> { - uint32 sort_value; ///< A number that increases for every created story page. Used for sorting. The id of a story page is the pool index. + uint32_t sort_value; ///< A number that increases for every created story page. Used for sorting. The id of a story page is the pool index. TimerGameCalendar::Date date; ///< Date when the page was created. CompanyID company; ///< StoryPage is for a specific company; INVALID_COMPANY if it is global diff --git a/src/story_cmd.h b/src/story_cmd.h index 85651fe982..d71efa6383 100644 --- a/src/story_cmd.h +++ b/src/story_cmd.h @@ -17,8 +17,8 @@ #include "vehicle_type.h" std::tuple CmdCreateStoryPage(DoCommandFlag flags, CompanyID company, const std::string &text); -std::tuple CmdCreateStoryPageElement(DoCommandFlag flags, TileIndex tile, StoryPageID page_id, StoryPageElementType type, uint32 reference, const std::string &text); -CommandCost CmdUpdateStoryPageElement(DoCommandFlag flags, TileIndex tile, StoryPageElementID page_element_id, uint32 reference, const std::string &text); +std::tuple CmdCreateStoryPageElement(DoCommandFlag flags, TileIndex tile, StoryPageID page_id, StoryPageElementType type, uint32_t reference, const std::string &text); +CommandCost CmdUpdateStoryPageElement(DoCommandFlag flags, TileIndex tile, StoryPageElementID page_element_id, uint32_t reference, const std::string &text); CommandCost CmdSetStoryPageTitle(DoCommandFlag flags, StoryPageID page_id, const std::string &text); CommandCost CmdSetStoryPageDate(DoCommandFlag flags, StoryPageID page_id, TimerGameCalendar::Date date); CommandCost CmdShowStoryPage(DoCommandFlag flags, StoryPageID page_id); diff --git a/src/story_gui.cpp b/src/story_gui.cpp index 87369ce148..3ed03149c7 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -249,7 +249,7 @@ protected: DropDownList BuildDropDownList() const { DropDownList list; - uint16 page_num = 1; + uint16_t page_num = 1; for (const StoryPage *p : this->story_pages) { bool current_page = p->index == this->selected_page_id; if (!p->title.empty()) { @@ -632,7 +632,7 @@ public: * Sets the selected page. * @param page_index pool index of the page to select. */ - void SetSelectedPage(uint16 page_index) + void SetSelectedPage(uint16_t page_index) { if (this->selected_page_id != page_index) { if (this->active_button_id) ResetObjectToPlace(); @@ -1042,7 +1042,7 @@ static CursorID TranslateStoryPageButtonCursor(StoryPageButtonCursor cursor) * @param company 'Owner' of the story book, may be #INVALID_COMPANY. * @param page_id Page to open, may be #INVALID_STORY_PAGE. */ -void ShowStoryBook(CompanyID company, uint16 page_id) +void ShowStoryBook(CompanyID company, uint16_t page_id) { if (!Company::IsValidID(company)) company = (CompanyID)INVALID_COMPANY; diff --git a/src/story_type.h b/src/story_type.h index 386abe5e25..5df99c34c7 100644 --- a/src/story_type.h +++ b/src/story_type.h @@ -12,8 +12,8 @@ #include "core/enum_type.hpp" -typedef uint16 StoryPageElementID; ///< ID of a story page element -typedef uint16 StoryPageID; ///< ID of a story page +typedef uint16_t StoryPageElementID; ///< ID of a story page element +typedef uint16_t StoryPageID; ///< ID of a story page struct StoryPageElement; struct StoryPage; enum StoryPageElementType : byte; diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp index a2a8e79310..3f9334c62a 100644 --- a/src/strgen/strgen.cpp +++ b/src/strgen/strgen.cpp @@ -136,14 +136,14 @@ void FileStringReader::HandlePragma(char *str) if (langid > (long)UINT16_MAX || langid < 0) { FatalError("Invalid winlangid {}", buf); } - _lang.winlangid = (uint16)langid; + _lang.winlangid = (uint16_t)langid; } else if (!memcmp(str, "grflangid ", 10)) { const char *buf = str + 10; long langid = std::strtol(buf, nullptr, 16); if (langid >= 0x7F || langid < 0) { FatalError("Invalid grflangid {}", buf); } - _lang.newgrflangid = (uint8)langid; + _lang.newgrflangid = (uint8_t)langid; } else if (!memcmp(str, "gender ", 7)) { if (this->master) FatalError("Genders are not allowed in the base translation."); char *buf = str + 7; diff --git a/src/strgen/strgen_base.cpp b/src/strgen/strgen_base.cpp index 36b6bfcd00..1913b1925a 100644 --- a/src/strgen/strgen_base.cpp +++ b/src/strgen/strgen_base.cpp @@ -189,7 +189,7 @@ struct Buffer : std::vector { * Add an Unicode character encoded in UTF-8 to the buffer. * @param value The character to add. */ - void AppendUtf8(uint32 value) + void AppendUtf8(uint32_t value) { if (value < 0x80) { this->push_back(value); @@ -213,7 +213,7 @@ struct Buffer : std::vector { size_t Utf8Validate(const char *s) { - uint32 c; + uint32_t c; if (!HasBit(s[0], 7)) { /* 1 byte */ @@ -435,7 +435,7 @@ static uint ResolveCaseName(const char *str, size_t len) memcpy(case_str, str, len); case_str[len] = '\0'; - uint8 case_idx = _lang.GetCaseIndex(case_str); + uint8_t case_idx = _lang.GetCaseIndex(case_str); if (case_idx >= MAX_NUM_CASES) StrgenFatal("Invalid case-name '{}'", case_str); return case_idx + 1; } @@ -663,7 +663,7 @@ void StringReader::HandleString(char *str) size_t len = Utf8Validate(tmp); if (len == 0) StrgenFatal("Invalid UTF-8 sequence in '{}'", s); - WChar c; + char32_t c; Utf8Decode(&c, tmp); if (c <= 0x001F || // ASCII control character range c == 0x200B || // Zero width space diff --git a/src/string.cpp b/src/string.cpp index 1de35f66bf..7fc604e7ca 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -117,7 +117,7 @@ static void StrMakeValid(T &dst, const char *str, const char *last, StringValida while (str <= last && *str != '\0') { size_t len = Utf8EncodedCharLen(*str); - WChar c; + char32_t c; /* If the first byte does not look like the first byte of an encoded * character, i.e. encoded length is 0, then this byte is definitely bad * and it should be skipped. @@ -240,7 +240,7 @@ bool StrValid(const char *str, const char *last) * within the encoding of an UTF8 character. */ if (len == 0 || str + len > last) return false; - WChar c; + char32_t c; len = Utf8Decode(&c, str); if (!IsPrintable(c) || (c >= SCC_SPRITE_START && c <= SCC_SPRITE_END)) { return false; @@ -436,7 +436,7 @@ bool strtolower(std::string &str, std::string::size_type offs) * @param afilter the filter to use * @return true or false depending if the character is printable/valid or not */ -bool IsValidChar(WChar key, CharSetFilter afilter) +bool IsValidChar(char32_t key, CharSetFilter afilter) { switch (afilter) { case CS_ALPHANUMERAL: return IsPrintable(key); @@ -459,7 +459,7 @@ bool IsValidChar(WChar key, CharSetFilter afilter) * @param s Character stream to retrieve character from. * @return Number of characters in the sequence. */ -size_t Utf8Decode(WChar *c, const char *s) +size_t Utf8Decode(char32_t *c, const char *s) { assert(c != nullptr); @@ -500,7 +500,7 @@ size_t Utf8Decode(WChar *c, const char *s) * @return Number of characters in the encoded sequence. */ template -inline size_t Utf8Encode(T buf, WChar c) +inline size_t Utf8Encode(T buf, char32_t c) { if (c < 0x80) { *buf = c; @@ -526,17 +526,17 @@ inline size_t Utf8Encode(T buf, WChar c) return 1; } -size_t Utf8Encode(char *buf, WChar c) +size_t Utf8Encode(char *buf, char32_t c) { return Utf8Encode(buf, c); } -size_t Utf8Encode(std::ostreambuf_iterator &buf, WChar c) +size_t Utf8Encode(std::ostreambuf_iterator &buf, char32_t c) { return Utf8Encode &>(buf, c); } -size_t Utf8Encode(std::back_insert_iterator &buf, WChar c) +size_t Utf8Encode(std::back_insert_iterator &buf, char32_t c) { return Utf8Encode &>(buf, c); } @@ -687,7 +687,7 @@ public: while (*s != '\0') { size_t idx = s - string_base; - WChar c = Utf8Consume(&s); + char32_t c = Utf8Consume(&s); if (c < 0x10000) { this->utf16_str.push_back((UChar)c); } else { @@ -742,7 +742,7 @@ public: * break point, but we only want word starts. Move to the next location in * case the new position points to whitespace. */ while (pos != icu::BreakIterator::DONE && - IsWhitespace(Utf16DecodeChar((const uint16 *)&this->utf16_str[pos]))) { + IsWhitespace(Utf16DecodeChar((const uint16_t *)&this->utf16_str[pos]))) { int32_t new_pos = this->word_itr->next(); /* Don't set it to DONE if it was valid before. Otherwise we'll return END * even though the iterator wasn't at the end of the string before. */ @@ -774,7 +774,7 @@ public: * break point, but we only want word starts. Move to the previous location in * case the new position points to whitespace. */ while (pos != icu::BreakIterator::DONE && - IsWhitespace(Utf16DecodeChar((const uint16 *)&this->utf16_str[pos]))) { + IsWhitespace(Utf16DecodeChar((const uint16_t *)&this->utf16_str[pos]))) { int32_t new_pos = this->word_itr->previous(); /* Don't set it to DONE if it was valid before. Otherwise we'll return END * even though the iterator wasn't at the start of the string before. */ @@ -836,13 +836,13 @@ public: switch (what) { case ITER_CHARACTER: { - WChar c; + char32_t c; this->cur_pos += Utf8Decode(&c, this->string + this->cur_pos); return this->cur_pos; } case ITER_WORD: { - WChar c; + char32_t c; /* Consume current word. */ size_t offs = Utf8Decode(&c, this->string + this->cur_pos); while (this->cur_pos < this->len && !IsWhitespace(c)) { @@ -878,7 +878,7 @@ public: case ITER_WORD: { const char *s = this->string + this->cur_pos; - WChar c; + char32_t c; /* Consume preceding whitespace. */ do { s = Utf8PrevChar(s); diff --git a/src/string_func.h b/src/string_func.h index 2286f2fe25..21e24b5114 100644 --- a/src/string_func.h +++ b/src/string_func.h @@ -71,26 +71,26 @@ static inline size_t ttd_strnlen(const char *str, size_t maxlen) return t - str; } -bool IsValidChar(WChar key, CharSetFilter afilter); +bool IsValidChar(char32_t key, CharSetFilter afilter); -size_t Utf8Decode(WChar *c, const char *s); -size_t Utf8Encode(char *buf, WChar c); -size_t Utf8Encode(std::ostreambuf_iterator &buf, WChar c); -size_t Utf8Encode(std::back_insert_iterator &buf, WChar c); +size_t Utf8Decode(char32_t *c, const char *s); +size_t Utf8Encode(char *buf, char32_t c); +size_t Utf8Encode(std::ostreambuf_iterator &buf, char32_t c); +size_t Utf8Encode(std::back_insert_iterator &buf, char32_t c); size_t Utf8TrimString(char *s, size_t maxlen); -static inline WChar Utf8Consume(const char **s) +static inline char32_t Utf8Consume(const char **s) { - WChar c; + char32_t c; *s += Utf8Decode(&c, *s); return c; } template -static inline WChar Utf8Consume(Titr &s) +static inline char32_t Utf8Consume(Titr &s) { - WChar c; + char32_t c; s += Utf8Decode(&c, &*s); return c; } @@ -100,7 +100,7 @@ static inline WChar Utf8Consume(Titr &s) * @param c Unicode character. * @return Length of UTF-8 encoding for character. */ -static inline int8 Utf8CharLen(WChar c) +static inline int8_t Utf8CharLen(char32_t c) { if (c < 0x80) return 1; if (c < 0x800) return 2; @@ -119,7 +119,7 @@ static inline int8 Utf8CharLen(WChar c) * @param c char to query length of * @return requested size */ -static inline int8 Utf8EncodedCharLen(char c) +static inline int8_t Utf8EncodedCharLen(char c) { if (GB(c, 3, 5) == 0x1E) return 4; if (GB(c, 4, 4) == 0x0E) return 3; @@ -187,7 +187,7 @@ static inline bool Utf16IsTrailSurrogate(uint c) * @param trail Trail surrogate code point. * @return Decoded Unicode character. */ -static inline WChar Utf16DecodeSurrogate(uint lead, uint trail) +static inline char32_t Utf16DecodeSurrogate(uint lead, uint trail) { return 0x10000 + (((lead - 0xD800) << 10) | (trail - 0xDC00)); } @@ -197,7 +197,7 @@ static inline WChar Utf16DecodeSurrogate(uint lead, uint trail) * @param c Pointer to one or two UTF-16 code points. * @return Decoded Unicode character. */ -static inline WChar Utf16DecodeChar(const uint16 *c) +static inline char32_t Utf16DecodeChar(const uint16_t *c) { if (Utf16IsLeadSurrogate(c[0])) { return Utf16DecodeSurrogate(c[0], c[1]); @@ -212,7 +212,7 @@ static inline WChar Utf16DecodeChar(const uint16 *c) * @return true iff the character is used to influence * the text direction. */ -static inline bool IsTextDirectionChar(WChar c) +static inline bool IsTextDirectionChar(char32_t c) { switch (c) { case CHAR_TD_LRM: @@ -229,7 +229,7 @@ static inline bool IsTextDirectionChar(WChar c) } } -static inline bool IsPrintable(WChar c) +static inline bool IsPrintable(char32_t c) { if (c < 0x20) return false; if (c < 0xE000) return true; @@ -244,7 +244,7 @@ static inline bool IsPrintable(WChar c) * @return a boolean value whether 'c' is a whitespace character or not * @see http://www.fileformat.info/info/unicode/category/Zs/list.htm */ -static inline bool IsWhitespace(WChar c) +static inline bool IsWhitespace(char32_t c) { return c == 0x0020 /* SPACE */ || c == 0x3000; /* IDEOGRAPHIC SPACE */ } diff --git a/src/string_type.h b/src/string_type.h index 841097516e..c0507a2553 100644 --- a/src/string_type.h +++ b/src/string_type.h @@ -35,13 +35,13 @@ typedef char32_t WChar; /* The following are directional formatting codes used to get the LTR and RTL strings right: * http://www.unicode.org/unicode/reports/tr9/#Directional_Formatting_Codes */ -static const WChar CHAR_TD_LRM = 0x200E; ///< The next character acts like a left-to-right character. -static const WChar CHAR_TD_RLM = 0x200F; ///< The next character acts like a right-to-left character. -static const WChar CHAR_TD_LRE = 0x202A; ///< The following text is embedded left-to-right. -static const WChar CHAR_TD_RLE = 0x202B; ///< The following text is embedded right-to-left. -static const WChar CHAR_TD_LRO = 0x202D; ///< Force the following characters to be treated as left-to-right characters. -static const WChar CHAR_TD_RLO = 0x202E; ///< Force the following characters to be treated as right-to-left characters. -static const WChar CHAR_TD_PDF = 0x202C; ///< Restore the text-direction state to before the last LRE, RLE, LRO or RLO. +static const char32_t CHAR_TD_LRM = 0x200E; ///< The next character acts like a left-to-right character. +static const char32_t CHAR_TD_RLM = 0x200F; ///< The next character acts like a right-to-left character. +static const char32_t CHAR_TD_LRE = 0x202A; ///< The following text is embedded left-to-right. +static const char32_t CHAR_TD_RLE = 0x202B; ///< The following text is embedded right-to-left. +static const char32_t CHAR_TD_LRO = 0x202D; ///< Force the following characters to be treated as left-to-right characters. +static const char32_t CHAR_TD_RLO = 0x202E; ///< Force the following characters to be treated as right-to-left characters. +static const char32_t CHAR_TD_PDF = 0x202C; ///< Restore the text-direction state to before the last LRE, RLE, LRO or RLO. /** Settings for the string validation. */ enum StringValidationSettings { diff --git a/src/stringfilter.cpp b/src/stringfilter.cpp index 11ce86941d..87a8bd5f3f 100644 --- a/src/stringfilter.cpp +++ b/src/stringfilter.cpp @@ -16,10 +16,10 @@ #include "safeguards.h" -static const WChar STATE_WHITESPACE = ' '; -static const WChar STATE_WORD = 'w'; -static const WChar STATE_QUOTE1 = '\''; -static const WChar STATE_QUOTE2 = '"'; +static const char32_t STATE_WHITESPACE = ' '; +static const char32_t STATE_WORD = 'w'; +static const char32_t STATE_QUOTE1 = '\''; +static const char32_t STATE_QUOTE2 = '"'; /** * Set the term to filter on. @@ -37,12 +37,12 @@ void StringFilter::SetFilterTerm(const char *str) char *dest = MallocT(strlen(str) + 1); this->filter_buffer = dest; - WChar state = STATE_WHITESPACE; + char32_t state = STATE_WHITESPACE; const char *pos = str; WordState *word = nullptr; size_t len; for (;; pos += len) { - WChar c; + char32_t c; len = Utf8Decode(&c, pos); if (c == 0 || (state == STATE_WORD && IsWhitespace(c))) { diff --git a/src/strings.cpp b/src/strings.cpp index 37e0f6efa4..eb04519e8e 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -146,7 +146,7 @@ void SetDParamMaxDigits(size_t n, uint count, FontSize size) uint front = 0; uint next = 0; GetBroadestDigit(&front, &next, size); - uint64 val = count > 1 ? front : next; + uint64_t val = count > 1 ? front : next; for (; count > 1; count--) { val = 10 * val + next; } @@ -206,7 +206,7 @@ bool HaveDParamChanged(const std::vector &backup) } static void StationGetSpecialString(StringBuilder &builder, StationFacility x); -static void GetSpecialTownNameString(StringBuilder &builder, int ind, uint32 seed); +static void GetSpecialTownNameString(StringBuilder &builder, int ind, uint32_t seed); static void GetSpecialNameString(StringBuilder &builder, int ind, StringParameters &args); static void FormatString(StringBuilder &builder, const char *str, StringParameters &args, uint case_index = 0, bool game_script = false, bool dry_run = false); @@ -385,10 +385,10 @@ void SetDParamStr(size_t n, std::string &&str) * @param fractional_digits number of fractional digits to display after a decimal separator. The decimal separator is inserted * in front of the \a fractional_digits last digit of \a number. */ -static void FormatNumber(StringBuilder &builder, int64 number, const char *separator, int zerofill = 1, int fractional_digits = 0) +static void FormatNumber(StringBuilder &builder, int64_t number, const char *separator, int zerofill = 1, int fractional_digits = 0) { static const int max_digits = 20; - uint64 divisor = 10000000000000000000ULL; + uint64_t divisor = 10000000000000000000ULL; zerofill += fractional_digits; int thousands_offset = (max_digits - fractional_digits - 1) % 3; @@ -397,8 +397,8 @@ static void FormatNumber(StringBuilder &builder, int64 number, const char *separ number = -number; } - uint64 num = number; - uint64 tot = 0; + uint64_t num = number; + uint64_t tot = 0; for (int i = 0; i < max_digits; i++) { if (i == max_digits - fractional_digits) { const char *decimal_separator = _settings_game.locale.digit_decimal_separator.c_str(); @@ -406,7 +406,7 @@ static void FormatNumber(StringBuilder &builder, int64 number, const char *separ builder += decimal_separator; } - uint64 quot = 0; + uint64_t quot = 0; if (num >= divisor) { quot = num / divisor; num = num % divisor; @@ -420,24 +420,24 @@ static void FormatNumber(StringBuilder &builder, int64 number, const char *separ } } -static void FormatCommaNumber(StringBuilder &builder, int64 number, int fractional_digits = 0) +static void FormatCommaNumber(StringBuilder &builder, int64_t number, int fractional_digits = 0) { const char *separator = _settings_game.locale.digit_group_separator.c_str(); if (StrEmpty(separator)) separator = _langpack.langpack->digit_group_separator; FormatNumber(builder, number, separator, 1, fractional_digits); } -static void FormatNoCommaNumber(StringBuilder &builder, int64 number) +static void FormatNoCommaNumber(StringBuilder &builder, int64_t number) { FormatNumber(builder, number, ""); } -static void FormatZerofillNumber(StringBuilder &builder, int64 number, int count) +static void FormatZerofillNumber(StringBuilder &builder, int64_t number, int count) { FormatNumber(builder, number, "", count); } -static void FormatHexNumber(StringBuilder &builder, uint64 number) +static void FormatHexNumber(StringBuilder &builder, uint64_t number) { fmt::format_to(builder, "0x{:X}", number); } @@ -447,7 +447,7 @@ static void FormatHexNumber(StringBuilder &builder, uint64 number) * @param builder the string builder to write to * @param number the number of bytes to write down */ -static void FormatBytes(StringBuilder &builder, int64 number) +static void FormatBytes(StringBuilder &builder, int64_t number) { assert(number >= 0); @@ -563,10 +563,10 @@ static void FormatGenericCurrency(StringBuilder &builder, const CurrencySpec *sp * @param plural_form The plural form we want an index for. * @return The plural index for the given form. */ -static int DeterminePluralForm(int64 count, int plural_form) +static int DeterminePluralForm(int64_t count, int plural_form) { /* The absolute value determines plurality */ - uint64 n = abs(count); + uint64_t n = abs(count); switch (plural_form) { default: @@ -710,7 +710,7 @@ struct UnitConversion { * @param round Whether to round the value or not. * @return The converted value. */ - int64 ToDisplay(int64 input, bool round = true) const + int64_t ToDisplay(int64_t input, bool round = true) const { return round ? (int64_t)std::round(input * this->factor) @@ -724,7 +724,7 @@ struct UnitConversion { * @param divider Divide the return value by this. * @return The converted value. */ - int64 FromDisplay(int64 input, bool round = true, int64 divider = 1) const + int64_t FromDisplay(int64_t input, bool round = true, int64_t divider = 1) const { return round ? (int64_t)std::round(input / this->factor / divider) @@ -897,7 +897,7 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara /* We have to restore the original offset here to to read the correct values. */ args.SetOffset(orig_offset); } - WChar b = '\0'; + char32_t b = '\0'; uint next_substr_case_index = 0; std::stack> str_stack; str_stack.push(str_arg); @@ -927,7 +927,7 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara AllocatedStringParameters sub_args(20); char *p; - uint32 stringid = std::strtoul(str, &p, 16); + uint32_t stringid = std::strtoul(str, &p, 16); if (*p != ':' && *p != '\0') { while (*p != '\0') p++; str = p; @@ -943,7 +943,7 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara int i = 0; while (*p != '\0' && i < 20) { - uint64 param; + uint64_t param; const char *s = ++p; /* Find the next value */ @@ -974,7 +974,7 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara if (*s != '"') { /* Check if we want to look up another string */ - WChar l; + char32_t l; size_t len = Utf8Decode(&l, s); bool lookup = (l == SCC_ENCODED); if (lookup) s += len; @@ -1043,7 +1043,7 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara /* And determine the string. */ const char *s = buffer.c_str(); - WChar c = Utf8Consume(&s); + char32_t c = Utf8Consume(&s); /* Does this string have a gender, if so, set it */ if (c == SCC_GENDER_INDEX) gender = (byte)s[0]; } @@ -1065,7 +1065,7 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara case SCC_PLURAL_LIST: { // {P} int plural_form = *str++; // contains the plural form for this string size_t offset = orig_offset + (byte)*str++; - int64 v = args.GetParam(offset); // contains the number that determines plural + int64_t v = args.GetParam(offset); // contains the number that determines plural str = ParseStringChoice(str, DeterminePluralForm(v, plural_form), builder); break; } @@ -1150,7 +1150,7 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara break; case SCC_DECIMAL: { // {DECIMAL} - int64 number = args.GetNextParameter(); + int64_t number = args.GetNextParameter(); int digits = args.GetNextParameter(); FormatCommaNumber(builder, number, digits); break; @@ -1161,7 +1161,7 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara break; case SCC_ZEROFILL_NUM: { // {ZEROFILL_NUM} - int64 num = args.GetNextParameter(); + int64_t num = args.GetNextParameter(); FormatZerofillNumber(builder, num, args.GetNextParameter()); break; } @@ -1182,7 +1182,7 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara if (cargo >= CargoSpec::GetArraySize()) break; StringID cargo_str = CargoSpec::Get(cargo)->units_volume; - int64 amount = 0; + int64_t amount = 0; switch (cargo_str) { case STR_TONS: amount = _units_weight[_settings_game.locale.units_weight].c.ToDisplay(args.GetNextParameter()); @@ -1430,7 +1430,7 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara } if (HasBit(e->info.callback_mask, CBM_VEHICLE_NAME)) { - uint16 callback = GetVehicleCallback(CBID_VEHICLE_NAME, static_cast(arg >> 32), 0, e->index, nullptr); + uint16_t callback = GetVehicleCallback(CBID_VEHICLE_NAME, static_cast(arg >> 32), 0, e->index, nullptr); /* Not calling ErrorUnknownCallbackResult due to being inside string processing. */ if (callback != CALLBACK_FAILED && callback < 0x400) { const GRFFile *grffile = e->GetGRF(); @@ -1643,7 +1643,7 @@ static void StationGetSpecialString(StringBuilder &builder, StationFacility x) if ((x & FACIL_AIRPORT) != 0) builder.Utf8Encode(SCC_PLANE); } -static void GetSpecialTownNameString(StringBuilder &builder, int ind, uint32 seed) +static void GetSpecialTownNameString(StringBuilder &builder, int ind, uint32_t seed) { GenerateTownNameString(builder, ind, seed); } @@ -1716,7 +1716,7 @@ static const char _initial_name_letters[] = { 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'W', }; -static void GenAndCoName(StringBuilder &builder, uint32 arg) +static void GenAndCoName(StringBuilder &builder, uint32_t arg) { const char * const *base; uint num; @@ -1733,7 +1733,7 @@ static void GenAndCoName(StringBuilder &builder, uint32 arg) builder += " & Co."; } -static void GenPresidentName(StringBuilder &builder, uint32 x) +static void GenPresidentName(StringBuilder &builder, uint32_t x) { char initial[] = "?. "; const char * const *base; @@ -1846,7 +1846,7 @@ bool ReadLanguagePack(const LanguageMetadata *lang) uint count = 0; for (uint i = 0; i < TEXT_TAB_END; i++) { - uint16 num = lang_pack->offsets[i]; + uint16_t num = lang_pack->offsets[i]; if (num > TAB_SIZE) return false; tab_start[i] = count; @@ -2107,7 +2107,7 @@ bool MissingGlyphSearcher::FindMissingGlyphs() FontSize size = this->DefaultSize(); while (src != text->cend()) { - WChar c = Utf8Consume(src); + char32_t c = Utf8Consume(src); if (c >= SCC_FIRST_FONT && c <= SCC_LAST_FONT) { size = (FontSize)(c - SCC_FIRST_FONT); diff --git a/src/strings_func.h b/src/strings_func.h index 9806661656..175e5556e3 100644 --- a/src/strings_func.h +++ b/src/strings_func.h @@ -71,11 +71,11 @@ uint ConvertDisplaySpeedToKmhishSpeed(uint speed, VehicleType type); * @param type Type of vehicle for parameter. * @return Bit-packed velocity and vehicle type, for use with SetDParam(). */ -static inline int64 PackVelocity(uint speed, VehicleType type) +static inline int64_t PackVelocity(uint speed, VehicleType type) { /* Vehicle type is a byte, so packed into the top 8 bits of the 64-bit * parameter, although only values from 0-3 are relevant. */ - return speed | (static_cast(type) << 56); + return speed | (static_cast(type) << 56); } void SetDParam(size_t n, uint64_t v); diff --git a/src/strings_internal.h b/src/strings_internal.h index 6dc0f086db..875c82f053 100644 --- a/src/strings_internal.h +++ b/src/strings_internal.h @@ -19,7 +19,7 @@ struct StringParameter { uint64_t data; ///< The data of the parameter. const char *string_view; ///< The string value, if it has any. std::unique_ptr string; ///< Copied string value, if it has any. - WChar type; ///< The #StringControlCode to interpret this data with when it's the first parameter, otherwise '\0'. + char32_t type; ///< The #StringControlCode to interpret this data with when it's the first parameter, otherwise '\0'. }; class StringParameters { @@ -28,7 +28,7 @@ protected: span parameters = {}; ///< Array with the actual parameters. size_t offset = 0; ///< Current offset in the parameters span. - WChar next_type = 0; ///< The type of the next data that is retrieved. + char32_t next_type = 0; ///< The type of the next data that is retrieved. StringParameters(span parameters = {}) : parameters(parameters) @@ -54,7 +54,7 @@ public: } void PrepareForNextRun(); - void SetTypeOfNextParameter(WChar type) { this->next_type = type; } + void SetTypeOfNextParameter(char32_t type) { this->next_type = type; } /** * Get the current offset, so it can be backed up for certain processing @@ -139,13 +139,13 @@ public: } /** Get the type of a specific element. */ - WChar GetTypeAtOffset(size_t offset) const + char32_t GetTypeAtOffset(size_t offset) const { assert(offset < this->parameters.size()); return this->parameters[offset].type; } - void SetParam(size_t n, uint64 v) + void SetParam(size_t n, uint64_t v) { assert(n < this->parameters.size()); this->parameters[n].data = v; @@ -171,7 +171,7 @@ public: this->parameters[n].string_view = nullptr; } - uint64 GetParam(size_t n) const + uint64_t GetParam(size_t n) const { assert(n < this->parameters.size()); assert(this->parameters[n].string_view == nullptr && this->parameters[n].string == nullptr); @@ -285,7 +285,7 @@ public: * Encode the given Utf8 character into the output buffer. * @param c The character to encode. */ - void Utf8Encode(WChar c) + void Utf8Encode(char32_t c) { auto iterator = std::back_inserter(*this->string); ::Utf8Encode(iterator, c); @@ -326,7 +326,7 @@ std::string GetStringWithArgs(StringID string, StringParameters &args); /* Do not leak the StringBuilder to everywhere. */ void GenerateTownNameString(StringBuilder &builder, size_t lang, uint32_t seed); void GetTownName(StringBuilder &builder, const struct Town *t); -void GRFTownNameGenerate(StringBuilder &builder, uint32 grfid, uint16 gen, uint32 seed); +void GRFTownNameGenerate(StringBuilder &builder, uint32_t grfid, uint16_t gen, uint32_t seed); uint RemapNewGRFStringControlCode(uint scc, const char **str, StringParameters ¶meters, bool modify_parameters); diff --git a/src/strings_type.h b/src/strings_type.h index 53b2abd48b..5e6d715b63 100644 --- a/src/strings_type.h +++ b/src/strings_type.h @@ -13,7 +13,7 @@ /** * Numeric value that represents a string, independent of the selected language. */ -typedef uint32 StringID; +typedef uint32_t StringID; static const StringID INVALID_STRING_ID = 0xFFFF; ///< Constant representing an invalid string (16bit in case it is used in savegames) static const int MAX_CHAR_LENGTH = 4; ///< Max. length of UTF-8 encoded unicode character static const uint MAX_LANG = 0x7F; ///< Maximum number of languages supported by the game, and the NewGRF specs diff --git a/src/subsidy.cpp b/src/subsidy.cpp index 7595e79ca9..6821a35d44 100644 --- a/src/subsidy.cpp +++ b/src/subsidy.cpp @@ -334,13 +334,13 @@ bool FindSubsidyTownCargoRoute() /* Passenger subsidies are not handled here. */ town_cargo_produced[CT_PASSENGERS] = 0; - uint8 cargo_count = town_cargo_produced.GetCount(); + uint8_t cargo_count = town_cargo_produced.GetCount(); /* No cargo produced at all? */ if (cargo_count == 0) return false; /* Choose a random cargo that is produced in the town. */ - uint8 cargo_number = RandomRange(cargo_count); + uint8_t cargo_number = RandomRange(cargo_count); CargoID cid; for (cid = 0; cid < NUM_CARGO; cid++) { if (town_cargo_produced[cid] > 0) { diff --git a/src/subsidy_base.h b/src/subsidy_base.h index 1f7ad0caff..5f72a25898 100644 --- a/src/subsidy_base.h +++ b/src/subsidy_base.h @@ -21,7 +21,7 @@ extern SubsidyPool _subsidy_pool; /** Struct about subsidies, offered and awarded */ struct Subsidy : SubsidyPool::PoolItem<&_subsidy_pool> { CargoID cargo_type; ///< Cargo type involved in this subsidy, CT_INVALID for invalid subsidy - uint16 remaining; ///< Remaining months when this subsidy is valid + uint16_t remaining; ///< Remaining months when this subsidy is valid CompanyID awarded; ///< Subsidy is awarded to this company; INVALID_COMPANY if it's not awarded to anyone SourceType src_type; ///< Source of subsidised path (SourceType::Industry or SourceType::Town) SourceType dst_type; ///< Destination of subsidised path (SourceType::Industry or SourceType::Town) diff --git a/src/subsidy_type.h b/src/subsidy_type.h index 6ee80ca3c1..cc5435ad87 100644 --- a/src/subsidy_type.h +++ b/src/subsidy_type.h @@ -20,7 +20,7 @@ enum PartOfSubsidy : byte { }; DECLARE_ENUM_AS_BIT_SET(PartOfSubsidy) -typedef uint16 SubsidyID; ///< ID of a subsidy +typedef uint16_t SubsidyID; ///< ID of a subsidy struct Subsidy; #endif /* SUBSIDY_TYPE_H */ diff --git a/src/table/airport_movement.h b/src/table/airport_movement.h index 14fe1c9abb..3ab00002f4 100644 --- a/src/table/airport_movement.h +++ b/src/table/airport_movement.h @@ -18,7 +18,7 @@ struct AirportFTAbuildup { byte position; ///< The position that an airplane is at. byte heading; ///< The current orders (eg. TAKEOFF, HANGAR, ENDLANDING, etc.). - uint64 block; ///< The block this position is on on the airport (st->airport.flags). + uint64_t block; ///< The block this position is on on the airport (st->airport.flags). byte next; ///< Next position from this position. }; diff --git a/src/table/build_industry.h b/src/table/build_industry.h index 28bf003ea5..43881e8309 100644 --- a/src/table/build_industry.h +++ b/src/table/build_industry.h @@ -1032,16 +1032,16 @@ static const std::vector _tile_table_sugar_mine { #undef MK /** Array with saw sound, for sawmill */ -static const uint8 _sawmill_sounds[] = { SND_28_SAWMILL }; +static const uint8_t _sawmill_sounds[] = { SND_28_SAWMILL }; /** Array with whistle sound, for factory */ -static const uint8 _factory_sounds[] = { SND_03_FACTORY }; +static const uint8_t _factory_sounds[] = { SND_03_FACTORY }; /** Array with 3 animal sounds, for farms */ -static const uint8 _farm_sounds[] = { SND_24_FARM_1, SND_25_FARM_2, SND_26_FARM_3 }; +static const uint8_t _farm_sounds[] = { SND_24_FARM_1, SND_25_FARM_2, SND_26_FARM_3 }; /** Array with... hem... a sound of toyland */ -static const uint8 _plastic_mine_sounds[] = { SND_33_PLASTIC_MINE }; +static const uint8_t _plastic_mine_sounds[] = { SND_33_PLASTIC_MINE }; enum IndustryTypes { IT_COAL_MINE = 0, diff --git a/src/table/elrail_data.h b/src/table/elrail_data.h index 5e1b9e792f..5b14eb2de3 100644 --- a/src/table/elrail_data.h +++ b/src/table/elrail_data.h @@ -245,11 +245,11 @@ static const Direction PPPorder[DIAGDIR_END][TLG_END][DIR_END] = { // X - } }; /* Geometric placement of the PCP relative to the tile origin */ -static const int8 x_pcp_offsets[DIAGDIR_END] = {0, 8, 16, 8}; -static const int8 y_pcp_offsets[DIAGDIR_END] = {8, 16, 8, 0}; +static const int8_t x_pcp_offsets[DIAGDIR_END] = {0, 8, 16, 8}; +static const int8_t y_pcp_offsets[DIAGDIR_END] = {8, 16, 8, 0}; /* Geometric placement of the PPP relative to the PCP*/ -static const int8 x_ppp_offsets[DIR_END] = {-2, -4, -2, 0, 2, 4, 2, 0}; -static const int8 y_ppp_offsets[DIR_END] = {-2, 0, 2, 4, 2, 0, -2, -4}; +static const int8_t x_ppp_offsets[DIR_END] = {-2, -4, -2, 0, 2, 4, 2, 0}; +static const int8_t y_ppp_offsets[DIR_END] = {-2, 0, 2, 4, 2, 0, -2, -4}; /** * Offset for pylon sprites from the base pylon sprite. @@ -266,7 +266,7 @@ enum PylonSpriteOffset { }; /* The type of pylon to draw at each PPP */ -static const uint8 pylon_sprites[] = { +static const uint8_t pylon_sprites[] = { PSO_EW_N, PSO_Y_NE, PSO_NS_E, @@ -315,13 +315,13 @@ enum WireSpriteOffset { }; struct SortableSpriteStruct { - uint8 image_offset; - int8 x_offset; - int8 y_offset; - int8 x_size; - int8 y_size; - int8 z_size; - int8 z_offset; + uint8_t image_offset; + int8_t x_offset; + int8_t y_offset; + int8_t x_size; + int8_t y_size; + int8_t z_size; + int8_t z_offset; }; /** Distance between wire and rail */ diff --git a/src/table/heightmap_colours.h b/src/table/heightmap_colours.h index 9f4b7d4129..a03e714cfc 100644 --- a/src/table/heightmap_colours.h +++ b/src/table/heightmap_colours.h @@ -10,7 +10,7 @@ */ /** Height map colours for the green colour scheme, ordered by height. */ -static const uint32 _green_map_heights[] = { +static const uint32_t _green_map_heights[] = { MKCOLOUR(0x59595958), MKCOLOUR(0x59595958), MKCOLOUR(0x59595959), @@ -129,7 +129,7 @@ static const uint32 _green_map_heights[] = { }; /** Height map colours for the dark green colour scheme, ordered by height. */ -static const uint32 _dark_green_map_heights[] = { +static const uint32_t _dark_green_map_heights[] = { MKCOLOUR(0x60606060), MKCOLOUR(0x60606061), MKCOLOUR(0x60606160), @@ -232,7 +232,7 @@ static const uint32 _dark_green_map_heights[] = { }; /** Height map colours for the violet colour scheme, ordered by height. */ -static const uint32 _violet_map_heights[] = { +static const uint32_t _violet_map_heights[] = { MKCOLOUR(0x80808080), MKCOLOUR(0x80808081), MKCOLOUR(0x80808180), diff --git a/src/table/newgrf_debug_data.h b/src/table/newgrf_debug_data.h index d5bbc6d4ef..2410e68882 100644 --- a/src/table/newgrf_debug_data.h +++ b/src/table/newgrf_debug_data.h @@ -76,7 +76,7 @@ class NIHVehicle : public NIHelper { const void *GetInstance(uint index)const override { return Vehicle::Get(index); } const void *GetSpec(uint index) const override { return Vehicle::Get(index)->GetEngine(); } void SetStringParameters(uint index) const override { this->SetSimpleStringParameters(STR_VEHICLE_NAME, index); } - uint32 GetGRFID(uint index) const override { return Vehicle::Get(index)->GetGRFID(); } + uint32_t GetGRFID(uint index) const override { return Vehicle::Get(index)->GetGRFID(); } uint Resolve(uint index, uint var, uint param, bool *avail) const override { @@ -140,7 +140,7 @@ class NIHStation : public NIHelper { const void *GetInstance(uint index)const override { return nullptr; } const void *GetSpec(uint index) const override { return GetStationSpec(index); } void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); } - uint32 GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetStationSpec(index)->grf_prop.grffile->grfid : 0; } + uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetStationSpec(index)->grf_prop.grffile->grfid : 0; } uint Resolve(uint index, uint var, uint param, bool *avail) const override { @@ -205,7 +205,7 @@ class NIHHouse : public NIHelper { const void *GetInstance(uint index)const override { return nullptr; } const void *GetSpec(uint index) const override { return HouseSpec::Get(GetHouseType(index)); } void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_TOWN_NAME, GetTownIndex(index), index); } - uint32 GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? HouseSpec::Get(GetHouseType(index))->grf_prop.grffile->grfid : 0; } + uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? HouseSpec::Get(GetHouseType(index))->grf_prop.grffile->grfid : 0; } uint Resolve(uint index, uint var, uint param, bool *avail) const override { @@ -255,7 +255,7 @@ class NIHIndustryTile : public NIHelper { const void *GetInstance(uint index)const override { return nullptr; } const void *GetSpec(uint index) const override { return GetIndustryTileSpec(GetIndustryGfx(index)); } void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_INDUSTRY_NAME, GetIndustryIndex(index), index); } - uint32 GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetIndustryTileSpec(GetIndustryGfx(index))->grf_prop.grffile->grfid : 0; } + uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetIndustryTileSpec(GetIndustryGfx(index))->grf_prop.grffile->grfid : 0; } uint Resolve(uint index, uint var, uint param, bool *avail) const override { @@ -363,7 +363,7 @@ class NIHIndustry : public NIHelper { const void *GetInstance(uint index)const override { return Industry::Get(index); } const void *GetSpec(uint index) const override { return GetIndustrySpec(Industry::Get(index)->type); } void SetStringParameters(uint index) const override { this->SetSimpleStringParameters(STR_INDUSTRY_NAME, index); } - uint32 GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grffile->grfid : 0; } + uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetIndustrySpec(Industry::Get(index)->type)->grf_prop.grffile->grfid : 0; } uint Resolve(uint index, uint var, uint param, bool *avail) const override { @@ -372,13 +372,13 @@ class NIHIndustry : public NIHelper { return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail); } - uint GetPSASize(uint index, uint32 grfid) const override { return cpp_lengthof(PersistentStorage, storage); } + uint GetPSASize(uint index, uint32_t grfid) const override { return cpp_lengthof(PersistentStorage, storage); } - const int32 *GetPSAFirstPosition(uint index, uint32 grfid) const override + const int32_t *GetPSAFirstPosition(uint index, uint32_t grfid) const override { const Industry *i = (const Industry *)this->GetInstance(index); if (i->psa == nullptr) return nullptr; - return (int32 *)(&i->psa->storage); + return (int32_t *)(&i->psa->storage); } }; @@ -428,7 +428,7 @@ class NIHObject : public NIHelper { const void *GetInstance(uint index)const override { return Object::GetByTile(index); } const void *GetSpec(uint index) const override { return ObjectSpec::GetByTile(index); } void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_OBJECT, INVALID_STRING_ID, index); } - uint32 GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? ObjectSpec::GetByTile(index)->grf_prop.grffile->grfid : 0; } + uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? ObjectSpec::GetByTile(index)->grf_prop.grffile->grfid : 0; } uint Resolve(uint index, uint var, uint param, bool *avail) const override { @@ -462,7 +462,7 @@ class NIHRailType : public NIHelper { const void *GetInstance(uint index)const override { return nullptr; } const void *GetSpec(uint index) const override { return nullptr; } void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE, INVALID_STRING_ID, index); } - uint32 GetGRFID(uint index) const override { return 0; } + uint32_t GetGRFID(uint index) const override { return 0; } uint Resolve(uint index, uint var, uint param, bool *avail) const override { @@ -498,7 +498,7 @@ class NIHAirportTile : public NIHelper { const void *GetInstance(uint index)const override { return nullptr; } const void *GetSpec(uint index) const override { return AirportTileSpec::Get(GetAirportGfx(index)); } void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); } - uint32 GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? AirportTileSpec::Get(GetAirportGfx(index))->grf_prop.grffile->grfid : 0; } + uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? AirportTileSpec::Get(GetAirportGfx(index))->grf_prop.grffile->grfid : 0; } uint Resolve(uint index, uint var, uint param, bool *avail) const override { @@ -536,9 +536,9 @@ class NIHTown : public NIHelper { const void *GetInstance(uint index)const override { return Town::Get(index); } const void *GetSpec(uint index) const override { return nullptr; } void SetStringParameters(uint index) const override { this->SetSimpleStringParameters(STR_TOWN_NAME, index); } - uint32 GetGRFID(uint index) const override { return 0; } + uint32_t GetGRFID(uint index) const override { return 0; } bool PSAWithParameter() const override { return true; } - uint GetPSASize(uint index, uint32 grfid) const override { return cpp_lengthof(PersistentStorage, storage); } + uint GetPSASize(uint index, uint32_t grfid) const override { return cpp_lengthof(PersistentStorage, storage); } uint Resolve(uint index, uint var, uint param, bool *avail) const override { @@ -546,7 +546,7 @@ class NIHTown : public NIHelper { return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, avail); } - const int32 *GetPSAFirstPosition(uint index, uint32 grfid) const override + const int32_t *GetPSAFirstPosition(uint index, uint32_t grfid) const override { Town *t = Town::Get(index); @@ -582,7 +582,7 @@ class NIHRoadType : public NIHelper { const void *GetInstance(uint index) const override { return nullptr; } const void *GetSpec(uint index) const override { return nullptr; } void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_NEWGRF_INSPECT_CAPTION_OBJECT_AT_RAIL_TYPE, INVALID_STRING_ID, index); } - uint32 GetGRFID(uint index) const override { return 0; } + uint32_t GetGRFID(uint index) const override { return 0; } uint Resolve(uint index, uint var, uint param, bool *avail) const override { @@ -647,9 +647,9 @@ class NIHRoadStop : public NIHelper { const void *GetInstance(uint index)const override { return nullptr; } const void *GetSpec(uint index) const override { return GetRoadStopSpec(index); } void SetStringParameters(uint index) const override { this->SetObjectAtStringParameters(STR_STATION_NAME, GetStationIndex(index), index); } - uint32 GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetRoadStopSpec(index)->grf_prop.grffile->grfid : 0; } + uint32_t GetGRFID(uint index) const override { return (this->IsInspectable(index)) ? GetRoadStopSpec(index)->grf_prop.grffile->grfid : 0; } - uint Resolve(uint index, uint var, uint32 param, bool *avail) const override + uint Resolve(uint index, uint var, uint32_t param, bool *avail) const override { int view = GetRoadStopDir(index); if (IsDriveThroughStopTile(index)) view += 4; diff --git a/src/table/object_land.h b/src/table/object_land.h index 4c4dcf95a1..b6ab0e3b79 100644 --- a/src/table/object_land.h +++ b/src/table/object_land.h @@ -8,7 +8,7 @@ /** @file object_land.h Sprites to use and how to display them for object tiles. */ #define TILE_SEQ_LINE(sz, img) { 0, 0, 0, 16, 16, sz, {img, PAL_NONE} }, -#define TILE_SEQ_END() { (int8)0x80, 0, 0, 0, 0, 0, {0, 0} } +#define TILE_SEQ_END() { (int8_t)0x80, 0, 0, 0, 0, 0, {0, 0} } static const DrawTileSeqStruct _object_nothing[] = { TILE_SEQ_END() diff --git a/src/table/road_land.h b/src/table/road_land.h index 0f84ebf183..3b9b557767 100644 --- a/src/table/road_land.h +++ b/src/table/road_land.h @@ -8,7 +8,7 @@ /** @file road_land.h Sprite constructs for road depots. */ #define TILE_SEQ_LINE(img, pal, dx, dy, sx, sy) { dx, dy, 0, sx, sy, 20, {img, pal} }, -#define TILE_SEQ_END() { (int8)0x80, 0, 0, 0, 0, 0, {0, 0} } +#define TILE_SEQ_END() { (int8_t)0x80, 0, 0, 0, 0, 0, {0, 0} } static const DrawTileSeqStruct _road_depot_NE[] = { TILE_SEQ_LINE(0x584 | (1 << PALETTE_MODIFIER_COLOUR), PAL_NONE, 0, 15, 16, 1) diff --git a/src/table/settings.h.preamble b/src/table/settings.h.preamble index dd978727ed..3dfbd2a7fb 100644 --- a/src/table/settings.h.preamble +++ b/src/table/settings.h.preamble @@ -36,7 +36,7 @@ static size_t ConvertLandscape(const char *value); * * The something part defines the type of variable to store. There are a * lot of types. Easy ones are: - * - VAR: any number type, 'type' field specifies what number. eg int8 or uint32 + * - VAR: any number type, 'type' field specifies what number. eg int8_t or uint32 * - BOOL: a boolean number type * - STR: a string or character. 'type' field specifies what string. Normal, string, or quoted * A bit more difficult to use are MMANY (meaning ManyOfMany) and OMANY (OneOfMany) diff --git a/src/table/settings/company_settings.ini b/src/table/settings/company_settings.ini index 9d4b17898a..c712b7b0a8 100644 --- a/src/table/settings/company_settings.ini +++ b/src/table/settings/company_settings.ini @@ -8,9 +8,9 @@ ; company changes them, it changes for all players. [pre-amble] -static void UpdateAllServiceInterval(int32 new_value); -static bool CanUpdateServiceInterval(VehicleType type, int32 &new_value); -static void UpdateServiceInterval(VehicleType type, int32 new_value); +static void UpdateAllServiceInterval(int32_t new_value); +static bool CanUpdateServiceInterval(VehicleType type, int32_t &new_value); +static void UpdateServiceInterval(VehicleType type, int32_t new_value); static const SettingVariant _company_settings_table[] = { [post-amble] diff --git a/src/table/settings/difficulty_settings.ini b/src/table/settings/difficulty_settings.ini index 740e83aa54..0c95a576c0 100644 --- a/src/table/settings/difficulty_settings.ini +++ b/src/table/settings/difficulty_settings.ini @@ -10,11 +10,11 @@ [pre-amble] const std::array _old_diff_settings{"max_no_competitors", "competitor_start_time", "number_towns", "industry_density", "max_loan", "initial_interest", "vehicle_costs", "competitor_speed", "competitor_intelligence", "vehicle_breakdowns", "subsidy_multiplier", "construction_cost", "terrain_type", "quantity_sea_lakes", "economy", "line_reverse_mode", "disasters", "town_council_tolerance"}; -uint16 _old_diff_custom[GAME_DIFFICULTY_NUM]; -uint8 _old_diff_level; ///< Old difficulty level from old savegames +uint16_t _old_diff_custom[GAME_DIFFICULTY_NUM]; +uint8_t _old_diff_level; ///< Old difficulty level from old savegames -static void DifficultyNoiseChange(int32 new_value); -static void MaxNoAIsChange(int32 new_value); +static void DifficultyNoiseChange(int32_t new_value); +static void MaxNoAIsChange(int32_t new_value); static const SettingVariant _difficulty_settings_table[] = { [post-amble] diff --git a/src/table/settings/economy_settings.ini b/src/table/settings/economy_settings.ini index 33fa429ab4..8456fa6030 100644 --- a/src/table/settings/economy_settings.ini +++ b/src/table/settings/economy_settings.ini @@ -8,7 +8,7 @@ ; and in the savegame PATS chunk. [pre-amble] -static void TownFoundingChanged(int32 new_value); +static void TownFoundingChanged(int32_t new_value); static const SettingVariant _economy_settings_table[] = { [post-amble] diff --git a/src/table/settings/game_settings.ini b/src/table/settings/game_settings.ini index b937960b82..7c4fdf51c9 100644 --- a/src/table/settings/game_settings.ini +++ b/src/table/settings/game_settings.ini @@ -11,16 +11,16 @@ [pre-amble] static constexpr std::initializer_list _roadsides{"left", "right"}; -static void StationSpreadChanged(int32 new_value); -static void UpdateConsists(int32 new_value); -static void TrainAccelerationModelChanged(int32 new_value); -static void RoadVehAccelerationModelChanged(int32 new_value); -static void TrainSlopeSteepnessChanged(int32 new_value); -static void RoadVehSlopeSteepnessChanged(int32 new_value); -static bool CheckRoadSide(int32 &new_value); -static bool CheckDynamicEngines(int32 &new_value); -static void StationCatchmentChanged(int32 new_value); -static void MaxVehiclesChanged(int32 new_value); +static void StationSpreadChanged(int32_t new_value); +static void UpdateConsists(int32_t new_value); +static void TrainAccelerationModelChanged(int32_t new_value); +static void RoadVehAccelerationModelChanged(int32_t new_value); +static void TrainSlopeSteepnessChanged(int32_t new_value); +static void RoadVehSlopeSteepnessChanged(int32_t new_value); +static bool CheckRoadSide(int32_t &new_value); +static bool CheckDynamicEngines(int32_t &new_value); +static void StationCatchmentChanged(int32_t new_value); +static void MaxVehiclesChanged(int32_t new_value); static const SettingVariant _game_settings_table[] = { [post-amble] diff --git a/src/table/settings/gui_settings.ini b/src/table/settings/gui_settings.ini index d2cf5a185a..5a2c3a8555 100644 --- a/src/table/settings/gui_settings.ini +++ b/src/table/settings/gui_settings.ini @@ -7,14 +7,14 @@ ; GUI settings as stored in the main configuration file ("openttd.cfg"). [pre-amble] -static void v_PositionMainToolbar(int32 new_value); -static void v_PositionStatusbar(int32 new_value); -static void RedrawSmallmap(int32 new_value); -static void UpdateLinkgraphColours(int32 new_value); -static void InvalidateCompanyLiveryWindow(int32 new_value); -static void InvalidateNewGRFChangeWindows(int32 new_value); -static void ZoomMinMaxChanged(int32 new_value); -static void SpriteZoomMinChanged(int32 new_value); +static void v_PositionMainToolbar(int32_t new_value); +static void v_PositionStatusbar(int32_t new_value); +static void RedrawSmallmap(int32_t new_value); +static void UpdateLinkgraphColours(int32_t new_value); +static void InvalidateCompanyLiveryWindow(int32_t new_value); +static void InvalidateNewGRFChangeWindows(int32_t new_value); +static void ZoomMinMaxChanged(int32_t new_value); +static void SpriteZoomMinChanged(int32_t new_value); static constexpr std::initializer_list _osk_activation{"disabled", "double", "single", "immediately"}; static constexpr std::initializer_list _savegame_date{"long", "short", "iso"}; diff --git a/src/table/settings/locale_settings.ini b/src/table/settings/locale_settings.ini index 33dd1eae1d..57038636dc 100644 --- a/src/table/settings/locale_settings.ini +++ b/src/table/settings/locale_settings.ini @@ -8,7 +8,7 @@ ; in the savegame PATS chunk. These settings are not sync'd over the network. [pre-amble] -uint8 _old_units; ///< Old units from old savegames +uint8_t _old_units; ///< Old units from old savegames static constexpr std::initializer_list _locale_currencies{"GBP", "USD", "EUR", "JPY", "ATS", "BEF", "CHF", "CZK", "DEM", "DKK", "ESP", "FIM", "FRF", "GRD", "HUF", "ISK", "ITL", "NLG", "NOK", "PLN", "RON", "RUR", "SIT", "SEK", "TRY", "SKK", "BRL", "EEK", "LTL", "KRW", "ZAR", "custom", "GEL", "IRR", "RUB", "MXN", "NTD", "CNY", "HKD", "INR", "IDR", "MYR"}; static constexpr std::initializer_list _locale_units{"imperial", "metric", "si", "gameunits"}; diff --git a/src/table/settings/pathfinding_settings.ini b/src/table/settings/pathfinding_settings.ini index ac0a428371..20c08aced4 100644 --- a/src/table/settings/pathfinding_settings.ini +++ b/src/table/settings/pathfinding_settings.ini @@ -8,7 +8,7 @@ ; and in the savegame PATS chunk. [pre-amble] -static void InvalidateShipPathCache(int32 new_value); +static void InvalidateShipPathCache(int32_t new_value); static const SettingVariant _pathfinding_settings_table[] = { [post-amble] diff --git a/src/table/settings/world_settings.ini b/src/table/settings/world_settings.ini index d5fafd9d83..490221dc0a 100644 --- a/src/table/settings/world_settings.ini +++ b/src/table/settings/world_settings.ini @@ -10,9 +10,9 @@ ; basically construction and game_creation settings. [pre-amble] -static bool CheckMaxHeightLevel(int32 &new_value); -static bool CheckFreeformEdges(int32 &new_value); -static void UpdateFreeformEdges(int32 new_value); +static bool CheckMaxHeightLevel(int32_t &new_value); +static bool CheckFreeformEdges(int32_t &new_value); +static void UpdateFreeformEdges(int32_t new_value); static const SettingVariant _world_settings_table[] = { [post-amble] diff --git a/src/table/sprites.h b/src/table/sprites.h index 504db6e446..ea522724b5 100644 --- a/src/table/sprites.h +++ b/src/table/sprites.h @@ -54,7 +54,7 @@ static const SpriteID SPR_LARGE_SMALL_WINDOW = 682; /** Extra graphic spritenumbers */ static const SpriteID SPR_OPENTTD_BASE = 4896; -static const uint16 OPENTTD_SPRITE_COUNT = 191; +static const uint16_t OPENTTD_SPRITE_COUNT = 191; /* Halftile-selection sprites */ static const SpriteID SPR_HALFTILE_SELECTION_FLAT = SPR_OPENTTD_BASE; @@ -175,12 +175,12 @@ static const SpriteID SPR_PLAYER_HOST = SPR_OPENTTD_BASE + 190; static const SpriteID SPR_IMG_CARGOFLOW = SPR_OPENTTD_BASE + 174; static const SpriteID SPR_SIGNALS_BASE = SPR_OPENTTD_BASE + OPENTTD_SPRITE_COUNT; -static const uint16 PRESIGNAL_SPRITE_COUNT = 48; -static const uint16 PRESIGNAL_AND_SEMAPHORE_SPRITE_COUNT = 112; -static const uint16 PRESIGNAL_SEMAPHORE_AND_PBS_SPRITE_COUNT = 240; +static const uint16_t PRESIGNAL_SPRITE_COUNT = 48; +static const uint16_t PRESIGNAL_AND_SEMAPHORE_SPRITE_COUNT = 112; +static const uint16_t PRESIGNAL_SEMAPHORE_AND_PBS_SPRITE_COUNT = 240; static const SpriteID SPR_CANALS_BASE = SPR_SIGNALS_BASE + PRESIGNAL_SEMAPHORE_AND_PBS_SPRITE_COUNT; -static const uint16 CANALS_SPRITE_COUNT = 65; +static const uint16_t CANALS_SPRITE_COUNT = 65; /** Sprites for the Aqueduct. */ static const SpriteID SPR_AQUEDUCT_BASE = SPR_CANALS_BASE + CANALS_SPRITE_COUNT; @@ -192,33 +192,33 @@ static const SpriteID SPR_AQUEDUCT_MIDDLE_X = SPR_AQUEDUCT_BASE + 4; static const SpriteID SPR_AQUEDUCT_MIDDLE_Y = SPR_AQUEDUCT_BASE + 5; static const SpriteID SPR_AQUEDUCT_PILLAR_X = SPR_AQUEDUCT_BASE + 6; static const SpriteID SPR_AQUEDUCT_PILLAR_Y = SPR_AQUEDUCT_BASE + 7; -static const uint16 AQUEDUCT_SPRITE_COUNT = 8; +static const uint16_t AQUEDUCT_SPRITE_COUNT = 8; /** Sprites for 'highlighting' tracks on sloped land. */ static const SpriteID SPR_TRACKS_FOR_SLOPES_BASE = SPR_AQUEDUCT_BASE + AQUEDUCT_SPRITE_COUNT; static const SpriteID SPR_TRACKS_FOR_SLOPES_RAIL_BASE = SPR_TRACKS_FOR_SLOPES_BASE + 0; static const SpriteID SPR_TRACKS_FOR_SLOPES_MONO_BASE = SPR_TRACKS_FOR_SLOPES_BASE + 4; static const SpriteID SPR_TRACKS_FOR_SLOPES_MAGLEV_BASE = SPR_TRACKS_FOR_SLOPES_BASE + 8; -static const uint16 TRACKS_FOR_SLOPES_SPRITE_COUNT = 12; +static const uint16_t TRACKS_FOR_SLOPES_SPRITE_COUNT = 12; static const SpriteID SPR_SLOPES_BASE = SPR_TRACKS_FOR_SLOPES_BASE + TRACKS_FOR_SLOPES_SPRITE_COUNT; static const SpriteID SPR_SLOPES_INCLINED_OFFSET = 15; static const SpriteID SPR_SLOPES_VIRTUAL_BASE = SPR_SLOPES_BASE - SPR_SLOPES_INCLINED_OFFSET; // The original foundations (see SPR_FOUNDATION_BASE below) are mapped before the additional foundations. static const SpriteID SPR_TRKFOUND_BLOCK_SIZE = 22; // The normal track foundation sprites are organized in blocks of 22. -static const uint16 NORMAL_FOUNDATION_SPRITE_COUNT = 74; +static const uint16_t NORMAL_FOUNDATION_SPRITE_COUNT = 74; /** Halftile foundations */ static const SpriteID SPR_HALFTILE_FOUNDATION_BASE = SPR_SLOPES_BASE + NORMAL_FOUNDATION_SPRITE_COUNT; static const SpriteID SPR_HALFTILE_BLOCK_SIZE = 4; // The half tile foundation sprites are organized in blocks of 4. -static const uint16 NORMAL_AND_HALFTILE_FOUNDATION_SPRITE_COUNT = 90; +static const uint16_t NORMAL_AND_HALFTILE_FOUNDATION_SPRITE_COUNT = 90; static const SpriteID SPR_AUTORAIL_BASE = SPR_HALFTILE_FOUNDATION_BASE + NORMAL_AND_HALFTILE_FOUNDATION_SPRITE_COUNT; -static const uint16 AUTORAIL_SPRITE_COUNT = 55; +static const uint16_t AUTORAIL_SPRITE_COUNT = 55; static const SpriteID SPR_ELRAIL_BASE = SPR_AUTORAIL_BASE + AUTORAIL_SPRITE_COUNT; -static const uint16 ELRAIL_SPRITE_COUNT = 48; +static const uint16_t ELRAIL_SPRITE_COUNT = 48; static const SpriteID SPR_2CCMAP_BASE = SPR_ELRAIL_BASE + ELRAIL_SPRITE_COUNT; -static const uint16 TWOCCMAP_SPRITE_COUNT = 256; +static const uint16_t TWOCCMAP_SPRITE_COUNT = 256; /** shore tiles - action 05-0D */ static const SpriteID SPR_SHORE_BASE = SPR_2CCMAP_BASE + TWOCCMAP_SPRITE_COUNT; @@ -242,7 +242,7 @@ static const SpriteID SPR_NEWHANGAR_E = SPR_AIRPORTX_BASE + 11; static const SpriteID SPR_NEWHELIPAD = SPR_AIRPORTX_BASE + 12; static const SpriteID SPR_GRASS_RIGHT = SPR_AIRPORTX_BASE + 13; static const SpriteID SPR_GRASS_LEFT = SPR_AIRPORTX_BASE + 14; -static const uint16 AIRPORTX_SPRITE_COUNT = 15; +static const uint16_t AIRPORTX_SPRITE_COUNT = 15; /** Airport preview sprites */ static const SpriteID SPR_AIRPORT_PREVIEW_BASE = SPR_AIRPORTX_BASE + AIRPORTX_SPRITE_COUNT; @@ -266,7 +266,7 @@ static const SpriteID SPR_TRUCK_STOP_DT_Y_W = SPR_ROADSTOP_BASE + 4; static const SpriteID SPR_TRUCK_STOP_DT_Y_E = SPR_ROADSTOP_BASE + 5; static const SpriteID SPR_TRUCK_STOP_DT_X_W = SPR_ROADSTOP_BASE + 6; static const SpriteID SPR_TRUCK_STOP_DT_X_E = SPR_ROADSTOP_BASE + 7; -static const uint16 ROADSTOP_SPRITE_COUNT = 8; +static const uint16_t ROADSTOP_SPRITE_COUNT = 8; /** Tramway sprites */ static const SpriteID SPR_TRAMWAY_BASE = SPR_ROADSTOP_BASE + ROADSTOP_SPRITE_COUNT; @@ -287,25 +287,25 @@ static const SpriteID SPR_TRAMWAY_FRONT_WIRES_SLOPED = SPR_TRAMWAY_BASE + 72; static const SpriteID SPR_TRAMWAY_TUNNEL_WIRES = SPR_TRAMWAY_BASE + 80; static const SpriteID SPR_TRAMWAY_BRIDGE = SPR_TRAMWAY_BASE + 107; static const SpriteID SPR_TRAMWAY_DEPOT_NO_TRACK = SPR_TRAMWAY_BASE + 113; -static const uint16 TRAMWAY_SPRITE_COUNT = 119; +static const uint16_t TRAMWAY_SPRITE_COUNT = 119; /** One way road sprites */ static const SpriteID SPR_ONEWAY_BASE = SPR_TRAMWAY_BASE + TRAMWAY_SPRITE_COUNT; static const SpriteID SPR_ONEWAY_SLOPE_N_OFFSET = 6; static const SpriteID SPR_ONEWAY_SLOPE_S_OFFSET = 12; -static const uint16 ONEWAY_SPRITE_COUNT = 18; +static const uint16_t ONEWAY_SPRITE_COUNT = 18; /** Tunnel sprites with grass only for custom railtype tunnel. */ static const SpriteID SPR_RAILTYPE_TUNNEL_BASE = SPR_ONEWAY_BASE + ONEWAY_SPRITE_COUNT; -static const uint16 RAILTYPE_TUNNEL_BASE_COUNT = 16; +static const uint16_t RAILTYPE_TUNNEL_BASE_COUNT = 16; /* Not really a sprite, but an empty bounding box. Used to construct bounding boxes that help sorting the sprites, but do not have a sprite associated. */ static const SpriteID SPR_EMPTY_BOUNDING_BOX = SPR_RAILTYPE_TUNNEL_BASE + RAILTYPE_TUNNEL_BASE_COUNT; -static const uint16 EMPTY_BOUNDING_BOX_SPRITE_COUNT = 1; +static const uint16_t EMPTY_BOUNDING_BOX_SPRITE_COUNT = 1; /* Black palette sprite, needed for painting (fictive) tiles outside map */ static const SpriteID SPR_PALETTE_BASE = SPR_EMPTY_BOUNDING_BOX + EMPTY_BOUNDING_BOX_SPRITE_COUNT; -static const uint16 PALETTE_SPRITE_COUNT = 1; +static const uint16_t PALETTE_SPRITE_COUNT = 1; /* From where can we start putting NewGRFs? */ static const SpriteID SPR_NEWGRFS_BASE = SPR_PALETTE_BASE + PALETTE_SPRITE_COUNT; diff --git a/src/table/station_land.h b/src/table/station_land.h index 53a69e1e21..6e3db1d0d0 100644 --- a/src/table/station_land.h +++ b/src/table/station_land.h @@ -39,7 +39,7 @@ * @param img Sprite to draw * @param pal Palette sprite */ -#define TILE_SEQ_CHILD(dx, dy, img, pal) TILE_SEQ_LINE_PAL(dx, dy, (int8)0x80, 0, 0, 0, img, pal) +#define TILE_SEQ_CHILD(dx, dy, img, pal) TILE_SEQ_LINE_PAL(dx, dy, (int8_t)0x80, 0, 0, 0, img, pal) /** * Constructor macro for additional ground sprites. @@ -52,7 +52,7 @@ #define TILE_SEQ_GROUND(dx, dy, dz, img) TILE_SEQ_CHILD(2 * (dy - dx), dx + dy - dz, img, PAL_NONE) /** Constructor macro for a terminating DrawTileSeqStruct entry in an array */ -#define TILE_SEQ_END() { (int8)0x80, 0, 0, 0, 0, 0, {0, 0} } +#define TILE_SEQ_END() { (int8_t)0x80, 0, 0, 0, 0, 0, {0, 0} } static const DrawTileSeqStruct _station_display_nothing[] = { TILE_SEQ_END() diff --git a/src/table/strgen_tables.h b/src/table/strgen_tables.h index e6ec697958..60fcf80060 100644 --- a/src/table/strgen_tables.h +++ b/src/table/strgen_tables.h @@ -24,8 +24,8 @@ struct CmdStruct { const char *cmd; ParseCmdProc proc; long value; - uint8 consumes; - int8 default_plural_offset; + uint8_t consumes; + int8_t default_plural_offset; CmdFlags flags; }; diff --git a/src/table/track_land.h b/src/table/track_land.h index 33950a4389..70ea770bfe 100644 --- a/src/table/track_land.h +++ b/src/table/track_land.h @@ -8,7 +8,7 @@ /** @file track_land.h Sprites to use and how to display them for train depot tiles. */ #define TILE_SEQ_LINE(img, dx, dy, sx, sy) { dx, dy, 0, sx, sy, 23, {img, PAL_NONE} }, -#define TILE_SEQ_END() { (int8)0x80, 0, 0, 0, 0, 0, {0, 0} } +#define TILE_SEQ_END() { (int8_t)0x80, 0, 0, 0, 0, 0, {0, 0} } static const DrawTileSeqStruct _depot_gfx_NE[] = { diff --git a/src/table/tree_land.h b/src/table/tree_land.h index 6c35cc3f07..b64365f861 100644 --- a/src/table/tree_land.h +++ b/src/table/tree_land.h @@ -14,8 +14,8 @@ static const byte _tree_base_by_landscape[4] = {0, 12, 20, 32}; static const byte _tree_count_by_landscape[4] = {12, 8, 12, 9}; struct TreePos { - uint8 x; - uint8 y; + uint8_t x; + uint8_t y; }; static const TreePos _tree_layout_xy[][4] = { diff --git a/src/table/unicode.h b/src/table/unicode.h index 5e142a88f7..0f978b4756 100644 --- a/src/table/unicode.h +++ b/src/table/unicode.h @@ -8,7 +8,7 @@ /** @file unicode.h Character mapping for using Unicode characters in OTTD. */ struct DefaultUnicodeMapping { - WChar code; ///< Unicode value + char32_t code; ///< Unicode value byte key; ///< Character index of sprite }; diff --git a/src/table/water_land.h b/src/table/water_land.h index c1d55de956..4bb0395ee7 100644 --- a/src/table/water_land.h +++ b/src/table/water_land.h @@ -20,7 +20,7 @@ #define TILE_SEQ_LINE(dx, dy, dz, sx, sy, sz, img) { dx, dy, dz, sx, sy, sz, {img, PAL_NONE} }, /** Constructor macro for a terminating DrawTileSeqStruct entry in an array */ -#define TILE_SEQ_END() { (int8)0x80, 0, 0, 0, 0, 0, {0, 0} } +#define TILE_SEQ_END() { (int8_t)0x80, 0, 0, 0, 0, 0, {0, 0} } /** * Constructor macro of a DrawTileSprites structure diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp index d42227d3f1..b7b2da67e9 100644 --- a/src/terraform_cmd.cpp +++ b/src/terraform_cmd.cpp @@ -311,7 +311,7 @@ std::tuple CmdTerraformLand(DoCommandFlag flags, SetTileHeight(t, (uint)height); } - if (c != nullptr) c->terraform_limit -= (uint32)ts.tile_to_new_height.size() << 16; + if (c != nullptr) c->terraform_limit -= (uint32_t)ts.tile_to_new_height.size() << 16; } return { total_cost, 0, total_cost.Succeeded() ? tile : INVALID_TILE }; } diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index cf267c25c8..ee7a353e58 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -258,7 +258,7 @@ struct TerraformToolbarWindow : Window { VpSelectTilesWithMethod(pt.x, pt.y, select_method); } - Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override + Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override { Point pt = GetToolbarAlignedWindowPosition(sm_width); pt.y += sm_height; @@ -438,7 +438,7 @@ static void CommonRaiseLowerBigLand(TileIndex tile, bool mode) } } -static const int8 _multi_terraform_coords[][2] = { +static const int8_t _multi_terraform_coords[][2] = { { 0, -2}, { 4, 0}, { -4, 0}, { 0, 2}, { -8, 2}, { -4, 4}, { 0, 6}, { 4, 4}, { 8, 2}, @@ -570,7 +570,7 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { int center_y = RoundDivSU(r.top + r.bottom, 2); int n = _terraform_size * _terraform_size; - const int8 *coords = &_multi_terraform_coords[0][0]; + const int8_t *coords = &_multi_terraform_coords[0][0]; assert(n != 0); do { diff --git a/src/tests/math_func.cpp b/src/tests/math_func.cpp index 25abb1838e..769e344145 100644 --- a/src/tests/math_func.cpp +++ b/src/tests/math_func.cpp @@ -99,10 +99,10 @@ TEST_CASE("ClampTo") CHECK(127 == ClampTo(127)); CHECK(126 == ClampTo(126)); - CHECK(126 == ClampTo(static_cast(126))); - CHECK(126 == ClampTo(static_cast(126))); - CHECK(0 == ClampTo(static_cast(-126))); - CHECK(0 == ClampTo(static_cast(-126))); + CHECK(126 == ClampTo(static_cast(126))); + CHECK(126 == ClampTo(static_cast(126))); + CHECK(0 == ClampTo(static_cast(-126))); + CHECK(0 == ClampTo(static_cast(-126))); /* The realm around 64 bits types is tricky as there is not one type/method that works for all. */ diff --git a/src/textbuf.cpp b/src/textbuf.cpp index 7418cdf29a..be8cc68432 100644 --- a/src/textbuf.cpp +++ b/src/textbuf.cpp @@ -47,7 +47,7 @@ bool Textbuf::CanDelChar(bool backspace) * @param keycode Type of deletion, either WKC_BACKSPACE or WKC_DELETE * @return Return true on successful change of Textbuf, or false otherwise */ -bool Textbuf::DeleteChar(uint16 keycode) +bool Textbuf::DeleteChar(uint16_t keycode) { bool word = (keycode & WKC_CTRL) != 0; @@ -59,17 +59,17 @@ bool Textbuf::DeleteChar(uint16 keycode) if (!CanDelChar(backspace)) return false; char *s = this->buf + this->caretpos; - uint16 len = 0; + uint16_t len = 0; if (word) { /* Delete a complete word. */ if (backspace) { /* Delete whitespace and word in front of the caret. */ - len = this->caretpos - (uint16)this->char_iter->Prev(StringIterator::ITER_WORD); + len = this->caretpos - (uint16_t)this->char_iter->Prev(StringIterator::ITER_WORD); s -= len; } else { /* Delete word and following whitespace following the caret. */ - len = (uint16)this->char_iter->Next(StringIterator::ITER_WORD) - this->caretpos; + len = (uint16_t)this->char_iter->Next(StringIterator::ITER_WORD) - this->caretpos; } /* Update character count. */ for (const char *ss = s; ss < s + len; Utf8Consume(&ss)) { @@ -80,12 +80,12 @@ bool Textbuf::DeleteChar(uint16 keycode) if (backspace) { /* Delete the last code point in front of the caret. */ s = Utf8PrevChar(s); - WChar c; - len = (uint16)Utf8Decode(&c, s); + char32_t c; + len = (uint16_t)Utf8Decode(&c, s); this->chars--; } else { /* Delete the complete character following the caret. */ - len = (uint16)this->char_iter->Next(StringIterator::ITER_CHARACTER) - this->caretpos; + len = (uint16_t)this->char_iter->Next(StringIterator::ITER_CHARACTER) - this->caretpos; /* Update character count. */ for (const char *ss = s; ss < s + len; Utf8Consume(&ss)) { this->chars--; @@ -126,9 +126,9 @@ void Textbuf::DeleteAll() * @param key Character to be inserted * @return Return true on successful change of Textbuf, or false otherwise */ -bool Textbuf::InsertChar(WChar key) +bool Textbuf::InsertChar(char32_t key) { - uint16 len = (uint16)Utf8CharLen(key); + uint16_t len = (uint16_t)Utf8CharLen(key); if (this->bytes + len <= this->max_bytes && this->chars + 1 <= this->max_chars) { memmove(this->buf + this->caretpos + len, this->buf + this->caretpos, this->bytes - this->caretpos); Utf8Encode(this->buf + this->caretpos, key); @@ -158,7 +158,7 @@ bool Textbuf::InsertChar(WChar key) */ bool Textbuf::InsertString(const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end) { - uint16 insertpos = (marked && this->marklength != 0) ? this->markpos : this->caretpos; + uint16_t insertpos = (marked && this->marklength != 0) ? this->markpos : this->caretpos; if (insert_location != nullptr) { insertpos = insert_location - this->buf; if (insertpos > this->bytes) return false; @@ -172,8 +172,8 @@ bool Textbuf::InsertString(const char *str, bool marked, const char *caret, cons if (str == nullptr) return false; - uint16 bytes = 0, chars = 0; - WChar c; + uint16_t bytes = 0, chars = 0; + char32_t c; for (const char *ptr = str; (c = Utf8Consume(&ptr)) != '\0';) { if (!IsValidChar(c, this->afilter)) break; @@ -233,7 +233,7 @@ bool Textbuf::InsertClipboard() * @param to End of the text to delete. * @param update Set to true if the internal state should be updated. */ -void Textbuf::DeleteText(uint16 from, uint16 to, bool update) +void Textbuf::DeleteText(uint16_t from, uint16_t to, bool update) { uint c = 0; const char *s = this->buf + from; @@ -280,7 +280,7 @@ void Textbuf::UpdateStringIter() { this->char_iter->SetString(this->buf); size_t pos = this->char_iter->SetCurPosition(this->caretpos); - this->caretpos = pos == StringIterator::END ? 0 : (uint16)pos; + this->caretpos = pos == StringIterator::END ? 0 : (uint16_t)pos; } /** Update pixel width of the text. */ @@ -312,7 +312,7 @@ void Textbuf::UpdateMarkedText() * @param keycode Direction in which navigation occurs (WKC_CTRL |) WKC_LEFT, (WKC_CTRL |) WKC_RIGHT, WKC_END, WKC_HOME * @return Return true on successful change of Textbuf, or false otherwise */ -bool Textbuf::MovePos(uint16 keycode) +bool Textbuf::MovePos(uint16_t keycode) { switch (keycode) { case WKC_LEFT: @@ -322,7 +322,7 @@ bool Textbuf::MovePos(uint16 keycode) size_t pos = this->char_iter->Prev(keycode & WKC_CTRL ? StringIterator::ITER_WORD : StringIterator::ITER_CHARACTER); if (pos == StringIterator::END) return true; - this->caretpos = (uint16)pos; + this->caretpos = (uint16_t)pos; this->UpdateCaretPosition(); return true; } @@ -334,7 +334,7 @@ bool Textbuf::MovePos(uint16 keycode) size_t pos = this->char_iter->Next(keycode & WKC_CTRL ? StringIterator::ITER_WORD : StringIterator::ITER_CHARACTER); if (pos == StringIterator::END) return true; - this->caretpos = (uint16)pos; + this->caretpos = (uint16_t)pos; this->UpdateCaretPosition(); return true; } @@ -364,7 +364,7 @@ bool Textbuf::MovePos(uint16 keycode) * @param max_bytes maximum size in bytes, including terminating '\0' * @param max_chars maximum size in chars, including terminating '\0' */ -Textbuf::Textbuf(uint16 max_bytes, uint16 max_chars) +Textbuf::Textbuf(uint16_t max_bytes, uint16_t max_chars) : buf(MallocT(max_bytes)), char_iter(StringIterator::Create()) { assert(max_bytes != 0); @@ -422,7 +422,7 @@ void Textbuf::UpdateSize() this->chars = this->bytes = 1; // terminating zero - WChar c; + char32_t c; while ((c = Utf8Consume(&buf)) != '\0') { this->bytes += Utf8CharLen(c); this->chars++; @@ -454,7 +454,7 @@ bool Textbuf::HandleCaret() return false; } -HandleKeyPressResult Textbuf::HandleKeyPress(WChar key, uint16 keycode) +HandleKeyPressResult Textbuf::HandleKeyPress(char32_t key, uint16_t keycode) { bool edited = false; diff --git a/src/textbuf_type.h b/src/textbuf_type.h index 2385129adc..16f0fd86ae 100644 --- a/src/textbuf_type.h +++ b/src/textbuf_type.h @@ -30,20 +30,20 @@ enum HandleKeyPressResult struct Textbuf { CharSetFilter afilter; ///< Allowed characters char * const buf; ///< buffer in which text is saved - uint16 max_bytes; ///< the maximum size of the buffer in bytes (including terminating '\0') - uint16 max_chars; ///< the maximum size of the buffer in characters (including terminating '\0') - uint16 bytes; ///< the current size of the string in bytes (including terminating '\0') - uint16 chars; ///< the current size of the string in characters (including terminating '\0') - uint16 pixels; ///< the current size of the string in pixels + uint16_t max_bytes; ///< the maximum size of the buffer in bytes (including terminating '\0') + uint16_t max_chars; ///< the maximum size of the buffer in characters (including terminating '\0') + uint16_t bytes; ///< the current size of the string in bytes (including terminating '\0') + uint16_t chars; ///< the current size of the string in characters (including terminating '\0') + uint16_t pixels; ///< the current size of the string in pixels bool caret; ///< is the caret ("_") visible or not - uint16 caretpos; ///< the current position of the caret in the buffer, in bytes - uint16 caretxoffs; ///< the current position of the caret in pixels - uint16 markpos; ///< the start position of the marked area in the buffer, in bytes - uint16 markend; ///< the end position of the marked area in the buffer, in bytes - uint16 markxoffs; ///< the start position of the marked area in pixels - uint16 marklength; ///< the length of the marked area in pixels - - explicit Textbuf(uint16 max_bytes, uint16 max_chars = UINT16_MAX); + uint16_t caretpos; ///< the current position of the caret in the buffer, in bytes + uint16_t caretxoffs; ///< the current position of the caret in pixels + uint16_t markpos; ///< the start position of the marked area in the buffer, in bytes + uint16_t markend; ///< the end position of the marked area in the buffer, in bytes + uint16_t markxoffs; ///< the start position of the marked area in pixels + uint16_t marklength; ///< the length of the marked area in pixels + + explicit Textbuf(uint16_t max_bytes, uint16_t max_chars = UINT16_MAX); ~Textbuf(); void Assign(StringID string); @@ -52,13 +52,13 @@ struct Textbuf { void DeleteAll(); bool InsertClipboard(); - bool InsertChar(WChar key); + bool InsertChar(char32_t key); bool InsertString(const char *str, bool marked, const char *caret = nullptr, const char *insert_location = nullptr, const char *replacement_end = nullptr); - bool DeleteChar(uint16 keycode); - bool MovePos(uint16 keycode); + bool DeleteChar(uint16_t keycode); + bool MovePos(uint16_t keycode); - HandleKeyPressResult HandleKeyPress(WChar key, uint16 keycode); + HandleKeyPressResult HandleKeyPress(char32_t key, uint16_t keycode); bool HandleCaret(); void UpdateSize(); @@ -70,7 +70,7 @@ private: bool CanDelChar(bool backspace); - void DeleteText(uint16 from, uint16 to, bool update); + void DeleteText(uint16_t from, uint16_t to, bool update); void UpdateStringIter(); void UpdateWidth(); diff --git a/src/texteff.cpp b/src/texteff.cpp index ae1e796880..43ece0fee7 100644 --- a/src/texteff.cpp +++ b/src/texteff.cpp @@ -23,7 +23,7 @@ struct TextEffect : public ViewportSign { std::vector params; ///< Backup of string parameters StringID string_id; ///< String to draw for the text effect, if INVALID_STRING_ID then it's not valid - uint8 duration; ///< How long the text effect should stay, in ticks (applies only when mode == TE_RISING) + uint8_t duration; ///< How long the text effect should stay, in ticks (applies only when mode == TE_RISING) TextEffectMode mode; ///< Type of text effect /** Reset the text effect */ @@ -38,7 +38,7 @@ struct TextEffect : public ViewportSign { static std::vector _text_effects; ///< Text effects are stored there /* Text Effects */ -TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, TextEffectMode mode) +TextEffectID AddTextEffect(StringID msg, int center, int y, uint8_t duration, TextEffectMode mode) { if (_game_mode == GM_MENU) return INVALID_TE_ID; diff --git a/src/texteff.hpp b/src/texteff.hpp index f684c3d955..f5b0e3aa10 100644 --- a/src/texteff.hpp +++ b/src/texteff.hpp @@ -26,7 +26,7 @@ enum TextEffectMode { typedef size_t TextEffectID; -TextEffectID AddTextEffect(StringID msg, int x, int y, uint8 duration, TextEffectMode mode); +TextEffectID AddTextEffect(StringID msg, int x, int y, uint8_t duration, TextEffectMode mode); void InitTextEffects(); void DrawTextEffects(DrawPixelInfo *dpi); void UpdateTextEffect(TextEffectID effect_id, StringID msg); @@ -34,8 +34,8 @@ void RemoveTextEffect(TextEffectID effect_id); void UpdateAllTextEffectVirtCoords(); /* misc_gui.cpp */ -TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent, StringID colour); -void UpdateFillingPercent(TextEffectID te_id, uint8 percent, StringID colour); +TextEffectID ShowFillingPercent(int x, int y, int z, uint8_t percent, StringID colour); +void UpdateFillingPercent(TextEffectID te_id, uint8_t percent, StringID colour); void HideFillingPercent(TextEffectID *te_id); void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost); diff --git a/src/tgp.cpp b/src/tgp.cpp index 92255f1781..f9337d5a42 100644 --- a/src/tgp.cpp +++ b/src/tgp.cpp @@ -24,7 +24,7 @@ * and starting X & Y, is entirely predictable. On the face of it, that may not * be useful. However, it means that if you want to replay a map in a different * terrain, or just vary the sea level, you just re-run the generator with the - * same seed. The seed is an int32, and is randomised on each run of New Game. + * same seed. The seed is an int32_t, and is randomised on each run of New Game. * The Scenario Generator does not randomise the value, so that you can * experiment with one terrain until you are happy, or click "Random" for a new * random seed. @@ -150,7 +150,7 @@ */ /** Fixed point type for heights */ -using Height = int16; +using Height = int16_t; static const int height_decimal_bits = 4; /** Fixed point array for amplitudes (and percent values) */ @@ -419,7 +419,7 @@ static void HeightMapGenerate() static void HeightMapGetMinMaxAvg(Height *min_ptr, Height *max_ptr, Height *avg_ptr) { Height h_min, h_max, h_avg; - int64 h_accu = 0; + int64_t h_accu = 0; h_min = h_max = _height_map.height(0, 0); /* Get h_min, h_max and accumulate heights into h_accu */ @@ -675,7 +675,7 @@ static void HeightMapCurves(uint level) static void HeightMapAdjustWaterLevel(Amplitude water_percent, Height h_max_new) { Height h_min, h_max, h_avg, h_water_level; - int64 water_tiles, desired_water_tiles; + int64_t water_tiles, desired_water_tiles; int *hist; HeightMapGetMinMaxAvg(&h_min, &h_max, &h_avg); @@ -686,7 +686,7 @@ static void HeightMapAdjustWaterLevel(Amplitude water_percent, Height h_max_new) hist = HeightMapMakeHistogram(h_min, h_max, hist_buf); /* How many water tiles do we want? */ - desired_water_tiles = A2I(((int64)water_percent) * (int64)(_height_map.size_x * _height_map.size_y)); + desired_water_tiles = A2I(((int64_t)water_percent) * (int64_t)(_height_map.size_x * _height_map.size_y)); /* Raise water_level and accumulate values from histogram until we reach required number of water tiles */ for (h_water_level = h_min, water_tiles = 0; h_water_level < h_max; h_water_level++) { @@ -733,7 +733,7 @@ static double perlin_coast_noise_2D(const double x, const double y, const double * Please note that all the small numbers; 53, 101, 167, etc. are small primes * to help give the perlin noise a bit more of a random feel. */ -static void HeightMapCoastLines(uint8 water_borders) +static void HeightMapCoastLines(uint8_t water_borders) { int smallest_size = std::min(_settings_game.game_creation.map_x, _settings_game.game_creation.map_y); const int margin = 4; @@ -826,7 +826,7 @@ static void HeightMapSmoothCoastInDirection(int org_x, int org_y, int dir_x, int } /** Smooth coasts by modulating height of tiles close to map edges with cosine of distance from edge */ -static void HeightMapSmoothCoasts(uint8 water_borders) +static void HeightMapSmoothCoasts(uint8_t water_borders) { int x, y; /* First Smooth NW and SE coasts (y close to 0 and y close to size_y) */ diff --git a/src/tile_cmd.h b/src/tile_cmd.h index 32a04ab6ac..ff56b35aeb 100644 --- a/src/tile_cmd.h +++ b/src/tile_cmd.h @@ -62,11 +62,11 @@ struct TileDesc { StringID airport_tile_name; ///< Name of the airport tile const char *grf; ///< newGRF used for the tile contents StringID railtype; ///< Type of rail on the tile. - uint16 rail_speed; ///< Speed limit of rail (bridges and track) + uint16_t rail_speed; ///< Speed limit of rail (bridges and track) StringID roadtype; ///< Type of road on the tile. - uint16 road_speed; ///< Speed limit of road (bridges and track) + uint16_t road_speed; ///< Speed limit of road (bridges and track) StringID tramtype; ///< Type of tram on the tile. - uint16 tram_speed; ///< Speed limit of tram (bridges and track) + uint16_t tram_speed; ///< Speed limit of tram (bridges and track) }; /** diff --git a/src/tile_type.h b/src/tile_type.h index db7ece562c..87bbcc9f95 100644 --- a/src/tile_type.h +++ b/src/tile_type.h @@ -82,21 +82,21 @@ enum TropicZone { /** * The index/ID of a Tile. */ -struct TileIndex : StrongIntegralTypedef { - using StrongIntegralTypedef::StrongIntegralTypedef; +struct TileIndex : StrongIntegralTypedef { + using StrongIntegralTypedef::StrongIntegralTypedef; debug_inline constexpr TileIndex() = default; debug_inline constexpr TileIndex(const TileIndex &o) = default; debug_inline constexpr TileIndex(TileIndex &&o) = default; - debug_inline constexpr TileIndex(const uint32 &value) : StrongIntegralTypedef(value) {} + debug_inline constexpr TileIndex(const uint32_t &value) : StrongIntegralTypedef(value) {} debug_inline constexpr TileIndex &operator =(const TileIndex &rhs) { this->value = rhs.value; return *this; } debug_inline constexpr TileIndex &operator =(TileIndex &&rhs) { this->value = std::move(rhs.value); return *this; } - debug_inline constexpr TileIndex &operator =(const uint32 &rhs) { this->value = rhs; return *this; } + debug_inline constexpr TileIndex &operator =(const uint32_t &rhs) { this->value = rhs; return *this; } /** Implicit conversion to the base type for e.g. array indexing. */ - debug_inline constexpr operator uint32() const { return this->value; } + debug_inline constexpr operator uint32_t() const { return this->value; } /* Import operators from the base class into our overload set. */ using StrongIntegralTypedef::operator ==; @@ -106,15 +106,15 @@ struct TileIndex : StrongIntegralTypedef { /* Add comparison and add/sub for signed ints as e.g. 0 is signed and will * match ambiguously when only unsigned overloads are present. */ - constexpr bool operator ==(int rhs) const { return this->value == (uint32)rhs; } - constexpr bool operator !=(int rhs) const { return this->value != (uint32)rhs; } - constexpr TileIndex operator +(int rhs) const { return { (uint32)(this->value + rhs) }; } - constexpr TileIndex operator -(int rhs) const { return { (uint32)(this->value - rhs) }; } + constexpr bool operator ==(int rhs) const { return this->value == (uint32_t)rhs; } + constexpr bool operator !=(int rhs) const { return this->value != (uint32_t)rhs; } + constexpr TileIndex operator +(int rhs) const { return { (uint32_t)(this->value + rhs) }; } + constexpr TileIndex operator -(int rhs) const { return { (uint32_t)(this->value - rhs) }; } }; /** * The very nice invalid tile marker */ -static inline constexpr TileIndex INVALID_TILE = TileIndex{ (uint32)-1 }; +static inline constexpr TileIndex INVALID_TILE = TileIndex{ (uint32_t)-1 }; #endif /* TILE_TYPE_H */ diff --git a/src/tilearea_type.h b/src/tilearea_type.h index 412f7c3752..69304bcb09 100644 --- a/src/tilearea_type.h +++ b/src/tilearea_type.h @@ -17,8 +17,8 @@ class OrthogonalTileIterator; /** Represents the covered area of e.g. a rail station */ struct OrthogonalTileArea { TileIndex tile; ///< The base tile of the area - uint16 w; ///< The width of the area - uint16 h; ///< The height of the area + uint16_t w; ///< The width of the area + uint16_t h; ///< The height of the area /** * Construct this tile area with some set values @@ -26,7 +26,7 @@ struct OrthogonalTileArea { * @param w the width * @param h the height */ - OrthogonalTileArea(TileIndex tile = INVALID_TILE, uint8 w = 0, uint8 h = 0) : tile(tile), w(w), h(h) + OrthogonalTileArea(TileIndex tile = INVALID_TILE, uint8_t w = 0, uint8_t h = 0) : tile(tile), w(w), h(h) { } @@ -70,8 +70,8 @@ struct OrthogonalTileArea { struct DiagonalTileArea { TileIndex tile; ///< Base tile of the area - int16 a; ///< Extent in diagonal "x" direction (may be negative to signify the area stretches to the left) - int16 b; ///< Extent in diagonal "y" direction (may be negative to signify the area stretches upwards) + int16_t a; ///< Extent in diagonal "x" direction (may be negative to signify the area stretches to the left) + int16_t b; ///< Extent in diagonal "y" direction (may be negative to signify the area stretches upwards) /** * Construct this tile area with some set values. @@ -79,7 +79,7 @@ struct DiagonalTileArea { * @param a The "x" extent. * @param b The "y" estent. */ - DiagonalTileArea(TileIndex tile = INVALID_TILE, int8 a = 0, int8 b = 0) : tile(tile), a(a), b(b) + DiagonalTileArea(TileIndex tile = INVALID_TILE, int8_t a = 0, int8_t b = 0) : tile(tile), a(a), b(b) { } diff --git a/src/timer/timer_game_calendar.cpp b/src/timer/timer_game_calendar.cpp index dd72187bd5..f7e5707354 100644 --- a/src/timer/timer_game_calendar.cpp +++ b/src/timer/timer_game_calendar.cpp @@ -25,7 +25,7 @@ TimerGameCalendar::Date TimerGameCalendar::date = {}; TimerGameCalendar::DateFract TimerGameCalendar::date_fract = {}; #define M(a, b) ((a << 5) | b) -static const uint16 _month_date_from_year_day[] = { +static const uint16_t _month_date_from_year_day[] = { M(0, 1), M(0, 2), M(0, 3), M(0, 4), M(0, 5), M(0, 6), M(0, 7), M(0, 8), M(0, 9), M(0, 10), M(0, 11), M(0, 12), M(0, 13), M(0, 14), M(0, 15), M(0, 16), M(0, 17), M(0, 18), M(0, 19), M(0, 20), M(0, 21), M(0, 22), M(0, 23), M(0, 24), M(0, 25), M(0, 26), M(0, 27), M(0, 28), M(0, 29), M(0, 30), M(0, 31), M(1, 1), M(1, 2), M(1, 3), M(1, 4), M(1, 5), M(1, 6), M(1, 7), M(1, 8), M(1, 9), M(1, 10), M(1, 11), M(1, 12), M(1, 13), M(1, 14), M(1, 15), M(1, 16), M(1, 17), M(1, 18), M(1, 19), M(1, 20), M(1, 21), M(1, 22), M(1, 23), M(1, 24), M(1, 25), M(1, 26), M(1, 27), M(1, 28), M(1, 29), M(2, 1), M(2, 2), M(2, 3), M(2, 4), M(2, 5), M(2, 6), M(2, 7), M(2, 8), M(2, 9), M(2, 10), M(2, 11), M(2, 12), M(2, 13), M(2, 14), M(2, 15), M(2, 16), M(2, 17), M(2, 18), M(2, 19), M(2, 20), M(2, 21), M(2, 22), M(2, 23), M(2, 24), M(2, 25), M(2, 26), M(2, 27), M(2, 28), M(2, 29), M(2, 30), M(2, 31), @@ -57,7 +57,7 @@ enum DaysTillMonth { }; /** Number of days to pass from the first day in the year before reaching the first of a month. */ -static const uint16 _accum_days_for_month[] = { +static const uint16_t _accum_days_for_month[] = { ACCUM_JAN, ACCUM_FEB, ACCUM_MAR, ACCUM_APR, ACCUM_MAY, ACCUM_JUN, ACCUM_JUL, ACCUM_AUG, ACCUM_SEP, ACCUM_OCT, ACCUM_NOV, ACCUM_DEC, @@ -77,7 +77,7 @@ static const uint16 _accum_days_for_month[] = { /* There are 97 leap years in 400 years */ TimerGameCalendar::Year yr = 400 * (date / (DAYS_IN_YEAR * 400 + 97)); int rem = date % (DAYS_IN_YEAR * 400 + 97); - uint16 x; + uint16_t x; if (rem >= DAYS_IN_YEAR * 100 + 25) { /* There are 25 leap years in the first 100 years after diff --git a/src/timer/timer_game_calendar.h b/src/timer/timer_game_calendar.h index 2afe179057..b1e8448daf 100644 --- a/src/timer/timer_game_calendar.h +++ b/src/timer/timer_game_calendar.h @@ -74,12 +74,12 @@ public: struct TStorage { }; - using Date = int32; ///< The type to store our dates in - using DateFract = uint16; ///< The fraction of a date we're in, i.e. the number of ticks since the last date changeover + using Date = int32_t; ///< The type to store our dates in + using DateFract = uint16_t; ///< The fraction of a date we're in, i.e. the number of ticks since the last date changeover - using Year = int32; ///< Type for the year, note: 0 based, i.e. starts at the year 0. - using Month = uint8; ///< Type for the month, note: 0 based, i.e. 0 = January, 11 = December. - using Day = uint8; ///< Type for the day of the month, note: 1 based, first day of a month is 1. + using Year = int32_t; ///< Type for the year, note: 0 based, i.e. starts at the year 0. + using Month = uint8_t; ///< Type for the month, note: 0 based, i.e. 0 = January, 11 = December. + using Day = uint8_t; ///< Type for the day of the month, note: 1 based, first day of a month is 1. /** * Data structure to convert between Date and triplet (year, month, and day). diff --git a/src/timer/timer_game_tick.cpp b/src/timer/timer_game_tick.cpp index 88ef701157..18203d7b75 100644 --- a/src/timer/timer_game_tick.cpp +++ b/src/timer/timer_game_tick.cpp @@ -16,7 +16,7 @@ #include "safeguards.h" -uint64 TimerGameTick::counter = 0; +uint64_t TimerGameTick::counter = 0; template<> void IntervalTimer::Elapsed(TimerGameTick::TElapsed delta) diff --git a/src/timer/timer_game_tick.h b/src/timer/timer_game_tick.h index 0356b1b311..f6f5638217 100644 --- a/src/timer/timer_game_tick.h +++ b/src/timer/timer_game_tick.h @@ -30,7 +30,7 @@ public: uint elapsed; }; - static uint64 counter; ///< Monotonic counter, in ticks, since start of game. + static uint64_t counter; ///< Monotonic counter, in ticks, since start of game. }; #endif /* TIMER_GAME_TICK_H */ diff --git a/src/timetable.h b/src/timetable.h index 3341f287f0..2a1ef830c4 100644 --- a/src/timetable.h +++ b/src/timetable.h @@ -13,7 +13,7 @@ #include "date_type.h" #include "vehicle_type.h" -static const uint8 MAX_TIMETABLE_START_YEARS = 15; ///< The maximum start date offset, in years. +static const uint8_t MAX_TIMETABLE_START_YEARS = 15; ///< The maximum start date offset, in years. void ShowTimetableWindow(const Vehicle *v); void UpdateVehicleTimetable(Vehicle *v, bool travelling); diff --git a/src/timetable_cmd.cpp b/src/timetable_cmd.cpp index 3b07c91adc..35ebc37f3f 100644 --- a/src/timetable_cmd.cpp +++ b/src/timetable_cmd.cpp @@ -28,7 +28,7 @@ * @param mtf Which part of the timetable entry to change. * @param timetabled If the new value is explicitly timetabled. */ -static void ChangeTimetable(Vehicle *v, VehicleOrderID order_number, uint16 val, ModifyTimetableFlags mtf, bool timetabled) +static void ChangeTimetable(Vehicle *v, VehicleOrderID order_number, uint16_t val, ModifyTimetableFlags mtf, bool timetabled) { Order *order = v->GetOrder(order_number); assert(order != nullptr); @@ -95,7 +95,7 @@ static void ChangeTimetable(Vehicle *v, VehicleOrderID order_number, uint16 val, * 0 to clear times, UINT16_MAX to clear speed limit. * @return the cost of this operation or an error */ -CommandCost CmdChangeTimetable(DoCommandFlag flags, VehicleID veh, VehicleOrderID order_number, ModifyTimetableFlags mtf, uint16 data) +CommandCost CmdChangeTimetable(DoCommandFlag flags, VehicleID veh, VehicleOrderID order_number, ModifyTimetableFlags mtf, uint16_t data) { Vehicle *v = Vehicle::GetIfValid(veh); if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR; @@ -184,7 +184,7 @@ CommandCost CmdChangeTimetable(DoCommandFlag flags, VehicleID veh, VehicleOrderI * 0 to clear times, UINT16_MAX to clear speed limit. * @return the cost of this operation or an error */ -CommandCost CmdBulkChangeTimetable(DoCommandFlag flags, VehicleID veh, ModifyTimetableFlags mtf, uint16 data) +CommandCost CmdBulkChangeTimetable(DoCommandFlag flags, VehicleID veh, ModifyTimetableFlags mtf, uint16_t data) { Vehicle *v = Vehicle::GetIfValid(veh); if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR; @@ -225,7 +225,7 @@ CommandCost CmdSetVehicleOnTime(DoCommandFlag flags, VehicleID veh, bool apply_t if (flags & DC_EXEC) { if (apply_to_group) { - int32 most_late = 0; + int32_t most_late = 0; for (Vehicle *u = v->FirstShared(); u != nullptr; u = u->NextShared()) { if (u->lateness_counter > most_late) { most_late = u->lateness_counter; diff --git a/src/timetable_cmd.h b/src/timetable_cmd.h index 7a3c70a632..433f191196 100644 --- a/src/timetable_cmd.h +++ b/src/timetable_cmd.h @@ -13,8 +13,8 @@ #include "command_type.h" #include "timer/timer_game_calendar.h" -CommandCost CmdChangeTimetable(DoCommandFlag flags, VehicleID veh, VehicleOrderID order_number, ModifyTimetableFlags mtf, uint16 data); -CommandCost CmdBulkChangeTimetable(DoCommandFlag flags, VehicleID veh, ModifyTimetableFlags mtf, uint16 data); +CommandCost CmdChangeTimetable(DoCommandFlag flags, VehicleID veh, VehicleOrderID order_number, ModifyTimetableFlags mtf, uint16_t data); +CommandCost CmdBulkChangeTimetable(DoCommandFlag flags, VehicleID veh, ModifyTimetableFlags mtf, uint16_t data); CommandCost CmdSetVehicleOnTime(DoCommandFlag flags, VehicleID veh, bool apply_to_group); CommandCost CmdAutofillTimetable(DoCommandFlag flags, VehicleID veh, bool autofill, bool preserve_wait_time); CommandCost CmdSetTimetableStart(DoCommandFlag flags, VehicleID veh_id, bool timetable_all, TimerGameCalendar::Date start_date); diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 5065330e76..2d5e7b62d2 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -650,7 +650,7 @@ struct TimetableWindow : Window { if (str == nullptr) return; const Vehicle *v = this->vehicle; - uint64 val = StrEmpty(str) ? 0 : std::strtoul(str, nullptr, 10); + uint64_t val = StrEmpty(str) ? 0 : std::strtoul(str, nullptr, 10); auto [order_id, mtf] = PackTimetableArgs(v, this->sel_index, query_widget == WID_VT_CHANGE_SPEED); switch (query_widget) { diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index c76240c5f0..9198d182e8 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -2505,7 +2505,7 @@ struct ScenarioEditorToolbarWindow : Window { /* Was 'cancel' pressed? */ if (str == nullptr) return; - int32 value; + int32_t value; if (!StrEmpty(str)) { value = atoi(str); } else { diff --git a/src/town.h b/src/town.h index c8be077d22..c33a05a6a1 100644 --- a/src/town.h +++ b/src/town.h @@ -30,20 +30,20 @@ static const TownID INVALID_TOWN = 0xFFFF; static const uint TOWN_GROWTH_WINTER = 0xFFFFFFFE; ///< The town only needs this cargo in the winter (any amount) static const uint TOWN_GROWTH_DESERT = 0xFFFFFFFF; ///< The town needs the cargo for growth when on desert (any amount) -static const uint16 TOWN_GROWTH_RATE_NONE = 0xFFFF; ///< Special value for Town::growth_rate to disable town growth. -static const uint16 MAX_TOWN_GROWTH_TICKS = 930; ///< Max amount of original town ticks that still fit into uint16, about equal to UINT16_MAX / TOWN_GROWTH_TICKS but slightly less to simplify calculations +static const uint16_t TOWN_GROWTH_RATE_NONE = 0xFFFF; ///< Special value for Town::growth_rate to disable town growth. +static const uint16_t MAX_TOWN_GROWTH_TICKS = 930; ///< Max amount of original town ticks that still fit into uint16_t, about equal to UINT16_MAX / TOWN_GROWTH_TICKS but slightly less to simplify calculations typedef Pool TownPool; extern TownPool _town_pool; /** Data structure with cached data of towns. */ struct TownCache { - uint32 num_houses; ///< Amount of houses - uint32 population; ///< Current population of people + uint32_t num_houses; ///< Amount of houses + uint32_t population; ///< Current population of people TrackedViewportSign sign; ///< Location of name sign, UpdateVirtCoord updates this PartOfSubsidy part_of_subsidy; ///< Is this town a source/destination of a subsidy? - uint32 squared_town_zone_radius[HZB_END]; ///< UpdateTownRadius updates this given the house count - BuildingCounts building_counts; ///< The number of each type of building in the town + uint32_t squared_town_zone_radius[HZB_END]; ///< UpdateTownRadius updates this given the house count + BuildingCounts building_counts; ///< The number of each type of building in the town }; /** Town data structure. */ @@ -53,28 +53,28 @@ struct Town : TownPool::PoolItem<&_town_pool> { TownCache cache; ///< Container for all cacheable data. /* Town name */ - uint32 townnamegrfid; - uint16 townnametype; - uint32 townnameparts; + uint32_t townnamegrfid; + uint16_t townnametype; + uint32_t townnameparts; std::string name; ///< Custom town name. If empty, the town was not renamed and uses the generated name. mutable std::string cached_name; ///< NOSAVE: Cache of the resolved name of the town, if not using a custom town name byte flags; ///< See #TownFlags. - uint16 noise_reached; ///< level of noise that all the airports are generating + uint16_t noise_reached; ///< level of noise that all the airports are generating CompanyMask statues; ///< which companies have a statue? /* Company ratings. */ CompanyMask have_ratings; ///< which companies have a rating - uint8 unwanted[MAX_COMPANIES]; ///< how many months companies aren't wanted by towns (bribe) + uint8_t unwanted[MAX_COMPANIES]; ///< how many months companies aren't wanted by towns (bribe) CompanyID exclusivity; ///< which company has exclusivity - uint8 exclusive_counter; ///< months till the exclusivity expires - int16 ratings[MAX_COMPANIES]; ///< ratings of each company for this town + uint8_t exclusive_counter; ///< months till the exclusivity expires + int16_t ratings[MAX_COMPANIES]; ///< ratings of each company for this town - TransportedCargoStat supplied[NUM_CARGO]; ///< Cargo statistics about supplied cargo. - TransportedCargoStat received[NUM_TE]; ///< Cargo statistics about received cargotypes. - uint32 goal[NUM_TE]; ///< Amount of cargo required for the town to grow. + TransportedCargoStat supplied[NUM_CARGO]; ///< Cargo statistics about supplied cargo. + TransportedCargoStat received[NUM_TE]; ///< Cargo statistics about received cargotypes. + uint32_t goal[NUM_TE]; ///< Amount of cargo required for the town to grow. std::string text; ///< General text with additional information. @@ -82,10 +82,10 @@ struct Town : TownPool::PoolItem<&_town_pool> { StationList stations_near; ///< NOSAVE: List of nearby stations. - uint16 time_until_rebuild; ///< time until we rebuild a house + uint16_t time_until_rebuild; ///< time until we rebuild a house - uint16 grow_counter; ///< counter to count when to grow, value is smaller than or equal to growth_rate - uint16 growth_rate; ///< town growth rate + uint16_t grow_counter; ///< counter to count when to grow, value is smaller than or equal to growth_rate + uint16_t growth_rate; ///< town growth rate byte fund_buildings_months; ///< fund buildings program in action? byte road_build_months; ///< fund road reconstruction in action? @@ -114,7 +114,7 @@ struct Town : TownPool::PoolItem<&_town_pool> { * entry in town_noise_population corresponding to the town's tolerance. * @return the maximum noise level the town will tolerate. */ - inline uint16 MaxTownNoise() const + inline uint16_t MaxTownNoise() const { if (this->cache.population == 0) return 0; // no population? no noise @@ -143,7 +143,7 @@ private: void FillCachedName() const; }; -uint32 GetWorldPopulation(); +uint32_t GetWorldPopulation(); void UpdateAllTownVirtCoords(); void ClearAllTownCachedNames(); @@ -260,10 +260,10 @@ void MakeDefaultName(T *obj) * If it wasn't using 'used' and 'idx', it would just search for increasing 'next', * but this way it is faster */ - uint32 used = 0; // bitmap of used waypoint numbers, sliding window with 'next' as base - uint32 next = 0; // first number in the bitmap - uint32 idx = 0; // index where we will stop - uint32 cid = 0; // current index, goes to T::GetPoolSize()-1, then wraps to 0 + uint32_t used = 0; // bitmap of used waypoint numbers, sliding window with 'next' as base + uint32_t next = 0; // first number in the bitmap + uint32_t idx = 0; // index where we will stop + uint32_t cid = 0; // current index, goes to T::GetPoolSize()-1, then wraps to 0 do { T *lobj = T::GetIfValid(cid); @@ -297,14 +297,14 @@ void MakeDefaultName(T *obj) if (cid == T::GetPoolSize()) cid = 0; // wrap to zero... } while (cid != idx); - obj->town_cn = (uint16)next; // set index... + obj->town_cn = (uint16_t)next; // set index... } /* * Converts original town ticks counters to plain game ticks. Note that * tick 0 is a valid tick so actual amount is one more than the counter value. */ -static inline uint16 TownTicksToGameTicks(uint16 ticks) { +static inline uint16_t TownTicksToGameTicks(uint16_t ticks) { return (std::min(ticks, MAX_TOWN_GROWTH_TICKS) + 1) * TOWN_GROWTH_TICKS - 1; } diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 6891504b9c..ca8ac9f8c7 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -188,7 +188,7 @@ void Town::InitializeLayout(TownLayout layout) /* static */ Town *Town::GetRandom() { if (Town::GetNumItems() == 0) return nullptr; - int num = RandomRange((uint16)Town::GetNumItems()); + int num = RandomRange((uint16_t)Town::GetNumItems()); size_t index = MAX_UVALUE(size_t); while (num >= 0) { @@ -230,7 +230,7 @@ enum TownGrowthResult { }; static bool BuildTownHouse(Town *t, TileIndex tile); -static Town *CreateRandomTown(uint attempts, uint32 townnameparts, TownSize size, bool city, TownLayout layout); +static Town *CreateRandomTown(uint attempts, uint32_t townnameparts, TownSize size, bool city, TownLayout layout); static void TownDrawHouseLift(const TileInfo *ti) { @@ -323,7 +323,7 @@ static Foundation GetFoundation_Town(TileIndex tile, Slope tileh) if (hid >= NEW_HOUSE_OFFSET) { const HouseSpec *hs = HouseSpec::Get(hid); if (hs->grf_prop.spritegroup[0] != nullptr && HasBit(hs->callback_mask, CBM_HOUSE_DRAW_FOUNDATIONS)) { - uint32 callback_res = GetHouseCallback(CBID_HOUSE_DRAW_FOUNDATIONS, 0, 0, hid, Town::GetByTile(tile), tile); + uint32_t callback_res = GetHouseCallback(CBID_HOUSE_DRAW_FOUNDATIONS, 0, 0, hid, Town::GetByTile(tile), tile); if (callback_res != CALLBACK_FAILED && !ConvertBooleanCallback(hs->grf_prop.grffile, CBID_HOUSE_DRAW_FOUNDATIONS, callback_res)) return FOUNDATION_NONE; } } @@ -447,11 +447,11 @@ static void ChangePopulation(Town *t, int mod) /** * Determines the world population * Basically, count population of all towns, one by one - * @return uint32 the calculated population of the world + * @return uint32_t the calculated population of the world */ -uint32 GetWorldPopulation() +uint32_t GetWorldPopulation() { - uint32 pop = 0; + uint32_t pop = 0; for (const Town *t : Town::Iterate()) pop += t->cache.population; return pop; } @@ -548,13 +548,13 @@ static void TileLoop_Town(TileIndex tile) } Town *t = Town::GetByTile(tile); - uint32 r = Random(); + uint32_t r = Random(); StationFinder stations(TileArea(tile, 1, 1)); if (HasBit(hs->callback_mask, CBM_HOUSE_PRODUCE_CARGO)) { for (uint i = 0; i < 256; i++) { - uint16 callback = GetHouseCallback(CBID_HOUSE_PRODUCE_CARGO, i, r, house_id, t, tile); + uint16_t callback = GetHouseCallback(CBID_HOUSE_PRODUCE_CARGO, i, r, house_id, t, tile); if (callback == CALLBACK_FAILED || callback == CALLBACK_HOUSEPRODCARGO_END) break; @@ -598,7 +598,7 @@ static void TileLoop_Town(TileIndex tile) if (GB(TimerGameTick::counter, 8, 2) == GB(tile, 0, 2)) { /* Make a bitmask with up to 32 bits set, one for each potential pax */ int genmax = (hs->population + 7) / 8; - uint32 genmask = (genmax >= 32) ? 0xFFFFFFFF : ((1 << genmax) - 1); + uint32_t genmask = (genmax >= 32) ? 0xFFFFFFFF : ((1 << genmax) - 1); /* Mask random value by potential pax and count number of actual pax */ uint amt = CountBits(r & genmask); /* Adjust and apply */ @@ -698,7 +698,7 @@ static void AddProducedCargo_Town(TileIndex tile, CargoArray &produced) if (HasBit(hs->callback_mask, CBM_HOUSE_PRODUCE_CARGO)) { for (uint i = 0; i < 256; i++) { - uint16 callback = GetHouseCallback(CBID_HOUSE_PRODUCE_CARGO, i, 0, house_id, t, tile); + uint16_t callback = GetHouseCallback(CBID_HOUSE_PRODUCE_CARGO, i, 0, house_id, t, tile); if (callback == CALLBACK_FAILED || callback == CALLBACK_HOUSEPRODCARGO_END) break; @@ -730,13 +730,13 @@ static void AddAcceptedCargo_Town(TileIndex tile, CargoArray &acceptance, CargoT CargoID accepts[lengthof(hs->accepts_cargo)]; /* Set the initial accepted cargo types */ - for (uint8 i = 0; i < lengthof(accepts); i++) { + for (uint8_t i = 0; i < lengthof(accepts); i++) { accepts[i] = hs->accepts_cargo[i]; } /* Check for custom accepted cargo types */ if (HasBit(hs->callback_mask, CBM_HOUSE_ACCEPT_CARGO)) { - uint16 callback = GetHouseCallback(CBID_HOUSE_ACCEPT_CARGO, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile); + uint16_t callback = GetHouseCallback(CBID_HOUSE_ACCEPT_CARGO, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile); if (callback != CALLBACK_FAILED) { /* Replace accepted cargo types with translated values from callback */ accepts[0] = GetCargoTranslation(GB(callback, 0, 5), hs->grf_prop.grffile); @@ -747,7 +747,7 @@ static void AddAcceptedCargo_Town(TileIndex tile, CargoArray &acceptance, CargoT /* Check for custom cargo acceptance */ if (HasBit(hs->callback_mask, CBM_HOUSE_CARGO_ACCEPTANCE)) { - uint16 callback = GetHouseCallback(CBID_HOUSE_CARGO_ACCEPTANCE, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile); + uint16_t callback = GetHouseCallback(CBID_HOUSE_CARGO_ACCEPTANCE, 0, 0, GetHouseType(tile), Town::GetByTile(tile), tile); if (callback != CALLBACK_FAILED) { AddAcceptedCargoSetMask(accepts[0], GB(callback, 0, 4), acceptance, always_accepted); AddAcceptedCargoSetMask(accepts[1], GB(callback, 4, 4), acceptance, always_accepted); @@ -762,7 +762,7 @@ static void AddAcceptedCargo_Town(TileIndex tile, CargoArray &acceptance, CargoT } /* No custom acceptance, so fill in with the default values */ - for (uint8 i = 0; i < lengthof(accepts); i++) { + for (uint8_t i = 0; i < lengthof(accepts); i++) { AddAcceptedCargoSetMask(accepts[i], hs->cargo_acceptance[i], acceptance, always_accepted); } } @@ -775,7 +775,7 @@ static void GetTileDesc_Town(TileIndex tile, TileDesc *td) td->str = hs->building_name; - uint16 callback_res = GetHouseCallback(CBID_HOUSE_CUSTOM_NAME, house_completed ? 1 : 0, 0, house, Town::GetByTile(tile), tile); + uint16_t callback_res = GetHouseCallback(CBID_HOUSE_CUSTOM_NAME, house_completed ? 1 : 0, 0, house, Town::GetByTile(tile), tile); if (callback_res != CALLBACK_FAILED && callback_res != 0x400) { if (callback_res > 0x400) { ErrorUnknownCallbackResult(hs->grf_prop.grffile->grfid, CBID_HOUSE_CUSTOM_NAME, callback_res); @@ -822,7 +822,7 @@ static void TownTickHandler(Town *t) i = t->growth_rate; } else { /* If growth failed wait a bit before retrying */ - i = std::min(t->growth_rate, TOWN_GROWTH_TICKS - 1); + i = std::min(t->growth_rate, TOWN_GROWTH_TICKS - 1); } } t->grow_counter = i; @@ -857,7 +857,7 @@ RoadType GetTownRoadType(const Town *t) { RoadType best_rt = ROADTYPE_ROAD; const RoadTypeInfo *best = nullptr; - const uint16 assume_max_speed = 50; + const uint16_t assume_max_speed = 50; for (RoadType rt = ROADTYPE_BEGIN; rt != ROADTYPE_END; rt++) { if (RoadTypeIsTram(rt)) continue; @@ -1247,7 +1247,7 @@ static bool GrowTownWithBridge(const Town *t, const TileIndex tile, const DiagDi DiagDirection direction_to_match = bridge_dir; if (slope != SLOPE_FLAT && CircularTileSearch(&search, bridge_length, 0, 0, RedundantBridgeExistsNearby, &direction_to_match)) return false; - for (uint8 times = 0; times <= 22; times++) { + for (uint8_t times = 0; times <= 22; times++) { byte bridge_type = RandomRange(MAX_BRIDGES - 1); /* Can we actually build the bridge? */ @@ -1291,7 +1291,7 @@ static bool GrowTownWithTunnel(const Town *t, const TileIndex tile, const DiagDi if (CanRoadContinueIntoNextTile(t, tile, tunnel_dir)) { /* Only tunnel under a mountain if the slope is continuous for at least 4 tiles. We want tunneling to be a last resort for large hills. */ TileIndex slope_tile = tile; - for (uint8 tiles = 0; tiles < 4; tiles++) { + for (uint8_t tiles = 0; tiles < 4; tiles++) { if (!IsValidTile(slope_tile)) return false; slope = GetTileSlope(slope_tile); if (slope != InclinedSlope(tunnel_dir) && !IsSteepSlope(slope) && !IsSlopeWithOneCornerRaised(slope)) return false; @@ -1305,7 +1305,7 @@ static bool GrowTownWithTunnel(const Town *t, const TileIndex tile, const DiagDi max_tunnel_length = 5; } - uint8 tunnel_length = 0; + uint8_t tunnel_length = 0; TileIndex tunnel_tile = tile; // Iteratator to store the other end tile of the tunnel. /* Find the end tile of the tunnel for length and continuation checks. */ @@ -1727,7 +1727,7 @@ static bool GrowTownAtRoad(Town *t, TileIndex tile) */ static RoadBits GenRandomRoadBits() { - uint32 r = Random(); + uint32_t r = Random(); uint a = GB(r, 0, 2); uint b = GB(r, 8, 2); if (a == b) b ^= 2; @@ -1797,7 +1797,7 @@ static bool GrowTown(Town *t) void UpdateTownRadius(Town *t) { - static const uint32 _town_squared_town_zone_radius_data[23][5] = { + static const uint32_t _town_squared_town_zone_radius_data[23][5] = { { 4, 0, 0, 0, 0}, // 0 { 16, 0, 0, 0, 0}, { 25, 0, 0, 0, 0}, @@ -1858,7 +1858,7 @@ static void UpdateTownGrowth(Town *t); * @param layout the (road) layout of the town * @param manual was the town placed manually? */ -static void DoCreateTown(Town *t, TileIndex tile, uint32 townnameparts, TownSize size, bool city, TownLayout layout, bool manual) +static void DoCreateTown(Town *t, TileIndex tile, uint32_t townnameparts, TownSize size, bool city, TownLayout layout, bool manual) { t->xy = tile; t->cache.num_houses = 0; @@ -1980,7 +1980,7 @@ static bool IsUniqueTownName(const std::string &name) * @param text Custom name for the town. If empty, the town name parts will be used. * @return the cost of this operation or an error */ -std::tuple CmdFoundTown(DoCommandFlag flags, TileIndex tile, TownSize size, bool city, TownLayout layout, bool random_location, uint32 townnameparts, const std::string &text) +std::tuple CmdFoundTown(DoCommandFlag flags, TileIndex tile, TownSize size, bool city, TownLayout layout, bool random_location, uint32_t townnameparts, const std::string &text) { TownNameParams par(_settings_game.game_creation.town_name); @@ -2192,7 +2192,7 @@ static TileIndex FindNearestGoodCoastalTownSpot(TileIndex tile, TownLayout layou return INVALID_TILE; } -static Town *CreateRandomTown(uint attempts, uint32 townnameparts, TownSize size, bool city, TownLayout layout) +static Town *CreateRandomTown(uint attempts, uint32_t townnameparts, TownSize size, bool city, TownLayout layout) { assert(_game_mode == GM_EDITOR || _generating_world); // These are the preconditions for CMD_DELETE_TOWN @@ -2251,7 +2251,7 @@ bool GenerateTowns(TownLayout layout) uint difficulty = (_game_mode != GM_EDITOR) ? _settings_game.difficulty.number_towns : 0; uint total = (difficulty == (uint)CUSTOM_TOWN_NUMBER_DIFFICULTY) ? _settings_game.game_creation.custom_town_number : Map::ScaleBySize(_num_initial_towns[difficulty] + (Random() & 7)); total = std::min(TownPool::MAX_SIZE, total); - uint32 townnameparts; + uint32_t townnameparts; TownNames town_names; SetGeneratingWorldProgress(GWP_TOWN, total); @@ -2660,7 +2660,7 @@ static bool BuildTownHouse(Town *t, TileIndex tile) byte random_bits = Random(); if (HasBit(hs->callback_mask, CBM_HOUSE_ALLOW_CONSTRUCTION)) { - uint16 callback_res = GetHouseCallback(CBID_HOUSE_ALLOW_CONSTRUCTION, 0, 0, house, t, tile, true, random_bits); + uint16_t callback_res = GetHouseCallback(CBID_HOUSE_ALLOW_CONSTRUCTION, 0, 0, house, t, tile, true, random_bits); if (callback_res != CALLBACK_FAILED && !Convert8bitBooleanCallback(hs->grf_prop.grffile, CBID_HOUSE_ALLOW_CONSTRUCTION, callback_res)) continue; } @@ -2674,7 +2674,7 @@ static bool BuildTownHouse(Town *t, TileIndex tile) byte construction_stage = 0; if (_generating_world || _game_mode == GM_EDITOR) { - uint32 construction_random = Random(); + uint32_t construction_random = Random(); construction_stage = TOWN_HOUSE_COMPLETED; if (Chance16(1, 7)) construction_stage = GB(construction_random, 0, 2); @@ -2832,7 +2832,7 @@ const CargoSpec *FindFirstCargoWithTownEffect(TownEffect effect) * @param goal The new goal value. * @return Empty cost or an error. */ -CommandCost CmdTownCargoGoal(DoCommandFlag flags, TownID town_id, TownEffect te, uint32 goal) +CommandCost CmdTownCargoGoal(DoCommandFlag flags, TownID town_id, TownEffect te, uint32_t goal) { if (_current_company != OWNER_DEITY) return CMD_ERROR; @@ -2883,7 +2883,7 @@ CommandCost CmdTownSetText(DoCommandFlag flags, TownID town_id, const std::strin * @param growth_rate Amount of days between growth, or TOWN_GROWTH_RATE_NONE, or 0 to reset custom growth rate. * @return Empty cost or an error. */ -CommandCost CmdTownGrowthRate(DoCommandFlag flags, TownID town_id, uint16 growth_rate) +CommandCost CmdTownGrowthRate(DoCommandFlag flags, TownID town_id, uint16_t growth_rate) { if (_current_company != OWNER_DEITY) return CMD_ERROR; @@ -2918,10 +2918,10 @@ CommandCost CmdTownGrowthRate(DoCommandFlag flags, TownID town_id, uint16 growth * @param flags Type of operation. * @param town_id Town ID to change, bit 16..23 = * @param company_id Company ID to change. - * @param rating New rating of company (signed int16). + * @param rating New rating of company (signed int16_t). * @return Empty cost or an error. */ -CommandCost CmdTownRating(DoCommandFlag flags, TownID town_id, CompanyID company_id, int16 rating) +CommandCost CmdTownRating(DoCommandFlag flags, TownID town_id, CompanyID company_id, int16_t rating) { if (_current_company != OWNER_DEITY) return CMD_ERROR; @@ -2930,7 +2930,7 @@ CommandCost CmdTownRating(DoCommandFlag flags, TownID town_id, CompanyID company if (!Company::IsValidID(company_id)) return CMD_ERROR; - int16 new_rating = Clamp(rating, RATING_MINIMUM, RATING_MAXIMUM); + int16_t new_rating = Clamp(rating, RATING_MINIMUM, RATING_MAXIMUM); if (flags & DC_EXEC) { t->ratings[company_id] = new_rating; InvalidateWindowData(WC_TOWN_AUTHORITY, town_id); @@ -2946,7 +2946,7 @@ CommandCost CmdTownRating(DoCommandFlag flags, TownID town_id, CompanyID company * @param grow_amount Amount to grow, or 0 to grow a random size up to the current amount of houses. * @return Empty cost or an error. */ -CommandCost CmdExpandTown(DoCommandFlag flags, TownID town_id, uint32 grow_amount) +CommandCost CmdExpandTown(DoCommandFlag flags, TownID town_id, uint32_t grow_amount) { if (_game_mode != GM_EDITOR && _current_company != OWNER_DEITY) return CMD_ERROR; Town *t = Town::GetIfValid(town_id); @@ -3231,7 +3231,7 @@ static CommandCost TownActionFundBuildings(Town *t, DoCommandFlag flags) * tick-perfect and gives player some time window where they can * spam funding with the exact same efficiency. */ - t->grow_counter = std::min(t->grow_counter, 2 * TOWN_GROWTH_TICKS - (t->growth_rate - t->grow_counter) % TOWN_GROWTH_TICKS); + t->grow_counter = std::min(t->grow_counter, 2 * TOWN_GROWTH_TICKS - (t->growth_rate - t->grow_counter) % TOWN_GROWTH_TICKS); SetWindowDirty(WC_TOWN_VIEW, t->index); } @@ -3368,7 +3368,7 @@ TownActions GetMaskOfTownActions(CompanyID cid, const Town *t) * @param action action to perform, @see _town_action_proc for the list of available actions * @return the cost of this operation or an error */ -CommandCost CmdDoTownAction(DoCommandFlag flags, TownID town_id, uint8 action) +CommandCost CmdDoTownAction(DoCommandFlag flags, TownID town_id, uint8_t action) { Town *t = Town::GetIfValid(town_id); if (t == nullptr || action >= lengthof(_town_action_proc)) return CMD_ERROR; @@ -3440,14 +3440,14 @@ static void UpdateTownRating(Town *t) * @param t The town to calculate grow counter for * @param prev_growth_rate Town growth rate before it changed (one that was used with grow counter to be updated) */ -static void UpdateTownGrowCounter(Town *t, uint16 prev_growth_rate) +static void UpdateTownGrowCounter(Town *t, uint16_t prev_growth_rate) { if (t->growth_rate == TOWN_GROWTH_RATE_NONE) return; if (prev_growth_rate == TOWN_GROWTH_RATE_NONE) { - t->grow_counter = std::min(t->growth_rate, t->grow_counter); + t->grow_counter = std::min(t->growth_rate, t->grow_counter); return; } - t->grow_counter = RoundDivSU((uint32)t->grow_counter * (t->growth_rate + 1), prev_growth_rate + 1); + t->grow_counter = RoundDivSU((uint32_t)t->grow_counter * (t->growth_rate + 1), prev_growth_rate + 1); } /** @@ -3479,13 +3479,13 @@ static uint GetNormalGrowthRate(Town *t) * Unserviced+unfunded towns get an additional malus in UpdateTownGrowth(), * so the "320" is actually not better than the "420". */ - static const uint16 _grow_count_values[2][6] = { + static const uint16_t _grow_count_values[2][6] = { { 120, 120, 120, 100, 80, 60 }, // Fund new buildings has been activated { 320, 420, 300, 220, 160, 100 } // Normal values }; int n = CountActiveStations(t); - uint16 m = _grow_count_values[t->fund_buildings_months != 0 ? 0 : 1][std::min(n, 5)]; + uint16_t m = _grow_count_values[t->fund_buildings_months != 0 ? 0 : 1][std::min(n, 5)]; uint growth_multiplier = _settings_game.economy.town_growth_rate != 0 ? _settings_game.economy.town_growth_rate - 1 : 1; @@ -3803,7 +3803,7 @@ static CommandCost TerraformTile_Town(TileIndex tile, DoCommandFlag flags, int z hs = HouseSpec::Get(house); if (HasBit(hs->callback_mask, CBM_HOUSE_AUTOSLOPE)) { /* If the callback fails, allow autoslope. */ - uint16 res = GetHouseCallback(CBID_HOUSE_AUTOSLOPE, 0, 0, house, Town::GetByTile(tile), tile); + uint16_t res = GetHouseCallback(CBID_HOUSE_AUTOSLOPE, 0, 0, house, Town::GetByTile(tile), tile); if (res != CALLBACK_FAILED && ConvertBooleanCallback(hs->grf_prop.grffile, CBID_HOUSE_AUTOSLOPE, res)) allow_terraform = false; } diff --git a/src/town_cmd.h b/src/town_cmd.h index 52ea486c93..3ee49365c3 100644 --- a/src/town_cmd.h +++ b/src/town_cmd.h @@ -16,14 +16,14 @@ enum TownEffect : byte; -std::tuple CmdFoundTown(DoCommandFlag flags, TileIndex tile, TownSize size, bool city, TownLayout layout, bool random_location, uint32 townnameparts, const std::string &text); +std::tuple CmdFoundTown(DoCommandFlag flags, TileIndex tile, TownSize size, bool city, TownLayout layout, bool random_location, uint32_t townnameparts, const std::string &text); CommandCost CmdRenameTown(DoCommandFlag flags, TownID town_id, const std::string &text); -CommandCost CmdDoTownAction(DoCommandFlag flags, TownID town_id, uint8 action); -CommandCost CmdTownGrowthRate(DoCommandFlag flags, TownID town_id, uint16 growth_rate); -CommandCost CmdTownRating(DoCommandFlag flags, TownID town_id, CompanyID company_id, int16 rating); -CommandCost CmdTownCargoGoal(DoCommandFlag flags, TownID town_id, TownEffect te, uint32 goal); +CommandCost CmdDoTownAction(DoCommandFlag flags, TownID town_id, uint8_t action); +CommandCost CmdTownGrowthRate(DoCommandFlag flags, TownID town_id, uint16_t growth_rate); +CommandCost CmdTownRating(DoCommandFlag flags, TownID town_id, CompanyID company_id, int16_t rating); +CommandCost CmdTownCargoGoal(DoCommandFlag flags, TownID town_id, TownEffect te, uint32_t goal); CommandCost CmdTownSetText(DoCommandFlag flags, TownID town_id, const std::string &text); -CommandCost CmdExpandTown(DoCommandFlag flags, TownID town_id, uint32 grow_amount); +CommandCost CmdExpandTown(DoCommandFlag flags, TownID town_id, uint32_t grow_amount); CommandCost CmdDeleteTown(DoCommandFlag flags, TownID town_id); DEF_CMD_TRAIT(CMD_FOUND_TOWN, CmdFoundTown, CMD_DEITY | CMD_NO_TEST, CMDT_LANDSCAPE_CONSTRUCTION) // founding random town can fail only in exec run diff --git a/src/town_gui.cpp b/src/town_gui.cpp index c60307fa5c..15c1be5b27 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -752,8 +752,8 @@ private: /** Sort by population (default descending, as big towns are of the most interest). */ static bool TownPopulationSorter(const Town * const &a, const Town * const &b) { - uint32 a_population = a->cache.population; - uint32 b_population = b->cache.population; + uint32_t a_population = a->cache.population; + uint32_t b_population = b->cache.population; if (a_population == b_population) return TownDirectoryWindow::TownNameSorter(a, b); return a_population < b_population; } @@ -766,8 +766,8 @@ private: /* Towns without rating are always after towns with rating. */ if (HasBit(a->have_ratings, _local_company)) { if (HasBit(b->have_ratings, _local_company)) { - int16 a_rating = a->ratings[_local_company]; - int16 b_rating = b->ratings[_local_company]; + int16_t a_rating = a->ratings[_local_company]; + int16_t b_rating = b->ratings[_local_company]; if (a_rating == b_rating) return TownDirectoryWindow::TownNameSorter(a, b); return a_rating < b_rating; } @@ -1135,7 +1135,7 @@ private: bool city; ///< Are we building a city? QueryString townname_editbox; ///< Townname editbox bool townnamevalid; ///< Is generated town name valid? - uint32 townnameparts; ///< Generated town name + uint32_t townnameparts; ///< Generated town name TownNameParams params; ///< Town name parameters public: diff --git a/src/town_kdtree.h b/src/town_kdtree.h index 9241655854..74898bc23b 100644 --- a/src/town_kdtree.h +++ b/src/town_kdtree.h @@ -13,8 +13,8 @@ #include "core/kdtree.hpp" #include "town.h" -inline uint16 Kdtree_TownXYFunc(TownID tid, int dim) { return (dim == 0) ? TileX(Town::Get(tid)->xy) : TileY(Town::Get(tid)->xy); } -typedef Kdtree TownKdtree; +inline uint16_t Kdtree_TownXYFunc(TownID tid, int dim) { return (dim == 0) ? TileX(Town::Get(tid)->xy) : TileY(Town::Get(tid)->xy); } +typedef Kdtree TownKdtree; extern TownKdtree _town_kdtree; extern TownKdtree _town_local_authority_kdtree; diff --git a/src/town_type.h b/src/town_type.h index 80d6652d7a..53fd0d7b82 100644 --- a/src/town_type.h +++ b/src/town_type.h @@ -12,7 +12,7 @@ #include "core/enum_type.hpp" -typedef uint16 TownID; +typedef uint16_t TownID; struct Town; /** Supported initial town sizes */ diff --git a/src/townname.cpp b/src/townname.cpp index 0e6e2262b6..9850fdad57 100644 --- a/src/townname.cpp +++ b/src/townname.cpp @@ -45,7 +45,7 @@ TownNameParams::TownNameParams(const Town *t) : * @param par Town name parameters. * @param townnameparts 'Encoded' town name. */ -static void GetTownName(StringBuilder &builder, const TownNameParams *par, uint32 townnameparts) +static void GetTownName(StringBuilder &builder, const TownNameParams *par, uint32_t townnameparts) { if (par->grfid == 0) { auto tmp_params = MakeParameters(townnameparts); @@ -62,7 +62,7 @@ static void GetTownName(StringBuilder &builder, const TownNameParams *par, uint3 * @param townnameparts 'Encoded' town name. * @return The town name. */ -std::string GetTownName(const TownNameParams *par, uint32 townnameparts) +std::string GetTownName(const TownNameParams *par, uint32_t townnameparts) { std::string result; StringBuilder builder(result); @@ -100,7 +100,7 @@ std::string GetTownName(const Town *t) * @param town_names if a name is generated, check its uniqueness with the set * @return true iff name is valid and unique */ -bool VerifyTownName(uint32 r, const TownNameParams *par, TownNames *town_names) +bool VerifyTownName(uint32_t r, const TownNameParams *par, TownNames *town_names) { std::string name = GetTownName(par, r); @@ -133,7 +133,7 @@ bool VerifyTownName(uint32 r, const TownNameParams *par, TownNames *town_names) * @param town_names if a name is generated, check its uniqueness with the set * @return true iff a name was generated */ -bool GenerateTownName(Randomizer &randomizer, uint32 *townnameparts, TownNames *town_names) +bool GenerateTownName(Randomizer &randomizer, uint32_t *townnameparts, TownNames *town_names) { TownNameParams par(_settings_game.game_creation.town_name); @@ -147,7 +147,7 @@ bool GenerateTownName(Randomizer &randomizer, uint32 *townnameparts, TownNames * * the other towns may take considerable amount of time (10000 is * too much). */ for (int i = 1000; i != 0; i--) { - uint32 r = randomizer.Next(); + uint32_t r = randomizer.Next(); if (!VerifyTownName(r, &par, town_names)) continue; *townnameparts = r; @@ -166,7 +166,7 @@ bool GenerateTownName(Randomizer &randomizer, uint32 *townnameparts, TownNames * * @param seed seed * @return seed transformed to a number from given range */ -static inline uint32 SeedChance(byte shift_by, int max, uint32 seed) +static inline uint32_t SeedChance(byte shift_by, int max, uint32_t seed) { return (GB(seed, shift_by, 16) * max) >> 16; } @@ -179,7 +179,7 @@ static inline uint32 SeedChance(byte shift_by, int max, uint32 seed) * @param seed seed * @return seed transformed to a number from given range */ -static inline uint32 SeedModChance(byte shift_by, int max, uint32 seed) +static inline uint32_t SeedModChance(byte shift_by, int max, uint32_t seed) { /* This actually gives *MUCH* more even distribution of the values * than SeedChance(), which is absolutely horrible in that. If @@ -202,7 +202,7 @@ static inline uint32 SeedModChance(byte shift_by, int max, uint32 seed) * @param bias minimum value that can be returned * @return seed transformed to a number from given range */ -static inline int32 SeedChanceBias(byte shift_by, int max, uint32 seed, int bias) +static inline int32_t SeedChanceBias(byte shift_by, int max, uint32_t seed, int bias) { return SeedChance(shift_by, max + bias, seed) - bias; } @@ -976,7 +976,7 @@ static void MakeCatalanTownName(StringBuilder &builder, uint32_t seed) * @param builder The builder to write the name to. * @param seed The seed of the town name. */ -typedef void TownNameGenerator(StringBuilder &builder, uint32 seed); +typedef void TownNameGenerator(StringBuilder &builder, uint32_t seed); /** Town name generators */ static TownNameGenerator *_town_name_generators[] = { @@ -1010,7 +1010,7 @@ static TownNameGenerator *_town_name_generators[] = { * @param lang town name language * @param seed generation seed */ -void GenerateTownNameString(StringBuilder &builder, size_t lang, uint32 seed) +void GenerateTownNameString(StringBuilder &builder, size_t lang, uint32_t seed) { assert(lang < lengthof(_town_name_generators)); return _town_name_generators[lang](builder, seed); diff --git a/src/townname_func.h b/src/townname_func.h index 026b067fc2..b3c0a601b5 100644 --- a/src/townname_func.h +++ b/src/townname_func.h @@ -13,9 +13,9 @@ #include "core/random_func.hpp" #include "townname_type.h" -std::string GetTownName(const TownNameParams *par, uint32 townnameparts); +std::string GetTownName(const TownNameParams *par, uint32_t townnameparts); std::string GetTownName(const Town *t); -bool VerifyTownName(uint32 r, const TownNameParams *par, TownNames *town_names = nullptr); -bool GenerateTownName(Randomizer &randomizer, uint32 *townnameparts, TownNames *town_names = nullptr); +bool VerifyTownName(uint32_t r, const TownNameParams *par, TownNames *town_names = nullptr); +bool GenerateTownName(Randomizer &randomizer, uint32_t *townnameparts, TownNames *town_names = nullptr); #endif /* TOWNNAME_FUNC_H */ diff --git a/src/townname_type.h b/src/townname_type.h index 6012af3fbd..85fbf069a1 100644 --- a/src/townname_type.h +++ b/src/townname_type.h @@ -26,8 +26,8 @@ static constexpr uint BUILTIN_TOWNNAME_GENERATOR_COUNT = SPECSTR_TOWNNAME_LAST - * Speeds things up a bit because these values are computed only once per name generation. */ struct TownNameParams { - uint32 grfid; ///< newgrf ID (0 if not used) - uint16 type; ///< town name style + uint32_t grfid; ///< newgrf ID (0 if not used) + uint16_t type; ///< town name style /** * Initializes this struct from language ID diff --git a/src/track_type.h b/src/track_type.h index d7a200e28a..d5ce4a3a41 100644 --- a/src/track_type.h +++ b/src/track_type.h @@ -92,7 +92,7 @@ enum Trackdir : byte { * These are a combination of tracks and directions. Values are 0-5 in one * direction (corresponding to the Track enum) and 8-13 in the other direction. */ -enum TrackdirBits : uint16 { +enum TrackdirBits : uint16_t { TRACKDIR_BIT_NONE = 0U, ///< No track build TRACKDIR_BIT_X_NE = 1U << TRACKDIR_X_NE, ///< Track x-axis, direction north-east TRACKDIR_BIT_Y_SE = 1U << TRACKDIR_Y_SE, ///< Track y-axis, direction south-east @@ -112,6 +112,6 @@ enum TrackdirBits : uint16 { }; DECLARE_ENUM_AS_BIT_SET(TrackdirBits) -typedef uint32 TrackStatus; +typedef uint32_t TrackStatus; #endif /* TRACK_TYPE_H */ diff --git a/src/train.h b/src/train.h index 6f6c9a4861..460a1cd365 100644 --- a/src/train.h +++ b/src/train.h @@ -92,16 +92,16 @@ struct Train FINAL : public GroundVehicle { /* Link between the two ends of a multiheaded engine */ Train *other_multiheaded_part; - uint16 crash_anim_pos; ///< Crash animation counter. + uint16_t crash_anim_pos; ///< Crash animation counter. - uint16 flags; + uint16_t flags; TrackBits track; TrainForceProceeding force_proceed; RailType railtype; RailTypes compatible_railtypes; /** Ticks waiting in front of a signal, ticks being stuck or a counter for forced proceeding through signals. */ - uint16 wait_counter; + uint16_t wait_counter; /** We don't want GCC to zero our struct! It already is zeroed and has an index! */ Train() : GroundVehicleBase() {} @@ -184,11 +184,11 @@ protected: // These functions should not be called outside acceleration code. * Allows to know the power value that this vehicle will use. * @return Power value from the engine in HP, or zero if the vehicle is not powered. */ - inline uint16 GetPower() const + inline uint16_t GetPower() const { /* Power is not added for articulated parts */ if (!this->IsArticulatedPart() && HasPowerOnRail(this->railtype, GetRailType(this->tile))) { - uint16 power = GetVehicleProperty(this, PROP_TRAIN_POWER, RailVehInfo(this->engine_type)->power); + uint16_t power = GetVehicleProperty(this, PROP_TRAIN_POWER, RailVehInfo(this->engine_type)->power); /* Halve power for multiheaded parts */ if (this->IsMultiheaded()) power /= 2; return power; @@ -201,7 +201,7 @@ protected: // These functions should not be called outside acceleration code. * Returns a value if this articulated part is powered. * @return Power value from the articulated part in HP, or zero if it is not powered. */ - inline uint16 GetPoweredPartPower(const Train *head) const + inline uint16_t GetPoweredPartPower(const Train *head) const { /* For powered wagons the engine defines the type of engine (i.e. railtype) */ if (HasBit(this->flags, VRF_POWEREDWAGON) && HasPowerOnRail(head->railtype, GetRailType(this->tile))) { @@ -215,9 +215,9 @@ protected: // These functions should not be called outside acceleration code. * Allows to know the weight value that this vehicle will use. * @return Weight value from the engine in tonnes. */ - inline uint16 GetWeight() const + inline uint16_t GetWeight() const { - uint16 weight = CargoSpec::Get(this->cargo_type)->WeightOfNUnitsInTrain(this->cargo.StoredCount()); + uint16_t weight = CargoSpec::Get(this->cargo_type)->WeightOfNUnitsInTrain(this->cargo.StoredCount()); /* Vehicle weight is not added for articulated parts. */ if (!this->IsArticulatedPart()) { @@ -236,7 +236,7 @@ protected: // These functions should not be called outside acceleration code. * Calculates the weight value that this vehicle will have when fully loaded with its current cargo. * @return Weight value in tonnes. */ - uint16 GetMaxWeight() const override; + uint16_t GetMaxWeight() const override; /** * Allows to know the tractive effort value that this vehicle will use. @@ -279,7 +279,7 @@ protected: // These functions should not be called outside acceleration code. * Calculates the current speed of this vehicle. * @return Current speed in km/h-ish. */ - inline uint16 GetCurrentSpeed() const + inline uint16_t GetCurrentSpeed() const { return this->cur_speed; } @@ -288,7 +288,7 @@ protected: // These functions should not be called outside acceleration code. * Returns the rolling friction coefficient of this vehicle. * @return Rolling friction coefficient in [1e-4]. */ - inline uint32 GetRollingFriction() const + inline uint32_t GetRollingFriction() const { /* Rolling friction for steel on steel is between 0.1% and 0.2%. * The friction coefficient increases with speed in a way that @@ -309,7 +309,7 @@ protected: // These functions should not be called outside acceleration code. * Returns the slope steepness used by this vehicle. * @return Slope steepness used by the vehicle. */ - inline uint32 GetSlopeSteepness() const + inline uint32_t GetSlopeSteepness() const { return _settings_game.vehicle.train_slope_steepness; } @@ -318,7 +318,7 @@ protected: // These functions should not be called outside acceleration code. * Gets the maximum speed allowed by the track for this vehicle. * @return Maximum speed allowed. */ - inline uint16 GetMaxTrackSpeed() const + inline uint16_t GetMaxTrackSpeed() const { return GetRailTypeInfo(GetRailType(this->tile))->max_speed; } diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 2018159eca..628675a635 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -55,7 +55,7 @@ static const byte _vehicle_initial_x_fract[4] = {10, 8, 4, 8}; static const byte _vehicle_initial_y_fract[4] = { 8, 4, 8, 10}; template <> -bool IsValidImageIndex(uint8 image_index) +bool IsValidImageIndex(uint8_t image_index) { return image_index < lengthof(_engine_sprite_base); } @@ -109,7 +109,7 @@ void CheckTrainsLengths() */ void Train::ConsistChanged(ConsistChangeFlags allowed_changes) { - uint16 max_speed = UINT16_MAX; + uint16_t max_speed = UINT16_MAX; assert(this->IsFrontEngine() || this->IsFreeWagon()); @@ -186,12 +186,12 @@ void Train::ConsistChanged(ConsistChangeFlags allowed_changes) /* max speed is the minimum of the speed limits of all vehicles in the consist */ if ((rvi_u->railveh_type != RAILVEH_WAGON || _settings_game.vehicle.wagon_speed_limits) && !UsesWagonOverride(u)) { - uint16 speed = GetVehicleProperty(u, PROP_TRAIN_SPEED, rvi_u->max_speed); + uint16_t speed = GetVehicleProperty(u, PROP_TRAIN_SPEED, rvi_u->max_speed); if (speed != 0) max_speed = std::min(speed, max_speed); } } - uint16 new_cap = e_u->DetermineCapacity(u); + uint16_t new_cap = e_u->DetermineCapacity(u); if (allowed_changes & CCF_CAPACITY) { /* Update vehicle capacity. */ if (u->cargo_cap > new_cap) u->cargo.Truncate(new_cap); @@ -204,7 +204,7 @@ void Train::ConsistChanged(ConsistChangeFlags allowed_changes) u->vcache.cached_cargo_age_period = GetVehicleProperty(u, PROP_TRAIN_CARGO_AGE_PERIOD, e_u->info.cargo_age_period); /* check the vehicle length (callback) */ - uint16 veh_len = CALLBACK_FAILED; + uint16_t veh_len = CALLBACK_FAILED; if (e_u->GetGRF() != nullptr && e_u->GetGRF()->grf_version >= 8) { /* Use callback 36 */ veh_len = GetVehicleProperty(u, PROP_TRAIN_SHORTEN_FACTOR, CALLBACK_FAILED); @@ -478,7 +478,7 @@ int Train::GetDisplayImageWidth(Point *offset) const return ScaleSpriteTrad(this->gcache.cached_veh_length * reference_width / VEHICLE_LENGTH); } -static SpriteID GetDefaultTrainSprite(uint8 spritenum, Direction direction) +static SpriteID GetDefaultTrainSprite(uint8_t spritenum, Direction direction) { assert(IsValidImageIndex(spritenum)); return ((direction + _engine_sprite_add[spritenum]) & _engine_sprite_and[spritenum]) + _engine_sprite_base[spritenum]; @@ -492,7 +492,7 @@ static SpriteID GetDefaultTrainSprite(uint8 spritenum, Direction direction) */ void Train::GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const { - uint8 spritenum = this->spritenum; + uint8_t spritenum = this->spritenum; if (HasBit(this->flags, VRF_REVERSE_DIRECTION)) direction = ReverseDir(direction); @@ -515,7 +515,7 @@ static void GetRailIcon(EngineID engine, bool rear_head, int &y, EngineImageType { const Engine *e = Engine::Get(engine); Direction dir = rear_head ? DIR_E : DIR_W; - uint8 spritenum = e->u.rail.image_index; + uint8_t spritenum = e->u.rail.image_index; if (is_custom_sprite(spritenum)) { GetCustomVehicleIcon(engine, dir, image_type, result); @@ -1031,7 +1031,7 @@ static CommandCost CheckTrainAttachment(Train *t) * the loop and after each callback does not need to be cleared here. */ t->InvalidateNewGRFCache(); - uint16 callback = GetVehicleCallbackParent(CBID_TRAIN_ALLOW_WAGON_ATTACH, 0, 0, head->engine_type, t, head); + uint16_t callback = GetVehicleCallbackParent(CBID_TRAIN_ALLOW_WAGON_ATTACH, 0, 0, head->engine_type, t, head); /* Restore original first_engine data */ t->gcache.first_engine = first_engine; @@ -1549,10 +1549,10 @@ static void MarkTrainAsStuck(Train *v) * @param[in,out] swap_flag1 First train flag. * @param[in,out] swap_flag2 Second train flag. */ -static void SwapTrainFlags(uint16 *swap_flag1, uint16 *swap_flag2) +static void SwapTrainFlags(uint16_t *swap_flag1, uint16_t *swap_flag2) { - uint16 flag1 = *swap_flag1; - uint16 flag2 = *swap_flag2; + uint16_t flag1 = *swap_flag1; + uint16_t flag2 = *swap_flag2; /* Clear the flags */ ClrBit(*swap_flag1, GVF_GOINGUP_BIT); @@ -1625,7 +1625,7 @@ void ReverseTrainSwapVeh(Train *v, int l, int r) if (a != b) { /* swap the hidden bits */ { - uint16 tmp = (a->vehstatus & ~VS_HIDDEN) | (b->vehstatus & VS_HIDDEN); + uint16_t tmp = (a->vehstatus & ~VS_HIDDEN) | (b->vehstatus & VS_HIDDEN); b->vehstatus = (b->vehstatus & ~VS_HIDDEN) | (a->vehstatus & VS_HIDDEN); a->vehstatus = tmp; } @@ -3042,7 +3042,7 @@ static inline void AffectSpeedByZChange(Train *v, int old_z) if (old_z < v->z_pos) { v->cur_speed -= (v->cur_speed * asp->z_up >> 8); } else { - uint16 spd = v->cur_speed + asp->z_down; + uint16_t spd = v->cur_speed + asp->z_down; if (spd <= v->gcache.cached_max_track_speed) v->cur_speed = spd; } } @@ -3278,7 +3278,7 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse) /* Reverse when we are at the end of the track already, do not move to the new position */ if (v->IsFrontEngine() && !TrainCheckIfLineEnds(v, reverse)) return false; - uint32 r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y); + uint32_t r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y); if (HasBit(r, VETS_CANNOT_ENTER)) { goto invalid_rail; } @@ -3425,7 +3425,7 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse) Direction chosen_dir = (Direction)b[2]; /* Call the landscape function and tell it that the vehicle entered the tile */ - uint32 r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y); + uint32_t r = VehicleEnterTile(v, gp.new_tile, gp.x, gp.y); if (HasBit(r, VETS_CANNOT_ENTER)) { goto invalid_rail; } @@ -3717,7 +3717,7 @@ static bool HandleCrashedTrain(Train *v) CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE); } - uint32 r; + uint32_t r; if (state <= 200 && Chance16R(1, 7, r)) { int index = (r * 10 >> 16); @@ -3748,7 +3748,7 @@ static bool HandleCrashedTrain(Train *v) } /** Maximum speeds for train that is broken down or approaching line end */ -static const uint16 _breakdown_speeds[16] = { +static const uint16_t _breakdown_speeds[16] = { 225, 210, 195, 180, 165, 150, 135, 120, 105, 90, 75, 60, 45, 30, 15, 15 }; @@ -3794,7 +3794,7 @@ static bool TrainApproachingLineEnd(Train *v, bool signal, bool reverse) /* slow down */ v->vehstatus |= VS_TRAIN_SLOWING; - uint16 break_speed = _breakdown_speeds[x & 0xF]; + uint16_t break_speed = _breakdown_speeds[x & 0xF]; if (break_speed < v->cur_speed) v->cur_speed = break_speed; return true; @@ -3871,7 +3871,7 @@ static bool TrainCheckIfLineEnds(Train *v, bool reverse) if (t > 1) { v->vehstatus |= VS_TRAIN_SLOWING; - uint16 break_speed = _breakdown_speeds[GB(~t, 4, 4)]; + uint16_t break_speed = _breakdown_speeds[GB(~t, 4, 4)]; if (break_speed < v->cur_speed) v->cur_speed = break_speed; } else { v->vehstatus &= ~VS_TRAIN_SLOWING; @@ -4210,9 +4210,9 @@ Trackdir Train::GetVehicleTrackdir() const return TrackDirectionToTrackdir(FindFirstTrack(this->track), this->direction); } -uint16 Train::GetMaxWeight() const +uint16_t Train::GetMaxWeight() const { - uint16 weight = CargoSpec::Get(this->cargo_type)->WeightOfNUnitsInTrain(this->GetEngine()->DetermineCapacity(this)); + uint16_t weight = CargoSpec::Get(this->cargo_type)->WeightOfNUnitsInTrain(this->GetEngine()->DetermineCapacity(this)); /* Vehicle weight is not added for articulated parts. */ if (!this->IsArticulatedPart()) { diff --git a/src/train_cmd.h b/src/train_cmd.h index bf365a851c..e122dcca96 100644 --- a/src/train_cmd.h +++ b/src/train_cmd.h @@ -25,6 +25,6 @@ DEF_CMD_TRAIT(CMD_MOVE_RAIL_VEHICLE, CmdMoveRailVehicle, CMD_LOCATIO DEF_CMD_TRAIT(CMD_FORCE_TRAIN_PROCEED, CmdForceTrainProceed, CMD_LOCATION, CMDT_VEHICLE_MANAGEMENT) DEF_CMD_TRAIT(CMD_REVERSE_TRAIN_DIRECTION, CmdReverseTrainDirection, CMD_LOCATION, CMDT_VEHICLE_MANAGEMENT) -void CcBuildWagon(Commands cmd, const CommandCost &result, VehicleID new_veh_id, uint, uint16, CargoArray, TileIndex tile, EngineID, bool, CargoID, ClientID); +void CcBuildWagon(Commands cmd, const CommandCost &result, VehicleID new_veh_id, uint, uint16_t, CargoArray, TileIndex tile, EngineID, bool, CargoID, ClientID); #endif /* TRAIN_CMD_H */ diff --git a/src/train_gui.cpp b/src/train_gui.cpp index 76993eb2c3..4c121fb135 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -27,7 +27,7 @@ * @param new_veh_id ID of the ne vehicle. * @param tile The tile the command was executed on. */ -void CcBuildWagon(Commands cmd, const CommandCost &result, VehicleID new_veh_id, uint, uint16, CargoArray, TileIndex tile, EngineID, bool, CargoID, ClientID) +void CcBuildWagon(Commands cmd, const CommandCost &result, VehicleID new_veh_id, uint, uint16_t, CargoArray, TileIndex tile, EngineID, bool, CargoID, ClientID) { if (result.Failed()) return; @@ -351,7 +351,7 @@ int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab) * @param vscroll_cap Number of lines currently displayed * @param det_tab Selected details tab */ -void DrawTrainDetails(const Train *v, const Rect &r, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab) +void DrawTrainDetails(const Train *v, const Rect &r, int vscroll_pos, uint16_t vscroll_cap, TrainDetailsWindowTabs det_tab) { bool rtl = _current_text_dir == TD_RTL; int line_height = r.Height(); diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index 479e0f8b7a..19b39f60fd 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -104,7 +104,7 @@ public: } } - Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override + Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override { Point pt = GetToolbarAlignedWindowPosition(sm_width); pt.y += 2 * (sm_height - this->GetWidget(WID_TT_BUTTONS)->current_y); diff --git a/src/transport_type.h b/src/transport_type.h index 7784e9205d..5ad7202020 100644 --- a/src/transport_type.h +++ b/src/transport_type.h @@ -13,7 +13,7 @@ #include "core/enum_type.hpp" /** Type for the company global vehicle unit number. */ -typedef uint16 UnitID; +typedef uint16_t UnitID; /** Available types of transport */ enum TransportType : byte { diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index a3838fbf6e..f5ad488eeb 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -54,9 +54,9 @@ enum ExtraTreePlacement { /** Determines when to consider building more trees. */ byte _trees_tick_ctr; -static const uint16 DEFAULT_TREE_STEPS = 1000; ///< Default number of attempts for placing trees. -static const uint16 DEFAULT_RAINFOREST_TREE_STEPS = 15000; ///< Default number of attempts for placing extra trees at rainforest in tropic. -static const uint16 EDITOR_TREE_DIV = 5; ///< Game editor tree generation divisor factor. +static const uint16_t DEFAULT_TREE_STEPS = 1000; ///< Default number of attempts for placing trees. +static const uint16_t DEFAULT_RAINFOREST_TREE_STEPS = 15000; ///< Default number of attempts for placing extra trees at rainforest in tropic. +static const uint16_t EDITOR_TREE_DIV = 5; ///< Game editor tree generation divisor factor. /** * Tests if a tile can be converted to MP_TREES @@ -161,7 +161,7 @@ static TreeType GetRandomTreeType(TileIndex tile, uint seed) * @param tile The tile to make a tree-tile from * @param r The randomness value from a Random() value */ -static void PlaceTree(TileIndex tile, uint32 r) +static void PlaceTree(TileIndex tile, uint32_t r) { TreeType tree = GetRandomTreeType(tile, GB(r, 24, 8)); @@ -189,7 +189,7 @@ static void PlaceTreeGroups(uint num_groups) TileIndex center_tile = RandomTile(); for (uint i = 0; i < DEFAULT_TREE_STEPS; i++) { - uint32 r = Random(); + uint32_t r = Random(); int x = GB(r, 0, 5) - 16; int y = GB(r, 8, 5) - 16; uint dist = abs(x) + abs(y); @@ -217,7 +217,7 @@ static void PlaceTreeGroups(uint num_groups) static void PlaceTreeAtSameHeight(TileIndex tile, int height) { for (uint i = 0; i < DEFAULT_TREE_STEPS; i++) { - uint32 r = Random(); + uint32_t r = Random(); int x = GB(r, 0, 5) - 16; int y = GB(r, 8, 5) - 16; TileIndex cur_tile = TileAddWrap(tile, x, y); @@ -250,7 +250,7 @@ void PlaceTreesRandomly() i = Map::ScaleBySize(DEFAULT_TREE_STEPS); if (_game_mode == GM_EDITOR) i /= EDITOR_TREE_DIV; do { - uint32 r = Random(); + uint32_t r = Random(); TileIndex tile = RandomTileSeed(r); IncreaseGeneratingWorldProgress(GWP_TREE); @@ -279,7 +279,7 @@ void PlaceTreesRandomly() if (_game_mode == GM_EDITOR) i /= EDITOR_TREE_DIV; do { - uint32 r = Random(); + uint32_t r = Random(); TileIndex tile = RandomTileSeed(r); IncreaseGeneratingWorldProgress(GWP_TREE); @@ -312,14 +312,14 @@ uint PlaceTreeGroupAroundTile(TileIndex tile, TreeType treetype, uint radius, ui for (; count > 0; count--) { /* Simple quasi-normal distribution with range [-radius; radius) */ - auto mkcoord = [&]() -> int32 { - const uint32 rand = InteractiveRandom(); - const int32 dist = GB(rand, 0, 8) + GB(rand, 8, 8) + GB(rand, 16, 8) + GB(rand, 24, 8); - const int32 scu = dist * radius / 512; + auto mkcoord = [&]() -> int32_t { + const uint32_t rand = InteractiveRandom(); + const int32_t dist = GB(rand, 0, 8) + GB(rand, 8, 8) + GB(rand, 16, 8) + GB(rand, 24, 8); + const int32_t scu = dist * radius / 512; return scu - radius; }; - const int32 xofs = mkcoord(); - const int32 yofs = mkcoord(); + const int32_t xofs = mkcoord(); + const int32_t yofs = mkcoord(); const TileIndex tile_to_plant = TileAddWrap(tile, xofs, yofs); if (tile_to_plant != INVALID_TILE) { if (IsTileType(tile_to_plant, MP_TREES) && GetTreeCount(tile_to_plant) < 4) { @@ -527,7 +527,7 @@ static void DrawTile_Trees(TileInfo *ti) /* Do not draw trees when the invisible trees setting is set */ if (IsInvisibilitySet(TO_TREES)) return; - uint tmp = CountBits(static_cast(ti->tile + ti->x + ti->y)); + uint tmp = CountBits(static_cast(ti->tile + ti->x + ti->y)); uint index = GB(tmp, 0, 2) + (GetTreeType(ti->tile) << 2); /* different tree styles above one of the grounds */ @@ -646,7 +646,7 @@ static void TileLoopTreesDesert(TileIndex tile) SND_44_RAINFOREST_3, SND_48_RAINFOREST_4 }; - uint32 r = Random(); + uint32_t r = Random(); if (Chance16I(1, 200, r) && _settings_client.sound.ambient) SndPlayTileFx(forest_sounds[GB(r, 16, 2)], tile); break; @@ -676,7 +676,7 @@ static void TileLoopTreesAlps(TileIndex tile) SetTreeGroundDensity(tile, GetTreeGround(tile), density); } else { if (GetTreeDensity(tile) == 3) { - uint32 r = Random(); + uint32_t r = Random(); if (Chance16I(1, 200, r) && _settings_client.sound.ambient) { SndPlayTileFx((r & 0x80000000) ? SND_39_ARCTIC_SNOW_2 : SND_34_ARCTIC_SNOW_1, tile); } @@ -711,7 +711,7 @@ static void TileLoop_Trees(TileIndex tile) * Also, we use a simple hash to spread the updates evenly over the map. * 11 and 9 are just some co-prime numbers for better spread. */ - uint32 cycle = 11 * TileX(tile) + 9 * TileY(tile) + (TimerGameTick::counter >> 8); + uint32_t cycle = 11 * TileX(tile) + 9 * TileY(tile) + (TimerGameTick::counter >> 8); /* Handle growth of grass (under trees/on MP_TREES tiles) at every 8th processings, like it's done for grass on MP_CLEAR tiles. */ if ((cycle & 7) == 7 && GetTreeGround(tile) == TREE_GROUND_GRASS) { @@ -833,7 +833,7 @@ void OnTick_Trees() /* Don't spread trees if that's not allowed */ if (_settings_game.construction.extra_tree_placement == ETP_NO_SPREAD || _settings_game.construction.extra_tree_placement == ETP_NO_GROWTH_NO_SPREAD) return; - uint32 r; + uint32_t r; TileIndex tile; TreeType tree; diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index 5292ba1e64..ac8d0fc962 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -52,8 +52,8 @@ const PalSpriteID tree_sprites[] = { */ static Dimension GetMaxTreeSpriteSize() { - const uint16 base = _tree_base_by_landscape[_settings_game.game_creation.landscape]; - const uint16 count = _tree_count_by_landscape[_settings_game.game_creation.landscape]; + const uint16_t base = _tree_base_by_landscape[_settings_game.game_creation.landscape]; + const uint16_t count = _tree_count_by_landscape[_settings_game.game_creation.landscape]; Dimension size, this_size; Point offset; diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 0ccb488052..61adb5936e 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -601,10 +601,10 @@ CommandCost CmdBuildBridge(DoCommandFlag flags, TileIndex tile_end, TileIndex ti if (c != nullptr) bridge_len = CalcBridgeLenCostFactor(bridge_len); if (transport_type != TRANSPORT_WATER) { - cost.AddCost((int64)bridge_len * _price[PR_BUILD_BRIDGE] * GetBridgeSpec(bridge_type)->price >> 8); + cost.AddCost((int64_t)bridge_len * _price[PR_BUILD_BRIDGE] * GetBridgeSpec(bridge_type)->price >> 8); } else { /* Aqueducts use a separate base cost. */ - cost.AddCost((int64)bridge_len * _price[PR_BUILD_AQUEDUCT]); + cost.AddCost((int64_t)bridge_len * _price[PR_BUILD_AQUEDUCT]); } } @@ -1749,7 +1749,7 @@ static void GetTileDesc_TunnelBridge(TileIndex tile, TileDesc *td) td->railtype = rti->strings.name; if (!IsTunnel(tile)) { - uint16 spd = GetBridgeSpec(GetBridgeType(tile))->speed; + uint16_t spd = GetBridgeSpec(GetBridgeType(tile))->speed; /* rail speed special-cases 0 as unlimited, hides display of limit etc. */ if (spd == UINT16_MAX) spd = 0; if (td->rail_speed == 0 || spd < td->rail_speed) { @@ -1757,7 +1757,7 @@ static void GetTileDesc_TunnelBridge(TileIndex tile, TileDesc *td) } } } else if (tt == TRANSPORT_ROAD && !IsTunnel(tile)) { - uint16 spd = GetBridgeSpec(GetBridgeType(tile))->speed; + uint16_t spd = GetBridgeSpec(GetBridgeType(tile))->speed; /* road speed special-cases 0 as unlimited, hides display of limit etc. */ if (spd == UINT16_MAX) spd = 0; if (road_rt != INVALID_ROADTYPE && (td->road_speed == 0 || spd < td->road_speed)) td->road_speed = spd; @@ -1965,7 +1965,7 @@ static VehicleEnterTileStatus VehicleEnter_TunnelBridge(Vehicle *v, TileIndex ti } else { // IsBridge(tile) if (v->type != VEH_SHIP) { /* modify speed of vehicle */ - uint16 spd = GetBridgeSpec(GetBridgeType(tile))->speed; + uint16_t spd = GetBridgeSpec(GetBridgeType(tile))->speed; if (v->type == VEH_ROAD) spd *= 2; Vehicle *first = v->First(); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 29f03bd060..1efdb30ba5 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -331,7 +331,7 @@ void VehicleLengthChanged(const Vehicle *u) { /* show a warning once for each engine in whole game and once for each GRF after each game load */ const Engine *engine = u->GetEngine(); - uint32 grfid = engine->grf_prop.grffile->grfid; + uint32_t grfid = engine->grf_prop.grffile->grfid; GRFConfig *grfconfig = GetGRFConfig(grfid); if (_gamelog.GRFBugReverse(grfid, engine->grf_prop.local_id) || !HasBit(grfconfig->grf_bugs, GBUG_VEH_LENGTH)) { ShowNewGrfVehicleError(u->engine_type, STR_NEWGRF_BROKEN, STR_NEWGRF_BROKEN_VEHICLE_LENGTH, GBUG_VEH_LENGTH, true); @@ -748,7 +748,7 @@ const GRFFile *Vehicle::GetGRF() const * This is the GRF providing the Action 3 for the engine type. * @return GRF ID of the associated NewGRF. */ -uint32 Vehicle::GetGRFID() const +uint32_t Vehicle::GetGRFID() const { return this->GetEngine()->GetGRFID(); } @@ -921,7 +921,7 @@ static void RunVehicleDayProc() /* Call the 32-day callback if needed */ if ((v->day_counter & 0x1F) == 0 && v->HasEngineType()) { - uint16 callback = GetVehicleCallback(CBID_VEHICLE_32DAY_CALLBACK, 0, 0, v->engine_type, v); + uint16_t callback = GetVehicleCallback(CBID_VEHICLE_32DAY_CALLBACK, 0, 0, v->engine_type, v); if (callback != CALLBACK_FAILED) { if (HasBit(callback, 0)) { TriggerVehicle(v, VEHICLE_TRIGGER_CALLBACK_32); // Trigger vehicle trigger 10 @@ -1270,7 +1270,7 @@ void CheckVehicleBreakdown(Vehicle *v) return; } - uint32 r = Random(); + uint32_t r = Random(); /* increase chance of failure */ int chance = v->breakdown_chance + 1; @@ -1414,7 +1414,7 @@ void AgeVehicle(Vehicle *v) * if the vehicle is completely empty or full. * This is useful for both display and conditional orders. */ -uint8 CalcPercentVehicleFilled(const Vehicle *front, StringID *colour) +uint8_t CalcPercentVehicleFilled(const Vehicle *front, StringID *colour) { int count = 0; int max = 0; @@ -1689,7 +1689,7 @@ bool Vehicle::MarkAllViewportsDirty() const */ GetNewVehiclePosResult GetNewVehiclePos(const Vehicle *v) { - static const int8 _delta_coord[16] = { + static const int8_t _delta_coord[16] = { -1,-1,-1, 0, 1, 1, 1, 0, /* x */ -1, 0, 1, 1, 1, 0,-1,-1, /* y */ }; @@ -2000,7 +2000,7 @@ static PaletteID GetEngineColourMap(EngineID engine_type, CompanyID company, Eng /* Check if we should use the colour map callback */ if (HasBit(e->info.callback_mask, CBM_VEHICLE_COLOUR_REMAP)) { - uint16 callback = GetVehicleCallback(CBID_VEHICLE_COLOUR_MAPPING, 0, 0, engine_type, v); + uint16_t callback = GetVehicleCallback(CBID_VEHICLE_COLOUR_MAPPING, 0, 0, engine_type, v); /* Failure means "use the default two-colour" */ if (callback != CALLBACK_FAILED) { static_assert(PAL_NONE == 0); // Returning 0x4000 (resp. 0xC000) coincidences with default value (PAL_NONE) @@ -2063,7 +2063,7 @@ PaletteID GetVehiclePalette(const Vehicle *v) void Vehicle::DeleteUnreachedImplicitOrders() { if (this->IsGroundVehicle()) { - uint16 &gv_flags = this->GetGroundVehicleFlags(); + uint16_t &gv_flags = this->GetGroundVehicleFlags(); if (HasBit(gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS)) { /* Do not delete orders, only skip them */ ClrBit(gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS); @@ -2198,7 +2198,7 @@ void Vehicle::BeginLoading() /* InsertOrder disabled creation of implicit orders for all vehicles with the same implicit order. * Reenable it for this vehicle */ - uint16 &gv_flags = this->GetGroundVehicleFlags(); + uint16_t &gv_flags = this->GetGroundVehicleFlags(); ClrBit(gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS); } } @@ -2410,7 +2410,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command) if (this->current_order.GetDepotOrderType() & ODTFB_PART_OF_ORDERS) this->IncrementRealOrderIndex(); if (this->IsGroundVehicle()) { - uint16 &gv_flags = this->GetGroundVehicleFlags(); + uint16_t &gv_flags = this->GetGroundVehicleFlags(); SetBit(gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS); } @@ -2428,7 +2428,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command) if (this->current_order.IsType(OT_LOADING)) this->LeaveStation(); if (this->IsGroundVehicle() && this->GetNumManualOrders() > 0) { - uint16 &gv_flags = this->GetGroundVehicleFlags(); + uint16_t &gv_flags = this->GetGroundVehicleFlags(); SetBit(gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS); } @@ -2475,7 +2475,7 @@ void Vehicle::UpdateVisualEffect(bool allow_power_change) /* Check powered wagon / visual effect callback */ if (HasBit(e->info.callback_mask, CBM_VEHICLE_VISUAL_EFFECT)) { - uint16 callback = GetVehicleCallback(CBID_VEHICLE_VISUAL_EFFECT, 0, 0, this->engine_type, this); + uint16_t callback = GetVehicleCallback(CBID_VEHICLE_VISUAL_EFFECT, 0, 0, this->engine_type, this); if (callback != CALLBACK_FAILED) { if (callback >= 0x100 && e->GetGRF()->grf_version >= 8) ErrorUnknownCallbackResult(e->GetGRFID(), CBID_VEHICLE_VISUAL_EFFECT, callback); @@ -2519,7 +2519,7 @@ void Vehicle::UpdateVisualEffect(bool allow_power_change) } } -static const int8 _vehicle_smoke_pos[8] = { +static const int8_t _vehicle_smoke_pos[8] = { 1, 1, 1, 0, -1, -1, -1, 0 }; @@ -2529,14 +2529,14 @@ static const int8 _vehicle_smoke_pos[8] = { */ static void SpawnAdvancedVisualEffect(const Vehicle *v) { - uint16 callback = GetVehicleCallback(CBID_VEHICLE_SPAWN_VISUAL_EFFECT, 0, Random(), v->engine_type, v); + uint16_t callback = GetVehicleCallback(CBID_VEHICLE_SPAWN_VISUAL_EFFECT, 0, Random(), v->engine_type, v); if (callback == CALLBACK_FAILED) return; uint count = GB(callback, 0, 2); bool auto_center = HasBit(callback, 13); bool auto_rotate = !HasBit(callback, 14); - int8 l_center = 0; + int8_t l_center = 0; if (auto_center) { /* For road vehicles: Compute offset from vehicle position to vehicle center */ if (v->type == VEH_ROAD) l_center = -(int)(VEHICLE_LENGTH - RoadVehicle::From(v)->gcache.cached_veh_length) / 2; @@ -2549,19 +2549,19 @@ static void SpawnAdvancedVisualEffect(const Vehicle *v) if (v->type == VEH_TRAIN && HasBit(Train::From(v)->flags, VRF_REVERSE_DIRECTION)) l_dir = ReverseDir(l_dir); Direction t_dir = ChangeDir(l_dir, DIRDIFF_90RIGHT); - int8 x_center = _vehicle_smoke_pos[l_dir] * l_center; - int8 y_center = _vehicle_smoke_pos[t_dir] * l_center; + int8_t x_center = _vehicle_smoke_pos[l_dir] * l_center; + int8_t y_center = _vehicle_smoke_pos[t_dir] * l_center; for (uint i = 0; i < count; i++) { - uint32 reg = GetRegister(0x100 + i); + uint32_t reg = GetRegister(0x100 + i); uint type = GB(reg, 0, 8); - int8 x = GB(reg, 8, 8); - int8 y = GB(reg, 16, 8); - int8 z = GB(reg, 24, 8); + int8_t x = GB(reg, 8, 8); + int8_t y = GB(reg, 16, 8); + int8_t z = GB(reg, 24, 8); if (auto_rotate) { - int8 l = x; - int8 t = y; + int8_t l = x; + int8_t t = y; x = _vehicle_smoke_pos[l_dir] * l + _vehicle_smoke_pos[t_dir] * t; y = _vehicle_smoke_pos[t_dir] * l - _vehicle_smoke_pos[l_dir] * t; } @@ -2978,7 +2978,7 @@ const GroundVehicleCache *Vehicle::GetGroundVehicleCache() const * @pre The vehicle is a #GroundVehicle. * @return #GroundVehicleFlags of the vehicle. */ -uint16 &Vehicle::GetGroundVehicleFlags() +uint16_t &Vehicle::GetGroundVehicleFlags() { assert(this->IsGroundVehicle()); if (this->type == VEH_TRAIN) { @@ -2993,7 +2993,7 @@ uint16 &Vehicle::GetGroundVehicleFlags() * @pre The vehicle is a #GroundVehicle. * @return #GroundVehicleFlags of the vehicle. */ -const uint16 &Vehicle::GetGroundVehicleFlags() const +const uint16_t &Vehicle::GetGroundVehicleFlags() const { assert(this->IsGroundVehicle()); if (this->type == VEH_TRAIN) { @@ -3011,7 +3011,7 @@ const uint16 &Vehicle::GetGroundVehicleFlags() const * @pre \a set must be empty. * @post \a set will contain the vehicles that will be refitted. */ -void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8 num_vehicles) +void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8_t num_vehicles) { if (v->type == VEH_TRAIN) { Train *u = Train::From(v); @@ -3037,9 +3037,9 @@ void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8 num_vehicles) * Calculates the maximum weight of the ground vehicle when loaded. * @return Weight in tonnes */ -uint32 Vehicle::GetDisplayMaxWeight() const +uint32_t Vehicle::GetDisplayMaxWeight() const { - uint32 max_weight = 0; + uint32_t max_weight = 0; for (const Vehicle* u = this; u != nullptr; u = u->Next()) { max_weight += u->GetMaxWeight(); @@ -3052,9 +3052,9 @@ uint32 Vehicle::GetDisplayMaxWeight() const * Calculates the minimum power-to-weight ratio using the maximum weight of the ground vehicle * @return power-to-weight ratio in 10ths of hp(I) per tonne */ -uint32 Vehicle::GetDisplayMinPowerToWeight() const +uint32_t Vehicle::GetDisplayMinPowerToWeight() const { - uint32 max_weight = GetDisplayMaxWeight(); + uint32_t max_weight = GetDisplayMaxWeight(); if (max_weight == 0) return 0; return GetGroundVehicleCache()->cached_power * 10u / max_weight; } diff --git a/src/vehicle_base.h b/src/vehicle_base.h index 0be02bb71d..093f4b5c2e 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -67,12 +67,12 @@ enum NewGRFCacheValidValues { /** Cached often queried (NewGRF) values */ struct NewGRFCache { /* Values calculated when they are requested for the first time after invalidating the NewGRF cache. */ - uint32 position_consist_length; ///< Cache for NewGRF var 40. - uint32 position_same_id_length; ///< Cache for NewGRF var 41. - uint32 consist_cargo_information; ///< Cache for NewGRF var 42. (Note: The cargotype is untranslated in the cache because the accessing GRF is yet unknown.) - uint32 company_information; ///< Cache for NewGRF var 43. - uint32 position_in_vehicle; ///< Cache for NewGRF var 4D. - uint8 cache_valid; ///< Bitset that indicates which cache values are valid. + uint32_t position_consist_length; ///< Cache for NewGRF var 40. + uint32_t position_same_id_length; ///< Cache for NewGRF var 41. + uint32_t consist_cargo_information; ///< Cache for NewGRF var 42. (Note: The cargotype is untranslated in the cache because the accessing GRF is yet unknown.) + uint32_t company_information; ///< Cache for NewGRF var 43. + uint32_t position_in_vehicle; ///< Cache for NewGRF var 4D. + uint8_t cache_valid; ///< Bitset that indicates which cache values are valid. }; /** Meaning of the various bits of the visual effect. */ @@ -121,8 +121,8 @@ enum GroundVehicleSubtypeFlags { /** Cached often queried values common to all vehicles. */ struct VehicleCache { - uint16 cached_max_speed; ///< Maximum speed of the consist (minimum of the max speed of all vehicles in the consist). - uint16 cached_cargo_age_period; ///< Number of ticks before carried cargo is aged. + uint16_t cached_max_speed; ///< Maximum speed of the consist (minimum of the max speed of all vehicles in the consist). + uint16_t cached_cargo_age_period; ///< Number of ticks before carried cargo is aged. byte cached_vis_effect; ///< Visual effect to show (see #VisualEffect) }; @@ -213,9 +213,9 @@ struct GRFFile; */ struct RefitDesc { CargoID cargo; ///< Cargo type the vehicle will be carrying. - uint16 capacity; ///< Capacity the vehicle will have. - uint16 remaining; ///< Capacity remaining from before the previous refit. - RefitDesc(CargoID cargo, uint16 capacity, uint16 remaining) : + uint16_t capacity; ///< Capacity the vehicle will have. + uint16_t remaining; ///< Capacity remaining from before the previous refit. + RefitDesc(CargoID cargo, uint16_t capacity, uint16_t remaining) : cargo(cargo), capacity(capacity), remaining(remaining) {} }; @@ -288,16 +288,16 @@ public: TimerGameCalendar::Date age; ///< Age in days TimerGameCalendar::Date max_age; ///< Maximum age TimerGameCalendar::Date date_of_last_service; ///< Last date the vehicle had a service at a depot. - uint16 reliability; ///< Reliability. - uint16 reliability_spd_dec; ///< Reliability decrease speed. + uint16_t reliability; ///< Reliability. + uint16_t reliability_spd_dec; ///< Reliability decrease speed. byte breakdown_ctr; ///< Counter for managing breakdown events. @see Vehicle::HandleBreakdown byte breakdown_delay; ///< Counter for managing breakdown length. byte breakdowns_since_last_service; ///< Counter for the amount of breakdowns. byte breakdown_chance; ///< Current chance of breakdowns. - int32 x_pos; ///< x coordinate. - int32 y_pos; ///< y coordinate. - int32 z_pos; ///< z coordinate. + int32_t x_pos; ///< x coordinate. + int32_t y_pos; ///< y coordinate. + int32_t z_pos; ///< z coordinate. Direction direction; ///< facing Owner owner; ///< Which company owns the vehicle? @@ -310,19 +310,19 @@ public: byte x_extent; ///< x-extent of vehicle bounding box byte y_extent; ///< y-extent of vehicle bounding box byte z_extent; ///< z-extent of vehicle bounding box - int8 x_bb_offs; ///< x offset of vehicle bounding box - int8 y_bb_offs; ///< y offset of vehicle bounding box - int8 x_offs; ///< x offset for vehicle sprite - int8 y_offs; ///< y offset for vehicle sprite + int8_t x_bb_offs; ///< x offset of vehicle bounding box + int8_t y_bb_offs; ///< y offset of vehicle bounding box + int8_t x_offs; ///< x offset for vehicle sprite + int8_t y_offs; ///< y offset for vehicle sprite EngineID engine_type; ///< The type of engine used for this vehicle. TextEffectID fill_percent_te_id; ///< a text-effect id to a loading indicator object UnitID unitnumber; ///< unit number, for display purposes only - uint16 cur_speed; ///< current speed + uint16_t cur_speed; ///< current speed byte subspeed; ///< fractional speed byte acceleration; ///< used by train & aircraft - uint32 motion_counter; ///< counter to occasionally play a vehicle sound. + uint32_t motion_counter; ///< counter to occasionally play a vehicle sound. byte progress; ///< The percentage (if divided by 256) this vehicle already crossed the tile unit. uint16_t random_bits; ///< Bits used for randomized variational spritegroups. @@ -334,11 +334,11 @@ public: CargoID cargo_type; ///< type of cargo this vehicle is carrying byte cargo_subtype; ///< Used for livery refits (NewGRF variations) - uint16 cargo_cap; ///< total capacity - uint16 refit_cap; ///< Capacity left over from before last refit. + uint16_t cargo_cap; ///< total capacity + uint16_t refit_cap; ///< Capacity left over from before last refit. VehicleCargoList cargo; ///< The cargo this vehicle is carrying - uint16 cargo_age_counter; ///< Ticks till cargo is aged next. - int8 trip_occupancy; ///< NOSAVE: Occupancy of vehicle of the current trip (updated after leaving a station). + uint16_t cargo_age_counter; ///< Ticks till cargo is aged next. + int8_t trip_occupancy; ///< NOSAVE: Occupancy of vehicle of the current trip (updated after leaving a station). byte day_counter; ///< Increased by one for each day byte tick_counter; ///< Increased by one for each tick @@ -352,7 +352,7 @@ public: Order *old_orders; ///< Only used during conversion of old save games }; - uint16 load_unload_ticks; ///< Ticks to wait before starting next cycle. + uint16_t load_unload_ticks; ///< Ticks to wait before starting next cycle. GroupID group_id; ///< Index of group Pool array byte subtype; ///< subtype (Filled with values from #AircraftSubType/#DisasterSubType/#EffectVehicleType/#GroundVehicleSubtypeFlags) @@ -365,7 +365,7 @@ public: * Calculates the weight value that this vehicle will have when fully loaded with its current cargo. * @return Weight value in tonnes. */ - virtual uint16 GetMaxWeight() const + virtual uint16_t GetMaxWeight() const { return 0; } @@ -383,8 +383,8 @@ public: GroundVehicleCache *GetGroundVehicleCache(); const GroundVehicleCache *GetGroundVehicleCache() const; - uint16 &GetGroundVehicleFlags(); - const uint16 &GetGroundVehicleFlags() const; + uint16_t &GetGroundVehicleFlags(); + const uint16_t &GetGroundVehicleFlags() const; void DeleteUnreachedImplicitOrders(); @@ -484,7 +484,7 @@ public: virtual void GetImage(Direction direction, EngineImageType image_type, VehicleSpriteSeq *result) const { result->Clear(); } const GRFFile *GetGRF() const; - uint32 GetGRFID() const; + uint32_t GetGRFID() const; /** * Invalidates cached NewGRF variables @@ -803,9 +803,9 @@ public: void UpdatePositionAndViewport(); bool MarkAllViewportsDirty() const; - inline uint16 GetServiceInterval() const { return this->service_interval; } + inline uint16_t GetServiceInterval() const { return this->service_interval; } - inline void SetServiceInterval(uint16 interval) { this->service_interval = interval; } + inline void SetServiceInterval(uint16_t interval) { this->service_interval = interval; } inline bool ServiceIntervalIsCustom() const { return HasBit(this->vehicle_flags, VF_SERVINT_IS_CUSTOM); } @@ -1063,8 +1063,8 @@ public: */ IterateWrapper Orders() const { return IterateWrapper(this->orders); } - uint32 GetDisplayMaxWeight() const; - uint32 GetDisplayMinPowerToWeight() const; + uint32_t GetDisplayMaxWeight() const; + uint32_t GetDisplayMinPowerToWeight() const; }; /** @@ -1278,6 +1278,6 @@ struct FreeUnitIDGenerator { }; /** Sentinel for an invalid coordinate. */ -static const int32 INVALID_COORD = 0x7fffffff; +static const int32_t INVALID_COORD = 0x7fffffff; #endif /* VEHICLE_BASE_H */ diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index ba988ffeb9..46f284e15c 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -84,7 +84,7 @@ const StringID _send_to_depot_msg_table[] = { * @param client_id User * @return the cost of this operation + the new vehicle ID + the refitted capacity + the refitted mail capacity (aircraft) or an error */ -std::tuple CmdBuildVehicle(DoCommandFlag flags, TileIndex tile, EngineID eid, bool use_free_vehicles, CargoID cargo, ClientID client_id) +std::tuple CmdBuildVehicle(DoCommandFlag flags, TileIndex tile, EngineID eid, bool use_free_vehicles, CargoID cargo, ClientID client_id) { /* Elementary check for valid location. */ if (!IsDepotTile(tile) || !IsTileOwner(tile, _current_company)) return { CMD_ERROR, INVALID_VEHICLE, 0, 0, {} }; @@ -144,7 +144,7 @@ std::tuple CmdBuildVehicle(DoC VehicleID veh_id = INVALID_VEHICLE; uint refitted_capacity = 0; - uint16 refitted_mail_capacity = 0; + uint16_t refitted_mail_capacity = 0; CargoArray cargo_capacities{}; if (value.Succeeded()) { if (subflags & DC_EXEC) { @@ -272,9 +272,9 @@ static int GetRefitCostFactor(const Vehicle *v, EngineID engine_type, CargoID ne /* Is this vehicle a NewGRF vehicle? */ if (e->GetGRF() != nullptr) { const CargoSpec *cs = CargoSpec::Get(new_cid); - uint32 param1 = (cs->classes << 16) | (new_subtype << 8) | e->GetGRF()->cargo_map[new_cid]; + uint32_t param1 = (cs->classes << 16) | (new_subtype << 8) | e->GetGRF()->cargo_map[new_cid]; - uint16 cb_res = GetVehicleCallback(CBID_VEHICLE_REFIT_COST, param1, 0, engine_type, v); + uint16_t cb_res = GetVehicleCallback(CBID_VEHICLE_REFIT_COST, param1, 0, engine_type, v); if (cb_res != CALLBACK_FAILED) { *auto_refit_allowed = HasBit(cb_res, 14); int factor = GB(cb_res, 0, 14); @@ -353,7 +353,7 @@ struct RefitResult { * @param auto_refit Refitting is done as automatic refitting outside a depot. * @return Refit cost + refittet capacity + mail capacity (aircraft). */ -static std::tuple RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles, CargoID new_cid, byte new_subtype, DoCommandFlag flags, bool auto_refit) +static std::tuple RefitVehicle(Vehicle *v, bool only_this, uint8_t num_vehicles, CargoID new_cid, byte new_subtype, DoCommandFlag flags, bool auto_refit) { CommandCost cost(v->GetExpenseType(false)); uint total_capacity = 0; @@ -403,7 +403,7 @@ static std::tuple RefitVehicle(Vehicle *v v->cargo_subtype = actual_subtype; } - uint16 mail_capacity = 0; + uint16_t mail_capacity = 0; uint amount = e->DetermineCapacity(v, &mail_capacity); total_capacity += amount; /* mail_capacity will always be zero if the vehicle is not an aircraft. */ @@ -452,7 +452,7 @@ static std::tuple RefitVehicle(Vehicle *v /* Store the result */ for (RefitResult &result : refit_result) { Vehicle *u = result.v; - u->refit_cap = (u->cargo_type == new_cid) ? std::min(result.capacity, u->refit_cap) : 0; + u->refit_cap = (u->cargo_type == new_cid) ? std::min(result.capacity, u->refit_cap) : 0; if (u->cargo.TotalCount() > u->refit_cap) u->cargo.Truncate(u->cargo.TotalCount() - u->refit_cap); u->cargo_type = new_cid; u->cargo_cap = result.capacity; @@ -460,7 +460,7 @@ static std::tuple RefitVehicle(Vehicle *v if (u->type == VEH_AIRCRAFT) { Vehicle *w = u->Next(); assert(w != nullptr); - w->refit_cap = std::min(w->refit_cap, result.mail_capacity); + w->refit_cap = std::min(w->refit_cap, result.mail_capacity); w->cargo_cap = result.mail_capacity; if (w->cargo.TotalCount() > w->refit_cap) w->cargo.Truncate(w->cargo.TotalCount() - w->refit_cap); } @@ -483,7 +483,7 @@ static std::tuple RefitVehicle(Vehicle *v * Only used if "refit only this vehicle" is false. * @return the cost of this operation or an error */ -std::tuple CmdRefitVehicle(DoCommandFlag flags, VehicleID veh_id, CargoID new_cid, byte new_subtype, bool auto_refit, bool only_this, uint8 num_vehicles) +std::tuple CmdRefitVehicle(DoCommandFlag flags, VehicleID veh_id, CargoID new_cid, byte new_subtype, bool auto_refit, bool only_this, uint8_t num_vehicles) { Vehicle *v = Vehicle::GetIfValid(veh_id); if (v == nullptr) return { CMD_ERROR, 0, 0, {} }; @@ -600,7 +600,7 @@ CommandCost CmdStartStopVehicle(DoCommandFlag flags, VehicleID veh_id, bool eval if (evaluate_startstop_cb) { /* Check if this vehicle can be started/stopped. Failure means 'allow'. */ - uint16 callback = GetVehicleCallback(CBID_VEHICLE_START_STOP_CHECK, 0, 0, v->engine_type, v); + uint16_t callback = GetVehicleCallback(CBID_VEHICLE_START_STOP_CHECK, 0, 0, v->engine_type, v); StringID error = STR_NULL; if (callback != CALLBACK_FAILED) { if (v->GetGRF()->grf_version < 8) { @@ -1100,7 +1100,7 @@ CommandCost CmdRenameVehicle(DoCommandFlag flags, VehicleID veh_id, const std::s * @param is_percent service interval is percentage flag * @return the cost of this operation or an error */ -CommandCost CmdChangeServiceInt(DoCommandFlag flags, VehicleID veh_id, uint16 serv_int, bool is_custom, bool is_percent) +CommandCost CmdChangeServiceInt(DoCommandFlag flags, VehicleID veh_id, uint16_t serv_int, bool is_custom, bool is_percent) { Vehicle *v = Vehicle::GetIfValid(veh_id); if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR; diff --git a/src/vehicle_cmd.h b/src/vehicle_cmd.h index d892875ff1..bdd5d9124c 100644 --- a/src/vehicle_cmd.h +++ b/src/vehicle_cmd.h @@ -17,11 +17,11 @@ #include "vehiclelist_cmd.h" #include "cargo_type.h" -std::tuple CmdBuildVehicle(DoCommandFlag flags, TileIndex tile, EngineID eid, bool use_free_vehicles, CargoID cargo, ClientID client_id); +std::tuple CmdBuildVehicle(DoCommandFlag flags, TileIndex tile, EngineID eid, bool use_free_vehicles, CargoID cargo, ClientID client_id); CommandCost CmdSellVehicle(DoCommandFlag flags, VehicleID v_id, bool sell_chain, bool backup_order, ClientID client_id); -std::tuple CmdRefitVehicle(DoCommandFlag flags, VehicleID veh_id, CargoID new_cid, byte new_subtype, bool auto_refit, bool only_this, uint8 num_vehicles); +std::tuple CmdRefitVehicle(DoCommandFlag flags, VehicleID veh_id, CargoID new_cid, byte new_subtype, bool auto_refit, bool only_this, uint8_t num_vehicles); CommandCost CmdSendVehicleToDepot(DoCommandFlag flags, VehicleID veh_id, DepotCommand depot_cmd, const VehicleListIdentifier &vli); -CommandCost CmdChangeServiceInt(DoCommandFlag flags, VehicleID veh_id, uint16 serv_int, bool is_custom, bool is_percent); +CommandCost CmdChangeServiceInt(DoCommandFlag flags, VehicleID veh_id, uint16_t serv_int, bool is_custom, bool is_percent); CommandCost CmdRenameVehicle(DoCommandFlag flags, VehicleID veh_id, const std::string &text); std::tuple CmdCloneVehicle(DoCommandFlag flags, TileIndex tile, VehicleID veh_id, bool share_orders); CommandCost CmdStartStopVehicle(DoCommandFlag flags, VehicleID veh_id, bool evaluate_startstop_cb); @@ -41,7 +41,7 @@ DEF_CMD_TRAIT(CMD_MASS_START_STOP, CmdMassStartStopVehicle, 0, DEF_CMD_TRAIT(CMD_DEPOT_SELL_ALL_VEHICLES, CmdDepotSellAllVehicles, 0, CMDT_VEHICLE_CONSTRUCTION) DEF_CMD_TRAIT(CMD_DEPOT_MASS_AUTOREPLACE, CmdDepotMassAutoReplace, 0, CMDT_VEHICLE_CONSTRUCTION) -void CcBuildPrimaryVehicle(Commands cmd, const CommandCost &result, VehicleID new_veh_id, uint, uint16, CargoArray); +void CcBuildPrimaryVehicle(Commands cmd, const CommandCost &result, VehicleID new_veh_id, uint, uint16_t, CargoArray); void CcStartStopVehicle(Commands cmd, const CommandCost &result, VehicleID veh_id, bool); template diff --git a/src/vehicle_func.h b/src/vehicle_func.h index a8b63ac2d0..e0c7b37956 100644 --- a/src/vehicle_func.h +++ b/src/vehicle_func.h @@ -35,7 +35,7 @@ static const Money VEHICLE_PROFIT_THRESHOLD = 10000; ///< Threshold for a * @return True iff the image index is valid. */ template -bool IsValidImageIndex(uint8 image_index); +bool IsValidImageIndex(uint8_t image_index); typedef Vehicle *VehicleFromPosProc(Vehicle *v, void *data); @@ -46,7 +46,7 @@ void FindVehicleOnPosXY(int x, int y, void *data, VehicleFromPosProc *proc); bool HasVehicleOnPos(TileIndex tile, void *data, VehicleFromPosProc *proc); bool HasVehicleOnPosXY(int x, int y, void *data, VehicleFromPosProc *proc); void CallVehicleTicks(); -uint8 CalcPercentVehicleFilled(const Vehicle *v, StringID *colour); +uint8_t CalcPercentVehicleFilled(const Vehicle *v, StringID *colour); void VehicleLengthChanged(const Vehicle *u); @@ -171,7 +171,7 @@ StringID GetVehicleCannotUseStationReason(const Vehicle *v, const Station *st); void ReleaseDisastersTargetingVehicle(VehicleID vehicle); typedef std::vector VehicleSet; -void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8 num_vehicles); +void GetVehicleSet(VehicleSet &set, Vehicle *v, uint8_t num_vehicles); void CheckCargoCapacity(Vehicle *v); diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 772425b3b4..7f5f1d9da4 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -614,7 +614,7 @@ struct RefitWindow : public Window { uint vehicle_margin; ///< Margin to use while selecting vehicles when the vehicle image is centered. int click_x; ///< Position of the first click while dragging. VehicleID selected_vehicle; ///< First vehicle in the current selection. - uint8 num_vehicles; ///< Number of selected vehicles. + uint8_t num_vehicles; ///< Number of selected vehicles. bool auto_refit; ///< Select cargo for auto-refitting. /** @@ -1288,7 +1288,7 @@ uint ShowRefitOptionsList(int left, int right, int y, EngineID engine) StringID GetCargoSubtypeText(const Vehicle *v) { if (HasBit(EngInfo(v->engine_type)->callback_mask, CBM_VEHICLE_CARGO_SUFFIX)) { - uint16 cb = GetVehicleCallback(CBID_VEHICLE_CARGO_SUFFIX, 0, 0, v->engine_type, v); + uint16_t cb = GetVehicleCallback(CBID_VEHICLE_CARGO_SUFFIX, 0, 0, v->engine_type, v); if (cb != CALLBACK_FAILED) { if (cb > 0x400) ErrorUnknownCallbackResult(v->GetGRFID(), CBID_VEHICLE_CARGO_SUFFIX, cb); if (cb >= 0x400 || (v->GetGRF()->grf_version < 8 && cb == 0xFF)) cb = CALLBACK_FAILED; @@ -2181,7 +2181,7 @@ static WindowDesc _vehicle_list_train_desc( _nested_vehicle_list, lengthof(_nested_vehicle_list) ); -static void ShowVehicleListWindowLocal(CompanyID company, VehicleListType vlt, VehicleType vehicle_type, uint32 unique_number) +static void ShowVehicleListWindowLocal(CompanyID company, VehicleListType vlt, VehicleType vehicle_type, uint32_t unique_number) { if (!Company::IsValidID(company) && company != OWNER_NONE) return; @@ -2220,7 +2220,7 @@ void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, StationI void ShowVehicleListWindow(CompanyID company, VehicleType vehicle_type, TileIndex depot_tile) { - uint16 depot_airport_index; + uint16_t depot_airport_index; if (vehicle_type == VEH_AIRCRAFT) { depot_airport_index = GetStationIndex(depot_tile); @@ -2299,7 +2299,7 @@ static const NWidgetPart _nested_train_vehicle_details_widgets[] = { extern int GetTrainDetailsWndVScroll(VehicleID veh_id, TrainDetailsWindowTabs det_tab); -extern void DrawTrainDetails(const Train *v, const Rect &r, int vscroll_pos, uint16 vscroll_cap, TrainDetailsWindowTabs det_tab); +extern void DrawTrainDetails(const Train *v, const Rect &r, int vscroll_pos, uint16_t vscroll_cap, TrainDetailsWindowTabs det_tab); extern void DrawRoadVehDetails(const Vehicle *v, const Rect &r); extern void DrawShipDetails(const Vehicle *v, const Rect &r); extern void DrawAircraftDetails(const Aircraft *v, const Rect &r); @@ -2659,7 +2659,7 @@ struct VehicleDetailsWindow : Window { const Vehicle *v = Vehicle::Get(this->window_number); bool iscustom = index != 0; bool ispercent = iscustom ? (index == 2) : Company::Get(v->owner)->settings.vehicle.servint_ispercent; - uint16 interval = GetServiceIntervalClamped(v->GetServiceInterval(), ispercent); + uint16_t interval = GetServiceIntervalClamped(v->GetServiceInterval(), ispercent); Command::Post(STR_ERROR_CAN_T_CHANGE_SERVICING, v->index, interval, iscustom, ispercent); break; } @@ -3366,7 +3366,7 @@ void StopGlobalFollowVehicle(const Vehicle *v) * @param result indicates completion (or not) of the operation * @param new_veh_id ID of the new vehicle. */ -void CcBuildPrimaryVehicle(Commands cmd, const CommandCost &result, VehicleID new_veh_id, uint, uint16, CargoArray) +void CcBuildPrimaryVehicle(Commands cmd, const CommandCost &result, VehicleID new_veh_id, uint, uint16_t, CargoArray) { if (result.Failed()) return; diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h index 7c6949a090..8d35281550 100644 --- a/src/vehicle_gui.h +++ b/src/vehicle_gui.h @@ -42,7 +42,7 @@ struct TestedEngineDetails { Money cost; ///< Refit cost CargoID cargo; ///< Cargo type uint capacity; ///< Cargo capacity - uint16 mail_capacity; ///< Mail capacity if available + uint16_t mail_capacity; ///< Mail capacity if available CargoArray all_capacities{}; ///< Capacities for all cargoes void FillDefaultCapacities(const Engine *e); diff --git a/src/vehicle_type.h b/src/vehicle_type.h index ce8c606358..625d032b3e 100644 --- a/src/vehicle_type.h +++ b/src/vehicle_type.h @@ -13,7 +13,7 @@ #include "core/enum_type.hpp" /** The type all our vehicle IDs have. */ -typedef uint32 VehicleID; +typedef uint32_t VehicleID; static const int GROUND_ACCELERATION = 9800; ///< Acceleration due to gravity, 9.8 m/s^2 diff --git a/src/vehiclelist.cpp b/src/vehiclelist.cpp index 111762ee13..b7cbbb22b9 100644 --- a/src/vehiclelist.cpp +++ b/src/vehiclelist.cpp @@ -18,7 +18,7 @@ * Pack a VehicleListIdentifier in a single uint32. * @return The packed identifier. */ -uint32 VehicleListIdentifier::Pack() const +uint32_t VehicleListIdentifier::Pack() const { byte c = this->company == OWNER_NONE ? 0xF : (byte)this->company; assert(c < (1 << 4)); @@ -35,7 +35,7 @@ uint32 VehicleListIdentifier::Pack() const * @param data The data to unpack. * @return true iff the data was valid (enough). */ -bool VehicleListIdentifier::UnpackIfValid(uint32 data) +bool VehicleListIdentifier::UnpackIfValid(uint32_t data) { byte c = GB(data, 28, 4); this->company = c == 0xF ? OWNER_NONE : (CompanyID)c; @@ -50,7 +50,7 @@ bool VehicleListIdentifier::UnpackIfValid(uint32 data) * Decode a packed vehicle list identifier into a new one. * @param data The data to unpack. */ -/* static */ VehicleListIdentifier VehicleListIdentifier::UnPack(uint32 data) +/* static */ VehicleListIdentifier VehicleListIdentifier::UnPack(uint32_t data) { VehicleListIdentifier result; [[maybe_unused]] bool ret = result.UnpackIfValid(data); diff --git a/src/vehiclelist.h b/src/vehiclelist.h index df9649d5e3..87a8912642 100644 --- a/src/vehiclelist.h +++ b/src/vehiclelist.h @@ -29,11 +29,11 @@ struct VehicleListIdentifier { VehicleListType type; ///< The type of vehicle list. VehicleType vtype; ///< The vehicle type associated with this list. CompanyID company; ///< The company associated with this list. - uint32 index; ///< A vehicle list type specific index. + uint32_t index; ///< A vehicle list type specific index. - uint32 Pack() const; - bool UnpackIfValid(uint32 data); - static VehicleListIdentifier UnPack(uint32 data); + uint32_t Pack() const; + bool UnpackIfValid(uint32_t data); + static VehicleListIdentifier UnPack(uint32_t data); bool Valid() const { return this->type < VLT_END; } diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp index e7310539e2..a2ac32c117 100644 --- a/src/video/allegro_v.cpp +++ b/src/video/allegro_v.cpp @@ -246,7 +246,7 @@ std::vector VideoDriver_Allegro::GetListOfMonitorRefreshRates() } struct AllegroVkMapping { - uint16 vk_from; + uint16_t vk_from; byte vk_count; byte map_to; }; @@ -307,7 +307,7 @@ static const AllegroVkMapping _vk_mapping[] = { AS(KEY_TILDE, WKC_BACKQUOTE), }; -static uint32 ConvertAllegroKeyIntoMy(WChar *character) +static uint32_t ConvertAllegroKeyIntoMy(char32_t *character) { int scancode; int unicode = ureadkey(&scancode); @@ -407,7 +407,7 @@ bool VideoDriver_Allegro::PollEvent() if ((key_shifts & KB_ALT_FLAG) && (key[KEY_ENTER] || key[KEY_F])) { ToggleFullScreen(!_fullscreen); } else if (keypressed()) { - WChar character; + char32_t character; uint keycode = ConvertAllegroKeyIntoMy(&character); HandleKeypress(keycode, character); } diff --git a/src/video/cocoa/cocoa_ogl.h b/src/video/cocoa/cocoa_ogl.h index 5d616c1472..b8a06c3bae 100644 --- a/src/video/cocoa/cocoa_ogl.h +++ b/src/video/cocoa/cocoa_ogl.h @@ -17,7 +17,7 @@ class VideoDriver_CocoaOpenGL : public VideoDriver_Cocoa { CGLContextObj gl_context; - uint8 *anim_buffer; ///< Animation buffer from OpenGL back-end. + uint8_t *anim_buffer; ///< Animation buffer from OpenGL back-end. std::string driver_info; ///< Information string about selected driver. const char *AllocateContext(bool allow_software); @@ -37,7 +37,7 @@ public: void PopulateSystemSprites() override; bool HasAnimBuffer() override { return true; } - uint8 *GetAnimBuffer() override { return this->anim_buffer; } + uint8_t *GetAnimBuffer() override { return this->anim_buffer; } /** Return driver name */ const char *GetName() const override { return "cocoa-opengl"; } diff --git a/src/video/cocoa/cocoa_v.h b/src/video/cocoa/cocoa_v.h index 3fe79ac905..8606a902bc 100644 --- a/src/video/cocoa/cocoa_v.h +++ b/src/video/cocoa/cocoa_v.h @@ -99,7 +99,7 @@ private: int window_height; ///< Current window height in pixel int window_pitch; - uint32 palette[256]; ///< Colour Palette + uint32_t palette[256]; ///< Colour Palette void BlitIndexedToView32(int left, int top, int right, int bottom); void UpdatePalette(uint first_color, uint num_colors); diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm index 568377710f..28058bea15 100644 --- a/src/video/cocoa/cocoa_v.mm +++ b/src/video/cocoa/cocoa_v.mm @@ -573,11 +573,11 @@ void VideoDriver_Cocoa::MainLoopReal() static FVideoDriver_CocoaQuartz iFVideoDriver_CocoaQuartz; /** Clear buffer to opaque black. */ -static void ClearWindowBuffer(uint32 *buffer, uint32 pitch, uint32 height) +static void ClearWindowBuffer(uint32_t *buffer, uint32_t pitch, uint32_t height) { - uint32 fill = Colour(0, 0, 0).data; - for (uint32 y = 0; y < height; y++) { - for (uint32 x = 0; x < pitch; x++) { + uint32_t fill = Colour(0, 0, 0).data; + for (uint32_t y = 0; y < height; y++) { + for (uint32_t x = 0; x < pitch; x++) { buffer[y * pitch + x] = fill; } } @@ -651,14 +651,14 @@ void VideoDriver_CocoaQuartz::AllocateBackingStore(bool force) this->window_width = (int)newframe.size.width; this->window_height = (int)newframe.size.height; - this->window_pitch = Align(this->window_width, 16 / sizeof(uint32)); // Quartz likes lines that are multiple of 16-byte. + this->window_pitch = Align(this->window_width, 16 / sizeof(uint32_t)); // Quartz likes lines that are multiple of 16-byte. this->buffer_depth = BlitterFactory::GetCurrentBlitter()->GetScreenDepth(); /* Create Core Graphics Context */ free(this->window_buffer); - this->window_buffer = malloc(this->window_pitch * this->window_height * sizeof(uint32)); + this->window_buffer = malloc(this->window_pitch * this->window_height * sizeof(uint32_t)); /* Initialize with opaque black. */ - ClearWindowBuffer((uint32 *)this->window_buffer, this->window_pitch, this->window_height); + ClearWindowBuffer((uint32_t *)this->window_buffer, this->window_pitch, this->window_height); CGContextRelease(this->cgcontext); this->cgcontext = CGBitmapContextCreate( @@ -706,9 +706,9 @@ void VideoDriver_CocoaQuartz::AllocateBackingStore(bool force) */ void VideoDriver_CocoaQuartz::BlitIndexedToView32(int left, int top, int right, int bottom) { - const uint32 *pal = this->palette; - const uint8 *src = (uint8*)this->pixel_buffer; - uint32 *dst = (uint32*)this->window_buffer; + const uint32_t *pal = this->palette; + const uint8_t *src = (uint8_t*)this->pixel_buffer; + uint32_t *dst = (uint32_t*)this->window_buffer; uint width = this->window_width; uint pitch = this->window_pitch; @@ -725,10 +725,10 @@ void VideoDriver_CocoaQuartz::UpdatePalette(uint first_color, uint num_colors) if (this->buffer_depth != 8) return; for (uint i = first_color; i < first_color + num_colors; i++) { - uint32 clr = 0xff000000; - clr |= (uint32)_local_palette.palette[i].r << 16; - clr |= (uint32)_local_palette.palette[i].g << 8; - clr |= (uint32)_local_palette.palette[i].b; + uint32_t clr = 0xff000000; + clr |= (uint32_t)_local_palette.palette[i].r << 16; + clr |= (uint32_t)_local_palette.palette[i].g << 8; + clr |= (uint32_t)_local_palette.palette[i].b; this->palette[i] = clr; } diff --git a/src/video/cocoa/cocoa_wnd.mm b/src/video/cocoa/cocoa_wnd.mm index d31be0920c..83048ed98a 100644 --- a/src/video/cocoa/cocoa_wnd.mm +++ b/src/video/cocoa/cocoa_wnd.mm @@ -107,7 +107,7 @@ static NSUInteger CountUtf16Units(const char *from, const char *to) NSUInteger i = 0; while (from < to) { - WChar c; + char32_t c; size_t len = Utf8Decode(&c, from); i += len < 4 ? 1 : 2; // Watch for surrogate pairs. from += len; @@ -125,7 +125,7 @@ static NSUInteger CountUtf16Units(const char *from, const char *to) static const char *Utf8AdvanceByUtf16Units(const char *str, NSUInteger count) { for (NSUInteger i = 0; i < count && *str != '\0'; ) { - WChar c; + char32_t c; size_t len = Utf8Decode(&c, str); i += len < 4 ? 1 : 2; // Watch for surrogates. str += len; @@ -139,9 +139,9 @@ static const char *Utf8AdvanceByUtf16Units(const char *str, NSUInteger count) * @param s String to convert. * @return Vector of UTF-32 characters. */ -static std::vector NSStringToUTF32(NSString *s) +static std::vector NSStringToUTF32(NSString *s) { - std::vector unicode_str; + std::vector unicode_str; unichar lead = 0; for (NSUInteger i = 0; i < s.length; i++) { @@ -161,7 +161,7 @@ static std::vector NSStringToUTF32(NSString *s) static void CGDataFreeCallback(void *, const void *data, size_t) { - delete[] (const uint32 *)data; + delete[] (const uint32_t *)data; } /** @@ -176,7 +176,7 @@ static NSImage *NSImageFromSprite(SpriteID sprite_id, ZoomLevel zoom) /* Fetch the sprite and create a new bitmap */ Dimension dim = GetSpriteSize(sprite_id, nullptr, zoom); - std::unique_ptr buffer = DrawSpriteToRgbaBuffer(sprite_id, zoom); + std::unique_ptr buffer = DrawSpriteToRgbaBuffer(sprite_id, zoom); if (!buffer) return nullptr; // Failed to blit sprite for some reason. CFAutoRelease data(CGDataProviderCreateWithData(nullptr, buffer.release(), dim.width * dim.height * 4, &CGDataFreeCallback)); @@ -674,7 +674,7 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel - (BOOL)emulateRightButton:(NSEvent *)event { - uint32 keymask = 0; + uint32_t keymask = 0; if (_settings_client.gui.right_mouse_btn_emulation == RMBE_COMMAND) keymask |= NSEventModifierFlagCommand; if (_settings_client.gui.right_mouse_btn_emulation == RMBE_CONTROL) keymask |= NSEventModifierFlagControl; @@ -780,7 +780,7 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel } -- (BOOL)internalHandleKeycode:(unsigned short)keycode unicode:(WChar)unicode pressed:(BOOL)down modifiers:(NSUInteger)modifiers +- (BOOL)internalHandleKeycode:(unsigned short)keycode unicode:(char32_t)unicode pressed:(BOOL)down modifiers:(NSUInteger)modifiers { switch (keycode) { case QZ_UP: SB(_dirkeys, 1, 1, down); break; @@ -813,7 +813,7 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel if (down) { /* Map keycode to OTTD code. */ auto vk = std::find_if(std::begin(_vk_mapping), std::end(_vk_mapping), [=](const CocoaVkMapping &m) { return m.vk_from == keycode; }); - uint32 pressed_key = vk != std::end(_vk_mapping) ? vk->map_to : 0; + uint32_t pressed_key = vk != std::end(_vk_mapping) ? vk->map_to : 0; if (modifiers & NSEventModifierFlagShift) pressed_key |= WKC_SHIFT; if (modifiers & NSEventModifierFlagControl) pressed_key |= (_settings_client.gui.right_mouse_btn_emulation != RMBE_CONTROL ? WKC_CTRL : WKC_META); @@ -861,7 +861,7 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel } /* Convert UTF-16 characters to UCS-4 chars. */ - std::vector unicode_str = NSStringToUTF32([ event characters ]); + std::vector unicode_str = NSStringToUTF32([ event characters ]); if (unicode_str.empty()) unicode_str.push_back(0); if (EditBoxInGlobalFocus()) { @@ -890,7 +890,7 @@ void CocoaDialog(const char *title, const char *message, const char *buttonLabel } /* Convert UTF-16 characters to UCS-4 chars. */ - std::vector unicode_str = NSStringToUTF32([ event characters ]); + std::vector unicode_str = NSStringToUTF32([ event characters ]); if (unicode_str.empty()) unicode_str.push_back(0); [ self internalHandleKeycode:event.keyCode unicode:unicode_str[0] pressed:NO modifiers:event.modifierFlags ]; diff --git a/src/video/opengl.cpp b/src/video/opengl.cpp index 9c13361498..c9543319ff 100644 --- a/src/video/opengl.cpp +++ b/src/video/opengl.cpp @@ -940,7 +940,7 @@ bool OpenGLBackend::Resize(int w, int h, bool force) if (_glClearBufferSubData != nullptr) { _glClearBufferSubData(GL_PIXEL_UNPACK_BUFFER, GL_RGBA8, 0, line_pixel_count * bpp / 8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, &black.data); } else { - ClearPixelBuffer(line_pixel_count, black.data); + ClearPixelBuffer(line_pixel_count, black.data); } } else if (bpp == 8) { if (_glClearBufferSubData != nullptr) { @@ -1173,7 +1173,7 @@ void *OpenGLBackend::GetVideoBuffer() * Get a pointer to the memory for the separate animation buffer. * @return Pointer to draw on. */ -uint8 *OpenGLBackend::GetAnimBuffer() +uint8_t *OpenGLBackend::GetAnimBuffer() { if (this->anim_pbo == 0) return nullptr; @@ -1189,7 +1189,7 @@ uint8 *OpenGLBackend::GetAnimBuffer() this->anim_buffer = _glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, static_cast(_screen.pitch) * _screen.height, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); } - return (uint8 *)this->anim_buffer; + return (uint8_t *)this->anim_buffer; } /** @@ -1370,7 +1370,7 @@ void OpenGLBackend::RenderOglSprite(OpenGLSprite *gl_sprite, PaletteID pal, int _glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, 1, 1, 0, GL_RED, GL_UNSIGNED_BYTE, &pal); /* Create palette remap textures. */ - std::array identity_pal; + std::array identity_pal; std::iota(std::begin(identity_pal), std::end(identity_pal), 0); /* Permanent texture for identity remap. */ @@ -1474,7 +1474,7 @@ OpenGLSprite::~OpenGLSprite() void OpenGLSprite::Update(uint width, uint height, uint level, const SpriteLoader::CommonPixel * data) { static ReusableBuffer buf_rgba; - static ReusableBuffer buf_pal; + static ReusableBuffer buf_pal; _glActiveTexture(GL_TEXTURE0); _glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); @@ -1499,7 +1499,7 @@ void OpenGLSprite::Update(uint width, uint height, uint level, const SpriteLoade /* Unpack and align pixel data. */ size_t pitch = Align(width, 4); - uint8 *pal = buf_pal.Allocate(pitch * height); + uint8_t *pal = buf_pal.Allocate(pitch * height); const SpriteLoader::CommonPixel *row = data; for (uint y = 0; y < height; y++, pal += pitch, row += width) { for (uint x = 0; x < width; x++) { diff --git a/src/video/opengl.h b/src/video/opengl.h index 0cdb89035a..f3607a2e33 100644 --- a/src/video/opengl.h +++ b/src/video/opengl.h @@ -101,7 +101,7 @@ public: void ClearCursorCache(); void *GetVideoBuffer(); - uint8 *GetAnimBuffer(); + uint8_t *GetAnimBuffer(); void ReleaseVideoBuffer(const Rect &update_rect); void ReleaseAnimBuffer(const Rect &update_rect); diff --git a/src/video/sdl2_opengl_v.h b/src/video/sdl2_opengl_v.h index c7e647ca88..a79fe48d59 100644 --- a/src/video/sdl2_opengl_v.h +++ b/src/video/sdl2_opengl_v.h @@ -27,7 +27,7 @@ public: void PopulateSystemSprites() override; bool HasAnimBuffer() override { return true; } - uint8 *GetAnimBuffer() override { return this->anim_buffer; } + uint8_t *GetAnimBuffer() override { return this->anim_buffer; } void ToggleVsync(bool vsync) override; @@ -42,7 +42,7 @@ protected: private: void *gl_context; ///< OpenGL context. - uint8 *anim_buffer; ///< Animation buffer from OpenGL back-end. + uint8_t *anim_buffer; ///< Animation buffer from OpenGL back-end. const char *AllocateContext(); void DestroyContext(); diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp index 7ffd3d4eb1..bad581eef3 100644 --- a/src/video/sdl2_v.cpp +++ b/src/video/sdl2_v.cpp @@ -166,7 +166,7 @@ bool VideoDriver_SDL_Base::CreateMainWindow(uint w, uint h, uint flags) SDL_Surface *icon = SDL_LoadBMP(icon_path.c_str()); if (icon != nullptr) { /* Get the colourkey, which will be magenta */ - uint32 rgbmap = SDL_MapRGB(icon->format, 255, 0, 255); + uint32_t rgbmap = SDL_MapRGB(icon->format, 255, 0, 255); SDL_SetColorKey(icon, SDL_TRUE, rgbmap); SDL_SetWindowIcon(this->sdl_window, icon); @@ -302,7 +302,7 @@ static const SDLVkMapping _vk_mapping[] = { AS(SDLK_PERIOD, WKC_PERIOD) }; -static uint ConvertSdlKeyIntoMy(SDL_Keysym *sym, WChar *character) +static uint ConvertSdlKeyIntoMy(SDL_Keysym *sym, char32_t *character) { const SDLVkMapping *map; uint key = 0; @@ -440,7 +440,7 @@ bool VideoDriver_SDL_Base::PollEvent() (ev.key.keysym.sym == SDLK_RETURN || ev.key.keysym.sym == SDLK_f)) { if (ev.key.repeat == 0) ToggleFullScreen(!_fullscreen); } else { - WChar character; + char32_t character; uint keycode = ConvertSdlKeyIntoMy(&ev.key.keysym, &character); // Only handle non-text keys here. Text is handled in @@ -470,7 +470,7 @@ bool VideoDriver_SDL_Base::PollEvent() uint keycode = ConvertSdlKeycodeIntoMy(kc); if (keycode == WKC_BACKQUOTE && FocusedWindowIsConsole()) { - WChar character; + char32_t character; Utf8Decode(&character, ev.text.text); HandleKeypress(keycode, character); } else { @@ -575,7 +575,7 @@ void VideoDriver_SDL_Base::Stop() void VideoDriver_SDL_Base::InputLoop() { - uint32 mod = SDL_GetModState(); + uint32_t mod = SDL_GetModState(); const Uint8 *keys = SDL_GetKeyboardState(nullptr); bool old_ctrl_pressed = _ctrl_pressed; diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index af3571314f..54819eb9e3 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -240,7 +240,7 @@ bool VideoDriver_SDL::CreateMainSurface(uint w, uint h) icon = SDL_LoadBMP(icon_path.c_str()); if (icon != nullptr) { /* Get the colourkey, which will be magenta */ - uint32 rgbmap = SDL_MapRGB(icon->format, 255, 0, 255); + uint32_t rgbmap = SDL_MapRGB(icon->format, 255, 0, 255); SDL_SetColorKey(icon, SDL_SRCCOLORKEY, rgbmap); SDL_WM_SetIcon(icon, nullptr); @@ -373,7 +373,7 @@ bool VideoDriver_SDL::ClaimMousePointer() } struct SDLVkMapping { - uint16 vk_from; + uint16_t vk_from; byte vk_count; byte map_to; }; @@ -433,7 +433,7 @@ static const SDLVkMapping _vk_mapping[] = { AS(SDLK_PERIOD, WKC_PERIOD) }; -static uint ConvertSdlKeyIntoMy(SDL_keysym *sym, WChar *character) +static uint ConvertSdlKeyIntoMy(SDL_keysym *sym, char32_t *character) { const SDLVkMapping *map; uint key = 0; @@ -553,7 +553,7 @@ bool VideoDriver_SDL::PollEvent() (ev.key.keysym.sym == SDLK_RETURN || ev.key.keysym.sym == SDLK_f)) { ToggleFullScreen(!_fullscreen); } else { - WChar character; + char32_t character; uint keycode = ConvertSdlKeyIntoMy(&ev.key.keysym, &character); HandleKeypress(keycode, character); } @@ -627,7 +627,7 @@ void VideoDriver_SDL::Stop() void VideoDriver_SDL::InputLoop() { - uint32 mod = SDL_GetModState(); + uint32_t mod = SDL_GetModState(); int numkeys; Uint8 *keys = SDL_GetKeyState(&numkeys); diff --git a/src/video/video_driver.hpp b/src/video/video_driver.hpp index f9e8a254b2..25d47a1c72 100644 --- a/src/video/video_driver.hpp +++ b/src/video/video_driver.hpp @@ -140,7 +140,7 @@ public: * Get a pointer to the animation buffer of the video back-end. * @return Pointer to the buffer or nullptr if no animation buffer is supported. */ - virtual uint8 *GetAnimBuffer() + virtual uint8_t *GetAnimBuffer() { return nullptr; } diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index cf260c2508..cb92196d66 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -123,7 +123,7 @@ static uint MapWindowsKey(uint sym) } /** Colour depth to use for fullscreen display modes. */ -uint8 VideoDriver_Win32Base::GetFullscreenBpp() +uint8_t VideoDriver_Win32Base::GetFullscreenBpp() { /* Check modes for the relevant fullscreen bpp */ return _support8bpp != S8BPP_HARDWARE ? 32 : BlitterFactory::GetCurrentBlitter()->GetScreenDepth(); @@ -239,9 +239,9 @@ bool VideoDriver_Win32Base::MakeWindow(bool full_screen, bool resize) } /** Forward key presses to the window system. */ -static LRESULT HandleCharMsg(uint keycode, WChar charcode) +static LRESULT HandleCharMsg(uint keycode, char32_t charcode) { - static WChar prev_char = 0; + static char32_t prev_char = 0; /* Did we get a lead surrogate? If yes, store and exit. */ if (Utf16IsLeadSurrogate(charcode)) { @@ -399,7 +399,7 @@ static void CancelIMEComposition(HWND hwnd) LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - static uint32 keycode = 0; + static uint32_t keycode = 0; static bool console = false; VideoDriver_Win32Base *video_driver = (VideoDriver_Win32Base *)GetWindowLongPtr(hwnd, GWLP_USERDATA); @@ -471,8 +471,8 @@ LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return 0; case WM_MOUSEMOVE: { - int x = (int16)LOWORD(lParam); - int y = (int16)HIWORD(lParam); + int x = (int16_t)LOWORD(lParam); + int y = (int16_t)HIWORD(lParam); /* If the mouse was not in the window and it has moved it means it has * come into the window, so start drawing the mouse. Also start @@ -492,8 +492,8 @@ LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) * end, we only care about the current mouse position and not bygone events. */ MSG m; while (PeekMessage(&m, hwnd, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE | PM_NOYIELD | PM_QS_INPUT)) { - x = (int16)LOWORD(m.lParam); - y = (int16)HIWORD(m.lParam); + x = (int16_t)LOWORD(m.lParam); + y = (int16_t)HIWORD(m.lParam); } } @@ -793,7 +793,7 @@ static const Dimension default_resolutions[] = { { 1920, 1200 } }; -static void FindResolutions(uint8 bpp) +static void FindResolutions(uint8_t bpp) { _resolutions.clear(); diff --git a/src/video/win32_v.h b/src/video/win32_v.h index c25d5d73ac..14f1c6690b 100644 --- a/src/video/win32_v.h +++ b/src/video/win32_v.h @@ -60,7 +60,7 @@ protected: void ClientSizeChanged(int w, int h, bool force = false); /** Get screen depth to use for fullscreen mode. */ - virtual uint8 GetFullscreenBpp(); + virtual uint8_t GetFullscreenBpp(); /** (Re-)create the backing store. */ virtual bool AllocateBackingStore(int w, int h, bool force = false) = 0; /** Get a pointer to the video buffer. */ @@ -136,7 +136,7 @@ public: void ClearSystemSprites() override; bool HasAnimBuffer() override { return true; } - uint8 *GetAnimBuffer() override { return this->anim_buffer; } + uint8_t *GetAnimBuffer() override { return this->anim_buffer; } void ToggleVsync(bool vsync) override; @@ -147,10 +147,10 @@ public: protected: HDC dc; ///< Window device context. HGLRC gl_rc; ///< OpenGL context. - uint8 *anim_buffer; ///< Animation buffer from OpenGL back-end. + uint8_t *anim_buffer; ///< Animation buffer from OpenGL back-end. std::string driver_info; ///< Information string about selected driver. - uint8 GetFullscreenBpp() override { return 32; } // OpenGL is always 32 bpp. + uint8_t GetFullscreenBpp() override { return 32; } // OpenGL is always 32 bpp. void Paint() override; diff --git a/src/viewport.cpp b/src/viewport.cpp index 2165d15fcf..02548dd442 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -115,25 +115,25 @@ struct StringSpriteToDraw { std::string string; StringID string_id; Colours colour; - int32 x; - int32 y; - uint16 width; + int32_t x; + int32_t y; + uint16_t width; }; struct TileSpriteToDraw { SpriteID image; PaletteID pal; const SubSprite *sub; ///< only draw a rectangular part of the sprite - int32 x; ///< screen X coordinate of sprite - int32 y; ///< screen Y coordinate of sprite + int32_t x; ///< screen X coordinate of sprite + int32_t y; ///< screen Y coordinate of sprite }; struct ChildScreenSpriteToDraw { SpriteID image; PaletteID pal; const SubSprite *sub; ///< only draw a rectangular part of the sprite - int32 x; - int32 y; + int32_t x; + int32_t y; bool relative; int next; ///< next child to draw (-1 at the end) }; @@ -219,7 +219,7 @@ void DeleteWindowViewport(Window *w) * @param zoom Zoomlevel to display */ void InitializeWindowViewport(Window *w, int x, int y, - int width, int height, uint32 follow_flags, ZoomLevel zoom) + int width, int height, uint32_t follow_flags, ZoomLevel zoom) { assert(w->viewport == nullptr); @@ -500,7 +500,7 @@ void HandleZoomMessage(Window *w, const Viewport *vp, byte widget_zoom_in, byte * @param extra_offs_x Pixel X offset for the sprite position. * @param extra_offs_y Pixel Y offset for the sprite position. */ -static void AddTileSpriteToDraw(SpriteID image, PaletteID pal, int32 x, int32 y, int z, const SubSprite *sub = nullptr, int extra_offs_x = 0, int extra_offs_y = 0) +static void AddTileSpriteToDraw(SpriteID image, PaletteID pal, int32_t x, int32_t y, int z, const SubSprite *sub = nullptr, int extra_offs_x = 0, int extra_offs_y = 0) { assert((image & SPRITE_MASK) < MAX_SPRITES); @@ -554,7 +554,7 @@ static void AddChildSpriteToFoundation(SpriteID image, PaletteID pal, const SubS * @param extra_offs_x Pixel X offset for the sprite position. * @param extra_offs_y Pixel Y offset for the sprite position. */ -void DrawGroundSpriteAt(SpriteID image, PaletteID pal, int32 x, int32 y, int z, const SubSprite *sub, int extra_offs_x, int extra_offs_y) +void DrawGroundSpriteAt(SpriteID image, PaletteID pal, int32_t x, int32_t y, int z, const SubSprite *sub, int extra_offs_x, int extra_offs_y) { /* Switch to first foundation part, if no foundation was drawn */ if (_vd.foundation_part == FOUNDATION_PART_NONE) _vd.foundation_part = FOUNDATION_PART_NORMAL; @@ -663,7 +663,7 @@ static void AddCombinedSprite(SpriteID image, PaletteID pal, int x, int y, int z */ void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w, int h, int dz, int z, bool transparent, int bb_offset_x, int bb_offset_y, int bb_offset_z, const SubSprite *sub) { - int32 left, right, top, bottom; + int32_t left, right, top, bottom; assert((image & SPRITE_MASK) < MAX_SPRITES); @@ -849,7 +849,7 @@ void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool tran _vd.last_child = &cs.next; } -static void AddStringToDraw(int x, int y, StringID string, Colours colour, uint16 width) +static void AddStringToDraw(int x, int y, StringID string, Colours colour, uint16_t width) { assert(width != 0); StringSpriteToDraw &ss = _vd.string_sprites_to_draw.emplace_back(); @@ -1524,12 +1524,12 @@ static void ViewportSortParentSprites(ParentSpriteToSortVector *psdv) * Also use special constants to indicate sorting state without * adding extra fields to ParentSpriteToDraw structure. */ - const uint32 ORDER_COMPARED = UINT32_MAX; // Sprite was compared but we still need to compare the ones preceding it - const uint32 ORDER_RETURNED = UINT32_MAX - 1; // Makr sorted sprite in case there are other occurrences of it in the stack + const uint32_t ORDER_COMPARED = UINT32_MAX; // Sprite was compared but we still need to compare the ones preceding it + const uint32_t ORDER_RETURNED = UINT32_MAX - 1; // Makr sorted sprite in case there are other occurrences of it in the stack std::stack sprite_order; - uint32 next_order = 0; + uint32_t next_order = 0; - std::forward_list> sprite_list; // We store sprites in a list sorted by xmin+ymin + std::forward_list> sprite_list; // We store sprites in a list sorted by xmin+ymin /* Initialize sprite list and order. */ for (auto p = psdv->rbegin(); p != psdv->rend(); p++) { @@ -1687,7 +1687,7 @@ static void ViewportDrawDirtyBlocks() byte bo = UnScaleByZoom(dpi->left + dpi->top, dpi->zoom) & 1; do { - for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, (uint8)colour); + for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, (uint8_t)colour); dst = blitter->MoveTo(dst, 0, 1); } while (--bottom > 0); } @@ -2709,7 +2709,7 @@ void VpSetPlaceSizingLimit(int limit) */ void VpSetPresizeRange(TileIndex from, TileIndex to) { - uint64 distance = DistanceManhattan(from, to) + 1; + uint64_t distance = DistanceManhattan(from, to) + 1; _thd.selend.x = TileX(to) * TILE_SIZE; _thd.selend.y = TileY(to) * TILE_SIZE; @@ -3470,7 +3470,7 @@ void InitializeSpriteSorter() * @param ref company or client id depending on the target * @return the cost of this operation or an error */ -CommandCost CmdScrollViewport(DoCommandFlag flags, TileIndex tile, ViewportScrollTarget target, uint32 ref) +CommandCost CmdScrollViewport(DoCommandFlag flags, TileIndex tile, ViewportScrollTarget target, uint32_t ref) { if (_current_company != OWNER_DEITY) return CMD_ERROR; switch (target) { diff --git a/src/viewport_cmd.h b/src/viewport_cmd.h index 0cae1d9317..4c3314e091 100644 --- a/src/viewport_cmd.h +++ b/src/viewport_cmd.h @@ -13,7 +13,7 @@ #include "command_type.h" #include "viewport_type.h" -CommandCost CmdScrollViewport(DoCommandFlag flags, TileIndex tile, ViewportScrollTarget target, uint32 ref); +CommandCost CmdScrollViewport(DoCommandFlag flags, TileIndex tile, ViewportScrollTarget target, uint32_t ref); DEF_CMD_TRAIT(CMD_SCROLL_VIEWPORT, CmdScrollViewport, CMD_DEITY, CMDT_OTHER_MANAGEMENT) diff --git a/src/viewport_func.h b/src/viewport_func.h index 8b68b55dfe..d6be050979 100644 --- a/src/viewport_func.h +++ b/src/viewport_func.h @@ -21,7 +21,7 @@ static const int TILE_HEIGHT_STEP = 50; ///< One Z unit tile height difference i void SetSelectionRed(bool); void DeleteWindowViewport(Window *w); -void InitializeWindowViewport(Window *w, int x, int y, int width, int height, uint32 follow_flags, ZoomLevel zoom); +void InitializeWindowViewport(Window *w, int x, int y, int width, int height, uint32_t follow_flags, ZoomLevel zoom); Viewport *IsPtInWindowViewport(const Window *w, int x, int y); Point TranslateXYToTileCoord(const Viewport *vp, int x, int y, bool clamp_to_map = true); Point GetTileBelowCursor(); @@ -50,7 +50,7 @@ static inline void MaxZoomInOut(ZoomStateChange how, Window *w) void OffsetGroundSprite(int x, int y); void DrawGroundSprite(SpriteID image, PaletteID pal, const SubSprite *sub = nullptr, int extra_offs_x = 0, int extra_offs_y = 0); -void DrawGroundSpriteAt(SpriteID image, PaletteID pal, int32 x, int32 y, int z, const SubSprite *sub = nullptr, int extra_offs_x = 0, int extra_offs_y = 0); +void DrawGroundSpriteAt(SpriteID image, PaletteID pal, int32_t x, int32_t y, int z, const SubSprite *sub = nullptr, int extra_offs_x = 0, int extra_offs_y = 0); void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w, int h, int dz, int z, bool transparent = false, int bb_offset_x = 0, int bb_offset_y = 0, int bb_offset_z = 0, const SubSprite *sub = nullptr); void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool transparent = false, const SubSprite *sub = nullptr, bool scale = true, bool relative = true); void ViewportAddString(const DrawPixelInfo *dpi, ZoomLevel small_from, const ViewportSign *sign, StringID string_normal, StringID string_small, StringID string_small_shadow, Colours colour = INVALID_COLOUR); diff --git a/src/viewport_kdtree.h b/src/viewport_kdtree.h index 93344a5e63..940d695051 100644 --- a/src/viewport_kdtree.h +++ b/src/viewport_kdtree.h @@ -17,7 +17,7 @@ #include "signs_base.h" struct ViewportSignKdtreeItem { - enum ItemType : uint16 { + enum ItemType : uint16_t { VKI_STATION, VKI_WAYPOINT, VKI_TOWN, @@ -29,8 +29,8 @@ struct ViewportSignKdtreeItem { TownID town; SignID sign; } id; - int32 center; - int32 top; + int32_t center; + int32_t top; bool operator== (const ViewportSignKdtreeItem &other) const { @@ -70,12 +70,12 @@ struct ViewportSignKdtreeItem { static ViewportSignKdtreeItem MakeSign(SignID id); }; -inline int32 Kdtree_ViewportSignXYFunc(const ViewportSignKdtreeItem &item, int dim) +inline int32_t Kdtree_ViewportSignXYFunc(const ViewportSignKdtreeItem &item, int dim) { return (dim == 0) ? item.center : item.top; } -typedef Kdtree ViewportSignKdtree; +typedef Kdtree ViewportSignKdtree; extern ViewportSignKdtree _viewport_sign_kdtree; void RebuildViewportKdtree(); diff --git a/src/viewport_sprite_sorter.h b/src/viewport_sprite_sorter.h index 0528fc39a9..e277ff3708 100644 --- a/src/viewport_sprite_sorter.h +++ b/src/viewport_sprite_sorter.h @@ -16,26 +16,26 @@ /** Parent sprite that should be drawn */ struct ParentSpriteToDraw { /* Block of 16B loadable in xmm register */ - int32 xmin; ///< minimal world X coordinate of bounding box - int32 ymin; ///< minimal world Y coordinate of bounding box - int32 zmin; ///< minimal world Z coordinate of bounding box - int32 x; ///< screen X coordinate of sprite + int32_t xmin; ///< minimal world X coordinate of bounding box + int32_t ymin; ///< minimal world Y coordinate of bounding box + int32_t zmin; ///< minimal world Z coordinate of bounding box + int32_t x; ///< screen X coordinate of sprite /* Second block of 16B loadable in xmm register */ - int32 xmax; ///< maximal world X coordinate of bounding box - int32 ymax; ///< maximal world Y coordinate of bounding box - int32 zmax; ///< maximal world Z coordinate of bounding box - int32 y; ///< screen Y coordinate of sprite + int32_t xmax; ///< maximal world X coordinate of bounding box + int32_t ymax; ///< maximal world Y coordinate of bounding box + int32_t zmax; ///< maximal world Z coordinate of bounding box + int32_t y; ///< screen Y coordinate of sprite SpriteID image; ///< sprite to draw PaletteID pal; ///< palette to use const SubSprite *sub; ///< only draw a rectangular part of the sprite - int32 left; ///< minimal screen X coordinate of sprite (= x + sprite->x_offs), reference point for child sprites - int32 top; ///< minimal screen Y coordinate of sprite (= y + sprite->y_offs), reference point for child sprites + int32_t left; ///< minimal screen X coordinate of sprite (= x + sprite->x_offs), reference point for child sprites + int32_t top; ///< minimal screen Y coordinate of sprite (= y + sprite->y_offs), reference point for child sprites - int32 first_child; ///< the first child to draw. - uint32 order; ///< Used during sprite sorting + int32_t first_child; ///< the first child to draw. + uint32_t order; ///< Used during sprite sorting }; typedef std::vector ParentSpriteToSortVector; diff --git a/src/viewport_sprite_sorter_sse4.cpp b/src/viewport_sprite_sorter_sse4.cpp index 899dc37568..3c868d2a09 100644 --- a/src/viewport_sprite_sorter_sse4.cpp +++ b/src/viewport_sprite_sorter_sse4.cpp @@ -39,12 +39,12 @@ void ViewportSortParentSpritesSSE41(ParentSpriteToSortVector *psdv) * Also use special constants to indicate sorting state without * adding extra fields to ParentSpriteToDraw structure. */ - const uint32 ORDER_COMPARED = UINT32_MAX; // Sprite was compared but we still need to compare the ones preceding it - const uint32 ORDER_RETURNED = UINT32_MAX - 1; // Mark sorted sprite in case there are other occurrences of it in the stack + const uint32_t ORDER_COMPARED = UINT32_MAX; // Sprite was compared but we still need to compare the ones preceding it + const uint32_t ORDER_RETURNED = UINT32_MAX - 1; // Mark sorted sprite in case there are other occurrences of it in the stack std::stack sprite_order; - uint32 next_order = 0; + uint32_t next_order = 0; - std::forward_list> sprite_list; // We store sprites in a list sorted by xmin+ymin + std::forward_list> sprite_list; // We store sprites in a list sorted by xmin+ymin /* Initialize sprite list and order. */ for (auto p = psdv->rbegin(); p != psdv->rend(); p++) { diff --git a/src/viewport_type.h b/src/viewport_type.h index dc610d1686..234edadc7c 100644 --- a/src/viewport_type.h +++ b/src/viewport_type.h @@ -36,10 +36,10 @@ struct Viewport { /** Location information about a sign as seen on the viewport */ struct ViewportSign { - int32 center; ///< The center position of the sign - int32 top; ///< The top of the sign - uint16 width_normal; ///< The width when not zoomed out (normal font) - uint16 width_small; ///< The width when zoomed out (small font) + int32_t center; ///< The center position of the sign + int32_t top; ///< The top of the sign + uint16_t width_normal; ///< The width when not zoomed out (normal font) + uint16_t width_small; ///< The width when zoomed out (small font) void UpdatePosition(int center, int top, StringID str, StringID str_small = STR_NULL); void MarkDirty(ZoomLevel maxzoom = ZOOM_LVL_MAX) const; diff --git a/src/water.h b/src/water.h index 379c13ef72..cd2db3c926 100644 --- a/src/water.h +++ b/src/water.h @@ -49,7 +49,7 @@ bool IsWateredTile(TileIndex tile, Direction from); * @param num Number of canal tiles. * @return Total cost. */ -static inline Money CanalMaintenanceCost(uint32 num) +static inline Money CanalMaintenanceCost(uint32_t num) { return (_price[PR_INFRASTRUCTURE_WATER] * num * (1 + IntSqrt(num))) >> 6; // 6 bits scaling. } diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 2004f26d53..41159d4e36 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -47,7 +47,7 @@ /** * Describes from which directions a specific slope can be flooded (if the tile is floodable at all). */ -static const uint8 _flood_from_dirs[] = { +static const uint8_t _flood_from_dirs[] = { (1 << DIR_NW) | (1 << DIR_SW) | (1 << DIR_SE) | (1 << DIR_NE), // SLOPE_FLAT (1 << DIR_NE) | (1 << DIR_SE), // SLOPE_W (1 << DIR_NW) | (1 << DIR_NE), // SLOPE_S @@ -829,7 +829,7 @@ static void DrawWaterLock(const TileInfo *ti) if (base == 0) { /* If no custom graphics, use defaults. */ base = SPR_LOCK_BASE; - uint8 z_threshold = part == LOCK_PART_UPPER ? 8 : 0; + uint8_t z_threshold = part == LOCK_PART_UPPER ? 8 : 0; zoffs = ti->z > z_threshold ? 24 : 0; } diff --git a/src/water_map.h b/src/water_map.h index 9a0779b908..ec6be4c68f 100644 --- a/src/water_map.h +++ b/src/water_map.h @@ -402,7 +402,7 @@ static inline void MakeShore(Tile t) * @param wc The class of water the tile has to be * @param random_bits Eventual random bits to be set for this tile */ -static inline void MakeWater(Tile t, Owner o, WaterClass wc, uint8 random_bits) +static inline void MakeWater(Tile t, Owner o, WaterClass wc, uint8_t random_bits) { SetTileType(t, MP_WATER); SetTileOwner(t, o); @@ -430,7 +430,7 @@ static inline void MakeSea(Tile t) * @param t The tile to change into river * @param random_bits Random bits to be set for this tile */ -static inline void MakeRiver(Tile t, uint8 random_bits) +static inline void MakeRiver(Tile t, uint8_t random_bits) { MakeWater(t, OWNER_WATER, WATER_CLASS_RIVER, random_bits); } @@ -441,7 +441,7 @@ static inline void MakeRiver(Tile t, uint8 random_bits) * @param o The owner of the canal * @param random_bits Random bits to be set for this tile */ -static inline void MakeCanal(Tile t, Owner o, uint8 random_bits) +static inline void MakeCanal(Tile t, Owner o, uint8_t random_bits) { assert(o != OWNER_WATER); MakeWater(t, o, WATER_CLASS_CANAL, random_bits); diff --git a/src/waypoint_base.h b/src/waypoint_base.h index 2c7cc530f6..9abd77ae77 100644 --- a/src/waypoint_base.h +++ b/src/waypoint_base.h @@ -14,7 +14,7 @@ /** Representation of a waypoint. */ struct Waypoint FINAL : SpecializedStation { - uint16 town_cn; ///< The N-1th waypoint for this town (consecutive number) + uint16_t town_cn; ///< The N-1th waypoint for this town (consecutive number) /** * Create a waypoint at the given tile. @@ -32,7 +32,7 @@ struct Waypoint FINAL : SpecializedStation { return IsRailWaypointTile(tile) && GetStationIndex(tile) == this->index; } - uint32 GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const override; + uint32_t GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const override; void GetTileArea(TileArea *ta, StationType type) const override; diff --git a/src/widget.cpp b/src/widget.cpp index fa4094ccd2..5dafacd7a2 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -168,7 +168,7 @@ WidgetDimensions WidgetDimensions::scaled = {}; */ static inline RectPadding ScaleGUITrad(const RectPadding &r) { - return {(uint8)ScaleGUITrad(r.left), (uint8)ScaleGUITrad(r.top), (uint8)ScaleGUITrad(r.right), (uint8)ScaleGUITrad(r.bottom)}; + return {(uint8_t)ScaleGUITrad(r.left), (uint8_t)ScaleGUITrad(r.top), (uint8_t)ScaleGUITrad(r.right), (uint8_t)ScaleGUITrad(r.bottom)}; } /** @@ -537,7 +537,7 @@ static inline void DrawInset(const Rect &r, Colours colour, TextColour text_colo * @param resize_x Matrix resize unit size. * @param resize_y Matrix resize unit size. */ -static inline void DrawMatrix(const Rect &r, Colours colour, bool clicked, uint16 data, uint resize_x, uint resize_y) +static inline void DrawMatrix(const Rect &r, Colours colour, bool clicked, uint16_t data, uint resize_x, uint resize_y) { DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FR_LOWERED : FR_NONE); @@ -615,8 +615,8 @@ static inline void DrawVerticalScrollbar(const Rect &r, Colours colour, bool up_ /* track positions. These fractions are based on original 1x dimensions, but scale better. */ int left = r.left + r.Width() * 3 / 11; /* left track is positioned 3/11ths from the left */ int right = r.left + r.Width() * 8 / 11; /* right track is positioned 8/11ths from the left */ - const uint8 bl = WidgetDimensions::scaled.bevel.left; - const uint8 br = WidgetDimensions::scaled.bevel.right; + const uint8_t bl = WidgetDimensions::scaled.bevel.left; + const uint8_t br = WidgetDimensions::scaled.bevel.right; /* draw shaded lines */ GfxFillRect(left - bl, r.top + height, left - 1, r.bottom - height, c1); @@ -654,8 +654,8 @@ static inline void DrawHorizontalScrollbar(const Rect &r, Colours colour, bool l /* track positions. These fractions are based on original 1x dimensions, but scale better. */ int top = r.top + r.Height() * 3 / 11; /* top track is positioned 3/11ths from the top */ int bottom = r.top + r.Height() * 8 / 11; /* bottom track is positioned 8/11ths from the top */ - const uint8 bt = WidgetDimensions::scaled.bevel.top; - const uint8 bb = WidgetDimensions::scaled.bevel.bottom; + const uint8_t bt = WidgetDimensions::scaled.bevel.top; + const uint8_t bb = WidgetDimensions::scaled.bevel.bottom; /* draw shaded lines */ GfxFillRect(r.left + width, top - bt, r.right - width, top - 1, c1); @@ -1109,7 +1109,7 @@ void NWidgetResizeBase::SetMinimalSizeAbsolute(uint min_x, uint min_y) * @param spacing Extra unscaled spacing (eg WidgetDimensions::unscaled.framerect.Vertical()) of the widget. * @param size Font size of text. */ -void NWidgetResizeBase::SetMinimalTextLines(uint8 min_lines, uint8 spacing, FontSize size) +void NWidgetResizeBase::SetMinimalTextLines(uint8_t min_lines, uint8_t spacing, FontSize size) { this->uz_text_lines = min_lines; this->uz_text_spacing = spacing; @@ -1165,7 +1165,7 @@ void NWidgetResizeBase::AssignSizePosition(SizingType sizing, uint x, uint y, ui * @param widget_data Data component of the widget. @see Widget::data * @param tool_tip Tool tip of the widget. @see Widget::tooltips */ -NWidgetCore::NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint32 widget_data, StringID tool_tip) : NWidgetResizeBase(tp, fill_x, fill_y) +NWidgetCore::NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint32_t widget_data, StringID tool_tip) : NWidgetResizeBase(tp, fill_x, fill_y) { this->colour = colour; this->index = -1; @@ -1192,7 +1192,7 @@ void NWidgetCore::SetIndex(int index) * @param widget_data Data to use. * @param tool_tip Tool tip string to use. */ -void NWidgetCore::SetDataTip(uint32 widget_data, StringID tool_tip) +void NWidgetCore::SetDataTip(uint32_t widget_data, StringID tool_tip) { this->widget_data = widget_data; this->tool_tip = tool_tip; @@ -1454,7 +1454,7 @@ void NWidgetPIPContainer::AdjustPaddingForZoom() * @param pip_post Additional space after the last child widget (below for the * vertical container, at the right for the horizontal container). */ -void NWidgetPIPContainer::SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post) +void NWidgetPIPContainer::SetPIP(uint8_t pip_pre, uint8_t pip_inter, uint8_t pip_post) { this->uz_pip_pre = pip_pre; this->uz_pip_inter = pip_inter; @@ -2141,7 +2141,7 @@ void NWidgetBackground::Add(NWidgetBase *nwid) * vertical container, at the right for the horizontal container). * @note Using this function implies that the widget has (or will have) child widgets. */ -void NWidgetBackground::SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post) +void NWidgetBackground::SetPIP(uint8_t pip_pre, uint8_t pip_inter, uint8_t pip_post) { if (this->child == nullptr) { this->child = new NWidgetVertical(); @@ -2177,7 +2177,7 @@ void NWidgetBackground::SetupSmallestSize(Window *w, bool init_array) if (this->type == WWT_FRAME) { /* Account for the size of the frame's text if that exists */ this->child->padding = WidgetDimensions::scaled.frametext; - this->child->padding.top = std::max(WidgetDimensions::scaled.frametext.top, this->widget_data != STR_NULL ? FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.frametext.top / 2 : 0); + this->child->padding.top = std::max(WidgetDimensions::scaled.frametext.top, this->widget_data != STR_NULL ? FONT_HEIGHT_NORMAL + WidgetDimensions::scaled.frametext.top / 2 : 0); this->smallest_x += this->child->padding.Horizontal(); this->smallest_y += this->child->padding.Vertical(); @@ -2336,7 +2336,7 @@ void NWidgetViewport::Draw(const Window *w) * @param follow_flags Type of viewport, see #InitializeWindowViewport(). * @param zoom Zoom level. */ -void NWidgetViewport::InitializeViewport(Window *w, uint32 follow_flags, ZoomLevel zoom) +void NWidgetViewport::InitializeViewport(Window *w, uint32_t follow_flags, ZoomLevel zoom) { InitializeWindowViewport(w, this->pos_x, this->pos_y, this->current_x, this->current_y, follow_flags, zoom); } @@ -2389,7 +2389,7 @@ int Scrollbar::GetScrolledRowFromWidget(int clickpos, const Window * const w, in * @param key_code The pressed key code. * @return ES_NOT_HANDLED when another key than the 6 specific keys was pressed, otherwise ES_HANDLED. */ -EventState Scrollbar::UpdateListPositionOnKeyPress(int &list_position, uint16 keycode) const +EventState Scrollbar::UpdateListPositionOnKeyPress(int &list_position, uint16_t keycode) const { int new_pos = list_position; switch (keycode) { @@ -2586,7 +2586,7 @@ Dimension NWidgetLeaf::dropdown_dimension = {0, 0}; * @param data Data of the widget. * @param tip Tooltip of the widget. */ -NWidgetLeaf::NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data, StringID tip) : NWidgetCore(tp, colour, 1, 1, data, tip) +NWidgetLeaf::NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32_t data, StringID tip) : NWidgetCore(tp, colour, 1, 1, data, tip) { assert(index >= 0 || tp == WWT_LABEL || tp == WWT_TEXT || tp == WWT_CAPTION || tp == WWT_RESIZEBOX || tp == WWT_SHADEBOX || tp == WWT_DEFSIZEBOX || tp == WWT_DEBUGBOX || tp == WWT_STICKYBOX || tp == WWT_CLOSEBOX); if (index >= 0) this->SetIndex(index); diff --git a/src/widget_type.h b/src/widget_type.h index 974fd4d852..96776c1af1 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -147,7 +147,7 @@ public: * @param bottom Amount of additional space below the widget. * @param left Amount of additional space left of the widget. */ - inline void SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left) + inline void SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left) { this->uz_padding.top = top; this->uz_padding.right = right; @@ -259,7 +259,7 @@ public: void AdjustPaddingForZoom() override; void SetMinimalSize(uint min_x, uint min_y); void SetMinimalSizeAbsolute(uint min_x, uint min_y); - void SetMinimalTextLines(uint8 min_lines, uint8 spacing, FontSize size); + void SetMinimalTextLines(uint8_t min_lines, uint8_t spacing, FontSize size); void SetFill(uint fill_x, uint fill_y); void SetResize(uint resize_x, uint resize_y); @@ -274,8 +274,8 @@ public: uint uz_min_x; ///< Unscaled Minimal horizontal size of only this widget. uint uz_min_y; ///< Unscaled Minimal vertical size of only this widget. - uint8 uz_text_lines; ///< 'Unscaled' text lines, stored for resize calculation. - uint8 uz_text_spacing; ///< 'Unscaled' text padding, stored for resize calculation. + uint8_t uz_text_lines; ///< 'Unscaled' text lines, stored for resize calculation. + uint8_t uz_text_spacing; ///< 'Unscaled' text padding, stored for resize calculation. FontSize uz_text_size; ///< 'Unscaled' font size, stored for resize calculation. }; @@ -317,10 +317,10 @@ DECLARE_ENUM_AS_BIT_SET(NWidgetDisplay) */ class NWidgetCore : public NWidgetResizeBase { public: - NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint32 widget_data, StringID tool_tip); + NWidgetCore(WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint32_t widget_data, StringID tool_tip); void SetIndex(int index); - void SetDataTip(uint32 widget_data, StringID tool_tip); + void SetDataTip(uint32_t widget_data, StringID tool_tip); void SetToolTip(StringID tool_tip); void SetTextStyle(TextColour colour, FontSize size); void SetAlignment(StringAlignment align); @@ -339,7 +339,7 @@ public: NWidgetDisplay disp_flags; ///< Flags that affect display and interaction with the widget. Colours colour; ///< Colour of this widget. int index; ///< Index of the nested widget in the widget array of the window (\c -1 means 'not used'). - uint32 widget_data; ///< Data of the widget. @see Widget::data + uint32_t widget_data; ///< Data of the widget. @see Widget::data StringID tool_tip; ///< Tooltip of the widget. @see Widget::tootips int scrollbar_index; ///< Index of an attached scrollbar. TextColour highlight_colour; ///< Colour of highlight. @@ -480,20 +480,20 @@ public: NWidgetPIPContainer(WidgetType tp, NWidContainerFlags flags = NC_NONE); void AdjustPaddingForZoom() override; - void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post); + void SetPIP(uint8_t pip_pre, uint8_t pip_inter, uint8_t pip_post); void Draw(const Window *w) override; NWidgetCore *GetWidgetFromPos(int x, int y) override; protected: NWidContainerFlags flags; ///< Flags of the container. - uint8 pip_pre; ///< Amount of space before first widget. - uint8 pip_inter; ///< Amount of space between widgets. - uint8 pip_post; ///< Amount of space after last widget. + uint8_t pip_pre; ///< Amount of space before first widget. + uint8_t pip_inter; ///< Amount of space between widgets. + uint8_t pip_post; ///< Amount of space after last widget. - uint8 uz_pip_pre; ///< Unscaled space before first widget. - uint8 uz_pip_inter; ///< Unscaled space between widgets. - uint8 uz_pip_post; ///< Unscaled space after last widget. + uint8_t uz_pip_pre; ///< Unscaled space before first widget. + uint8_t uz_pip_inter; ///< Unscaled space between widgets. + uint8_t uz_pip_post; ///< Unscaled space after last widget. }; /** @@ -597,7 +597,7 @@ public: ~NWidgetBackground(); void Add(NWidgetBase *nwid); - void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post); + void SetPIP(uint8_t pip_pre, uint8_t pip_inter, uint8_t pip_post); void AdjustPaddingForZoom() override; void SetupSmallestSize(Window *w, bool init_array) override; @@ -629,7 +629,7 @@ public: void SetupSmallestSize(Window *w, bool init_array) override; void Draw(const Window *w) override; - void InitializeViewport(Window *w, uint32 follow_flags, ZoomLevel zoom); + void InitializeViewport(Window *w, uint32_t follow_flags, ZoomLevel zoom); void UpdateViewportCoordinates(Window *w); }; @@ -639,10 +639,10 @@ public: class Scrollbar { private: const bool is_vertical; ///< Scrollbar has vertical orientation. - uint16 count; ///< Number of elements in the list. - uint16 cap; ///< Number of visible elements of the scroll bar. - uint16 pos; ///< Index of first visible item of the list. - uint16 stepsize; ///< Distance to scroll, when pressing the buttons or using the wheel. + uint16_t count; ///< Number of elements in the list. + uint16_t cap; ///< Number of visible elements of the scroll bar. + uint16_t pos; ///< Index of first visible item of the list. + uint16_t stepsize; ///< Distance to scroll, when pressing the buttons or using the wheel. public: /** Stepping sizes when scrolling */ @@ -660,7 +660,7 @@ public: * Gets the number of elements in the list * @return the number of elements */ - inline uint16 GetCount() const + inline uint16_t GetCount() const { return this->count; } @@ -669,7 +669,7 @@ public: * Gets the number of visible elements of the scrollbar * @return the number of visible elements */ - inline uint16 GetCapacity() const + inline uint16_t GetCapacity() const { return this->cap; } @@ -678,7 +678,7 @@ public: * Gets the position of the first visible element in the list * @return the position of the element */ - inline uint16 GetPosition() const + inline uint16_t GetPosition() const { return this->pos; } @@ -688,7 +688,7 @@ public: * @param item to check * @return true iff the item is visible */ - inline bool IsVisible(uint16 item) const + inline bool IsVisible(uint16_t item) const { return IsInsideBS(item, this->GetPosition(), this->GetCapacity()); } @@ -720,7 +720,7 @@ public: */ void SetCount(size_t num) { - assert(num <= MAX_UVALUE(uint16)); + assert(num <= MAX_UVALUE(uint16_t)); this->count = ClampTo(num); /* Ensure position is within bounds */ @@ -734,7 +734,7 @@ public: */ void SetCapacity(size_t capacity) { - assert(capacity <= MAX_UVALUE(uint16)); + assert(capacity <= MAX_UVALUE(uint16_t)); this->cap = ClampTo(capacity); /* Ensure position is within bounds */ @@ -750,7 +750,7 @@ public: */ bool SetPosition(int position) { - uint16 old_pos = this->pos; + uint16_t old_pos = this->pos; this->pos = Clamp(position, 0, std::max(this->count - this->cap, 0)); return this->pos != old_pos; } @@ -814,7 +814,7 @@ public: return it; } - EventState UpdateListPositionOnKeyPress(int &list_position, uint16 keycode) const; + EventState UpdateListPositionOnKeyPress(int &list_position, uint16_t keycode) const; }; /** @@ -844,7 +844,7 @@ private: */ class NWidgetLeaf : public NWidgetCore { public: - NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data, StringID tip); + NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32_t data, StringID tip); void SetupSmallestSize(Window *w, bool init_array) override; void Draw(const Window *w) override; @@ -883,7 +883,7 @@ static inline uint ComputeMaxSize(uint base, uint max_space, uint step) * @defgroup NestedWidgetParts Hierarchical widget parts * To make nested widgets easier to enter, nested widget parts have been created. They allow the tree to be defined in a flat array of parts. * - * - Leaf widgets start with a #NWidget(WidgetType tp, Colours col, int16 idx) part. + * - Leaf widgets start with a #NWidget(WidgetType tp, Colours col, int16_t idx) part. * Next, specify its properties with one or more of * - #SetMinimalSize Define the minimal size of the widget. * - #SetFill Define how the widget may grow to make it nicely. @@ -914,7 +914,7 @@ static inline uint ComputeMaxSize(uint base, uint max_space, uint step) * so the widget does not support #SetPIP. #SetPadding is allowed though. * Like the other container widgets, below the last child widgets, a #EndContainer part should be used to denote the end of the stacked widget. * - * - Background widgets #NWidgetBackground start with a #NWidget(WidgetType tp, Colours col, int16 idx) part. + * - Background widgets #NWidgetBackground start with a #NWidget(WidgetType tp, Colours col, int16_t idx) part. * What follows depends on how the widget is used. * - If the widget is used as a leaf widget, that is, to create some space in the window to display a viewport or some text, use the properties of the * leaf widgets to define how it behaves. @@ -931,7 +931,7 @@ static inline uint ComputeMaxSize(uint base, uint max_space, uint step) * @ingroup NestedWidgetParts */ struct NWidgetPartDataTip { - uint32 data; ///< Data value of the widget. + uint32_t data; ///< Data value of the widget. StringID tooltip; ///< Tooltip of the widget. }; @@ -941,7 +941,7 @@ struct NWidgetPartDataTip { */ struct NWidgetPartWidget { Colours colour; ///< Widget colour. - int16 index; ///< Widget index in the widget array. + int16_t index; ///< Widget index in the widget array. }; /** @@ -956,7 +956,7 @@ struct NWidgetPartPaddings : RectPadding { * @ingroup NestedWidgetParts */ struct NWidgetPartPIP { - uint8 pre, inter, post; ///< Amount of space before/between/after child widgets. + uint8_t pre, inter, post; ///< Amount of space before/between/after child widgets. }; /** @@ -964,8 +964,8 @@ struct NWidgetPartPIP { * @ingroup NestedWidgetParts */ struct NWidgetPartTextLines { - uint8 lines; ///< Number of text lines. - uint8 spacing; ///< Extra spacing around lines. + uint8_t lines; ///< Number of text lines. + uint8_t spacing; ///< Extra spacing around lines. FontSize size; ///< Font size of text lines. }; @@ -1020,7 +1020,7 @@ struct NWidgetPart { * @param dy Vertical resize step. 0 means no vertical resizing. * @ingroup NestedWidgetParts */ -static inline NWidgetPart SetResize(int16 dx, int16 dy) +static inline NWidgetPart SetResize(int16_t dx, int16_t dy) { NWidgetPart part; @@ -1037,7 +1037,7 @@ static inline NWidgetPart SetResize(int16 dx, int16 dy) * @param y Vertical minimal size. * @ingroup NestedWidgetParts */ -static inline NWidgetPart SetMinimalSize(int16 x, int16 y) +static inline NWidgetPart SetMinimalSize(int16_t x, int16_t y) { NWidgetPart part; @@ -1055,7 +1055,7 @@ static inline NWidgetPart SetMinimalSize(int16 x, int16 y) * @param size Font size of text. * @ingroup NestedWidgetParts */ -static inline NWidgetPart SetMinimalTextLines(uint8 lines, uint8 spacing, FontSize size = FS_NORMAL) +static inline NWidgetPart SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize size = FS_NORMAL) { NWidgetPart part; @@ -1136,7 +1136,7 @@ static inline NWidgetPart EndContainer() * @param tip Tooltip of the widget. * @ingroup NestedWidgetParts */ -static inline NWidgetPart SetDataTip(uint32 data, StringID tip) +static inline NWidgetPart SetDataTip(uint32_t data, StringID tip) { NWidgetPart part; @@ -1154,7 +1154,7 @@ static inline NWidgetPart SetDataTip(uint32 data, StringID tip) * @param tip Tooltip of the widget. * @ingroup NestedWidgetParts */ -static inline NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip) +static inline NWidgetPart SetMatrixDataTip(uint8_t cols, uint8_t rows, StringID tip) { return SetDataTip((rows << MAT_ROW_START) | (cols << MAT_COL_START), tip); } @@ -1168,7 +1168,7 @@ static inline NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip) * @param left The padding left of the widget. * @ingroup NestedWidgetParts */ -static inline NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left) +static inline NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left) { NWidgetPart part; @@ -1204,7 +1204,7 @@ static inline NWidgetPart SetPadding(const RectPadding &padding) * @param padding The padding to use for all directions. * @ingroup NestedWidgetParts */ -static inline NWidgetPart SetPadding(uint8 padding) +static inline NWidgetPart SetPadding(uint8_t padding) { return SetPadding(padding, padding, padding, padding); } @@ -1216,7 +1216,7 @@ static inline NWidgetPart SetPadding(uint8 padding) * @param post The amount of space after the last widget. * @ingroup NestedWidgetParts */ -static inline NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post) +static inline NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post) { NWidgetPart part; @@ -1254,7 +1254,7 @@ static inline NWidgetPart SetScrollbar(int index) * Child widgets must have a index bigger than the parent index. * @ingroup NestedWidgetParts */ -static inline NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx = -1) +static inline NWidgetPart NWidget(WidgetType tp, Colours col, int16_t idx = -1) { NWidgetPart part; diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 1709d840f3..d43e3f995f 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -197,7 +197,7 @@ struct DropdownWindow : Window { } } - Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override + Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override { return this->position; } @@ -458,7 +458,7 @@ void ShowDropDownList(Window *w, DropDownList &&list, int selected, int button, * @param hidden_mask Bitmask for hidden items (items with their bit set are not copied to the dropdown list). * @param width Minimum width of the dropdown menu. */ -void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width) +void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32_t disabled_mask, uint32_t hidden_mask, uint width) { DropDownList list; diff --git a/src/widgets/dropdown_func.h b/src/widgets/dropdown_func.h index 1a0102c17b..88b0053c9d 100644 --- a/src/widgets/dropdown_func.h +++ b/src/widgets/dropdown_func.h @@ -13,6 +13,6 @@ #include "../window_gui.h" /* Show drop down menu containing a fixed list of strings */ -void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width = 0); +void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32_t disabled_mask, uint32_t hidden_mask, uint width = 0); #endif /* WIDGETS_DROPDOWN_FUNC_H */ diff --git a/src/window.cpp b/src/window.cpp index 870371c9ba..831224e187 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -102,9 +102,9 @@ static std::vector *_window_descs = nullptr; std::string _windows_file; /** Window description constructor. */ -WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16 def_width_trad, int16 def_height_trad, - WindowClass window_class, WindowClass parent_class, uint32 flags, - const NWidgetPart *nwid_parts, int16 nwid_length, HotkeyList *hotkeys) : +WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16_t def_width_trad, int16_t def_height_trad, + WindowClass window_class, WindowClass parent_class, uint32_t flags, + const NWidgetPart *nwid_parts, int16_t nwid_length, HotkeyList *hotkeys) : default_pos(def_pos), cls(window_class), parent_cls(parent_class), @@ -133,7 +133,7 @@ WindowDesc::~WindowDesc() * This is either a stored user preferred size, or the built-in default. * @return Width in pixels. */ -int16 WindowDesc::GetDefaultWidth() const +int16_t WindowDesc::GetDefaultWidth() const { return this->pref_width != 0 ? this->pref_width : ScaleGUITrad(this->default_width_trad); } @@ -143,7 +143,7 @@ int16 WindowDesc::GetDefaultWidth() const * This is either a stored user preferred size, or the built-in default. * @return Height in pixels. */ -int16 WindowDesc::GetDefaultHeight() const +int16_t WindowDesc::GetDefaultHeight() const { return this->pref_height != 0 ? this->pref_height : ScaleGUITrad(this->default_height_trad); } @@ -752,8 +752,8 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count) w->window_desc->pref_width = w->width; w->window_desc->pref_height = w->height; } else { - int16 def_width = std::max(std::min(w->window_desc->GetDefaultWidth(), _screen.width), w->nested_root->smallest_x); - int16 def_height = std::max(std::min(w->window_desc->GetDefaultHeight(), _screen.height - 50), w->nested_root->smallest_y); + int16_t def_width = std::max(std::min(w->window_desc->GetDefaultWidth(), _screen.width), w->nested_root->smallest_x); + int16_t def_height = std::max(std::min(w->window_desc->GetDefaultHeight(), _screen.height - 50), w->nested_root->smallest_y); int dx = (w->resize.step_width == 0) ? 0 : def_width - w->width; int dy = (w->resize.step_height == 0) ? 0 : def_height - w->height; @@ -1721,13 +1721,13 @@ Point GetToolbarAlignedWindowPosition(int window_width) * * @return Coordinate of the top-left corner of the new window. */ -static Point LocalGetWindowPlacement(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number) +static Point LocalGetWindowPlacement(const WindowDesc *desc, int16_t sm_width, int16_t sm_height, int window_number) { Point pt; const Window *w; - int16 default_width = std::max(desc->GetDefaultWidth(), sm_width); - int16 default_height = std::max(desc->GetDefaultHeight(), sm_height); + int16_t default_width = std::max(desc->GetDefaultWidth(), sm_width); + int16_t default_height = std::max(desc->GetDefaultHeight(), sm_height); if (desc->parent_cls != WC_NONE && (w = FindWindowById(desc->parent_cls, window_number)) != nullptr) { bool rtl = _current_text_dir == TD_RTL; @@ -1780,7 +1780,7 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int16 sm_width, int return pt; } -/* virtual */ Point Window::OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) +/* virtual */ Point Window::OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) { return LocalGetWindowPlacement(this->window_desc, sm_width, sm_height, window_number); } @@ -2545,7 +2545,7 @@ static bool MaybeBringWindowToFront(Window *w) * @return #ES_HANDLED if the key press has been handled and no other * window should receive the event. */ -EventState Window::HandleEditBoxKey(int wid, WChar key, uint16 keycode) +EventState Window::HandleEditBoxKey(int wid, char32_t key, uint16_t keycode) { QueryString *query = this->GetQueryString(wid); if (query == nullptr) return ES_NOT_HANDLED; @@ -2634,7 +2634,7 @@ void HandleToolbarHotkey(int hotkey) * @param keycode Virtual keycode of the key. * @param key Unicode character of the key. */ -void HandleKeypress(uint keycode, WChar key) +void HandleKeypress(uint keycode, char32_t key) { /* World generation is multithreaded and messes with companies. * But there is no company related window open anyway, so _current_company is not used. */ @@ -2803,7 +2803,7 @@ static void ScrollMainViewport(int x, int y) * 4 = right * 8 = down */ -static const int8 scrollamt[16][2] = { +static const int8_t scrollamt[16][2] = { { 0, 0}, ///< no key specified {-2, 0}, ///< 1 : left { 0, -2}, ///< 2 : up diff --git a/src/window_gui.h b/src/window_gui.h index 8bbfb6ede2..a639362ecd 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -95,9 +95,9 @@ struct HotkeyList; */ struct WindowDesc : ZeroedMemoryAllocator { - WindowDesc(WindowPosition default_pos, const char *ini_key, int16 def_width_trad, int16 def_height_trad, - WindowClass window_class, WindowClass parent_class, uint32 flags, - const NWidgetPart *nwid_parts, int16 nwid_length, HotkeyList *hotkeys = nullptr); + WindowDesc(WindowPosition default_pos, const char *ini_key, int16_t def_width_trad, int16_t def_height_trad, + WindowClass window_class, WindowClass parent_class, uint32_t flags, + const NWidgetPart *nwid_parts, int16_t nwid_length, HotkeyList *hotkeys = nullptr); ~WindowDesc(); @@ -105,24 +105,24 @@ struct WindowDesc : ZeroedMemoryAllocator { WindowClass cls; ///< Class of the window, @see WindowClass. WindowClass parent_cls; ///< Class of the parent window. @see WindowClass const char *ini_key; ///< Key to store window defaults in openttd.cfg. \c nullptr if nothing shall be stored. - uint32 flags; ///< Flags. @see WindowDefaultFlag + uint32_t flags; ///< Flags. @see WindowDefaultFlag const NWidgetPart *nwid_parts; ///< Nested widget parts describing the window. - int16 nwid_length; ///< Length of the #nwid_parts array. + int16_t nwid_length; ///< Length of the #nwid_parts array. HotkeyList *hotkeys; ///< Hotkeys for the window. bool pref_sticky; ///< Preferred stickyness. - int16 pref_width; ///< User-preferred width of the window. Zero if unset. - int16 pref_height; ///< User-preferred height of the window. Zero if unset. + int16_t pref_width; ///< User-preferred width of the window. Zero if unset. + int16_t pref_height; ///< User-preferred height of the window. Zero if unset. - int16 GetDefaultWidth() const; - int16 GetDefaultHeight() const; + int16_t GetDefaultWidth() const; + int16_t GetDefaultHeight() const; static void LoadFromConfig(); static void SaveToConfig(); private: - int16 default_width_trad; ///< Preferred initial width of the window (pixels at 1x zoom). - int16 default_height_trad; ///< Preferred initial height of the window (pixels at 1x zoom). + int16_t default_width_trad; ///< Preferred initial width of the window (pixels at 1x zoom). + int16_t default_height_trad; ///< Preferred initial height of the window (pixels at 1x zoom). /** * Dummy private copy constructor to prevent compilers from @@ -186,10 +186,10 @@ static const int WHITE_BORDER_DURATION = 3; ///< The initial timeout value for W */ struct ViewportData : Viewport { VehicleID follow_vehicle; ///< VehicleID to follow if following a vehicle, #INVALID_VEHICLE otherwise. - int32 scrollpos_x; ///< Currently shown x coordinate (virtual screen coordinate of topleft corner of the viewport). - int32 scrollpos_y; ///< Currently shown y coordinate (virtual screen coordinate of topleft corner of the viewport). - int32 dest_scrollpos_x; ///< Current destination x coordinate to display (virtual screen coordinate of topleft corner of the viewport). - int32 dest_scrollpos_y; ///< Current destination y coordinate to display (virtual screen coordinate of topleft corner of the viewport). + int32_t scrollpos_x; ///< Currently shown x coordinate (virtual screen coordinate of topleft corner of the viewport). + int32_t scrollpos_y; ///< Currently shown y coordinate (virtual screen coordinate of topleft corner of the viewport). + int32_t dest_scrollpos_x; ///< Current destination x coordinate to display (virtual screen coordinate of topleft corner of the viewport). + int32_t dest_scrollpos_y; ///< Current destination y coordinate to display (virtual screen coordinate of topleft corner of the viewport). }; struct QueryString; @@ -235,8 +235,8 @@ public: WindowClass window_class; ///< Window class WindowNumber window_number; ///< Window number within the window class - uint8 timeout_timer; ///< Timer value of the WF_TIMEOUT for flags. - uint8 white_border_timer; ///< Timer value of the WF_WHITE_BORDER for flags. + uint8_t timeout_timer; ///< Timer value of the WF_TIMEOUT for flags. + uint8_t white_border_timer; ///< Timer value of the WF_WHITE_BORDER for flags. int left; ///< x position of left edge of the window int top; ///< y position of top edge of the window @@ -423,7 +423,7 @@ public: void UnfocusFocusedWidget(); bool SetFocusedWidget(int widget_index); - EventState HandleEditBoxKey(int wid, WChar key, uint16 keycode); + EventState HandleEditBoxKey(int wid, char32_t key, uint16_t keycode); virtual void InsertTextString(int wid, const char *str, bool marked, const char *caret, const char *insert_location, const char *replacement_end); void HandleButtonClick(byte widget); @@ -475,7 +475,7 @@ public: * @param window_number The window number of the new window. * @return Initial position of the top-left corner of the window. */ - virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number); + virtual Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number); /** * The window must be repainted. @@ -534,7 +534,7 @@ public: * @return #ES_HANDLED if the key press has been handled and no other * window should receive the event. */ - virtual EventState OnKeyPress(WChar key, uint16 keycode) { return ES_NOT_HANDLED; } + virtual EventState OnKeyPress(char32_t key, uint16_t keycode) { return ES_NOT_HANDLED; } virtual EventState OnHotkey(int hotkey); diff --git a/src/window_type.h b/src/window_type.h index e35814e9e5..422d373ef6 100644 --- a/src/window_type.h +++ b/src/window_type.h @@ -719,7 +719,7 @@ enum GameOptionsInvalidationData { struct Window; /** Number to differentiate different windows of the same class */ -typedef int32 WindowNumber; +typedef int32_t WindowNumber; /** State of handling an event. */ enum EventState {