From 97e6f3062e800afcff3ce3098e295059419052ae Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sun, 7 Jan 2024 16:41:53 +0000 Subject: [PATCH] Adding of _t to (u)int types, and WChar to char32_t See: eaae0bb5e --- 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/ai/ai_instance.cpp | 2 +- src/aircraft.h | 8 +- src/aircraft_cmd.cpp | 28 +- src/airport.cpp | 8 +- src/airport.h | 10 +- src/airport_gui.cpp | 6 +- src/animated_tile.cpp | 12 +- src/animated_tile.h | 2 +- src/articulated_vehicles.cpp | 8 +- src/autoreplace_base.h | 2 +- src/autoreplace_cmd.cpp | 6 +- src/autoreplace_gui.cpp | 2 +- src/base_consist.h | 18 +- src/base_media_base.h | 4 +- src/base_media_func.h | 2 +- src/base_station_base.h | 20 +- src/blitter/32bpp_anim.cpp | 116 +-- src/blitter/32bpp_anim.hpp | 20 +- src/blitter/32bpp_anim_sse2.cpp | 6 +- src/blitter/32bpp_anim_sse4.cpp | 48 +- src/blitter/32bpp_base.cpp | 66 +- src/blitter/32bpp_base.hpp | 26 +- src/blitter/32bpp_optimized.cpp | 56 +- src/blitter/32bpp_optimized.hpp | 4 +- src/blitter/32bpp_simple.cpp | 4 +- src/blitter/32bpp_simple.hpp | 12 +- src/blitter/32bpp_sse2.cpp | 16 +- src/blitter/32bpp_sse2.hpp | 12 +- src/blitter/32bpp_sse_func.hpp | 24 +- src/blitter/32bpp_sse_type.h | 10 +- src/blitter/40bpp_anim.cpp | 116 +-- src/blitter/40bpp_anim.hpp | 16 +- src/blitter/8bpp_base.cpp | 62 +- src/blitter/8bpp_base.hpp | 12 +- src/blitter/8bpp_optimized.cpp | 10 +- src/blitter/8bpp_optimized.hpp | 4 +- src/blitter/8bpp_simple.cpp | 8 +- src/blitter/base.hpp | 20 +- src/blitter/common.hpp | 20 +- src/blitter/null.hpp | 14 +- src/bmp.cpp | 10 +- src/bmp.h | 14 +- src/bridge.h | 6 +- src/bridge_gui.cpp | 18 +- src/bridge_map.cpp | 30 +- src/bridge_signal_map.h | 18 +- src/build_vehicle_gui.cpp | 40 +- src/cargo_type.h | 4 +- src/cargomonitor.cpp | 12 +- src/cargomonitor.h | 12 +- src/cargopacket.cpp | 14 +- src/cargopacket.h | 22 +- src/cargotype.cpp | 6 +- src/cargotype.h | 54 +- src/cheat_gui.cpp | 44 +- src/clear_cmd.cpp | 8 +- src/command.cpp | 44 +- src/command_aux.h | 10 +- src/command_func.h | 22 +- src/command_type.h | 42 +- src/company_base.h | 46 +- src/company_cmd.cpp | 42 +- src/company_gui.cpp | 26 +- src/company_manager_face.h | 2 +- src/company_type.h | 4 +- src/console.cpp | 2 +- src/console_cmds.cpp | 88 +-- src/console_gui.cpp | 8 +- src/console_internal.h | 2 +- src/core/bitmath_func.cpp | 16 +- src/core/bitmath_func.hpp | 44 +- src/core/checksum_func.hpp | 6 +- src/core/endian_func.hpp | 4 +- src/core/geometry_type.hpp | 16 +- src/core/hash_func.hpp | 2 +- src/core/math_func.cpp | 30 +- src/core/math_func.hpp | 10 +- src/core/overflowsafe_type.hpp | 34 +- src/core/pod_pool.hpp | 2 +- src/core/pool_func.hpp | 4 +- src/core/pool_type.hpp | 4 +- src/core/random_func.cpp | 20 +- src/core/random_func.hpp | 20 +- src/core/ring_buffer.hpp | 126 +-- src/core/serialisation.cpp | 44 +- src/core/serialisation.hpp | 78 +- src/cpu.cpp | 24 +- src/cpu.h | 2 +- src/crashlog.cpp | 16 +- src/currency.cpp | 4 +- src/currency.h | 6 +- src/date.cpp | 36 +- src/date_func.h | 16 +- src/date_gui.cpp | 2 +- src/date_type.h | 14 +- src/debug.cpp | 8 +- src/debug.h | 10 +- src/debug_desync.h | 2 +- src/debug_settings.h | 2 +- src/departures.cpp | 8 +- src/departures_gui.cpp | 12 +- src/depot_base.h | 2 +- src/depot_cmd.cpp | 2 +- src/depot_gui.cpp | 8 +- src/depot_type.h | 2 +- src/disaster_vehicle.cpp | 18 +- src/dock_gui.cpp | 8 +- src/economy.cpp | 44 +- src/economy_func.h | 4 +- src/economy_type.h | 32 +- src/effectvehicle.cpp | 14 +- src/effectvehicle_base.h | 4 +- src/elrail.cpp | 6 +- src/elrail_func.h | 2 +- src/engine.cpp | 36 +- src/engine_base.h | 64 +- src/engine_func.h | 6 +- src/engine_gui.cpp | 4 +- src/engine_gui.h | 2 +- src/engine_type.h | 62 +- src/error.h | 10 +- src/error_gui.cpp | 12 +- src/event_logs.cpp | 2 +- src/event_logs.h | 2 +- src/fios.cpp | 4 +- src/fios.h | 2 +- src/fios_gui.cpp | 2 +- src/fontcache.h | 8 +- src/fontcache/freetypefontcache.cpp | 8 +- src/fontcache/spritefontcache.cpp | 4 +- src/fontcache/spritefontcache.h | 2 +- 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_instance.cpp | 2 +- src/game/game_text.hpp | 4 +- src/gamelog.cpp | 20 +- src/gamelog.h | 10 +- src/gamelog_internal.h | 30 +- src/genworld.h | 4 +- src/genworld_gui.cpp | 10 +- src/gfx.cpp | 40 +- src/gfx_func.h | 12 +- src/gfx_layout.cpp | 8 +- src/gfx_layout.h | 2 +- src/gfx_layout_fallback.cpp | 24 +- src/gfx_layout_fallback.h | 6 +- src/gfx_layout_icu.cpp | 8 +- src/gfx_layout_icu.h | 2 +- src/gfx_type.h | 20 +- src/gfxinit.cpp | 10 +- src/goal.cpp | 24 +- src/goal_gui.cpp | 4 +- src/goal_type.h | 6 +- src/graph_gui.cpp | 52 +- src/graph_gui.h | 4 +- src/ground_vehicle.cpp | 68 +- src/ground_vehicle.hpp | 70 +- src/group.h | 10 +- src/group_cmd.cpp | 22 +- src/group_gui.cpp | 12 +- src/group_type.h | 4 +- src/gui.h | 4 +- src/heightmap.cpp | 2 +- src/highscore.cpp | 2 +- src/highscore.h | 8 +- src/highscore_gui.cpp | 10 +- src/hotkeys.cpp | 26 +- src/hotkeys.h | 16 +- src/house.h | 4 +- src/house_type.h | 4 +- src/industry.h | 42 +- src/industry_cmd.cpp | 106 +-- src/industry_gui.cpp | 18 +- src/industry_map.h | 2 +- src/industry_type.h | 6 +- src/industrytype.h | 30 +- src/infrastructure.cpp | 4 +- src/landscape.cpp | 56 +- src/language.h | 34 +- src/league_base.h | 2 +- src/league_cmd.cpp | 16 +- src/league_type.h | 6 +- src/linkgraph/demands.cpp | 8 +- src/linkgraph/demands.h | 6 +- src/linkgraph/linkgraph.cpp | 24 +- src/linkgraph/linkgraph.h | 14 +- src/linkgraph/linkgraph_gui.cpp | 42 +- src/linkgraph/linkgraph_gui.h | 8 +- src/linkgraph/linkgraph_type.h | 6 +- src/linkgraph/linkgraphjob.cpp | 4 +- src/linkgraph/linkgraphschedule.cpp | 10 +- src/linkgraph/mcf.cpp | 8 +- src/linkgraph/refresh.cpp | 16 +- src/linkgraph/refresh.h | 18 +- src/load_check.h | 2 +- src/main_gui.cpp | 28 +- src/map.cpp | 10 +- src/map_func.h | 2 +- src/map_type.h | 14 +- src/misc.cpp | 6 +- src/misc/countedobj.cpp | 6 +- src/misc/countedptr.hpp | 6 +- src/misc/getoptdata.h | 2 +- src/misc/hashtable.hpp | 2 +- src/misc_cmd.cpp | 32 +- src/misc_gui.cpp | 8 +- src/mixer.cpp | 46 +- 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 | 76 +- src/music/midifile.hpp | 14 +- src/music/win32_m.cpp | 2 +- src/network/core/address.cpp | 22 +- src/network/core/address.h | 8 +- src/network/core/config.h | 28 +- src/network/core/network_game_info.cpp | 20 +- src/network/core/network_game_info.h | 8 +- src/network/core/os_abstraction.cpp | 2 +- src/network/core/packet.cpp | 2 +- src/network/core/packet.h | 6 +- src/network/core/tcp.h | 4 +- src/network/core/tcp_admin.h | 202 ++--- src/network/core/tcp_connect.cpp | 4 +- src/network/core/tcp_content.h | 58 +- src/network/core/tcp_content_type.h | 4 +- src/network/core/tcp_coordinator.h | 80 +- src/network/core/tcp_game.h | 158 ++-- src/network/core/tcp_listen.h | 2 +- src/network/core/tcp_stun.h | 4 +- src/network/core/tcp_turn.h | 2 +- src/network/core/udp.cpp | 24 +- src/network/core/udp.h | 4 +- src/network/network.cpp | 80 +- src/network/network_admin.cpp | 20 +- src/network/network_admin.h | 4 +- src/network/network_base.h | 4 +- src/network/network_chat_gui.cpp | 4 +- src/network/network_client.cpp | 28 +- src/network/network_command.cpp | 6 +- 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 | 4 +- src/network/network_coordinator.cpp | 38 +- 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 | 40 +- src/network/network_server.cpp | 50 +- src/network/network_server.h | 8 +- src/network/network_stun.cpp | 8 +- src/network/network_stun.h | 10 +- src/network/network_sync.h | 8 +- src/network/network_turn.cpp | 2 +- src/network/network_turn.h | 6 +- src/network/network_type.h | 20 +- src/network/network_udp.cpp | 6 +- src/newgrf.cpp | 700 ++++++++--------- src/newgrf.h | 80 +- src/newgrf_airport.cpp | 18 +- src/newgrf_airport.h | 14 +- src/newgrf_airporttiles.cpp | 24 +- src/newgrf_airporttiles.h | 14 +- src/newgrf_analysis.cpp | 18 +- src/newgrf_analysis.h | 10 +- src/newgrf_animation_base.h | 20 +- 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 | 8 +- src/newgrf_class_func.h | 8 +- src/newgrf_commons.cpp | 78 +- src/newgrf_commons.h | 102 +-- src/newgrf_config.cpp | 14 +- src/newgrf_config.h | 36 +- src/newgrf_debug.h | 2 +- src/newgrf_debug_gui.cpp | 72 +- src/newgrf_engine.cpp | 60 +- src/newgrf_engine.h | 16 +- src/newgrf_extension.h | 6 +- src/newgrf_generic.cpp | 44 +- src/newgrf_generic.h | 4 +- src/newgrf_gui.cpp | 20 +- src/newgrf_house.cpp | 72 +- src/newgrf_house.h | 40 +- src/newgrf_industries.cpp | 62 +- src/newgrf_industries.h | 46 +- src/newgrf_industrytiles.cpp | 50 +- src/newgrf_industrytiles.h | 18 +- src/newgrf_industrytiles_analysis.h | 6 +- src/newgrf_internal.h | 32 +- src/newgrf_newlandscape.cpp | 6 +- src/newgrf_newlandscape.h | 6 +- src/newgrf_newsignals.cpp | 18 +- src/newgrf_newsignals.h | 34 +- src/newgrf_object.cpp | 38 +- src/newgrf_object.h | 64 +- src/newgrf_optimiser.cpp | 82 +- src/newgrf_profiling.cpp | 16 +- src/newgrf_profiling.h | 32 +- src/newgrf_railtype.cpp | 32 +- src/newgrf_railtype.h | 16 +- src/newgrf_roadstop.cpp | 46 +- src/newgrf_roadstop.h | 38 +- src/newgrf_roadtype.cpp | 12 +- src/newgrf_roadtype.h | 12 +- src/newgrf_sound.cpp | 12 +- src/newgrf_spritegroup.cpp | 54 +- src/newgrf_spritegroup.h | 122 +-- src/newgrf_station.cpp | 94 +-- src/newgrf_station.h | 22 +- src/newgrf_storage.h | 14 +- src/newgrf_text.cpp | 80 +- src/newgrf_text.h | 18 +- src/newgrf_town.cpp | 10 +- src/newgrf_town.h | 6 +- src/news_func.h | 2 +- src/news_gui.cpp | 14 +- src/news_type.h | 10 +- src/object.h | 2 +- src/object_base.h | 4 +- src/object_cmd.cpp | 30 +- src/object_gui.cpp | 4 +- src/object_type.h | 4 +- src/openttd.cpp | 34 +- src/openttd.h | 2 +- src/order_backup.cpp | 14 +- src/order_backup.h | 16 +- src/order_base.h | 108 +-- src/order_cmd.cpp | 68 +- src/order_func.h | 2 +- src/order_gui.cpp | 42 +- src/order_type.h | 10 +- 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/font_win32.cpp | 2 +- src/os/windows/font_win32.h | 2 +- src/os/windows/string_uniscribe.cpp | 8 +- src/os/windows/win32.cpp | 6 +- src/osk_gui.cpp | 4 +- src/pathfinder/follow_track.hpp | 4 +- src/pathfinder/npf/aystar.cpp | 16 +- src/pathfinder/npf/aystar.h | 16 +- src/pathfinder/npf/npf.cpp | 22 +- src/pathfinder/npf/queue.cpp | 6 +- src/pathfinder/npf/queue.h | 8 +- src/pathfinder/yapf/yapf_node_rail.hpp | 10 +- src/pbs.cpp | 60 +- src/pbs.h | 48 +- src/plans_base.h | 14 +- src/plans_cmd.cpp | 18 +- src/plans_gui.cpp | 6 +- src/plans_type.h | 2 +- src/programmable_signals.cpp | 18 +- src/programmable_signals.h | 4 +- src/programmable_signals_gui.cpp | 18 +- src/querystring_gui.h | 2 +- src/rail.h | 10 +- src/rail_cmd.cpp | 54 +- src/rail_gui.cpp | 90 +-- src/rail_gui.h | 2 +- src/rail_gui_type.h | 4 +- src/rail_map.h | 10 +- src/rail_type.h | 6 +- src/random_access_file.cpp | 4 +- src/random_access_file_type.h | 16 +- src/rev.cpp.in | 2 +- src/rev.h | 2 +- src/road.cpp | 30 +- src/road.h | 12 +- src/road_cmd.cpp | 32 +- src/road_gui.cpp | 34 +- src/road_type.h | 8 +- src/roadveh.h | 50 +- src/roadveh_cmd.cpp | 46 +- src/saveload/afterload.cpp | 22 +- src/saveload/animated_tile_sl.cpp | 2 +- src/saveload/cargomonitor_sl.cpp | 6 +- src/saveload/company_sl.cpp | 4 +- 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/order_sl.cpp | 14 +- src/saveload/saveload.cpp | 166 ++-- src/saveload/saveload.h | 14 +- src/saveload/settings_sl.cpp | 2 +- src/saveload/station_sl.cpp | 24 +- src/saveload/story_sl.cpp | 4 +- src/saveload/town_sl.cpp | 16 +- src/saveload/vehicle_sl.cpp | 14 +- src/schdispatch_cmd.cpp | 66 +- src/schdispatch_gui.cpp | 44 +- src/screenshot.cpp | 56 +- src/screenshot.h | 4 +- src/script/api/script_airport.cpp | 4 +- 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 | 10 +- src/script/api/script_company.hpp | 4 +- src/script/api/script_engine.cpp | 2 +- src/script/api/script_event_types.cpp | 8 +- src/script/api/script_event_types.hpp | 14 +- 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_industry.cpp | 6 +- src/script/api/script_industrytype.cpp | 6 +- src/script/api/script_inflation.cpp | 20 +- src/script/api/script_inflation.hpp | 8 +- src/script/api/script_info_docs.hpp | 14 +- src/script/api/script_infrastructure.cpp | 4 +- src/script/api/script_news.cpp | 2 +- src/script/api/script_object.cpp | 10 +- src/script/api/script_object.hpp | 16 +- src/script/api/script_order.cpp | 6 +- src/script/api/script_order.hpp | 2 +- src/script/api/script_rail.cpp | 16 +- src/script/api/script_road.cpp | 20 +- src/script/api/script_road.hpp | 2 +- src/script/api/script_station.cpp | 4 +- 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_town.cpp | 8 +- src/script/api/script_town.hpp | 4 +- src/script/api/script_types.hpp | 36 +- src/script/api/script_vehicle.cpp | 4 +- src/script/api/script_window.hpp.in | 8 +- src/script/script_gui.cpp | 16 +- src/script/script_instance.cpp | 12 +- src/script/script_instance.hpp | 4 +- src/script/script_scanner.cpp | 4 +- src/script/script_storage.hpp | 18 +- src/script/squirrel.cpp | 14 +- src/script/squirrel_helper.hpp | 32 +- src/script/squirrel_helper_type.hpp | 2 +- src/settings.cpp | 312 ++++---- src/settings_func.h | 6 +- src/settings_gui.cpp | 44 +- src/settings_internal.h | 56 +- src/settings_type.h | 830 ++++++++++---------- src/ship.h | 20 +- src/ship_cmd.cpp | 18 +- src/signal.cpp | 94 +-- src/signal_func.h | 36 +- src/signal_type.h | 2 +- src/signs_base.h | 6 +- src/signs_cmd.cpp | 6 +- src/signs_gui.cpp | 2 +- src/signs_type.h | 2 +- src/sl/bridge_signal_sl.cpp | 12 +- src/sl/cargomonitor_sl.cpp | 6 +- src/sl/cargopacket_sl.cpp | 6 +- src/sl/cheat_sl.cpp | 12 +- src/sl/company_sl.cpp | 38 +- src/sl/economy_sl.cpp | 2 +- src/sl/engine_sl.cpp | 2 +- src/sl/extended_ver_sl.cpp | 130 +-- src/sl/extended_ver_sl.h | 34 +- src/sl/labelmaps_sl.cpp | 2 +- src/sl/linkgraph_sl.cpp | 4 +- src/sl/map_sl.cpp | 46 +- src/sl/misc_sl.cpp | 4 +- src/sl/oldloader.cpp | 32 +- src/sl/oldloader.h | 4 +- src/sl/oldloader_sl.cpp | 40 +- src/sl/order_sl.cpp | 28 +- src/sl/plans_sl.cpp | 4 +- src/sl/saveload.cpp | 206 ++--- src/sl/saveload.h | 48 +- src/sl/saveload_buffer.h | 24 +- src/sl/saveload_common.h | 14 +- src/sl/saveload_internal.h | 10 +- src/sl/saveload_types.h | 4 +- src/sl/station_sl.cpp | 50 +- src/sl/story_sl.cpp | 4 +- src/sl/strings_sl.cpp | 2 +- src/sl/tbtr_template_veh_sl.cpp | 2 +- src/sl/town_sl.cpp | 40 +- src/sl/tracerestrict_sl.cpp | 8 +- src/sl/vehicle_sl.cpp | 52 +- src/sl/waypoint_sl.cpp | 8 +- src/slope_type.h | 2 +- src/smallmap_colours.h | 16 +- src/smallmap_gui.cpp | 34 +- src/smallmap_gui.h | 18 +- src/sortlist_type.h | 22 +- src/sound.cpp | 8 +- src/sound/allegro_s.cpp | 2 +- src/sound_type.h | 12 +- src/sprite.cpp | 12 +- src/sprite.h | 12 +- src/spritecache.cpp | 58 +- src/spritecache.h | 40 +- src/spritecache_internal.h | 14 +- src/spriteloader/grf.cpp | 30 +- src/spriteloader/grf.hpp | 2 +- src/spriteloader/sprite_file_type.hpp | 2 +- src/spriteloader/spriteloader.hpp | 20 +- src/station.cpp | 6 +- src/station_base.h | 60 +- src/station_cmd.cpp | 108 +-- src/station_func.h | 2 +- src/station_gui.cpp | 10 +- src/station_kdtree.h | 14 +- src/station_type.h | 6 +- src/statusbar_gui.cpp | 6 +- src/stdafx.h | 14 +- src/story.cpp | 28 +- src/story_base.h | 12 +- src/story_gui.cpp | 6 +- src/story_type.h | 4 +- src/strgen/strgen.cpp | 6 +- src/strgen/strgen_base.cpp | 8 +- src/string.cpp | 38 +- src/string_func.h | 2 +- src/string_type.h | 14 +- src/stringfilter.cpp | 12 +- src/strings.cpp | 6 +- src/strings_func.h | 10 +- src/strings_type.h | 2 +- src/subsidy.cpp | 6 +- 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 | 78 +- src/table/object_land.h | 2 +- src/table/road_land.h | 2 +- src/table/settings.h.preamble | 4 +- src/table/settings/difficulty_settings.ini | 12 +- src/table/settings/economy_settings.ini | 24 +- src/table/settings/game_settings.ini | 16 +- src/table/settings/gui_settings.ini | 20 +- src/table/settings/linkgraph_settings.ini | 4 +- src/table/settings/locale_settings.ini | 2 +- src/table/settings/pathfinding_settings.ini | 2 +- src/table/settings/script_settings.ini | 6 +- src/table/settings/world_settings.ini | 10 +- src/table/sprites.h | 54 +- 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 | 4 +- src/table/water_land.h | 2 +- src/tbtr_template_gui_create.cpp | 14 +- src/tbtr_template_gui_main.cpp | 20 +- src/tbtr_template_vehicle.cpp | 2 +- src/tbtr_template_vehicle.h | 30 +- src/tbtr_template_vehicle_func.cpp | 8 +- src/tbtr_template_vehicle_func.h | 2 +- src/terraform_cmd.cpp | 6 +- src/terraform_gui.cpp | 12 +- src/tests/bitmath_func.cpp | 38 +- src/tests/mock_spritecache.cpp | 2 +- src/tests/ring_buffer.cpp | 76 +- src/texteff.cpp | 10 +- src/texteff.hpp | 8 +- src/tgp.cpp | 14 +- src/tile_cmd.h | 10 +- src/tile_type.h | 2 +- src/tilearea_type.h | 12 +- src/timetable_cmd.cpp | 52 +- src/timetable_gui.cpp | 18 +- src/toolbar_gui.cpp | 52 +- src/town.h | 88 +-- src/town_cmd.cpp | 130 +-- src/town_gui.cpp | 22 +- src/town_kdtree.h | 4 +- src/town_type.h | 2 +- src/tracerestrict.cpp | 68 +- src/tracerestrict.h | 62 +- src/tracerestrict_gui.cpp | 70 +- src/track_type.h | 4 +- src/train.h | 82 +- src/train_cmd.cpp | 222 +++--- src/train_gui.cpp | 8 +- src/train_speed_adaptation.h | 10 +- src/transparency_gui.cpp | 2 +- src/transport_type.h | 2 +- src/tree_cmd.cpp | 52 +- src/tree_gui.cpp | 4 +- src/tunnel_base.h | 12 +- src/tunnel_map.cpp | 14 +- src/tunnel_map.h | 8 +- src/tunnelbridge_cmd.cpp | 36 +- src/tunnelbridge_map.h | 22 +- src/unit_conversion.h | 8 +- src/vehicle.cpp | 100 +-- src/vehicle_base.h | 98 +-- src/vehicle_cmd.cpp | 88 +-- src/vehicle_func.h | 34 +- src/vehicle_gui.cpp | 34 +- src/vehicle_gui.h | 10 +- src/vehicle_type.h | 4 +- src/vehiclelist.cpp | 6 +- src/vehiclelist.h | 8 +- src/video/allegro_v.cpp | 6 +- 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_v.cpp | 28 +- src/video/sdl_v.cpp | 10 +- src/video/video_driver.hpp | 4 +- src/video/win32_v.cpp | 18 +- src/video/win32_v.h | 4 +- src/viewport.cpp | 142 ++-- src/viewport_func.h | 8 +- src/viewport_gui.cpp | 6 +- src/viewport_kdtree.h | 10 +- src/viewport_sprite_sorter.h | 26 +- src/viewport_type.h | 14 +- src/water_cmd.cpp | 12 +- src/water_map.h | 8 +- src/waypoint_base.h | 6 +- src/waypoint_cmd.cpp | 10 +- src/widget.cpp | 26 +- src/widget_type.h | 58 +- src/window.cpp | 26 +- src/window_gui.h | 48 +- src/window_type.h | 2 +- src/zoning.h | 2 +- src/zoning_cmd.cpp | 10 +- src/zoom_type.h | 2 +- 655 files changed, 7569 insertions(+), 7569 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 ca1c607b7a..611589e615 100644 --- a/src/3rdparty/md5/md5.h +++ b/src/3rdparty/md5/md5.h @@ -78,11 +78,11 @@ char *md5sumToString(char *buf, const char *last, const MD5Hash &md5sum); 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 67b20a4d75..6a8976abb8 100644 --- a/src/3rdparty/squirrel/include/squirrel.h +++ b/src/3rdparty/squirrel/include/squirrel.h @@ -179,7 +179,7 @@ typedef void (*SQPRINTFUNCTION)(HSQUIRRELVM,const SQChar * ,...); 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 f7ddf18a4b..f68553b1ba 100644 --- a/src/3rdparty/squirrel/squirrel/sqapi.cpp +++ b/src/3rdparty/squirrel/squirrel/sqapi.cpp @@ -1258,9 +1258,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]; @@ -1278,7 +1278,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/ai/ai_instance.cpp b/src/ai/ai_instance.cpp index a3b6166884..b08b436337 100644 --- a/src/ai/ai_instance.cpp +++ b/src/ai/ai_instance.cpp @@ -100,7 +100,7 @@ ScriptInfo *AIInstance::FindLibrary(const std::string &library, int version) * @param p2 p2 as given to DoCommandPInternal. * @param cmd cmd as given to DoCommandPInternal. */ -void CcAI(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcAI(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { /* * The company might not exist anymore. Check for this. diff --git a/src/aircraft.h b/src/aircraft.h index 16ca6fa029..d45d63cc5f 100644 --- a/src/aircraft.h +++ b/src/aircraft.h @@ -65,8 +65,8 @@ 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. byte image_movement_state; ///< Cached image aircraft movement state }; @@ -74,7 +74,7 @@ struct AircraftCache { * 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. @@ -134,7 +134,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 b926645b31..c0edaf5f11 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); } @@ -188,7 +188,7 @@ void Aircraft::GetImage(Direction direction, EngineImageType image_type, Vehicle return; } - uint8 spritenum = this->spritenum; + uint8_t spritenum = this->spritenum; if (is_custom_sprite(spritenum)) { GetCustomVehicleSprite(this, direction, image_type, result); @@ -218,7 +218,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); @@ -1270,7 +1270,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 @@ -1314,8 +1314,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 }, @@ -1457,7 +1457,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) { @@ -1468,7 +1468,7 @@ static void MaybeCrashAirplane(Aircraft *v) } if (_settings_game.vehicle.improved_breakdowns && v->breakdown_ctr == 1 && v->breakdown_type == BREAKDOWN_AIRCRAFT_EM_LANDING) { /* Airplanes that are attempting an emergency landing have a 2% chance to crash */ - prob = std::max(prob, 0x10000 / 50); + prob = std::max(prob, 0x10000 / 50); } if (GB(Random(), 0, 22) > prob) return; @@ -1769,8 +1769,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); @@ -1954,7 +1954,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) { @@ -1984,7 +1984,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; @@ -2021,7 +2021,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. */ @@ -2229,7 +2229,7 @@ static bool AircraftEventHandler(Aircraft *v, int loop) bool Aircraft::Tick() { DEBUG_UPDATESTATECHECKSUM("Aircraft::Tick: v: %u, x: %d, y: %d", this->index, this->x_pos, this->y_pos); - UpdateStateChecksum((((uint64) this->x_pos) << 32) | this->y_pos); + UpdateStateChecksum((((uint64_t) this->x_pos) << 32) | this->y_pos); if (!this->IsNormalAircraft()) return true; this->tick_counter++; 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..1e8a36336a 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/airport_gui.cpp b/src/airport_gui.cpp index d43fbab240..2b407a3c24 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -42,7 +42,7 @@ static void ShowBuildAirportPicker(Window *parent); SpriteID GetCustomAirportSprite(const AirportSpec *as, byte layout); -void CcBuildAirport(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcBuildAirport(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; @@ -57,10 +57,10 @@ void CcBuildAirport(const CommandCost &result, TileIndex tile, uint32 p1, uint32 static void PlaceAirport(TileIndex tile) { if (_selected_airport_index == -1) return; - uint32 p2 = _ctrl_pressed; + uint32_t p2 = _ctrl_pressed; SB(p2, 16, 16, INVALID_STATION); // no station to join - uint32 p1 = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->GetIndex(); + uint32_t p1 = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index)->GetIndex(); p1 |= _selected_airport_layout << 8; CommandContainer cmdcont = NewCommandContainerBasic(tile, p1, p2, CMD_BUILD_AIRPORT | CMD_MSG(STR_ERROR_CAN_T_BUILD_AIRPORT_HERE), CcBuildAirport); ShowSelectStationIfNeeded(cmdcont, TileArea(tile, _thd.size.x / TILE_SIZE, _thd.size.y / TILE_SIZE)); diff --git a/src/animated_tile.cpp b/src/animated_tile.cpp index 0a29992964..75174fcd08 100644 --- a/src/animated_tile.cpp +++ b/src/animated_tile.cpp @@ -39,10 +39,10 @@ void DeleteAnimatedTile(TileIndex tile) static void UpdateAnimatedTileSpeed(TileIndex tile, AnimatedTileInfo &info) { - extern uint8 GetAnimatedTileSpeed_Town(TileIndex tile); - extern uint8 GetAnimatedTileSpeed_Station(TileIndex tile); - extern uint8 GetAnimatedTileSpeed_Industry(TileIndex tile); - extern uint8 GetNewObjectTileAnimationSpeed(TileIndex tile); + extern uint8_t GetAnimatedTileSpeed_Town(TileIndex tile); + extern uint8_t GetAnimatedTileSpeed_Station(TileIndex tile); + extern uint8_t GetAnimatedTileSpeed_Industry(TileIndex tile); + extern uint8_t GetNewObjectTileAnimationSpeed(TileIndex tile); switch (GetTileType(tile)) { case MP_HOUSE: @@ -101,8 +101,8 @@ void AnimateAnimatedTiles() PerformanceAccumulator framerate(PFE_GL_LANDSCAPE); - const uint32 ticks = (uint) _scaled_tick_counter; - const uint8 max_speed = (ticks == 0) ? 32 : FindFirstBit(ticks); + const uint32_t ticks = (uint) _scaled_tick_counter; + const uint8_t max_speed = (ticks == 0) ? 32 : FindFirstBit(ticks); auto iter = _animated_tiles.begin(); while (iter != _animated_tiles.end()) { diff --git a/src/animated_tile.h b/src/animated_tile.h index bb4b71e38a..d5f4bc83e8 100644 --- a/src/animated_tile.h +++ b/src/animated_tile.h @@ -14,7 +14,7 @@ #include "3rdparty/cpp-btree/btree_map.h" struct AnimatedTileInfo { - uint8 speed = 0; + uint8_t speed = 0; bool pending_deletion = false; }; diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp index a2d06f83e7..a4e222d3d5 100644 --- a/src/articulated_vehicles.cpp +++ b/src/articulated_vehicles.cpp @@ -44,7 +44,7 @@ static EngineID GetNextArticulatedPart(uint index, EngineID front_type, Vehicle return INVALID_ENGINE; } - 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) { @@ -143,7 +143,7 @@ void GetArticulatedPartsEngineIDs(EngineID engine_type, bool purchase_window, st * @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); @@ -183,7 +183,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->IsArticulatedCallbackVehicleType()) return capacity; @@ -212,7 +212,7 @@ CargoTypes GetCargoTypesOfArticulatedParts(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 && cargo_capacity > 0) SetBit(cargoes, cargo_type); if (!e->IsArticulatedCallbackVehicleType()) return cargoes; 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 39dc792b9a..d579d010e3 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -674,7 +674,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++; @@ -895,7 +895,7 @@ static CommandCost ReplaceChain(Vehicle **chain, DoCommandFlag flags, bool wagon * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Vehicle *v = Vehicle::GetIfValid(p1); if (v == nullptr) return CMD_ERROR; @@ -990,7 +990,7 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdSetAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSetAutoReplace(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Company *c = Company::GetIfValid(_current_company); if (c == nullptr) return CMD_ERROR; diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 154cc6110e..4eaf9d4f39 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -30,7 +30,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 f769434ca5..e7818d299c 100644 --- a/src/base_consist.h +++ b/src/base_consist.h @@ -17,20 +17,20 @@ /** Various front vehicle properties that are preserved when autoreplacing, using order-backup or switching front engines within a consist. */ struct BaseConsist { - TinyString name; ///< Name of vehicle + TinyString 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. - DateTicksScaled timetable_start; ///< When the vehicle is supposed to start the timetable. + 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. + DateTicksScaled 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 - VehicleOrderID cur_timetable_order_index;///< The index to the current real (non-implicit) order used for timetable updates + 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 + VehicleOrderID cur_timetable_order_index; ///< The index to the current real (non-implicit) order used for timetable updates - uint32 vehicle_flags; ///< Used for gradual loading and other miscellaneous things (@see VehicleFlags enum) + uint32_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 57b14ca067..d069ff107b 100644 --- a/src/base_media_base.h +++ b/src/base_media_base.h @@ -61,8 +61,8 @@ struct BaseSet { std::string name; ///< The name of the base set std::string url; ///< URL for information about 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 59de6e84a9..8f1e13d4c7 100644 --- a/src/base_media_func.h +++ b/src/base_media_func.h @@ -66,7 +66,7 @@ bool BaseSet::FillSetDetails(const IniFile &ini, 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 6f2e73b8fb..803c2a89ce 100644 --- a/src/base_station_base.h +++ b/src/base_station_base.h @@ -24,20 +24,20 @@ extern StationPool _station_pool; struct StationSpecList { const StationSpec *spec; - uint32 grfid; ///< GRF ID of this custom station - uint16 localidx; ///< Station ID within GRF of 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 - uint16 localidx; ///< Station ID within GRF of 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 */ @@ -82,10 +82,10 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> { 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 @@ -121,7 +121,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, uint16 variable, byte parameter, bool *available) const = 0; + virtual uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint16_t 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 003cde40a0..b5b3809259 100644 --- a/src/blitter/32bpp_anim.cpp +++ b/src/blitter/32bpp_anim.cpp @@ -33,15 +33,15 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel const BlitterSpriteFlags sprite_flags = src->flags; 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 const int width = bp->width; @@ -52,12 +52,12 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel for (int y = 0; y < height; y++) { Colour *dst_ln = dst + pitch; - uint16 *anim_ln = anim + anim_pitch; + uint16_t *anim_ln = anim + anim_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; @@ -132,7 +132,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel } else { uint r = remap[GB(m, 0, 8)]; if (r != 0) { - uint8 brightness = GB(m, 8, 8); + uint8_t brightness = GB(m, 8, 8); if (mode == BM_COLOUR_REMAP_WITH_BRIGHTNESS) { brightness = Clamp(brightness + bp->brightness_adjust, 0, 255); SB(m, 8, 8, brightness); @@ -158,7 +158,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel uint r = remap[GB(m, 0, 8)]; *anim = 0; if (r != 0) { - uint8 brightness = GB(m, 8, 8); + uint8_t brightness = GB(m, 8, 8); if (mode == BM_COLOUR_REMAP_WITH_BRIGHTNESS) brightness = Clamp(brightness + bp->brightness_adjust, 0, 255); *dst = ComposeColourPANoCheck(this->AdjustBrightness(this->LookupColourInPalette(r), brightness), src_px->a, *dst); } @@ -176,7 +176,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 { @@ -194,7 +194,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; } @@ -273,7 +273,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel } else if (src_px->a == 255) { do { /* Compiler assumes pointer aliasing, can't optimise this on its own */ - uint16 mv = *src_n; + uint16_t mv = *src_n; uint m = GB(mv, 0, 8); /* Above PALETTE_ANIM_START is palette animation */ if (m >= PALETTE_ANIM_START) { @@ -293,7 +293,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel uint m = GB(*src_n, 0, 8); *anim++ = 0; if (m >= PALETTE_ANIM_START) { - uint8 brightness = GB(*src_n, 8, 8); + uint8_t brightness = GB(*src_n, 8, 8); if (mode == BM_NORMAL_WITH_BRIGHTNESS) brightness = Clamp(brightness + bp->brightness_adjust, 0, 255); *dst = ComposeColourPANoCheck(this->AdjustBrightness(this->LookupColourInPalette(m), brightness), src_px->a, *dst); } else { @@ -373,7 +373,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 { @@ -405,25 +405,25 @@ void Blitter_32bppAnim::DrawColourMappingRect(void *dst, int width, int height, DEBUG(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('%d')", 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::SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) +void Blitter_32bppAnim::SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32) { *((Colour *)video + x + y * _screen.pitch) = colour32; /* 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] = 0; + this->anim_buf[this->ScreenToAnimOffset((uint32_t *)video) + x + y * this->anim_buf_pitch] = 0; } -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); @@ -432,8 +432,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; @@ -441,7 +441,7 @@ void Blitter_32bppAnim::DrawLine(void *video, int x, int y, int x2, int y2, int } } -void Blitter_32bppAnim::SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) +void Blitter_32bppAnim::SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch) { Colour *dst = (Colour *)video + x + y * _screen.pitch; @@ -457,7 +457,7 @@ void Blitter_32bppAnim::SetRect(void *video, int x, int y, const uint8 *colours, colours += pitch - width; } while (--lines); } else { - uint16 *dstanim = (uint16 *)(&this->anim_buf[this->ScreenToAnimOffset((uint32 *)video) + x + y * this->anim_buf_pitch]); + uint16_t *dstanim = (uint16_t *)(&this->anim_buf[this->ScreenToAnimOffset((uint32_t *)video) + x + y * this->anim_buf_pitch]); do { uint w = width; do { @@ -474,21 +474,21 @@ void Blitter_32bppAnim::SetRect(void *video, int x, int y, const uint8 *colours, } } -void Blitter_32bppAnim::SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch) +void Blitter_32bppAnim::SetRect32(void *video, int x, int y, const uint32_t *colours, uint lines, uint width, uint pitch) { - uint32 *dst = (uint32 *)video + x + y * _screen.pitch; + uint32_t *dst = (uint32_t *)video + x + y * _screen.pitch; if (_screen_disable_anim) { do { - memcpy(dst, colours, width * sizeof(uint32)); + memcpy(dst, colours, width * sizeof(uint32_t)); dst += _screen.pitch; colours += pitch; } while (--lines); } else { - uint16 *dstanim = (uint16 *)(&this->anim_buf[this->ScreenToAnimOffset((uint32 *)video) + x + y * this->anim_buf_pitch]); + uint16_t *dstanim = (uint16_t *)(&this->anim_buf[this->ScreenToAnimOffset((uint32_t *)video) + x + y * this->anim_buf_pitch]); do { - memcpy(dst, colours, width * sizeof(uint32)); - memset(dstanim, 0, width * sizeof(uint16)); + memcpy(dst, colours, width * sizeof(uint32_t)); + memset(dstanim, 0, width * sizeof(uint16_t)); dst += _screen.pitch; dstanim += this->anim_buf_pitch; colours += pitch; @@ -496,7 +496,7 @@ void Blitter_32bppAnim::SetRect32(void *video, int x, int y, const uint32 *colou } } -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() */ @@ -505,11 +505,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; @@ -518,12 +518,12 @@ 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); } -void Blitter_32bppAnim::DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour) +void Blitter_32bppAnim::DrawRectAt(void *video, int x, int y, int width, int height, uint8_t colour) { this->Blitter_32bppAnim::DrawRect((Colour *)video + x + y * _screen.pitch, width, height, colour); } @@ -531,22 +531,22 @@ void Blitter_32bppAnim::DrawRectAt(void *video, int x, int y, int width, int hei 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 @@ -571,21 +571,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; } } @@ -593,8 +593,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) { @@ -611,7 +611,7 @@ void Blitter_32bppAnim::ScrollBuffer(void *video, int left, int top, int width, 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; } @@ -632,7 +632,7 @@ void Blitter_32bppAnim::ScrollBuffer(void *video, int left, int top, int width, 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; } @@ -643,7 +643,7 @@ void Blitter_32bppAnim::ScrollBuffer(void *video, int left, int top, int width, 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) @@ -656,7 +656,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 */ @@ -665,8 +665,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)); @@ -695,9 +695,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 5a64de2afc..b22508ad45 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_pitch; ///< The pitch of the animation buffer (width rounded up to 16 byte boundary). @@ -37,13 +37,13 @@ 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 SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) 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 SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) override; - void SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch) override; - void DrawRect(void *video, int width, int height, uint8 colour) override; - void DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour) override; + void SetPixel(void *video, int x, int y, uint8_t colour) override; + void SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32) 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 SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch) override; + void SetRect32(void *video, int x, int y, const uint32_t *colours, uint lines, uint width, uint pitch) override; + void DrawRect(void *video, int width, int height, uint8_t colour) override; + void DrawRectAt(void *video, int x, int y, 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; @@ -62,9 +62,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 484da2b60c..154c03242b 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 a420a6c6b5..e19e4bb4d0 100644 --- a/src/blitter/32bpp_anim_sse4.cpp +++ b/src/blitter/32bpp_anim_sse4.cpp @@ -35,7 +35,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. */ @@ -60,7 +60,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 @@ -82,7 +82,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; @@ -98,7 +98,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); @@ -118,26 +118,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; @@ -160,7 +160,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; @@ -180,7 +180,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); @@ -202,14 +202,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]; @@ -227,11 +227,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) { @@ -246,9 +246,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; @@ -273,7 +273,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) { @@ -337,7 +337,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; } @@ -376,7 +376,7 @@ bmcr_alpha_blend_single: } else { *dst = AdjustBrightneSSE(src->data, DEFAULT_BRIGHTNESS + bp->brightness_adjust); } - *anim = *(const uint16*) &mv; + *anim = *(const uint16_t*) &mv; } else { *anim = 0; __m128i srcABCD; @@ -406,7 +406,7 @@ bmcr_alpha_blend_single: MapValue mv = *src_mv; mv.v = Clamp(mv.v + bp->brightness_adjust, 0, 255); const uint r = remap[mv.m]; - *anim = (animated && src->a == 255) ? r | ((uint16) mv.v << 8) : 0; + *anim = (animated && src->a == 255) ? r | ((uint16_t) mv.v << 8) : 0; if (r != 0) { Colour remapped_colour = AdjustBrightneSSE(this->LookupColourInPalette(r), mv.v); if (src->a == 255) { diff --git a/src/blitter/32bpp_base.cpp b/src/blitter/32bpp_base.cpp index c6be9f3240..4115c11d4e 100644 --- a/src/blitter/32bpp_base.cpp +++ b/src/blitter/32bpp_base.cpp @@ -15,20 +15,20 @@ 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::SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) +void Blitter_32bppBase::SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32) { *((Colour *)video + x + y * _screen.pitch) = colour32; } -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) { @@ -36,7 +36,7 @@ void Blitter_32bppBase::DrawLine(void *video, int x, int y, int x2, int y2, int }); } -void Blitter_32bppBase::SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) +void Blitter_32bppBase::SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch) { Colour *dst = (Colour *)video + x + y * _screen.pitch; do { @@ -51,17 +51,17 @@ void Blitter_32bppBase::SetRect(void *video, int x, int y, const uint8 *colours, } while (--lines); } -void Blitter_32bppBase::SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch) +void Blitter_32bppBase::SetRect32(void *video, int x, int y, const uint32_t *colours, uint lines, uint width, uint pitch) { - uint32 *dst = (uint32 *)video + x + y * _screen.pitch; + uint32_t *dst = (uint32_t *)video + x + y * _screen.pitch; do { - memcpy(dst, colours, width * sizeof(uint32)); + memcpy(dst, colours, width * sizeof(uint32_t)); dst += _screen.pitch; colours += pitch; } while (--lines); } -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); @@ -71,22 +71,22 @@ 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::DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour) +void Blitter_32bppBase::DrawRectAt(void *video, int x, int y, int width, int height, uint8_t colour) { this->Blitter_32bppBase::DrawRect((Colour *)video + x + y * _screen.pitch, width, height, colour); } 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; } @@ -94,11 +94,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; } @@ -106,11 +106,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; } @@ -118,12 +118,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 */ @@ -142,13 +142,13 @@ void Blitter_32bppBase::ScrollBuffer(void *video, int left, int top, int width, } 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). */ @@ -168,7 +168,7 @@ void Blitter_32bppBase::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(uint32)); + memmove(dst, src, width * sizeof(uint32_t)); src += _screen.pitch; dst += _screen.pitch; } @@ -177,7 +177,7 @@ void Blitter_32bppBase::ScrollBuffer(void *video, int left, int top, int width, 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 &) @@ -185,22 +185,22 @@ void Blitter_32bppBase::PaletteAnimate(const 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 0f774f4c5e..f1f05ee362 100644 --- a/src/blitter/32bpp_base.hpp +++ b/src/blitter/32bpp_base.hpp @@ -24,13 +24,13 @@ public: } void *MoveTo(void *video, int x, int y) override; - void SetPixel(void *video, int x, int y, uint8 colour) override; - void SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) 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 SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) override; - void SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch) override; - void DrawRect(void *video, int width, int height, uint8 colour) override; - void DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour) override; + void SetPixel(void *video, int x, int y, uint8_t colour) override; + void SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32) 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 SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch) override; + void SetRect32(void *video, int x, int y, const uint32_t *colours, uint lines, uint width, uint pitch) override; + void DrawRect(void *video, int width, int height, uint8_t colour) override; + void DrawRectAt(void *video, int x, int y, 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; @@ -125,7 +125,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; @@ -138,7 +138,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); } @@ -164,9 +164,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 (likely(brightness == DEFAULT_BRIGHTNESS)) return colour; @@ -174,9 +174,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 af839b78a6..483c45fc58 100644 --- a/src/blitter/32bpp_optimized.cpp +++ b/src/blitter/32bpp_optimized.cpp @@ -31,18 +31,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 */ @@ -56,11 +56,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 */ @@ -153,7 +153,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)]; @@ -168,7 +168,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 { @@ -308,14 +308,14 @@ 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_SPR_COUNT]; + uint16_t *dst_n_orig[ZOOM_LVL_SPR_COUNT]; /* lengths of streams */ - uint32 lengths[ZOOM_LVL_SPR_COUNT][2]; + uint32_t lengths[ZOOM_LVL_SPR_COUNT][2]; ZoomLevel zoom_min; ZoomLevel zoom_max; - uint8 missing_zoom_levels = 0; + uint8_t missing_zoom_levels = 0; if (sprite[ZOOM_LVL_NORMAL].type == SpriteType::Font) { zoom_min = ZOOM_LVL_NORMAL; @@ -341,17 +341,17 @@ template Sprite *Blitter_32bppOptimized::EncodeInternal(const } Colour * const px_buffer = MallocT(px_size); - uint16 * const n_buffer = MallocT(n_size); + uint16_t * const n_buffer = MallocT(n_size); Colour *px_buffer_next = px_buffer; - uint16 *n_buffer_next = n_buffer; + uint16_t *n_buffer_next = n_buffer; for (ZoomLevel z = zoom_min; z <= zoom_max; z++) { const SpriteLoader::Sprite *src_orig = &sprite[z]; dst_px_orig[z] = px_buffer_next; dst_n_orig[z] = n_buffer_next; - uint32 *dst_px_ln = (uint32 *)px_buffer_next; - uint32 *dst_n_ln = (uint32 *)n_buffer_next; + uint32_t *dst_px_ln = (uint32_t *)px_buffer_next; + uint32_t *dst_n_ln = (uint32_t *)n_buffer_next; const SpriteLoader::CommonPixel *src = (const SpriteLoader::CommonPixel *)src_orig->data; @@ -365,16 +365,16 @@ template Sprite *Blitter_32bppOptimized::EncodeInternal(const 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++; *dst_len = 0; 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) { @@ -396,7 +396,7 @@ template Sprite *Blitter_32bppOptimized::EncodeInternal(const *dst_n = 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; @@ -411,7 +411,7 @@ template Sprite *Blitter_32bppOptimized::EncodeInternal(const if (src->m >= PALETTE_ANIM_START) flags &= ~BSF_NO_ANIM; /* 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; @@ -450,20 +450,20 @@ 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 lengths[z][1] = (byte *)dst_n_ln - (byte *)dst_n_orig[z]; px_buffer_next = (Colour *)dst_px_ln; - n_buffer_next = (uint16 *)dst_n_ln; + n_buffer_next = (uint16_t *)dst_n_ln; } uint len = 0; // total length of data @@ -490,7 +490,7 @@ template Sprite *Blitter_32bppOptimized::EncodeInternal(const /* Store sprite flags. */ dst->flags = flags; - uint32 next_offset = 0; + uint32_t next_offset = 0; for (ZoomLevel z = zoom_min; z <= zoom_max; z++) { dst->offset[z][0] = next_offset; dst->offset[z][1] = lengths[z][0] + next_offset; diff --git a/src/blitter/32bpp_optimized.hpp b/src/blitter/32bpp_optimized.hpp index bad52a652e..44b0d3fb70 100644 --- a/src/blitter/32bpp_optimized.hpp +++ b/src/blitter/32bpp_optimized.hpp @@ -18,8 +18,8 @@ public: /** Data stored about a (single) sprite. */ struct SpriteData { BlitterSpriteFlags flags; - uint32 offset[ZOOM_LVL_SPR_COUNT][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information. - byte data[]; ///< Data, all zoomlevels. + uint32_t offset[ZOOM_LVL_SPR_COUNT][2]; ///< Offsets (from .data) to streams for different zoom levels, and the normal and remap image information. + byte data[]; ///< Data, all zoomlevels. }; Blitter_32bppOptimized() diff --git a/src/blitter/32bpp_simple.cpp b/src/blitter/32bpp_simple.cpp index 403e0e81a3..41d5f3d730 100644 --- a/src/blitter/32bpp_simple.cpp +++ b/src/blitter/32bpp_simple.cpp @@ -61,7 +61,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 { @@ -159,7 +159,7 @@ Sprite *Blitter_32bppSimple::Encode(const SpriteLoader::SpriteCollection &sprite 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 61490d668c..df154ce57d 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 ac9686fd39..8c3e721ebf 100644 --- a/src/blitter/32bpp_sse2.cpp +++ b/src/blitter/32bpp_sse2.cpp @@ -22,13 +22,13 @@ static FBlitter_32bppSSE2 iFBlitter_32bppSSE2; Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &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; ZoomLevel zoom_max = ZOOM_LVL_NORMAL; - uint8 missing_zoom_levels = 0; + uint8_t missing_zoom_levels = 0; if (sprite[ZOOM_LVL_NORMAL].type != SpriteType::Font) { zoom_min = _settings_client.gui.zoom_min; zoom_max = (ZoomLevel) std::min(_settings_client.gui.zoom_max, ZOOM_LVL_DRAW_SPR); @@ -52,7 +52,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri 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; @@ -91,7 +91,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri dst_mv->m = src->m; if (z >= _settings_client.gui.disable_water_animation && src->m >= 245 && src->m <= 254) { /* 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 = Blitter_32bppBase::DEFAULT_BRIGHTNESS; @@ -108,7 +108,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri 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. */ @@ -124,7 +124,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri } } else { dst_rgba->data = 0; - *(uint16*) dst_mv = 0; + *(uint16_t*) dst_mv = 0; } dst_rgba++; dst_mv++; @@ -133,7 +133,7 @@ Sprite *Blitter_32bppSSE_Base::Encode(const SpriteLoader::SpriteCollection &spri /* 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 f717159e42..7026a91c54 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); @@ -53,10 +53,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 { BlitterSpriteFlags flags; diff --git a/src/blitter/32bpp_sse_func.hpp b/src/blitter/32bpp_sse_func.hpp index c87333aa5a..9f8539f1c8 100644 --- a/src/blitter/32bpp_sse_func.hpp +++ b/src/blitter/32bpp_sse_func.hpp @@ -75,7 +75,7 @@ inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask) GNU_TARGET(SSE_TARGET) 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 @@ inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &distribu 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) { @@ -224,7 +224,7 @@ inline void Blitter_32bppSSE4::Draw(const Blitter::BlitterParams *bp, ZoomLevel const MapValue *src_mv_line = (const MapValue *) &sd->data[si->mv_offset] + bp->skip_top * si->sprite_width; const Colour *src_rgba_line = (const Colour *) ((const byte *) &sd->data[si->sprite_offset] + bp->skip_top * si->sprite_line_size); - uint32 bm_normal_brightness = 0; + uint32_t bm_normal_brightness = 0; if (mode == BM_NORMAL_WITH_BRIGHTNESS) { bm_normal_brightness = (DEFAULT_BRIGHTNESS + bp->brightness_adjust) << 8; bm_normal_brightness |= bm_normal_brightness << 16; @@ -304,7 +304,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) { @@ -320,12 +320,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]; @@ -414,7 +414,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 4a8e9f2793..7b88f53ba6 100644 --- a/src/blitter/40bpp_anim.cpp +++ b/src/blitter/40bpp_anim.cpp @@ -24,7 +24,7 @@ static FBlitter_40bppAnim iFBlitter_40bppAnim; -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); @@ -32,11 +32,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::SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) +void Blitter_40bppAnim::SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32) { if (_screen_disable_anim) { Blitter_32bppOptimized::SetPixel32(video, x, y, colour, colour32); @@ -44,20 +44,20 @@ void Blitter_40bppAnim::SetPixel32(void *video, int x, int y, uint8 colour, uint size_t y_offset = static_cast(y) * _screen.pitch; *((Colour *)video + x + y_offset) = colour32; - VideoDriver::GetInstance()->GetAnimBuffer()[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y_offset] = 0; + VideoDriver::GetInstance()->GetAnimBuffer()[((uint32_t *)video - (uint32_t *)_screen.dst_ptr) + x + y_offset] = 0; } } -void Blitter_40bppAnim::SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) +void Blitter_40bppAnim::SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch) { if (_screen_disable_anim) { Blitter_32bppOptimized::SetRect(video, x, y, colours, lines, width, pitch); } else { Colour *dst = (Colour *)video + x + y * _screen.pitch; - uint8 *dstanim = ((uint32 *)dst - (uint32 *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer(); + uint8_t *dstanim = ((uint32_t *)dst - (uint32_t *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer(); do { memset_colour(dst, _black_colour, width); - memcpy(dstanim, colours, width * sizeof(uint8)); + memcpy(dstanim, colours, width * sizeof(uint8_t)); dst += _screen.pitch; dstanim += _screen.pitch; colours += pitch; @@ -65,16 +65,16 @@ void Blitter_40bppAnim::SetRect(void *video, int x, int y, const uint8 *colours, } } -void Blitter_40bppAnim::SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch) +void Blitter_40bppAnim::SetRect32(void *video, int x, int y, const uint32_t *colours, uint lines, uint width, uint pitch) { if (_screen_disable_anim) { Blitter_32bppOptimized::SetRect32(video, x, y, colours, lines, width, pitch); } else { Colour *dst = (Colour *)video + x + y * _screen.pitch; - uint8 *dstanim = ((uint32 *)dst - (uint32 *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer(); + uint8_t *dstanim = ((uint32_t *)dst - (uint32_t *)_screen.dst_ptr) + VideoDriver::GetInstance()->GetAnimBuffer(); do { - memcpy((uint32 *)dst, colours, width * sizeof(uint32)); - memset(dstanim, 0, width * sizeof(uint8)); + memcpy((uint32_t *)dst, colours, width * sizeof(uint32_t)); + memset(dstanim, 0, width * sizeof(uint8_t)); dst += _screen.pitch; dstanim += _screen.pitch; colours += pitch; @@ -82,7 +82,7 @@ void Blitter_40bppAnim::SetRect32(void *video, int x, int y, const uint32 *colou } } -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() */ @@ -91,23 +91,23 @@ 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 { memset_colour((Colour *)video, _black_colour, width); memset(anim_line, colour, width); - video = (uint32 *)video + _screen.pitch; + video = (uint32_t *)video + _screen.pitch; anim_line += _screen.pitch; } while (--height); } -void Blitter_40bppAnim::DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour) +void Blitter_40bppAnim::DrawRectAt(void *video, int x, int y, int width, int height, uint8_t colour) { this->Blitter_40bppAnim::DrawRect((Colour *)video + x + y * _screen.pitch, width, height, colour); } -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() */ @@ -116,7 +116,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; @@ -136,24 +136,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; @@ -161,14 +161,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 */ @@ -228,7 +228,7 @@ inline void Blitter_40bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel case BM_COLOUR_REMAP_WITH_BRIGHTNESS: 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) { Colour c = *src_px; @@ -254,7 +254,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 = *src_px; @@ -355,7 +355,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) { @@ -425,7 +425,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 @@ -442,7 +442,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); @@ -454,7 +454,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]; @@ -474,21 +474,21 @@ Sprite *Blitter_40bppAnim::Encode(const SpriteLoader::SpriteCollection &sprite, 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; } } @@ -496,36 +496,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++) { @@ -540,9 +540,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) { @@ -559,7 +559,7 @@ void Blitter_40bppAnim::ScrollBuffer(void *video, int left, int top, int width, 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; } @@ -580,7 +580,7 @@ void Blitter_40bppAnim::ScrollBuffer(void *video, int left, int top, int width, 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; } @@ -591,7 +591,7 @@ void Blitter_40bppAnim::ScrollBuffer(void *video, int left, int top, int width, 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 45a1056462..38cc9c4dd2 100644 --- a/src/blitter/40bpp_anim.hpp +++ b/src/blitter/40bpp_anim.hpp @@ -18,13 +18,13 @@ class Blitter_40bppAnim : public Blitter_32bppOptimized { public: - void SetPixel(void *video, int x, int y, uint8 colour) override; - void SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) override; - void SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) override; - void SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch) override; - void DrawRect(void *video, int width, int height, uint8 colour) override; - void DrawRectAt(void *video, int x, int y, 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 SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32) override; + void SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch) override; + void SetRect32(void *video, int x, int y, const uint32_t *colours, uint lines, uint width, uint pitch) override; + void DrawRect(void *video, int width, int height, uint8_t colour) override; + void DrawRectAt(void *video, int x, int y, 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; @@ -41,7 +41,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 4a3424e92f..455db891b1 100644 --- a/src/blitter/8bpp_base.cpp +++ b/src/blitter/8bpp_base.cpp @@ -16,66 +16,66 @@ 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::SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) +void Blitter_8bppBase::SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32) { this->Blitter_8bppBase::SetPixel(video, x, y, 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::SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) +void Blitter_8bppBase::SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch) { - uint8 *dst = (uint8 *)video + x + y * _screen.pitch; + uint8_t *dst = (uint8_t *)video + x + y * _screen.pitch; do { - memcpy(dst, colours, width * sizeof(uint8)); + memcpy(dst, colours, width * sizeof(uint8_t)); dst += _screen.pitch; colours += pitch; } while (--lines); } -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::DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour) +void Blitter_8bppBase::DrawRectAt(void *video, int x, int y, int width, int height, uint8_t colour) { - this->Blitter_8bppBase::DrawRect((uint8 *)video + x + y * _screen.pitch, width, height, colour); + this->Blitter_8bppBase::DrawRect((uint8_t *)video + x + y * _screen.pitch, width, height, colour); } 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; } @@ -83,11 +83,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; } @@ -95,11 +95,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; } @@ -107,12 +107,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 */ @@ -131,13 +131,13 @@ void Blitter_8bppBase::ScrollBuffer(void *video, int left, int top, int width, i } 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). */ @@ -157,7 +157,7 @@ void Blitter_8bppBase::ScrollBuffer(void *video, int left, int top, int width, i /* 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 1ac30a15e6..517a3aa215 100644 --- a/src/blitter/8bpp_base.hpp +++ b/src/blitter/8bpp_base.hpp @@ -22,12 +22,12 @@ public: 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 SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) 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 SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) override; - void DrawRect(void *video, int width, int height, uint8 colour) override; - void DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour) override; + void SetPixel(void *video, int x, int y, uint8_t colour) override; + void SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32) 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 SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch) override; + void DrawRect(void *video, int width, int height, uint8_t colour) override; + void DrawRectAt(void *video, int x, int y, 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 50709aafee..6c8a88fb82 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; @@ -87,7 +87,7 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z case BM_COLOUR_REMAP: case BM_CRASH_REMAP: case BM_COLOUR_REMAP_WITH_BRIGHTNESS: { - const uint8 *remap = bp->remap; + const uint8_t *remap = bp->remap; do { uint m = remap[*src]; if (m != 0) *dst = m; diff --git a/src/blitter/8bpp_optimized.hpp b/src/blitter/8bpp_optimized.hpp index eb655c50ac..62cc2e9ef5 100644 --- a/src/blitter/8bpp_optimized.hpp +++ b/src/blitter/8bpp_optimized.hpp @@ -18,8 +18,8 @@ class Blitter_8bppOptimized FINAL : public Blitter_8bppBase { public: /** Data stored about a (single) sprite. */ struct SpriteData { - uint32 offset[ZOOM_LVL_SPR_COUNT]; ///< Offsets (from .data) to streams for different zoom levels. - byte data[]; ///< Data, all zoomlevels. + uint32_t offset[ZOOM_LVL_SPR_COUNT]; ///< Offsets (from .data) to streams for different zoom levels. + byte data[]; ///< Data, all zoomlevels. }; void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) override; diff --git a/src/blitter/8bpp_simple.cpp b/src/blitter/8bpp_simple.cpp index 44993dba4b..7282d8daa7 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 056ce79802..35e7639799 100644 --- a/src/blitter/base.hpp +++ b/src/blitter/base.hpp @@ -45,10 +45,10 @@ DECLARE_ENUM_AS_BIT_SET(BlitterSpriteFlags); * How all blitters should look like. Extend this class to make your own. */ class Blitter : public SpriteEncoder { - uint8 screen_depth = 0; + uint8_t screen_depth = 0; protected: - void SetScreenDepth(uint8 depth) + void SetScreenDepth(uint8_t depth) { this->screen_depth = depth; this->SetIs32BppSupported(depth > 8); @@ -85,7 +85,7 @@ public: * Get the screen depth this blitter works for. * This is either: 8, 16, 24 or 32. */ - inline uint8 GetScreenDepth() const + inline uint8_t GetScreenDepth() const { return this->screen_depth; } @@ -123,7 +123,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; /** * Draw a pixel with a given 32bpp colour on the video-buffer. @@ -134,7 +134,7 @@ public: * @param colour A 8bpp mapping colour. * @param colour32 A 32bpp colour. */ - virtual void SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) = 0; + virtual void SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32) = 0; /** * Draw a rectangle of pixels on the video-buffer. @@ -146,7 +146,7 @@ public: * @param width The length of the lines. * @param pitch The pitch of the colours buffer */ - virtual void SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) = 0; + virtual void SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch) = 0; /** * Draw a rectangle of pixels on the video-buffer (no LookupColourInPalette). @@ -158,7 +158,7 @@ public: * @param width The length of the lines. * @param pitch The pitch of the colours buffer. */ - virtual void SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch) { NOT_REACHED(); }; + virtual void SetRect32(void *video, int x, int y, const uint32_t *colours, uint lines, uint width, uint pitch) { NOT_REACHED(); }; /** * Make a single horizontal line in a single colour on the video-buffer. @@ -167,7 +167,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; /** * Make a single horizontal line in a single colour on the video-buffer. @@ -178,7 +178,7 @@ public: * @param height The height of the line. * @param colour A 8bpp mapping colour. */ - virtual void DrawRectAt(void *video, int x, int y, int width, int height, uint8 colour) = 0; + virtual void DrawRectAt(void *video, int x, int y, int width, int height, uint8_t colour) = 0; /** * Draw a line with a given colour. @@ -193,7 +193,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 21b56bead7..d0da1b23bc 100644 --- a/src/blitter/common.hpp +++ b/src/blitter/common.hpp @@ -58,11 +58,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; @@ -97,8 +97,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; @@ -159,8 +159,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; @@ -200,12 +200,12 @@ void Blitter::DrawLineGeneric(int x1, int y1, int x2, int y2, int screen_width, } } -inline void memset_uint32(uint32 *s, uint32 c, size_t n) +inline void memset_uint32(uint32_t *s, uint32_t c, size_t n) { #ifdef __APPLE__ - memset_pattern4(static_cast(s), static_cast(&c), n * sizeof(uint32)); + memset_pattern4(static_cast(s), static_cast(&c), n * sizeof(uint32_t)); #else - if constexpr (sizeof(wchar_t) == sizeof(uint32)) { + if constexpr (sizeof(wchar_t) == sizeof(uint32_t)) { wmemset((wchar_t *)s, (wchar_t)c, n); } else { for (; n > 0; n--) { @@ -218,7 +218,7 @@ inline void memset_uint32(uint32 *s, uint32 c, size_t n) inline void memset_colour(Colour *s, Colour c, size_t n) { - memset_uint32((uint32 *)s, c.data, n); + memset_uint32((uint32_t *)s, c.data, n); } #endif /* BLITTER_COMMON_HPP */ diff --git a/src/blitter/null.hpp b/src/blitter/null.hpp index 4eceafb7cc..f6e737ab4c 100644 --- a/src/blitter/null.hpp +++ b/src/blitter/null.hpp @@ -25,13 +25,13 @@ public: void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) override {}; Sprite *Encode(const SpriteLoader::SpriteCollection &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 SetPixel32(void *video, int x, int y, uint8 colour, uint32 colour32) override {}; - void DrawRect(void *video, int width, int height, uint8 colour) override {}; - void DrawRectAt(void *video, int x, int y, 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 SetRect(void *video, int x, int y, const uint8 *colours, uint lines, uint width, uint pitch) override {}; - void SetRect32(void *video, int x, int y, const uint32 *colours, uint lines, uint width, uint pitch) override {}; + void SetPixel(void *video, int x, int y, uint8_t colour) override {}; + void SetPixel32(void *video, int x, int y, uint8_t colour, uint32_t colour32) override {}; + void DrawRect(void *video, int width, int height, uint8_t colour) override {}; + void DrawRectAt(void *video, int x, int y, 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 SetRect(void *video, int x, int y, const uint8_t *colours, uint lines, uint width, uint pitch) override {}; + void SetRect32(void *video, int x, int y, const uint32_t *colours, uint lines, uint width, uint pitch) 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..2aa59e3e23 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 - 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 + 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_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 7d6967f3b3..bfc653b29e 100644 --- a/src/bridge.h +++ b/src/bridge.h @@ -64,9 +64,9 @@ enum BridgeSpecCtrlFlags { struct BridgeSpec { 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 1c968a3c22..5941903b2a 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -59,7 +59,7 @@ typedef GUIList GUIBridgeList; ///< List of bridges, used in #B * - p2 = (bit 15-16) - transport type. * @param cmd unused */ -void CcBuildBridge(const CommandCost &result, TileIndex end_tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcBuildBridge(const CommandCost &result, TileIndex end_tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; if (_settings_client.sound.confirm) SndPlayTileFx(SND_27_CONSTRUCTION_BRIDGE, end_tile); @@ -92,7 +92,7 @@ private: /* Internal variables */ TileIndex start_tile; TileIndex end_tile; - uint32 type; + uint32_t type; GUIBridgeList bridges; int icon_width; ///< Scaled width of the the bridge icon sprite. Scrollbar *vscroll; @@ -120,7 +120,7 @@ private: return (TransportType)(this->type >> 15); } - void BuildBridge(uint8 i) + void BuildBridge(uint8_t i) { switch (this->GetTransportType()) { case TRANSPORT_RAIL: _last_railbridge_type = this->bridges.at(i).index; break; @@ -162,7 +162,7 @@ private: } public: - BuildBridgeWindow(WindowDesc *desc, TileIndex start, TileIndex end, uint32 br_type, GUIBridgeList &&bl) : Window(desc), + BuildBridgeWindow(WindowDesc *desc, TileIndex start, TileIndex end, uint32_t br_type, GUIBridgeList &&bl) : Window(desc), start_tile(start), end_tile(end), type(br_type), @@ -226,7 +226,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); @@ -258,9 +258,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(i); @@ -381,7 +381,7 @@ void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transpo * Bit 16,15 = transport type, * 14..8 = road/rail types, * 7..0 = type of bridge */ - uint32 type = (transport_type << 15) | (road_rail_type << 8); + uint32_t type = (transport_type << 15) | (road_rail_type << 8); /* The bridge length without ramps. */ const uint bridge_len = GetTunnelBridgeLength(start, end); @@ -457,7 +457,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; } else if (type_check.GetErrorMessage() != INVALID_STRING_ID && !query_per_bridge_type) { type_errmsg = type_check.GetErrorMessage(); diff --git a/src/bridge_map.cpp b/src/bridge_map.cpp index d9c3b94544..3c710a337b 100644 --- a/src/bridge_map.cpp +++ b/src/bridge_map.cpp @@ -82,14 +82,14 @@ int GetBridgeHeight(TileIndex t) std::unordered_map _long_bridge_signal_sim_map; -SignalState GetBridgeEntranceSimulatedSignalStateExtended(TileIndex t, uint16 signal) +SignalState GetBridgeEntranceSimulatedSignalStateExtended(TileIndex t, uint16_t signal) { const auto it = _long_bridge_signal_sim_map.find(t); if (it != _long_bridge_signal_sim_map.end()) { const LongBridgeSignalStorage &lbss = it->second; - uint16 offset = signal - BRIDGE_M2_SIGNAL_STATE_COUNT; - uint16 slot = offset >> 6; - uint16 bit = offset & 0x3F; + uint16_t offset = signal - BRIDGE_M2_SIGNAL_STATE_COUNT; + uint16_t slot = offset >> 6; + uint16_t bit = offset & 0x3F; if (slot >= lbss.signal_red_bits.size()) return SIGNAL_STATE_GREEN; return GB(lbss.signal_red_bits[slot], bit, 1) ? SIGNAL_STATE_RED : SIGNAL_STATE_GREEN; } else { @@ -97,14 +97,14 @@ SignalState GetBridgeEntranceSimulatedSignalStateExtended(TileIndex t, uint16 si } } -void SetBridgeEntranceSimulatedSignalStateExtended(TileIndex t, uint16 signal, SignalState state) +void SetBridgeEntranceSimulatedSignalStateExtended(TileIndex t, uint16_t signal, SignalState state) { LongBridgeSignalStorage &lbss = _long_bridge_signal_sim_map[t]; - uint16 offset = signal - BRIDGE_M2_SIGNAL_STATE_COUNT; - uint16 slot = offset >> 6; - uint16 bit = offset & 0x3F; + uint16_t offset = signal - BRIDGE_M2_SIGNAL_STATE_COUNT; + uint16_t slot = offset >> 6; + uint16_t bit = offset & 0x3F; if (slot >= lbss.signal_red_bits.size()) lbss.signal_red_bits.resize(slot + 1); - SB(lbss.signal_red_bits[slot], bit, 1, (uint64) ((state == SIGNAL_STATE_RED) ? 1 : 0)); + SB(lbss.signal_red_bits[slot], bit, 1, (uint64_t) ((state == SIGNAL_STATE_RED) ? 1 : 0)); _m[t].m2 |= BRIDGE_M2_SIGNAL_STATE_EXT_FLAG; } @@ -132,7 +132,7 @@ void ClearBridgeEntranceSimulatedSignalsExtended(TileIndex t) SB(_m[t].m2, BRIDGE_M2_SIGNAL_STATE_OFFSET, BRIDGE_M2_SIGNAL_STATE_FIELD_SIZE, 0); } -void ShiftBridgeEntranceSimulatedSignalsExtended(TileIndex t, int shift, uint64 in) +void ShiftBridgeEntranceSimulatedSignalsExtended(TileIndex t, int shift, uint64_t in) { if (shift > 0) { /* shift into array */ @@ -147,7 +147,7 @@ void ShiftBridgeEntranceSimulatedSignalsExtended(TileIndex t, int shift, uint64 } const size_t orig_size = lbss->signal_red_bits.size(); size_t i = orig_size; - auto insert_bits = [&](uint64 bits, size_t pos) { + auto insert_bits = [&](uint64_t bits, size_t pos) { if (bits) { if (pos >= lbss->signal_red_bits.size()) lbss->signal_red_bits.resize(pos + 1); lbss->signal_red_bits[pos] |= bits; @@ -155,7 +155,7 @@ void ShiftBridgeEntranceSimulatedSignalsExtended(TileIndex t, int shift, uint64 }; while (i) { i--; - uint64 out = GB(lbss->signal_red_bits[i], 64 - shift, shift); + uint64_t out = GB(lbss->signal_red_bits[i], 64 - shift, shift); lbss->signal_red_bits[i] <<= shift; insert_bits(out, i + 1); } @@ -171,11 +171,11 @@ void ClearBridgeSimulatedSignalMapping() _long_bridge_signal_sim_map.clear(); } -btree::btree_set _bridge_signal_style_map; +btree::btree_set _bridge_signal_style_map; static_assert(MAX_MAP_TILES_BITS + 4 <= 32); static_assert(1 << 4 <= MAX_NEW_SIGNAL_STYLES + 1); -void SetBridgeSignalStyle(TileIndex t, uint8 style) +void SetBridgeSignalStyle(TileIndex t, uint8_t style) { if (style == 0) { /* No style allocated before */ @@ -192,7 +192,7 @@ void SetBridgeSignalStyle(TileIndex t, uint8 style) } } -uint8 GetBridgeSignalStyleExtended(TileIndex t) +uint8_t GetBridgeSignalStyleExtended(TileIndex t) { auto iter = _bridge_signal_style_map.lower_bound(t << 4); if (iter != _bridge_signal_style_map.end() && *iter >> 4 == t) return (*iter) & 0xF; diff --git a/src/bridge_signal_map.h b/src/bridge_signal_map.h index 9870568bba..35c2aea78b 100644 --- a/src/bridge_signal_map.h +++ b/src/bridge_signal_map.h @@ -20,14 +20,14 @@ #include struct LongBridgeSignalStorage { - std::vector signal_red_bits; + std::vector signal_red_bits; }; extern std::unordered_map _long_bridge_signal_sim_map; -extern btree::btree_set _bridge_signal_style_map; +extern btree::btree_set _bridge_signal_style_map; -SignalState GetBridgeEntranceSimulatedSignalStateExtended(TileIndex t, uint16 signal); +SignalState GetBridgeEntranceSimulatedSignalStateExtended(TileIndex t, uint16_t signal); enum { BRIDGE_M2_SIGNAL_STATE_COUNT = 11, @@ -36,7 +36,7 @@ enum { BRIDGE_M2_SIGNAL_STATE_EXT_FLAG = 0x8000, }; -inline SignalState GetBridgeEntranceSimulatedSignalState(TileIndex t, uint16 signal) +inline SignalState GetBridgeEntranceSimulatedSignalState(TileIndex t, uint16_t signal) { if (signal < BRIDGE_M2_SIGNAL_STATE_COUNT) { return GB(_m[t].m2, signal + BRIDGE_M2_SIGNAL_STATE_OFFSET, 1) ? SIGNAL_STATE_RED : SIGNAL_STATE_GREEN; @@ -45,9 +45,9 @@ inline SignalState GetBridgeEntranceSimulatedSignalState(TileIndex t, uint16 sig } } -void SetBridgeEntranceSimulatedSignalStateExtended(TileIndex t, uint16 signal, SignalState state); +void SetBridgeEntranceSimulatedSignalStateExtended(TileIndex t, uint16_t signal, SignalState state); -inline void SetBridgeEntranceSimulatedSignalState(TileIndex t, uint16 signal, SignalState state) +inline void SetBridgeEntranceSimulatedSignalState(TileIndex t, uint16_t signal, SignalState state) { if (signal < BRIDGE_M2_SIGNAL_STATE_COUNT) { SB(_m[t].m2, signal + BRIDGE_M2_SIGNAL_STATE_OFFSET, 1, (state == SIGNAL_STATE_RED) ? 1 : 0); @@ -82,13 +82,13 @@ inline void ClearBridgeEntranceSimulatedSignals(TileIndex t) void ClearBridgeSimulatedSignalMapping(); -void SetBridgeSignalStyle(TileIndex t, uint8 style); +void SetBridgeSignalStyle(TileIndex t, uint8_t style); -inline uint8 GetBridgeSignalStyle(TileIndex t) +inline uint8_t GetBridgeSignalStyle(TileIndex t) { if (likely(!HasBit(_m[t].m3, 7))) return 0; - extern uint8 GetBridgeSignalStyleExtended(TileIndex t); + extern uint8_t GetBridgeSignalStyleExtended(TileIndex t); return GetBridgeSignalStyleExtended(t); } diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 23bd2fa084..99b9235335 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -573,7 +573,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; @@ -601,7 +601,7 @@ static bool AircraftEngineCapacityVsRunningCostSorter(const GUIEngineListItem &a 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); @@ -616,8 +616,8 @@ static bool AircraftEngineCapacityVsRunningCostSorter(const GUIEngineListItem &a */ 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; @@ -904,7 +904,7 @@ static int DrawRoadVehPurchaseInfo(int left, int right, int y, EngineID engine_n y += GetCharacterHeight(FS_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); @@ -1056,7 +1056,7 @@ static int DrawAircraftPurchaseInfo(int left, int right, int y, EngineID engine_ y += GetCharacterHeight(FS_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); @@ -1074,7 +1074,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); @@ -1217,7 +1217,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 }; @@ -1314,7 +1314,7 @@ void DrawEngineList(VehicleType type, const Rect &r, const GUIEngineList &eng_li */ void DisplayVehicleSortDropDown(Window *w, const VehicleType vehicle_type, const int selected, const 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 @@ -1925,7 +1925,7 @@ struct BuildVehicleWindow : BuildVehicleWindowBase { EngineID sel_eng = this->sel_engine; if (sel_eng != INVALID_ENGINE) { CommandCallback *callback; - uint32 cmd; + uint32_t cmd; if (this->virtual_train_mode) { callback = CcAddVirtualEngine; cmd = CMD_BUILD_VIRTUAL_RAIL_VEHICLE; @@ -2072,7 +2072,7 @@ struct BuildVehicleWindow : BuildVehicleWindowBase { 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 @@ -2247,7 +2247,7 @@ static const StringID _sort_listing_wagon[8] = { */ void DisplayLocomotiveSortDropDown(Window *w, int selected) { - uint32 hidden_mask = 0; + uint32_t hidden_mask = 0; /* Disable sorting by tractive effort when the original acceleration model for trains is being used. */ if (_settings_game.vehicle.train_acceleration_model == AM_ORIGINAL) { SetBit(hidden_mask, 4); // tractive effort @@ -2262,7 +2262,7 @@ void DisplayLocomotiveSortDropDown(Window *w, int selected) */ void DisplayWagonSortDropDown(Window *w, int selected) { - uint32 hidden_mask = 0; + uint32_t hidden_mask = 0; /* Disable sorting by maximum speed when wagon speed is disabled. */ if (!_settings_game.vehicle.wagon_speed_limits) { SetBit(hidden_mask, 2); // maximum speed @@ -2700,7 +2700,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase { { if (selected != INVALID_ENGINE) { CommandCallback *callback; - uint32 cmd; + uint32_t cmd; if (this->virtual_train_mode) { callback = CcAddVirtualEngine; cmd = CMD_BUILD_VIRTUAL_RAIL_VEHICLE; @@ -3058,8 +3058,8 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase { case WID_BV_LIST_LOCO: { DrawEngineList(this->vehicle_type, r, this->loco.eng_list, this->loco.vscroll->GetPosition(), - std::min(this->loco.vscroll->GetPosition() + this->loco.vscroll->GetCapacity(), - static_cast(this->loco.eng_list.size())), this->loco.sel_engine, false, + std::min(this->loco.vscroll->GetPosition() + this->loco.vscroll->GetCapacity(), + static_cast(this->loco.eng_list.size())), this->loco.sel_engine, false, DEFAULT_GROUP); break; } @@ -3072,8 +3072,8 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase { case WID_BV_LIST_WAGON: { DrawEngineList(this->vehicle_type, r, this->wagon.eng_list, this->wagon.vscroll->GetPosition(), - std::min(this->wagon.vscroll->GetPosition() + this->wagon.vscroll->GetCapacity(), - static_cast(this->wagon.eng_list.size())), this->wagon.sel_engine, false, + std::min(this->wagon.vscroll->GetPosition() + this->wagon.vscroll->GetCapacity(), + static_cast(this->wagon.eng_list.size())), this->wagon.sel_engine, false, DEFAULT_GROUP); break; } @@ -3229,7 +3229,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase { } }; -void CcAddVirtualEngine(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcAddVirtualEngine(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; @@ -3243,7 +3243,7 @@ void CcAddVirtualEngine(const CommandCost &result, TileIndex tile, uint32 p1, ui } } -void CcMoveNewVirtualEngine(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcMoveNewVirtualEngine(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; diff --git a/src/cargo_type.h b/src/cargo_type.h index 48af1a7ed9..b5710e899a 100644 --- a/src/cargo_type.h +++ b/src/cargo_type.h @@ -77,7 +77,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; @@ -123,7 +123,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 c85e9b88c0..7837d175bd 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 3c7f1677d6..c9e3237689 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 btree::btree_map CargoMonitorMap; @@ -63,7 +63,7 @@ inline CargoMonitorID EncodeCargoIndustryMonitor(CompanyID company, CargoID ctyp 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 @@ inline CargoMonitorID EncodeCargoTownMonitor(CompanyID company, CargoID ctype, T 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 @@ 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 9f4405888f..aafd23eb9a 100644 --- a/src/cargopacket.cpp +++ b/src/cargopacket.cpp @@ -28,7 +28,7 @@ CargoPacketPool _cargopacket_pool("CargoPacket"); INSTANTIATE_POOL_METHODS(CargoPacket) -btree::btree_map _cargo_packet_deferred_payments; +btree::btree_map _cargo_packet_deferred_payments; void ClearCargoPacketDeferredPayments() { _cargo_packet_deferred_payments.clear(); @@ -36,10 +36,10 @@ void ClearCargoPacketDeferredPayments() { void ChangeOwnershipOfCargoPacketDeferredPayments(Owner old_owner, Owner new_owner) { - std::vector> to_merge; + std::vector> to_merge; auto iter = _cargo_packet_deferred_payments.begin(); while (iter != _cargo_packet_deferred_payments.end()) { - uint64 k = iter->first; + uint64_t k = iter->first; if ((CompanyID) GB(k, 24, 8) == old_owner) { if (new_owner != INVALID_OWNER) { SB(k, 24, 8, new_owner); @@ -55,9 +55,9 @@ void ChangeOwnershipOfCargoPacketDeferredPayments(Owner old_owner, Owner new_own } } -inline uint64 CargoPacketDeferredPaymentKey(CargoPacketID id, CompanyID cid, VehicleType type) +inline uint64_t CargoPacketDeferredPaymentKey(CargoPacketID id, CompanyID cid, VehicleType type) { - return (((uint64) id) << 32) | (cid << 24) | (type << 22); + return (((uint64_t) id) << 32) | (cid << 24) | (type << 22); } template @@ -194,7 +194,7 @@ CargoPacket *CargoPacket::Split(uint new_size) this->feeder_share -= fs; if (this->flags & CPF_HAS_DEFERRED_PAYMENT) { - std::vector> to_add; + std::vector> to_add; IterateCargoPacketDeferredPayments(this->index, false, [&](Money &payment, CompanyID cid, VehicleType type) { Money share = payment * new_size / static_cast(this->count); payment -= share; @@ -220,7 +220,7 @@ void CargoPacket::Merge(CargoPacket *cp) this->feeder_share += cp->feeder_share; if (cp->flags & CPF_HAS_DEFERRED_PAYMENT) { - std::vector> to_merge; + std::vector> to_merge; IterateCargoPacketDeferredPayments(cp->index, true, [&](Money &payment, CompanyID cid, VehicleType type) { to_merge.push_back({ CargoPacketDeferredPaymentKey(this->index, cid, type), payment }); }); diff --git a/src/cargopacket.h b/src/cargopacket.h index b419240f96..69b474f7eb 100644 --- a/src/cargopacket.h +++ b/src/cargopacket.h @@ -23,7 +23,7 @@ #include "3rdparty/cpp-btree/btree_map.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. */ @@ -57,14 +57,14 @@ private: int32_t y; }; - uint16 count = 0; ///< The amount of cargo in this packet. - uint16 periods_in_transit = 0; ///< Amount of cargo aging periods this packet has been in transit. + uint16_t count = 0; ///< The amount of cargo in this packet. + uint16_t periods_in_transit = 0; ///< Amount of cargo aging periods this packet has been in transit. Money feeder_share = 0; ///< Value of feeder pickup to be paid for on delivery of cargo. TileIndex source_xy = INVALID_TILE; ///< The origin of the cargo. Vector travelled = {0, 0}; ///< If cargo is in station: the vector from the unload tile to the source tile. If in vehicle: an intermediate value. SourceID source_id = INVALID_SOURCE; ///< Index of industry/town/HQ, INVALID_SOURCE if unknown/invalid. SourceType source_type = SourceType::Industry; ///< Type of \c source_id. - uint8 flags = 0; ///< NOSAVE: temporary flags + uint8_t flags = 0; ///< NOSAVE: temporary flags StationID first_station = INVALID_STATION; ///< The station where the cargo came from first. StationID next_hop = INVALID_STATION; ///< Station where the cargo wants to go next. @@ -84,7 +84,7 @@ private: friend void Load_CPDP(); 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 first_station, uint16_t count, SourceType source_type, SourceID source_id); @@ -166,7 +166,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; } @@ -201,7 +201,7 @@ public: * it is capped at UINT16_MAX. * @return Length this cargo has been in transit. */ - inline uint16 GetPeriodsInTransit() const + inline uint16_t GetPeriodsInTransit() const { return this->periods_in_transit; } @@ -318,10 +318,10 @@ 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. + uint count; ///< Cache for the number of cargo entities. + 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. + Tcont packets; ///< The cargo packets in this list. void AddToCache(const CargoPacket *cp); @@ -364,7 +364,7 @@ public: return this->count; } - inline uint64 CargoPeriodsInTransit() const + inline uint64_t CargoPeriodsInTransit() const { return this->cargo_periods_in_transit; } diff --git a/src/cargotype.cpp b/src/cargotype.cpp index fdc50de45c..736d0396e1 100644 --- a/src/cargotype.cpp +++ b/src/cargotype.cpp @@ -128,7 +128,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_BITNUM) return CT_INVALID; @@ -209,7 +209,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++; @@ -220,7 +220,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 bf09eff0b8..55d0bed328 100644 --- a/src/cargotype.h +++ b/src/cargotype.h @@ -20,7 +20,7 @@ #include /** Globally unique label of a cargo type. */ -typedef uint32 CargoLabel; +typedef uint32_t CargoLabel; /** Town growth effect when delivering cargo. */ enum TownEffect { @@ -55,29 +55,29 @@ static const byte INVALID_CARGO_BITNUM = 0xFF; ///< Constant representing invali /** Specification of a cargo type. */ struct CargoSpec { - CargoLabel label; ///< Unique label of the cargo type. - uint8 bitnum{INVALID_CARGO_BITNUM}; ///< Cargo bit number, is #INVALID_CARGO_BITNUM for a non-used spec. - 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{0x100}; ///< Capacity multiplier for vehicles. (8 fractional bits) - uint16 classes; ///< Classes of this cargo type. @see CargoClass - int32 initial_payment; ///< Initial payment rate before inflation is applied. - uint8 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 - - StringID name; ///< Name of this type of cargo. - StringID name_single; ///< Name of a single entity of this type of cargo. - StringID units_volume; ///< Name of a single unit of cargo of this type. - StringID quantifier; ///< Text for multiple units of cargo of this type. - StringID abbrev; ///< Two letter abbreviation for this cargo type. - - SpriteID sprite; ///< Icon to display this cargo type, may be \c 0xFFF (which means to resolve an action123 chain). - - const struct GRFFile *grffile; ///< NewGRF where #group belongs to. + CargoLabel label; ///< Unique label of the cargo type. + uint8_t bitnum{INVALID_CARGO_BITNUM}; ///< Cargo bit number, is #INVALID_CARGO_BITNUM for a non-used spec. + 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{0x100}; ///< Capacity multiplier for vehicles. (8 fractional bits) + uint16_t classes; ///< Classes of this cargo type. @see CargoClass + 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_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. + StringID units_volume; ///< Name of a single unit of cargo of this type. + StringID quantifier; ///< Text for multiple units of cargo of this type. + StringID abbrev; ///< Two letter abbreviation for this cargo type. + + SpriteID sprite; ///< Icon to display this cargo type, may be \c 0xFFF (which means to resolve an action123 chain). + + const struct GRFFile *grffile; ///< NewGRF where #group belongs to. const struct SpriteGroup *group; Money current_payment; @@ -132,12 +132,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 @@ -193,7 +193,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); Dimension GetLargestCargoIconSize(); diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index fa1101d0d5..acf3a6b006 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -45,7 +45,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. @@ -56,9 +56,9 @@ static int32 _money_cheat_amount = 10000000; * @param p2 is -1 or +1 (down/up) * @return Amount of money cheat. */ -static int32 ClickMoneyCheat(int32 p1, int32 p2) +static int32_t ClickMoneyCheat(int32_t p1, int32_t p2) { - DoCommandPEx(0, 0, 0, (uint64)(p2 * _money_cheat_amount), _network_server || _network_settings_access ? CMD_MONEY_CHEAT_ADMIN : CMD_MONEY_CHEAT); + DoCommandPEx(0, 0, 0, (uint64_t)(p2 * _money_cheat_amount), _network_server || _network_settings_access ? CMD_MONEY_CHEAT_ADMIN : CMD_MONEY_CHEAT); return _money_cheat_amount; } @@ -68,7 +68,7 @@ static int32 ClickMoneyCheat(int32 p1, int32 p2) * @param p2 is -1 or +1 (down/up) * @return The new company. */ -static int32 ClickChangeCompanyCheat(int32 p1, int32 p2) +static int32_t ClickChangeCompanyCheat(int32_t p1, int32_t p2) { while ((uint)p1 < Company::GetPoolSize()) { if (Company::IsValidID((CompanyID)p1)) { @@ -87,7 +87,7 @@ static int32 ClickChangeCompanyCheat(int32 p1, int32 p2) * @param p2 unused * @return New value allowing change of industry production. */ -static int32 ClickSetProdCheat(int32 p1, int32 p2) +static int32_t ClickSetProdCheat(int32_t p1, int32_t p2) { _cheats.setup_prod.value = (p1 != 0); InvalidateWindowClassesData(WC_INDUSTRY_VIEW); @@ -102,7 +102,7 @@ extern void EnginesMonthlyLoop(); * @param p2 +1 (increase) or -1 (decrease). * @return New year. */ -static int32 ClickChangeDateCheat(int32 p1, int32 p2) +static int32_t ClickChangeDateCheat(int32_t p1, int32_t p2) { /* Don't allow changing to an invalid year, or the current year. */ p1 = Clamp(p1, MIN_YEAR, MAX_YEAR); @@ -135,14 +135,14 @@ static int32 ClickChangeDateCheat(int32 p1, int32 p2) * @return New value (or unchanged old value) of the maximum * allowed heightlevel value. */ -static int32 ClickChangeMaxHlCheat(int32 p1, int32 p2) +static int32_t ClickChangeMaxHlCheat(int32_t p1, int32_t p2) { p1 = Clamp(p1, 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 < MapSize(); t++) { - if ((int32)TileHeight(t) > p1) { + if ((int32_t)TileHeight(t) > p1) { ShowErrorMessage(STR_CONFIG_SETTING_TOO_HIGH_MOUNTAIN, INVALID_STRING_ID, WL_ERROR); /* Return old, unchanged value */ return _settings_game.construction.map_height_limit; @@ -164,7 +164,7 @@ static int32 ClickChangeMaxHlCheat(int32 p1, int32 p2) * @param p1 The new value. * @param p2 Change direction (+1, +1), \c 0 for boolean settings. */ -typedef int32 CheckButtonClick(int32 p1, int32 p2); +typedef int32_t CheckButtonClick(int32_t p1, int32_t p2); enum CheatNetworkMode { CNM_ALL, @@ -282,7 +282,7 @@ struct CheatWindow : Window { /* Draw [<][>] boxes for settings of an integer-type */ DrawArrowButtons(button_left, y + button_y_offset, COLOUR_YELLOW, clicked - (i * 2), true, true); - uint64 val = (uint64)ReadValue(ce->variable, SLE_UINT64); + uint64_t val = (uint64_t)ReadValue(ce->variable, SLE_UINT64); SetDParam(0, val * 1000 >> 16); SetDParam(1, 3); break; @@ -297,7 +297,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); @@ -397,7 +397,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) { @@ -418,7 +418,7 @@ struct CheatWindow : Window { return; } else if (ce->type == SLF_ALLOW_CONTROL && x >= 20 + this->box.width + SETTING_BUTTON_WIDTH) { clicked_widget = btn; - uint64 val = (uint64)ReadValue(ce->variable, SLE_UINT64); + uint64_t val = (uint64_t)ReadValue(ce->variable, SLE_UINT64); SetDParam(0, val * 1000 >> 16); SetDParam(1, 3); StringID str = (btn == CHT_INFLATION_COST) ? STR_CHEAT_INFLATION_COST_QUERY_CAPT : STR_CHEAT_INFLATION_INCOME_QUERY_CAPT; @@ -445,10 +445,10 @@ struct CheatWindow : Window { switch (ce->type) { case SLF_ALLOW_CONTROL: { /* Change inflation factors */ - uint64 oldvalue = (uint64)ReadValue(ce->variable, SLE_UINT64); - uint64 value = oldvalue + (uint64)(get_arrow_button_value() << 16); - value = Clamp(value, 1 << 16, MAX_INFLATION); - DoCommandP(0, (uint32)btn, (uint32)value, CMD_CHEAT_SETTING); + uint64_t oldvalue = (uint64_t)ReadValue(ce->variable, SLE_UINT64); + uint64_t value = oldvalue + (uint64_t)(get_arrow_button_value() << 16); + value = Clamp(value, 1 << 16, MAX_INFLATION); + DoCommandP(0, (uint32_t)btn, (uint32_t)value, CMD_CHEAT_SETTING); if (value != oldvalue) register_arrow_button_clicked(); break; } @@ -470,9 +470,9 @@ struct CheatWindow : Window { if (value != oldvalue) { if (_networking || btn == CHT_STATION_RATING || btn == CHT_TOWN_RATING) { - if (btn != CHT_MONEY) DoCommandP(0, (uint32)btn, (uint32)value, CMD_CHEAT_SETTING); + if (btn != CHT_MONEY) DoCommandP(0, (uint32_t)btn, (uint32_t)value, CMD_CHEAT_SETTING); } else { - WriteValue(ce->variable, ce->type, (int64)value); + WriteValue(ce->variable, ce->type, (int64_t)value); } } @@ -498,7 +498,7 @@ struct CheatWindow : Window { char tmp_buffer[32]; strecpy(tmp_buffer, str, lastof(tmp_buffer)); str_replace_wchar(tmp_buffer, lastof(tmp_buffer), GetDecimalSeparatorChar(), '.'); - DoCommandP(0, (uint32)clicked_widget, (uint32)Clamp(atof(tmp_buffer) * 65536.0, 1 << 16, MAX_INFLATION), CMD_CHEAT_SETTING); + DoCommandP(0, (uint32_t)clicked_widget, (uint32_t)Clamp(atof(tmp_buffer) * 65536.0, 1 << 16, MAX_INFLATION), CMD_CHEAT_SETTING); return; } if (ce->mode == CNM_MONEY) { @@ -508,12 +508,12 @@ struct CheatWindow : Window { } if (_networking) return; - 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 2d43c59a33..7e332f12f6 100644 --- a/src/clear_cmd.cpp +++ b/src/clear_cmd.cpp @@ -80,7 +80,7 @@ inline SpriteID GetSpriteIDForRocksUsingOffset(const uint slope_to_sprite_offset return ((HasGrfMiscBit(GMB_SECOND_ROCKY_TILE_SET) && (TileHash(x, y) & 1)) ? SPR_FLAT_ROCKY_LAND_2 : SPR_FLAT_ROCKY_LAND_1) + slope_to_sprite_offset; } -bool DrawCustomSpriteIDForRocks(const TileInfo *ti, uint8 slope_to_sprite_offset, bool require_snow_flag) +bool DrawCustomSpriteIDForRocks(const TileInfo *ti, uint8_t slope_to_sprite_offset, bool require_snow_flag) { for (const GRFFile *grf : _new_landscape_rocks_grfs) { if (require_snow_flag && !HasBit(grf->new_landscape_ctrl_flags, NLCF_ROCKS_DRAW_SNOWY_ENABLED)) continue; @@ -166,7 +166,7 @@ static void DrawTile_Clear(TileInfo *ti, DrawTileProcParams params) case CLEAR_ROCKS: if (!params.no_ground_tiles) { - uint8 slope_to_sprite_offset = SlopeToSpriteOffset(ti->tileh); + uint8_t slope_to_sprite_offset = SlopeToSpriteOffset(ti->tileh); if (DrawCustomSpriteIDForRocks(ti, slope_to_sprite_offset, false)) break; DrawGroundSprite(GetSpriteIDForRocksUsingOffset(slope_to_sprite_offset, ti->x, ti->y), PAL_NONE); } @@ -181,7 +181,7 @@ static void DrawTile_Clear(TileInfo *ti, DrawTileProcParams params) case CLEAR_SNOW: if (!params.no_ground_tiles) { - uint8 slope_to_sprite_offset = SlopeToSpriteOffset(ti->tileh); + uint8_t slope_to_sprite_offset = SlopeToSpriteOffset(ti->tileh); if (GetRawClearGround(ti->tile) == CLEAR_ROCKS && !_new_landscape_rocks_grfs.empty()) { if (DrawCustomSpriteIDForRocks(ti, slope_to_sprite_offset, true)) break; } @@ -401,7 +401,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 ac43b76bf7..d702dbd705 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -585,7 +585,7 @@ ClientID _cmd_client_id = INVALID_CLIENT_ID; /** * List of flags for a command log entry */ -enum CommandLogEntryFlag : uint16 { +enum CommandLogEntryFlag : uint16_t { CLEF_NONE = 0x00, ///< no flag is set CLEF_CMD_FAILED = 0x01, ///< command failed CLEF_GENERATING_WORLD = 0x02, ///< generating world @@ -602,27 +602,27 @@ enum CommandLogEntryFlag : uint16 { }; DECLARE_ENUM_AS_BIT_SET(CommandLogEntryFlag) -extern uint32 _frame_counter; +extern uint32_t _frame_counter; struct CommandLogEntry { std::string text; TileIndex tile; - uint32 p1; - uint32 p2; - uint32 cmd; - uint64 p3; + uint32_t p1; + uint32_t p2; + uint32_t cmd; + uint64_t p3; Date date; DateFract date_fract; - uint8 tick_skip_counter; + uint8_t tick_skip_counter; CompanyID current_company; CompanyID local_company; CommandLogEntryFlag log_flags; ClientID client_id; - uint32 frame_counter; + uint32_t frame_counter; CommandLogEntry() { } - CommandLogEntry(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd, CommandLogEntryFlag log_flags, std::string text) + CommandLogEntry(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd, CommandLogEntryFlag log_flags, std::string text) : text(text), tile(tile), p1(p1), p2(p2), cmd(cmd), p3(p3), date(_date), date_fract(_date_fract), tick_skip_counter(_tick_skip_counter), current_company(_current_company), local_company(_local_company), log_flags(log_flags), client_id(_cmd_client_id), frame_counter(_frame_counter) { } }; @@ -734,7 +734,7 @@ char *DumpCommandLog(char *buffer, const char *last, std::function _temp_store; + extern TemporaryStorageArray _temp_store; if (!this->aux_data) { this->AllocAuxData(); @@ -1355,12 +1355,12 @@ void CommandCost::UseTextRefStack(const GRFFile *grffile, uint num_registers) std::string CommandCost::SummaryMessage(StringID cmd_msg) const { if (this->Succeeded()) { - return stdstr_fmt("Success: cost: " OTTD_PRINTF64, (int64) this->GetCost()); + return stdstr_fmt("Success: cost: " OTTD_PRINTF64, (int64_t) this->GetCost()); } else { const uint textref_stack_size = this->GetTextRefStackSize(); if (textref_stack_size > 0) StartTextRefStackUsage(this->GetTextRefStackGRF(), textref_stack_size, this->GetTextRefStack()); - std::string buf = stdstr_fmt("Failed: cost: " OTTD_PRINTF64, (int64) this->GetCost()); + std::string buf = stdstr_fmt("Failed: cost: " OTTD_PRINTF64, (int64_t) this->GetCost()); if (cmd_msg != 0) { buf += ' '; GetString(StringBuilder(buf), cmd_msg); @@ -1416,7 +1416,7 @@ void CommandCost::SetTile(TileIndex tile) } } -void CommandCost::SetResultData(uint32 result) +void CommandCost::SetResultData(uint32_t result) { this->flags |= CCIF_VALID_RESULT; diff --git a/src/command_aux.h b/src/command_aux.h index 72ee23a1ab..d8f53785b9 100644 --- a/src/command_aux.h +++ b/src/command_aux.h @@ -18,12 +18,12 @@ #include struct CommandDeserialisationBuffer : public BufferDeserialisationHelper { - const uint8 *buffer; + const uint8_t *buffer; size_t size; size_t pos = 0; bool error = false; - CommandDeserialisationBuffer(const uint8 *buffer, size_t size) : buffer(buffer), size(size) {} + CommandDeserialisationBuffer(const uint8_t *buffer, size_t size) : buffer(buffer), size(size) {} const byte *GetDeserialisationBuffer() const { return this->buffer; } size_t GetDeserialisationBufferSize() const { return this->size; } @@ -61,14 +61,14 @@ struct CommandAuxiliarySerialised : public CommandAuxiliaryBase { return new CommandAuxiliarySerialised(*this); } - virtual std::optional> GetDeserialisationSrc() const override { return span(this->serialised_data.data(), this->serialised_data.size()); } + virtual std::optional> GetDeserialisationSrc() const override { return span(this->serialised_data.data(), this->serialised_data.size()); } virtual void Serialise(CommandSerialisationBuffer &buffer) const override { buffer.Send_binary(this->serialised_data.data(), this->serialised_data.size()); } }; template struct CommandAuxiliarySerialisable : public CommandAuxiliaryBase { - virtual std::optional> GetDeserialisationSrc() const override { return {}; } + virtual std::optional> GetDeserialisationSrc() const override { return {}; } CommandAuxiliaryBase *Clone() const override { @@ -86,7 +86,7 @@ public: inline CommandCost Load(const CommandAuxiliaryBase *base) { if (base == nullptr) return CMD_ERROR; - std::optional> deserialise_from = base->GetDeserialisationSrc(); + std::optional> deserialise_from = base->GetDeserialisationSrc(); if (deserialise_from.has_value()) { this->store = T(); CommandDeserialisationBuffer buffer(deserialise_from->begin(), deserialise_from->size()); diff --git a/src/command_func.h b/src/command_func.h index 2407a50bc4..04a6d7a95c 100644 --- a/src/command_func.h +++ b/src/command_func.h @@ -32,9 +32,9 @@ static const CommandCost CMD_ERROR = CommandCost(INVALID_STRING_ID); */ #define return_cmd_error(errcode) return CommandCost(errcode); -CommandCost DoCommandEx(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, DoCommandFlag flags, uint32 cmd, const char *text = nullptr, const CommandAuxiliaryBase *aux_data = nullptr); +CommandCost DoCommandEx(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, DoCommandFlag flags, uint32_t cmd, const char *text = nullptr, const CommandAuxiliaryBase *aux_data = nullptr); -inline CommandCost DoCommand(TileIndex tile, uint32 p1, uint32 p2, DoCommandFlag flags, uint32 cmd, const char *text = nullptr) +inline CommandCost DoCommand(TileIndex tile, uint32_t p1, uint32_t p2, DoCommandFlag flags, uint32_t cmd, const char *text = nullptr) { return DoCommandEx(tile, p1, p2, 0, flags, cmd, text, 0); } @@ -43,9 +43,9 @@ inline CommandCost DoCommand(const CommandContainer *container, DoCommandFlag fl return DoCommandEx(container->tile, container->p1, container->p2, container->p3, flags, container->cmd & CMD_ID_MASK, container->text.c_str(), container->aux_data.get()); } -bool DoCommandPEx(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd, CommandCallback *callback = nullptr, const char *text = nullptr, const CommandAuxiliaryBase *aux_data = nullptr, bool my_cmd = true); +bool DoCommandPEx(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd, CommandCallback *callback = nullptr, const char *text = nullptr, const CommandAuxiliaryBase *aux_data = nullptr, bool my_cmd = true); -inline bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = nullptr, const char *text = nullptr, bool my_cmd = true) +inline bool DoCommandP(TileIndex tile, uint32_t p1, uint32_t p2, uint32_t cmd, CommandCallback *callback = nullptr, const char *text = nullptr, bool my_cmd = true) { return DoCommandPEx(tile, p1, p2, 0, cmd, callback, text, 0, my_cmd); } @@ -55,18 +55,18 @@ inline bool DoCommandP(const CommandContainer *container, bool my_cmd = true) return DoCommandPEx(container->tile, container->p1, container->p2, container->p3, container->cmd, container->callback, container->text.c_str(), container->aux_data.get(), my_cmd); } -CommandCost DoCommandPScript(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only, bool asynchronous, const CommandAuxiliaryBase *aux_data); -CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only, const CommandAuxiliaryBase *aux_data); +CommandCost DoCommandPScript(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only, bool asynchronous, const CommandAuxiliaryBase *aux_data); +CommandCost DoCommandPInternal(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd, CommandCallback *callback, const char *text, bool my_cmd, bool estimate_only, const CommandAuxiliaryBase *aux_data); -void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company, const CommandAuxiliaryBase *aux_data); +void NetworkSendCommand(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd, CommandCallback *callback, const char *text, CompanyID company, const CommandAuxiliaryBase *aux_data); extern Money _additional_cash_required; -bool IsValidCommand(uint32 cmd); -CommandFlags GetCommandFlags(uint32 cmd); -const char *GetCommandName(uint32 cmd); +bool IsValidCommand(uint32_t cmd); +CommandFlags GetCommandFlags(uint32_t cmd); +const char *GetCommandName(uint32_t cmd); Money GetAvailableMoneyForCommand(); -bool IsCommandAllowedWhilePaused(uint32 cmd); +bool IsCommandAllowedWhilePaused(uint32_t cmd); /** * Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags diff --git a/src/command_type.h b/src/command_type.h index bb58057caf..baa3990f46 100644 --- a/src/command_type.h +++ b/src/command_type.h @@ -19,7 +19,7 @@ struct GRFFile; -enum CommandCostIntlFlags : uint8 { +enum CommandCostIntlFlags : uint8_t { CCIF_NONE = 0, CCIF_SUCCESS = 1 << 0, CCIF_INLINE_EXTRA_MSG = 1 << 1, @@ -39,18 +39,18 @@ class CommandCost { CommandCostIntlFlags flags; ///< Flags: see CommandCostIntlFlags StringID message; ///< Warning message for when success is unset union { - uint32 result = 0; + uint32_t result = 0; StringID extra_message; ///< Additional warning message for when success is unset TileIndex tile; } inl; struct CommandCostAuxiliaryData { - uint32 textref_stack[16] = {}; + uint32_t textref_stack[16] = {}; const GRFFile *textref_stack_grffile = nullptr; ///< NewGRF providing the #TextRefStack content. - uint textref_stack_size = 0; ///< Number of uint32 values to put on the #TextRefStack for the error message. + uint textref_stack_size = 0; ///< 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 TileIndex tile = INVALID_TILE; - uint32 result = 0; + uint32_t result = 0; }; std::unique_ptr aux_data; @@ -160,8 +160,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 { @@ -170,9 +170,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 this->aux_data != nullptr ? this->aux_data->textref_stack : nullptr; } @@ -254,13 +254,13 @@ public: return (this->flags & CCIF_VALID_RESULT); } - uint32 GetResultData() const + uint32_t GetResultData() const { if (this->flags & CCIF_INLINE_RESULT) return this->inl.result; return this->aux_data != nullptr ? this->aux_data->result : 0; } - void SetResultData(uint32 result); + void SetResultData(uint32_t result); }; /** @@ -651,8 +651,8 @@ struct CommandAuxiliaryBase; * @param text Additional text * @return The CommandCost of the command, which can be succeeded or failed. */ -typedef CommandCost CommandProc(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text); -typedef CommandCost CommandProcEx(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data); +typedef CommandCost CommandProc(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text); +typedef CommandCost CommandProcEx(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data); /** * Define a command with the flags which belongs to it. @@ -674,7 +674,7 @@ struct Command { Command(CommandProcEx *procex, const char *name, CommandFlags flags, CommandType type) : procex(procex), name(name), flags(flags | CMD_PROCEX), type(type) {} - inline CommandCost Execute(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) const { + inline CommandCost Execute(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) const { if (this->flags & CMD_PROCEX) { return this->procex(tile, flags, p1, p2, p3, text, aux_data); } else { @@ -697,7 +697,7 @@ struct Command { * @param p3 Additional data of the command * @see CommandProc */ -typedef void CommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd); +typedef void CommandCallback(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd); #define MAX_CMD_TEXT_LENGTH 32000 @@ -708,7 +708,7 @@ struct CommandAuxiliaryBase { virtual CommandAuxiliaryBase *Clone() const = 0; - virtual std::optional> GetDeserialisationSrc() const = 0; + virtual std::optional> GetDeserialisationSrc() const = 0; virtual void Serialise(CommandSerialisationBuffer &buffer) const = 0; }; @@ -740,16 +740,16 @@ private: */ struct CommandContainer { TileIndex tile; ///< tile command being executed on. - uint32 p1; ///< parameter p1. - uint32 p2; ///< parameter p2. - uint32 cmd; ///< command being executed. - uint64 p3; ///< parameter p3. (here for alignment) + uint32_t p1; ///< parameter p1. + uint32_t p2; ///< parameter p2. + uint32_t cmd; ///< command being executed. + uint64_t p3; ///< parameter p3. (here for alignment) CommandCallback *callback; ///< any callback function executed upon successful completion of the command. std::string text; ///< possible text sent for name changes etc. CommandAuxiliaryPtr aux_data; ///< Auxiliary command data }; -inline CommandContainer NewCommandContainerBasic(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback = nullptr) +inline CommandContainer NewCommandContainerBasic(TileIndex tile, uint32_t p1, uint32_t p2, uint32_t cmd, CommandCallback *callback = nullptr) { return { tile, p1, p2, cmd, 0, callback, {}, nullptr }; } diff --git a/src/company_base.h b/src/company_base.h index 9b16870f6a..f864754d66 100644 --- a/src/company_base.h +++ b/src/company_base.h @@ -21,31 +21,31 @@ /** Statistics about the economy. */ struct CompanyEconomyEntry { - Money income; ///< The amount of income. - Money expenses; ///< The amount of expenses. + 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) - Money company_value; ///< The value of the company. + 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; char *Dump(char *buffer, const char *last) const; }; @@ -63,12 +63,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. @@ -92,14 +92,14 @@ struct CompanyProperties { CompanyID bankrupt_last_asked; ///< Which company was most recently asked about buying it? CompanyBankruptcyFlags bankrupt_flags; ///< bankruptcy flags 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 purchase_land_limit; ///< Amount of tiles we can (still) purchase (times 65536). - uint32 build_object_limit; ///< Amount of tiles we can (still) build objects on (times 65536). + 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 purchase_land_limit; ///< Amount of tiles we can (still) purchase (times 65536). + uint32_t build_object_limit; ///< Amount of tiles we can (still) build objects on (times 65536). /** * If \c true, the company is (also) controlled by the computer (a NoAI program). @@ -127,7 +127,7 @@ struct CompanyProperties { }; struct Company : CompanyPool::PoolItem<&_company_pool>, CompanyProperties { - 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 f03d609bb8..0fc1126150 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -60,7 +60,7 @@ CompanyManagerFace _company_manager_face; ///< for company manager face storage uint _cur_company_tick_index; ///< used to generate a name for one company that doesn't have a name yet per tick CompanyMask _saved_PLYP_invalid_mask; -std::vector _saved_PLYP_data; +std::vector _saved_PLYP_data; CompanyPool _company_pool("Company"); ///< Pool of companies. INSTANTIATE_POOL_METHODS(Company) @@ -70,16 +70,16 @@ 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->terraform_limit = (uint32_t)_settings_game.construction.terraform_frame_burst << 16; this->clear_limit = _settings_game.construction.clear_frame_burst << 16; - this->tree_limit = (uint32)(uint32)_settings_game.construction.tree_frame_burst << 16; - this->purchase_land_limit = (uint32)_settings_game.construction.purchase_land_frame_burst << 16; - this->build_object_limit = (uint32)_settings_game.construction.build_object_frame_burst << 16; + this->tree_limit = (uint32_t)(uint32_t)_settings_game.construction.tree_frame_burst << 16; + this->purchase_land_limit = (uint32_t)_settings_game.construction.purchase_land_frame_burst << 16; + this->build_object_limit = (uint32_t)_settings_game.construction.build_object_frame_burst << 16; std::fill(this->share_owners.begin(), this->share_owners.end(), INVALID_OWNER); InvalidateWindowData(WC_PERFORMANCE_DETAIL, 0, INVALID_COMPANY); @@ -386,7 +386,7 @@ static void GenerateCompanyName(Company *c) Town *t = ClosestTownFromTile(c->last_build_coordinate, UINT_MAX); StringID str; - uint32 strp; + uint32_t strp; std::string buffer; if (t->name.empty() && IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST + 1)) { str = t->townnametype - SPECSTR_TOWNNAME_START + SPECSTR_COMPANY_NAME_START; @@ -588,7 +588,7 @@ Company *DoStartupNewCompany(DoStartupNewCompanyFlag flags, CompanyID 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); std::fill(c->share_owners.begin(), c->share_owners.end(), INVALID_OWNER); @@ -631,7 +631,7 @@ TimeoutTimer _new_competitor_timeout(0, []() { if (_networking && Company::GetNumItems() >= _settings_client.network.max_companies) return; /* count number of competitors */ - uint8 n = 0; + uint8_t n = 0; for (const Company *c : Company::Iterate()) { if (c->is_ai) n++; } @@ -730,7 +730,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()) { @@ -789,11 +789,11 @@ void OnTick_Companies(bool main_tick) } 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, start as many competitors as needed then check every ~10 minutes if a company went bankrupt and needs replacing. */ if (timeout == 0) { /* count number of competitors */ - uint8 n = 0; + uint8_t n = 0; for (const Company *cc : Company::Iterate()) { if (cc->is_ai) n++; } @@ -892,7 +892,7 @@ void CompanyAdminRemove(CompanyID company_id, CompanyRemoveReason reason) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { InvalidateWindowData(WC_COMPANY_LEAGUE, 0, 0); CompanyID company_id = (CompanyID)GB(p1, 16, 8); @@ -1042,7 +1042,7 @@ CommandCost CmdCompanyCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdSetCompanyManagerFace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSetCompanyManagerFace(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { CompanyManagerFace cmf = (CompanyManagerFace)p2; @@ -1080,7 +1080,7 @@ void UpdateCompanyLiveries(Company *c) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Colours colour = Extract(p2); LiveryScheme scheme = Extract(p1); @@ -1193,7 +1193,7 @@ static bool IsUniqueCompanyName(const char *name) * @param text the new name or an empty string when resetting to the default * @return the cost of this operation or an error */ -CommandCost CmdRenameCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRenameCompany(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { bool reset = StrEmpty(text); @@ -1239,7 +1239,7 @@ static bool IsUniquePresidentName(const char *name) * @param text the new name or an empty string when resetting to the default * @return the cost of this operation or an error */ -CommandCost CmdRenamePresident(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRenamePresident(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { bool reset = StrEmpty(text); @@ -1307,9 +1307,9 @@ CompanyID GetDefaultLocalCompany() * 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]; } @@ -1320,9 +1320,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_gui.cpp b/src/company_gui.cpp index 3cce6e7803..61029ba589 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -636,7 +636,7 @@ public: /** Company livery colour scheme window. */ struct SelectCompanyLiveryWindow : public Window { private: - uint32 sel; + uint32_t sel; LiveryClass livery_class; Dimension square; uint rows; @@ -645,9 +645,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; @@ -1876,14 +1876,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); } @@ -1966,17 +1966,17 @@ struct CompanyInfrastructureWindow : Window case WID_CI_COUNT: { /* 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)); @@ -2102,7 +2102,7 @@ struct CompanyInfrastructureWindow : Window case WID_CI_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(width, y, c->infrastructure.rail[rt], RailMaintenanceCost(rt, c->infrastructure.rail[rt], rail_total)); @@ -2114,7 +2114,7 @@ struct CompanyInfrastructureWindow : Window y += GetCharacterHeight(FS_NORMAL) + EXP_SPACING; - uint32 road_total = c->infrastructure.GetRoadTotal(); + uint32_t road_total = c->infrastructure.GetRoadTotal(); for (const auto &rt : _sorted_roadtypes) { if (HasBit(this->roadtypes, rt) && RoadTypeIsRoad(rt)) { this->DrawCountLine(width, y, c->infrastructure.road[rt], RoadMaintenanceCost(rt, c->infrastructure.road[rt], road_total)); @@ -2123,7 +2123,7 @@ struct CompanyInfrastructureWindow : Window y += GetCharacterHeight(FS_NORMAL) + EXP_SPACING; - uint32 tram_total = c->infrastructure.GetTramTotal(); + uint32_t tram_total = c->infrastructure.GetTramTotal(); for (const auto &rt : _sorted_roadtypes) { if (HasBit(this->roadtypes, rt) && RoadTypeIsTram(rt)) { this->DrawCountLine(width, y, c->infrastructure.road[rt], RoadMaintenanceCost(rt, c->infrastructure.road[rt], tram_total)); diff --git a/src/company_manager_face.h b/src/company_manager_face.h index 73dd210639..0d8cc68da6 100644 --- a/src/company_manager_face.h +++ b/src/company_manager_face.h @@ -129,7 +129,7 @@ inline void SetCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFac */ 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 eaa06b41b7..8ff1f5697a 100644 --- a/src/company_type.h +++ b/src/company_type.h @@ -50,10 +50,10 @@ template <> struct EnumPropsT : MakeEnumPropsT= MapSize()) { IConsolePrint(CC_ERROR, "Tile does not exist"); @@ -392,7 +392,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 >= MapSizeX() || y >= MapSizeY()) { IConsolePrint(CC_ERROR, "Tile does not exist"); @@ -427,7 +427,7 @@ DEF_CONSOLE_CMD(ConHighlightTile) return true; case 2: { - uint32 result; + uint32_t result; if (GetArgumentInteger(&result, argv[1])) { if (result >= MapSize()) { IConsolePrint(CC_ERROR, "Tile does not exist"); @@ -440,7 +440,7 @@ DEF_CONSOLE_CMD(ConHighlightTile) } case 3: { - uint32 x, y; + uint32_t x, y; if (GetArgumentInteger(&x, argv[1]) && GetArgumentInteger(&y, argv[2])) { if (x >= MapSizeX() || y >= MapSizeY()) { IConsolePrint(CC_ERROR, "Tile does not exist"); @@ -1651,10 +1651,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) { @@ -1907,7 +1907,7 @@ DEF_CONSOLE_CMD(ConCompanies) IConsolePrintF(CC_INFO, "#:%d(%s) Company Name: '%s' Year Founded: %d Money: " OTTD_PRINTF64 " Loan: " OTTD_PRINTF64 " Value: " OTTD_PRINTF64 " (T:%d, R:%d, P:%d, S:%d) %s", c->index + 1, GetStringPtr(STR_COLOUR_DARK_BLUE + _company_colours[c->index]), company_name.c_str(), - 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, @@ -2512,7 +2512,7 @@ DEF_CONSOLE_CMD(ConDeleteVehicleID) } if (argc == 2) { - uint32 result; + uint32_t result; if (GetArgumentInteger(&result, argv[1])) { extern void ConsoleRemoveVehicle(VehicleID id); ConsoleRemoveVehicle(result); @@ -2531,18 +2531,18 @@ DEF_CONSOLE_CMD(ConRunTileLoopTile) } if (argc >= 2) { - uint32 tile; + uint32_t tile; if (!GetArgumentInteger(&tile, argv[1])) return false; if (tile >= MapSize()) { IConsolePrint(CC_ERROR, "Tile does not exist"); return true; } - uint32 count = 1; + uint32_t count = 1; if (argc >= 3) { if (!GetArgumentInteger(&count, argv[2])) return false; } - for (uint32 i = 0; i < count; i++) { + for (uint32_t i = 0; i < count; i++) { _tile_type_procs[GetTileType(tile)]->tile_loop_proc(tile); } return true; @@ -2758,22 +2758,22 @@ DEF_CONSOLE_CMD(ConDumpRoadTypes) IConsolePrintF(CC_DEFAULT, " T = disallow tunnels"); IConsolePrintF(CC_DEFAULT, " c = disallow collisions with trains for vehicles of this type"); - btree::btree_map grfs; + btree::btree_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) { - uint32 str_grfid = GetStringGRFID(rti->strings.name); + uint32_t str_grfid = GetStringGRFID(rti->strings.name); if (str_grfid != 0) { - extern GRFFile *GetFileByGRFID(uint32 grfid); + extern GRFFile *GetFileByGRFID(uint32_t grfid); grf = GetFileByGRFID(grfid); } } if (grf != nullptr) { grfid = grf->grfid; - grfs.insert(std::pair(grfid, grf)); + grfs.insert(std::pair(grfid, grf)); } IConsolePrintF(CC_DEFAULT, " %02u %s %c%c%c%c, Flags: %c%c%c%c%c, Extra Flags: %c%c%c%c, GRF: %08X, %s", (uint) rt, @@ -2816,22 +2816,22 @@ DEF_CONSOLE_CMD(ConDumpRailTypes) IConsolePrintF(CC_DEFAULT, " p = signal graphics callback enabled for programmable pre-signals"); IConsolePrintF(CC_DEFAULT, " r = signal graphics callback restricted signal flag enabled"); - btree::btree_map grfs; + btree::btree_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) { - uint32 str_grfid = GetStringGRFID(rti->strings.name); + uint32_t str_grfid = GetStringGRFID(rti->strings.name); if (str_grfid != 0) { - extern GRFFile *GetFileByGRFID(uint32 grfid); + extern GRFFile *GetFileByGRFID(uint32_t grfid); grf = GetFileByGRFID(grfid); } } if (grf != nullptr) { grfid = grf->grfid; - grfs.insert(std::pair(grfid, grf)); + grfs.insert(std::pair(grfid, grf)); } IConsolePrintF(CC_DEFAULT, " %02u %c%c%c%c, Flags: %c%c%c%c%c%c, Ctrl Flags: %c%c%c%c, GRF: %08X, %s", (uint) rt, @@ -2869,10 +2869,10 @@ DEF_CONSOLE_CMD(ConDumpBridgeTypes) IConsolePrintF(CC_DEFAULT, " t = not available to towns"); IConsolePrintF(CC_DEFAULT, " s = not available to scripts (AI/GS)"); - btree::btree_set grfids; + btree::btree_set grfids; for (BridgeType bt = 0; bt < MAX_BRIDGES; bt++) { const BridgeSpec *spec = GetBridgeSpec(bt); - uint32 grfid = GetStringGRFID(spec->material); + uint32_t grfid = GetStringGRFID(spec->material); if (grfid != 0) grfids.insert(grfid); IConsolePrintF(CC_DEFAULT, " %02u Year: %7u, Min: %3u, Max: %5u, Flags: %02X, Ctrl Flags: %c%c%c%c, Pillars: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X, GRF: %08X, %s", (uint) bt, @@ -2900,8 +2900,8 @@ DEF_CONSOLE_CMD(ConDumpBridgeTypes) GetStringPtr(spec->material) ); } - for (uint32 grfid : grfids) { - extern GRFFile *GetFileByGRFID(uint32 grfid); + for (uint32_t grfid : grfids) { + extern GRFFile *GetFileByGRFID(uint32_t grfid); const GRFFile *grffile = GetFileByGRFID(grfid); IConsolePrintF(CC_DEFAULT, " GRF: %08X = %s", BSWAP32(grfid), grffile ? grffile->filename.c_str() : "????"); } @@ -2928,22 +2928,22 @@ DEF_CONSOLE_CMD(ConDumpCargoTypes) IConsolePrintF(CC_DEFAULT, " c = covered/sheltered"); IConsolePrintF(CC_DEFAULT, " S = special"); - btree::btree_map grfs; + btree::btree_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) { - uint32 str_grfid = GetStringGRFID(spec->name); + uint32_t str_grfid = GetStringGRFID(spec->name); if (str_grfid != 0) { - extern GRFFile *GetFileByGRFID(uint32 grfid); + extern GRFFile *GetFileByGRFID(uint32_t grfid); grf = GetFileByGRFID(grfid); } } if (grf != nullptr) { grfid = grf->grfid; - grfs.insert(std::pair(grfid, grf)); + grfs.insert(std::pair(grfid, grf)); } IConsolePrintF(CC_DEFAULT, " %02u Bit: %2u, Label: %c%c%c%c, Callback mask: 0x%02X, Cargo class: %c%c%c%c%c%c%c%c%c%c%c, GRF: %08X, %s", (uint) i, @@ -3009,7 +3009,7 @@ DEF_CONSOLE_CMD(ConDumpTile) return true; case 2: { - uint32 result; + uint32_t result; if (GetArgumentInteger(&result, argv[1])) { if (result >= MapSize()) { IConsolePrint(CC_ERROR, "Tile does not exist"); @@ -3023,7 +3023,7 @@ DEF_CONSOLE_CMD(ConDumpTile) } case 3: { - uint32 x, y; + uint32_t x, y; if (GetArgumentInteger(&x, argv[1]) && GetArgumentInteger(&y, argv[2])) { if (x >= MapSizeX() || y >= MapSizeY()) { IConsolePrint(CC_ERROR, "Tile does not exist"); @@ -3090,14 +3090,14 @@ DEF_CONSOLE_CMD(ConDumpSignalStyles) IConsolePrintF(CC_DEFAULT, " r = realistic braking only"); IConsolePrintF(CC_DEFAULT, " Extra aspects: %u", _extra_aspects); - btree::btree_map grfs; - for (uint8 i = 0; i < _num_new_signal_styles; i++) { + btree::btree_map grfs; + for (uint8_t i = 0; i < _num_new_signal_styles; i++) { const NewSignalStyle &style = _new_signal_styles[i]; - uint32 grfid = 0; + uint32_t grfid = 0; if (style.grffile != nullptr) { grfid = style.grffile->grfid; - grfs.insert(std::pair(grfid, style.grffile)); + grfs.insert(std::pair(grfid, style.grffile)); } IConsolePrintF(CC_DEFAULT, " %2u: GRF: %08X, Local: %2u, Extra aspects: %3u, Flags: %c%c%c%c%c%c%c, %s", (uint) (i + 1), @@ -3236,7 +3236,7 @@ DEF_CONSOLE_CMD(ConViewportDebug) return true; } - extern uint32 _viewport_debug_flags; + extern uint32_t _viewport_debug_flags; if (argc == 1) { IConsolePrintF(CC_DEFAULT, "Viewport debug flags: %X", _viewport_debug_flags); } else { @@ -3297,7 +3297,7 @@ DEF_CONSOLE_CMD(ConGfxDebug) return true; } - extern uint32 _gfx_debug_flags; + extern uint32_t _gfx_debug_flags; if (argc == 1) { IConsolePrintF(CC_DEFAULT, "Gfx debug flags: %X", _gfx_debug_flags); } else { @@ -3549,7 +3549,7 @@ DEF_CONSOLE_CMD(ConNewGRFProfile) if (started > 0) { IConsolePrintF(CC_DEBUG, "Started profiling for GRFID%s %s", (started > 1) ? "s" : "", grfids.c_str()); if (argc >= 3) { - uint64 ticks = std::max(atoi(argv[2]), 1); + uint64_t ticks = std::max(atoi(argv[2]), 1); NewGRFProfiler::StartTimer(ticks); IConsolePrintF(CC_DEBUG, "Profiling will automatically stop after %u ticks.", (uint)ticks); } @@ -3609,7 +3609,7 @@ DEF_CONSOLE_CMD(ConRailTypeMapColourCtl) } RailType rt = (RailType)atoi(argv[1]); - uint8 map_colour = atoi(argv[2]); + uint8_t map_colour = atoi(argv[2]); if (rt >= RAILTYPE_END) return true; extern RailTypeInfo _railtypes[RAILTYPE_END]; diff --git a/src/console_gui.cpp b/src/console_gui.cpp index 68d88058b5..8723dee46f 100644 --- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -40,7 +40,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) { @@ -206,7 +206,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; @@ -485,8 +485,8 @@ static void IConsoleTabCompletion() const char *cmdp = cmd_name; while (true) { const char *end = cmdp; - WChar a = Utf8Consume(cp); - WChar b = Utf8Consume(cmdp); + char32_t a = Utf8Consume(cp); + char32_t b = Utf8Consume(cmdp); if (a == 0 || b == 0 || a != b) { common_prefix.resize(end - cmd_name); break; diff --git a/src/console_internal.h b/src/console_internal.h index 43081c0e31..ac7c9caf54 100644 --- a/src/console_internal.h +++ b/src/console_internal.h @@ -84,7 +84,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 6026903805..ca4abca2bb 100644 --- a/src/core/bitmath_func.cpp +++ b/src/core/bitmath_func.cpp @@ -14,7 +14,7 @@ #ifndef WITH_BITMATH_BUILTINS -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, @@ -25,13 +25,13 @@ const uint8 _ffb_64[64] = { 3, 0, 1, 0, 2, 0, 1, 0, }; -uint8 FindFirstBit32(uint32 x) +uint8_t FindFirstBit32(uint32_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 & 0x0000ffff) == 0) { x >>= 16; pos += 16; } if ((x & 0x000000ff) == 0) { x >>= 8; pos += 8; } @@ -42,11 +42,11 @@ uint8 FindFirstBit32(uint32 x) return pos; } -uint8 FindFirstBit64(uint64 x) +uint8_t FindFirstBit64(uint64_t x) { if (x == 0) return 0; - if ((x & 0x00000000ffffffffULL) != 0) return FindFirstBit32(static_cast(x)); - return FindFirstBit32(static_cast(x >> 32)) + 32; + if ((x & 0x00000000ffffffffULL) != 0) return FindFirstBit32(static_cast(x)); + return FindFirstBit32(static_cast(x >> 32)) + 32; } #endif @@ -62,11 +62,11 @@ uint8 FindFirstBit64(uint64 x) * @param x The value to search * @return The position of the last bit set */ -uint8 FindLastBit64(uint64 x) +uint8_t FindLastBit64(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 1554ec90f8..ad9b28fe72 100644 --- a/src/core/bitmath_func.hpp +++ b/src/core/bitmath_func.hpp @@ -31,7 +31,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); } @@ -103,7 +103,7 @@ inline T AB(T &x, const uint8_t s, const uint8_t 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; } @@ -193,7 +193,7 @@ inline T ToggleBit(T &x, const uint8_t y) #else /** 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). @@ -216,7 +216,7 @@ extern const uint8 _ffb_64[64]; * @return The position of the first bit set, or 0 when value is 0 */ template -inline uint8 FindFirstBit(T value) +inline uint8_t FindFirstBit(T value) { static_assert(sizeof(T) <= sizeof(unsigned long long)); #ifdef WITH_BITMATH_BUILTINS @@ -230,11 +230,11 @@ inline uint8 FindFirstBit(T value) return __builtin_ctzll(unsigned_value); } #else - if (sizeof(T) <= sizeof(uint32)) { - extern uint8 FindFirstBit32(uint32 x); + if (sizeof(T) <= sizeof(uint32_t)) { + extern uint8_t FindFirstBit32(uint32_t x); return FindFirstBit32(value); } else { - extern uint8 FindFirstBit64(uint64 x); + extern uint8_t FindFirstBit64(uint64_t x); return FindFirstBit64(value); } #endif @@ -247,7 +247,7 @@ inline uint8 FindFirstBit(T value) * @return The position of the last bit set, or 0 when value is 0 */ template -inline uint8 FindLastBit(T value) +inline uint8_t FindLastBit(T value) { static_assert(sizeof(T) <= sizeof(unsigned long long)); #ifdef WITH_BITMATH_BUILTINS @@ -261,7 +261,7 @@ inline uint8 FindLastBit(T value) return __builtin_clzll(1) - __builtin_clzll(unsigned_value); } #else - extern uint8 FindLastBit64(uint64 x); + extern uint8_t FindLastBit64(uint64_t x); return FindLastBit64(value); #endif } @@ -497,27 +497,27 @@ 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 BSWAP64(x) ((uint64)CFSwapInt64((uint64)(x))) - #define BSWAP32(x) ((uint32)CFSwapInt32((uint32)(x))) - #define BSWAP16(x) ((uint16)CFSwapInt16((uint16)(x))) + #define BSWAP64(x) ((uint64_t)CFSwapInt64((uint64_t)(x))) + #define BSWAP32(x) ((uint32_t)CFSwapInt32((uint32_t)(x))) + #define BSWAP16(x) ((uint16_t)CFSwapInt16((uint16_t)(x))) #elif defined(_MSC_VER) /* MSVC has intrinsics for swapping, resulting in faster code */ - #define BSWAP64(x) ((uint64)_byteswap_uint64((uint64)(x))) - #define BSWAP32(x) ((uint32)_byteswap_ulong((uint32)(x))) - #define BSWAP16(x) ((uint16)_byteswap_ushort((uint16)(x))) + #define BSWAP64(x) ((uint64_t)_byteswap_uint64((uint64_t)(x))) + #define BSWAP32(x) ((uint32_t)_byteswap_ulong((uint32_t)(x))) + #define BSWAP16(x) ((uint16_t)_byteswap_ushort((uint16_t)(x))) #else /** * Perform a 64 bits endianness bitswap on x. * @param x the variable to bitswap * @return the bitswapped value. */ - static inline uint64 BSWAP64(uint64 x) + static inline uint64_t BSWAP64(uint64_t x) { #if !defined(__ICC) && (defined(__GNUC__) || defined(__clang__)) /* GCC >= 4.3 provides a builtin, resulting in faster code */ - return (uint64)__builtin_bswap64((uint64)x); + return (uint64_t)__builtin_bswap64((uint64_t)x); #else return ((x >> 56) & 0xFFULL) | ((x >> 40) & 0xFF00ULL) | ((x >> 24) & 0xFF0000ULL) | ((x >> 8) & 0xFF000000ULL) | ((x << 8) & 0xFF00000000ULL) | ((x << 24) & 0xFF0000000000ULL) | ((x << 40) & 0xFF000000000000ULL) | ((x << 56) & 0xFF00000000000000ULL); @@ -530,11 +530,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__) || defined(__clang__)) /* GCC >= 4.3 provides a builtin, resulting in faster code */ - return (uint32)__builtin_bswap32((uint32)x); + return (uint32_t)__builtin_bswap32((uint32_t)x); #else return ((x >> 24) & 0xFF) | ((x >> 8) & 0xFF00) | ((x << 8) & 0xFF0000) | ((x << 24) & 0xFF000000); #endif /* __GNUC__ || __clang__ */ @@ -545,11 +545,11 @@ 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) { #if !defined(__ICC) && (defined(__GNUC__) || defined(__clang__)) /* GCC >= 4.3 provides a builtin, resulting in faster code */ - return (uint16)__builtin_bswap16((uint16)x); + return (uint16_t)__builtin_bswap16((uint16_t)x); #else return (x >> 8) | (x << 8); #endif /* __GNUC__ || __clang__ */ diff --git a/src/core/checksum_func.hpp b/src/core/checksum_func.hpp index a7d06db53f..fac042c6a3 100644 --- a/src/core/checksum_func.hpp +++ b/src/core/checksum_func.hpp @@ -23,9 +23,9 @@ #endif /* RANDOM_DEBUG */ struct SimpleChecksum64 { - uint64 state = 0; + uint64_t state = 0; - void Update(uint64 input) + void Update(uint64_t input) { this->state = ROL(this->state, 1) ^ input ^ 0x123456789ABCDEF7ULL; } @@ -33,7 +33,7 @@ struct SimpleChecksum64 { extern SimpleChecksum64 _state_checksum; -inline void UpdateStateChecksum(uint64 input) +inline void UpdateStateChecksum(uint64_t input) { if (_networking) _state_checksum.Update(input); } diff --git a/src/core/endian_func.hpp b/src/core/endian_func.hpp index 8bacc42567..1b236c8cce 100644 --- a/src/core/endian_func.hpp +++ b/src/core/endian_func.hpp @@ -48,7 +48,7 @@ inline uint16_t ReadLE16Aligned(const void *x) { - return FROM_LE16(*(const uint16*)x); + return FROM_LE16(*(const uint16_t*)x); } inline uint16_t ReadLE16Unaligned(const void *x) @@ -56,7 +56,7 @@ 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 42da441e08..ce3caee3d9 100644 --- a/src/core/geometry_type.hpp +++ b/src/core/geometry_type.hpp @@ -46,10 +46,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; @@ -225,10 +225,10 @@ struct Rect { }; struct Rect16 { - int16 left; - int16 top; - int16 right; - int16 bottom; + int16_t left; + int16_t top; + int16_t right; + int16_t bottom; }; template diff --git a/src/core/hash_func.hpp b/src/core/hash_func.hpp index af526a45b8..28d09ad46e 100644 --- a/src/core/hash_func.hpp +++ b/src/core/hash_func.hpp @@ -14,7 +14,7 @@ * Simple 32 bit to 32 bit hash * From MurmurHash3 */ -inline uint32 SimpleHash32(uint32 h) +inline uint32_t SimpleHash32(uint32_t h) { h ^= h >> 16; h *= 0x85ebca6b; diff --git a/src/core/math_func.cpp b/src/core/math_func.cpp index 3a62fcd303..17afafff2c 100644 --- a/src/core/math_func.cpp +++ b/src/core/math_func.cpp @@ -57,7 +57,7 @@ int GreatestCommonDivisor(int a, int b) */ int DivideApprox(int a, int b) { - int random_like = (((int64) (a + b)) * ((int64) (a - b))) % b; + int random_like = (((int64_t) (a + b)) * ((int64_t) (a - b))) % b; int remainder = a % b; @@ -75,10 +75,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; @@ -105,10 +105,10 @@ uint32 IntSqrt(uint32 num) * @return Rounded integer square root. * @note Algorithm taken from http://en.wikipedia.org/wiki/Methods_of_computing_square_roots */ -uint32 IntSqrt64(uint64 num) +uint32_t IntSqrt64(uint64_t num) { - uint64 res = 0; - uint64 bit = 1ULL << 62; // Second to top bit number. + uint64_t res = 0; + uint64_t bit = 1ULL << 62; // Second to top bit number. /* 'bit' starts at the highest power of four <= the argument. */ while (bit > num) bit >>= 2; @@ -126,7 +126,7 @@ uint32 IntSqrt64(uint64 num) /* Arithmetic rounding to nearest integer. */ if (num > res) res++; - return (uint32)res; + return (uint32_t)res; } /** @@ -135,10 +135,10 @@ uint32 IntSqrt64(uint64 num) * @return Rounded integer square root. * @note Algorithm taken from https://stackoverflow.com/a/56738014 */ -uint32 IntCbrt(uint64 num) +uint32_t IntCbrt(uint64_t num) { - uint64 r0 = 1; - uint64 r1 = 0; + uint64_t r0 = 1; + uint64_t r1 = 0; if (num == 0) return 0; @@ -160,23 +160,23 @@ uint32 IntCbrt(uint64 num) } while (r0 < r1); - return ((uint32) r1); /* floor(cbrt(x)); */ + return ((uint32_t) r1); /* floor(cbrt(x)); */ } /** * Compress unsigned integer into 16 bits, in a way that increases dynamic range, at the expense of precision for large values */ -uint16 RXCompressUint(uint32 num) +uint16_t RXCompressUint(uint32_t num) { if (num <= 0x100) return num; if (num <= 0x7900) return 0x100 + ((num - 0x100) >> 3); - return std::min(UINT16_MAX, 0x1000 + ((num - 0x7900) >> 6)); + return std::min(UINT16_MAX, 0x1000 + ((num - 0x7900) >> 6)); } /** * Inverse of RXCompressUint */ -uint32 RXDecompressUint(uint16 num) +uint32_t RXDecompressUint(uint16_t num) { if (num > 0x1000) return ((num - 0x1000) << 6) + 0x7900; if (num > 0x100) return ((num - 0x100) << 3) + 0x100; diff --git a/src/core/math_func.hpp b/src/core/math_func.hpp index eaa8a127ce..cfd5a1314f 100644 --- a/src/core/math_func.hpp +++ b/src/core/math_func.hpp @@ -420,11 +420,11 @@ inline T DivTowardsPositiveInf(T a, T b) return (a / b) + (a % b > 0 ? 1 : 0); } -uint32 IntSqrt(uint32 num); -uint32 IntSqrt64(uint64 num); -uint32 IntCbrt(uint64 num); +uint32_t IntSqrt(uint32_t num); +uint32_t IntSqrt64(uint64_t num); +uint32_t IntCbrt(uint64_t num); -uint16 RXCompressUint(uint32 num); -uint32 RXDecompressUint(uint16 num); +uint16_t RXCompressUint(uint32_t num); +uint32_t RXDecompressUint(uint16_t num); #endif /* MATH_FUNC_HPP */ diff --git a/src/core/overflowsafe_type.hpp b/src/core/overflowsafe_type.hpp index 73d669dfcc..f9a14d62f4 100644 --- a/src/core/overflowsafe_type.hpp +++ b/src/core/overflowsafe_type.hpp @@ -89,11 +89,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; } @@ -134,14 +134,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; } @@ -179,11 +179,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; } @@ -203,8 +203,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/pod_pool.hpp b/src/core/pod_pool.hpp index 99c511c3ff..2906bd29b7 100644 --- a/src/core/pod_pool.hpp +++ b/src/core/pod_pool.hpp @@ -15,7 +15,7 @@ /** * Pool-type container for POD data.. */ -template +template class PodPool { static_assert(SIZE >= sizeof(IDX)); diff --git a/src/core/pool_func.hpp b/src/core/pool_func.hpp index 088d27bd6c..b84dd067fa 100644 --- a/src/core/pool_func.hpp +++ b/src/core/pool_func.hpp @@ -63,7 +63,7 @@ DEFINE_POOL_METHOD(inline void)::ResizeFor(size_t index) this->free_bitmap = ReallocT(this->free_bitmap, CeilDivT(new_size, 64)); MemSetT(this->free_bitmap + CeilDivT(this->size, 64), 0, CeilDivT(new_size, 64) - CeilDivT(this->size, 64)); if (new_size % 64 != 0) { - this->free_bitmap[new_size / 64] |= (~((uint64) 0)) << (new_size % 64); + this->free_bitmap[new_size / 64] |= (~((uint64_t) 0)) << (new_size % 64); } this->size = new_size; @@ -79,7 +79,7 @@ DEFINE_POOL_METHOD(inline size_t)::FindFirstFree() size_t bitmap_end = CeilDivT(this->first_unused, 64); for (; bitmap_index < bitmap_end; bitmap_index++) { - uint64 available = ~this->free_bitmap[bitmap_index]; + uint64_t available = ~this->free_bitmap[bitmap_index]; if (available == 0) continue; return (bitmap_index * 64) + FindFirstBit(available); } diff --git a/src/core/pool_type.hpp b/src/core/pool_type.hpp index d4ba9ccab2..e5ba372c8e 100644 --- a/src/core/pool_type.hpp +++ b/src/core/pool_type.hpp @@ -80,7 +80,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 @@ -96,7 +96,7 @@ struct Pool : PoolBase { bool cleaning; ///< True if cleaning pool (deleting all items) Titem **data; ///< Pointer to array of pointers to Titem - uint64 *free_bitmap; ///< Pointer to free bitmap + uint64_t *free_bitmap; ///< Pointer to free bitmap Pool(const char *name); void CleanPool() override; diff --git a/src/core/random_func.cpp b/src/core/random_func.cpp index 33799992ce..20ee7e72f1 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, "%s; %04x; %02x; %s:%d", debug_date_dumper().HexDate(), _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 b016d3b471..03c01913d0 100644 --- a/src/core/random_func.hpp +++ b/src/core/random_func.hpp @@ -22,11 +22,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 @@ -73,18 +73,18 @@ public: } }; -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(); } @@ -96,7 +96,7 @@ 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); } @@ -130,7 +130,7 @@ inline uint32_t InteractiveRandomRange(uint32_t limit) 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; } /** diff --git a/src/core/ring_buffer.hpp b/src/core/ring_buffer.hpp index 5aca52a7d2..f4e86151c0 100644 --- a/src/core/ring_buffer.hpp +++ b/src/core/ring_buffer.hpp @@ -26,14 +26,14 @@ template class ring_buffer { std::unique_ptr data; - uint32 head = 0; - uint32 count = 0; - uint32 mask = (uint32)-1; + uint32_t head = 0; + uint32_t count = 0; + uint32_t mask = (uint32_t)-1; - static uint32 round_up_size(uint32 size) + static uint32_t round_up_size(uint32_t size) { if (size <= 4) return 4; - uint8 bit = FindLastBit(size - 1); + uint8_t bit = FindLastBit(size - 1); return 1 << (bit + 1); } @@ -43,15 +43,15 @@ class ring_buffer protected: const ring_buffer *ring = nullptr; - uint32 pos = 0; + uint32_t pos = 0; ring_buffer_iterator_base() {} - ring_buffer_iterator_base(const ring_buffer *ring, uint32 pos) + ring_buffer_iterator_base(const ring_buffer *ring, uint32_t pos) : ring(ring), pos(pos) {} public: - uint32 debug_raw_position() const { return this->pos; } + uint32_t debug_raw_position() const { return this->pos; } }; public: @@ -68,7 +68,7 @@ public: : ring_buffer_iterator_base(other.ring, other.pos) {} private: - ring_buffer_iterator(const ring_buffer *ring, uint32 pos) + ring_buffer_iterator(const ring_buffer *ring, uint32_t pos) : ring_buffer_iterator_base(ring, pos) {} void next() @@ -92,9 +92,9 @@ public: void move(std::ptrdiff_t delta) { if (REVERSE) { - this->pos -= (uint32)delta; + this->pos -= (uint32_t)delta; } else { - this->pos += (uint32)delta; + this->pos += (uint32_t)delta; } } @@ -185,9 +185,9 @@ public: { dbg_assert(this->ring == other.ring); if (REVERSE) { - return (int32)(other.pos - this->pos); + return (int32_t)(other.pos - this->pos); } else { - return (int32)(this->pos - other.pos); + return (int32_t)(this->pos - other.pos); } } }; @@ -207,11 +207,11 @@ public: template void construct_from(const U &other) { - uint32 cap = round_up_size((uint32)other.size()); + uint32_t cap = round_up_size((uint32_t)other.size()); this->data.reset(MallocT(cap * sizeof(T))); this->mask = cap - 1; this->head = 0; - this->count = (uint32)other.size(); + this->count = (uint32_t)other.size(); byte *ptr = this->data.get(); for (const T &item : other) { new (ptr) T(item); @@ -247,7 +247,7 @@ public: this->clear(); if (!other.empty()) { if (other.size() > this->capacity()) { - uint32 cap = round_up_size(other.count); + uint32_t cap = round_up_size(other.count); this->data.reset(MallocT(cap * sizeof(T))); this->mask = cap - 1; } @@ -332,9 +332,9 @@ public: } private: - void reallocate(uint32 new_cap) + void reallocate(uint32_t new_cap) { - const uint32 cap = round_up_size(new_cap); + const uint32_t cap = round_up_size(new_cap); byte *new_buf = MallocT(cap * sizeof(T)); byte *pos = new_buf; for (T &item : *this) { @@ -347,22 +347,22 @@ private: this->data.reset(new_buf); } - void *raw_ptr_at_pos(uint32 idx) const + void *raw_ptr_at_pos(uint32_t idx) const { return this->data.get() + (sizeof(T) * (idx & this->mask)); } - void *raw_ptr_at_offset(uint32 idx) const + void *raw_ptr_at_offset(uint32_t idx) const { return this->raw_ptr_at_pos(this->head + idx); } - T *ptr_at_pos(uint32 idx) const + T *ptr_at_pos(uint32_t idx) const { return static_cast(this->raw_ptr_at_pos(idx)); } - T *ptr_at_offset(uint32 idx) const + T *ptr_at_offset(uint32_t idx) const { return static_cast(this->raw_ptr_at_offset(idx)); } @@ -511,15 +511,15 @@ public: } private: - uint32 setup_insert(uint32 pos, uint32 num) + uint32_t setup_insert(uint32_t pos, uint32_t num) { - if (this->count + num > (uint32)this->capacity()) { + if (this->count + num > (uint32_t)this->capacity()) { /* grow container */ - const uint32 cap = round_up_size(this->count + num); + const uint32_t cap = round_up_size(this->count + num); byte *new_buf = MallocT(cap * sizeof(T)); byte *write_to = new_buf; - const uint32 end = this->head + this->count; - for (uint32 idx = this->head; idx != end; idx++) { + const uint32_t end = this->head + this->count; + for (uint32_t idx = this->head; idx != end; idx++) { if (idx == pos) { /* gap for inserted items */ write_to += num * sizeof(T); @@ -529,7 +529,7 @@ private: item.~T(); write_to += sizeof(T); } - uint32 res = pos - this->head; + uint32_t res = pos - this->head; this->mask = cap - 1; this->head = 0; this->count += num; @@ -548,17 +548,17 @@ private: /* middle, move data */ if (pos - this->head < (this->count / 2)) { /* closer to the beginning, shuffle those backwards */ - const uint32 new_head = this->head - num; - const uint32 insert_start = pos - num; - for (uint32 idx = new_head; idx != this->head; idx++) { + const uint32_t new_head = this->head - num; + const uint32_t insert_start = pos - num; + for (uint32_t idx = new_head; idx != this->head; idx++) { /* Move construct to move backwards into uninitialised region */ new (this->raw_ptr_at_pos(idx)) T(std::move(*(this->ptr_at_pos(idx + num)))); } - for (uint32 idx = this->head; idx != insert_start; idx++) { + for (uint32_t idx = this->head; idx != insert_start; idx++) { /* Move assign to move backwards in initialised region */ *this->ptr_at_pos(idx) = std::move(*this->ptr_at_pos(idx + num)); } - for (uint32 idx = insert_start; idx != pos; idx++) { + for (uint32_t idx = insert_start; idx != pos; idx++) { /* Destruct to leave space for inserts */ this->ptr_at_pos(idx)->~T(); } @@ -567,18 +567,18 @@ private: return insert_start; } else { /* closer to the end, shuffle those forwards */ - const uint32 last_inserted = pos + num - 1; - const uint32 last = this->head + this->count - 1; - const uint32 new_last = last + num; - for (uint32 idx = new_last; idx != last; idx--) { + const uint32_t last_inserted = pos + num - 1; + const uint32_t last = this->head + this->count - 1; + const uint32_t new_last = last + num; + for (uint32_t idx = new_last; idx != last; idx--) { /* Move construct to move forwards into uninitialised region */ new (this->raw_ptr_at_pos(idx)) T(std::move(*(this->ptr_at_pos(idx - num)))); } - for (uint32 idx = last; idx != last_inserted; idx--) { + for (uint32_t idx = last; idx != last_inserted; idx--) { /* Move assign to move forwards in initialised region */ *this->ptr_at_pos(idx) = std::move(*this->ptr_at_pos(idx - num)); } - for (uint32 idx = last_inserted; idx != pos; idx--) { + for (uint32_t idx = last_inserted; idx != pos; idx--) { /* Destruct to leave space for inserts */ this->ptr_at_pos(idx)->~T(); } @@ -594,7 +594,7 @@ public: { dbg_assert(pos.ring == this); - uint32 new_pos = this->setup_insert(pos.pos, 1); + uint32_t new_pos = this->setup_insert(pos.pos, 1); new (this->raw_ptr_at_pos(new_pos)) T(std::forward(args)...); return iterator(this, new_pos); } @@ -615,8 +615,8 @@ public: dbg_assert(pos.ring == this); - const uint32 new_pos_start = this->setup_insert(pos.pos, (uint32)count); - uint32 new_pos = new_pos_start; + const uint32_t new_pos_start = this->setup_insert(pos.pos, (uint32_t)count); + uint32_t new_pos = new_pos_start; for (size_t i = 0; i != count; i++) { new (this->raw_ptr_at_pos(new_pos)) T(value); ++new_pos; @@ -631,8 +631,8 @@ public: dbg_assert(pos.ring == this); - const uint32 new_pos_start = this->setup_insert(pos.pos, (uint32)std::distance(first, last)); - uint32 new_pos = new_pos_start; + const uint32_t new_pos_start = this->setup_insert(pos.pos, (uint32_t)std::distance(first, last)); + uint32_t new_pos = new_pos_start; for (auto iter = first; iter != last; ++iter) { new (this->raw_ptr_at_pos(new_pos)) T(*iter); ++new_pos; @@ -646,11 +646,11 @@ public: } private: - uint32 do_erase(uint32 pos, uint32 num) + uint32_t do_erase(uint32_t pos, uint32_t num) { if (pos == this->head) { /* erase from beginning */ - for (uint32 i = 0; i < num; i++) { + for (uint32_t i = 0; i < num; i++) { this->ptr_at_pos(pos + i)->~T(); } this->head += num; @@ -658,19 +658,19 @@ private: return this->head; } else if (pos + num == this->head + this->count) { /* erase from end */ - for (uint32 i = 0; i < num; i++) { + for (uint32_t i = 0; i < num; i++) { this->ptr_at_pos(pos + i)->~T(); } this->count -= num; return pos; } else if (pos - this->head < this->head + this->count - (pos + num)) { /* closer to the beginning, shuffle beginning forwards to fill gap */ - const uint32 new_head = this->head + num; - const uint32 erase_end = pos + num; - for (uint32 idx = erase_end - 1; idx != new_head - 1; idx--) { + const uint32_t new_head = this->head + num; + const uint32_t erase_end = pos + num; + for (uint32_t idx = erase_end - 1; idx != new_head - 1; idx--) { *this->ptr_at_pos(idx) = std::move(*this->ptr_at_pos(idx - num)); } - for (uint32 idx = new_head - 1; idx != this->head - 1; idx--) { + for (uint32_t idx = new_head - 1; idx != this->head - 1; idx--) { this->ptr_at_pos(idx)->~T(); } this->head = new_head; @@ -678,12 +678,12 @@ private: return pos + num; } else { /* closer to the end, shuffle end backwards to fill gap */ - const uint32 current_end = this->head + this->count; - const uint32 new_end = current_end - num; - for (uint32 idx = pos; idx != new_end; idx++) { + const uint32_t current_end = this->head + this->count; + const uint32_t new_end = current_end - num; + for (uint32_t idx = pos; idx != new_end; idx++) { *this->ptr_at_pos(idx) = std::move(*this->ptr_at_pos(idx + num)); } - for (uint32 idx = new_end; idx != current_end; idx++) { + for (uint32_t idx = new_end; idx != current_end; idx++) { this->ptr_at_pos(idx)->~T(); } this->count -= num; @@ -712,24 +712,24 @@ public: { if (new_cap <= this->capacity()) return; - this->reallocate((uint32)new_cap); + this->reallocate((uint32_t)new_cap); } void resize(size_t new_size) { if (new_size < this->size()) { - for (uint32 i = (uint32)new_size; i != this->count; i++) { + for (uint32_t i = (uint32_t)new_size; i != this->count; i++) { this->ptr_at_offset(i)->~T(); } } else if (new_size > this->size()) { if (new_size > this->capacity()) { - this->reallocate((uint32)new_size); + this->reallocate((uint32_t)new_size); } - for (uint32 i = this->count; i != (uint32)new_size; i++) { + for (uint32_t i = this->count; i != (uint32_t)new_size; i++) { new (this->raw_ptr_at_offset(i)) T(); } } - this->count = (uint32)new_size; + this->count = (uint32_t)new_size; } void shrink_to_fit() @@ -737,7 +737,7 @@ public: if (this->empty()) { this->clear(); this->data.reset(); - this->mask = (uint32)-1; + this->mask = (uint32_t)-1; } else if (round_up_size(this->count) < this->capacity()) { this->reallocate(this->count); } @@ -745,12 +745,12 @@ public: T &operator[](size_t index) { - return *this->ptr_at_offset((uint32)index); + return *this->ptr_at_offset((uint32_t)index); } const T &operator[](size_t index) const { - return *this->ptr_at_offset((uint32)index); + return *this->ptr_at_offset((uint32_t)index); } }; diff --git a/src/core/serialisation.cpp b/src/core/serialisation.cpp index 22cf6c9dbd..3c734681b7 100644 --- a/src/core/serialisation.cpp +++ b/src/core/serialisation.cpp @@ -23,13 +23,13 @@ /* * 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. */ @@ -46,7 +46,7 @@ void BufferSend_bool(std::vector &buffer, size_t limit, bool data) * Package a 8 bits integer in the packet. * @param data The data to send. */ -void BufferSend_uint8(std::vector &buffer, size_t limit, uint8 data) +void BufferSend_uint8(std::vector &buffer, size_t limit, uint8_t data) { assert(BufferCanWriteToPacket(buffer, limit, sizeof(data))); buffer.emplace_back(data); @@ -56,12 +56,12 @@ void BufferSend_uint8(std::vector &buffer, size_t limit, uint8 data) * Package a 16 bits integer in the packet. * @param data The data to send. */ -void BufferSend_uint16(std::vector &buffer, size_t limit, uint16 data) +void BufferSend_uint16(std::vector &buffer, size_t limit, uint16_t data) { assert(BufferCanWriteToPacket(buffer, limit, sizeof(data))); buffer.insert(buffer.end(), { - (uint8)GB(data, 0, 8), - (uint8)GB(data, 8, 8), + (uint8_t)GB(data, 0, 8), + (uint8_t)GB(data, 8, 8), }); } @@ -69,14 +69,14 @@ void BufferSend_uint16(std::vector &buffer, size_t limit, uint16 data) * Package a 32 bits integer in the packet. * @param data The data to send. */ -void BufferSend_uint32(std::vector &buffer, size_t limit, uint32 data) +void BufferSend_uint32(std::vector &buffer, size_t limit, uint32_t data) { assert(BufferCanWriteToPacket(buffer, limit, sizeof(data))); buffer.insert(buffer.end(), { - (uint8)GB(data, 0, 8), - (uint8)GB(data, 8, 8), - (uint8)GB(data, 16, 8), - (uint8)GB(data, 24, 8), + (uint8_t)GB(data, 0, 8), + (uint8_t)GB(data, 8, 8), + (uint8_t)GB(data, 16, 8), + (uint8_t)GB(data, 24, 8), }); } @@ -84,18 +84,18 @@ void BufferSend_uint32(std::vector &buffer, size_t limit, uint32 data) * Package a 64 bits integer in the packet. * @param data The data to send. */ -void BufferSend_uint64(std::vector &buffer, size_t limit, uint64 data) +void BufferSend_uint64(std::vector &buffer, size_t limit, uint64_t data) { assert(BufferCanWriteToPacket(buffer, limit, sizeof(data))); buffer.insert(buffer.end(), { - (uint8)GB(data, 0, 8), - (uint8)GB(data, 8, 8), - (uint8)GB(data, 16, 8), - (uint8)GB(data, 24, 8), - (uint8)GB(data, 32, 8), - (uint8)GB(data, 40, 8), - (uint8)GB(data, 48, 8), - (uint8)GB(data, 56, 8), + (uint8_t)GB(data, 0, 8), + (uint8_t)GB(data, 8, 8), + (uint8_t)GB(data, 16, 8), + (uint8_t)GB(data, 24, 8), + (uint8_t)GB(data, 32, 8), + (uint8_t)GB(data, 40, 8), + (uint8_t)GB(data, 48, 8), + (uint8_t)GB(data, 56, 8), }); } @@ -147,8 +147,8 @@ void BufferSend_buffer(std::vector &buffer, size_t limit, const byte *data assert(size <= UINT16_MAX); assert(BufferCanWriteToPacket(buffer, limit, size + 2)); buffer.insert(buffer.end(), { - (uint8)GB(size, 0, 8), - (uint8)GB(size, 8, 8), + (uint8_t)GB(size, 0, 8), + (uint8_t)GB(size, 8, 8), }); buffer.insert(buffer.end(), data, data + size); } diff --git a/src/core/serialisation.hpp b/src/core/serialisation.hpp index 71b7d8731b..444423e904 100644 --- a/src/core/serialisation.hpp +++ b/src/core/serialisation.hpp @@ -20,10 +20,10 @@ #include void BufferSend_bool (std::vector &buffer, size_t limit, bool data); -void BufferSend_uint8 (std::vector &buffer, size_t limit, uint8 data); -void BufferSend_uint16(std::vector &buffer, size_t limit, uint16 data); -void BufferSend_uint32(std::vector &buffer, size_t limit, uint32 data); -void BufferSend_uint64(std::vector &buffer, size_t limit, uint64 data); +void BufferSend_uint8 (std::vector &buffer, size_t limit, uint8_t data); +void BufferSend_uint16(std::vector &buffer, size_t limit, uint16_t data); +void BufferSend_uint32(std::vector &buffer, size_t limit, uint32_t data); +void BufferSend_uint64(std::vector &buffer, size_t limit, uint64_t data); void BufferSend_string(std::vector &buffer, size_t limit, const std::string_view data); size_t BufferSend_binary_until_full(std::vector &buffer, size_t limit, const byte *begin, const byte *end); void BufferSend_binary(std::vector &buffer, size_t limit, const byte *data, const size_t size); @@ -37,25 +37,25 @@ struct BufferSerialisationHelper { BufferSend_bool(self->GetSerialisationBuffer(), self->GetSerialisationLimit(), data); } - void Send_uint8(uint8 data) + void Send_uint8(uint8_t data) { T *self = static_cast(this); BufferSend_uint8(self->GetSerialisationBuffer(), self->GetSerialisationLimit(), data); } - void Send_uint16(uint16 data) + void Send_uint16(uint16_t data) { T *self = static_cast(this); BufferSend_uint16(self->GetSerialisationBuffer(), self->GetSerialisationLimit(), data); } - void Send_uint32(uint32 data) + void Send_uint32(uint32_t data) { T *self = static_cast(this); BufferSend_uint32(self->GetSerialisationBuffer(), self->GetSerialisationLimit(), data); } - void Send_uint64(uint64 data) + void Send_uint64(uint64_t data) { T *self = static_cast(this); BufferSend_uint64(self->GetSerialisationBuffer(), self->GetSerialisationLimit(), data); @@ -130,9 +130,9 @@ public: * Read a 8 bits integer from the packet. * @return The read data. */ - uint8 Recv_uint8() + uint8_t Recv_uint8() { - uint8 n; + uint8_t n; if (!this->CanRecvBytes(sizeof(n), true)) return 0; @@ -146,16 +146,16 @@ public: * Read a 16 bits integer from the packet. * @return The read data. */ - uint16 Recv_uint16() + uint16_t Recv_uint16() { - uint16 n; + uint16_t n; if (!this->CanRecvBytes(sizeof(n), true)) return 0; auto &pos = static_cast(this)->GetDeserialisationPosition(); - n = (uint16)this->GetBuffer()[pos++]; - n += (uint16)this->GetBuffer()[pos++] << 8; + n = (uint16_t)this->GetBuffer()[pos++]; + n += (uint16_t)this->GetBuffer()[pos++] << 8; return n; } @@ -163,18 +163,18 @@ public: * Read a 32 bits integer from the packet. * @return The read data. */ - uint32 Recv_uint32() + uint32_t Recv_uint32() { - uint32 n; + uint32_t n; if (!this->CanRecvBytes(sizeof(n), true)) return 0; auto &pos = static_cast(this)->GetDeserialisationPosition(); - n = (uint32)this->GetBuffer()[pos++]; - n += (uint32)this->GetBuffer()[pos++] << 8; - n += (uint32)this->GetBuffer()[pos++] << 16; - n += (uint32)this->GetBuffer()[pos++] << 24; + n = (uint32_t)this->GetBuffer()[pos++]; + n += (uint32_t)this->GetBuffer()[pos++] << 8; + n += (uint32_t)this->GetBuffer()[pos++] << 16; + n += (uint32_t)this->GetBuffer()[pos++] << 24; return n; } @@ -182,22 +182,22 @@ public: * Read a 64 bits integer from the packet. * @return The read data. */ - uint64 Recv_uint64() + uint64_t Recv_uint64() { - uint64 n; + uint64_t n; if (!this->CanRecvBytes(sizeof(n), true)) return 0; auto &pos = static_cast(this)->GetDeserialisationPosition(); - n = (uint64)this->GetBuffer()[pos++]; - n += (uint64)this->GetBuffer()[pos++] << 8; - n += (uint64)this->GetBuffer()[pos++] << 16; - n += (uint64)this->GetBuffer()[pos++] << 24; - n += (uint64)this->GetBuffer()[pos++] << 32; - n += (uint64)this->GetBuffer()[pos++] << 40; - n += (uint64)this->GetBuffer()[pos++] << 48; - n += (uint64)this->GetBuffer()[pos++] << 56; + n = (uint64_t)this->GetBuffer()[pos++]; + n += (uint64_t)this->GetBuffer()[pos++] << 8; + n += (uint64_t)this->GetBuffer()[pos++] << 16; + n += (uint64_t)this->GetBuffer()[pos++] << 24; + n += (uint64_t)this->GetBuffer()[pos++] << 32; + n += (uint64_t)this->GetBuffer()[pos++] << 40; + n += (uint64_t)this->GetBuffer()[pos++] << 48; + n += (uint64_t)this->GetBuffer()[pos++] << 56; return n; } @@ -269,13 +269,13 @@ public: * @param size The size of the data. * @return The view of the data. */ - span Recv_binary_view(size_t size) + span Recv_binary_view(size_t size) { if (!this->CanRecvBytes(size, true)) return {}; auto &pos = static_cast(this)->GetDeserialisationPosition(); - span view { &this->GetBuffer()[pos], size }; + span view { &this->GetBuffer()[pos], size }; pos += (decltype(pos)) size; return view; @@ -286,9 +286,9 @@ public: * @param size The size of the data. * @return The binary buffer. */ - std::vector Recv_binary(size_t size) + std::vector Recv_binary(size_t size) { - span view = this->Recv_binary_view(size); + span view = this->Recv_binary_view(size); return { view.begin(), view.end() }; } @@ -297,14 +297,14 @@ public: * Returns a view of a length-prefixed binary buffer from the packet. * @return The binary buffer. */ - span Recv_buffer_view() + span Recv_buffer_view() { - uint16 length = this->Recv_uint16(); + uint16_t length = this->Recv_uint16(); if (!this->CanRecvBytes(length, true)) return {}; auto &pos = static_cast(this)->GetDeserialisationPosition(); - span buffer { &this->GetBuffer()[pos], length }; + span buffer { &this->GetBuffer()[pos], length }; pos += length; return buffer; @@ -314,9 +314,9 @@ public: * Reads a length-prefixed binary buffer from the packet. * @return The binary buffer. */ - std::vector Recv_buffer() + std::vector Recv_buffer() { - span view = this->Recv_buffer_view(); + span view = this->Recv_buffer_view(); return { view.begin(), view.end() }; } diff --git a/src/cpu.cpp b/src/cpu.cpp index 120c813012..a9909858ab 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 AARCH64. Use GCC syntax */ #if defined(__aarch64__) && !defined(RDTSC_AVAILABLE) -uint64 ottd_rdtsc() +uint64_t ottd_rdtsc() { - uint64 val; + uint64_t val; asm volatile("mrs %0, cntvct_el0" : "=r" (val)); return val; } @@ -56,9 +56,9 @@ uint64 ottd_rdtsc() /* 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 @@ -72,14 +72,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 @@ -91,7 +91,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 @@ -99,7 +99,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/crashlog.cpp b/src/crashlog.cpp index 0f054d21e3..266621149a 100644 --- a/src/crashlog.cpp +++ b/src/crashlog.cpp @@ -215,7 +215,7 @@ char *CrashLog::LogOpenTTDVersion(char *buffer, const char *last) const */ char *CrashLog::LogConfiguration(char *buffer, const char *last) const { - auto pathfinder_name = [](uint8 pf) -> const char * { + auto pathfinder_name = [](uint8_t pf) -> const char * { switch (pf) { case VPF_NPF: return "NPF"; case VPF_YAPF: return "YAPF"; @@ -560,7 +560,7 @@ char *CrashLog::FillCrashLog(char *buffer, const char *last) buffer = this->TryCrashLogFaultSection(buffer, last, "network sync", [](CrashLog *self, char *buffer, const char *last) -> char * { if (IsGameThread() && _record_sync_records && !_network_sync_records.empty()) { uint total = 0; - for (uint32 count : _network_sync_record_counts) { + for (uint32_t count : _network_sync_record_counts) { total += count; } NetworkSyncRecordEvents event = NSRE_BEGIN; @@ -648,7 +648,7 @@ char *CrashLog::FillDesyncCrashLog(char *buffer, const char *last, const DesyncE buffer += seprintf(buffer, last, "%s\n", info.desync_frame_info.c_str()); } - extern uint32 _frame_counter; + extern uint32_t _frame_counter; buffer += seprintf(buffer, last, "In game date: %i-%02i-%02i (%i, %i) (DL: %u), %08X\n", _cur_date_ymd.year, _cur_date_ymd.month + 1, _cur_date_ymd.day, _date_fract, _tick_skip_counter, _settings_game.economy.day_length_factor, _frame_counter); @@ -661,8 +661,8 @@ char *CrashLog::FillDesyncCrashLog(char *buffer, const char *last, const DesyncE if (!_network_server) { extern Date _last_sync_date; extern DateFract _last_sync_date_fract; - extern uint8 _last_sync_tick_skip_counter; - extern uint32 _last_sync_frame_counter; + extern uint8_t _last_sync_tick_skip_counter; + extern uint32_t _last_sync_frame_counter; YearMonthDay ymd = ConvertDateToYMD(_last_sync_date); buffer += seprintf(buffer, last, "Last sync at: %i-%02i-%02i (%i, %i), %08X\n", @@ -713,7 +713,7 @@ char *CrashLog::FillInconsistencyLog(char *buffer, const char *last, const Incon buffer += WriteScopeLog(buffer, last); #endif - extern uint32 _frame_counter; + extern uint32_t _frame_counter; buffer += seprintf(buffer, last, "In game date: %i-%02i-%02i (%i, %i) (DL: %u), %08X\n", _cur_date_ymd.year, _cur_date_ymd.month + 1, _cur_date_ymd.day, _date_fract, _tick_skip_counter, _settings_game.economy.day_length_factor, _frame_counter); @@ -726,8 +726,8 @@ char *CrashLog::FillInconsistencyLog(char *buffer, const char *last, const Incon if (_networking && !_network_server) { extern Date _last_sync_date; extern DateFract _last_sync_date_fract; - extern uint8 _last_sync_tick_skip_counter; - extern uint32 _last_sync_frame_counter; + extern uint8_t _last_sync_tick_skip_counter; + extern uint32_t _last_sync_frame_counter; YearMonthDay ymd = ConvertDateToYMD(_last_sync_date); buffer += seprintf(buffer, last, "Last sync at: %i-%02i-%02i (%i, %i), %08X\n", diff --git a/src/currency.cpp b/src/currency.cpp index facb54f923..c804fc9594 100644 --- a/src/currency.cpp +++ b/src/currency.cpp @@ -119,9 +119,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 a144ecce77..e63f0bceec 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. 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, Year to_euro, const char *prefix, const char *suffix, const char *code, byte symbol_pos, StringID name) : + CurrencySpec(uint16_t rate, const char *separator, 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 CheckSwitchToEuro(); void ResetCurrencies(bool preserve_custom = true); byte GetNewgrfCurrencyIdConverted(byte grfcurr_id); diff --git a/src/date.cpp b/src/date.cpp index 34dd29dd36..a947edd1ab 100644 --- a/src/date.cpp +++ b/src/date.cpp @@ -26,19 +26,19 @@ #include "safeguards.h" -YearMonthDay _cur_date_ymd; ///< Current date as YearMonthDay struct -Date _date; ///< Current date in days (day counter) -DateFract _date_fract; ///< Fractional part of the day. -uint64 _tick_counter; ///< Ever incrementing tick counter for setting off various events -uint8 _tick_skip_counter; ///< Counter for ticks, when only vehicles are moving and nothing else happens -uint64 _scaled_tick_counter; ///< Tick counter in daylength-scaled ticks -DateTicksScaled _scaled_date_ticks; ///< Date as ticks in daylength-scaled ticks +YearMonthDay _cur_date_ymd; ///< Current date as YearMonthDay struct +Date _date; ///< Current date in days (day counter) +DateFract _date_fract; ///< Fractional part of the day. +uint64_t _tick_counter; ///< Ever incrementing tick counter for setting off various events +uint8_t _tick_skip_counter; ///< Counter for ticks, when only vehicles are moving and nothing else happens +uint64_t _scaled_tick_counter; ///< Tick counter in daylength-scaled ticks +DateTicksScaled _scaled_date_ticks; ///< Date as ticks in daylength-scaled ticks DateTicksScaled _scaled_date_ticks_offset; ///< Offset to add when generating _scaled_date_ticks -uint32 _quit_after_days; ///< Quit after this many days of run time +uint32_t _quit_after_days; ///< Quit after this many days of run time YearMonthDay _game_load_cur_date_ymd; DateFract _game_load_date_fract; -uint8 _game_load_tick_skip_counter; +uint8_t _game_load_tick_skip_counter; extern void ClearOutOfDateSignalSpeedRestrictions(); @@ -46,12 +46,12 @@ void CheckScaledDateTicksWrap() { DateTicksScaledDelta tick_adjust = 0; auto get_tick_adjust = [&](DateTicksScaled target) { - int32 rounding = _settings_time.time_in_minutes * 1440; + int32_t rounding = _settings_time.time_in_minutes * 1440; return target.AsDelta() - (target.base() % rounding); }; - if (_scaled_date_ticks >= ((int64)1 << 60)) { + if (_scaled_date_ticks >= ((int64_t)1 << 60)) { tick_adjust = get_tick_adjust(_scaled_date_ticks); - } else if (_scaled_date_ticks <= -((int64)1 << 60)) { + } else if (_scaled_date_ticks <= -((int64_t)1 << 60)) { tick_adjust = -get_tick_adjust(-(_scaled_date_ticks.base())); } else { return; @@ -104,11 +104,11 @@ void SetDate(Date date, DateFract fract, bool preserve_scaled_ticks) void SetScaledTickVariables() { - _scaled_date_ticks = ((int64)(DateToDateTicks(_date, _date_fract).base()) * _settings_game.economy.day_length_factor) + _tick_skip_counter + _scaled_date_ticks_offset; + _scaled_date_ticks = ((int64_t)(DateToDateTicks(_date, _date_fract).base()) * _settings_game.economy.day_length_factor) + _tick_skip_counter + _scaled_date_ticks_offset; } #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), @@ -140,7 +140,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, @@ -160,7 +160,7 @@ YearMonthDay ConvertDateToYMD(Date date) /* There are 97 leap years in 400 years */ Year yr = 400 * (date.base() / (DAYS_IN_YEAR * 400 + 97)); int rem = date.base() % (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 @@ -270,7 +270,7 @@ static void OnNewYear() LinkGraphSchedule::instance.ShiftDates(-days_this_year); ShiftOrderDates(-days_this_year); ShiftVehicleDates(-days_this_year); - _scaled_date_ticks_offset += ((int64)days_this_year) * (DAY_TICKS * _settings_game.economy.day_length_factor); + _scaled_date_ticks_offset += ((int64_t)days_this_year) * (DAY_TICKS * _settings_game.economy.day_length_factor); /* Because the _date wraps here, and text-messages expire by game-days, we have to clean out * all of them if the date is set back, else those messages will hang for ever */ @@ -369,7 +369,7 @@ void IncreaseDate() if (new_year) OnNewYear(); } -const char *debug_date_dumper::HexDate(Date date, DateFract date_fract, uint8 tick_skip_counter) +const char *debug_date_dumper::HexDate(Date date, DateFract date_fract, uint8_t tick_skip_counter) { seprintf(this->buffer, lastof(this->buffer), "date{%08x; %02x; %02x}", date.base(), date_fract, tick_skip_counter); return this->buffer; diff --git a/src/date_func.h b/src/date_func.h index 227efd68c3..87cded0928 100644 --- a/src/date_func.h +++ b/src/date_func.h @@ -17,16 +17,16 @@ extern YearMonthDay _cur_date_ymd; extern Date _date; extern DateFract _date_fract; -extern uint64 _tick_counter; -extern uint8 _tick_skip_counter; -extern uint64 _scaled_tick_counter; +extern uint64_t _tick_counter; +extern uint8_t _tick_skip_counter; +extern uint64_t _scaled_tick_counter; extern DateTicksScaled _scaled_date_ticks; extern DateTicksScaled _scaled_date_ticks_offset; -extern uint32 _quit_after_days; +extern uint32_t _quit_after_days; extern YearMonthDay _game_load_cur_date_ymd; extern DateFract _game_load_date_fract; -extern uint8 _game_load_tick_skip_counter; +extern uint8_t _game_load_tick_skip_counter; void SetDate(Date date, DateFract fract, bool preserve_scaled_ticks = true); YearMonthDay ConvertDateToYMD(Date date); @@ -57,7 +57,7 @@ inline Date ScaledDateTicksToDate(DateTicksScaled ticks) inline DateTicksScaled DateToScaledDateTicks(Date date) { - return ((int64)date.base() * DAY_TICKS * _settings_game.economy.day_length_factor) + _scaled_date_ticks_offset.base(); + return ((int64_t)date.base() * DAY_TICKS * _settings_game.economy.day_length_factor) + _scaled_date_ticks_offset.base(); } inline DateTicks ScaledDateTicksToDateTicks(DateTicksScaled ticks) @@ -67,7 +67,7 @@ inline DateTicks ScaledDateTicksToDateTicks(DateTicksScaled ticks) inline DateTicksScaled DateTicksToScaledDateTicks(DateTicks date_ticks) { - return ((int64)date_ticks.base() * _settings_game.economy.day_length_factor) + _scaled_date_ticks_offset.base(); + return ((int64_t)date_ticks.base() * _settings_game.economy.day_length_factor) + _scaled_date_ticks_offset.base(); } /** @@ -101,7 +101,7 @@ inline DateTicks NowDateTicks() } struct debug_date_dumper { - const char *HexDate(Date date, DateFract date_fract, uint8 tick_skip_counter); + const char *HexDate(Date date, DateFract date_fract, uint8_t tick_skip_counter); inline const char *HexDate() { return this->HexDate(_date, _date_fract, _tick_skip_counter); } diff --git a/src/date_gui.cpp b/src/date_gui.cpp index e3e066ce86..df47ff2a2c 100644 --- a/src/date_gui.cpp +++ b/src/date_gui.cpp @@ -61,7 +61,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 ea6126e07d..ef0438f4cc 100644 --- a/src/date_type.h +++ b/src/date_type.h @@ -14,7 +14,7 @@ #include "core/math_func.hpp" /** - * 1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885. On + * 1 day is 74 ticks; _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 @@ -26,12 +26,12 @@ static const int MONTHS_IN_YEAR = 12; ///< months per year static const int SECONDS_PER_DAY = 2; ///< approximate seconds per day, not for precise calculations -typedef uint16 DateFract; ///< The fraction of a date we're in, i.e. the number of ticks since the last date changeover -typedef int32 Ticks; ///< The type to store ticks in +typedef uint16_t DateFract; ///< The fraction of a date we're in, i.e. the number of ticks since the last date changeover +typedef int32_t Ticks; ///< The type to store ticks in -typedef int32 Year; ///< Type for the year, note: 0 based, i.e. starts at the year 0. -typedef uint8 Month; ///< Type for the month, note: 0 based, i.e. 0 = January, 11 = December. -typedef uint8 Day; ///< Type for the day of the month, note: 1 based, first day of a month is 1. +typedef int32_t Year; ///< Type for the year, note: 0 based, i.e. starts at the year 0. +typedef uint8_t Month; ///< Type for the month, note: 0 based, i.e. 0 = January, 11 = December. +typedef uint8_t Day; ///< Type for the day of the month, note: 1 based, first day of a month is 1. /* The type to store our dates in */ using DateDelta = StrongType::Typedef; @@ -165,7 +165,7 @@ static constexpr Year ORIGINAL_MAX_YEAR = 2090; */ static constexpr Date DateAtStartOfYear(Year year) { - int32 year_as_int = year; + int32_t year_as_int = year; uint number_of_leap_years = (year == 0) ? 0 : ((year_as_int - 1) / 4 - (year_as_int - 1) / 100 + (year_as_int - 1) / 400 + 1); /* Hardcode the number of days in a year because we can't access CalendarTime from here. */ diff --git a/src/debug.cpp b/src/debug.cpp index b95cf1cdc0..2affce019d 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -73,7 +73,7 @@ std::string _loadgame_DBGL_data; bool _save_DBGC_data = false; std::string _loadgame_DBGC_data; -uint32 _misc_debug_flags; +uint32_t _misc_debug_flags; struct DebugLevel { const char *name; @@ -336,8 +336,8 @@ const char *log_prefix::GetLogPrefix() struct DesyncMsgLogEntry { Date date; DateFract date_fract; - uint8 tick_skip_counter; - uint32 src_id; + uint8_t tick_skip_counter; + uint32_t src_id; std::string msg; DesyncMsgLogEntry() { } @@ -416,7 +416,7 @@ void LogDesyncMsg(std::string msg) _desync_msg_log.LogMsg(DesyncMsgLogEntry(std::move(msg))); } -void LogRemoteDesyncMsg(Date date, DateFract date_fract, uint8 tick_skip_counter, uint32 src_id, std::string msg) +void LogRemoteDesyncMsg(Date date, DateFract date_fract, uint8_t tick_skip_counter, uint32_t src_id, std::string msg) { DesyncMsgLogEntry entry(std::move(msg)); entry.date = date; diff --git a/src/debug.h b/src/debug.h index 75b5aa613c..28a3cc88eb 100644 --- a/src/debug.h +++ b/src/debug.h @@ -99,9 +99,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_;\ @@ -115,8 +115,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/debug_desync.h b/src/debug_desync.h index 121b831dc0..4e6fdf9ce8 100644 --- a/src/debug_desync.h +++ b/src/debug_desync.h @@ -12,7 +12,7 @@ #include -enum CheckCachesFlags : uint32 { +enum CheckCachesFlags : uint32_t { CHECK_CACHE_NONE = 0, CHECK_CACHE_GENERAL = 1 << 0, CHECK_CACHE_INFRA_TOTALS = 1 << 1, diff --git a/src/debug_settings.h b/src/debug_settings.h index 58c7062c7f..586d87f05e 100644 --- a/src/debug_settings.h +++ b/src/debug_settings.h @@ -53,6 +53,6 @@ enum MiscDebugFlags { MDF_NEWGRF_SG_SAVE_RAW, MDF_SPECIAL_CMDS, }; -extern uint32 _misc_debug_flags; +extern uint32_t _misc_debug_flags; #endif /* DEBUG_SETTINGS_H */ diff --git a/src/departures.cpp b/src/departures.cpp index d797de7eb0..af3f754714 100644 --- a/src/departures.cpp +++ b/src/departures.cpp @@ -87,7 +87,7 @@ static bool IsArrival(const Order *order, StationID station) { !(order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION)); } -static uint8 GetDepartureConditionalOrderMode(const Order *order, const Vehicle *v, DateTicksScaled eval_date) +static uint8_t GetDepartureConditionalOrderMode(const Order *order, const Vehicle *v, DateTicksScaled eval_date) { if (order->GetConditionVariable() == OCV_UNCONDITIONALLY) return 1; if (order->GetConditionVariable() == OCV_TIME_DATE) { @@ -116,8 +116,8 @@ static bool VehicleSetNextDepartureTime(Ticks *previous_departure, Ticks *waitin DateTicksScaled actual_departure = -1; const DateTicksScaled begin_time = ds.GetScheduledDispatchStartTick(); - const uint32 dispatch_duration = ds.GetScheduledDispatchDuration(); - const int32 max_delay = ds.GetScheduledDispatchDelay(); + const uint32_t dispatch_duration = ds.GetScheduledDispatchDuration(); + const int32_t max_delay = ds.GetScheduledDispatchDelay(); /* Earliest possible departure according to schedue */ DateTicksScaled earliest_departure = begin_time + ds.GetScheduledDispatchLastDispatch(); @@ -174,7 +174,7 @@ static bool VehicleSetNextDepartureTime(Ticks *previous_departure, Ticks *waitin static void ScheduledDispatchDepartureLocalFix(DepartureList *departure_list) { /* Seperate departure by each shared order group */ - btree::btree_map> separated_departure; + btree::btree_map> separated_departure; for (Departure* departure : *departure_list) { separated_departure[departure->vehicle->orders->index].push_back(departure); } diff --git a/src/departures_gui.cpp b/src/departures_gui.cpp index fa6401421b..4214e6be6c 100644 --- a/src/departures_gui.cpp +++ b/src/departures_gui.cpp @@ -95,7 +95,7 @@ protected: bool departures_invalid; ///< The departures and arrivals list are currently invalid. bool vehicles_invalid; ///< The vehicles list is currently invalid. uint entry_height; ///< The height of an entry in the departures list. - uint64 elapsed_ms; ///< The number of milliseconds that have elapsed since the window was created. Used for scrolling text. + uint64_t elapsed_ms; ///< The number of milliseconds that have elapsed since the window was created. Used for scrolling text. int calc_tick_countdown; ///< The number of ticks to wait until recomputing the departure list. Signed in case it goes below zero. bool show_types[4]; ///< The vehicle types to show in the departure list. bool departure_types[3]; ///< The types of departure to show in the departure list. @@ -211,7 +211,7 @@ protected: } for (GroupID gid : groups) { - SetDParam(0, (uint64)(gid | GROUP_NAME_HIERARCHY)); + SetDParam(0, (uint64_t)(gid | GROUP_NAME_HIERARCHY)); int width = (GetStringBoundingBox(STR_DEPARTURES_GROUP)).width + 4; if (width > this->group_width) this->group_width = width; } @@ -401,7 +401,7 @@ public: if (this->departures_invalid) return; /* We need to find the departure corresponding to where the user clicked. */ - uint32 id_v = (pt.y - this->GetWidget(WID_DB_LIST)->pos_y) / this->entry_height; + uint32_t id_v = (pt.y - this->GetWidget(WID_DB_LIST)->pos_y) / this->entry_height; if (id_v >= this->vscroll->GetCapacity()) return; // click out of bounds @@ -959,7 +959,7 @@ void DeparturesWindow::DrawDeparturesListItems(const Rect &r) const const int group_left = ltr ? text_right - PadWidth(toc_width) - group_width : text_left + PadWidth(toc_width); const int group_right = ltr ? text_right - PadWidth(toc_width) : text_left + PadWidth(toc_width) + group_width; - SetDParam(0, (uint64)(d->vehicle->group_id | GROUP_NAME_HIERARCHY)); + SetDParam(0, (uint64_t)(d->vehicle->group_id | GROUP_NAME_HIERARCHY)); DrawString(group_left, group_right, y + 1, STR_DEPARTURES_GROUP); } @@ -968,7 +968,7 @@ void DeparturesWindow::DrawDeparturesListItems(const Rect &r) const const int toc_left = ltr ? text_right - toc_width : text_left; const int toc_right = ltr ? text_right : text_left + toc_width; - SetDParam(0, (uint64)(d->vehicle->owner)); + SetDParam(0, (uint64_t)(d->vehicle->owner)); DrawString(toc_left, toc_right, y + 1, STR_DEPARTURES_TOC, TC_FROMSTRING, SA_RIGHT); } @@ -1044,7 +1044,7 @@ void DeparturesWindow::DrawDeparturesListItems(const Rect &r) const AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi); /* The scrolling text starts out of view at the right of the screen and finishes when it is out of view at the left of the screen. */ - int64 elapsed_scroll_px = this->elapsed_ms / 27; + int64_t elapsed_scroll_px = this->elapsed_ms / 27; int pos = ltr ? text_right - (elapsed_scroll_px % (list_width + text_right - text_left)) : text_left + (elapsed_scroll_px % (list_width + text_right - text_left)); diff --git a/src/depot_base.h b/src/depot_base.h index f1f0be5bc1..c0c771a2b4 100644 --- a/src/depot_base.h +++ b/src/depot_base.h @@ -19,7 +19,7 @@ extern DepotPool _depot_pool; struct Depot : DepotPool::PoolItem<&_depot_pool> { /* DepotID index member of DepotPool is 2 bytes. */ - 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) TileIndex xy; Town *town; TinyString name; diff --git a/src/depot_cmd.cpp b/src/depot_cmd.cpp index 9379afb82f..da774a384d 100644 --- a/src/depot_cmd.cpp +++ b/src/depot_cmd.cpp @@ -44,7 +44,7 @@ static bool IsUniqueDepotName(const char *name) * @param text the new name or an empty string when resetting to the default * @return the cost of this operation or an error */ -CommandCost CmdRenameDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRenameDepot(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Depot *d = Depot::GetIfValid(p1); if (d == nullptr) return CMD_ERROR; diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 72e9b58646..73d8ec2a57 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -122,7 +122,7 @@ extern void DepotSortList(VehicleList *list); * @param p2 unused * @param cmd unused */ -void CcCloneVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcCloneVehicle(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; @@ -400,7 +400,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))); @@ -1135,7 +1135,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); } @@ -1191,7 +1191,7 @@ void DeleteDepotHighlightOfVehicle(const Vehicle *v) } } -enum DepotTooltipMode : uint8 { +enum DepotTooltipMode : uint8_t { DTM_OFF, DTM_SIMPLE, DTM_DETAILED diff --git a/src/depot_type.h b/src/depot_type.h index 69b0ef166f..51dd5bff1d 100644 --- a/src/depot_type.h +++ b/src/depot_type.h @@ -10,7 +10,7 @@ #ifndef DEPOT_TYPE_H #define DEPOT_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 = UINT16_MAX; diff --git a/src/disaster_vehicle.cpp b/src/disaster_vehicle.cpp index 801040dfca..0eca295acd 100644 --- a/src/disaster_vehicle.cpp +++ b/src/disaster_vehicle.cpp @@ -54,9 +54,9 @@ #include "safeguards.h" /** Delay counter for considering the next disaster. */ -uint16 _disaster_delay; +uint16_t _disaster_delay; -static uint32 _disaster_vehicle_count = 0; +static uint32_t _disaster_vehicle_count = 0; static void DisasterClearSquare(TileIndex tile) { @@ -308,7 +308,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, @@ -444,7 +444,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; @@ -462,7 +462,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, @@ -664,7 +664,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, @@ -736,7 +736,7 @@ static DisasterVehicleTickProc * const _disastervehicle_tick_procs[] = { bool DisasterVehicle::Tick() { DEBUG_UPDATESTATECHECKSUM("DisasterVehicle::Tick: v: %u, x: %d, y: %d", this->index, this->x_pos, this->y_pos); - UpdateStateChecksum((((uint64) this->x_pos) << 32) | this->y_pos); + UpdateStateChecksum((((uint64_t) this->x_pos) << 32) | this->y_pos); return _disastervehicle_tick_procs[this->subtype](this); } @@ -874,7 +874,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)) { @@ -1001,7 +1001,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/dock_gui.cpp b/src/dock_gui.cpp index 1e55336307..ccfc4bdf1e 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -39,7 +39,7 @@ static void ShowBuildDocksDepotPicker(Window *parent); static Axis _ship_depot_direction; -void CcBuildDocks(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcBuildDocks(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; @@ -47,7 +47,7 @@ void CcBuildDocks(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } -void CcPlaySound_CONSTRUCTION_WATER(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcPlaySound_CONSTRUCTION_WATER(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_02_CONSTRUCTION_WATER, tile); } @@ -207,7 +207,7 @@ struct BuildDocksToolbarWindow : Window { break; case WID_DT_STATION: { // Build station button - uint32 p2 = (uint32)INVALID_STATION << 16; // no station to join + uint32_t p2 = (uint32_t)INVALID_STATION << 16; // no station to join /* tile is always the land tile, so need to evaluate _thd.pos */ CommandContainer cmdcont = NewCommandContainerBasic(tile, _ctrl_pressed, p2, CMD_BUILD_DOCK | CMD_MSG(STR_ERROR_CAN_T_BUILD_DOCK_HERE), CcBuildDocks); @@ -307,7 +307,7 @@ static EventState DockToolbarGlobalHotkeys(int hotkey) return w->OnHotkey(hotkey); } -const uint16 _dockstoolbar_aqueduct_keys[] = {'B', '8', 0}; +const uint16_t _dockstoolbar_aqueduct_keys[] = {'B', '8', 0}; static Hotkey dockstoolbar_hotkeys[] = { Hotkey('1', "canal", WID_DT_CANAL), diff --git a/src/economy.cpp b/src/economy.cpp index ff4527f7c6..f5089a77dd 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -80,9 +80,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; @@ -103,7 +103,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; Money _additional_cash_required; @@ -325,7 +325,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; } @@ -779,13 +779,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)); } @@ -871,7 +871,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++) { @@ -898,7 +898,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; @@ -924,7 +924,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); @@ -1088,7 +1088,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()) { @@ -1098,8 +1098,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); @@ -1118,7 +1118,7 @@ Money GetTransportedGoodsIncome(uint num_pieces, uint dist, uint16 transit_perio static const int TIME_FACTOR_FRAC_BITS = 4; static const int TIME_FACTOR_FRAC = 1 << TIME_FACTOR_FRAC_BITS; - if (_settings_game.economy.payment_algorithm == CPA_TRADITIONAL) transit_periods = std::min(transit_periods, 0xFFu); + if (_settings_game.economy.payment_algorithm == CPA_TRADITIONAL) transit_periods = std::min(transit_periods, 0xFFu); const int periods1 = cs->transit_periods[0]; const int periods2 = cs->transit_periods[1]; @@ -1383,7 +1383,7 @@ static Money DeliverGoods(int num_pieces, CargoID cargo_type, StationID dest, ui 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; @@ -1583,7 +1583,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); @@ -2500,7 +2500,7 @@ static void DoAcquireCompany(Company *c, bool hostile_takeover) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuyShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuyShareInCompany(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { CommandCost cost(EXPENSES_OTHER); CompanyID target_company = (CompanyID)p1; @@ -2549,7 +2549,7 @@ CommandCost CmdBuyShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdSellShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSellShareInCompany(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { CompanyID target_company = (CompanyID)p1; Company *c = Company::GetIfValid(target_company); @@ -2591,7 +2591,7 @@ CommandCost CmdSellShareInCompany(TileIndex tile, DoCommandFlag flags, uint32 p1 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuyCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuyCompany(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { CompanyID target_company = (CompanyID)p1; Company *c = Company::GetIfValid(target_company); @@ -2641,7 +2641,7 @@ CommandCost CmdBuyCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdDeclineBuyCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdDeclineBuyCompany(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { CompanyID target_company = (CompanyID)p1; Company *c = Company::GetIfValid(target_company); @@ -2668,8 +2668,8 @@ uint ScaleQuantity(uint amount, int cf, int fine, bool allow_trunc) { if (fine != 0) { // 2^0.1 << 16 to 2^0.9 << 16 - const uint32 adj[9] = {70239, 75281, 80684, 86475, 92681, 99334, 106463, 114104, 122294}; - uint64 scaled_amount = ((uint64) amount) * ((uint64) adj[fine - 1]); + const uint32_t adj[9] = {70239, 75281, 80684, 86475, 92681, 99334, 106463, 114104, 122294}; + uint64_t scaled_amount = ((uint64_t) amount) * ((uint64_t) adj[fine - 1]); amount = scaled_amount >> 16; } diff --git a/src/economy_func.h b/src/economy_func.h index 8d8e79e774..0c35d078a9 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 7601601d5d..e8918f82b7 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, @@ -26,19 +26,19 @@ enum EconomyType : uint8 { /** Data of the economy. */ struct Economy { - Money max_loan; ///< NOSAVE: Maximum possible loan - int16 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 + Money max_loan; ///< NOSAVE: Maximum possible loan + 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_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 { @@ -204,17 +204,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. @@ -237,7 +237,7 @@ 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; enum CargoPaymentAlgorithm : byte { CPA_BEGIN = 0, ///< Used for iterations and limit testing diff --git a/src/effectvehicle.cpp b/src/effectvehicle.cpp index e5888e8de5..cbd9d5fb83 100644 --- a/src/effectvehicle.cpp +++ b/src/effectvehicle.cpp @@ -43,7 +43,7 @@ static bool IncrementSprite(EffectVehicle *v, SpriteID last) static void ChimneySmokeInit(EffectVehicle *v) { - uint32 r = Random(); + uint32_t r = Random(); v->sprite_seq.Set(SPR_CHIMNEY_SMOKE_0 + GB(r, 0, 3)); v->UpdateSpriteSeqBound(); v->progress = GB(r, 16, 3); @@ -296,8 +296,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 }, @@ -341,9 +341,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; }; @@ -673,7 +673,7 @@ EffectVehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, Eff bool EffectVehicle::Tick() { DEBUG_UPDATESTATECHECKSUM("EffectVehicle::Tick: v: %u, x: %d, y: %d", this->index, this->x_pos, this->y_pos); - UpdateStateChecksum((((uint64) this->x_pos) << 32) | this->y_pos); + UpdateStateChecksum((((uint64_t) this->x_pos) << 32) | this->y_pos); return _effect_tick_procs[this->subtype](this); } diff --git a/src/effectvehicle_base.h b/src/effectvehicle_base.h index bb0617faa2..5164f36454 100644 --- a/src/effectvehicle_base.h +++ b/src/effectvehicle_base.h @@ -22,8 +22,8 @@ * - bubbles (industry) */ struct EffectVehicle FINAL : public SpecializedVehicle { - uint16 animation_state; ///< State primarily used to change the graphics/behaviour. - byte animation_substate; ///< Sub state to time the change of 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! */ EffectVehicle() : SpecializedVehicleBase() {} diff --git a/src/elrail.cpp b/src/elrail.cpp index bb4cfe520a..732db18fdc 100644 --- a/src/elrail.cpp +++ b/src/elrail.cpp @@ -265,8 +265,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); return (z + 2) & ~3; // this means z = (z + TILE_HEIGHT / 4) / (TILE_HEIGHT / 2) * (TILE_HEIGHT / 2); } @@ -695,7 +695,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 de5808b458..124dffb0b9 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 64d967dc32..d33074e48c 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -48,7 +48,7 @@ EngineOverrideManager _engine_mngr; static 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), @@ -56,7 +56,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), @@ -150,7 +150,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; @@ -223,7 +223,7 @@ bool Engine::CanPossiblyCarryCargo() 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; @@ -241,7 +241,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; + uint16_t callback; if (this->refit_capacity_values != nullptr) { const EngineRefitCapacityValue *caps = this->refit_capacity_values.get(); while (true) { @@ -296,8 +296,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; @@ -494,7 +494,7 @@ DateDelta 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: @@ -573,7 +573,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) { @@ -672,7 +672,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 */ @@ -736,7 +736,7 @@ void SetYearEngineAgingStops() * @param aging_date The date used for age calculations. * @param seed Random seed. */ -void StartupOneEngine(Engine *e, Date aging_date, const YearMonthDay &aging_ymd, uint32 seed, Date no_introduce_after_date) +void StartupOneEngine(Engine *e, Date aging_date, const YearMonthDay &aging_ymd, uint32_t seed, Date no_introduce_after_date) { const EngineInfo *ei = &e->info; @@ -753,7 +753,7 @@ void StartupOneEngine(Engine *e, Date aging_date, const YearMonthDay &aging_ymd, ei->base_intro.base() ^ 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. @@ -832,7 +832,7 @@ void StartupEngines() no_introduce_after_date = ConvertYMDToDate(_settings_game.vehicle.no_introduce_vehicles_after, 0, 1) - 1; } - uint32 seed = Random(); + uint32_t seed = Random(); for (Engine *e : Engine::Iterate()) { StartupOneEngine(e, aging_date, aging_ymd, seed, no_introduce_after_date); @@ -951,7 +951,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) { @@ -1050,7 +1050,7 @@ void ClearEnginesHiddenFlagOfCompany(CompanyID cid) * @param text Unused. * @return The cost of this operation or an error. */ -CommandCost CmdSetVehicleVisibility(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSetVehicleVisibility(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Engine *e = Engine::GetIfValid(GB(p2, 0, 31)); if (e == nullptr || _current_company >= MAX_COMPANIES) return CMD_ERROR; @@ -1074,7 +1074,7 @@ CommandCost CmdSetVehicleVisibility(TileIndex tile, DoCommandFlag flags, uint32 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdWantEnginePreview(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdWantEnginePreview(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Engine *e = Engine::GetIfValid(p1); if (e == nullptr || !(e->flags & ENGINE_EXCLUSIVE_PREVIEW) || e->preview_company != _current_company) return CMD_ERROR; @@ -1095,7 +1095,7 @@ CommandCost CmdWantEnginePreview(TileIndex tile, DoCommandFlag flags, uint32 p1, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdEngineCtrl(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdEngineCtrl(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; EngineID engine_id = (EngineID)p1; @@ -1269,7 +1269,7 @@ static bool IsUniqueEngineName(const char *name) * @param text the new name or an empty string when resetting to the default * @return the cost of this operation or an error */ -CommandCost CmdRenameEngine(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRenameEngine(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Engine *e = Engine::GetIfValid(p1); if (e == nullptr) return CMD_ERROR; diff --git a/src/engine_base.h b/src/engine_base.h index 93bed32805..c7f2bc978a 100644 --- a/src/engine_base.h +++ b/src/engine_base.h @@ -39,29 +39,29 @@ extern EnginePool _engine_pool; struct EngineRefitCapacityValue { CargoTypes cargoes; - uint32 capacity; + uint32_t capacity; }; struct Engine : EnginePool::PoolItem<&_engine_pool> { - TinyString name; ///< Custom name of engine. - 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. - 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 - VehicleType type; ///< %Vehicle type, ie #VEH_ROAD, #VEH_TRAIN, etc. + TinyString name; ///< Custom name of engine. + Date intro_date; ///< Date of introduction of the engine. + 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_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. EngineID display_last_variant; ///< NOSAVE client-side-only last variant selected. @@ -84,11 +84,11 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> { */ GRFFilePropsBase grf_prop; std::vector overrides; - uint16 list_position; + uint16_t list_position; SpriteGroupCallbacksUsed callbacks_used = SGCU_ALL; - uint64 cb36_properties_used = UINT64_MAX; - btree::btree_map sprite_group_cb36_properties_used; + uint64_t cb36_properties_used = UINT64_MAX; + btree::btree_map sprite_group_cb36_properties_used; std::unique_ptr refit_capacity_values; @@ -112,7 +112,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; bool CanPossiblyCarryCargo() const; @@ -128,7 +128,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); } @@ -141,7 +141,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> { uint GetDisplayWeight() const; uint GetDisplayMaxTractiveEffort() const; DateDelta GetLifeLengthInDays() const; - uint16 GetRange() const; + uint16_t GetRange() const; StringID GetAircraftTypeText() const; /** @@ -194,7 +194,7 @@ struct Engine : EnginePool::PoolItem<&_engine_pool> { return this->grf_prop.grffile; } - uint32 GetGRFID() const; + uint32_t GetGRFID() const; struct EngineTypeFilter { VehicleType vt; @@ -215,10 +215,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 - VehicleType type; ///< The engine type - uint8 substitute_id; ///< The (original) entity ID to use if this GRF is not available (currently not used) + 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_t substitute_id; ///< The (original) entity ID to use if this GRF is not available (currently not used) }; /** @@ -229,7 +229,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 174622c0de..3ef321d887 100644 --- a/src/engine_func.h +++ b/src/engine_func.h @@ -20,14 +20,14 @@ void CheckEngines(); void AnalyseEngineCallbacks(); /* 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, Date aging_date, const YearMonthDay &aging_ymd, uint32 seed, Date no_introduce_after_date); +void StartupOneEngine(Engine *e, Date aging_date, const YearMonthDay &aging_ymd, uint32_t seed, Date no_introduce_after_date); uint GetTotalCapacityOfArticulatedParts(EngineID engine); diff --git a/src/engine_gui.cpp b/src/engine_gui.cpp index fcecd5f6d5..9b140a9335 100644 --- a/src/engine_gui.cpp +++ b/src/engine_gui.cpp @@ -220,9 +220,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 d8944fbc67..6abd3b986c 100644 --- a/src/engine_gui.h +++ b/src/engine_gui.h @@ -21,7 +21,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 bbb579b7b2..149c9ffe50 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. @@ -100,13 +100,13 @@ struct AircraftVehicleInfo { byte image_index; byte cost_factor; byte running_cost; - byte subtype; ///< Type of aircraft. @see AircraftSubTypeBits + 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) - byte mail_capacity; ///< Mail capacity (bags). - uint16 passenger_capacity; ///< Passenger capacity (persons). - uint16 max_range; ///< Maximum range of this aircraft. + uint16_t max_speed; ///< Maximum speed (1 unit = 8 mph = 12.8 km-ish/h) + byte mail_capacity; ///< Mail capacity (bags). + 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 - 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 + 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 : uint8 { +enum class ExtraEngineFlags : uint8_t { None = 0, NoNews = (1U << 0), ///< No 'new vehicle' news will be generated. NoPreview = (1U << 1), ///< No exclusive preview will be offered. @@ -150,12 +150,12 @@ struct EngineInfo { CargoID cargo_type; 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 - StringID string_id; ///< Default name of engine - uint16 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. + byte misc_flags; ///< Miscellaneous flags. @see EngineMiscFlags + 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_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 = 64; ///< The maximum length of an engine name in characters including '\0' diff --git a/src/error.h b/src/error.h index b5df4705bb..b385719b8e 100644 --- a/src/error.h +++ b/src/error.h @@ -33,8 +33,8 @@ protected: GUITimer display_timer; ///< Timer before closing the message. 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, uint duration = 0, 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, uint duration = 0, 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); @@ -64,7 +64,7 @@ typedef std::list ErrorList; void ScheduleErrorMessage(ErrorList &datas); void ScheduleErrorMessage(const ErrorMessageData &data); -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(); void ShowFirstError(); diff --git a/src/error_gui.cpp b/src/error_gui.cpp index 0a8ea693b4..2916163468 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, uint duration, 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, uint duration, int x, int y, const GRFFile *textref_stack_grffile, uint textref_stack_size, const uint32_t *textref_stack, StringID extra_msg) : textref_stack_grffile(textref_stack_grffile), textref_stack_size(textref_stack_size), summary_msg(summary_msg), @@ -132,7 +132,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; @@ -203,7 +203,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) { @@ -365,11 +365,11 @@ void UnshowCriticalError() * @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 showed 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/event_logs.cpp b/src/event_logs.cpp index 0a6399466b..dc951be76d 100644 --- a/src/event_logs.cpp +++ b/src/event_logs.cpp @@ -44,7 +44,7 @@ struct SpecialEventLogEntry { std::string msg; Date date; DateFract date_fract; - uint8 tick_skip_counter; + uint8_t tick_skip_counter; CompanyID current_company; CompanyID local_company; diff --git a/src/event_logs.h b/src/event_logs.h index bdf3bdc8c4..b0dc62098f 100644 --- a/src/event_logs.h +++ b/src/event_logs.h @@ -13,7 +13,7 @@ #include "core/enum_type.hpp" #include -enum GameEventFlags : uint32 { +enum GameEventFlags : uint32_t { GEF_COMPANY_DELETE = 1 << 0, ///< (d) A company has been deleted GEF_COMPANY_MERGE = 1 << 1, ///< (m) A company has been bought by another GEF_RELOAD_NEWGRF = 1 << 2, ///< (n) ReloadNewGRFData() has been called diff --git a/src/fios.cpp b/src/fios.cpp index 194b67fd7e..7f0def93f1 100644 --- a/src/fios.cpp +++ b/src/fios.cpp @@ -623,7 +623,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. @@ -671,7 +671,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 b7d614b31b..e53686393b 100644 --- a/src/fios.h +++ b/src/fios.h @@ -27,7 +27,7 @@ enum SaveLoadInvalidateWindowData { /** 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 3f481e33ee..63a2b74500 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -760,7 +760,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 18686ea25f..948bd2f8d1 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; extern int font_height_cache[FS_END]; ///< Cache of font heights @@ -83,7 +83,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; @@ -116,7 +116,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. @@ -124,7 +124,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. diff --git a/src/fontcache/freetypefontcache.cpp b/src/fontcache/freetypefontcache.cpp index 24f3e10407..4a64217224 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 stdstr_fmt("%s, %s", face->family_name, face->style_name); } bool IsBuiltInFont() override { return false; } const void *GetOSHandle() override { return &face; } @@ -278,7 +278,7 @@ const Sprite *FreeTypeFontCache::InternalGetGlyph(GlyphID key, bool aa) } -GlyphID FreeTypeFontCache::MapCharToGlyph(WChar key) +GlyphID FreeTypeFontCache::MapCharToGlyph(char32_t key) { assert(IsPrintable(key)); @@ -289,7 +289,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 093fce7b6a..054957c4e0 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 80f127852a..628a6d08e1 100644 --- a/src/fontcache/spritefontcache.h +++ b/src/fontcache/spritefontcache.h @@ -17,7 +17,7 @@ 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: diff --git a/src/fontcache/truetypefontcache.cpp b/src/fontcache/truetypefontcache.cpp index f6c43e043a..78e787bea0 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 6bb2e46a90..0e37318828 100644 --- a/src/fontcache/truetypefontcache.h +++ b/src/fontcache/truetypefontcache.h @@ -56,14 +56,14 @@ 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); } virtual void InitializeUnicodeGlyphMap() override { @@ -73,7 +73,7 @@ public: 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 710d7bb861..8269aa6cf0 100644 --- a/src/framerate_gui.cpp +++ b/src/framerate_gui.cpp @@ -407,13 +407,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; } @@ -421,7 +421,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; } @@ -596,7 +596,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); @@ -618,7 +618,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); @@ -652,7 +652,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 + GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; // first line contains headings in the value columns for (PerformanceElement e : DISPLAY_ORDER_PFE) { @@ -945,7 +945,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]; @@ -975,8 +975,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 3ca0a7abd0..8dd84c29ce 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 cd3b010364..55a8c95e05 100644 --- a/src/game/game_gui.cpp +++ b/src/game/game_gui.cpp @@ -376,7 +376,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_instance.cpp b/src/game/game_instance.cpp index 985b50fc75..e95a77ddac 100644 --- a/src/game/game_instance.cpp +++ b/src/game/game_instance.cpp @@ -88,7 +88,7 @@ void GameInstance::Died() * @param p3 p3 as given to DoCommandPInternal. * @param cmd cmd as given to DoCommandPInternal. */ -void CcGame(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcGame(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (Game::GetGameInstance()->DoCommandCallback(result, tile, p1, p2, p3, cmd)) { Game::GetGameInstance()->Continue(); 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 413d9532b3..64a6eab7c7 100644 --- a/src/gamelog.cpp +++ b/src/gamelog.cpp @@ -26,7 +26,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! @@ -155,7 +155,7 @@ struct GRFPresence{ GRFPresence(const GRFConfig *gc) : gc(gc), was_missing(false) {} GRFPresence() = default; }; -typedef btree::btree_map GrfIDMapping; +typedef btree::btree_map GrfIDMapping; /** * Prints active gamelog @@ -443,7 +443,7 @@ void GamelogOldver() if (lc == nullptr) return; lc->oldver.type = _savegame_type; - lc->oldver.version = (_savegame_type == SGT_OTTD ? ((uint32)_sl_version << 8 | _sl_minor_version) : _ttdp_version); + lc->oldver.version = (_savegame_type == SGT_OTTD ? ((uint32_t)_sl_version << 8 | _sl_minor_version) : _ttdp_version); } /** @@ -452,7 +452,7 @@ void GamelogOldver() * @param oldval old setting value * @param newval new setting value */ -void GamelogSetting(const char *name, int32 oldval, int32 newval) +void GamelogSetting(const char *name, int32_t oldval, int32_t newval) { assert(_gamelog_action_type == GLAT_SETTING); @@ -510,7 +510,7 @@ void GamelogTestMode() * @param bug type of bug, @see enum GRFBugs * @param data additional data */ -static void GamelogGRFBug(uint32 grfid, byte bug, uint64 data) +static void GamelogGRFBug(uint32_t grfid, byte bug, uint64_t data) { assert(_gamelog_action_type == GLAT_GRFBUG); @@ -531,7 +531,7 @@ static void GamelogGRFBug(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 GamelogGRFBugReverse(uint32 grfid, uint16 internal_id) +bool GamelogGRFBugReverse(uint32_t grfid, uint16_t internal_id) { for (LoggedAction &la : _gamelog_actions) { for (LoggedChange &lc : la.changes) { @@ -564,7 +564,7 @@ static inline bool IsLoggableGrfConfig(const GRFConfig *g) * Logs removal of a GRF * @param grfid ID of removed GRF */ -void GamelogGRFRemove(uint32 grfid) +void GamelogGRFRemove(uint32_t grfid) { assert(_gamelog_action_type == GLAT_LOAD || _gamelog_action_type == GLAT_GRF); @@ -610,7 +610,7 @@ void GamelogGRFCompatible(const GRFIdentifier *newg) * @param grfid GRF that is moved * @param offset how far it is moved, positive = moved down */ -static void GamelogGRFMove(uint32 grfid, int32 offset) +static void GamelogGRFMove(uint32_t grfid, int32_t offset) { assert(_gamelog_action_type == GLAT_GRF); @@ -626,7 +626,7 @@ static void GamelogGRFMove(uint32 grfid, int32 offset) * Details about parameters changed are not stored * @param grfid ID of GRF to store */ -static void GamelogGRFParameters(uint32 grfid) +static void GamelogGRFParameters(uint32_t grfid) { assert(_gamelog_action_type == GLAT_GRF); @@ -766,7 +766,7 @@ void GamelogGRFUpdate(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 GamelogInfo(const std::vector &gamelog_actions, uint32 *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs) +void GamelogInfo(const std::vector &gamelog_actions, uint32_t *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs) { for (const LoggedAction &la : gamelog_actions) { for (const LoggedChange &lc : la.changes) { diff --git a/src/gamelog.h b/src/gamelog.h index 1d30092228..95469153fd 100644 --- a/src/gamelog.h +++ b/src/gamelog.h @@ -16,7 +16,7 @@ struct LoggedAction; /** The actions we log. */ -enum GamelogActionType : uint8 { +enum GamelogActionType : uint8_t { GLAT_START, ///< Game created GLAT_LOAD, ///< Game loaded GLAT_GRF, ///< GRF changed @@ -51,20 +51,20 @@ bool GamelogTestEmergency(); void GamelogRevision(); void GamelogMode(); void GamelogOldver(); -void GamelogSetting(const char *name, int32 oldval, int32 newval); +void GamelogSetting(const char *name, int32_t oldval, int32_t newval); void GamelogGRFUpdate(const GRFConfig *oldg, const GRFConfig *newg); void GamelogGRFAddList(const GRFConfig *newg); -void GamelogGRFRemove(uint32 grfid); +void GamelogGRFRemove(uint32_t grfid); void GamelogGRFAdd(const GRFConfig *newg); void GamelogGRFCompatible(const GRFIdentifier *newg); void GamelogTestRevision(); void GamelogTestMode(); -bool GamelogGRFBugReverse(uint32 grfid, uint16 internal_id); +bool GamelogGRFBugReverse(uint32_t grfid, uint16_t internal_id); -void GamelogInfo(const std::vector &gamelog_actions, uint32 *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs); +void GamelogInfo(const std::vector &gamelog_actions, uint32_t *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs); const char *GamelogGetLastRevision(const std::vector &gamelog_actions); #endif /* GAMELOG_H */ diff --git a/src/gamelog_internal.h b/src/gamelog_internal.h index b49b42a6df..c55f81fe79 100644 --- a/src/gamelog_internal.h +++ b/src/gamelog_internal.h @@ -44,35 +44,35 @@ struct LoggedChange { } mode; struct { char *text; ///< revision string, _openttd_revision - uint32 newgrf; ///< _openttd_newgrf_version - uint16 slver; ///< _sl_version + uint32_t newgrf; ///< _openttd_newgrf_version + uint16_t slver; ///< _sl_version byte modified; ///< _openttd_revision_modified } revision; struct { - uint32 type; ///< type of savegame, @see SavegameType - uint32 version; ///< major and minor version OR ttdp version + uint32_t type; ///< type of savegame, @see SavegameType + uint32_t version; ///< major and minor version OR ttdp version } oldver; GRFIdentifier grfadd; ///< ID and md5sum of added GRF struct { - uint32 grfid; ///< ID of removed GRF + uint32_t grfid; ///< ID of removed GRF } grfrem; GRFIdentifier grfcompat; ///< ID and new md5sum of changed GRF struct { - uint32 grfid; ///< ID of GRF with changed parameters + uint32_t grfid; ///< ID of GRF with changed parameters } grfparam; struct { - uint32 grfid; ///< ID of moved GRF - int32 offset; ///< offset, positive = move down + uint32_t grfid; ///< ID of moved GRF + int32_t offset; ///< offset, positive = move down } grfmove; struct { - char *name; ///< name of the setting - int32 oldval; ///< old value - int32 newval; ///< new value + char *name; ///< name of the setting + int32_t oldval; ///< old value + int32_t newval; ///< new value } setting; struct { - uint64 data; ///< additional data - uint32 grfid; ///< ID of problematic GRF - byte bug; ///< type of bug, @see enum GRFBugs + uint64_t data; ///< additional data + uint32_t grfid; ///< ID of problematic GRF + byte bug; ///< type of bug, @see enum GRFBugs } grfbug; }; }; @@ -82,7 +82,7 @@ struct LoggedChange { struct LoggedAction { std::vector changes; ///< Changes in this action GamelogActionType at; ///< Type of action - uint64 tick; ///< Tick when it happened + uint64_t tick; ///< Tick when it happened }; extern std::vector _gamelog_actions; diff --git a/src/genworld.h b/src/genworld.h index 3d0436740a..ce4b40cfad 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 { @@ -97,7 +97,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 1a1a5ef54b..ffe88d7693 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -368,7 +368,7 @@ static void LandscapeGenerationCallback(Window *w, bool confirmed) */ static bool CheckMapSize(bool print_warning = true) { - uint64 tiles = 1ULL << (_settings_newgame.game_creation.map_x + _settings_newgame.game_creation.map_y); + uint64_t tiles = 1ULL << (_settings_newgame.game_creation.map_x + _settings_newgame.game_creation.map_y); if (_settings_newgame.game_creation.map_x + _settings_newgame.game_creation.map_y > MAX_MAP_TILES_BITS) { if (print_warning) { @@ -929,7 +929,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); @@ -1072,7 +1072,7 @@ struct GenerateLandscapeWindow : public Window { /* Was 'cancel' pressed? */ if (str == nullptr) return; - int32 value; + int32_t value; if (!StrEmpty(str)) { value = atoi(str); } else { @@ -1207,7 +1207,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; @@ -1389,7 +1389,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 9ebe133cec..495551a861 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -45,8 +45,8 @@ bool _ctrl_pressed; ///< Is Ctrl pressed? bool _shift_pressed; ///< Is Shift pressed? bool _invert_ctrl; bool _invert_shift; -uint16 _game_speed = 100; ///< Current game-speed; 100 is 1x, 0 is infinite. -uint8 _milliseconds_per_tick = 27; ///< Milliseconds per tick +uint16_t _game_speed = 100; ///< Current game-speed; 100 is 1x, 0 is infinite. +uint8_t _milliseconds_per_tick = 27; ///< Milliseconds per tick float _ticks_per_second; ///< Ticks per second bool _left_button_down; ///< Is left mouse button pressed? bool _left_button_clicked; ///< Is left mouse button clicked? @@ -60,7 +60,7 @@ GameMode _game_mode; SwitchMode _switch_mode; ///< The next mainloop command. std::chrono::steady_clock::time_point _switch_mode_time; ///< The time when the switch mode was requested. PauseMode _pause_mode; -uint32 _pause_countdown; +uint32_t _pause_countdown; std::string _switch_baseset; static bool _adjust_gui_zoom_startup_done = false; @@ -81,7 +81,7 @@ struct GfxBlitterCtx { static void GfxMainBlitterViewport(const GfxBlitterCtx &ctx, const Sprite *sprite, int x, int y, BlitterMode mode, const SubSprite *sub = nullptr, SpriteID sprite_id = SPR_CURSOR_MOUSE); static void GfxMainBlitter(const GfxBlitterCtx &ctx, 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) @@ -108,7 +108,7 @@ enum GfxDebugFlags { GDF_SHOW_WIDGET_DIRTY, GDF_SHOW_RECT_DIRTY, }; -uint32 _gfx_debug_flags; +uint32_t _gfx_debug_flags; /** * Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen. @@ -153,7 +153,7 @@ void GfxFillRect(const DrawPixelInfo *dpi, int left, int top, int right, int bot switch (mode) { default: // FILLRECT_OPAQUE - blitter->DrawRect(dst, right, bottom, (uint8)colour); + blitter->DrawRect(dst, right, bottom, (uint8_t)colour); break; case FILLRECT_RECOLOUR: @@ -163,7 +163,7 @@ void GfxFillRect(const DrawPixelInfo *dpi, int left, int top, int right, int bot 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; @@ -290,7 +290,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)); @@ -299,7 +299,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; case FILLRECT_FUNCTOR: @@ -328,7 +328,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(); @@ -940,7 +940,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) { GfxBlitterCtx ctx(_cur_dpi); ctx.SetColourRemap(colour); @@ -1212,7 +1212,7 @@ static void GfxBlitter(const GfxBlitterCtx &ctx, const Sprite *sprite, int x, in * @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; @@ -1225,7 +1225,7 @@ std::unique_ptr DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zo const Sprite *sprite = GetSprite(real_sprite, SpriteType::Normal, ZoomMask(zoom)); 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); @@ -1259,7 +1259,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; @@ -1300,7 +1300,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]; @@ -1328,12 +1328,12 @@ byte GetDigitWidth(FontSize size) * @param size Font of the number * @return The number. */ -uint64 GetBroadestDigitsValue(uint count, FontSize size) +uint64_t GetBroadestDigitsValue(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; } @@ -1430,7 +1430,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); @@ -1522,7 +1522,7 @@ static void DrawDirtyViewport(uint occlusion, int left, int top, int right, int if (_game_mode == GM_MENU) { RedrawScreenRect(left, top, right, bottom); } else { - extern void ViewportDrawChk(Viewport *vp, int left, int top, int right, int bottom, uint8 display_flags); + extern void ViewportDrawChk(Viewport *vp, int left, int top, int right, int bottom, uint8_t display_flags); ViewportDrawChk(_dirty_viewport, left, top, right, bottom, _dirty_viewport_disp_flags); VideoDriver::GetInstance()->MakeDirty(left, top, right - left, bottom - top); } @@ -2136,7 +2136,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 ab8d1fd776..ee9d62aa68 100644 --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -57,8 +57,8 @@ extern bool _ctrl_pressed; ///< Is Ctrl pressed? extern bool _shift_pressed; ///< Is Shift pressed? extern bool _invert_ctrl; extern bool _invert_shift; -extern uint16 _game_speed; -extern uint8 _milliseconds_per_tick; +extern uint16_t _game_speed; +extern uint8_t _milliseconds_per_tick; extern float _ticks_per_second; extern bool _left_button_down; @@ -76,7 +76,7 @@ extern Palette _cur_palette; ///< Current palette extern DrawPixelInfo *_cur_dpi; 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 HandleShiftChanged(); @@ -113,7 +113,7 @@ int DrawString(int left, int right, int top, StringID str, TextColour colour = T 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(const DrawPixelInfo *dpi, int left, int top, int right, int bottom, int colour, FillRectMode mode = FILLRECT_OPAQUE); inline void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode = FILLRECT_OPAQUE) { GfxFillRect(_cur_dpi, left, top, right, bottom, colour, mode); } @@ -208,10 +208,10 @@ 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); -uint64 GetBroadestDigitsValue(uint count, FontSize size = FS_NORMAL); +uint64_t GetBroadestDigitsValue(uint count, FontSize size = FS_NORMAL); extern int font_height_cache[FS_END]; diff --git a/src/gfx_layout.cpp b/src/gfx_layout.cpp index e018d17941..d8b4caa74d 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; @@ -243,7 +243,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); } @@ -301,7 +301,7 @@ ptrdiff_t Layouter::GetCharAtPosition(int x, size_t line_index) 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 c4c8c7367c..fff14c8f0f 100644 --- a/src/gfx_layout.h +++ b/src/gfx_layout.h @@ -114,7 +114,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 0e049eb8e8..2343c8aa86 100644 --- a/src/gfx_layout_fallback.cpp +++ b/src/gfx_layout_fallback.cpp @@ -63,14 +63,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. - FontMap &runs; ///< The fonts we have to use for this paragraph. + 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; }; @@ -82,7 +82,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); } @@ -190,7 +190,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); } @@ -233,14 +233,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 03be2cdffd..14cbf38294 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; @@ -161,7 +161,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); @@ -521,11 +521,11 @@ 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) { assert(buff < buffer_last); /* 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 f0990ed299..8ae732a436 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 { @@ -158,14 +158,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 */ }; @@ -176,7 +176,7 @@ union Colour { * @param b The channel for the blue colour. * @param a The channel for the alpha/transparency. */ - constexpr Colour(uint8 r, uint8 g, uint8 b, uint8 a = 0xFF) : + constexpr 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 @@ -196,7 +196,7 @@ union Colour { } }; -static_assert(sizeof(Colour) == sizeof(uint32)); +static_assert(sizeof(Colour) == sizeof(uint32_t)); /** Available font sizes */ @@ -227,7 +227,7 @@ struct SubSprite { int left, top, right, bottom; }; -enum Colours : uint8 { +enum Colours : uint8_t { COLOUR_BEGIN, COLOUR_DARK_BLUE = COLOUR_BEGIN, COLOUR_PALE_GREEN, diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp index a08d4fa610..ef747b264c 100644 --- a/src/gfxinit.cpp +++ b/src/gfxinit.cpp @@ -165,7 +165,7 @@ void InitGRFGlobalVars() extern uint _extra_station_names_used; _extra_station_names_used = 0; - extern uint8 _extra_station_names_probability; + extern uint8_t _extra_station_names_probability; _extra_station_names_probability = 0; extern bool _allow_rocks_desert; @@ -454,7 +454,7 @@ void GfxDetermineMainColours() { #if !defined(DEDICATED) /* Water. */ - extern uint32 _vp_map_water_colour[5]; + extern uint32_t _vp_map_water_colour[5]; _vp_map_water_colour[0] = GetSpriteMainColour(SPR_FLAT_WATER_TILE, PAL_NONE); if (BlitterFactory::GetCurrentBlitter()->GetScreenDepth() == 32) { _vp_map_water_colour[1] = Blitter_32bppBase::MakeTransparent(_vp_map_water_colour[0], 256, 192).data; // lighter @@ -464,7 +464,7 @@ void GfxDetermineMainColours() } /* Clear ground. */ - extern uint32 _vp_map_vegetation_clear_colours[16][6][8]; + extern uint32_t _vp_map_vegetation_clear_colours[16][6][8]; memset(_vp_map_vegetation_clear_colours, 0, sizeof(_vp_map_vegetation_clear_colours)); const struct { byte min; @@ -486,7 +486,7 @@ void GfxDetermineMainColours() } /* Trees. */ - extern uint32 _vp_map_vegetation_tree_colours[16][5][MAX_TREE_COUNT_BY_LANDSCAPE]; + extern uint32_t _vp_map_vegetation_tree_colours[16][5][MAX_TREE_COUNT_BY_LANDSCAPE]; const uint base = _tree_base_by_landscape[_settings_game.game_creation.landscape]; const uint count = _tree_count_by_landscape[_settings_game.game_creation.landscape]; for (uint tg = 0; tg < 5; tg++) { @@ -647,7 +647,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 c1041b4dcb..a368cd7854 100644 --- a/src/goal.cpp +++ b/src/goal.cpp @@ -78,7 +78,7 @@ INSTANTIATE_POOL_METHODS(Goal) * @param text Text of the goal. * @return the cost of this operation or an error */ -CommandCost CmdCreateGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdCreateGoal(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (!Goal::CanAllocateItem()) return CMD_ERROR; @@ -125,7 +125,7 @@ CommandCost CmdCreateGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 * @param text unused. * @return the cost of this operation or an error */ -CommandCost CmdRemoveGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRemoveGoal(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; if (!Goal::IsValidID(p1)) return CMD_ERROR; @@ -157,7 +157,7 @@ CommandCost CmdRemoveGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 * @param p2 GoalTypeID of destination. * @param text unused. */ -CommandCost CmdSetGoalDestination(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdSetGoalDestination(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { GoalID goal = p1; GoalTypeID dest = p2; @@ -185,7 +185,7 @@ CommandCost CmdSetGoalDestination(TileIndex tile, DoCommandFlag flags, uint32 p1 * @param text Text of the goal. * @return the cost of this operation or an error */ -CommandCost CmdSetGoalText(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSetGoalText(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; if (!Goal::IsValidID(p1)) return CMD_ERROR; @@ -218,7 +218,7 @@ CommandCost CmdSetGoalText(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 * @param text Progress text of the goal. * @return the cost of this operation or an error */ -CommandCost CmdSetGoalProgress(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSetGoalProgress(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; if (!Goal::IsValidID(p1)) return CMD_ERROR; @@ -250,7 +250,7 @@ CommandCost CmdSetGoalProgress(TileIndex tile, DoCommandFlag flags, uint32 p1, u * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdSetGoalCompleted(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSetGoalCompleted(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; if (!Goal::IsValidID(p1)) return CMD_ERROR; @@ -284,17 +284,17 @@ CommandCost CmdSetGoalCompleted(TileIndex tile, DoCommandFlag flags, uint32 p1, * @param text Text of the question. * @return the cost of this operation or an error */ -CommandCost CmdGoalQuestion(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdGoalQuestion(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { - uint16 uniqueid = (uint16)GB(p1, 0, 16); + uint16_t uniqueid = (uint16_t)GB(p1, 0, 16); CompanyID company = (CompanyID)GB(p3, 0, 32); ClientID client = (ClientID)GB(p3, 0, 32); - static_assert(sizeof(uint32) >= sizeof(CompanyID)); - static_assert(sizeof(uint32) >= sizeof(ClientID)); + static_assert(sizeof(uint32_t) >= sizeof(CompanyID)); + static_assert(sizeof(uint32_t) >= sizeof(ClientID)); static_assert(GOAL_QUESTION_BUTTON_COUNT < 29); - uint32 button_mask = GB(p2, 0, GOAL_QUESTION_BUTTON_COUNT); + uint32_t button_mask = GB(p2, 0, GOAL_QUESTION_BUTTON_COUNT); byte type = GB(p2, 29, 2); bool is_client = HasBit(p2, 31); @@ -334,7 +334,7 @@ CommandCost CmdGoalQuestion(TileIndex tile, DoCommandFlag flags, uint32 p1, uint * @param text Text of the question. * @return the cost of this operation or an error */ -CommandCost CmdGoalQuestionAnswer(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdGoalQuestionAnswer(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (p1 > UINT16_MAX) return CMD_ERROR; if (p2 >= GOAL_QUESTION_BUTTON_COUNT) return CMD_ERROR; diff --git a/src/goal_gui.cpp b/src/goal_gui.cpp index 0f84a2265d..c93ade358a 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; @@ -548,7 +548,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 f8b8030941..5cac9c2b40 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 7601df1592..d2bb26b255 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -41,7 +41,7 @@ static CargoTypes _legend_excluded_cargo; static const OverflowSafeInt64 INVALID_DATAPOINT(INT64_MAX); // Value used for a datapoint that shouldn't be drawn. static const uint INVALID_DATAPOINT_POS = UINT_MAX; // Used to determine if the previous point was drawn. -uint8 _cargo_payment_x_mode; +uint8_t _cargo_payment_x_mode; /****************/ /* GRAPH LEGEND */ @@ -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; WidgetID 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; @@ -284,13 +284,13 @@ protected: return max_width; } - virtual StringID PrepareXAxisText(uint16 label) const + virtual StringID PrepareXAxisText(uint16_t label) const { SetDParam(0, label); return STR_JUST_COMMA; } - virtual StringID PrepareXAxisMaxSizeText(uint16 label) const + virtual StringID PrepareXAxisMaxSizeText(uint16_t label) const { SetDParamMaxValue(0, label, 0, FS_SMALL); return STR_JUST_COMMA; @@ -377,8 +377,8 @@ protected: assert(this->num_on_x_axis > 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; @@ -416,7 +416,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++) { StringID str = this->PrepareXAxisText(label); @@ -455,7 +455,7 @@ protected: * integer, so at about 31 bits because of the sign bit, the * least significant bits are removed. */ - int mult_range = FindLastBit(x_axis_offset) + FindLastBit(abs(datapoint)); + int mult_range = FindLastBit(x_axis_offset) + FindLastBit(abs(datapoint)); int reduce_range = std::max(mult_range - 31, 0); /* Handle negative values differently (don't shift sign) */ @@ -1178,7 +1178,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { void SetXAxis() { - uint16 x_scale = 10; + uint16_t x_scale = 10; if (_cargo_payment_x_mode) { switch (_settings_game.locale.units_velocity) { case 2: @@ -1195,7 +1195,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { this->x_values_increment = x_scale; } - std::pair ProcessXAxisValue(uint16 label) const + std::pair ProcessXAxisValue(uint16_t label) const { uint val = label; uint decimals; @@ -1228,7 +1228,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { return { val, decimals }; } - StringID PrepareXAxisText(uint16 label) const override + StringID PrepareXAxisText(uint16_t label) const override { auto val = this->ProcessXAxisValue(label); @@ -1237,7 +1237,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { return STR_JUST_DECIMAL; } - StringID PrepareXAxisMaxSizeText(uint16 label) const override + StringID PrepareXAxisMaxSizeText(uint16_t label) const override { auto val = this->ProcessXAxisValue(label); @@ -1611,8 +1611,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 ;) */ @@ -1631,7 +1631,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; @@ -1644,7 +1644,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 */ @@ -1806,7 +1806,7 @@ struct StationCargoGraphWindow final : BaseGraphWindow { StationCargoGraphWindow(WindowDesc *desc, WindowNumber window) : BaseGraphWindow(desc, WID_SCG_GRAPH, STR_JUST_COMMA) { - station_id = static_cast(window); + station_id = static_cast(window); this->num_on_x_axis = MAX_STATION_CARGO_HISTORY_DAYS; // Four weeks this->num_vert_lines = MAX_STATION_CARGO_HISTORY_DAYS; @@ -1844,7 +1844,7 @@ struct StationCargoGraphWindow final : BaseGraphWindow { { this->excluded_data = 0; - uint8 i = 0; + uint8_t i = 0; for (const CargoSpec *cs : _sorted_standard_cargo_specs) { if (!HasBit(this->present_cargoes, cs->Index())) continue; if (HasBit(legend_excluded_cargo, cs->Index())) SetBit(this->excluded_data, i); @@ -1987,7 +1987,7 @@ struct StationCargoGraphWindow final : BaseGraphWindow { this->UpdateExcludedData(); - uint8 i = 0; + uint8_t i = 0; for (const CargoSpec *cs : _sorted_standard_cargo_specs) { if (!HasBit(this->present_cargoes, cs->Index())) continue; this->colours[i] = cs->legend_colour; diff --git a/src/graph_gui.h b/src/graph_gui.h index 9556ad36c7..234263b366 100644 --- a/src/graph_gui.h +++ b/src/graph_gui.h @@ -10,9 +10,9 @@ #ifndef GRAPH_GUI_H #define GRAPH_GUI_H -extern uint8 _cargo_payment_x_mode; +extern uint8_t _cargo_payment_x_mode; -typedef uint16 StationID; +typedef uint16_t StationID; void ShowOperatingProfitGraph(); void ShowIncomeGraph(); diff --git a/src/ground_vehicle.cpp b/src/ground_vehicle.cpp index 0aefe0cf81..08f4672b25 100644 --- a/src/ground_vehicle.cpp +++ b/src/ground_vehicle.cpp @@ -25,10 +25,10 @@ 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. this->CalculatePower(total_power, max_te, false); @@ -36,7 +36,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); } @@ -45,7 +45,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 { @@ -69,7 +69,7 @@ void GroundVehicle::PowerChanged() } template -void GroundVehicle::CalculatePower(uint32& total_power, uint32& max_te, bool breakdowns) const { +void GroundVehicle::CalculatePower(uint32_t &total_power, uint32_t &max_te, bool breakdowns) const { total_power = 0; max_te = 0; @@ -77,7 +77,7 @@ void GroundVehicle::CalculatePower(uint32& total_power, uint32& max_te, const T *v = T::From(this); 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); if (breakdowns && u->breakdown_ctr == 1 && u->breakdown_type == BREAKDOWN_LOW_POWER) { current_power = current_power * u->breakdown_severity / 256; @@ -101,17 +101,17 @@ template void GroundVehicle::CargoChanged() { assert(this->First() == this); - uint32 weight = 0; - uint64 mass_offset = 0; - uint32 veh_offset = 0; - uint16 articulated_weight = 0; + uint32_t weight = 0; + uint64_t mass_offset = 0; + uint32_t veh_offset = 0; + uint16_t articulated_weight = 0; for (T *u = T::From(this); u != nullptr; u = u->Next()) { - uint32 current_weight = u->GetCargoWeight(); + uint32_t current_weight = u->GetCargoWeight(); if (u->IsArticulatedPart()) { current_weight += articulated_weight; } else { - uint16 engine_weight = u->GetWeightWithoutCargo(); + uint16_t engine_weight = u->GetWeightWithoutCargo(); uint part_count = u->GetEnginePartsCount(); articulated_weight = engine_weight / part_count; current_weight += articulated_weight + (engine_weight % part_count); @@ -150,16 +150,16 @@ GroundVehicleAcceleration GroundVehicle::GetAcceleration() /* 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. @@ -170,9 +170,9 @@ GroundVehicleAcceleration GroundVehicle::GetAcceleration() * * 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; int acceleration_type = v->GetAccelerationType(); bool maglev = (acceleration_type == 2); @@ -185,7 +185,7 @@ GroundVehicleAcceleration GroundVehicle::GetAcceleration() } /* 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(); @@ -195,10 +195,10 @@ GroundVehicleAcceleration GroundVehicle::GetAcceleration() int braking_power = power; /* handle breakdown power reduction */ - uint32 max_te = this->gcache.cached_max_te; // [N] + uint32_t max_te = this->gcache.cached_max_te; // [N] if (Type == VEH_TRAIN && mode == AS_ACCEL && HasBit(Train::From(this)->flags, VRF_BREAKDOWN_POWER)) { /* We'd like to cache this, but changing cached_power has too many unwanted side-effects */ - uint32 power_temp; + uint32_t power_temp; this->CalculatePower(power_temp, max_te, true); power = power_temp * 746ll; } @@ -206,8 +206,8 @@ GroundVehicleAcceleration GroundVehicle::GetAcceleration() /* 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 braking_force; + int64_t force; + int64_t braking_force; if (speed > 0) { if (!maglev) { /* Conversion factor from km/h to m/s is 5/18 to get [N] in the end. */ @@ -220,13 +220,13 @@ GroundVehicleAcceleration GroundVehicle::GetAcceleration() } } else { /* "Kickoff" acceleration. */ - force = (mode == AS_ACCEL && !maglev) ? std::min(max_te, power) : power; + force = (mode == AS_ACCEL && !maglev) ? std::min(max_te, power) : power; force = std::max(force, (mass * 8) + resistance); braking_force = force; } if (Type == VEH_TRAIN && Train::From(this)->UsingRealisticBraking()) { - braking_power += (Train::From(this)->tcache.cached_braking_length * (int64)RBC_BRAKE_POWER_PER_LENGTH); + braking_power += (Train::From(this)->tcache.cached_braking_length * (int64_t)RBC_BRAKE_POWER_PER_LENGTH); } /* If power is 0 because of a breakdown, we make the force 0 if accelerating */ @@ -252,16 +252,16 @@ GroundVehicleAcceleration GroundVehicle::GetAcceleration() * Then we apply a correction for multiengine trains, and in the end we shift it 16 bits to the right to get a 0-255 number. * @note A seperate correction for multiheaded engines is done in CheckVehicleBreakdown. We can't do that here because it would affect the whole consist. */ - uint64 breakdown_factor = (uint64)abs(resistance) * (uint64)(this->cur_speed << 16); - breakdown_factor /= (std::max(force, (int64)100) * this->gcache.cached_max_track_speed); - breakdown_factor = std::min((64 << 16) + (breakdown_factor * 128), 255 << 16); + uint64_t breakdown_factor = (uint64_t)abs(resistance) * (uint64_t)(this->cur_speed << 16); + breakdown_factor /= (std::max(force, (int64_t)100) * this->gcache.cached_max_track_speed); + breakdown_factor = std::min((64 << 16) + (breakdown_factor * 128), 255 << 16); if (Type == VEH_TRAIN && Train::From(this)->tcache.cached_num_engines > 1) { /* For multiengine trains, breakdown chance is multiplied by 3 / (num_engines + 2) */ breakdown_factor *= 3; breakdown_factor /= (Train::From(this)->tcache.cached_num_engines + 2); } /* breakdown_chance is at least 5 (5 / 128 = ~4% of the normal chance) */ - this->breakdown_chance_factor = Clamp(breakdown_factor >> 16, 5, 255); + this->breakdown_chance_factor = Clamp(breakdown_factor >> 16, 5, 255); } int braking_accel; @@ -269,13 +269,13 @@ GroundVehicleAcceleration GroundVehicle::GetAcceleration() /* Assume that every part of a train is braked, not just the engine. * Exceptionally heavy freight trains should still have a sensible braking distance. * The total braking force is generally larger than the total tractive force. */ - braking_accel = ClampTo((-braking_force - resistance - (Train::From(this)->tcache.cached_braking_length * (int64)RBC_BRAKE_FORCE_PER_LENGTH)) / (mass * 4)); + braking_accel = ClampTo((-braking_force - resistance - (Train::From(this)->tcache.cached_braking_length * (int64_t)RBC_BRAKE_FORCE_PER_LENGTH)) / (mass * 4)); /* Defensive driving: prevent ridiculously fast deceleration. * -130 corresponds to a braking distance of about 6.2 tiles from 160 km/h. */ braking_accel = std::max(braking_accel, -(GetTrainRealisticBrakingTargetDecelerationLimit(acceleration_type) + 10)); } else { - braking_accel = ClampTo(std::min(-braking_force - resistance, -10000) / mass); + braking_accel = ClampTo(std::min(-braking_force - resistance, -10000) / mass); } if (mode == AS_ACCEL) { @@ -287,13 +287,13 @@ GroundVehicleAcceleration GroundVehicle::GetAcceleration() * down hill will never slow down enough, and a vehicle that came up * a hill will never speed up enough to (eventually) get back to the * same (maximum) speed. */ - int accel = ClampTo((force - resistance) / (mass * 4)); + int accel = ClampTo((force - resistance) / (mass * 4)); accel = force < resistance ? std::min(-1, accel) : std::max(1, accel); if (this->type == VEH_TRAIN) { if(_settings_game.vehicle.train_acceleration_model == AM_ORIGINAL && HasBit(Train::From(this)->flags, VRF_BREAKDOWN_POWER)) { /* We need to apply the power reducation for non-realistic acceleration here */ - uint32 power; + uint32_t power; CalculatePower(power, max_te, true); accel = accel * power / this->gcache.cached_power; accel -= this->acceleration >> 1; diff --git a/src/ground_vehicle.hpp b/src/ground_vehicle.hpp index 87e51e25b5..de806f16fc 100644 --- a/src/ground_vehicle.hpp +++ b/src/ground_vehicle.hpp @@ -29,23 +29,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). - 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. + 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_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. */ @@ -67,27 +67,27 @@ struct GroundVehicleAcceleration { * 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 GetWeightWithoutCargo() const = 0; - * virtual uint16 GetCargoWeight() const = 0; - * virtual uint16 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 int GetAccelerationType() const = 0; - * virtual int32 GetSlopeSteepness() const = 0; - * virtual int GetDisplayMaxSpeed() const = 0; - * virtual uint16 GetMaxTrackSpeed() const = 0; - * virtual bool TileMayHaveSlopedTrack() const = 0; + * virtual uint16_t GetPower() const = 0; + * virtual uint16_t GetPoweredPartPower(const T *head) const = 0; + * virtual uint16_t GetWeightWithoutCargo() const = 0; + * virtual uint16_t GetCargoWeight() 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_t GetCurrentSpeed() const = 0; + * virtual uint32_t GetRollingFriction() const = 0; + * virtual int GetAccelerationType() const = 0; + * virtual int32_t GetSlopeSteepness() const = 0; + * virtual int GetDisplayMaxSpeed() 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 @@ -100,7 +100,7 @@ struct GroundVehicle : public SpecializedVehicle { void CargoChanged(); bool IsChainInDepot() const override; - void CalculatePower(uint32& power, uint32& max_te, bool breakdowns) const; + void CalculatePower(uint32_t &power, uint32_t &max_te, bool breakdowns) const; GroundVehicleAcceleration GetAcceleration(); @@ -123,11 +123,11 @@ struct GroundVehicle : public SpecializedVehicle { * Calculates the total slope resistance for this vehicle. * @return Slope resistance. */ - inline int64 GetSlopeResistance() + inline int64_t GetSlopeResistance() { if (likely(HasBit(this->vcache.cached_veh_flags, VCF_GV_ZERO_SLOPE_RESIST))) return 0; - int64 incl = 0; + int64_t incl = 0; bool zero_slope_resist = true; for (const T *u = T::From(this); u != nullptr; u = u->Next()) { @@ -224,13 +224,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 c8fcab3afd..d5762717aa 100644 --- a/src/group.h +++ b/src/group.h @@ -25,9 +25,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? @@ -64,7 +64,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, @@ -76,7 +76,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 6947b7d1e5..105aee4df2 100644 --- a/src/group_cmd.cpp +++ b/src/group_cmd.cpp @@ -37,7 +37,7 @@ INSTANTIATE_POOL_METHODS(Group) GroupStatistics::GroupStatistics() { - this->num_engines = CallocT(Engine::GetPoolSize()); + this->num_engines = CallocT(Engine::GetPoolSize()); } GroupStatistics::~GroupStatistics() @@ -57,7 +57,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()); } /** @@ -409,7 +409,7 @@ Group::Group(Owner owner) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdCreateGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdCreateGroup(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleType vt = Extract(p1); if (!IsCompanyBuildableVehicleType(vt)) return CMD_ERROR; @@ -461,7 +461,7 @@ CommandCost CmdCreateGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdDeleteGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdDeleteGroup(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Group *g = Group::GetIfValid(p1); if (g == nullptr || g->owner != _current_company) return CMD_ERROR; @@ -522,7 +522,7 @@ CommandCost CmdDeleteGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 * @param text the new name or an empty string when resetting to the default * @return the cost of this operation or an error */ -CommandCost CmdAlterGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdAlterGroup(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Group *g = Group::GetIfValid(GB(p1, 0, 16)); if (g == nullptr || g->owner != _current_company) return CMD_ERROR; @@ -595,7 +595,7 @@ CommandCost CmdAlterGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 * @param text the new name or an empty string when setting to the default * @return the cost of this operation or an error */ -CommandCost CmdCreateGroupFromList(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdCreateGroupFromList(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleListIdentifier vli; VehicleList list; @@ -676,7 +676,7 @@ static void AddVehicleToGroup(Vehicle *v, GroupID new_g) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdAddVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdAddVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Vehicle *v = Vehicle::GetIfValid(GB(p2, 0, 20)); GroupID new_g = p1; @@ -813,7 +813,7 @@ std::string GenerateAutoNameForVehicleGroup(const Vehicle *v) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdAddSharedVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdAddSharedVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleType type = Extract(p2); GroupID id_g = p1; @@ -850,7 +850,7 @@ CommandCost CmdAddSharedVehicleGroup(TileIndex tile, DoCommandFlag flags, uint32 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdRemoveAllVehiclesGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRemoveAllVehiclesGroup(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { GroupID old_g = p1; Group *g = Group::GetIfValid(old_g); @@ -884,7 +884,7 @@ CommandCost CmdRemoveAllVehiclesGroup(TileIndex tile, DoCommandFlag flags, uint3 * - p2 bit 8 Set secondary instead of primary colour * - p2 bit 16-23 Colour. */ -CommandCost CmdSetGroupLivery(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSetGroupLivery(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Group *g = Group::GetIfValid(p1); bool primary = !HasBit(p2, 8); @@ -945,7 +945,7 @@ static void SetGroupFlag(Group *g, GroupFlags flag, bool set, bool children) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdSetGroupFlag(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSetGroupFlag(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Group *g = Group::GetIfValid(GB(p1, 0, 16)); if (g == nullptr || g->owner != _current_company) return CMD_ERROR; diff --git a/src/group_gui.cpp b/src/group_gui.cpp index e0a91d941f..5d8fba7ba5 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -168,7 +168,7 @@ private: Money money_this_year; Money money_last_year; - uint32 occupancy_ratio; + uint32_t occupancy_ratio; void AddChildren(GUIGroupList &source, GroupID parent, int indent) { @@ -388,7 +388,7 @@ private: { Money this_year = 0; Money last_year = 0; - uint32 occupancy = 0; + uint32_t occupancy = 0; uint vehicle_count = (uint)this->vehicles.size(); for (uint i = 0; i < vehicle_count; i++) { @@ -400,7 +400,7 @@ private: occupancy += v->trip_occupancy; } - uint32 occupancy_ratio = vehicle_count ? occupancy / vehicle_count : 0; + uint32_t occupancy_ratio = vehicle_count ? occupancy / vehicle_count : 0; bool ret = (this->money_this_year != this_year) || (this->money_last_year != last_year) || (occupancy_ratio != this->occupancy_ratio); this->money_this_year = this_year; @@ -609,7 +609,7 @@ public: WID_GL_AVAILABLE_VEHICLES); /* 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; @@ -1304,7 +1304,7 @@ static inline VehicleGroupWindow *FindVehicleGroupWindow(VehicleType vt, Owner o * @param cmd Unused. * @see CmdCreateGroup */ -void CcCreateGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcCreateGroup(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; assert(p1 <= VEH_AIRCRAFT); @@ -1321,7 +1321,7 @@ void CcCreateGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 * @param p2 Bit 0-19: Vehicle ID. * @param cmd Unused. */ -void CcAddVehicleNewGroup(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcAddVehicleNewGroup(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; assert(Vehicle::IsValidID(GB(p2, 0, 20))); diff --git a/src/group_type.h b/src/group_type.h index f23a1eecc8..205f1ea0d0 100644 --- a/src/group_type.h +++ b/src/group_type.h @@ -10,13 +10,13 @@ #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. static const GroupID DEFAULT_GROUP = 0xFFFE; ///< Ungrouped vehicles are in this group. static const GroupID INVALID_GROUP = 0xFFFF; ///< Sentinel for invalid groups. -static const uint32 GROUP_NAME_HIERARCHY = 0x80000000; ///< String constant to display the group name with its full hierarchy +static const uint32_t GROUP_NAME_HIERARCHY = 0x80000000; ///< String constant to display the group name with its full hierarchy static const uint MAX_LENGTH_GROUP_NAME_CHARS = 128; ///< The maximum length of a group name in characters including '\0' diff --git a/src/gui.h b/src/gui.h index dea40ba8b9..2d63ca2d05 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 0dee452593..34300fd18d 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 220f8df9e1..102f268bd7 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 3fb5f4a817..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 @@ -26,9 +26,9 @@ extern HighScoresTable _highscore_table; void SaveToHighScore(); void LoadFromHighScore(); -int8 SaveHighScoreValue(const Company *c); -int8 SaveHighScoreValueNetwork(); +int8_t SaveHighScoreValue(const Company *c); +int8_t SaveHighScoreValueNetwork(); StringID EndGameGetPerformanceTitleFromValue(uint value); -void ShowHighscoreTable(int difficulty = SP_CUSTOM, int8 rank = -1); +void ShowHighscoreTable(int difficulty = SP_CUSTOM, int8_t rank = -1); #endif /* HIGHSCORE_H */ diff --git a/src/highscore_gui.cpp b/src/highscore_gui.cpp index 4a890473be..dd23255f90 100644 --- a/src/highscore_gui.cpp +++ b/src/highscore_gui.cpp @@ -27,8 +27,8 @@ #include "safeguards.h" struct EndGameHighScoreBaseWindow : Window { - uint32 background_img; - int8 rank; + uint32_t background_img; + int8_t rank; EndGameHighScoreBaseWindow(WindowDesc *desc) : Window(desc) { @@ -67,7 +67,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 @@ -155,7 +155,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; @@ -230,7 +230,7 @@ static WindowDesc _endgame_desc(__FILE__, __LINE__, * 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 ee9e672259..c38ea27a2d 100644 --- a/src/hotkeys.cpp +++ b/src/hotkeys.cpp @@ -97,7 +97,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++; @@ -111,7 +111,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; } @@ -122,14 +122,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. */ @@ -158,7 +158,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; } @@ -171,7 +171,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) { @@ -229,7 +229,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 char *name, int num) : +Hotkey::Hotkey(uint16_t default_keycode, const char *name, int num) : name(name), num(num) { @@ -242,11 +242,11 @@ Hotkey::Hotkey(uint16 default_keycode, const char *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 uint16 *default_keycodes, const char *name, int num) : +Hotkey::Hotkey(const uint16_t *default_keycodes, const char *name, int num) : name(name), num(num) { - const uint16 *keycode = default_keycodes; + const uint16_t *keycode = default_keycodes; while (*keycode != 0) { this->AddKeycode(*keycode); keycode++; @@ -258,7 +258,7 @@ Hotkey::Hotkey(const uint16 *default_keycodes, const char *name, int num) : * 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); } @@ -311,7 +311,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 *list = this->items; list->name != nullptr; ++list) { auto begin = list->keycodes.begin(); @@ -353,7 +353,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 6e0a604eb6..38d855cab9 100644 --- a/src/hotkeys.h +++ b/src/hotkeys.h @@ -20,17 +20,17 @@ * a list of keycodes and a number to help identifying this hotkey. */ struct Hotkey { - Hotkey(uint16 default_keycode, const char *name, int num); - Hotkey(const uint16 *default_keycodes, const char *name, int num); + Hotkey(uint16_t default_keycode, const char *name, int num); + Hotkey(const uint16_t *default_keycodes, const char *name, int num); - void AddKeycode(uint16 keycode); + void AddKeycode(uint16_t keycode); const char *name; int num; - btree::btree_set keycodes; + btree::btree_set keycodes; }; -#define HOTKEY_LIST_END Hotkey((uint16)0, nullptr, -1) +#define HOTKEY_LIST_END Hotkey((uint16_t)0, nullptr, -1) struct IniFile; @@ -46,7 +46,7 @@ struct HotkeyList { void Load(const 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: @@ -60,12 +60,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 8f3937076b..d7bbd1c93b 100644 --- a/src/house.h +++ b/src/house.h @@ -109,7 +109,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 @@ -119,7 +119,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 aebeb2c9bb..35ca2791a8 100644 --- a/src/industry.h +++ b/src/industry.h @@ -65,17 +65,17 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> { Town *town; ///< Nearest town Station *neutral_station; ///< Associated neutral station std::array accepts_cargo{}; - std::array produced_cargo{}; ///< 16 production cargo slots - std::array produced_cargo_waiting{}; ///< amount of cargo produced per cargo - std::array incoming_cargo_waiting{}; ///< incoming cargo waiting to be processed - std::array production_rate{}; ///< production rate for each cargo - std::array this_month_production{}; ///< stats of this month's production per cargo - std::array this_month_transported{}; ///< stats of this month's transport per cargo - std::array last_month_pct_transported{}; ///< percentage transported per cargo in the last full month - std::array last_month_production{}; ///< total units produced per cargo in the last full month - std::array last_month_transported{}; ///< total units transported per cargo in the last full month - uint16 counter; ///< used for animation and/or production (if available cargo) - byte prod_level; ///< general production level + std::array produced_cargo{}; ///< 16 production cargo slots + std::array produced_cargo_waiting{}; ///< amount of cargo produced per cargo + std::array incoming_cargo_waiting{}; ///< incoming cargo waiting to be processed + std::array production_rate{}; ///< production rate for each cargo + std::array this_month_production{}; ///< stats of this month's production per cargo + std::array this_month_transported{}; ///< stats of this month's transport per cargo + std::array last_month_pct_transported{}; ///< percentage transported per cargo in the last full month + std::array last_month_production{}; ///< total units produced per cargo in the last full month + std::array last_month_transported{}; ///< total units transported per cargo in the last full month + uint16_t counter; ///< used for animation and/or production (if available cargo) + byte prod_level; ///< general production level IndustryType type; ///< type of industry. Owner owner; ///< owner of the industry. Which SHOULD always be (imho) OWNER_NONE @@ -90,14 +90,14 @@ struct Industry : IndustryPool::PoolItem<&_industry_pool> { Owner founder; ///< Founder of the industry 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) Date last_cargo_accepted_at[INDUSTRY_NUM_INPUTS]; ///< Last day each cargo type was accepted by this industry 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. @@ -199,7 +199,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]; @@ -221,7 +221,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(); @@ -234,11 +234,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. - 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. + 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_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(); @@ -250,7 +250,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 8c82dd2062..437b8ac3b0 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -60,7 +60,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]; @@ -220,7 +220,7 @@ void Industry::PostDestructor(size_t) /* 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) { @@ -258,7 +258,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)]; @@ -298,7 +298,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, @@ -401,7 +401,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; } } @@ -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) { accepts_cargo.fill(CT_INVALID); 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) { cargo_acceptance.fill(0); for (uint i = 0; i < 3; i++) cargo_acceptance[i] = GB(res, i * 4, 4); @@ -736,7 +736,7 @@ void AnimateTile_Industry(TileIndex tile) } -uint8 GetAnimatedTileSpeed_Industry(TileIndex tile) +uint8_t GetAnimatedTileSpeed_Industry(TileIndex tile) { IndustryGfx gfx = GetIndustryGfx(tile); @@ -847,7 +847,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 }, @@ -1081,7 +1081,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); @@ -1189,7 +1189,7 @@ static void ProduceIndustryGoodsFromRate(Industry *i, bool scale) if (amount != 0 && scale) { amount = ScaleQuantity(amount, _settings_game.economy.industry_cargo_scale_factor); } - i->produced_cargo_waiting[j] = ClampTo(i->produced_cargo_waiting[j] + amount); + i->produced_cargo_waiting[j] = ClampTo(i->produced_cargo_waiting[j] + amount); } } @@ -1201,7 +1201,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) { for (size_t j = 0; j < lengthof(i->last_month_production); j++) { if (i->last_month_production[j] > 0) { @@ -1234,7 +1234,7 @@ static void ProduceIndustryGoods(Industry *i) IndustryBehaviour indbehav = indsp->behaviour; 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); } @@ -1249,7 +1249,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); } @@ -1569,7 +1569,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; @@ -1825,7 +1825,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); @@ -1847,7 +1847,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; @@ -1873,7 +1873,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); @@ -1899,7 +1899,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); @@ -1912,7 +1912,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, /* Query actual types */ uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? lengthof(i->accepts_cargo) : 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); @@ -1944,7 +1944,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, /* Query actual types */ uint maxcargoes = (indspec->behaviour & INDUSTRYBEH_CARGOTYPES_UNLIMITED) ? lengthof(i->produced_cargo) : 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); @@ -1970,7 +1970,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, /* Plant the tiles */ - uint64 anim_inhibit_mask = indspec->layout_anim_masks[layout_index]; + uint64_t anim_inhibit_mask = indspec->layout_anim_masks[layout_index]; uint gfx_idx = 0; for (const IndustryTileLayoutTile &it : layout) { @@ -2027,7 +2027,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]; @@ -2093,7 +2093,7 @@ static CommandCost CreateNewIndustryHelper(TileIndex tile, IndustryType type, Do * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { IndustryType it = GB(p1, 0, 8); if (it >= NUM_INDUSTRYTYPES) return CMD_ERROR; @@ -2115,8 +2115,8 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin Randomizer randomizer; randomizer.SetSeed(p2); - uint16 random_initial_bits = GB(p2, 0, 16); - uint32 random_var8f = randomizer.Next(); + uint16_t random_initial_bits = GB(p2, 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 && !HasBit(p1, 16); @@ -2138,7 +2138,7 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin */ 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; @@ -2186,7 +2186,7 @@ CommandCost CmdBuildIndustry(TileIndex tile, DoCommandFlag flags, uint32 p1, uin * @param p2 IndustryControlFlags * @return Empty cost or an error. */ -CommandCost CmdIndustrySetFlags(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdIndustrySetFlags(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; @@ -2268,7 +2268,7 @@ CommandCost CmdIndustrySetProduction(DoCommandFlag flags, IndustryID ind_id, byt * @param text custom news message. * @return the cost of this operation or an error */ -CommandCost CmdIndustrySetProduction(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdIndustrySetProduction(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { return CmdIndustrySetProduction(flags, (IndustryID)p1, GB(p2, 0, 8), HasBit(p2, 8), text != nullptr ? std::string{ text } : std::string{}); } @@ -2283,7 +2283,7 @@ CommandCost CmdIndustrySetProduction(TileIndex tile, DoCommandFlag flags, uint32 * - p2 = (bit 8) - Set exclusive consumer if true, supplier if false. * @return Empty cost or an error. */ -CommandCost CmdIndustrySetExclusivity(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdIndustrySetExclusivity(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; @@ -2314,7 +2314,7 @@ CommandCost CmdIndustrySetExclusivity(TileIndex tile, DoCommandFlag flags, uint3 * @param text - Additional industry text. * @return Empty cost or an error. */ -CommandCost CmdIndustrySetText(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdIndustrySetText(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; @@ -2341,10 +2341,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; @@ -2356,10 +2356,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) { @@ -2382,7 +2382,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; @@ -2409,7 +2409,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 @@ -2512,9 +2512,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++) { @@ -2542,7 +2542,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]; @@ -2615,7 +2615,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; @@ -2637,7 +2637,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; @@ -2652,7 +2652,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; @@ -2674,7 +2674,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); @@ -2703,7 +2703,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. @@ -2876,11 +2876,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 */ @@ -2930,7 +2930,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly) closeit = !(i->ctlflags & (INDCTL_NO_CLOSURE | INDCTL_NO_PRODUCTION_DECREASE)); for (byte j = 0; j < lengthof(i->produced_cargo); j++) { if (i->produced_cargo[j] == CT_INVALID) 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 = (i->last_month_pct_transported[j] > PERCENT_TRANSPORTED_60) ? 1 : -1; @@ -3087,7 +3087,7 @@ void IndustryDailyLoop() /* 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; @@ -3104,7 +3104,7 @@ void IndustryDailyLoop() 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 { @@ -3161,7 +3161,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); @@ -3251,7 +3251,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_gui.cpp b/src/industry_gui.cpp index a2d46e138c..259bce38a9 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -240,11 +240,11 @@ void SortIndustryTypes() * @param p2 Additional data of the #CMD_BUILD_INDUSTRY command. * @param cmd Unused. */ -void CcBuildIndustry(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcBuildIndustry(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Succeeded()) return; - uint8 indtype = GB(p1, 0, 8); + uint8_t indtype = GB(p1, 0, 8); if (indtype < NUM_INDUSTRYTYPES) { const IndustrySpec *indsp = GetIndustrySpec(indtype); if (indsp->enabled) { @@ -525,7 +525,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); @@ -573,7 +573,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); @@ -692,8 +692,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 */ @@ -946,7 +946,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); @@ -1323,7 +1323,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 @@ -1546,7 +1546,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 bd2185fabc..98afbf8baa 100644 --- a/src/industry_map.h +++ b/src/industry_map.h @@ -275,7 +275,7 @@ inline void SetIndustryTriggers(TileIndex tile, byte triggers) * @param random the random value * @param wc the water class for this industry; only useful when build on water */ -inline void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx, uint8 random, WaterClass wc) +inline void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx, uint8_t random, WaterClass wc) { SetTileType(t, MP_INDUSTRY); _m[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 a1a3a56037..c9b846a3d9 100644 --- a/src/industrytype.h +++ b/src/industrytype.h @@ -106,10 +106,10 @@ using IndustryTileLayout = std::vector; */ struct IndustrySpec { std::vector layouts; ///< List of possible tile layouts for the industry - std::vector layout_anim_masks; ///< Animation inhibit masks for 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 + std::vector layout_anim_masks; ///< Animation inhibit masks for tile layouts for the industry + 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 std::array produced_cargo{}; @@ -120,7 +120,7 @@ struct IndustrySpec { */ byte minimal_cargo; std::array accepts_cargo{}; ///< 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 @@ -133,11 +133,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 @@ -156,7 +156,7 @@ struct IndustrySpec { */ struct IndustryTileSpec { std::array accepts_cargo; ///< Cargo accepted by this tile - std::array acceptance; ///< Level of acceptance per cargo type (signed, may be negative!) + std::array acceptance; ///< 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 @@ -166,11 +166,11 @@ struct IndustryTileSpec { */ bool anim_state; /* Newgrf data */ - uint8 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) + 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 - GRFFileProps grf_prop; ///< properties related to the grf file + bool enabled; ///< entity still available (by default true).newgrf can disable it, though + GRFFileProps grf_prop; ///< properties related to the grf file }; /* industry_cmd.cpp*/ @@ -208,6 +208,6 @@ 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/infrastructure.cpp b/src/infrastructure.cpp index fe7306bc46..22983cb014 100644 --- a/src/infrastructure.cpp +++ b/src/infrastructure.cpp @@ -60,9 +60,9 @@ void PayStationSharingFee(Vehicle *v, const Station *st) PaySharingFee(v, st->owner, (cost << 8) / DAY_TICKS); } -uint16 is2_GetWeight(Train *v) +uint16_t is2_GetWeight(Train *v) { - uint16 weight = (CargoSpec::Get(v->cargo_type)->weight * v->cargo.StoredCount() * FreightWagonMult(v->cargo_type)) / 16; + uint16_t weight = (CargoSpec::Get(v->cargo_type)->weight * v->cargo.StoredCount() * FreightWagonMult(v->cargo_type)) / 16; /* Vehicle weight is not added for articulated parts. */ if (!v->IsArticulatedPart()) { weight += GetVehicleProperty(v, PROP_TRAIN_WEIGHT, RailVehInfo(v->engine_type)->weight); diff --git a/src/landscape.cpp b/src/landscape.cpp index c943ba8127..d287410a53 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -604,7 +604,7 @@ void ClearSnowLine() * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdLandscapeClear(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdLandscapeClear(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { CommandCost cost(EXPENSES_CONSTRUCTION); bool do_clear = false; @@ -658,7 +658,7 @@ CommandCost CmdLandscapeClear(TileIndex tile, DoCommandFlag flags, uint32 p1, ui * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdClearArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdClearArea(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (p1 >= MapSize()) return CMD_ERROR; @@ -713,7 +713,7 @@ CommandCost CmdClearArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 TileIndex _cur_tileloop_tile; TileIndex _aux_tileloop_tile; -static uint32 GetTileLoopFeedback() +static uint32_t GetTileLoopFeedback() { /* The pseudorandom sequence of tiles is generated using a Galois linear feedback * shift register (LFSR). This allows a deterministic pseudorandom ordering, but @@ -721,7 +721,7 @@ static uint32 GetTileLoopFeedback() /* Maximal length LFSR feedback terms, from 12-bit (for 64x64 maps) to 28-bit (for 16kx16k 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, 0x10004F3, 0x200072D, 0x40006AE, 0x80009E3, }; @@ -736,11 +736,11 @@ void SetupTileLoopCounts() _tile_loop_counts.resize(_settings_game.economy.day_length_factor); if (_settings_game.economy.day_length_factor == 0) return; - uint64 count_per_tick_fp16 = (static_cast(1) << (MapLogX() + MapLogY() + 8)) / _settings_game.economy.day_length_factor; - uint64 accumulator = 0; + uint64_t count_per_tick_fp16 = (static_cast(1) << (MapLogX() + MapLogY() + 8)) / _settings_game.economy.day_length_factor; + uint64_t accumulator = 0; for (uint &count : _tile_loop_counts) { accumulator += count_per_tick_fp16; - count = static_cast(accumulator >> 16); + count = static_cast(accumulator >> 16); accumulator &= 0xFFFF; } if (accumulator > 0) _tile_loop_counts[0]++; @@ -762,7 +762,7 @@ void RunTileLoop(bool apply_day_length) PerformanceAccumulator framerate(PFE_GL_LANDSCAPE); - const uint32 feedback = GetTileLoopFeedback(); + const uint32_t feedback = GetTileLoopFeedback(); TileIndex tile = _cur_tileloop_tile; /* The LFSR cannot have a zeroed state. */ @@ -778,7 +778,7 @@ void RunTileLoop(bool apply_day_length) while (count--) { /* Get the next tile in sequence using a Galois LFSR. */ - TileIndex next = (tile >> 1) ^ (-(int32)(tile & 1) & feedback); + TileIndex next = (tile >> 1) ^ (-(int32_t)(tile & 1) & feedback); if (count > 0) { PREFETCH_NTA(&_m[next]); } @@ -799,13 +799,13 @@ void RunAuxiliaryTileLoop() PerformanceAccumulator framerate(PFE_GL_LANDSCAPE); - const uint32 feedback = GetTileLoopFeedback(); + const uint32_t feedback = GetTileLoopFeedback(); uint count = 1 << (MapLogX() + MapLogY() - 8); TileIndex tile = _aux_tileloop_tile; while (count--) { /* Get the next tile in sequence using a Galois LFSR. */ - TileIndex next = (tile >> 1) ^ (-(int32)(tile & 1) & feedback); + TileIndex next = (tile >> 1) ^ (-(int32_t)(tile & 1) & feedback); if (count > 0) { PREFETCH_NTA(&_m[next]); } @@ -842,7 +842,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, 0); @@ -983,8 +983,8 @@ void DesertOrRainforestProcessTiles(const std::paircentre); - const int64 y_delta = (int)TileY(tile) - (int)TileY(data->centre); + const int64_t x_delta = (int)TileX(tile) - (int)TileX(data->centre); + const int64_t y_delta = (int)TileY(tile) - (int)TileY(data->centre); /* Rotate to new coordinate system */ - const int64 a_delta = (x_delta * data->cos_fp + y_delta * data->sin_fp) >> 8; - const int64 b_delta = (-x_delta * data->sin_fp + y_delta * data->cos_fp) >> 8; + const int64_t a_delta = (x_delta * data->cos_fp + y_delta * data->sin_fp) >> 8; + const int64_t b_delta = (-x_delta * data->sin_fp + y_delta * data->cos_fp) >> 8; int max_distance = data->max_distance; if (max_distance >= 6) { /* Vary radius a bit for larger lakes */ uint coord = (std::abs(x_delta) > std::abs(y_delta)) ? TileY(tile) : TileX(tile); - static const int8 offset_fuzz[4] = { 0, 1, 0, -1 }; + static const int8_t offset_fuzz[4] = { 0, 1, 0, -1 }; max_distance += offset_fuzz[(coord / 3) & 3]; } /* Check if inside ellipse */ - if ((a_delta * a_delta) + ((data->secondary_axis_scale * b_delta * b_delta) >> 16) > ((int64)(max_distance * max_distance) << 16)) return false; + if ((a_delta * a_delta) + ((data->secondary_axis_scale * b_delta * b_delta) >> 16) > ((int64_t)(max_distance * max_distance) << 16)) return false; for (DiagDirection d = DIAGDIR_BEGIN; d < DIAGDIR_END; d++) { TileIndex t2 = tile + TileOffsByDiagDir(d); @@ -1147,19 +1147,19 @@ static bool FlowsDown(TileIndex begin, TileIndex end) } /* 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); } @@ -1345,7 +1345,7 @@ static bool FlowRiver(TileIndex spring, TileIndex begin, uint min_river_length) data.sin_fp = RandomRange(1 << 17) - (1 << 16); /* sin^2 + cos^2 = 1 */ - data.cos_fp = IntSqrt64(((int64)1 << 32) - ((int64)data.sin_fp * (int64)data.sin_fp)); + data.cos_fp = IntSqrt64(((int64_t)1 << 32) - ((int64_t)data.sin_fp * (int64_t)data.sin_fp)); CircularTileSearch(&lakeCenter, range, MakeLake, &data); /* Call the search a second time so artefacts from going circular in one direction get (mostly) hidden. */ @@ -1511,7 +1511,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() { if (_settings_game.game_creation.climate_threshold_mode != 0) return _settings_game.game_creation.rainforest_line_height; @@ -1546,7 +1546,7 @@ void GenerateLandscape(byte mode) } switch (_settings_game.game_creation.landscape) { case LT_ARCTIC: { - uint32 r = Random(); + uint32_t r = Random(); for (uint i = ScaleByMapSize(GB(r, 0, 7) + 950); i != 0; --i) { GenerateTerrain(2, 0); @@ -1560,7 +1560,7 @@ void GenerateLandscape(byte mode) } case LT_TROPIC: { - uint32 r = Random(); + uint32_t r = Random(); for (uint i = ScaleByMapSize(GB(r, 0, 7) + 170); i != 0; --i) { GenerateTerrain(0, 0); @@ -1580,7 +1580,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 = ScaleByMapSize(GB(r, 0, 7) + (3 - _settings_game.difficulty.quantity_sea_lakes) * 256 + 100); diff --git a/src/language.h b/src/language.h index a75fd375f6..b70367d3be 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,11 +48,11 @@ 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 - byte pad[3]; ///< pad header to be a multiple of 4 + 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 char cases[MAX_NUM_CASES][CASE_GENDER_LEN]; ///< the cases 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..b77ebebdbd 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 2b3b3ff038..22730b85ee 100644 --- a/src/league_cmd.cpp +++ b/src/league_cmd.cpp @@ -84,7 +84,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 }; @@ -142,7 +142,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); @@ -176,7 +176,7 @@ CommandCost CmdRemoveLeagueTableElement(DoCommandFlag flags, LeagueTableElementI return CommandCost(); } -CommandCost CmdCreateLeagueTable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdCreateLeagueTable(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { CommandAuxData data; CommandCost ret = data.Load(aux_data); @@ -187,14 +187,14 @@ CommandCost CmdCreateLeagueTable(TileIndex tile, DoCommandFlag flags, uint32 p1, return res; } -CommandCost CmdCreateLeagueTableElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdCreateLeagueTableElement(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { CommandAuxData data; CommandCost ret = data.Load(aux_data); if (ret.Failed()) return ret; LeagueTableID table = GB(p1, 0, 8); - int64 rating = p3; + int64_t rating = p3; CompanyID company = (CompanyID)GB(p1, 8, 8); LinkType link_type = (LinkType)GB(p1, 16, 8); LinkTargetID link_target = (LinkTargetID)p2; @@ -204,7 +204,7 @@ CommandCost CmdCreateLeagueTableElement(TileIndex tile, DoCommandFlag flags, uin return res; } -CommandCost CmdUpdateLeagueTableElementData(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdUpdateLeagueTableElementData(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { LeagueTableElementID element = GB(p1, 0, 16); CompanyID company = (CompanyID)GB(p1, 16, 8); @@ -214,12 +214,12 @@ CommandCost CmdUpdateLeagueTableElementData(TileIndex tile, DoCommandFlag flags, return CmdUpdateLeagueTableElementData(flags, element, company, text, link_type, link_target); } -CommandCost CmdUpdateLeagueTableElementScore(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdUpdateLeagueTableElementScore(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { return CmdUpdateLeagueTableElementScore(flags, p1, p3, text); } -CommandCost CmdRemoveLeagueTableElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRemoveLeagueTableElement(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { return CmdRemoveLeagueTableElement(flags, p1); } 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 4e7c71c309..6c6c77408b 100644 --- a/src/linkgraph/demands.cpp +++ b/src/linkgraph/demands.cpp @@ -300,16 +300,16 @@ void DemandCalculator::CalcDemand(LinkGraphJob &job, const std::vector &re 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].XY(), job[to_id].XY())) * + int32_t distance = this->max_distance - (this->max_distance - + (int32_t)DistanceMaxPlusManhattan(job[from_id].XY(), job[to_id].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 14dbf11f65..1a3798972a 100644 --- a/src/linkgraph/demands.h +++ b/src/linkgraph/demands.h @@ -15,9 +15,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, const std::vector &reachable_nodes, Tscaler scaler); diff --git a/src/linkgraph/linkgraph.cpp b/src/linkgraph/linkgraph.cpp index b350122859..5f97e49319 100644 --- a/src/linkgraph/linkgraph.cpp +++ b/src/linkgraph/linkgraph.cpp @@ -65,7 +65,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; @@ -79,8 +79,8 @@ void LinkGraph::Compress() */ void LinkGraph::Merge(LinkGraph *other) { - uint32 age = ClampTo(CeilDivT(_scaled_date_ticks.base() - this->last_compression.base() + 1, DAY_TICKS)); - uint32 other_age = ClampTo(CeilDivT(_scaled_date_ticks.base() - other->last_compression.base() + 1, DAY_TICKS)); + uint32_t age = ClampTo(CeilDivT(_scaled_date_ticks.base() - this->last_compression.base() + 1, DAY_TICKS)); + uint32_t other_age = ClampTo(CeilDivT(_scaled_date_ticks.base() - other->last_compression.base() + 1, DAY_TICKS)); NodeID first = this->Size(); this->nodes.reserve(first + other->Size()); for (NodeID node1 = 0; node1 < other->Size(); ++node1) { @@ -167,11 +167,11 @@ NodeID LinkGraph::AddNode(const Station *st) * @param usage Usage to be added. * @param mode Update mode to be used. */ -static void AddEdge(LinkGraph::BaseEdge &edge, uint capacity, uint usage, uint32 travel_time, EdgeUpdateMode mode) +static void AddEdge(LinkGraph::BaseEdge &edge, uint capacity, uint usage, uint32_t travel_time, EdgeUpdateMode mode) { 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 = _date; if (mode & EUM_RESTRICTED) edge.last_restricted_update = _date; if (mode & EUM_AIRCRAFT) edge.last_aircraft_update = _date; @@ -185,7 +185,7 @@ static void AddEdge(LinkGraph::BaseEdge &edge, uint capacity, uint usage, uint32 * @param usage Usage to be added. * @param mode Update mode to be used. */ -void LinkGraph::UpdateEdge(NodeID from, NodeID to, uint capacity, uint usage, uint32 travel_time, EdgeUpdateMode mode) +void LinkGraph::UpdateEdge(NodeID from, NodeID to, uint capacity, uint usage, uint32_t travel_time, EdgeUpdateMode mode) { assert(capacity > 0); assert(usage <= capacity); @@ -219,7 +219,7 @@ void LinkGraph::RemoveEdge(NodeID from, NodeID to) * @param travel_time Travel time to be added, in ticks. * @param mode Update mode to be applied. */ -void LinkGraph::Edge::Update(uint capacity, uint usage, uint32 travel_time, EdgeUpdateMode mode) +void LinkGraph::Edge::Update(uint capacity, uint usage, uint32_t travel_time, EdgeUpdateMode mode) { BaseEdge &edge = *(this->edge); assert(edge.capacity > 0); @@ -227,11 +227,11 @@ void LinkGraph::Edge::Update(uint capacity, uint usage, uint32 travel_time, Edge if (mode & EUM_INCREASE) { if (edge.travel_time_sum == 0) { - edge.travel_time_sum = static_cast(edge.capacity + capacity) * travel_time; + edge.travel_time_sum = static_cast(edge.capacity + capacity) * travel_time; } else if (travel_time == 0) { edge.travel_time_sum += (edge.travel_time_sum / edge.capacity) * capacity; } else { - edge.travel_time_sum += static_cast(travel_time) * capacity; + edge.travel_time_sum += static_cast(travel_time) * capacity; } edge.capacity += capacity; edge.usage += usage; @@ -240,13 +240,13 @@ void LinkGraph::Edge::Update(uint capacity, uint usage, uint32 travel_time, Edge * the capacity increase. */ if (capacity > edge.capacity) { if (travel_time == 0) { - edge.travel_time_sum = static_cast(edge.travel_time_sum / edge.capacity) * capacity; + edge.travel_time_sum = static_cast(edge.travel_time_sum / edge.capacity) * capacity; } else { - edge.travel_time_sum += static_cast(capacity - edge.capacity) * travel_time; + edge.travel_time_sum += static_cast(capacity - edge.capacity) * travel_time; } edge.capacity = capacity; } else if (edge.travel_time_sum == 0) { - edge.travel_time_sum = static_cast(travel_time) * edge.capacity; + edge.travel_time_sum = static_cast(travel_time) * edge.capacity; } edge.usage = std::max(edge.usage, usage); } diff --git a/src/linkgraph/linkgraph.h b/src/linkgraph/linkgraph.h index 4715462741..3698a76718 100644 --- a/src/linkgraph/linkgraph.h +++ b/src/linkgraph/linkgraph.h @@ -70,7 +70,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. Date last_unrestricted_update; ///< When the unrestricted part of the link was last updated. Date last_restricted_update; ///< When the restricted part of the link was last updated. Date last_aircraft_update; ///< When aircraft capacity of the link was last updated. @@ -124,7 +124,7 @@ public: * Get edge's average travel time. * @return Travel time, in ticks. */ - uint32 TravelTime() const { return this->edge->travel_time_sum / this->edge->capacity; } + uint32_t TravelTime() const { return this->edge->travel_time_sum / this->edge->capacity; } /** * Get the date of the last update to the edge's unrestricted capacity. @@ -218,7 +218,7 @@ public: * @param edge Edge to be wrapped. */ Edge(BaseEdge &edge) : EdgeWrapper(edge) {} - void Update(uint capacity, uint usage, uint32 time, EdgeUpdateMode mode); + void Update(uint capacity, uint usage, uint32_t time, EdgeUpdateMode mode); void Restrict() { this->edge->last_unrestricted_update = INVALID_DATE; } void Release() { this->edge->last_restricted_update = INVALID_DATE; } void ClearAircraft() { this->edge->last_aircraft_update = INVALID_DATE; } @@ -365,17 +365,17 @@ public: */ inline uint Monthly(uint base) const { - return (static_cast(base) * 30 * DAY_TICKS * _settings_game.economy.day_length_factor) / std::max((_scaled_date_ticks - this->last_compression).base(), DAY_TICKS); + return (static_cast(base) * 30 * DAY_TICKS * _settings_game.economy.day_length_factor) / std::max((_scaled_date_ticks - this->last_compression).base(), DAY_TICKS); } NodeID AddNode(const Station *st); void RemoveNode(NodeID id); - void UpdateEdge(NodeID from, NodeID to, uint capacity, uint usage, uint32 time, EdgeUpdateMode mode); + void UpdateEdge(NodeID from, NodeID to, uint capacity, uint usage, uint32_t time, EdgeUpdateMode mode); void RemoveEdge(NodeID from, NodeID to); - inline uint64 CalculateCostEstimate() const { - uint64 size_squared = (uint32)this->Size() * (uint32)this->Size(); + inline uint64_t CalculateCostEstimate() const { + uint64_t size_squared = (uint32_t)this->Size() * (uint32_t)this->Size(); return size_squared * FindLastBit(size_squared * size_squared); // N^2 * 4log_2(N) } diff --git a/src/linkgraph/linkgraph_gui.cpp b/src/linkgraph/linkgraph_gui.cpp index 24ba56ba42..fbfc1041ca 100644 --- a/src/linkgraph/linkgraph_gui.cpp +++ b/src/linkgraph/linkgraph_gui.cpp @@ -33,7 +33,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, @@ -285,11 +285,11 @@ 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; @@ -297,7 +297,7 @@ inline bool LinkGraphOverlay::IsLinkVisible(Point pta, Point ptb, const DrawPixe int y1 = ptb.y; auto out_code = [&](int x, int y) -> unsigned char { - uint8 out = INSIDE; + uint8_t out = INSIDE; if (x < left) { out |= LEFT; } else if (x > right) { @@ -311,24 +311,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; } @@ -348,7 +348,7 @@ inline bool LinkGraphOverlay::IsLinkVisible(Point pta, Point ptb, const DrawPixe * @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 || @@ -505,8 +505,8 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond) /* Check the distance from the cursor to the line defined by the two stations. */ auto check_distance = [&]() -> bool { - int64 a = ((int64)(ptb.x - pta.x) * (int64)(pta.y - pt.y) - (int64)(pta.x - pt.x) * (int64)(ptb.y - pta.y)); - int64 b = ((int64)(ptb.x - pta.x) * (int64)(ptb.x - pta.x) + (int64)(ptb.y - pta.y) * (int64)(ptb.y - pta.y)); + int64_t a = ((int64_t)(ptb.x - pta.x) * (int64_t)(pta.y - pt.y) - (int64_t)(pta.x - pt.x) * (int64_t)(ptb.y - pta.y)); + int64_t b = ((int64_t)(ptb.x - pta.x) * (int64_t)(ptb.x - pta.x) + (int64_t)(ptb.y - pta.y) * (int64_t)(ptb.y - pta.y)); if (b == 0) return false; return ((a * a) / b) <= 16; }; @@ -522,7 +522,7 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond) StringBuilder builder(buf); buf[0] = 0; - auto add_travel_time = [&](uint32 time) { + auto add_travel_time = [&](uint32_t time) { if (time > 0) { if (_settings_time.time_in_minutes) { SetDParam(0, STR_TIMETABLE_MINUTES); @@ -556,7 +556,7 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond) } /* Fill buf with more information if this is a bidirectional link. */ - uint32 back_time = 0; + uint32_t back_time = 0; for (LinkList::const_reverse_iterator j = std::next(i); j != this->cached_links.rend(); ++j) { if (j->from_id == i->to_id && j->to_id == i->from_id) { back_time = j->prop.time; @@ -586,7 +586,7 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond) uint dx = Delta(TileX(t0), TileX(t1)); uint dy = Delta(TileY(t0), TileY(t1)); SetDParam(0, DistanceManhattan(t0, t1)); - SetDParam(1, IntSqrt64(((uint64)dx * (uint64)dx) + ((uint64)dy * (uint64)dy))); // Avoid overflow in DistanceSquare + SetDParam(1, IntSqrt64(((uint64_t)dx * (uint64_t)dx) + ((uint64_t)dy * (uint64_t)dy))); // Avoid overflow in DistanceSquare GetString(builder, STR_LINKGRAPH_STATS_TOOLTIP_DISTANCE); } @@ -807,7 +807,7 @@ void LinkGraphLegendWindow::DrawWidget(const Rect &r, WidgetID 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) { @@ -854,7 +854,7 @@ bool LinkGraphLegendWindow::OnTooltip([[maybe_unused]] Point, WidgetID widget, T */ 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 b56c413967..7ffdbb5717 100644 --- a/src/linkgraph/linkgraph_gui.h +++ b/src/linkgraph/linkgraph_gui.h @@ -32,7 +32,7 @@ struct LinkProperties { uint usage; ///< Actual usage of the link. uint planned; ///< Planned usage of the link. CargoID cargo; ///< Cargo type 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. }; @@ -59,7 +59,7 @@ public: typedef std::vector StationSupplyList; typedef std::vector LinkList; - static const uint8 LINK_COLOURS[][12]; + static const uint8_t LINK_COLOURS[][12]; /** * Create a link graph overlay for the specified window. @@ -102,7 +102,7 @@ protected: Rect cached_region; ///< Region covered by cached_links and cached_stations. uint scale; ///< Width of link lines. bool dirty; ///< Set if overlay should be rebuilt. - uint64 last_update_number = 0; ///< Last window update number + uint64_t last_update_number = 0; ///< Last window update number Point GetStationMiddle(const Station *st) const; @@ -114,7 +114,7 @@ protected: bool IsPointVisible(Point pt, const DrawPixelInfo *dpi, int padding = 0) const; void GetWidgetDpi(DrawPixelInfo *dpi, uint margin = 0) const; - static void AddStats(CargoID new_cargo, uint new_cap, uint new_usg, uint new_plan, uint32 time, bool new_shared, LinkProperties &cargo); + static void AddStats(CargoID new_cargo, uint new_cap, uint new_usg, uint new_plan, uint32_t time, bool new_shared, LinkProperties &cargo); static void DrawVertex(const DrawPixelInfo *dpi, 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 f92fa43e02..4456f20c36 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 3a33d85db9..12aace5cf0 100644 --- a/src/linkgraph/linkgraphjob.cpp +++ b/src/linkgraph/linkgraphjob.cpp @@ -100,7 +100,7 @@ void LinkGraphJob::FinaliseJob() /* 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) { Node from = (*this)[node_id]; @@ -203,7 +203,7 @@ void LinkGraphJob::Init() * and the shortest route for other classes of cargo. * In-between stops are punished with a 1 tile or 1 day penalty. */ const bool express = IsLinkGraphCargoExpress(this->Cargo()); - const uint16 aircraft_link_scale = this->Settings().aircraft_link_scale; + const uint16_t aircraft_link_scale = this->Settings().aircraft_link_scale; size_t edge_count = 0; for (auto &it : this->link_graph.GetEdges()) { diff --git a/src/linkgraph/linkgraphschedule.cpp b/src/linkgraph/linkgraphschedule.cpp index 78e527044d..d17b588458 100644 --- a/src/linkgraph/linkgraphschedule.cpp +++ b/src/linkgraph/linkgraphschedule.cpp @@ -50,7 +50,7 @@ void LinkGraphSchedule::SpawnNext() if (this->schedule.empty()) return; GraphList schedule_to_back; - uint64 total_cost = 0; + uint64_t total_cost = 0; for (auto iter = this->schedule.begin(); iter != this->schedule.end();) { auto current = iter; ++iter; @@ -65,17 +65,17 @@ void LinkGraphSchedule::SpawnNext() for (auto &it : this->running) { total_cost += it->Graph().CalculateCostEstimate(); } - uint64 clamped_total_cost = std::min(total_cost, 1 << 25); + uint64_t clamped_total_cost = std::min(total_cost, 1 << 25); uint log2_clamped_total_cost = FindLastBit(clamped_total_cost); uint scaling = log2_clamped_total_cost > 13 ? log2_clamped_total_cost - 12 : 1; - uint64 cost_budget = clamped_total_cost / scaling; - uint64 used_budget = 0; + uint64_t cost_budget = clamped_total_cost / scaling; + uint64_t used_budget = 0; std::vector jobs_to_execute; while (used_budget < cost_budget && !this->schedule.empty()) { LinkGraph *lg = this->schedule.front(); assert(lg == LinkGraph::Get(lg->index)); this->schedule.pop_front(); - uint64 cost = lg->CalculateCostEstimate(); + uint64_t cost = lg->CalculateCostEstimate(); used_budget += cost; if (LinkGraphJob::CanAllocateItem()) { uint duration_multiplier = CeilDivT(lg->Size(), 75); diff --git a/src/linkgraph/mcf.cpp b/src/linkgraph/mcf.cpp index d6295f3f21..91ebce3db1 100644 --- a/src/linkgraph/mcf.cpp +++ b/src/linkgraph/mcf.cpp @@ -517,7 +517,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 @@ -535,7 +535,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); @@ -543,7 +543,7 @@ MCF1stPass::MCF1stPass(LinkGraphJob &job) : MultiCommodityFlow(job) uint min_step_size = 1; const uint adjust_threshold = 50; if (size >= adjust_threshold) { - uint64 total_demand = 0; + uint64_t total_demand = 0; uint demand_count = 0; for (NodeID source = 0; source < size; ++source) { const Node &node = job[source]; @@ -603,7 +603,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 aad56a8459..19d1de9a7f 100644 --- a/src/linkgraph/refresh.cpp +++ b/src/linkgraph/refresh.cpp @@ -55,7 +55,7 @@ HopSet seen_hops; LinkRefresher refresher(v, &seen_hops, allow_merge, is_full_loading, iter_cargo_mask); - uint8 flags = 0; + uint8_t flags = 0; if (iter_cargo_mask & have_cargo_mask) flags |= 1 << HAS_CARGO; if (v->type == VEH_AIRCRAFT) flags |= 1 << AIRCRAFT; refresher.RefreshLinks(first, first, { 0, TTT_NO_WAIT_TIME }, flags); @@ -116,7 +116,7 @@ bool LinkRefresher::HandleRefit(CargoID refit_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 */ @@ -228,7 +228,7 @@ LinkRefresher::TimetableTravelTime LinkRefresher::UpdateTimetableTravelSoFar(con * @param num_hops Number of hops already taken by recursive calls to this method. * @return new next Order, and travel time so far. */ -std::pair LinkRefresher::PredictNextOrder(const Order *cur, const Order *next, LinkRefresher::TimetableTravelTime travel, uint8 flags, uint num_hops) +std::pair LinkRefresher::PredictNextOrder(const Order *cur, const Order *next, LinkRefresher::TimetableTravelTime travel, 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 @@ -298,7 +298,7 @@ std::pair LinkRefresher::Pred * @param travel_estimate Estimated travel time, only valid if non-zero. * @param flags RefreshFlags to give hints about the previous link and state carried over from that. */ -void LinkRefresher::RefreshStats(const Order *cur, const Order *next, uint32 travel_estimate, uint8 flags) +void LinkRefresher::RefreshStats(const Order *cur, const Order *next, uint32_t travel_estimate, uint8_t flags) { StationID next_station = next->GetDestination(); Station *st = Station::GetIfValid(cur->GetDestination()); @@ -326,13 +326,13 @@ void LinkRefresher::RefreshStats(const Order *cur, const Order *next, uint32 tra /* 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 (travel_estimate > 0) { /* If a timetable-based time is available, use that, clamping it to be in the range (estimate / 3, estimate * 2) * of the distance/speed based estimate. * This is effectively clamping it to be within the estimated speed range: (max_speed / 4, max_speed * 1.5). */ - time_estimate = Clamp(travel_estimate, time_estimate / 3, time_estimate * 2); + time_estimate = Clamp(travel_estimate, time_estimate / 3, time_estimate * 2); } if (HasBit(flags, AIRCRAFT)) restricted_mode |= EUM_AIRCRAFT; @@ -375,7 +375,7 @@ void LinkRefresher::RefreshStats(const Order *cur, const Order *next, uint32 tra * @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, TimetableTravelTime travel, uint8 flags, uint num_hops) +void LinkRefresher::RefreshLinks(const Order *cur, const Order *next, TimetableTravelTime travel, uint8_t flags, uint num_hops) { while (next != nullptr) { @@ -429,7 +429,7 @@ void LinkRefresher::RefreshLinks(const Order *cur, const Order *next, TimetableT if (cur->IsType(OT_GOTO_STATION) || cur->IsType(OT_IMPLICIT)) { if (cur->CanLeaveWithCargo(HasBit(flags, HAS_CARGO), FindFirstBit(this->cargo_mask))) { SetBit(flags, HAS_CARGO); - this->RefreshStats(cur, next, ((travel.flags & TTT_INVALID) == 0 && travel.time_so_far > 0) ? (uint32)travel.time_so_far : 0, flags); + this->RefreshStats(cur, next, ((travel.flags & TTT_INVALID) == 0 && travel.time_so_far > 0) ? (uint32_t)travel.time_so_far : 0, flags); } else { ClrBit(flags, HAS_CARGO); } diff --git a/src/linkgraph/refresh.h b/src/linkgraph/refresh.h index 6392a42adc..868bf98838 100644 --- a/src/linkgraph/refresh.h +++ b/src/linkgraph/refresh.h @@ -41,10 +41,10 @@ protected: * Simulated cargo type and capacity for prediction of future links. */ 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) : + CargoID cargo; ///< Cargo type the vehicle will be carrying. + 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) {} }; @@ -61,7 +61,7 @@ protected: OrderID from; ///< Last order where vehicle could interact with cargo or absolute first order. OrderID to; ///< Next order to be processed. CargoID cargo; ///< Cargo the consist is probably carrying or CT_INVALID if unknown. - uint8 flags; ///< Flags, for branches + uint8_t flags; ///< Flags, for branches /** * Default constructor should not be called but has to be visible for @@ -75,7 +75,7 @@ protected: * @param to Second order of the hop. * @param cargo Cargo the consist is probably carrying when passing the hop. */ - Hop(OrderID from, OrderID to, CargoID cargo, uint8 flags = 0) : from(from), to(to), cargo(cargo), flags(flags) {} + Hop(OrderID from, OrderID to, CargoID cargo, uint8_t flags = 0) : from(from), to(to), cargo(cargo), flags(flags) {} bool operator<(const Hop &other) const { return std::tie(this->from, this->to, this->cargo, this->flags) < std::tie(other.from, other.to, other.cargo, other.flags); } bool operator==(const Hop &other) const { return std::tie(this->from, this->to, this->cargo, this->flags) == std::tie(other.from, other.to, other.cargo, other.flags); } bool operator!=(const Hop &other) const { return !(*this == other); } @@ -110,11 +110,11 @@ protected: bool HandleRefit(CargoID refit_cargo); void ResetRefit(); - void RefreshStats(const Order *cur, const Order *next,uint32 travel_estimate, uint8 flags); + void RefreshStats(const Order *cur, const Order *next,uint32_t travel_estimate, uint8_t flags); TimetableTravelTime UpdateTimetableTravelSoFar(const Order *from, const Order *to, TimetableTravelTime travel); - std::pair PredictNextOrder(const Order *cur, const Order *next, TimetableTravelTime travel, uint8 flags, uint num_hops = 0); + std::pair PredictNextOrder(const Order *cur, const Order *next, TimetableTravelTime travel, uint8_t flags, uint num_hops = 0); - void RefreshLinks(const Order *cur, const Order *next, TimetableTravelTime travel, uint8 flags, uint num_hops = 0); + void RefreshLinks(const Order *cur, const Order *next, TimetableTravelTime travel, uint8_t flags, uint num_hops = 0); }; #endif /* REFRESH_H */ diff --git a/src/load_check.h b/src/load_check.h index 0938608cda..746a246a11 100644 --- a/src/load_check.h +++ b/src/load_check.h @@ -30,7 +30,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; Date current_date; GameSettings settings; diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 3365118312..7b5f576c1c 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -48,7 +48,7 @@ #include "safeguards.h" -void CcGiveMoney(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcGiveMoney(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed() || !_settings_game.economy.give_money || !_networking) return; @@ -60,7 +60,7 @@ void CcGiveMoney(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2 * bits 31-16: source company * bits 15-0: target company */ - uint64 auxdata = (p1 & 0xFFFF) | (((uint64) _local_company) << 16); + uint64_t auxdata = (p1 & 0xFFFF) | (((uint64_t) _local_company) << 16); if (!_network_server) { NetworkClientSendChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_BROADCAST_SS, p2, msg, NetworkTextMessageData(result.GetCost(), auxdata)); @@ -97,7 +97,7 @@ bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLigh } -void CcPlaySound_EXPLOSION(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcPlaySound_EXPLOSION(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_12_EXPLOSION, tile); } @@ -550,12 +550,12 @@ struct MainWindow : Window static HotkeyList hotkeys; }; -const uint16 _ghk_quit_keys[] = {'Q' | WKC_CTRL, 'Q' | WKC_META, 0}; -const uint16 _ghk_abandon_keys[] = {'W' | WKC_CTRL, 'W' | WKC_META, 0}; -const uint16 _ghk_chat_keys[] = {WKC_RETURN, 'T', 0}; -const uint16 _ghk_chat_all_keys[] = {WKC_SHIFT | WKC_RETURN, WKC_SHIFT | 'T', 0}; -const uint16 _ghk_chat_company_keys[] = {WKC_CTRL | WKC_RETURN, WKC_CTRL | 'T', 0}; -const uint16 _ghk_chat_server_keys[] = {WKC_CTRL | WKC_SHIFT | WKC_RETURN, WKC_CTRL | WKC_SHIFT | 'T', 0}; +const uint16_t _ghk_quit_keys[] = {'Q' | WKC_CTRL, 'Q' | WKC_META, 0}; +const uint16_t _ghk_abandon_keys[] = {'W' | WKC_CTRL, 'W' | WKC_META, 0}; +const uint16_t _ghk_chat_keys[] = {WKC_RETURN, 'T', 0}; +const uint16_t _ghk_chat_all_keys[] = {WKC_SHIFT | WKC_RETURN, WKC_SHIFT | 'T', 0}; +const uint16_t _ghk_chat_company_keys[] = {WKC_CTRL | WKC_RETURN, WKC_CTRL | 'T', 0}; +const uint16_t _ghk_chat_server_keys[] = {WKC_CTRL | WKC_SHIFT | WKC_RETURN, WKC_CTRL | WKC_SHIFT | 'T', 0}; static Hotkey global_hotkeys[] = { Hotkey(_ghk_quit_keys, "quit", GHK_QUIT), @@ -563,7 +563,7 @@ static Hotkey global_hotkeys[] = { Hotkey(WKC_BACKQUOTE, "console", GHK_CONSOLE), Hotkey('B' | WKC_CTRL, "bounding_boxes", GHK_BOUNDING_BOXES), Hotkey('I' | WKC_CTRL, "dirty_blocks", GHK_DIRTY_BLOCKS), - Hotkey((uint16)0, "widget_outlines", GHK_WIDGET_OUTLINES), + Hotkey((uint16_t)0, "widget_outlines", GHK_WIDGET_OUTLINES), Hotkey('C', "center", GHK_CENTER), Hotkey('Z', "center_zoom", GHK_CENTER_ZOOM), Hotkey(WKC_ESC, "reset_object_to_place", GHK_RESET_OBJECT_TO_PLACE), @@ -603,9 +603,9 @@ static Hotkey global_hotkeys[] = { Hotkey(WKC_SPACE, "close_error", GHK_CLOSE_ERROR), Hotkey(WKC_PAGEUP, "previous_map_mode", GHK_CHANGE_MAP_MODE_PREV), Hotkey(WKC_PAGEDOWN, "next_map_mode", GHK_CHANGE_MAP_MODE_NEXT), - Hotkey((uint16)0, "switch_viewport_route_overlay_mode", GHK_SWITCH_VIEWPORT_ROUTE_OVERLAY_MODE), - Hotkey((uint16)0, "switch_viewport_map_slope_mode", GHK_SWITCH_VIEWPORT_MAP_SLOPE_MODE), - Hotkey((uint16)0, "switch_viewport_map_height_mode", GHK_SWITCH_VIEWPORT_MAP_HEIGHT_MODE), + Hotkey((uint16_t)0, "switch_viewport_route_overlay_mode", GHK_SWITCH_VIEWPORT_ROUTE_OVERLAY_MODE), + Hotkey((uint16_t)0, "switch_viewport_map_slope_mode", GHK_SWITCH_VIEWPORT_MAP_SLOPE_MODE), + Hotkey((uint16_t)0, "switch_viewport_map_height_mode", GHK_SWITCH_VIEWPORT_MAP_HEIGHT_MODE), HOTKEY_LIST_END }; HotkeyList MainWindow::hotkeys("global", global_hotkeys); @@ -623,7 +623,7 @@ static WindowDesc _main_window_desc(__FILE__, __LINE__, * @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 ce820b8d48..58c255faea 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -441,8 +441,8 @@ bool EnoughContiguousTilesMatchingCondition(TileIndex tile, uint threshold, Test static_assert(MAX_MAP_TILES_BITS <= 30); - btree::btree_set processed_tiles; - ring_buffer candidates; + btree::btree_set processed_tiles; + ring_buffer candidates; uint matching_count = 0; auto process_tile = [&](TileIndex t, DiagDirection exclude_onward_dir) { @@ -466,7 +466,7 @@ bool EnoughContiguousTilesMatchingCondition(TileIndex tile, uint threshold, Test process_tile(tile, INVALID_DIAGDIR); while (matching_count < threshold && !candidates.empty()) { - uint32 next = candidates.front(); + uint32_t next = candidates.front(); candidates.pop_front(); TileIndex t = GB(next, 0, 30); DiagDirection exclude_onward_dir = (DiagDirection)GB(next, 30, 2); @@ -501,8 +501,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 1d56e732ec..4bd8e201fc 100644 --- a/src/map_func.h +++ b/src/map_func.h @@ -152,7 +152,7 @@ inline uint ScaleByMapSize1D(uint n) * * @see TileDiffXY(int, int) */ -typedef int32 TileIndexDiff; +typedef int32_t TileIndexDiff; /** * Returns the TileIndex of a coordinate. diff --git a/src/map_type.h b/src/map_type.h index 0d59b74906..eb3bdbda9c 100644 --- a/src/map_type.h +++ b/src/map_type.h @@ -17,7 +17,7 @@ struct Tile { 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 @@ -31,9 +31,9 @@ static_assert(sizeof(Tile) == 8); * Look at docs/landscape.html for the exact meaning of the members. */ struct TileExtended { - byte m6; ///< General purpose - byte m7; ///< Primarily used for newgrf support - uint16 m8; ///< General purpose + byte m6; ///< General purpose + byte m7; ///< Primarily used for newgrf support + uint16_t m8; ///< General purpose }; /** @@ -46,7 +46,7 @@ struct TileExtended { * * @see TileDiffXY(int, int) */ -typedef int32 TileIndexDiff; +typedef int32_t TileIndexDiff; /** * A pair-construct of a TileIndexDiff. @@ -55,8 +55,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.cpp b/src/misc.cpp index 1c12bc35ce..8f7abbd4be 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -52,7 +52,7 @@ extern TileIndex _aux_tileloop_tile; extern void ClearAllSignalSpeedRestrictions(); extern void MakeNewgameSettingsLive(); -extern uint64 _station_tile_cache_hash; +extern uint64_t _station_tile_cache_hash; void InitializeSound(); void InitializeMusic(); @@ -79,10 +79,10 @@ std::string GenerateUid(std::string_view subject) { extern void NetworkRandomBytesWithFallback(void *buf, size_t n); - uint8 random_bytes[32]; + uint8_t random_bytes[32]; NetworkRandomBytesWithFallback(random_bytes, lengthof(random_bytes)); - uint8 digest[16]; + uint8_t digest[16]; crypto_blake2b_ctx ctx; crypto_blake2b_init (&ctx, lengthof(digest)); 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..858d61f10e 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 45df183d69..92e759adbe 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_cmd.cpp b/src/misc_cmd.cpp index 7e1080456f..dda8342038 100644 --- a/src/misc_cmd.cpp +++ b/src/misc_cmd.cpp @@ -43,7 +43,7 @@ static_assert((LOAN_INTERVAL & 3) == 0); * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdIncreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdIncreaseLoan(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Company *c = Company::Get(_current_company); @@ -62,7 +62,7 @@ CommandCost CmdIncreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint loan = _economy.max_loan - c->current_loan; break; case 2: // Take the given amount of loan - loan = ((uint64)p1 << 32) | (p2 & 0xFFFFFFFC); + loan = ((uint64_t)p1 << 32) | (p2 & 0xFFFFFFFC); if (loan < LOAN_INTERVAL || c->current_loan + loan > _economy.max_loan || loan % LOAN_INTERVAL != 0) return CMD_ERROR; break; } @@ -93,7 +93,7 @@ CommandCost CmdIncreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdDecreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdDecreaseLoan(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Company *c = Company::Get(_current_company); @@ -110,7 +110,7 @@ CommandCost CmdDecreaseLoan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint loan -= loan % LOAN_INTERVAL; break; case 2: // Repay the given amount of loan - loan = ((uint64)p1 << 32) | (p2 & 0xFFFFFFFC); + loan = ((uint64_t)p1 << 32) | (p2 & 0xFFFFFFFC); if (loan % LOAN_INTERVAL != 0 || loan < LOAN_INTERVAL || loan > c->current_loan) return CMD_ERROR; // Invalid amount to loan break; } @@ -152,7 +152,7 @@ static void AskUnsafeUnpauseCallback(Window *, bool confirmed) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdPause(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdPause(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { switch (p1) { case PM_PAUSED_SAVELOAD: @@ -211,14 +211,14 @@ CommandCost CmdPause(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdMoneyCheat(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdMoneyCheat(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { if (_networking && !_settings_game.difficulty.money_cheat_in_multiplayer) return CMD_ERROR; if (flags & DC_EXEC) { _cheats.money.been_used = true; SetWindowDirty(WC_CHEATS, 0); } - return CommandCost(EXPENSES_OTHER, -(int64)p3); + return CommandCost(EXPENSES_OTHER, -(int64_t)p3); } /** @@ -231,13 +231,13 @@ CommandCost CmdMoneyCheat(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdMoneyCheatAdmin(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdMoneyCheatAdmin(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { if (flags & DC_EXEC) { _cheats.money.been_used = true; SetWindowDirty(WC_CHEATS, 0); } - return CommandCost(EXPENSES_OTHER, -(int64)p3); + return CommandCost(EXPENSES_OTHER, -(int64_t)p3); } /** @@ -249,7 +249,7 @@ CommandCost CmdMoneyCheatAdmin(TileIndex tile, DoCommandFlag flags, uint32 p1, u * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdCheatSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdCheatSetting(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Cheat *cht = nullptr; switch ((CheatNumbers) p1) { @@ -268,7 +268,7 @@ CommandCost CmdCheatSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint case CHT_INFLATION_INCOME: if (flags & DC_EXEC) { _cheats.inflation_income.been_used = true; - _economy.inflation_payment = Clamp(p2, 1 << 16, MAX_INFLATION); + _economy.inflation_payment = Clamp(p2, 1 << 16, MAX_INFLATION); if (_economy.inflation_payment > _economy.inflation_prices) { _economy.inflation_prices = _economy.inflation_payment; _cheats.inflation_cost.been_used = true; @@ -281,7 +281,7 @@ CommandCost CmdCheatSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint case CHT_INFLATION_COST: if (flags & DC_EXEC) { _cheats.inflation_cost.been_used = true; - _economy.inflation_prices = Clamp(p2, 1 << 16, MAX_INFLATION); + _economy.inflation_prices = Clamp(p2, 1 << 16, MAX_INFLATION); if (_economy.inflation_payment > _economy.inflation_prices) { _economy.inflation_payment = _economy.inflation_prices; _cheats.inflation_income.been_used = true; @@ -330,9 +330,9 @@ CommandCost CmdCheatSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint * @param text unused * @return zero cost or an error */ -CommandCost CmdChangeBankBalance(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdChangeBankBalance(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { - int64 delta = (int64)p3; + int64_t delta = (int64_t)p3; CompanyID company = (CompanyID) GB(p1, 0, 8); ExpensesType expenses_type = Extract(p1); @@ -369,12 +369,12 @@ CommandCost CmdChangeBankBalance(TileIndex tile, DoCommandFlag flags, uint32 p1, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdGiveMoney(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { if (!_settings_game.economy.give_money) return CMD_ERROR; const Company *c = Company::Get(_current_company); - CommandCost amount(EXPENSES_OTHER, (int64)p3); + CommandCost amount(EXPENSES_OTHER, (int64_t)p3); CompanyID dest_company = (CompanyID)p1; /* You can only transfer funds that is in excess of your loan */ diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index e800f737f4..5609b42ff6 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -659,7 +659,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); @@ -673,7 +673,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); @@ -732,7 +732,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. @@ -1283,7 +1283,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 17ba32974b..79e3089697 100644 --- a/src/mixer.cpp +++ b/src/mixer.cpp @@ -22,13 +22,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; @@ -37,13 +37,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 @@ -106,7 +106,7 @@ static void mix_int16(MixerChannel *sc, int16_t *buffer, uint samples, uint8_t e sc->pos = b - (const T *)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); } @@ -121,26 +121,26 @@ 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_t*)buffer, samples, effect_vol); @@ -153,11 +153,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); @@ -165,7 +165,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; @@ -202,7 +202,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); } @@ -211,7 +211,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; @@ -228,7 +228,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 335d6496b8..7e597c187f 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 0bf1cc974b..18e5b706d3 100644 --- a/src/music/dmusic.cpp +++ b/src/music/dmusic.cpp @@ -116,7 +116,7 @@ PACK_N(struct WAVE_DOWNLOAD { }, 2); struct PlaybackSegment { - uint32 start, end; + uint32_t start, end; size_t start_block; bool loop; }; @@ -723,7 +723,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 %lu ms (music %u, ref " OTTD_PRINTF64 ")", next_timeout, block.realtime * MIDITIME_TO_REFTIME, playback_time); break; } diff --git a/src/music/fluidsynth.cpp b/src/music/fluidsynth.cpp index 1c4b67e12b..cdb8584aaf 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 0a6198bc12..38f82220f4 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 80b2f56a18..32edc42841 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.empty()) { @@ -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++; } } @@ -505,20 +505,20 @@ cleanup: struct MpsMachine { /** Starting parameter and playback status for one channel/track */ 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 + byte cur_program; ///< program selected, used for velocity scaling (lookup into programvelocities array) + byte running_status; ///< last midi status code seen + 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 - bool shouldplayflag; ///< not-end-of-song flag + Channel channels[16]; ///< playback status for each MIDI channel + 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; static const byte programvelocities[128]; @@ -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 */ @@ -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 char *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 char *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 d21267e60b..ce224e0b3f 100644 --- a/src/music/midifile.hpp +++ b/src/music/midifile.hpp @@ -19,20 +19,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 a5d5d21c5f..24120890b6 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 60d5b6ac4e..f0a8497026 100644 --- a/src/network/core/address.cpp +++ b/src/network/core/address.cpp @@ -35,7 +35,7 @@ const char *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: @@ -191,17 +191,17 @@ bool NetworkAddress::IsInNetmask(const char *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: @@ -209,7 +209,7 @@ bool NetworkAddress::IsInNetmask(const char *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; @@ -471,14 +471,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 8bad0618ff..77237134bb 100644 --- a/src/network/core/address.h +++ b/src/network/core/address.h @@ -75,7 +75,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) { @@ -106,8 +106,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 @@ -226,7 +226,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 d8c76b28f3..bbf32e02e0 100644 --- a/src/network/core/config.h +++ b/src/network/core/config.h @@ -18,16 +18,16 @@ 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 UDP_MTU_SHORT = 1400; ///< Number of bytes we can pack in a single UDP packet (conservative) +static const uint16_t UDP_MTU = 1460; ///< Number of bytes we can pack in a single UDP packet +static const uint16_t UDP_MTU_SHORT = 1400; ///< Number of bytes we can pack in a single UDP packet (conservative) static const std::string NETWORK_SURVEY_DETAILS_LINK = "https://survey.openttd.org/participate"; ///< Link with more details & privacy statement of the survey. /* @@ -38,14 +38,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? @@ -97,6 +97,6 @@ static const uint NETWORK_MAX_GRF_COUNT = 255; /** * Maximum version supported in PACKET_SERVER_GAME_INFO_EXTENDED */ -static const uint8 SERVER_GAME_INFO_EXTENDED_MAX_VERSION = 1; +static const uint8_t SERVER_GAME_INFO_EXTENDED_MAX_VERSION = 1; #endif /* NETWORK_CORE_CONFIG_H */ diff --git a/src/network/core/network_game_info.cpp b/src/network/core/network_game_info.cpp index c367db6113..4ca0fc05f9 100644 --- a/src/network/core/network_game_info.cpp +++ b/src/network/core/network_game_info.cpp @@ -27,7 +27,7 @@ #include "../../safeguards.h" -extern const uint8 _out_of_band_grf_md5[16]; +extern const uint8_t _out_of_band_grf_md5[16]; /** * How many hex digits of the git hash to include in network revision string. @@ -207,7 +207,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 */ @@ -223,7 +223,7 @@ void SerializeNetworkGameInfo(Packet *p, const NetworkServerGameInfo *info, bool for (c = info->grfconfig; c != nullptr; c = c->next) { if (!HasBit(c->flags, GCF_STATIC)) count++; } - p->Send_uint8(ClampTo(std::min(count, NETWORK_MAX_GRF_COUNT))); // Send number of GRFs + p->Send_uint8(ClampTo(std::min(count, NETWORK_MAX_GRF_COUNT))); // Send number of GRFs /* Send actual GRF Identifications */ for (c = info->grfconfig; c != nullptr; c = c->next) { @@ -251,7 +251,7 @@ void SerializeNetworkGameInfo(Packet *p, const NetworkServerGameInfo *info, bool p->Send_uint8 (info->clients_on); p->Send_uint8 (info->spectators_on); - auto encode_map_size = [&](uint32 in) -> uint16 { + auto encode_map_size = [&](uint32_t in) -> uint16_t { if (in < UINT16_MAX) { return in; } else { @@ -269,9 +269,9 @@ void SerializeNetworkGameInfo(Packet *p, const NetworkServerGameInfo *info, bool * @param p the packet to write the data to * @param info the NetworkGameInfo struct to serialize */ -void SerializeNetworkGameInfoExtended(Packet *p, const NetworkServerGameInfo *info, uint16 flags, uint16 version, bool send_newgrf_names) +void SerializeNetworkGameInfoExtended(Packet *p, const NetworkServerGameInfo *info, uint16_t flags, uint16_t version, bool send_newgrf_names) { - version = std::max(version, 1); // Version 1 is the max supported + version = std::max(version, 1); // Version 1 is the max supported p->Send_uint8(version); // version num @@ -295,7 +295,7 @@ void SerializeNetworkGameInfoExtended(Packet *p, const NetworkServerGameInfo *in if (version >= 1) { 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()); p->Send_uint8(send_newgrf_names ? NST_GRFID_MD5_NAME : NST_GRFID_MD5); @@ -361,7 +361,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; @@ -424,7 +424,7 @@ void DeserializeNetworkGameInfo(Packet *p, NetworkGameInfo *info, const GameInfo } if (game_info_version < 6) while (p->Recv_uint8() != 0) {} // Used to contain the map-name. - auto decode_map_size = [&](uint16 in) -> uint32 { + auto decode_map_size = [&](uint16_t in) -> uint32_t { if (in >= 65000) { return 1 << (in - 65000); } else { @@ -450,7 +450,7 @@ void DeserializeNetworkGameInfoExtended(Packet *p, NetworkGameInfo *info) { static const Date MAX_DATE = ConvertYMDToDate(MAX_YEAR, 11, 31); // December is month 11 - const uint8 version = p->Recv_uint8(); + const uint8_t version = p->Recv_uint8(); if (version > SERVER_GAME_INFO_EXTENDED_MAX_VERSION) return; // Unknown version NewGRFSerializationType newgrf_serialisation = NST_GRFID_MD5; diff --git a/src/network/core/network_game_info.h b/src/network/core/network_game_info.h index ec4c8aab99..3bf2223a98 100644 --- a/src/network/core/network_game_info.h +++ b/src/network/core/network_game_info.h @@ -94,8 +94,8 @@ struct NetworkServerGameInfo { GRFConfig *grfconfig; ///< List of NewGRF files used Date start_date; ///< When the game started Date game_date; ///< Current date - uint32 map_width; ///< Map width - uint32 map_height; ///< Map height + uint32_t map_width; ///< Map width + uint32_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; @@ -146,6 +146,6 @@ void SerializeGRFIdentifier(Packet *p, const GRFIdentifier *grf); void DeserializeNetworkGameInfo(Packet *p, NetworkGameInfo *info, const GameInfoNewGRFLookupTable *newgrf_lookup_table = nullptr); void DeserializeNetworkGameInfoExtended(Packet *p, NetworkGameInfo *info); void SerializeNetworkGameInfo(Packet *p, const NetworkServerGameInfo *info, bool send_newgrf_names = true); -void SerializeNetworkGameInfoExtended(Packet *p, const NetworkServerGameInfo *info, uint16 flags, uint16 version, bool send_newgrf_names = true); +void SerializeNetworkGameInfoExtended(Packet *p, const NetworkServerGameInfo *info, uint16_t flags, uint16_t version, bool send_newgrf_names = true); #endif /* NETWORK_CORE_GAME_INFO_H */ diff --git a/src/network/core/os_abstraction.cpp b/src/network/core/os_abstraction.cpp index 21ed6b5539..2cdbc9fd9f 100644 --- a/src/network/core/os_abstraction.cpp +++ b/src/network/core/os_abstraction.cpp @@ -204,7 +204,7 @@ bool ShutdownSocket(SOCKET d, bool read, bool write, uint linger_timeout) { if (!read && !write) return true; #ifdef _WIN32 - LINGER ln = { 1U, (uint16) linger_timeout }; + LINGER ln = { 1U, (uint16_t) linger_timeout }; #else struct linger ln = { 1, (int) linger_timeout }; #endif diff --git a/src/network/core/packet.cpp b/src/network/core/packet.cpp index 13601fa9a7..21f74a9f27 100644 --- a/src/network/core/packet.cpp +++ b/src/network/core/packet.cpp @@ -85,7 +85,7 @@ bool Packet::CanWriteToPacket(size_t bytes_to_write) return this->Size() + bytes_to_write <= this->limit; } -void Packet::WriteAtOffset_uint16(size_t offset, uint16 data) +void Packet::WriteAtOffset_uint16(size_t offset, uint16_t data) { assert(offset + 1 < this->buffer.size()); this->buffer[offset] = GB(data, 0, 8); diff --git a/src/network/core/packet.h b/src/network/core/packet.h index 52544d754e..320c6271ae 100644 --- a/src/network/core/packet.h +++ b/src/network/core/packet.h @@ -22,8 +22,8 @@ #include #include -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, @@ -75,7 +75,7 @@ public: bool CanWriteToPacket(size_t bytes_to_write); - void WriteAtOffset_uint16(size_t offset, uint16); + void WriteAtOffset_uint16(size_t offset, uint16_t); /* Reading/receiving of packets */ size_t ReadRawPacketSize() const; diff --git a/src/network/core/tcp.h b/src/network/core/tcp.h index 0665648123..1c46bef433 100644 --- a/src/network/core/tcp.h +++ b/src/network/core/tcp.h @@ -127,7 +127,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(); /** @@ -156,7 +156,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 33ab7b049d..5bea4b1073 100644 --- a/src/network/core/tcp_admin.h +++ b/src/network/core/tcp_admin.h @@ -135,8 +135,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. */ @@ -144,8 +144,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. @@ -155,9 +155,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. @@ -166,10 +166,10 @@ protected: /** * Send chat from the external source: - * string Name of the source this message came from. - * uint16 TextColour to use for the message. - * string Name of the user who sent the messsage. - * string Message. + * string Name of the source this message came from. + * 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. * @return The state the network should have. */ @@ -193,7 +193,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. */ @@ -215,7 +215,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. */ @@ -223,10 +223,10 @@ protected: /** * Inform a just joined admin about the protocol specifics: - * uint8 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). + * uint8_t Protocol version. + * bool Further protocol data follows (repeats through all update packet types). + * 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. */ @@ -234,15 +234,15 @@ protected: /** * Welcome a connected admin to the game: - * string Name of the Server. - * 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. + * string Name of the Server. + * string OpenTTD version string. + * bool Server is dedicated. + * string Name of the Map. + * 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. */ @@ -264,7 +264,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. */ @@ -272,7 +272,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. */ @@ -280,12 +280,12 @@ protected: /** * Client information of a specific client: - * uint32 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). + * uint32_t ID of the client. + * string Network address of the client. + * string Name of the client. + * 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. */ @@ -293,9 +293,9 @@ protected: /** * Client update details on a specific client (e.g. after rename or move): - * uint32 ID of the client. - * string Name of the client. - * uint8 ID of the company the client is playing as (255 for spectators). + * uint32_t ID of the client. + * string Name of the client. + * 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. */ @@ -303,7 +303,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. */ @@ -311,8 +311,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. */ @@ -320,7 +320,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. */ @@ -328,13 +328,13 @@ protected: /** * Company information on a specific company: - * uint8 ID of the company. - * string Name of the company. - * string Name of the companies manager. - * uint8 Main company colour. - * bool Company is password protected. - * uint32 Year the company was inaugurated. - * bool Company is an AI. + * uint8_t ID of the company. + * string Name of the company. + * string Name of the companies manager. + * uint8_t Main company colour. + * bool Company is password protected. + * 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. */ @@ -342,16 +342,16 @@ protected: /** * Company information of a specific company: - * uint8 ID of the company. - * string Name of the company. - * string Name of the companies manager. - * uint8 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 ID of the company. + * string Name of the company. + * string Name of the companies manager. + * uint8_t Main company colour. + * bool Company is password protected. + * 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. */ @@ -359,8 +359,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. */ @@ -368,17 +368,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. */ @@ -386,17 +386,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. */ @@ -404,11 +404,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. - * string Message. - * uint64 Money (only when it is a 'give money' action). + * 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_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. */ @@ -416,8 +416,8 @@ protected: /** * Result of an rcon command: - * uint16 Colour as it would be used on the server or a client. - * string Output of the executed command. + * 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. */ @@ -443,9 +443,9 @@ protected: * Data provided in this packet is for logging purposes only. * * These three fields are repeated until the packet is full: - * bool Data to follow. - * uint16 ID of the DoCommand. - * string Name of DoCommand. + * bool Data to follow. + * 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. */ @@ -460,14 +460,14 @@ 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 P1 (variable data passed to the command). - * uint32 P2 (variable data passed to the command). - * uint32 Tile where this is taking place. - * string Text passed to the command. - * uint32 Frame of execution. + * 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. + * uint32_t P1 (variable data passed to the command). + * uint32_t P2 (variable data passed to the command). + * uint32_t Tile where this is taking place. + * string Text passed to the command. + * uint32_t Frame of execution. * @param p The packet that was just received. * @return The state the network should have. */ @@ -475,7 +475,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 4c44561ec9..8204ae28b1 100644 --- a/src/network/core/tcp_connect.cpp +++ b/src/network/core/tcp_connect.cpp @@ -28,7 +28,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) { @@ -42,7 +42,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..34ef42a0c4 100644 --- a/src/network/core/tcp_content.h +++ b/src/network/core/tcp_content.h @@ -25,12 +25,12 @@ protected: /** * Client requesting a list of content info: - * byte type - * uint32 openttd version (or 0xFFFFFFFF if using a list) + * byte type + * uint32_t openttd version (or 0xFFFFFFFF if using a list) * Only if the above value is 0xFFFFFFFF: - * uint8 count - * string branch-name ("vanilla" for upstream OpenTTD) - * string release version (like "12.0") + * uint8_t count + * string branch-name ("vanilla" for upstream OpenTTD) + * string release version (like "12.0") * @param p The packet that was just received. * @return True upon success, otherwise false. */ @@ -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. @@ -76,17 +76,17 @@ protected: /** * Server sending list of content info: - * byte type (invalid ID == does not exist) - * uint32 id - * uint32 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 - * string tag (max 32 characters for tag count times) + * byte type (invalid ID == does not exist) + * uint32_t id + * uint32_t file_size + * string name (max 32 characters) + * string version (max 16 characters) + * 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,9 +103,9 @@ protected: /** * Server sending list of content info: - * uint32 unique id - * uint32 file size (0 == does not exist) - * string file name (max 48 characters) + * 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. * @param p The packet that was just received. diff --git a/src/network/core/tcp_content_type.h b/src/network/core/tcp_content_type.h index 5049c13f3c..29623ecdcc 100644 --- a/src/network/core/tcp_content_type.h +++ b/src/network/core/tcp_content_type.h @@ -63,13 +63,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 a9d9a430cf..afa984c80b 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,11 +89,11 @@ 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. - * 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). + * 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). * * @param p The packet that was just received. * @return True upon success, otherwise false. @@ -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. - * string Revision of the client. - * uint32 (Game Coordinator protocol >= 4) Cursor as received from GC_NEWGRF_LOOKUP, or zero. + * uint8_t Game Coordinator protocol version. + * uint8_t Game-info version used by this client. + * string Revision of the client. + * 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. @@ -214,10 +214,10 @@ protected: * Game Coordinator requests that the Client makes a direct connection to * the indicated peer, which is a Server. * - * string Token to track the current connect request. - * uint8 Tracking number to track current connect request. - * string Hostname of the peer. - * uint16 Port of the peer. + * string Token to track the current connect request. + * uint8_t Tracking number to track current connect request. + * string Hostname of the peer. + * uint16_t Port of the peer. * * @param p The packet that was just received. * @return True upon success, otherwise false. @@ -242,10 +242,10 @@ protected: /** * Client/server informs the Game Coordinator the result of a STUN request. * - * uint8 Game Coordinator protocol version. - * string Token to track the current connect request. - * uint8 Interface number, as given during STUN request. - * bool Whether the STUN connection was successful. + * uint8_t Game Coordinator protocol version. + * string Token to track the current connect 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. * @return True upon success, otherwise false. @@ -257,11 +257,11 @@ protected: * of the other side). It should start a connect() to this peer ASAP with * 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. - * string Host of the peer. - * uint16 Port of the peer. + * string Token to track the current connect 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_t Port of the peer. * * @param p The packet that was just received. * @return True upon success, otherwise false. @@ -273,12 +273,12 @@ 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. - * byte[16] MD5 checksum of the NewGRF - * string Name of the NewGRF. + * 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. * * The lookup table built using these packets are used by the deserialisation * of the NewGRFs for servers in the GC_LISTING. These updates are additive, @@ -295,10 +295,10 @@ protected: * Game Coordinator requests that we make a connection to the indicated * peer, which is a TURN server. * - * string Token to track the current connect request. - * uint8 Tracking number to track current connect request. - * string Ticket to hand over to the TURN server. - * string Connection string of the TURN server. + * string Token to track the 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. * * @param p The packet that was just received. * @return True upon success, otherwise false. diff --git a/src/network/core/tcp_game.h b/src/network/core/tcp_game.h index 2d0d0ca03c..c76387e355 100644 --- a/src/network/core/tcp_game.h +++ b/src/network/core/tcp_game.h @@ -191,15 +191,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); @@ -226,9 +226,9 @@ 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). - * string Name of the client. + * 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. */ virtual NetworkRecvStatus Receive_SERVER_CLIENT_INFO(Packet *p); @@ -241,32 +241,32 @@ protected: /** * Indication to the client that the server needs a company password: - * uint32 Generation seed. - * string Network ID of the server. + * uint32_t Generation seed. + * string Network ID of the server. * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_NEED_COMPANY_PASSWORD(Packet *p); /** * Send a password to the server to authorize: - * uint8 Password type (see NetworkPasswordType). - * string The password. + * uint8_t Password type (see NetworkPasswordType). + * string The password. * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_CLIENT_GAME_PASSWORD(Packet *p); /** * Send a password to the server to authorize - * uint8 Password type (see NetworkPasswordType). - * string The password. + * uint8_t Password type (see NetworkPasswordType). + * string The password. * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_CLIENT_COMPANY_PASSWORD(Packet *p); /** * Send a password to the server to authorize - * uint8 Password type (see NetworkPasswordType). - * string The password. + * uint8_t Password type (see NetworkPasswordType). + * string The password. * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_CLIENT_SETTINGS_PASSWORD(Packet *p); @@ -280,37 +280,37 @@ protected: /** * The client is joined and ready to receive their map: - * uint32 Own client ID. - * uint32 Generation seed. - * string Network ID of the server. + * uint32_t Own client ID. + * uint32_t Generation seed. + * string Network ID of the server. * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_WELCOME(Packet *p); /** * 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); @@ -336,93 +336,93 @@ 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). - * uint32 P1 (free variables used in DoCommand). - * uint32 P2 - * uint32 Tile where this is taking place. - * string Text. - * uint8 ID of the callback. + * uint8_t ID of the company (0..MAX_COMPANIES-1). + * uint32_t ID of the command (see command.h). + * uint32_t P1 (free variables used in DoCommand). + * uint32_t P2 + * uint32_t Tile where this is taking place. + * string Text. + * 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). - * uint32 P1 (free variable used in DoCommand). - * uint32 P2. - * uint32 Tile where this is taking place. - * string Text. - * uint8 ID of the callback. - * uint32 Frame of execution. + * uint8_t ID of the company (0..MAX_COMPANIES-1). + * uint32_t ID of the command (see command.h). + * uint32_t P1 (free variable used in DoCommand). + * uint32_t P2. + * uint32_t Tile where this is taking place. + * string Text. + * 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). - * string Message (max NETWORK_CHAT_LENGTH). - * uint64 data (used e.g. for 'give money' actions). + * 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_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). - * string Message (max NETWORK_CHAT_LENGTH). - * uint64 data (used e.g. for 'give money' actions). + * 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_t data (used e.g. for 'give money' actions). * @param p The packet that was just received. */ virtual NetworkRecvStatus Receive_SERVER_CHAT(Packet *p); /** * 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. - * string Name of the user who sent the messsage. - * string Message (max NETWORK_CHAT_LENGTH). + * string Name of the source this message came from. + * 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. */ virtual NetworkRecvStatus Receive_SERVER_EXTERNAL_CHAT(Packet *p); @@ -449,7 +449,7 @@ 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); @@ -460,15 +460,15 @@ protected: /** * 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); @@ -487,7 +487,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. */ @@ -503,9 +503,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); @@ -518,15 +518,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. */ @@ -534,15 +534,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); @@ -551,12 +551,12 @@ 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 - CommandQueue incoming_queue; ///< The command-queue awaiting handling + ClientID client_id; ///< Client identifier + 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. - PacketGameType last_pkt_type;///< Last received packet type + PacketGameType last_pkt_type; ///< Last received packet type NetworkRecvStatus CloseConnection(bool error = true) override; diff --git a/src/network/core/tcp_listen.h b/src/network/core/tcp_listen.h index 65ed0f81b2..14ada0e012 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.empty()); diff --git a/src/network/core/tcp_stun.h b/src/network/core/tcp_stun.h index e96a97ef36..c9564231e3 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 36afa8bcb1..9841e91816 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/core/udp.cpp b/src/network/core/udp.cpp index 8061be57d9..bf06d77500 100644 --- a/src/network/core/udp.cpp +++ b/src/network/core/udp.cpp @@ -35,7 +35,7 @@ NetworkUDPSocketHandler::NetworkUDPSocketHandler(NetworkAddressList *bind) this->bind.emplace_back("", 0, AF_INET6); } - this->fragment_token = ((uint64) InteractiveRandom()) | (((uint64) InteractiveRandom()) << 32); + this->fragment_token = ((uint64_t) InteractiveRandom()) | (((uint64_t) InteractiveRandom()) << 32); } @@ -82,21 +82,21 @@ void NetworkUDPSocketHandler::SendPacket(Packet *p, NetworkAddress *recv, bool a if (p->Size() > MTU) { p->PrepareToSend(); - uint64 token = this->fragment_token++; + uint64_t token = this->fragment_token++; const uint PAYLOAD_MTU = MTU - (1 + 2 + 8 + 1 + 1 + 2); const size_t packet_size = p->Size(); - const uint8 frag_count = (uint8)((packet_size + PAYLOAD_MTU - 1) / PAYLOAD_MTU); + const uint8_t frag_count = (uint8_t)((packet_size + PAYLOAD_MTU - 1) / PAYLOAD_MTU); Packet frag(PACKET_UDP_EX_MULTI); - uint8 current_frag = 0; + uint8_t current_frag = 0; size_t offset = 0; while (offset < packet_size) { - uint16 payload_size = (uint16)std::min(PAYLOAD_MTU, packet_size - offset); + uint16_t payload_size = (uint16_t)std::min(PAYLOAD_MTU, packet_size - offset); frag.Send_uint64(token); - frag.Send_uint8 (current_frag); - frag.Send_uint8 (frag_count); - frag.Send_uint16 (payload_size); + frag.Send_uint8(current_frag); + frag.Send_uint8(frag_count); + frag.Send_uint16(payload_size); frag.Send_binary(p->GetBufferData() + offset, payload_size); current_frag++; offset += payload_size; @@ -210,10 +210,10 @@ void NetworkUDPSocketHandler::HandleUDPPacket(Packet *p, NetworkAddress *client_ void NetworkUDPSocketHandler::Receive_EX_MULTI(Packet *p, NetworkAddress *client_addr) { - uint64 token = p->Recv_uint64(); - uint8 index = p->Recv_uint8 (); - uint8 total = p->Recv_uint8 (); - uint16 payload_size = p->Recv_uint16(); + uint64_t token = p->Recv_uint64(); + uint8_t index = p->Recv_uint8 (); + uint8_t total = p->Recv_uint8 (); + uint16_t payload_size = p->Recv_uint16(); DEBUG(net, 6, "[udp] received multi-part packet from %s: " OTTD_PRINTFHEX64 ", %u/%u, %u bytes", NetworkAddressDumper().GetAddressAsString(client_addr), token, index, total, payload_size); diff --git a/src/network/core/udp.h b/src/network/core/udp.h index dddc6514e9..d68fb34c0c 100644 --- a/src/network/core/udp.h +++ b/src/network/core/udp.h @@ -37,10 +37,10 @@ protected: /** The opened sockets. */ SocketList sockets; - uint64 fragment_token; + uint64_t fragment_token; struct FragmentSet { - uint64 token; + uint64_t token; NetworkAddress address; time_t create_time; std::vector fragments; diff --git a/src/network/network.cpp b/src/network/network.cpp index 85ab5a4a9f..c47ae7a9fe 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -63,36 +63,36 @@ static_assert(NetworkClientInfoPool::MAX_SIZE == NetworkClientSocketPool::MAX_SI NetworkClientInfoPool _networkclientinfo_pool("NetworkClientInfo"); INSTANTIATE_POOL_METHODS(NetworkClientInfo) -bool _networking; ///< are we in networking mode? -bool _network_server; ///< network-server is active -bool _network_available; ///< is network mode available? -bool _network_dedicated; ///< are we a dedicated server? -bool _is_network_server; ///< Does this client wants to be a network-server? -bool _network_settings_access; ///< Can this client change server settings? +bool _networking; ///< are we in networking mode? +bool _network_server; ///< network-server is active +bool _network_available; ///< is network mode available? +bool _network_dedicated; ///< are we a dedicated server? +bool _is_network_server; ///< Does this client wants to be a network-server? +bool _network_settings_access; ///< Can this client change server settings? NetworkCompanyState *_network_company_states = nullptr; ///< Statistics about some companies. -std::string _network_company_server_id; ///< Server ID string used for company passwords -uint8 _network_company_password_storage_token[16]; ///< Non-secret token for storage of company passwords in savegames -uint8 _network_company_password_storage_key[32]; ///< Key for storage of company passwords in savegames -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 -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. -NetworkAddressList _broadcast_list; ///< List of broadcast addresses. -uint32 _sync_seed_1; ///< Seed to compare during sync checks. -uint64 _sync_state_checksum; ///< State checksum to compare during sync checks. -uint32 _sync_frame; ///< The frame to perform the sync check. -Date _last_sync_date; ///< The game date of the last successfully received sync frame -DateFract _last_sync_date_fract; ///< " -uint8 _last_sync_tick_skip_counter; ///< " -uint32 _last_sync_frame_counter; ///< " -bool _network_first_time; ///< Whether we have finished joining or not. -CompanyMask _network_company_passworded; ///< Bitmask of the password status of all companies. +std::string _network_company_server_id; ///< Server ID string used for company passwords +uint8_t _network_company_password_storage_token[16]; ///< Non-secret token for storage of company passwords in savegames +uint8_t _network_company_password_storage_key[32]; ///< Key for storage of company passwords in savegames +ClientID _network_own_client_id; ///< Our client identifier. +ClientID _redirect_console_to_client; ///< If not invalid, redirect the console output to a client. +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_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_t _sync_seed_1; ///< Seed to compare during sync checks. +uint64_t _sync_state_checksum; ///< State checksum to compare during sync checks. +uint32_t _sync_frame; ///< The frame to perform the sync check. +Date _last_sync_date; ///< The game date of the last successfully received sync frame +DateFract _last_sync_date_fract; ///< " +uint8_t _last_sync_tick_skip_counter; ///< " +uint32_t _last_sync_frame_counter; ///< " +bool _network_first_time; ///< Whether we have finished joining or not. +CompanyMask _network_company_passworded; ///< Bitmask of the password status of all companies. ring_buffer _network_sync_records; ring_buffer _network_sync_record_counts; @@ -195,7 +195,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; @@ -229,7 +229,7 @@ std::string GenerateCompanyPasswordHash(const std::string &password, const std:: * @param password_game_seed Game seed. * @return The hashed password. */ -std::vector GenerateGeneralPasswordHash(const std::string &password, const std::string &password_server_id, uint64 password_game_seed) +std::vector GenerateGeneralPasswordHash(const std::string &password, const std::string &password_server_id, uint64_t password_game_seed) { if (password.empty()) return {}; @@ -532,7 +532,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; bool success = IntFromChars(company_string.data(), company_string.data() + company_string.size(), company_value); if (success) { if (company_value != COMPANY_NEW_COMPANY && company_value != COMPANY_SPECTATOR) { @@ -566,7 +566,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); @@ -586,9 +586,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); } @@ -601,9 +601,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); } @@ -772,7 +772,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); @@ -1177,7 +1177,7 @@ void NetworkGameLoop() static uint next_tick_skip_counter; static std::unique_ptr cp; 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; @@ -1370,7 +1370,7 @@ static void NetworkGenerateServerId() std::string NetworkGenerateRandomKeyString(uint bytes) { - uint8 *key = AllocaM(uint8, bytes); + uint8_t *key = AllocaM(uint8_t, bytes); NetworkRandomBytesWithFallback(key, bytes); return FormatArrayAsHex({key, bytes}); diff --git a/src/network/network_admin.cpp b/src/network/network_admin.cpp index ddbc3d3793..ee9e16d073 100644 --- a/src/network/network_admin.cpp +++ b/src/network/network_admin.cpp @@ -104,7 +104,7 @@ ServerNetworkAdminSocketHandler::~ServerNetworkAdminSocketHandler() { for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::Iterate()) { if (as->status == ADMIN_STATUS_INACTIVE && std::chrono::steady_clock::now() > as->connect_time + ADMIN_AUTHORISATION_TIMEOUT) { - DEBUG(net, 2, "[admin] Admin did not send its authorisation within %d seconds", (uint32)std::chrono::duration_cast(ADMIN_AUTHORISATION_TIMEOUT).count()); + DEBUG(net, 2, "[admin] Admin did not send its authorisation within %d seconds", (uint32_t)std::chrono::duration_cast(ADMIN_AUTHORISATION_TIMEOUT).count()); as->CloseConnection(true); continue; } @@ -394,13 +394,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); @@ -479,7 +479,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); @@ -520,7 +520,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 '%s' (%s): %d", this->admin_name.c_str(), this->admin_version.c_str(), d1); @@ -564,7 +564,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); @@ -583,7 +583,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCmdNames() const char *cmdname = GetCommandName(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); @@ -617,7 +617,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendCmdLogging(ClientID clien p->Send_uint8 (cp->company); p->Send_uint16(cp->cmd & CMD_ID_MASK); - p->Send_uint16(4 + 4 + 8 + 4 + (uint16)cp->text.size() + 1); + p->Send_uint16(4 + 4 + 8 + 4 + (uint16_t)cp->text.size() + 1); { p->Send_uint32(cp->p1); p->Send_uint32(cp->p2); @@ -695,7 +695,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: @@ -793,7 +793,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_EXTERNAL_CHAT(P if (!IsValidConsoleColour(colour)) { DEBUG(net, 1, "[admin] Not supported chat colour %d (%s, %s, %s) from '%s' (%s).", - (uint16)colour, source.c_str(), user.c_str(), msg.c_str(), this->admin_name.c_str(), this->admin_version.c_str()); + (uint16_t)colour, source.c_str(), user.c_str(), msg.c_str(), this->admin_name.c_str(), this->admin_version.c_str()); return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET); } diff --git a/src/network/network_admin.h b/src/network/network_admin.h index 5e695e2d5d..2253d8efbd 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. @@ -63,7 +63,7 @@ public: NetworkRecvStatus SendCompanyStats(); NetworkRecvStatus SendChat(NetworkAction action, DestType desttype, ClientID client_id, const std::string &msg, NetworkTextMessageData data); - NetworkRecvStatus SendRcon(uint16 colour, const std::string_view command); + 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(); diff --git a/src/network/network_base.h b/src/network/network_base.h index 471a307b50..a39b66cc18 100644 --- a/src/network/network_base.h +++ b/src/network/network_base.h @@ -27,8 +27,8 @@ struct NetworkClientInfo : NetworkClientInfoPool::PoolItem<&_networkclientinfo_p CompanyID client_playas; ///< As which company is this client playing (CompanyID) Date join_date; ///< Gamedate the client has joined DateFract join_date_fract; - uint8 join_tick_skip_counter; - uint32 join_frame; + uint8_t join_tick_skip_counter; + uint32_t join_frame; /** * Create a new client. diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index b07418595e..61b1c595f4 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -442,7 +442,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; @@ -470,7 +470,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 9401355a82..4948d3f9a8 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -389,21 +389,21 @@ 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 _company_password_game_seed; +static uint32_t _company_password_game_seed; /** Network server's x25519 public key, used for key derivation */ static byte _server_x25519_pub_key[32]; /** Key message ID counter */ -static uint64 _next_key_message_id; +static uint64_t _next_key_message_id; /** The other bit of 'entropy' used to generate a salt for the server, rcon, and settings passwords. */ static std::string _password_server_id; /** The other bit of 'entropy' used to generate a salt for the company passwords. */ static std::string _company_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; @@ -446,10 +446,10 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendKeyPasswordPacket(PacketTy if (payload != nullptr) buffer.Send_string(*payload); /* Message authentication code */ - uint8 mac[16]; + uint8_t mac[16]; /* Use only once per key: random */ - uint8 nonce[24]; + uint8_t nonce[24]; NetworkRandomBytesWithFallback(nonce, 24); /* Encrypt in place, use first half of hash as key */ @@ -619,7 +619,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendDesyncLog(const std::strin for (size_t offset = 0; offset < log.size();) { Packet *p = new Packet(PACKET_CLIENT_DESYNC_LOG, SHRT_MAX); size_t size = std::min(log.size() - offset, SHRT_MAX - 2 - p->Size()); - p->Send_uint16((uint16)size); + p->Send_uint16((uint16_t)size); p->Send_binary((const byte *)(log.data() + offset), size); my_client->SendPacket(p); @@ -646,7 +646,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendDesyncSyncData() if (_network_sync_record_counts.empty()) return NETWORK_RECV_STATUS_OKAY; uint total = 0; - for (uint32 count : _network_sync_record_counts) { + for (uint32_t count : _network_sync_record_counts) { total += count; } @@ -656,9 +656,9 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::SendDesyncSyncData() } Packet *p = new Packet(PACKET_CLIENT_DESYNC_SYNC_DATA, SHRT_MAX); - p->Send_uint32((uint32)_network_sync_record_counts.size()); - uint32 offset = 0; - for (uint32 count : _network_sync_record_counts) { + p->Send_uint32((uint32_t)_network_sync_record_counts.size()); + uint32_t offset = 0; + for (uint32_t count : _network_sync_record_counts) { p->Send_uint32(count); for (uint i = 0; i < count; i++) { const NetworkSyncRecord &record = _network_sync_records[offset + i]; @@ -1012,7 +1012,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; @@ -1099,7 +1099,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 %d", _frame_counter_server); @@ -1381,7 +1381,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); diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp index 7097de4697..0f6aa33449 100644 --- a/src/network/network_command.cpp +++ b/src/network/network_command.cpp @@ -147,7 +147,7 @@ static CommandQueue _local_execution_queue; * @param company The company that wants to send the command * @param aux_data Auxiliary command data */ -void NetworkSendCommand(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd, CommandCallback *callback, const char *text, CompanyID company, const CommandAuxiliaryBase *aux_data) +void NetworkSendCommand(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd, CommandCallback *callback, const char *text, CompanyID company, const CommandAuxiliaryBase *aux_data) { assert((cmd & CMD_FLAGS_MASK) == 0); @@ -344,7 +344,7 @@ const char *NetworkGameSocketHandler::ReceiveCommand(Packet *p, CommandPacket *c cp->callback = _callback_table[callback]; - uint16 aux_data_size = p->Recv_uint16(); + uint16_t aux_data_size = p->Recv_uint16(); if (aux_data_size > 0 && p->CanReadFromPacket(aux_data_size, true)) { CommandAuxiliarySerialised *aux_data = new CommandAuxiliarySerialised(); cp->aux_data.reset(aux_data); @@ -386,6 +386,6 @@ void NetworkGameSocketHandler::SendCommand(Packet *p, const CommandPacket *cp) if (cp->aux_data != nullptr) { CommandSerialisationBuffer serialiser(p->GetSerialisationBuffer(), p->GetSerialisationLimit()); cp->aux_data->Serialise(serialiser); - p->WriteAtOffset_uint16(aux_data_size_pos, (uint16)(p->Size() - aux_data_size_pos - 2)); + p->WriteAtOffset_uint16(aux_data_size_pos, (uint16_t)(p->Size() - aux_data_size_pos - 2)); } } diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index 38f7644354..a17c726109 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -235,9 +235,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); @@ -263,15 +263,15 @@ void ClientNetworkContentSocketHandler::RequestContentList(ContentVector *cv, bo this->Connect(); - const uint max_per_packet = std::min(255, (TCP_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8)) / - (sizeof(uint8) + sizeof(uint32) + (send_md5sum ? MD5_HASH_BYTES : 0))) - 1; + const uint max_per_packet = std::min(255, (TCP_MTU - sizeof(PacketSize) - sizeof(byte) - sizeof(uint8_t)) / + (sizeof(uint8_t) + sizeof(uint32_t) + (send_md5sum ? MD5_HASH_BYTES : 0))) - 1; uint offset = 0; while (cv->size() > offset) { Packet *p = new Packet(send_md5sum ? PACKET_CONTENT_CLIENT_INFO_EXTID_MD5 : PACKET_CONTENT_CLIENT_INFO_EXTID, TCP_MTU); const uint to_send = std::min(static_cast(cv->size() - offset), max_per_packet); - p->Send_uint8(static_cast(to_send)); + p->Send_uint8(static_cast(to_send)); for (uint i = 0; i < to_send; i++) { const ContentInfo *ci = (*cv)[offset + i]; @@ -367,9 +367,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 8dcaacc3dc..9a7e3d5172 100644 --- a/src/network/network_content.h +++ b/src/network/network_content.h @@ -138,7 +138,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 f92302a0b4..4d02a1cc67 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -141,7 +141,7 @@ void BaseNetworkContentDownloadStatusWindow::DrawWidget(const Rect &r, WidgetID /* 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); @@ -877,7 +877,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 6f96c91d7c..351b28ccc5 100644 --- a/src/network/network_content_gui.h +++ b/src/network/network_content_gui.h @@ -22,8 +22,8 @@ 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 - std::string name; ///< The current name 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 4b4dee3d0d..6fa4999595 100644 --- a/src/network/network_coordinator.cpp +++ b/src/network/network_coordinator.cpp @@ -34,8 +34,8 @@ std::string _network_server_invite_code = ""; ///< Our invite code as indicated /** Connect to a game server by IP:port. */ class NetworkDirectConnecter : public TCPConnecter { private: - std::string token; ///< Token of this connection. - uint8 tracking_number; ///< Tracking number of this connection. + std::string token; ///< Token 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 { @@ -62,9 +62,9 @@ public: /** Connecter used after STUN exchange to connect from both sides to each other. */ 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. + std::string token; ///< Token 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 3977c4e634..1eedfe55ae 100644 --- a/src/network/network_coordinator.h +++ b/src/network/network_coordinator.h @@ -60,7 +60,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: @@ -87,14 +87,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 921a2e730c..a793654527 100644 --- a/src/network/network_func.h +++ b/src/network/network_func.h @@ -26,12 +26,12 @@ extern NetworkCompanyState *_network_company_states; extern std::string _network_company_server_id; -extern uint8 _network_company_password_storage_token[16]; -extern uint8 _network_company_password_storage_key[32]; +extern uint8_t _network_company_password_storage_token[16]; +extern uint8_t _network_company_password_storage_key[32]; 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; @@ -50,7 +50,7 @@ void NetworkReboot(); void NetworkDisconnect(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); diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 8704675260..00b2cc09db 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -531,7 +531,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()); @@ -789,7 +789,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; @@ -1146,7 +1146,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(); @@ -2090,9 +2090,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; @@ -2110,7 +2110,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 45657c142f..c598711a85 100644 --- a/src/network/network_gui.h +++ b/src/network/network_gui.h @@ -35,7 +35,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 abdbf224cd..1b66796fbe 100644 --- a/src/network/network_internal.h +++ b/src/network/network_internal.h @@ -20,7 +20,7 @@ #include -static const uint32 FIND_SERVER_EXTENDED_TOKEN = 0x2A49582A; +static const uint32_t FIND_SERVER_EXTENDED_TOKEN = 0x2A49582A; #ifdef RANDOM_DEBUG /** @@ -63,41 +63,41 @@ 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 uint64 _sync_state_checksum; -extern uint32 _sync_frame; +extern uint32_t _sync_seed_1; +extern uint64_t _sync_state_checksum; +extern uint32_t _sync_frame; extern Date _last_sync_date; extern DateFract _last_sync_date_fract; -extern uint8 _last_sync_tick_skip_counter; -extern uint32 _last_sync_frame_counter; +extern uint8_t _last_sync_tick_skip_counter; +extern uint32_t _last_sync_frame_counter; 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(); @@ -124,7 +124,7 @@ struct CommandPacket : CommandContainer { /** Make sure the pointer is nullptr. */ CommandPacket() : next(nullptr), frame(0), client_id(INVALID_CLIENT_ID), company(INVALID_COMPANY), my_cmd(false) {} CommandPacket *next; ///< the next command packet (if in queue) - uint32 frame; ///< the frame in which this packet is executed + uint32_t frame; ///< the frame in which this packet is executed ClientID client_id; ///< originating client ID (or INVALID_CLIENT_ID if not specified) CompanyID company; ///< company that is executing the command bool my_cmd; ///< did the command originate from "me" @@ -140,13 +140,13 @@ void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send, 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::vector GenerateGeneralPasswordHash(const std::string &password, const std::string &password_server_id, uint64 password_game_seed); +std::string GenerateCompanyPasswordHash(const std::string &password, const std::string &password_server_id, uint32_t password_game_seed); +std::vector GenerateGeneralPasswordHash(const std::string &password, const std::string &password_server_id, uint64_t password_game_seed); std::string NetworkGenerateRandomKeyString(uint bytes); 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 32cdc5b86e..90857b388c 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -185,7 +185,7 @@ struct PacketWriter : SaveFilter { /* Fast-track the size to the client. */ this->map_size_packet.reset(new Packet(PACKET_SERVER_MAP_SIZE, SHRT_MAX)); - this->map_size_packet->Send_uint32((uint32)this->total_size); + this->map_size_packet->Send_uint32((uint32_t)this->total_size); } }; @@ -216,7 +216,7 @@ ServerNetworkGameSocketHandler::~ServerNetworkGameSocketHandler() if (_redirect_console_to_client == this->client_id) _redirect_console_to_client = INVALID_CLIENT_ID; OrderBackup::ResetUser(this->client_id); - extern void RemoveVirtualTrainsOfUser(uint32 user); + extern void RemoveVirtualTrainsOfUser(uint32_t user); RemoveVirtualTrainsOfUser(this->client_id); if (this->savegame != nullptr) { @@ -265,7 +265,7 @@ bool ServerNetworkGameSocketHandler::ParseKeyPasswordPacket(Packet *p, NetworkSh /* Decrypt in place, use first half of hash as key */ if (crypto_aead_unlock(message.data(), mac, ss.shared_data, nonce, client_pub_key, 32, message.data(), message.size()) == 0) { SubPacketDeserialiser spd(p, message); - uint64 message_id = spd.Recv_uint64(); + uint64_t message_id = spd.Recv_uint64(); if (message_id < this->min_key_message_id) { /* ID has not increased monotonically, reject the message */ return false; @@ -419,7 +419,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendGameInfo() return NETWORK_RECV_STATUS_OKAY; } -NetworkRecvStatus ServerNetworkGameSocketHandler::SendGameInfoExtended(PacketGameType reply_type, uint16 flags, uint16 version) +NetworkRecvStatus ServerNetworkGameSocketHandler::SendGameInfoExtended(PacketGameType reply_type, uint16_t flags, uint16_t version) { Packet *p = new Packet(reply_type, SHRT_MAX); SerializeNetworkGameInfoExtended(p, GetCurrentNetworkServerGameInfo(), flags, version); @@ -483,7 +483,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendDesyncLog(const std::strin for (size_t offset = 0; offset < log.size();) { Packet *p = new Packet(PACKET_SERVER_DESYNC_LOG, SHRT_MAX); size_t size = std::min(log.size() - offset, SHRT_MAX - 2 - p->Size()); - p->Send_uint16(static_cast(size)); + p->Send_uint16(static_cast(size)); p->Send_binary((const byte *)(log.data() + offset), size); this->SendPacket(p); @@ -503,7 +503,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendNewGRFCheck() if (!HasBit(c->flags, GCF_STATIC)) grf_count++; } - p->Send_uint32 (grf_count); + p->Send_uint32(grf_count); for (c = _grfconfig; c != nullptr; c = c->next) { if (!HasBit(c->flags, GCF_STATIC)) SerializeGRFIdentifier(p, &c->ident); } @@ -835,7 +835,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) { assert(this->rcon_reply_key != nullptr); @@ -845,10 +845,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendRConResult(uint16 colour, buffer.Send_string(command); /* Message authentication code */ - uint8 mac[16]; + uint8_t mac[16]; /* Use only once per key: random */ - uint8 nonce[24]; + uint8_t nonce[24]; NetworkRandomBytesWithFallback(nonce, 24); /* Encrypt in place, use first half of hash as key */ @@ -893,7 +893,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendCompanyUpdate() { Packet *p = new Packet(PACKET_SERVER_COMPANY_UPDATE, SHRT_MAX); - 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; @@ -928,8 +928,8 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_GAME_INFO(Packe { if (p->CanReadFromPacket(9) && p->Recv_uint32() == FIND_SERVER_EXTENDED_TOKEN) { PacketGameType reply_type = (PacketGameType)p->Recv_uint8(); - uint16 flags = p->Recv_uint16(); - uint16 version = p->Recv_uint16(); + uint16_t flags = p->Recv_uint16(); + uint16_t version = p->Recv_uint16(); return this->SendGameInfoExtended(reply_type, flags, version); } else { return this->SendGameInfo(); @@ -970,7 +970,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.c_str()) || _openttd_newgrf_version != newgrf_version) { @@ -1258,7 +1258,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(Packet *p char client_name[NETWORK_CLIENT_NAME_LENGTH]; NetworkErrorCode errorno = (NetworkErrorCode)p->Recv_uint8(); NetworkRecvStatus rx_status = p->CanReadFromPacket(1) ? (NetworkRecvStatus)p->Recv_uint8() : NETWORK_RECV_STATUS_OKAY; - int8 status = p->CanReadFromPacket(1) ? (int8)p->Recv_uint8() : -1; + int8_t status = p->CanReadFromPacket(1) ? (int8_t)p->Recv_uint8() : -1; PacketGameType last_pkt_type = p->CanReadFromPacket(1) ? (PacketGameType)p->Recv_uint8() : PACKET_END; /* The client was never joined.. thank the client for the packet, but ignore it */ @@ -1293,7 +1293,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(Packet *p this->SendDesyncLog(server_desync_log); // decrease the sync frequency for this point onwards - _settings_client.network.sync_freq = std::min(_settings_client.network.sync_freq, 16); + _settings_client.network.sync_freq = std::min(_settings_client.network.sync_freq, 16); // have the server and all clients run some sanity checks NetworkSendCommand(0, 0, 0, 0, CMD_DESYNC_CHECK, nullptr, nullptr, _local_company, nullptr); @@ -1321,18 +1321,18 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_DESYNC_MSG(Pack { Date date = p->Recv_uint32(); DateFract date_fract = p->Recv_uint16(); - uint8 tick_skip_counter = p->Recv_uint8(); + uint8_t tick_skip_counter = p->Recv_uint8(); std::string msg; p->Recv_string(msg); DEBUG(desync, 0, "Client-id %d desync msg: %s", this->client_id, msg.c_str()); - extern void LogRemoteDesyncMsg(Date date, DateFract date_fract, uint8 tick_skip_counter, uint32 src_id, std::string msg); + extern void LogRemoteDesyncMsg(Date date, DateFract date_fract, uint8_t tick_skip_counter, uint32_t src_id, std::string msg); LogRemoteDesyncMsg(date, date_fract, tick_skip_counter, this->client_id, std::move(msg)); return NETWORK_RECV_STATUS_OKAY; } NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_DESYNC_SYNC_DATA(Packet *p) { - uint32 frame_count = p->Recv_uint32(); + uint32_t frame_count = p->Recv_uint32(); DEBUG(net, 2, "Received desync sync data: %u frames", frame_count); @@ -1341,10 +1341,10 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_DESYNC_SYNC_DAT size_t record_count_offset = 0; size_t record_offset = 0; for (uint i = 0; i < frame_count; i++) { - uint32 item_count = p->Recv_uint32(); + uint32_t item_count = p->Recv_uint32(); if (item_count == 0) continue; - uint32 local_item_count = 0; - uint32 frame = 0; + uint32_t local_item_count = 0; + uint32_t frame = 0; NetworkSyncRecordEvents event = NSRE_BEGIN; for (uint j = 0; j < item_count; j++) { if (j == 0) { @@ -1360,8 +1360,8 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_DESYNC_SYNC_DAT } else { event = (NetworkSyncRecordEvents)p->Recv_uint32(); } - uint32 seed_1 = p->Recv_uint32(); - uint64 state_checksum = p->Recv_uint64(); + uint32_t seed_1 = p->Recv_uint32(); + uint64_t state_checksum = p->Recv_uint64(); if (j == local_item_count) { this->desync_frame_info = stdstr_fmt("Desync subframe count mismatch: extra client record: %08X, %s", frame, GetSyncRecordEventName(event)); return NETWORK_RECV_STATUS_OKAY; @@ -1422,7 +1422,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) { @@ -1438,7 +1438,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 diff --git a/src/network/network_server.h b/src/network/network_server.h index 88a39ca303..a4c7c82f5e 100644 --- a/src/network/network_server.h +++ b/src/network/network_server.h @@ -23,7 +23,7 @@ extern NetworkClientSocketPool _networkclientsocket_pool; /** Class for handling the server side of the game connection. */ class ServerNetworkGameSocketHandler : public NetworkClientSocketPool::PoolItem<&_networkclientsocket_pool>, public NetworkGameSocketHandler, public TCPListenHandler { NetworkGameKeys intl_keys; - uint64 min_key_message_id = 0; + uint64_t min_key_message_id = 0; byte *rcon_reply_key = nullptr; protected: @@ -49,7 +49,7 @@ protected: NetworkRecvStatus Receive_CLIENT_MOVE(Packet *p) override; NetworkRecvStatus SendGameInfo(); - NetworkRecvStatus SendGameInfoExtended(PacketGameType reply_type, uint16 flags, uint16 version); + NetworkRecvStatus SendGameInfoExtended(PacketGameType reply_type, uint16_t flags, uint16_t version); NetworkRecvStatus SendNewGRFCheck(); NetworkRecvStatus SendWelcome(); NetworkRecvStatus SendNeedGamePassword(); @@ -78,7 +78,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 @@ -109,7 +109,7 @@ 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 SendRConDenied(); NetworkRecvStatus SendMove(ClientID client_id, CompanyID company_id); 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..a387b8b80b 100644 --- a/src/network/network_stun.h +++ b/src/network/network_stun.h @@ -15,9 +15,9 @@ /** Class for handling the client side of the STUN connection. */ class ClientNetworkStunSocketHandler : public NetworkStunSocketHandler { private: - std::string token; ///< Token of this STUN handler. - uint8 family = AF_UNSPEC; ///< Family of this STUN handler. - bool sent_result = false; ///< Did we sent the result of the STUN connection? + std::string token; ///< Token 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: TCPConnecter *connecter = nullptr; ///< Connecter instance. @@ -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_sync.h b/src/network/network_sync.h index 51dc98919e..76eea4cd42 100644 --- a/src/network/network_sync.h +++ b/src/network/network_sync.h @@ -14,15 +14,15 @@ /* Sync debugging */ struct NetworkSyncRecord { - uint32 frame; - uint32 seed_1; - uint64 state_checksum; + uint32_t frame; + uint32_t seed_1; + uint64_t state_checksum; }; extern ring_buffer _network_sync_records; extern ring_buffer _network_sync_record_counts; extern bool _record_sync_records; -enum NetworkSyncRecordEvents : uint32 { +enum NetworkSyncRecordEvents : uint32_t { NSRE_BEGIN, NSRE_CMD, NSRE_AUX_TILE, diff --git a/src/network/network_turn.cpp b/src/network/network_turn.cpp index 44e5e0fcd6..e6f48d535a 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..1313ca60de 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 57fe181094..77c6915ecd 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; @@ -148,10 +148,10 @@ enum NetworkErrorCode { }; struct NetworkTextMessageData { - int64 data; - int64 auxdata; + int64_t data; + int64_t auxdata; - NetworkTextMessageData(int64 data = 0, int64 auxdata = 0) + NetworkTextMessageData(int64_t data = 0, int64_t auxdata = 0) : data(data), auxdata(auxdata) { } template void recv(T *p) { diff --git a/src/network/network_udp.cpp b/src/network/network_udp.cpp index 7e2540cbae..33b5933879 100644 --- a/src/network/network_udp.cpp +++ b/src/network/network_udp.cpp @@ -35,7 +35,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 { @@ -100,8 +100,8 @@ void ServerNetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER(Packet *p, Networ void ServerNetworkUDPSocketHandler::Reply_CLIENT_FIND_SERVER_extended(Packet *p, NetworkAddress *client_addr) { - [[maybe_unused]] uint16 flags = p->Recv_uint16(); - uint16 version = p->Recv_uint16(); + [[maybe_unused]] uint16_t flags = p->Recv_uint16(); + uint16_t version = p->Recv_uint16(); Packet packet(PACKET_UDP_EX_SERVER_RESPONSE); this->SendPacket(&packet, client_addr); diff --git a/src/newgrf.cpp b/src/newgrf.cpp index cd1902e091..25cdb07a14 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -79,14 +79,14 @@ const std::vector &GetAllGRFFiles() return _grf_files; } -static btree::btree_map _callback_result_cache; +static btree::btree_map _callback_result_cache; /** Miscellaneous GRF features, set by Action 0x0D, parameter 0x9E */ byte _misc_grf_features = 0; /** 32 * 8 = 256 flags. Apparently TTDPatch uses this many.. */ -static uint32 _ttdpatch_flags[8]; -static uint32 _observed_ttdpatch_flags[8]; +static uint32_t _ttdpatch_flags[8]; +static uint32_t _observed_ttdpatch_flags[8]; /** Indicates which are the newgrf features currently loaded ingame */ GRFLoadedFeatures _loaded_newgrf_features; @@ -101,7 +101,7 @@ 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); } @@ -136,25 +136,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(); @@ -227,13 +227,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. @@ -257,17 +257,17 @@ 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() { } - 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 { @@ -312,7 +312,7 @@ void CDECL _intl_grfmsg(int severity, const char *str, ...) * @param grfid The grfID to obtain the file for * @return The file. */ -GRFFile *GetFileByGRFID(uint32 grfid) +GRFFile *GetFileByGRFID(uint32_t grfid) { for (GRFFile * const file : _grf_files) { if (file->grfid == grfid) return file; @@ -325,7 +325,7 @@ GRFFile *GetFileByGRFID(uint32 grfid) * @param grfid The grfID to obtain the file for * @return The file. */ -GRFFile *GetFileByGRFIDExpectCurrent(uint32 grfid) +GRFFile *GetFileByGRFIDExpectCurrent(uint32_t grfid) { if (_cur.grffile->grfid == grfid) return _cur.grffile; return GetFileByGRFID(grfid); @@ -381,7 +381,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. }; @@ -470,7 +470,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. @@ -497,14 +497,14 @@ StringID MapGRFStringID(uint32 grfid, StringID str) } } -static btree::btree_map _grf_id_overrides; +static btree::btree_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)); @@ -518,15 +518,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); @@ -584,7 +584,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()) { @@ -610,12 +610,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; } @@ -657,7 +657,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(); @@ -776,8 +776,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 - uint16 *max_sprite_offset = AllocaM(uint16, num_building_sprites + 1); - uint16 *max_palette_offset = AllocaM(uint16, num_building_sprites + 1); + uint16_t *max_sprite_offset = AllocaM(uint16_t, num_building_sprites + 1); + uint16_t *max_palette_offset = AllocaM(uint16_t, num_building_sprites + 1); MemSetT(max_sprite_offset, 0, num_building_sprites + 1); MemSetT(max_palette_offset, 0, num_building_sprites + 1); @@ -861,12 +861,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 (cargo != CT_INVALID) SetBit(result, cargo); } @@ -880,7 +880,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) { @@ -888,8 +888,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, "%s: Unsupported running cost base 0x%04X, ignoring", error_location, base_pointer); @@ -1002,7 +1002,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]; @@ -1027,7 +1027,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; @@ -1056,8 +1056,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. */ @@ -1073,7 +1073,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; @@ -1090,7 +1090,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' */ @@ -1129,7 +1129,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) { @@ -1170,7 +1170,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; @@ -1252,7 +1252,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; @@ -1329,8 +1329,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; @@ -1352,7 +1352,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' */ @@ -1391,7 +1391,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; @@ -1462,7 +1462,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; @@ -1517,8 +1517,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; @@ -1548,7 +1548,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' */ @@ -1579,7 +1579,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; @@ -1646,7 +1646,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; @@ -1701,8 +1701,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; @@ -1759,7 +1759,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; @@ -1808,7 +1808,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; @@ -1884,13 +1884,13 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, cons } /* 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, cons } case 0x0A: { // Copy sprite layout - uint16 srcid = buf->ReadExtendedByte(); + uint16_t srcid = buf->ReadExtendedByte(); const StationSpec *srcstatspec = srcid >= _cur.grffile->stations.size() ? nullptr : _cur.grffile->stations[srcid].get(); if (srcstatspec == nullptr) { @@ -1994,7 +1994,7 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, cons break; case 0x0F: { // Copy custom layout - uint16 srcid = buf->ReadExtendedByte(); + uint16_t srcid = buf->ReadExtendedByte(); const StationSpec *srcstatspec = srcid >= _cur.grffile->stations.size() ? nullptr : _cur.grffile->stations[srcid].get(); if (srcstatspec == nullptr) { @@ -2050,7 +2050,7 @@ static ChangeInfoResult StationChangeInfo(uint stid, int numinfo, int prop, cons /* 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); @@ -2424,7 +2424,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, con 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; @@ -2444,7 +2444,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, con 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 */ @@ -2527,14 +2527,14 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, con 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 (cargo == CT_INVALID) { @@ -2605,7 +2605,7 @@ static ChangeInfoResult TownHouseChangeInfo(uint hid, int numinfo, int prop, con * @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); @@ -2631,7 +2631,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)); } @@ -2708,7 +2708,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, co 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, @@ -2723,7 +2723,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, co 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(); @@ -2844,7 +2844,7 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, co * 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; @@ -2872,8 +2872,8 @@ static ChangeInfoResult GlobalVarChangeInfo(uint gvid, int numinfo, int prop, co case A0RPI_GLOBALVAR_EXTRA_STATION_NAMES: { if (MappedPropertyLengthMismatch(buf, 4, mapping_entry)) break; - uint16 str = buf->ReadWord(); - uint16 flags = buf->ReadWord(); + uint16_t str = buf->ReadWord(); + uint16_t flags = buf->ReadWord(); if (_extra_station_names_used < MAX_EXTRA_STATION_NAMES) { ExtraStationNameInfo &info = _extra_station_names[_extra_station_names_used]; AddStringForMapping(str, &info.str); @@ -2960,8 +2960,8 @@ static ChangeInfoResult GlobalVarReserveInfo(uint gvid, int numinfo, int prop, c 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; } @@ -3092,7 +3092,7 @@ static ChangeInfoResult CargoChangeInfo(uint cid, int numinfo, int prop, const G 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; @@ -3117,7 +3117,7 @@ static ChangeInfoResult CargoChangeInfo(uint cid, int numinfo, int prop, const G break; case 0x1D: // Vehicle capacity muliplier - cs->multiplier = std::max(1u, buf->ReadWord()); + cs->multiplier = std::max(1u, buf->ReadWord()); break; default: @@ -3300,7 +3300,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; @@ -3342,7 +3342,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; @@ -3557,8 +3557,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; @@ -3625,8 +3625,8 @@ 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_t and * it.ti was just a TileIndexDiff that was added to it. @@ -3698,10 +3698,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 (...) { @@ -3744,7 +3744,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; @@ -3770,7 +3770,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 { @@ -3842,7 +3842,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; } @@ -3954,7 +3954,7 @@ static ChangeInfoResult AirportChangeInfo(uint airport, int numinfo, int prop, c as->num_table = buf->ReadByte(); // Number of layouts free(as->rotation); 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; @@ -3985,7 +3985,7 @@ static ChangeInfoResult AirportChangeInfo(uint airport, int numinfo, int prop, c 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 %u with airport id %u, not yet defined. Ignoring.", local_tile_id, airport + i); @@ -3994,8 +3994,8 @@ static ChangeInfoResult AirportChangeInfo(uint airport, int numinfo, int prop, c 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) { @@ -4110,7 +4110,7 @@ static ChangeInfoResult SignalsChangeInfo(uint id, int numinfo, int prop, const case A0RPI_SIGNALS_DEFINE_STYLE: { if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break; - uint8 local_id = buf->ReadByte(); + uint8_t local_id = buf->ReadByte(); if (_num_new_signal_styles < MAX_NEW_SIGNAL_STYLES) { NewSignalStyle &style = _new_signal_styles[_num_new_signal_styles]; style = {}; @@ -4127,7 +4127,7 @@ static ChangeInfoResult SignalsChangeInfo(uint id, int numinfo, int prop, const case A0RPI_SIGNALS_STYLE_NAME: { if (MappedPropertyLengthMismatch(buf, 2, mapping_entry)) break; - uint16 str = buf->ReadWord(); + uint16_t str = buf->ReadWord(); if (_cur.grffile->current_new_signal_style != nullptr) { AddStringForMapping(str, &(_cur.grffile->current_new_signal_style->name)); } @@ -4136,7 +4136,7 @@ static ChangeInfoResult SignalsChangeInfo(uint id, int numinfo, int prop, const case A0RPI_SIGNALS_STYLE_NO_ASPECT_INCREASE: { if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break; - uint8 value = buf->ReadByte(); + uint8_t value = buf->ReadByte(); if (_cur.grffile->current_new_signal_style != nullptr) { SB(_cur.grffile->current_new_signal_style->style_flags, NSSF_NO_ASPECT_INC, 1, (value != 0 ? 1 : 0)); } @@ -4145,7 +4145,7 @@ static ChangeInfoResult SignalsChangeInfo(uint id, int numinfo, int prop, const case A0RPI_SIGNALS_STYLE_ALWAYS_RESERVE_THROUGH: { if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break; - uint8 value = buf->ReadByte(); + uint8_t value = buf->ReadByte(); if (_cur.grffile->current_new_signal_style != nullptr) { SB(_cur.grffile->current_new_signal_style->style_flags, NSSF_ALWAYS_RESERVE_THROUGH, 1, (value != 0 ? 1 : 0)); } @@ -4154,7 +4154,7 @@ static ChangeInfoResult SignalsChangeInfo(uint id, int numinfo, int prop, const case A0RPI_SIGNALS_STYLE_LOOKAHEAD_EXTRA_ASPECTS: { if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break; - uint8 value = buf->ReadByte(); + uint8_t value = buf->ReadByte(); if (_cur.grffile->current_new_signal_style != nullptr) { SetBit(_cur.grffile->current_new_signal_style->style_flags, NSSF_LOOKAHEAD_ASPECTS_SET); _cur.grffile->current_new_signal_style->lookahead_extra_aspects = value; @@ -4164,7 +4164,7 @@ static ChangeInfoResult SignalsChangeInfo(uint id, int numinfo, int prop, const case A0RPI_SIGNALS_STYLE_LOOKAHEAD_SINGLE_SIGNAL_ONLY: { if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break; - uint8 value = buf->ReadByte(); + uint8_t value = buf->ReadByte(); if (_cur.grffile->current_new_signal_style != nullptr) { SB(_cur.grffile->current_new_signal_style->style_flags, NSSF_LOOKAHEAD_SINGLE_SIGNAL, 1, (value != 0 ? 1 : 0)); } @@ -4173,25 +4173,25 @@ static ChangeInfoResult SignalsChangeInfo(uint id, int numinfo, int prop, const case A0RPI_SIGNALS_STYLE_SEMAPHORE_ENABLED: { if (MappedPropertyLengthMismatch(buf, 4, mapping_entry)) break; - uint32 mask = buf->ReadDWord(); + uint32_t mask = buf->ReadDWord(); if (_cur.grffile->current_new_signal_style != nullptr) { - _cur.grffile->current_new_signal_style->semaphore_mask = (uint8)mask; + _cur.grffile->current_new_signal_style->semaphore_mask = (uint8_t)mask; } break; } case A0RPI_SIGNALS_STYLE_ELECTRIC_ENABLED: { if (MappedPropertyLengthMismatch(buf, 4, mapping_entry)) break; - uint32 mask = buf->ReadDWord(); + uint32_t mask = buf->ReadDWord(); if (_cur.grffile->current_new_signal_style != nullptr) { - _cur.grffile->current_new_signal_style->electric_mask = (uint8)mask; + _cur.grffile->current_new_signal_style->electric_mask = (uint8_t)mask; } break; } case A0RPI_SIGNALS_STYLE_OPPOSITE_SIDE: { if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break; - uint8 value = buf->ReadByte(); + uint8_t value = buf->ReadByte(); if (_cur.grffile->current_new_signal_style != nullptr) { SB(_cur.grffile->current_new_signal_style->style_flags, NSSF_OPPOSITE_SIDE, 1, (value != 0 ? 1 : 0)); } @@ -4200,7 +4200,7 @@ static ChangeInfoResult SignalsChangeInfo(uint id, int numinfo, int prop, const case A0RPI_SIGNALS_STYLE_COMBINED_NORMAL_SHUNT: { if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break; - uint8 value = buf->ReadByte(); + uint8_t value = buf->ReadByte(); if (_cur.grffile->current_new_signal_style != nullptr) { SB(_cur.grffile->current_new_signal_style->style_flags, NSSF_COMBINED_NORMAL_SHUNT, 1, (value != 0 ? 1 : 0)); } @@ -4209,7 +4209,7 @@ static ChangeInfoResult SignalsChangeInfo(uint id, int numinfo, int prop, const case A0RPI_SIGNALS_STYLE_REALISTIC_BRAKING_ONLY: { if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break; - uint8 value = buf->ReadByte(); + uint8_t value = buf->ReadByte(); if (_cur.grffile->current_new_signal_style != nullptr) { SB(_cur.grffile->current_new_signal_style->style_flags, NSSF_REALISTIC_BRAKING_ONLY, 1, (value != 0 ? 1 : 0)); } @@ -4312,7 +4312,7 @@ static ChangeInfoResult ObjectChangeInfo(uint id, int numinfo, int prop, const G } /* 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; } @@ -4466,7 +4466,7 @@ static ChangeInfoResult RailTypeChangeInfo(uint id, int numinfo, int prop, const 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); @@ -4724,7 +4724,7 @@ static ChangeInfoResult RoadTypeChangeInfo(uint id, int numinfo, int prop, const 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; } @@ -4816,7 +4816,7 @@ static ChangeInfoResult RoadTypeChangeInfo(uint id, int numinfo, int prop, const case A0RPI_ROADTYPE_COLLISION_MODE: { if (MappedPropertyLengthMismatch(buf, 1, mapping_entry)) break; - uint8 collision_mode = buf->ReadByte(); + uint8_t collision_mode = buf->ReadByte(); if (collision_mode < RTCM_END) rti->collision_mode = (RoadTypeCollisionMode)collision_mode; break; } @@ -5095,7 +5095,7 @@ static ChangeInfoResult RoadStopChangeInfo(uint id, int numinfo, int prop, const 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; @@ -5169,7 +5169,7 @@ static ChangeInfoResult RoadStopChangeInfo(uint id, int numinfo, int prop, const if (MappedPropertyLengthMismatch(buf, 4, mapping_entry)) break; FALLTHROUGH; case 0x12: // General flags - rs->flags = (uint16)buf->ReadDWord(); // Future-proofing, size this as 4 bytes, but we only need two bytes' worth of flags at present + rs->flags = (uint16_t)buf->ReadDWord(); // Future-proofing, size this as 4 bytes, but we only need two bytes' worth of flags at present break; case A0RPI_ROADSTOP_MIN_BRIDGE_HEIGHT: @@ -5286,7 +5286,7 @@ static bool HandleChangeInfoResult(const char *caller, ChangeInfoResult cir, Grf } } -static GrfSpecFeatureRef ReadFeature(uint8 raw_byte, bool allow_48 = false) +static GrfSpecFeatureRef ReadFeature(uint8_t raw_byte, bool allow_48 = false) { if (unlikely(HasBit(_cur.grffile->ctrl_flags, GFCF_HAVE_FEATURE_ID_REMAP))) { const GRFFeatureMapRemapSet &remap = _cur.grffile->feature_id_remaps; @@ -5364,7 +5364,7 @@ const char *GetFeatureString(GrfSpecFeatureRef feature) const char *GetFeatureString(GrfSpecFeature feature) { - uint8 raw_byte = feature; + uint8_t raw_byte = feature; if (feature >= GSF_REAL_FEATURE_END) { for (const auto &entry : _cur.grffile->feature_id_remaps.mapping) { if (entry.second.feature == feature) { @@ -5384,9 +5384,9 @@ struct GRFFilePropertyDescriptor { : prop(prop), entry(entry) {} }; -static GRFFilePropertyDescriptor ReadAction0PropertyID(ByteReader *buf, uint8 feature) +static GRFFilePropertyDescriptor ReadAction0PropertyID(ByteReader *buf, uint8_t feature) { - uint8 raw_prop = buf->ReadByte(); + uint8_t raw_prop = buf->ReadByte(); const GRFFilePropertyRemapSet &remap = _cur.grffile->action0_property_remaps[feature]; if (remap.remapped_ids[raw_prop]) { auto iter = remap.mapping.find(raw_prop); @@ -5404,7 +5404,7 @@ static GRFFilePropertyDescriptor ReadAction0PropertyID(ByteReader *buf, uint8 fe } else if (prop == A0RPI_ID_EXTENSION) { byte *outer_data = buf->Data(); size_t outer_length = buf->ReadExtendedByte(); - uint16 mapped_id = buf->ReadWord(); + uint16_t mapped_id = buf->ReadWord(); byte *inner_data = buf->Data(); size_t inner_length = buf->ReadExtendedByte(); if (inner_length + (inner_data - outer_data) != outer_length) { @@ -5413,7 +5413,7 @@ static GRFFilePropertyDescriptor ReadAction0PropertyID(ByteReader *buf, uint8 fe return GRFFilePropertyDescriptor(A0RPI_UNKNOWN_IGNORE, &def); } - auto ext = _cur.grffile->action0_extended_property_remaps.find((((uint32)feature) << 16) | mapped_id); + auto ext = _cur.grffile->action0_extended_property_remaps.find((((uint32_t)feature) << 16) | mapped_id); if (ext != _cur.grffile->action0_extended_property_remaps.end()) { buf->ResetReadPosition(inner_data); const GRFFilePropertyRemapEntry &ext_def = ext->second; @@ -5484,7 +5484,7 @@ static void FeatureChangeInfo(ByteReader *buf) GrfSpecFeatureRef feature_ref = ReadFeature(buf->ReadByte()); GrfSpecFeature feature = feature_ref.id; - uint8 numprops = buf->ReadByte(); + uint8_t numprops = buf->ReadByte(); uint numinfo = buf->ReadByte(); uint engine = buf->ReadExtendedByte(); @@ -5516,7 +5516,7 @@ static void FeatureChangeInfo(ByteReader *buf) static void SafeChangeInfo(ByteReader *buf) { GrfSpecFeatureRef feature = ReadFeature(buf->ReadByte()); - uint8 numprops = buf->ReadByte(); + uint8_t numprops = buf->ReadByte(); uint numinfo = buf->ReadByte(); buf->ReadExtendedByte(); // id @@ -5531,7 +5531,7 @@ static void SafeChangeInfo(ByteReader *buf) if (desc.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)) { @@ -5557,9 +5557,9 @@ static void ReserveChangeInfo(ByteReader *buf) 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()) { GRFFilePropertyDescriptor desc = ReadAction0PropertyID(buf, feature); @@ -5611,8 +5611,8 @@ static void NewSpriteSet(ByteReader *buf) GrfSpecFeatureRef feature_ref = ReadFeature(buf->ReadByte()); GrfSpecFeature feature = feature_ref.id; - uint16 num_sets = buf->ReadByte(); - uint16 first_set = 0; + uint16_t num_sets = buf->ReadByte(); + uint16_t first_set = 0; if (num_sets == 0 && buf->HasData(3)) { /* Extended Action1 format. @@ -5620,7 +5620,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; @@ -5644,7 +5644,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. @@ -5652,14 +5652,14 @@ 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; grfmsg(3, "SkipAct1: Skipping %d sprites", _cur.skip_sprites); } -const CallbackResultSpriteGroup *NewCallbackResultSpriteGroupNoTransform(uint16 result) +const CallbackResultSpriteGroup *NewCallbackResultSpriteGroupNoTransform(uint16_t result) { const CallbackResultSpriteGroup *&ptr = _callback_result_cache[result]; if (ptr == nullptr) { @@ -5669,13 +5669,13 @@ const CallbackResultSpriteGroup *NewCallbackResultSpriteGroupNoTransform(uint16 return ptr; } -static const CallbackResultSpriteGroup *NewCallbackResultSpriteGroup(uint16 groupid) +static const CallbackResultSpriteGroup *NewCallbackResultSpriteGroup(uint16_t groupid) { - uint16 result = CallbackResultSpriteGroup::TransformResultValue(groupid, _cur.grffile->grf_version >= 8); + uint16_t result = CallbackResultSpriteGroup::TransformResultValue(groupid, _cur.grffile->grf_version >= 8); return NewCallbackResultSpriteGroupNoTransform(result); } -static const SpriteGroup *GetGroupFromGroupIDNoCBResult(uint16 setid, byte type, uint16 groupid) +static const SpriteGroup *GetGroupFromGroupIDNoCBResult(uint16_t setid, byte type, uint16_t groupid) { if ((size_t)groupid >= _cur.spritegroups.size() || _cur.spritegroups[groupid] == nullptr) { grfmsg(1, "GetGroupFromGroupID(0x%04X:0x%02X): Groupid 0x%04X does not exist, leaving empty", setid, type, groupid); @@ -5689,7 +5689,7 @@ static const SpriteGroup *GetGroupFromGroupIDNoCBResult(uint16 setid, byte type, /* Helper function to either create a callback or link to a previously * defined spritegroup. */ -static const SpriteGroup *GetGroupFromGroupID(uint16 setid, byte type, uint16 groupid) +static const SpriteGroup *GetGroupFromGroupID(uint16_t setid, byte type, uint16_t groupid) { if (HasBit(groupid, 15)) { return NewCallbackResultSpriteGroup(groupid); @@ -5698,7 +5698,7 @@ static const SpriteGroup *GetGroupFromGroupID(uint16 setid, byte type, uint16 gr return GetGroupFromGroupIDNoCBResult(setid, type, groupid); } -static const SpriteGroup *GetGroupByID(uint16 groupid) +static const SpriteGroup *GetGroupByID(uint16_t groupid) { if ((size_t)groupid >= _cur.spritegroups.size()) return nullptr; @@ -5714,7 +5714,7 @@ static const SpriteGroup *GetGroupByID(uint16 groupid) * @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, uint16 setid, byte type, uint16 spriteid) +static const SpriteGroup *CreateGroupFromGroupID(byte feature, uint16_t setid, byte type, uint16_t spriteid) { if (HasBit(spriteid, 15)) { return NewCallbackResultSpriteGroup(spriteid); @@ -5738,7 +5738,7 @@ static const SpriteGroup *CreateGroupFromGroupID(byte feature, uint16 setid, byt static void ProcessDeterministicSpriteGroupRanges(const std::vector &ranges, std::vector &ranges_out, const SpriteGroup *default_group) { /* 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); @@ -5748,7 +5748,7 @@ static void ProcessDeterministicSpriteGroupRanges(const std::vector target; for (uint j = 0; j < bounds.size(); ++j) { - uint32 v = bounds[j]; + uint32_t v = bounds[j]; const SpriteGroup *t = default_group; for (uint i = 0; i < ranges.size(); i++) { if (ranges[i].low <= v && v <= ranges[i].high) { @@ -5809,8 +5809,8 @@ static void NewSpriteGroup(ByteReader *buf) return; } - uint16 setid = HasBit(_cur.grffile->observed_feature_tests, GFTOF_MORE_ACTION2_IDS) ? buf->ReadExtendedByte() : buf->ReadByte(); - uint8 type = buf->ReadByte(); + uint16_t setid = HasBit(_cur.grffile->observed_feature_tests, GFTOF_MORE_ACTION2_IDS) ? buf->ReadExtendedByte() : 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 @@ -5883,8 +5883,8 @@ static void NewSpriteGroup(ByteReader *buf) if (stype == STYPE_DETERMINISTIC_RELATIVE) { var_scope_count = ParseRelativeScopeByte(buf->ReadByte()); } else if (stype == STYPE_DETERMINISTIC_RELATIVE_2) { - uint8 mode = buf->ReadByte(); - uint8 offset = buf->ReadByte(); + uint8_t mode = buf->ReadByte(); + uint8_t offset = buf->ReadByte(); bool invalid = false; if ((mode & 0x7F) >= VSGSRM_END) { invalid = true; @@ -6066,7 +6066,7 @@ static void NewSpriteGroup(ByteReader *buf) group->var_scope_count = ParseRelativeScopeByte(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(); @@ -6138,14 +6138,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 %u", 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()); @@ -6173,12 +6173,12 @@ static void NewSpriteGroup(ByteReader *buf) if (_action6_override_active) group->sg_flags |= SGF_ACTION6; 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); } @@ -6191,7 +6191,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(); @@ -6219,7 +6219,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++) { @@ -6300,7 +6300,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; @@ -6348,7 +6348,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 ((size_t)groupid >= _cur.spritegroups.size() || _cur.spritegroups[groupid] == nullptr) { grfmsg(1, "%s: Spritegroup 0x%04X out of range or empty, skipping.", function, groupid); @@ -6358,7 +6358,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; @@ -6399,10 +6399,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: * [%d] Cargo type 0x%X, group id 0x%02X", c, ctype, groupid); @@ -6423,7 +6423,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); @@ -6441,21 +6441,21 @@ static void VehicleMapSpriteGroup(ByteReader *buf, byte feature, uint8 idcount) } -static void CanalMapSpriteGroup(ByteReader *buf, uint8 idcount) +static void CanalMapSpriteGroup(ByteReader *buf, uint8_t idcount) { - uint16 *cfs = AllocaM(uint16, idcount); + uint16_t *cfs = AllocaM(uint16_t, idcount); for (uint i = 0; i < idcount; i++) { cfs[i] = 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 (uint i = 0; i < idcount; i++) { - uint16 cf = cfs[i]; + uint16_t cf = cfs[i]; if (cf >= CF_END) { grfmsg(1, "CanalMapSpriteGroup: Canal subset %d out of range, skipping", cf); @@ -6468,22 +6468,22 @@ 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"); return; } - uint16 *stations = AllocaM(uint16, idcount); + uint16_t *stations = AllocaM(uint16_t, idcount); for (uint i = 0; i < idcount; i++) { stations[i] = 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); @@ -6501,7 +6501,7 @@ static void StationMapSpriteGroup(ByteReader *buf, uint8 idcount) } } - uint16 groupid = buf->ReadWord(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "StationMapSpriteGroup")) return; for (uint i = 0; i < idcount; i++) { @@ -6525,23 +6525,23 @@ 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"); return; } - uint16 *houses = AllocaM(uint16, idcount); + uint16_t *houses = AllocaM(uint16_t, idcount); for (uint i = 0; i < idcount; i++) { houses[i] = buf->ReadExtendedByte(); } /* 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 (uint i = 0; i < idcount; i++) { @@ -6556,23 +6556,23 @@ 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"); return; } - uint16 *industries = AllocaM(uint16, idcount); + uint16_t *industries = AllocaM(uint16_t, idcount); for (uint i = 0; i < idcount; i++) { industries[i] = buf->ReadExtendedByte(); } /* 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 (uint i = 0; i < idcount; i++) { @@ -6587,23 +6587,23 @@ 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"); return; } - uint16 *indtiles = AllocaM(uint16, idcount); + uint16_t *indtiles = AllocaM(uint16_t, idcount); for (uint i = 0; i < idcount; i++) { indtiles[i] = buf->ReadExtendedByte(); } /* 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 (uint i = 0; i < idcount; i++) { @@ -6618,22 +6618,22 @@ static void IndustrytileMapSpriteGroup(ByteReader *buf, uint8 idcount) } } -static void CargoMapSpriteGroup(ByteReader *buf, uint8 idcount) +static void CargoMapSpriteGroup(ByteReader *buf, uint8_t idcount) { - uint16 *cargoes = AllocaM(uint16, idcount); + uint16_t *cargoes = AllocaM(uint16_t, idcount); for (uint i = 0; i < idcount; i++) { cargoes[i] = buf->ReadExtendedByte(); } /* 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 (uint i = 0; i < idcount; i++) { - uint16 cid = cargoes[i]; + uint16_t cid = cargoes[i]; if (cid >= NUM_CARGO) { grfmsg(1, "CargoMapSpriteGroup: Cargo ID %d out of range, skipping", cid); @@ -6646,22 +6646,22 @@ static void CargoMapSpriteGroup(ByteReader *buf, uint8 idcount) } } -static void SignalsMapSpriteGroup(ByteReader *buf, uint8 idcount) +static void SignalsMapSpriteGroup(ByteReader *buf, uint8_t idcount) { - uint16 *ids = AllocaM(uint16, idcount); + uint16_t *ids = AllocaM(uint16_t, idcount); for (uint i = 0; i < idcount; i++) { ids[i] = buf->ReadExtendedByte(); } /* 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, "SignalsMapSpriteGroup")) return; for (uint i = 0; i < idcount; i++) { - uint16 id = ids[i]; + uint16_t id = ids[i]; switch (id) { case NSA3ID_CUSTOM_SIGNALS: @@ -6679,22 +6679,22 @@ static void SignalsMapSpriteGroup(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"); return; } - uint16 *objects = AllocaM(uint16, idcount); + uint16_t *objects = AllocaM(uint16_t, idcount); for (uint i = 0; i < idcount; i++) { objects[i] = 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. */ @@ -6715,7 +6715,7 @@ static void ObjectMapSpriteGroup(ByteReader *buf, uint8 idcount) } } - uint16 groupid = buf->ReadWord(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "ObjectMapSpriteGroup")) return; for (uint i = 0; i < idcount; i++) { @@ -6737,18 +6737,18 @@ static void ObjectMapSpriteGroup(ByteReader *buf, uint8 idcount) } } -static void RailTypeMapSpriteGroup(ByteReader *buf, uint8 idcount) +static void RailTypeMapSpriteGroup(ByteReader *buf, uint8_t idcount) { - uint8 *railtypes = AllocaM(uint8, idcount); + uint8_t *railtypes = AllocaM(uint8_t, idcount); for (uint i = 0; i < idcount; i++) { - uint16 id = buf->ReadExtendedByte(); + uint16_t id = buf->ReadExtendedByte(); railtypes[i] = 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; @@ -6768,20 +6768,20 @@ 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; - uint8 *roadtypes = AllocaM(uint8, idcount); + uint8_t *roadtypes = AllocaM(uint8_t, idcount); for (uint i = 0; i < idcount; i++) { - uint16 id = buf->ReadExtendedByte(); + uint16_t id = buf->ReadExtendedByte(); roadtypes[i] = 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; @@ -6801,23 +6801,23 @@ 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"); return; } - uint16 *airports = AllocaM(uint16, idcount); + uint16_t *airports = AllocaM(uint16_t, idcount); for (uint i = 0; i < idcount; i++) { airports[i] = buf->ReadExtendedByte(); } /* 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 (uint i = 0; i < idcount; i++) { @@ -6832,23 +6832,23 @@ 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"); return; } - uint16 *airptiles = AllocaM(uint16, idcount); + uint16_t *airptiles = AllocaM(uint16_t, idcount); for (uint i = 0; i < idcount; i++) { airptiles[i] = buf->ReadExtendedByte(); } /* 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 (uint i = 0; i < idcount; i++) { @@ -6863,17 +6863,17 @@ static void AirportTileMapSpriteGroup(ByteReader *buf, uint8 idcount) } } -static void RoadStopMapSpriteGroup(ByteReader *buf, uint8 idcount) +static void RoadStopMapSpriteGroup(ByteReader *buf, uint8_t idcount) { - uint16 *roadstops = AllocaM(uint16, idcount); + uint16_t *roadstops = AllocaM(uint16_t, idcount); for (uint i = 0; i < idcount; i++) { roadstops[i] = 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); @@ -6891,7 +6891,7 @@ static void RoadStopMapSpriteGroup(ByteReader *buf, uint8 idcount) } } - uint16 groupid = buf->ReadWord(); + uint16_t groupid = buf->ReadWord(); if (!IsValidGroupID(groupid, "RoadStopMapSpriteGroup")) return; if (_cur.grffile->roadstops.empty()) { @@ -6919,22 +6919,22 @@ static void RoadStopMapSpriteGroup(ByteReader *buf, uint8 idcount) } } -static void NewLandscapeMapSpriteGroup(ByteReader *buf, uint8 idcount) +static void NewLandscapeMapSpriteGroup(ByteReader *buf, uint8_t idcount) { - uint16 *ids = AllocaM(uint16, idcount); + uint16_t *ids = AllocaM(uint16_t, idcount); for (uint i = 0; i < idcount; i++) { ids[i] = buf->ReadExtendedByte(); } /* 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, "NewLandscapeMapSpriteGroup")) return; for (uint i = 0; i < idcount; i++) { - uint16 id = ids[i]; + uint16_t id = ids[i]; switch (id) { case NLA3ID_CUSTOM_ROCKS: @@ -6971,7 +6971,7 @@ static void FeatureMapSpriteGroup(ByteReader *buf) GrfSpecFeatureRef feature_ref = ReadFeature(buf->ReadByte()); GrfSpecFeature feature = feature_ref.id; - uint8 idcount = buf->ReadByte(); + uint8_t idcount = buf->ReadByte(); if (feature >= GSF_END) { grfmsg(1, "FeatureMapSpriteGroup: Unsupported feature %s, skipping", GetFeatureString(feature_ref)); @@ -6982,7 +6982,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 %s", GetFeatureString(feature_ref)); @@ -7098,10 +7098,10 @@ static void FeatureNewName(ByteReader *buf) 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) { @@ -7112,7 +7112,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 %d..%d (feature %s) in language 0x%02X", id, endid, GetFeatureString(feature), lang); @@ -7193,7 +7193,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) { @@ -7252,9 +7252,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. const Action5Type *action5_type; @@ -7323,7 +7323,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. */ @@ -7341,7 +7341,7 @@ static void GraphicsNew(ByteReader *buf) /* If the baseset or grf only provides sprites for flat tiles (pre #10282), duplicate those for use on slopes. */ bool dup_oneway_sprites = ((type == 0x09) && (offset + num <= SPR_ONEWAY_SLOPE_N_OFFSET)); - for (uint16 n = num; n > 0; n--) { + for (uint16_t n = num; n > 0; n--) { _cur.nfo_line++; int load_index = (replace == 0 ? _cur.spriteid++ : replace++); LoadNextSprite(load_index, *_cur.file, _cur.nfo_line); @@ -7386,7 +7386,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) { if (_sprite_group_resolve_check_veh_check) { switch (param) { @@ -7529,16 +7529,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); @@ -7551,9 +7551,9 @@ 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_t index = *cond_val / 0x20; *cond_val %= 0x20; - uint32 param_val = 0; + uint32_t param_val = 0; if (index < lengthof(_ttdpatch_flags)) { param_val = _ttdpatch_flags[index]; if (!HasBit(_cur.grfconfig->flags, GCF_STATIC) && !HasBit(_cur.grfconfig->flags, GCF_SYSTEM)) { @@ -7595,8 +7595,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) { @@ -7655,7 +7655,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; @@ -7698,13 +7698,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. */ @@ -7803,7 +7803,7 @@ static void SkipIf(ByteReader *buf) default: grfmsg(1, "SkipIf: Unsupported GRF condition type %02X. Ignoring", condtype); return; } } else if (param == 0x91 && (condtype == 0x02 || condtype == 0x03) && cond_val > 0) { - const std::vector &values = _cur.grffile->var91_values; + const std::vector &values = _cur.grffile->var91_values; /* condtype 0x02: skip if test result found * condtype 0x03: skip if test result not found */ @@ -7811,7 +7811,7 @@ static void SkipIf(ByteReader *buf) result = (found == (condtype == 0x02)); } 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; @@ -7834,7 +7834,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 @@ -7879,9 +7879,9 @@ static void SkipIf(ByteReader *buf) /* Action 0x08 (GLS_FILESCAN) */ static void ScanInfo(ByteReader *buf) { - uint8 grf_version = buf->ReadByte(); - uint32 grfid = buf->ReadDWord(); - const char *name = buf->ReadString(); + uint8_t grf_version = buf->ReadByte(); + uint32_t grfid = buf->ReadDWord(); + const char *name = buf->ReadString(); _cur.grfconfig->ident.grfid = grfid; @@ -7914,9 +7914,9 @@ 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(); - const char *name = buf->ReadString(); + 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) { DisableGrf(STR_NEWGRF_ERROR_MULTIPLE_ACTION_8); @@ -7946,11 +7946,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 %d] Changing %d sprites, beginning with %d", i, num_sprites, first_sprite @@ -7979,7 +7979,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 */ @@ -8115,7 +8115,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; @@ -8132,7 +8132,7 @@ static void SafeParamSet(ByteReader *buf) } -static uint32 GetPatchVariable(uint8 param) +static uint32_t GetPatchVariable(uint8_t param) { switch (param) { /* start year - 1920 */ @@ -8210,7 +8210,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; @@ -8282,12 +8282,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 @@ -8312,10 +8312,10 @@ static void ParamSet(ByteReader *buf) src1 = GetPatchVariable(src1); } else { /* GRF Resource Management */ - uint8 op = src1; + uint8_t op = src1; GrfSpecFeatureRef feature_ref = ReadFeature(GB(data, 8, 8)); GrfSpecFeature feature = feature_ref.id; - uint16 count = GB(data, 16, 16); + uint16_t count = GB(data, 16, 16); if (_cur.stage == GLS_RESERVE) { if (feature == 0x08) { @@ -8417,7 +8417,7 @@ static void ParamSet(ByteReader *buf) src2 = (src2 == 0xFF) ? data : GetParamVal(src2, nullptr); } - uint32 res; + uint32_t res; switch (oper) { case 0x00: res = src1; @@ -8436,22 +8436,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; @@ -8475,7 +8475,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; @@ -8491,7 +8491,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; @@ -8535,7 +8535,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); @@ -8568,10 +8568,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) { @@ -8593,10 +8593,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 */ @@ -8618,7 +8618,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); @@ -8648,13 +8648,13 @@ static void FeatureTownName(ByteReader *buf) townname->styles.emplace_back(style, id); } - uint8 parts = buf->ReadByte(); + uint8_t parts = buf->ReadByte(); grfmsg(6, "FeatureTownName: %u 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; @@ -8708,7 +8708,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); @@ -8757,7 +8757,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; @@ -8780,7 +8780,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) { @@ -8792,7 +8792,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; @@ -8865,12 +8865,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 %u is not supported, ignoring", size); @@ -8896,7 +8896,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 */ @@ -8922,7 +8922,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)); @@ -8946,7 +8946,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%4X, number: 0x%2X)", first_id, num_strings); @@ -9122,8 +9122,8 @@ static bool ChangeGRFParamLimits(size_t len, ByteReader *buf) grfmsg(2, "StaticGRFInfo: expected 8 bytes for 'INFO'->'PARA'->'LIMI' but got " PRINTF_SIZE ", 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; @@ -9191,7 +9191,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') { @@ -9203,7 +9203,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') { @@ -9215,7 +9215,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') { @@ -9228,7 +9228,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') { @@ -9236,8 +9236,8 @@ struct AllowedSubtags { this->handler.u.subtags = subtags; } - uint32 id; ///< The identifier for this node - byte type; ///< The type of the node, must be one of 'C', 'B' or 'T'. + 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'. TextHandler text; ///< Callback function for a text node, only valid if type == 'T'. @@ -9281,7 +9281,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; @@ -9328,7 +9328,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; @@ -9368,10 +9368,10 @@ AllowedSubtags _tags_info[] = { /** Action14 feature test instance */ struct GRFFeatureTest { const GRFFeatureInfo *feature; - uint16 min_version; - uint16 max_version; - uint8 platform_var_bit; - uint32 test_91_value; + uint16_t min_version; + uint16_t max_version; + uint8_t platform_var_bit; + uint32_t test_91_value; void Reset() { @@ -9384,7 +9384,7 @@ struct GRFFeatureTest { void ExecuteTest() { - uint16 version = (this->feature != nullptr) ? this->feature->version : 0; + uint16_t version = (this->feature != nullptr) ? this->feature->version : 0; bool has_feature = (version >= this->min_version && version <= this->max_version); if (this->platform_var_bit > 0) { SB(_cur.grffile->var9D_overlay, this->platform_var_bit, 1, has_feature ? 1 : 0); @@ -9456,7 +9456,7 @@ static bool ChangeGRFFeatureSetPlatformVarBit(size_t len, ByteReader *buf) grfmsg(2, "Action 14 feature test: expected 1 byte for 'FTST'->'SETP' but got " PRINTF_SIZE ", ignoring this field", len); buf->Skip(len); } else { - uint8 bit_number = buf->ReadByte(); + uint8_t bit_number = buf->ReadByte(); if (bit_number >= 4 && bit_number <= 31) { _current_grf_feature_test.platform_var_bit = bit_number; } else { @@ -9509,10 +9509,10 @@ struct GRFPropertyMapAction { int ext_prop_id; std::string name; GRFPropertyMapFallbackMode fallback_mode; - uint8 ttd_ver_var_bit; - uint32 test_91_value; - uint8 input_shift; - uint8 output_shift; + uint8_t ttd_ver_var_bit; + uint32_t test_91_value; + uint8_t input_shift; + uint8_t output_shift; uint input_mask; uint output_mask; uint output_param; @@ -9613,7 +9613,7 @@ struct GRFPropertyMapAction { entry.property_id = this->prop_id; } if (this->ext_prop_id > 0) { - GRFFilePropertyRemapEntry &entry = _cur.grffile->action0_extended_property_remaps[(((uint32)this->feature) << 16) | this->ext_prop_id]; + GRFFilePropertyRemapEntry &entry = _cur.grffile->action0_extended_property_remaps[(((uint32_t)this->feature) << 16) | this->ext_prop_id]; entry.name = info->name; entry.id = info->id; entry.feature = this->feature; @@ -9652,7 +9652,7 @@ struct GRFPropertyMapAction { entry.property_id = this->prop_id; } if (this->ext_prop_id > 0) { - GRFFilePropertyRemapEntry &entry = _cur.grffile->action0_extended_property_remaps[(((uint32)this->feature) << 16) | this->ext_prop_id]; + GRFFilePropertyRemapEntry &entry = _cur.grffile->action0_extended_property_remaps[(((uint32_t)this->feature) << 16) | this->ext_prop_id]; entry.name = str_store; entry.id = (this->fallback_mode == GPMFM_IGNORE) ? A0RPI_UNKNOWN_IGNORE : A0RPI_UNKNOWN_ERROR;; entry.feature = this->feature; @@ -9678,7 +9678,7 @@ struct GRFPropertyMapAction { extern const GRFVariableMapDefinition _grf_action2_remappable_variables[]; for (const GRFVariableMapDefinition *info = _grf_action2_remappable_variables; info->name != nullptr; info++) { if (info->feature == this->feature && strcmp(info->name, str) == 0) { - _cur.grffile->grf_variable_remaps.push_back({ (uint16)info->id, (uint8)this->feature, this->input_shift, this->output_shift, this->input_mask, this->output_mask, this->output_param }); + _cur.grffile->grf_variable_remaps.push_back({ (uint16_t)info->id, (uint8_t)this->feature, this->input_shift, this->output_shift, this->input_mask, this->output_mask, this->output_param }); success = true; break; } @@ -9818,7 +9818,7 @@ static bool ChangePropertyRemapTypeId(size_t len, ByteReader *buf) grfmsg(2, "Action 14 %s mapping: expected 1 byte for '%s'->'TYPE' but got " PRINTF_SIZE ", ignoring this field", action.descriptor, action.tag_name, len); buf->Skip(len); } else { - uint8 prop = buf->ReadByte(); + uint8_t prop = buf->ReadByte(); if (prop < 128) { action.prop_id = prop; } else { @@ -9849,7 +9849,7 @@ static bool ChangePropertyRemapSetTTDVerVarBit(size_t len, ByteReader *buf) grfmsg(2, "Action 14 %s mapping: expected 1 byte for '%s'->'SETT' but got " PRINTF_SIZE ", ignoring this field", action.descriptor, action.tag_name, len); buf->Skip(len); } else { - uint8 bit_number = buf->ReadByte(); + uint8_t bit_number = buf->ReadByte(); if (bit_number >= 4 && bit_number <= 31) { action.ttd_ver_var_bit = bit_number; } else { @@ -9880,7 +9880,7 @@ static bool ChangePropertyRemapSetInputShift(size_t len, ByteReader *buf) grfmsg(2, "Action 14 %s mapping: expected 1 byte for '%s'->'RSFT' but got " PRINTF_SIZE ", ignoring this field", action.descriptor, action.tag_name, len); buf->Skip(len); } else { - uint8 input_shift = buf->ReadByte(); + uint8_t input_shift = buf->ReadByte(); if (input_shift < 0x20) { action.input_shift = input_shift; } else { @@ -9898,7 +9898,7 @@ static bool ChangePropertyRemapSetOutputShift(size_t len, ByteReader *buf) grfmsg(2, "Action 14 %s mapping: expected 1 byte for '%s'->'VSFT' but got " PRINTF_SIZE ", ignoring this field", action.descriptor, action.tag_name, len); buf->Skip(len); } else { - uint8 output_shift = buf->ReadByte(); + uint8_t output_shift = buf->ReadByte(); if (output_shift < 0x20) { action.output_shift = output_shift; } else { @@ -10086,7 +10086,7 @@ static bool SkipUnknownInfo(ByteReader *buf, byte type) break; case 'B': { - uint16 size = buf->ReadWord(); + uint16_t size = buf->ReadWord(); buf->Skip(size); break; } @@ -10106,7 +10106,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; @@ -10148,7 +10148,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(); } @@ -11211,7 +11211,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 { @@ -11361,7 +11361,7 @@ 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(); @@ -11370,7 +11370,7 @@ static void FinalisePriceBaseMultipliers() grf_overrides[i] = -1; 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); @@ -11386,7 +11386,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; @@ -11404,7 +11404,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; @@ -11422,7 +11422,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; @@ -11603,9 +11603,9 @@ void LoadNewGRF(uint load_index, uint num_baseset) YearMonthDay date_ymd = _cur_date_ymd; Date date = _date; DateFract date_fract = _date_fract; - uint64 tick_counter = _tick_counter; - uint8 tick_skip_counter = _tick_skip_counter; - uint64 scaled_tick_counter = _scaled_tick_counter; + uint64_t tick_counter = _tick_counter; + uint8_t tick_skip_counter = _tick_skip_counter; + uint64_t scaled_tick_counter = _scaled_tick_counter; DateTicksScaled scaled_date_ticks_offset = _scaled_date_ticks_offset; byte display_opt = _display_opt; @@ -11653,7 +11653,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 aabc168881..22df7952da 100644 --- a/src/newgrf.h +++ b/src/newgrf.h @@ -41,8 +41,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 { @@ -67,7 +67,7 @@ enum GrfMiscBit { GMB_SECOND_ROCKY_TILE_SET = 6, }; -enum GrfSpecFeature : uint8 { +enum GrfSpecFeature : uint8_t { GSF_TRAINS, GSF_ROADVEHICLES, GSF_SHIPS, @@ -104,14 +104,14 @@ enum GrfSpecFeature : uint8 { 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) {} }; enum GRFPropertyMapFallbackMode { @@ -140,14 +140,14 @@ struct GRFFeatureMapDefinition { struct GRFFeatureMapRemapEntry { const char *name = nullptr; GrfSpecFeature feature = (GrfSpecFeature)0; - uint8 raw_id = 0; + uint8_t raw_id = 0; }; struct GRFFeatureMapRemapSet { std::bitset<256> remapped_ids; - btree::btree_map mapping; + btree::btree_map mapping; - GRFFeatureMapRemapEntry &Entry(uint8 raw_id) + GRFFeatureMapRemapEntry &Entry(uint8_t raw_id) { this->remapped_ids.set(raw_id); return this->mapping[raw_id]; @@ -178,14 +178,14 @@ struct GRFFilePropertyRemapEntry { int id = 0; GrfSpecFeature feature = (GrfSpecFeature)0; bool extended = false; - uint16 property_id = 0; + uint16_t property_id = 0; }; struct GRFFilePropertyRemapSet { std::bitset<256> remapped_ids; - btree::btree_map mapping; + btree::btree_map mapping; - GRFFilePropertyRemapEntry &Entry(uint8 property) + GRFFilePropertyRemapEntry &Entry(uint8_t property) { this->remapped_ids.set(property); return this->mapping[property]; @@ -228,13 +228,13 @@ struct GRFNameOnlyVariableMapDefinition { }; struct GRFVariableMapEntry { - uint16 id = 0; - uint8 feature = 0; - uint8 input_shift = 0; - uint8 output_shift = 0; - uint32 input_mask = 0; - uint32 output_mask = 0; - uint32 output_param = 0; + uint16_t id = 0; + uint8_t feature = 0; + uint8_t input_shift = 0; + uint8_t output_shift = 0; + uint32_t input_mask = 0; + uint32_t output_mask = 0; + uint32_t output_param = 0; }; /** The type of action 5 type. */ @@ -247,8 +247,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. }; @@ -262,7 +262,7 @@ struct Action5TypeRemapDefinition { info({ A5BLOCK_INVALID, 0, 0, 0, nullptr }) {} - Action5TypeRemapDefinition(const char *type_name, Action5BlockType block_type, SpriteID sprite_base, uint16 min_sprites, uint16 max_sprites, const char *info_name) : + Action5TypeRemapDefinition(const char *type_name, Action5BlockType block_type, SpriteID sprite_base, uint16_t min_sprites, uint16_t max_sprites, const char *info_name) : name(type_name), info({ block_type, sprite_base, min_sprites, max_sprites, info_name }) {} @@ -271,15 +271,15 @@ struct Action5TypeRemapDefinition { struct Action5TypeRemapEntry { const Action5Type *info = nullptr; const char *name = nullptr; - uint8 type_id = 0; + uint8_t type_id = 0; GRFPropertyMapFallbackMode fallback_mode = GPMFM_IGNORE; }; struct Action5TypeRemapSet { std::bitset<256> remapped_ids; - btree::btree_map mapping; + btree::btree_map mapping; - Action5TypeRemapEntry &Entry(uint8 property) + Action5TypeRemapEntry &Entry(uint8_t property) { this->remapped_ids.set(property); return this->mapping[property]; @@ -326,11 +326,11 @@ struct NewSignalStyle; /** 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; @@ -343,7 +343,7 @@ struct GRFFile : ZeroedMemoryAllocator { GRFFeatureMapRemapSet feature_id_remaps; GRFFilePropertyRemapSet action0_property_remaps[GSF_END]; - btree::btree_map action0_extended_property_remaps; + btree::btree_map action0_extended_property_remaps; Action5TypeRemapSet action5_type_remaps; std::vector grf_variable_remaps; std::vector> remap_unknown_property_names; @@ -372,19 +372,19 @@ 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. - uint32 var8D_overlay; ///< Overlay for global variable 8D (action 0x14) - uint32 var9D_overlay; ///< Overlay for global variable 9D (action 0x14) - std::vector var91_values; ///< Test result values for global variable 91 (action 0x14, only testable using action 7/9) + uint32_t var8D_overlay; ///< Overlay for global variable 8D (action 0x14) + uint32_t var9D_overlay; ///< Overlay for global variable 9D (action 0x14) + std::vector var91_values; ///< Test result values for global variable 91 (action 0x14, only testable using action 7/9) - uint32 observed_feature_tests; ///< Observed feature test bits (see: GRFFeatureTestObservationFlag) + uint32_t observed_feature_tests; ///< Observed feature test bits (see: GRFFeatureTestObservationFlag) const SpriteGroup *new_signals_group; ///< New signals sprite group byte new_signal_ctrl_flags; ///< Ctrl flags for new signals byte new_signal_extra_aspects; ///< Number of extra aspects for new signals - uint16 new_signal_style_mask; ///< New signal styles usable with this GRF + uint16_t new_signal_style_mask; ///< New signal styles usable with this GRF NewSignalStyle *current_new_signal_style; ///< Current new signal style being defined by this GRF const SpriteGroup *new_rocks_group; ///< New landscape rocks group @@ -392,13 +392,13 @@ struct GRFFile : ZeroedMemoryAllocator { byte ctrl_flags; ///< General GRF control flags - btree::btree_map string_map; ///< Map of local GRF string ID to string ID + btree::btree_map string_map; ///< Map of local GRF string ID to string ID 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. */ @@ -422,7 +422,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. }; @@ -450,9 +450,9 @@ void ResetPersistentNewGRFData(); #define grfmsg(severity, ...) if ((severity) == 0 || _debug_grf_level >= (severity)) _intl_grfmsg(severity, __VA_ARGS__) void CDECL _intl_grfmsg(int severity, const char *str, ...) WARN_FORMAT(2, 3); -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(); uint CountSelectedGRFs(GRFConfig *grfconf); @@ -460,7 +460,7 @@ struct TemplateVehicle; struct GrfSpecFeatureRef { GrfSpecFeature id; - uint8 raw_byte; + uint8_t raw_byte; }; const char *GetFeatureString(GrfSpecFeatureRef feature); diff --git a/src/newgrf_airport.cpp b/src/newgrf_airport.cpp index a9ae4ede02..9af5f5390d 100644 --- a/src/newgrf_airport.cpp +++ b/src/newgrf_airport.cpp @@ -153,7 +153,7 @@ void AirportOverrideManager::SetEntitySpec(AirportSpec *as) } } -/* virtual */ uint32 AirportScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +/* virtual */ uint32_t AirportScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const { switch (variable) { case 0x40: return this->layout; @@ -180,12 +180,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; } @@ -195,7 +195,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; @@ -204,7 +204,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); } @@ -242,7 +242,7 @@ TownScopeResolver *AirportResolverObject::GetTown() * @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]; @@ -257,7 +257,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(); @@ -270,10 +270,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 b0abbc1d85..bc523705e1 100644 --- a/src/newgrf_airport.h +++ b/src/newgrf_airport.h @@ -114,7 +114,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. @@ -165,9 +165,9 @@ struct AirportScopeResolver : public ScopeResolver { { } - uint32 GetRandomBits() const override; - uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override; - void StorePSA(uint pos, int32 value) override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const override; + void StorePSA(uint pos, int32_t value) override; }; @@ -177,7 +177,7 @@ struct AirportResolverObject : public ResolverObject { std::unique_ptr town_scope; ///< The town scope resolver (created on the first call). 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); TownScopeResolver *GetTown(); @@ -196,9 +196,9 @@ struct AirportResolverObject : public ResolverObject { } GrfSpecFeature GetFeature() const override; - uint32 GetDebugID() const override; + uint32_t GetDebugID() const override; }; -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 1d5c4521bf..32c21f4534 100644 --- a/src/newgrf_airporttiles.cpp +++ b/src/newgrf_airporttiles.cpp @@ -24,7 +24,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]; @@ -108,12 +108,12 @@ 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, uint32 mask) +static uint32_t GetNearbyAirportTileInformation(byte parameter, TileIndex tile, StationID index, bool grf_version8, uint32_t mask) { 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); - uint32 result = (is_same_airport ? 1 : 0) << 8; + uint32_t result = (is_same_airport ? 1 : 0) << 8; if (mask & ~0x100) result |= GetNearbyTileInformation(tile, grf_version8, mask); return result; } @@ -127,7 +127,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; @@ -162,7 +162,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(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +/* virtual */ uint32_t AirportTileScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const { assert(this->st != nullptr); @@ -207,7 +207,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); } @@ -222,7 +222,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), airport_scope(*this, tile, st, st != nullptr ? st->airport.type : (byte)AT_DUMMY, st != nullptr ? st->airport.layout : 0) @@ -235,12 +235,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(); @@ -270,7 +270,7 @@ bool DrawNewAirportTile(TileInfo *ti, Station *st, const AirportTileSpec *airts) 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); } @@ -310,7 +310,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) @@ -322,7 +322,7 @@ void AirportAnimationTrigger(Station *st, AirpAnimationTrigger trigger, CargoID } } -uint8 GetAirportTileAnimationSpeed(TileIndex tile) +uint8_t GetAirportTileAnimationSpeed(TileIndex tile) { const AirportTileSpec *ats = AirportTileSpec::GetByTile(tile); if (ats == nullptr) return 0; diff --git a/src/newgrf_airporttiles.h b/src/newgrf_airporttiles.h index abc61814bb..7ed31d0d2f 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(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const override; }; /** Resolver for tiles of an airport. */ @@ -47,7 +47,7 @@ struct AirportTileResolverObject : public ResolverObject { AirportScopeResolver airport_scope; ///< Scope resolver for the airport owning the tile. 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, VarSpriteGroupScopeOffset relative = 0) override { @@ -59,7 +59,7 @@ struct AirportTileResolverObject : public ResolverObject { } GrfSpecFeature GetFeature() const override; - uint32 GetDebugID() const override; + uint32_t GetDebugID() const override; }; /** @@ -68,8 +68,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 @@ -87,7 +87,7 @@ private: void AnimateAirportTile(TileIndex tile); void AirportTileAnimationTrigger(Station *st, TileIndex tile, AirpAnimationTrigger trigger, CargoID cargo_type = CT_INVALID); void AirportAnimationTrigger(Station *st, AirpAnimationTrigger trigger, CargoID cargo_type = CT_INVALID); -uint8 GetAirportTileAnimationSpeed(TileIndex tile); +uint8_t GetAirportTileAnimationSpeed(TileIndex tile); bool DrawNewAirportTile(TileInfo *ti, Station *st, const AirportTileSpec *airts); #endif /* NEWGRF_AIRPORTTILES_H */ diff --git a/src/newgrf_analysis.cpp b/src/newgrf_analysis.cpp index 994446db62..4620711ebe 100644 --- a/src/newgrf_analysis.cpp +++ b/src/newgrf_analysis.cpp @@ -27,7 +27,7 @@ void DeterministicSpriteGroup::AnalyseCallbacks(AnalyseCallbackOperation &op) co auto check_1A_range = [&]() -> bool { if (this->GroupMayBeBypassed()) { /* Not clear why some GRFs do this, perhaps a way of commenting out a branch */ - uint32 value = (this->adjusts.size() == 1) ? EvaluateDeterministicSpriteGroupAdjust(this->size, this->adjusts[0], nullptr, 0, UINT_MAX) : 0; + uint32_t value = (this->adjusts.size() == 1) ? EvaluateDeterministicSpriteGroupAdjust(this->size, this->adjusts[0], nullptr, 0, UINT_MAX) : 0; for (const auto &range : this->ranges) { if (range.low <= value && value <= range.high) { if (range.group != nullptr) range.group->AnalyseCallbacks(op); @@ -46,7 +46,7 @@ void DeterministicSpriteGroup::AnalyseCallbacks(AnalyseCallbackOperation &op) co return; } else if (!(op.result_flags & ACORF_CB_RESULT_FOUND)) { if (check_1A_range()) return; - auto check_var_filter = [&](uint8 var, uint value) -> bool { + auto check_var_filter = [&](uint8_t var, uint value) -> bool { if (this->adjusts.size() == 1 && this->adjusts[0].variable == var && (this->adjusts[0].operation == DSGA_OP_ADD || this->adjusts[0].operation == DSGA_OP_RST)) { const auto &adjust = this->adjusts[0]; if (adjust.shift_num == 0 && (adjust.and_mask & 0xFF) == 0xFF && adjust.type == DSGA_TYPE_NONE) { @@ -145,7 +145,7 @@ void DeterministicSpriteGroup::AnalyseCallbacks(AnalyseCallbackOperation &op) co for (const auto &range : this->ranges) { if (range.low == range.high) { if (range.low < 64) { - if (find_cb_result(range.group, { CBID_VEHICLE_MODIFY_PROPERTY, true, (uint8)range.low })) { + if (find_cb_result(range.group, { CBID_VEHICLE_MODIFY_PROPERTY, true, (uint8_t)range.low })) { SetBit(op.properties_used, range.low); if (range.low == 0x9) { /* Speed */ @@ -218,20 +218,20 @@ void DeterministicSpriteGroup::AnalyseCallbacks(AnalyseCallbackOperation &op) co } } if (op.mode == ACOM_INDUSTRY_TILE && adjust.variable == 0x43 && adjust.type == DSGA_TYPE_NONE && this->var_scope == VSG_SCOPE_SELF) { - const uint32 effective_mask = adjust.and_mask << adjust.shift_num; + const uint32_t effective_mask = adjust.and_mask << adjust.shift_num; if (effective_mask == 0xFFFF || effective_mask == 0xFF00 || effective_mask == 0x00FF) { /* Relative position switch */ const bool use_x = effective_mask & 0xFF; const bool use_y = effective_mask & 0xFF00; - uint64 default_mask = op.data.indtile->check_mask; + uint64_t default_mask = op.data.indtile->check_mask; for (const auto &range : this->ranges) { if (range.high - range.low < 32) { - uint64 new_check_mask = 0; + uint64_t new_check_mask = 0; for (uint i = range.low; i <= range.high; i++) { const uint offset = i << adjust.shift_num; - const int16 x = offset & 0xFF; - const int16 y = (offset >> 8) & 0xFF; - for (uint bit : SetBitIterator(op.data.indtile->check_mask)) { + const int16_t x = offset & 0xFF; + const int16_t y = (offset >> 8) & 0xFF; + for (uint bit : SetBitIterator(op.data.indtile->check_mask)) { const TileIndexDiffC &ti = (*(op.data.indtile->layout))[bit].ti; if ((!use_x || ti.x == x) && (!use_y || ti.y == y)) { SetBit(new_check_mask, bit); diff --git a/src/newgrf_analysis.h b/src/newgrf_analysis.h index e5ee458190..729d3ece69 100644 --- a/src/newgrf_analysis.h +++ b/src/newgrf_analysis.h @@ -16,7 +16,7 @@ struct SpriteGroup; -enum AnalyseCallbackOperationMode : uint8 { +enum AnalyseCallbackOperationMode : uint8_t { ACOM_CB_VAR, ACOM_CB36_PROP, ACOM_FIND_CB_RESULT, @@ -28,7 +28,7 @@ enum AnalyseCallbackOperationMode : uint8 { struct AnalyseCallbackOperationIndustryTileData; -enum AnalyseCallbackOperationResultFlags : uint8 { +enum AnalyseCallbackOperationResultFlags : uint8_t { ACORF_NONE = 0, ACORF_CB_RESULT_FOUND = 1 << 0, ACORF_CB_REFIT_CAP_NON_WHITELIST_FOUND = 1 << 1, @@ -38,16 +38,16 @@ DECLARE_ENUM_AS_BIT_SET(AnalyseCallbackOperationResultFlags) struct AnalyseCallbackOperation { struct FindCBResultData { - uint16 callback; + uint16_t callback; bool check_var_10; - uint8 var_10_value; + uint8_t var_10_value; }; btree::btree_set seen; AnalyseCallbackOperationMode mode; SpriteGroupCallbacksUsed callbacks_used = SGCU_NONE; AnalyseCallbackOperationResultFlags result_flags = ACORF_NONE; - uint64 properties_used = 0; + uint64_t properties_used = 0; union { FindCBResultData cb_result; AnalyseCallbackOperationIndustryTileData *indtile; diff --git a/src/newgrf_animation_base.h b/src/newgrf_animation_base.h index 063e23e7b9..c64836baec 100644 --- a/src/newgrf_animation_base.h +++ b/src/newgrf_animation_base.h @@ -41,7 +41,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. @@ -56,9 +56,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); @@ -69,15 +69,15 @@ struct AnimationBase { * increasing this value by one doubles the wait. 0 is the minimum value * allowed for animation_speed, which corresponds to 30ms, and 16 is the * maximum, corresponding to around 33 minutes. */ - if ((((uint32)_scaled_tick_counter) & ((1 << animation_speed) - 1)) != 0) return; + if ((((uint32_t)_scaled_tick_counter) & ((1 << animation_speed) - 1)) != 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; @@ -131,9 +131,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) { @@ -157,7 +157,7 @@ struct AnimationBase { if (GB(callback, 8, 7) != 0 && _settings_client.sound.ambient) PlayTileSound(spec->grf_prop.grffile, GB(callback, 8, 7), tile); } - static uint8 GetAnimationSpeed(const Tspec *spec) + static uint8_t GetAnimationSpeed(const Tspec *spec) { if (HasBit(spec->callback_mask, Tbase::cbm_animation_speed)) return 0; return spec->animation.speed; 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 71668b67d4..b59500631e 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(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) 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, VarSpriteGroupScopeOffset 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(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +/* virtual */ uint32_t CanalScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) 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..a2d9342331 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 7df6e011ed..75e9885130 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 fa14d352e2..682f151115 100644 --- a/src/newgrf_class.h +++ b/src/newgrf_class.h @@ -36,8 +36,8 @@ private: static void InsertDefaults(); public: - uint32 global_id; ///< Global ID for class, e.g. 'DFLT', 'WAYP', etc. - StringID name; ///< Name of this class. + uint32_t global_id; ///< Global ID for class, e.g. 'DFLT', 'WAYP', etc. + StringID name; ///< Name of this class. void Insert(Tspec *spec); @@ -54,7 +54,7 @@ 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(); @@ -63,7 +63,7 @@ public: static bool IsClassIDValid(Tid cls_id); static NewGRFClass *Get(Tid cls_id); - static const Tspec *GetByGrf(uint32 grfid, uint16 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 5b391baee1..be4b686722 100644 --- a/src/newgrf_class_func.h +++ b/src/newgrf_class_func.h @@ -51,7 +51,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) { @@ -209,7 +209,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 local_id, int *index) +DEFINE_NEWGRF_CLASS_METHOD(const Tspec *)::GetByGrf(uint32_t grfid, uint16_t local_id, int *index) { uint j; @@ -234,7 +234,7 @@ DEFINE_NEWGRF_CLASS_METHOD(const Tspec *)::GetByGrf(uint32 grfid, uint16 local_i #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 bool name::IsClassIDValid(Tid cls_id); \ @@ -246,4 +246,4 @@ DEFINE_NEWGRF_CLASS_METHOD(const Tspec *)::GetByGrf(uint32 grfid, uint16 local_i 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 localidx, int *index); + template const Tspec *name::GetByGrf(uint32_t grfid, uint16_t localidx, int *index); diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp index 03fdc41a6f..59bafab3e5 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 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 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 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 grf_local_id, uint32 grfid, uint16 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 grf_local_id, uint32 grfid, uint1 * @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 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 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 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,9 +426,9 @@ 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 mask) +uint32_t GetNearbyTileInformation(TileIndex tile, bool grf_version8, uint32_t mask) { - uint32 result = 0; + uint32_t result = 0; TileType tile_type = MP_CLEAR; if (mask & 0xFF000200) { tile_type = GetTileType(tile); @@ -450,7 +450,7 @@ uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8, uint32 mask) int z; Slope tileh = GetTilePixelSlope(tile, &z); if (grf_version8) z /= TILE_HEIGHT; - result |= ClampTo(z) << 16 | tileh; + result |= ClampTo(z) << 16 | tileh; } return result; } @@ -461,7 +461,7 @@ uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8, uint32 mask) * @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); @@ -474,7 +474,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; @@ -510,7 +510,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); @@ -541,7 +541,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 @@ -560,7 +560,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 @@ -651,10 +651,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. */ @@ -662,7 +662,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) { @@ -679,7 +679,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); } @@ -695,7 +695,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); } @@ -722,7 +722,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; @@ -734,7 +734,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) { @@ -742,7 +742,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 { @@ -752,13 +752,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]); } } } @@ -767,12 +767,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 2b1cbffed1..2abb5aafe6 100644 --- a/src/newgrf_commons.h +++ b/src/newgrf_commons.h @@ -21,7 +21,7 @@ #include /** Context for tile accesses */ -enum TileContext : uint8 { +enum TileContext : uint8_t { TCX_NORMAL, ///< Nothing special. TCX_UPPER_HALFTILE, ///< Querying information about the upper part of a tile with halftile foundation. TCX_ON_BRIDGE, ///< Querying information about stuff on the bridge (via some bridgehead). @@ -89,18 +89,18 @@ inline uint GetConstructionStageOffset(uint construction_stage, uint num_sprites * Additional modifiers for items in sprite layouts. */ 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) + TileLayoutFlags flags; ///< Flags defining which members are valid and to be used. + 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. @@ -152,8 +152,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. @@ -184,47 +184,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 - uint16 entity_id; ///< The entity ID within the GRF file - uint16 substitute_id; ///< The (original) entity ID to use if this GRF is not available + 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 local_id, uint32 grfid, uint entity_type); - virtual uint16 AddEntityID(uint16 grf_local_id, uint32 grfid, uint16 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 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); @@ -234,11 +234,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 grf_local_id, uint32 grfid, uint16 substitute_id) override; - uint16 GetID(uint16 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); }; @@ -249,7 +249,7 @@ class IndustryTileOverrideManager : public OverrideManagerBase { protected: bool CheckValidNewID(uint16_t testid) override { 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); @@ -258,7 +258,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); @@ -269,7 +269,7 @@ class AirportTileOverrideManager : public OverrideManagerBase { protected: 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); @@ -280,7 +280,7 @@ class ObjectOverrideManager : public OverrideManagerBase { protected: 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); @@ -293,15 +293,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 mask); -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 mask); +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. @@ -316,7 +316,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 }; @@ -324,16 +324,16 @@ 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 }; -enum SpriteGroupCallbacksUsed : uint8 { +enum SpriteGroupCallbacksUsed : uint8_t { SGCU_NONE = 0, SGCU_ALL = 0xF, SGCU_VEHICLE_32DAY_CALLBACK = 1 << 0, @@ -344,7 +344,7 @@ enum SpriteGroupCallbacksUsed : uint8 { }; DECLARE_ENUM_AS_BIT_SET(SpriteGroupCallbacksUsed) -enum CustomSignalSpriteContext : uint8 { +enum CustomSignalSpriteContext : uint8_t { CSSC_GUI = 0, CSSC_TRACK, CSSC_TUNNEL_BRIDGE_ENTRANCE, diff --git a/src/newgrf_config.cpp b/src/newgrf_config.cpp index 72b21d07ac..5b7fc4c7cf 100644 --- a/src/newgrf_config.cpp +++ b/src/newgrf_config.cpp @@ -204,7 +204,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]; @@ -216,7 +216,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) { @@ -234,7 +234,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; @@ -246,7 +246,7 @@ void GRFParameterInfo::Finalize() * Update the palettes of the graphics from the config file. * Called when changing the default palette in advanced settings. */ -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(); @@ -300,7 +300,7 @@ static const uint GRF_MD5_PENDING_MAX = 8; static void CalcGRFMD5SumFromState(const GRFMD5SumState &state) { Md5 checksum; - uint8 buffer[1024]; + uint8_t buffer[1024]; size_t len; size_t size = state.size; while ((len = fread(buffer, 1, (size > sizeof(buffer)) ? sizeof(buffer) : size, state.f)) != 0 && size != 0) { @@ -788,7 +788,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; @@ -814,7 +814,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 39927fc2c5..230be99c04 100644 --- a/src/newgrf_config.h +++ b/src/newgrf_config.h @@ -86,13 +86,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; @@ -102,7 +102,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; @@ -134,17 +134,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 btree::btree_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(); }; @@ -165,15 +165,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 @@ -226,8 +226,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); @@ -242,6 +242,6 @@ void ShowNewGRFSettings(bool editable, bool show_params, bool exec_changes, GRFC void OpenGRFParameterWindow(bool is_baseset, GRFConfig *c, bool editable); 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 2b134654cd..2403cb8c11 100644 --- a/src/newgrf_debug.h +++ b/src/newgrf_debug.h @@ -32,7 +32,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 112cae666e..aed91408cd 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -108,12 +108,12 @@ struct NICallback { ptrdiff_t offset; ///< Offset of the variable in the class 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; -enum NIVariableFlags : uint16 { +enum NIVariableFlags : uint16_t { NIVF_NONE = 0, NIVF_SHOW_PARAMS = 1 << 0, }; @@ -122,14 +122,14 @@ DECLARE_ENUM_AS_BIT_SET(NIVariableFlags) /** Representation on the NewGRF variables. */ struct NIVariable { const char *name; - uint16 var; + uint16_t var; NIVariableFlags flags; }; struct NIExtraInfoOutput { std::function print; std::function register_next_line_click_flag_toggle; - uint32 flags; + uint32_t flags; }; /** Helper class to wrap some functionality/queries in. */ @@ -177,7 +177,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. @@ -204,7 +204,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; } @@ -215,12 +215,12 @@ 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; } - virtual std::vector GetPSAGRFIDs(uint index) const + virtual std::vector GetPSAGRFIDs(uint index) const { return {}; } @@ -240,7 +240,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); @@ -253,7 +253,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); @@ -309,16 +309,16 @@ static inline const NIHelper *GetFeatureHelper(uint window_number) /** Window used for inspecting NewGRFs. */ struct NewGRFInspectWindow : Window { /** The value for the variable 60 parameters. */ - btree::btree_map var60params; + btree::btree_map var60params; /** 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; /** The currently edited parameter, to update the right one. */ - uint16 current_edit_param; + uint16_t current_edit_param; Scrollbar *vscroll; @@ -334,15 +334,15 @@ struct NewGRFInspectWindow : Window { bool sprite_dump_more_details = false; bool show_dropdown = false; - uint32 extra_info_flags = 0; + uint32_t extra_info_flags = 0; btree::btree_map extra_info_click_flag_toggles; btree::btree_map sprite_group_lines; - btree::btree_map nfo_line_lines; + btree::btree_map nfo_line_lines; const SpriteGroup *selected_sprite_group = nullptr; - btree::btree_map highlight_tag_lines; + btree::btree_map highlight_tag_lines; btree::btree_set collapsed_groups; - std::array selected_highlight_tags = {}; + std::array selected_highlight_tags = {}; std::array marked_groups = {}; enum DropDownOptions { @@ -367,7 +367,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(); @@ -594,16 +594,16 @@ struct NewGRFInspectWindow : Window { const SpriteGroup *collapse_group = nullptr; uint collapse_lines = 0; char tmp_buf[256]; - SpriteGroupDumper dumper([&](const SpriteGroup *group, DumpSpriteGroupPrintOp operation, uint32 highlight_tag, const char *buf) { + SpriteGroupDumper dumper([&](const SpriteGroup *group, DumpSpriteGroupPrintOp operation, uint32_t highlight_tag, const char *buf) { if (this->log_console && operation == DSGPO_PRINT) DEBUG(misc, 0, " %s", buf); if (operation == DSGPO_NFO_LINE) { - btree::btree_map &lines = const_cast(this)->nfo_line_lines; + btree::btree_map &lines = const_cast(this)->nfo_line_lines; auto iter = lines.lower_bound(highlight_tag); if (iter != lines.end() && iter->first == (int)highlight_tag) { /* Already stored, don't insert again */ } else { - lines.insert(iter, std::make_pair(highlight_tag, ClampTo(i))); + lines.insert(iter, std::make_pair(highlight_tag, ClampTo(i))); } } @@ -647,7 +647,7 @@ struct NewGRFInspectWindow : Window { if (group != nullptr) { for (uint i = 0; i < lengthof(this->marked_groups); i++) { if (this->marked_groups[i] == group) { - static const uint8 mark_colours[] = { PC_YELLOW, PC_GREEN, PC_ORANGE, PC_DARK_BLUE, PC_RED, PC_LIGHT_BLUE, 0xAE /* purple */, 0x6C /* brown */ }; + static const uint8_t mark_colours[] = { PC_YELLOW, PC_GREEN, PC_ORANGE, PC_DARK_BLUE, PC_RED, PC_LIGHT_BLUE, 0xAE /* purple */, 0x6C /* brown */ }; static_assert(lengthof(this->marked_groups) == lengthof(mark_colours)); Rect mark_ir = ir.Indent(WidgetDimensions::scaled.hsep_normal, rtl).WithWidth(WidgetDimensions::scaled.hsep_normal, rtl).Translate(0, (scroll_offset * this->resize.step_height)); GfxFillRect(mark_ir.left, mark_ir.top, mark_ir.right, mark_ir.top + this->resize.step_height - 1, mark_colours[i]); @@ -673,7 +673,7 @@ struct NewGRFInspectWindow : Window { if (nih->ShowExtraInfoOnly(index)) return; - uint32 grfid = nih->GetGRFID(index); + uint32_t grfid = nih->GetGRFID(index); if (grfid) { this->DrawString(r, i++, "GRF:"); this->DrawString(r, i++, " ID: %08X", BSWAP32(grfid)); @@ -754,10 +754,10 @@ struct NewGRFInspectWindow : Window { } } - std::vector psa_grfids = nih->GetPSAGRFIDs(index); - for (const uint32 grfid : psa_grfids) { + std::vector psa_grfids = nih->GetPSAGRFIDs(index); + for (const uint32_t grfid : psa_grfids) { uint psa_size = nih->GetPSASize(index, grfid); - const int32 *psa = nih->GetPSAFirstPosition(index, grfid); + const int32_t *psa = nih->GetPSAFirstPosition(index, grfid); if (psa_size != 0 && psa != nullptr) { if (nih->PSAWithParameter()) { this->DrawString(r, i++, "Persistent storage [%08X]:", BSWAP32(grfid)); @@ -785,9 +785,9 @@ struct NewGRFInspectWindow : Window { const void *ptr = (const byte *)base + nip->offset; 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(); } @@ -817,9 +817,9 @@ struct NewGRFInspectWindow : Window { const void *ptr = (const byte *)base_spec + nic->offset; 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(); } @@ -864,7 +864,7 @@ struct NewGRFInspectWindow : Window { items[items.size() - 1] = value; } - void SelectHighlightTag(uint32 tag) + void SelectHighlightTag(uint32_t tag) { this->SelectTagArrayItem(this->selected_highlight_tags, tag); } @@ -909,7 +909,7 @@ struct NewGRFInspectWindow : Window { if (this->sprite_dump) { if (_ctrl_pressed) { - uint32 highlight_tag = 0; + uint32_t highlight_tag = 0; auto iter = this->highlight_tag_lines.find(line); if (iter != this->highlight_tag_lines.end()) highlight_tag = iter->second; if (highlight_tag != 0) { @@ -1250,7 +1250,7 @@ static WindowDesc _newgrf_inspect_desc(__FILE__, __LINE__, * @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 (index >= (1 << 27)) return; if (!IsNewGRFInspectable(feature, index)) return; @@ -1385,7 +1385,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 970d3badcc..2d3b352463 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -143,7 +143,7 @@ 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: @@ -311,12 +311,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 { if (this->v == nullptr) { return 0; @@ -336,7 +336,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, 8); + int32_t count = GB(relative, 0, 8); if (this->self_scope.v != nullptr && (relative != this->cached_relative_count || HasBit(relative, 15))) { /* Note: This caching only works as long as the VSG_SCOPE_RELATIVE cannot be used in * VarAct2 with procedure calls. */ @@ -409,7 +409,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; @@ -428,7 +428,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, uint16 variable, uint32 parameter, GetVariableExtra *extra) +static uint32_t VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, uint16_t variable, uint32_t parameter, GetVariableExtra *extra) { if (_sprite_group_resolve_check_veh_check) { switch (variable) { @@ -627,7 +627,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; @@ -646,7 +646,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)); @@ -768,7 +768,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) { @@ -794,14 +794,14 @@ 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; _sprite_group_resolve_check_veh_curvature_check = false; /* 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; @@ -846,7 +846,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); @@ -1099,7 +1099,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, return UINT_MAX; } -/* virtual */ uint32 VehicleScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +/* virtual */ uint32_t VehicleScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const { if (this->v == nullptr) { /* Vehicle does not exist, so we're in a purchase list */ @@ -1119,8 +1119,8 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object, case 0x48: return Engine::Get(this->self_type)->flags; // Vehicle Type Info case 0x49: return _cur_year; // 'Long' format build year case 0x4B: return _date.base(); // Long date of last service - case 0x92: return ClampTo(_date - DAYS_TILL_ORIGINAL_BASE_YEAR); // Date of last service - case 0x93: return GB(ClampTo(_date - DAYS_TILL_ORIGINAL_BASE_YEAR), 8, 8); + case 0x92: return ClampTo(_date - DAYS_TILL_ORIGINAL_BASE_YEAR); // Date of last service + case 0x93: return GB(ClampTo(_date - DAYS_TILL_ORIGINAL_BASE_YEAR), 8, 8); case 0xC4: return Clamp(_cur_year, ORIGINAL_BASE_YEAR, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR; // Build year case 0xC6: return Engine::Get(this->self_type)->grf_prop.local_id; case 0xC7: return GB(Engine::Get(this->self_type)->grf_prop.local_id, 8, 8); @@ -1152,7 +1152,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]; @@ -1169,7 +1169,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; } @@ -1196,7 +1196,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), @@ -1241,7 +1241,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 @@ -1275,7 +1275,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 @@ -1306,7 +1306,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(); @@ -1322,7 +1322,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); @@ -1349,11 +1349,11 @@ int GetEngineProperty(EngineID engine, PropertyID property, int orig_value, cons if (!HasBit(iter->second, property)) return orig_value; } } - uint16 callback = object.ResolveCallback(); + uint16_t callback = object.ResolveCallback(); 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; } @@ -1377,12 +1377,12 @@ bool TestVehicleBuildProbability(Vehicle *v, EngineID engine, BuildProbabilityTy return p + RandomRange(PROBABILITY_RANGE) >= PROBABILITY_RANGE; } -static void DoTriggerVehicle(Vehicle *v, VehicleTrigger trigger, uint16 base_random_bits, bool first) +static void DoTriggerVehicle(Vehicle *v, VehicleTrigger trigger, uint16_t base_random_bits, bool first) { /* We can't trigger a non-existent vehicle... */ assert(v != nullptr); - uint32 reseed = 0; + uint32_t reseed = 0; if (Engine::Get(v->engine_type)->callbacks_used & SGCU_RANDOM_TRIGGER) { VehicleResolverObject object(v->engine_type, v, VehicleResolverObject::WO_CACHED, false, CBID_RANDOM_TRIGGER); object.waiting_triggers = v->waiting_triggers | trigger; @@ -1592,15 +1592,15 @@ void FillNewGRFVehicleCache(const Vehicle *v) void AnalyseEngineCallbacks() { - btree::btree_map sg_cb36; - btree::btree_map cb_refit_cap_values; + btree::btree_map sg_cb36; + btree::btree_map cb_refit_cap_values; for (Engine *e : Engine::Iterate()) { sg_cb36.clear(); e->sprite_group_cb36_properties_used.clear(); e->refit_capacity_values.reset(); SpriteGroupCallbacksUsed callbacks_used = SGCU_NONE; - uint64 cb36_properties_used = 0; + uint64_t cb36_properties_used = 0; bool refit_cap_whitelist_ok = true; bool refit_cap_no_var_47 = true; uint non_purchase_groups = 0; diff --git a/src/newgrf_engine.h b/src/newgrf_engine.h index 5cf0104c19..6bd33f603a 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(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override; - uint32 GetTriggers() const override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const override; + uint32_t GetTriggers() const override; }; /** Resolver for a vehicle (chain) */ @@ -60,14 +60,14 @@ struct VehicleResolverObject : public ResolverObject { VarSpriteGroupScopeOffset 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, VarSpriteGroupScopeOffset 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 @@ -125,7 +125,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_extension.h b/src/newgrf_extension.h index 98016e23bf..c9b6c1475d 100644 --- a/src/newgrf_extension.h +++ b/src/newgrf_extension.h @@ -104,7 +104,7 @@ enum Action2VariableRemapIds { A2VRI_TOWNS_XY, }; -enum GRFFeatureTestObservationFlag : uint8 { +enum GRFFeatureTestObservationFlag : uint8_t { GFTOF_MORE_ACTION2_IDS = 0, GFTOF_TOWN_ZONE_CALLBACK, GFTOF_MORE_VARACTION2_TYPES, @@ -117,7 +117,7 @@ enum GRFFeatureTestObservationFlag : uint8 { /** Action14 feature definition */ struct GRFFeatureInfo { const char *name; // nullptr indicates the end of the list - uint16 version; + uint16_t version; GRFFeatureTestObservationFlag observation_flag; /** Create empty object used to identify the end of a list. */ @@ -127,7 +127,7 @@ struct GRFFeatureInfo { observation_flag(GFTOF_INVALID) {} - GRFFeatureInfo(const char *name, uint16 version, GRFFeatureTestObservationFlag observation_flag = GFTOF_INVALID) : + GRFFeatureInfo(const char *name, uint16_t version, GRFFeatureTestObservationFlag observation_flag = GFTOF_INVALID) : name(name), version(version), observation_flag(observation_flag) diff --git a/src/newgrf_generic.cpp b/src/newgrf_generic.cpp index 0e4b5fad4a..1caffc7273 100644 --- a/src/newgrf_generic.cpp +++ b/src/newgrf_generic.cpp @@ -24,15 +24,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. @@ -45,7 +45,7 @@ struct GenericScopeResolver : public ScopeResolver { { } - uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override; + uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const override; private: bool ai_callback; ///< Callback comes from the AI. @@ -71,7 +71,7 @@ struct GenericResolverObject : public ResolverObject { return (GrfSpecFeature)this->generic_scope.feature; } - uint32 GetDebugID() const override + uint32_t GetDebugID() const override { return 0; } @@ -97,7 +97,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(); } } @@ -121,7 +121,7 @@ void AddGenericCallback(GrfSpecFeature feature, const GRFFile *file, const Sprit _gcl[feature].push_back(GenericCallback(file, group)); } -/* virtual */ uint32 GenericScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +/* virtual */ uint32_t GenericScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const { if (this->ai_callback) { switch (variable) { @@ -167,7 +167,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)); @@ -177,7 +177,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 */ @@ -206,7 +206,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(GrfSpecFeature 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(GrfSpecFeature 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); @@ -232,7 +232,7 @@ uint16 GetAiPurchaseCallbackResult(GrfSpecFeature feature, CargoID cargo_type, u 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; } @@ -247,35 +247,35 @@ void AmbientSoundEffectCallback(TileIndex tile) assert_tile(IsTileType(tile, MP_CLEAR) || IsTileType(tile, MP_TREES) || IsTileType(tile, MP_WATER), tile); /* 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); } -uint16 GetTownZonesCallback(Town *t) +uint16_t GetTownZonesCallback(Town *t) { TownResolverObject object(nullptr, t, true); object.callback = XCBID_TOWN_ZONES; - const uint16 MAX_RETURN_VERSION = 0; + const uint16_t MAX_RETURN_VERSION = 0; for (GenericCallbackList::const_reverse_iterator it = _gcl[GSF_FAKE_TOWNS].rbegin(); it != _gcl[GSF_FAKE_TOWNS].rend(); ++it) { if (!HasBit(it->file->observed_feature_tests, GFTOF_TOWN_ZONE_CALLBACK)) continue; object.grffile = it->file; object.root_spritegroup = it->group; - uint16 result = object.ResolveCallback(); + uint16_t result = object.ResolveCallback(); if (result == CALLBACK_FAILED || result > MAX_RETURN_VERSION) continue; return result; diff --git a/src/newgrf_generic.h b/src/newgrf_generic.h index 5d00826398..25baa9419b 100644 --- a/src/newgrf_generic.h +++ b/src/newgrf_generic.h @@ -47,9 +47,9 @@ static const IndustryType IT_AI_TOWN = 0xFF; ///< The AI actually wants to tr void ResetGenericCallbacks(); void AddGenericCallback(GrfSpecFeature feature, const GRFFile *file, const SpriteGroup *group); -uint16 GetAiPurchaseCallbackResult(GrfSpecFeature 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(GrfSpecFeature 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); -uint16 GetTownZonesCallback(Town *t); +uint16_t GetTownZonesCallback(Town *t); /** Play an ambient sound effect for an empty tile. */ inline void AmbientSoundEffect(TileIndex tile) diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 4076fb3dce..0283aa2bd9 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -295,7 +295,7 @@ struct NewGRFParametersWindow : public Window { int text_y_offset = (this->line_height - GetCharacterHeight(FS_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) { @@ -382,7 +382,7 @@ struct NewGRFParametersWindow : public Window { GRFParameterInfo &par_info = this->GetParameterInfo(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 */ @@ -404,7 +404,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.push_back(std::make_unique(GetGRFStringFromGRFText(par_info.value_names.find(i)->second), i, false)); } @@ -412,7 +412,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 { @@ -457,9 +457,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(); } @@ -592,7 +592,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. @@ -602,7 +602,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; } @@ -1348,7 +1348,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; @@ -1365,7 +1365,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 98c410a550..44da8a5849 100644 --- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -28,7 +28,7 @@ #include "table/strings.h" -static BuildingCounts _building_counts; +static BuildingCounts _building_counts; static std::array _class_mapping; HouseOverrideManager _house_mngr(NEW_HOUSE_OFFSET, NUM_HOUSES, INVALID_HOUSE_ID); @@ -57,8 +57,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. @@ -71,7 +71,7 @@ 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; } @@ -87,7 +87,7 @@ uint32 HouseResolverObject::GetDebugID() const * @param watched_cargo_triggers Cargo types that triggered the watched cargo callback. */ FakeHouseResolverObject::FakeHouseResolverObject(HouseID house_id, - CallbackID callback, uint32 param1, uint32 param2) + CallbackID callback, uint32_t param1, uint32_t param2) : ResolverObject(GetHouseSpecGrf(house_id), callback, param1, param2), house_scope(*this, house_id), town_scope(*this) // Don't access StorePSA if house is not yet constructed. @@ -100,7 +100,7 @@ GrfSpecFeature FakeHouseResolverObject::GetFeature() const return GSF_HOUSES; } -uint32 FakeHouseResolverObject::GetDebugID() const +uint32_t FakeHouseResolverObject::GetDebugID() const { return HouseSpec::Get(this->house_scope.house_id)->grf_prop.local_id; } @@ -110,7 +110,7 @@ void ResetHouseClassIDs() _class_mapping = {}; } -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++) { @@ -174,21 +174,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_tile(IsValidTile(this->tile) && (this->not_yet_constructed || IsTileType(this->tile, MP_HOUSE)), this->tile); 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_tile(IsValidTile(this->tile) && (this->not_yet_constructed || IsTileType(this->tile, MP_HOUSE)), this->tile); 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; @@ -207,7 +207,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, uint32 mask) +static uint32_t GetNearbyTileInformation(byte parameter, TileIndex tile, bool grf_version8, uint32_t mask) { tile = GetNearbyTile(parameter, tile); return GetNearbyTileInformation(tile, grf_version8, mask); @@ -300,7 +300,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, @@ -308,8 +308,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 @@ -327,7 +327,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(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +/* virtual */ uint32_t HouseScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const { switch (variable) { /* Construction stage. */ @@ -381,15 +381,15 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI if (cid == CT_INVALID) 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 = TILE_MASK(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); @@ -451,7 +451,7 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI /** * @note Used by the resolver to get values for feature 07 deterministic spritegroups. */ -/* virtual */ uint32 FakeHouseScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +/* virtual */ uint32_t FakeHouseScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const { switch (variable) { /* Construction stage. */ @@ -509,8 +509,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) { if (tile != INVALID_TILE) { HouseResolverObject object(house_id, tile, town, callback, param1, param2, @@ -534,7 +534,7 @@ StringID GetHouseName(HouseID house_id, TileIndex tile) bool house_completed = (tile == INVALID_TILE) || IsHouseCompleted(tile); Town *t = (tile == INVALID_TILE) ? nullptr : Town::GetByTile(tile); - uint16 callback_res = GetHouseCallback(CBID_HOUSE_CUSTOM_NAME, house_completed ? 1 : 0, 0, house_id, t, tile); + uint16_t callback_res = GetHouseCallback(CBID_HOUSE_CUSTOM_NAME, house_completed ? 1 : 0, 0, house_id, t, 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); @@ -552,7 +552,7 @@ static inline PaletteID GetHouseColour(HouseID house_id, TileIndex tile = INVALI const HouseSpec *hs = HouseSpec::Get(house_id); if (HasBit(hs->callback_mask, CBM_HOUSE_COLOUR)) { Town *t = (tile != INVALID_TILE) ? Town::GetByTile(tile) : nullptr; - uint16 callback = GetHouseCallback(CBID_HOUSE_COLOUR, 0, 0, house_id, t, tile); + uint16_t callback = GetHouseCallback(CBID_HOUSE_COLOUR, 0, 0, house_id, t, tile); if (callback != CALLBACK_FAILED) { /* If bit 14 is set, we should use a 2cc colour map, else use the callback value. */ return HasBit(callback, 14) ? GB(callback, 0, 8) + SPR_2CCMAP_BASE : callback; @@ -608,7 +608,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); } @@ -636,7 +636,7 @@ void DrawNewHouseTileInGUI(int x, int y, HouseID house_id, bool ground) } /* 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); } @@ -667,7 +667,7 @@ void AnimateNewHouseConstruction(TileIndex tile) } } -uint8 GetNewHouseTileAnimationSpeed(TileIndex tile) +uint8_t GetNewHouseTileAnimationSpeed(TileIndex tile) { const HouseSpec *hs = HouseSpec::Get(GetHouseType(tile)); if (hs == nullptr) return 0; @@ -687,7 +687,7 @@ bool HouseAllowsConstruction(HouseID house_id, TileIndex tile, Town *t, byte ran { const HouseSpec *hs = HouseSpec::Get(house_id); if (HasBit(hs->callback_mask, CBM_HOUSE_ALLOW_CONSTRUCTION)) { - uint16 callback_res = GetHouseCallback(CBID_HOUSE_ALLOW_CONSTRUCTION, 0, 0, house_id, t, tile, true, random_bits); + uint16_t callback_res = GetHouseCallback(CBID_HOUSE_ALLOW_CONSTRUCTION, 0, 0, house_id, t, tile, true, random_bits); if (callback_res != CALLBACK_FAILED && !Convert8bitBooleanCallback(hs->grf_prop.grffile, CBID_HOUSE_ALLOW_CONSTRUCTION, callback_res)) { return false; } @@ -706,19 +706,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); } } @@ -745,7 +745,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); @@ -759,7 +759,7 @@ bool NewHouseTileLoop(TileIndex tile) /* Check callback 21, which determines if a house should be destroyed. */ if (HasBit(hs->callback_mask, CBM_HOUSE_DESTRUCTION)) { Town *t = Town::GetByTile(tile); - uint16 callback_res = GetHouseCallback(CBID_HOUSE_DESTRUCTION, 0, 0, GetHouseType(tile), t, tile); + uint16_t callback_res = GetHouseCallback(CBID_HOUSE_DESTRUCTION, 0, 0, GetHouseType(tile), t, tile); if (callback_res != CALLBACK_FAILED && Convert8bitBooleanCallback(hs->grf_prop.grffile, CBID_HOUSE_DESTRUCTION, callback_res)) { ClearTownHouse(t, tile); return false; @@ -794,7 +794,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); @@ -830,10 +830,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); } @@ -854,7 +854,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 73858e1ebc..960c8d3414 100644 --- a/src/newgrf_house.h +++ b/src/newgrf_house.h @@ -26,10 +26,10 @@ struct CommonHouseScopeResolver : public ScopeResolver { /** Scope resolver for houses. */ struct HouseScopeResolver : public CommonHouseScopeResolver { - 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. + TileIndex tile; ///< Tile of this house. + Town *town; ///< Town of this house. + bool not_yet_constructed; ///< True for construction check. + uint16_t initial_random_bits; ///< Random bits during construction checks. CargoTypes watched_cargo_triggers; ///< Cargo types that triggered the watched cargo callback. /** @@ -43,15 +43,15 @@ struct HouseScopeResolver : public CommonHouseScopeResolver { * @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) : CommonHouseScopeResolver(ro, 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(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override; - uint32 GetTriggers() const override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const override; + uint32_t GetTriggers() const override; }; /** @@ -70,7 +70,7 @@ struct FakeHouseScopeResolver : public CommonHouseScopeResolver { : CommonHouseScopeResolver(ro, house_id) { } - /* virtual */ uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override; + /* virtual */ uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const override; }; /** Resolver object to be used for houses (feature 07 spritegroups). */ @@ -79,8 +79,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, VarSpriteGroupScopeOffset relative = 0) override { @@ -92,7 +92,7 @@ struct HouseResolverObject : public ResolverObject { } GrfSpecFeature GetFeature() const override; - uint32 GetDebugID() const override; + uint32_t GetDebugID() const override; }; /** Resolver object to be used for fake houses (feature 07 spritegroups). */ @@ -101,7 +101,7 @@ struct FakeHouseResolverObject : public ResolverObject { FakeTownScopeResolver town_scope; FakeHouseResolverObject(HouseID house_id, - CallbackID callback = CBID_NO_CALLBACK, uint32 param1 = 0, uint32 param2 = 0); + CallbackID callback = CBID_NO_CALLBACK, uint32_t param1 = 0, uint32_t param2 = 0); ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, VarSpriteGroupScopeOffset relative = 0) override { @@ -113,7 +113,7 @@ struct FakeHouseResolverObject : public ResolverObject { } GrfSpecFeature GetFeature() const override; - uint32 GetDebugID() const override; + uint32_t GetDebugID() const override; }; /** @@ -130,12 +130,12 @@ struct FakeHouseResolverObject : 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 }; void ResetHouseClassIDs(); -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); @@ -145,10 +145,10 @@ void DrawNewHouseTile(TileInfo *ti, HouseID house_id); void DrawNewHouseTileInGUI(int x, int y, HouseID house_id, bool ground); void AnimateNewHouseTile(TileIndex tile); void AnimateNewHouseConstruction(TileIndex tile); -uint8 GetNewHouseTileAnimationSpeed(TileIndex tile); +uint8_t GetNewHouseTileAnimationSpeed(TileIndex tile); -uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town = nullptr, TileIndex tile = INVALID_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 = nullptr, TileIndex tile = INVALID_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 HouseAllowsConstruction(HouseID house_id, TileIndex tile, Town *t, byte random_bits); diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 24de0e97f1..c35f14c4c9 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -36,7 +36,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); @@ -52,7 +52,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 */ @@ -88,7 +88,7 @@ uint32 GetIndustryIDAtOffset(TileIndex tile, const Industry *i, uint32 cur_grfid return 0xFF << 8 | indtsp->grf_prop.subst_id; // so just give it the substitute } -uint32 IndustriesScopeResolver::GetClosestIndustry(IndustryType type) const +uint32_t IndustriesScopeResolver::GetClosestIndustry(IndustryType type) const { if (type >= NUM_INDUSTRYTYPES) return UINT32_MAX; @@ -99,7 +99,7 @@ uint32 IndustriesScopeResolver::GetClosestIndustry(IndustryType type) const if (i == this->industry || i->type >= NUM_INDUSTRYTYPES) continue; uint dist = DistanceManhattan(this->tile, i->location.tile); - if (dist < (uint)this->location_distance_cache->distances[i->type]) this->location_distance_cache->distances[i->type] = (uint16)dist; + if (dist < (uint)this->location_distance_cache->distances[i->type]) this->location_distance_cache->distances[i->type] = (uint16_t)dist; } } return this->location_distance_cache->distances[type]; @@ -114,11 +114,11 @@ uint32 IndustriesScopeResolver::GetClosestIndustry(IndustryType type) const * @param town_filter Do we filter on the same town as the current industry? * @return the formatted answer to the callback : rr(reserved) cc(count) dddd(manhattan distance of closest sister) */ -uint32 IndustriesScopeResolver::GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout_filter, bool town_filter, uint32 mask) const +uint32_t IndustriesScopeResolver::GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout_filter, bool town_filter, uint32_t mask) const { - 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; uint count = 0; /* Determine what will be the industry type to look for */ @@ -156,8 +156,8 @@ uint32 IndustriesScopeResolver::GetCountAndDistanceOfClosestInstance(byte param_ if (i == this->industry || i->type >= NUM_INDUSTRYTYPES || i->town != this->industry->town) continue; uint dist = DistanceManhattan(this->tile, i->location.tile); - if (dist < (uint)cache->distances[i->type]) cache->distances[i->type] = (uint16)dist; - cache->counts[i->type] = ClampTo(cache->counts[i->type] + 1); + if (dist < (uint)cache->distances[i->type]) cache->distances[i->type] = (uint16_t)dist; + cache->counts[i->type] = ClampTo(cache->counts[i->type] + 1); } } closest_dist = cache->distances[ind_index]; @@ -177,7 +177,7 @@ uint32 IndustriesScopeResolver::GetCountAndDistanceOfClosestInstance(byte param_ return count << 16 | std::min(closest_dist, 0xFFFF); } -/* virtual */ uint32 IndustriesScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +/* virtual */ uint32_t IndustriesScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const { if (this->ro.callback == CBID_INDUSTRY_LOCATION) { /* Variables available during construction check. */ @@ -236,13 +236,13 @@ uint32 IndustriesScopeResolver::GetCountAndDistanceOfClosestInstance(byte param_ 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->incoming_cargo_waiting[variable - 0x40] / this->industry->prod_level); + return ClampTo(this->industry->incoming_cargo_waiting[variable - 0x40] / this->industry->prod_level); } else { - return ClampTo(this->industry->incoming_cargo_waiting[variable - 0x40]); + return ClampTo(this->industry->incoming_cargo_waiting[variable - 0x40]); } } else { return 0; @@ -327,7 +327,7 @@ uint32 IndustriesScopeResolver::GetCountAndDistanceOfClosestInstance(byte param_ 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); } @@ -431,7 +431,7 @@ uint32 IndustriesScopeResolver::GetCountAndDistanceOfClosestInstance(byte param_ case 0xB3: return this->industry->construction_type; // Construction type case 0xB4: { Date *latest = std::max_element(this->industry->last_cargo_accepted_at, endof(this->industry->last_cargo_accepted_at)); - return ClampTo((*latest) - DAYS_TILL_ORIGINAL_BASE_YEAR); // Date last cargo accepted since 1920 (in days) + return ClampTo((*latest) - DAYS_TILL_ORIGINAL_BASE_YEAR); // Date last cargo accepted since 1920 (in days) } } @@ -441,17 +441,17 @@ uint32 IndustriesScopeResolver::GetCountAndDistanceOfClosestInstance(byte param_ 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; @@ -461,7 +461,7 @@ uint32 IndustriesScopeResolver::GetCountAndDistanceOfClosestInstance(byte param_ /* 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); } @@ -490,8 +490,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) @@ -530,7 +530,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; } @@ -545,7 +545,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(); @@ -562,7 +562,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); @@ -578,7 +578,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. */ @@ -593,12 +593,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 */ @@ -616,9 +616,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; } /** @@ -690,7 +690,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); @@ -712,7 +712,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 fbd89dafe8..5d5a05dfa6 100644 --- a/src/newgrf_industries.h +++ b/src/newgrf_industries.h @@ -13,20 +13,20 @@ #include "newgrf_town.h" struct IndustryLocationDistanceCache { - uint16 distances[NUM_INDUSTRYTYPES]; + uint16_t distances[NUM_INDUSTRYTYPES]; }; struct IndustryLocationDistanceAndCountCache { - uint16 distances[NUM_INDUSTRYTYPES]; - uint8 counts[NUM_INDUSTRYTYPES]; + uint16_t distances[NUM_INDUSTRYTYPES]; + uint8_t counts[NUM_INDUSTRYTYPES]; }; /** Resolver for industry scopes. */ struct IndustriesScopeResolver : public ScopeResolver { - TileIndex tile; ///< Tile owned by the industry. - uint32 random_bits; ///< Random bits of the new industry. - Industry *industry; ///< %Industry being resolved. - IndustryType type; ///< Type of the industry. + TileIndex tile; ///< Tile owned by the industry. + uint32_t random_bits; ///< Random bits of the new industry. + Industry *industry; ///< %Industry being resolved. + IndustryType type; ///< Type of the industry. mutable std::unique_ptr location_distance_cache; mutable std::unique_ptr town_location_distance_cache; @@ -39,18 +39,18 @@ 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), random_bits(random_bits), industry(industry), type(type) { } - uint32 GetRandomBits() const override; - uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override; - uint32 GetTriggers() const override; - void StorePSA(uint pos, int32 value) override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const override; + uint32_t GetTriggers() const override; + void StorePSA(uint pos, int32_t value) override; - uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout_filter, bool town_filter, uint32 mask) const; - uint32 GetClosestIndustry(IndustryType type) const; + uint32_t GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout_filter, bool town_filter, uint32_t mask) const; + uint32_t GetClosestIndustry(IndustryType type) const; }; /** Resolver for industries. */ @@ -58,8 +58,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(); @@ -80,7 +80,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? */ @@ -102,16 +102,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 mask); +uint32_t GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8, uint32_t mask); #endif /* NEWGRF_INDUSTRIES_H */ diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp index a54c1554c4..95e82a75ba 100644 --- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -33,12 +33,12 @@ * @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 mask) +uint32_t GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8, uint32_t mask) { 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); - uint32 result = (is_same_industry ? 1 : 0) << 8; + uint32_t result = (is_same_industry ? 1 : 0) << 8; if (mask & ~0x100) result |= GetNearbyTileInformation(tile, grf_version8, mask); return result; } @@ -54,7 +54,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); @@ -62,7 +62,7 @@ uint32 GetRelativePosition(TileIndex tile, TileIndex ind_tile) return ((y & 0xF) << 20) | ((x & 0xF) << 16) | (y << 8) | x; } -/* virtual */ uint32 IndustryTileScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +/* virtual */ uint32_t IndustryTileScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const { switch (variable) { /* Construction state of the tile: a value between 0 and 3 */ @@ -103,7 +103,7 @@ uint32 GetRelativePosition(TileIndex tile, TileIndex ind_tile) return UINT_MAX; } -/* virtual */ uint32 IndustryTileScopeResolver::GetRandomBits() const +/* virtual */ uint32_t IndustryTileScopeResolver::GetRandomBits() const { assert_tile(this->industry != nullptr && IsValidTile(this->tile), this->tile); assert_tile(this->industry->index == INVALID_INDUSTRY || IsTileType(this->tile, MP_INDUSTRY), this->tile); @@ -111,7 +111,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_tile(this->industry != nullptr && IsValidTile(this->tile), this->tile); assert_tile(this->industry->index == INVALID_INDUSTRY || IsTileType(this->tile, MP_INDUSTRY), this->tile); @@ -140,7 +140,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), @@ -154,7 +154,7 @@ GrfSpecFeature IndustryTileResolverObject::GetFeature() const return GSF_INDUSTRYTILES; } -uint32 IndustryTileResolverObject::GetDebugID() const +uint32_t IndustryTileResolverObject::GetDebugID() const { return GetIndustryTileSpec(gfx)->grf_prop.local_id; } @@ -182,7 +182,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_tile(industry != nullptr && IsValidTile(tile), tile); assert_tile(industry->index == INVALID_INDUSTRY || IsTileType(tile, MP_INDUSTRY), tile); @@ -197,7 +197,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); } @@ -231,7 +231,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; @@ -241,7 +241,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); @@ -255,7 +255,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); } @@ -277,7 +277,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)); @@ -290,7 +290,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)) { @@ -304,7 +304,7 @@ bool StartStopIndustryTileAnimation(const Industry *ind, IndustryAnimationTrigge return ret; } -uint8 GetNewIndustryTileAnimationSpeed(TileIndex tile) +uint8_t GetNewIndustryTileAnimationSpeed(TileIndex tile) { const IndustryTileSpec *itspec = GetIndustryTileSpec(GetIndustryGfx(tile)); if (itspec == nullptr) return 0; @@ -319,7 +319,7 @@ uint8 GetNewIndustryTileAnimationSpeed(TileIndex tile) * @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_tile(IsValidTile(tile) && IsTileType(tile, MP_INDUSTRY), tile); @@ -354,11 +354,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; } @@ -370,7 +370,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); @@ -383,7 +383,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); @@ -414,12 +414,12 @@ void AnalyseIndustryTileSpriteGroups() /* Layout now contains the translated tile layout with gaps removed, up to a maximum of 64 tiles */ - uint64 anim_mask = 0; + uint64_t anim_mask = 0; - uint64 to_check = UINT64_MAX >> (64 - layout.size()); + uint64_t to_check = UINT64_MAX >> (64 - layout.size()); while (to_check != 0) { - uint64 current = 0; + uint64_t current = 0; uint i = FindFirstBit(to_check); IndustryGfx gfx = layout[i].gfx; for (; i < layout.size(); i++) { @@ -463,7 +463,7 @@ void ApplyIndustryTileAnimMasking() if (ind->selected_layout == 0 || ind->selected_layout > spec->layouts.size()) continue; - uint64 mask = spec->layout_anim_masks[ind->selected_layout - 1]; + uint64_t mask = spec->layout_anim_masks[ind->selected_layout - 1]; uint idx = 0; for (IndustryTileLayoutTile it : spec->layouts[ind->selected_layout - 1]) { diff --git a/src/newgrf_industrytiles.h b/src/newgrf_industrytiles.h index 68a1fd9ad6..681ee36450 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(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override; - uint32 GetTriggers() const override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) 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, VarSpriteGroupScopeOffset relative = 0) override { @@ -54,17 +54,17 @@ 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); -uint8 GetNewIndustryTileAnimationSpeed(TileIndex tile); +uint8_t GetNewIndustryTileAnimationSpeed(TileIndex tile); /** Available industry tile triggers. */ diff --git a/src/newgrf_industrytiles_analysis.h b/src/newgrf_industrytiles_analysis.h index 519c2f2ba2..39e4eb9603 100644 --- a/src/newgrf_industrytiles_analysis.h +++ b/src/newgrf_industrytiles_analysis.h @@ -14,9 +14,9 @@ struct AnalyseCallbackOperationIndustryTileData { const IndustryTileLayout *layout; - uint64 check_mask; - uint64 *result_mask; - uint8 layout_index; + uint64_t check_mask; + uint64_t *result_mask; + uint8_t layout_index; bool anim_state_at_offset; bool check_anim_next_frame_cb; }; diff --git a/src/newgrf_internal.h b/src/newgrf_internal.h index 1ff083cd2d..fc185324b1 100644 --- a/src/newgrf_internal.h +++ b/src/newgrf_internal.h @@ -22,7 +22,7 @@ #include /** Base GRF ID for OpenTTD's base graphics GRFs. */ -static const uint32 OPENTTD_GRAPHICS_BASE_GRF_ID = BSWAP32(0xFF4F5400); +static const uint32_t OPENTTD_GRAPHICS_BASE_GRF_ID = BSWAP32(0xFF4F5400); struct VarAction2GroupVariableTracking { std::bitset<256> in; @@ -33,8 +33,8 @@ struct VarAction2GroupVariableTracking { struct VarAction2ProcedureAnnotation { std::bitset<256> stores; - uint32 special_register_values[16]; - uint16 special_register_mask = 0; + uint32_t special_register_values[16]; + uint16_t special_register_mask = 0; bool unskippable = false; }; @@ -59,7 +59,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) @@ -226,31 +226,31 @@ DECLARE_ENUM_AS_BIT_SET(VarAction2AdjustInferenceFlags) struct VarAction2TempStoreInferenceVarSource { DeterministicSpriteGroupAdjustType type; - uint16 variable; + uint16_t variable; byte shift_num; - uint32 parameter; - uint32 and_mask; - uint32 add_val; - uint32 divmod_val; + uint32_t parameter; + uint32_t and_mask; + uint32_t add_val; + uint32_t divmod_val; }; struct VarAction2TempStoreInference { VarAction2AdjustInferenceFlags inference = VA2AIF_NONE; - uint32 store_constant = 0; + uint32_t store_constant = 0; VarAction2TempStoreInferenceVarSource var_source; uint version = 0; }; struct VarAction2InferenceBackup { VarAction2AdjustInferenceFlags inference = VA2AIF_NONE; - uint32 current_constant = 0; + uint32_t current_constant = 0; uint adjust_size = 0; }; struct VarAction2OptimiseState { VarAction2AdjustInferenceFlags inference = VA2AIF_NONE; - uint32 current_constant = 0; - btree::btree_map temp_stores; + uint32_t current_constant = 0; + btree::btree_map temp_stores; VarAction2InferenceBackup inference_backup; VarAction2GroupVariableTracking *var_tracking = nullptr; bool seen_procedure_call = false; @@ -258,8 +258,8 @@ struct VarAction2OptimiseState { bool check_expensive_vars = false; bool enable_dse = false; uint default_variable_version = 0; - uint32 special_register_store_values[16]; - uint16 special_register_store_mask = 0; + uint32_t special_register_store_values[16]; + uint16_t special_register_store_mask = 0; inline VarAction2GroupVariableTracking *GetVarTracking(DeterministicSpriteGroup *group) { @@ -272,7 +272,7 @@ struct VarAction2OptimiseState { inline void OptimiseVarAction2PreCheckAdjust(VarAction2OptimiseState &state, const DeterministicSpriteGroupAdjust &adjust) { - uint16 variable = adjust.variable; + uint16_t variable = adjust.variable; if (variable == 0x7B) variable = adjust.parameter; if (variable == 0x1C) state.var_1C_present = true; } diff --git a/src/newgrf_newlandscape.cpp b/src/newgrf_newlandscape.cpp index 45c4e2592a..af207736da 100644 --- a/src/newgrf_newlandscape.cpp +++ b/src/newgrf_newlandscape.cpp @@ -20,7 +20,7 @@ std::vector _new_landscape_rocks_grfs; -/* virtual */ uint32 NewLandscapeScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +/* virtual */ uint32_t NewLandscapeScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const { if (unlikely(this->ti->tile == INVALID_TILE)) { switch (variable) { @@ -55,7 +55,7 @@ std::vector _new_landscape_rocks_grfs; case 0x60: { TileIndex tile = this->ti->tile; if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required - uint32 result = 0; + uint32_t result = 0; if (extra->mask & ~0x100) result |= GetNearbyTileInformation(tile, this->ro.grffile == nullptr || this->ro.grffile->grf_version >= 8, extra->mask); if (extra->mask & 0x100) { switch (this->landscape_type) { @@ -86,7 +86,7 @@ GrfSpecFeature NewLandscapeResolverObject::GetFeature() const return GSF_NEWLANDSCAPE; } -NewLandscapeResolverObject::NewLandscapeResolverObject(const GRFFile *grffile, const TileInfo *ti, NewLandscapeType landscape_type, uint32 param1, uint32 param2) +NewLandscapeResolverObject::NewLandscapeResolverObject(const GRFFile *grffile, const TileInfo *ti, NewLandscapeType landscape_type, uint32_t param1, uint32_t param2) : ResolverObject(grffile, CBID_NO_CALLBACK, param1, param2), newlandscape_scope(*this, ti, landscape_type) { if (grffile != nullptr) { diff --git a/src/newgrf_newlandscape.h b/src/newgrf_newlandscape.h index 504121f907..8bf7d7acf7 100644 --- a/src/newgrf_newlandscape.h +++ b/src/newgrf_newlandscape.h @@ -16,7 +16,7 @@ extern std::vector _new_landscape_rocks_grfs; -enum NewLandscapeType : uint8 { +enum NewLandscapeType : uint8_t { NEW_LANDSCAPE_ROCKS, }; @@ -32,13 +32,13 @@ struct NewLandscapeScopeResolver : public ScopeResolver { { } - uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override; + uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const override; }; struct NewLandscapeResolverObject : public ResolverObject { NewLandscapeScopeResolver newlandscape_scope; - NewLandscapeResolverObject(const GRFFile *grffile, const TileInfo *ti, NewLandscapeType landscape_type, uint32 param1 = 0, uint32 param2 = 0); + NewLandscapeResolverObject(const GRFFile *grffile, const TileInfo *ti, NewLandscapeType landscape_type, uint32_t param1 = 0, uint32_t param2 = 0); ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, VarSpriteGroupScopeOffset relative = 0) override { diff --git a/src/newgrf_newsignals.cpp b/src/newgrf_newsignals.cpp index 8412b59c7f..9801869b00 100644 --- a/src/newgrf_newsignals.cpp +++ b/src/newgrf_newsignals.cpp @@ -20,21 +20,21 @@ std::vector _new_signals_grfs; std::array _new_signal_styles; std::array _new_signal_style_mapping; -uint8 _num_new_signal_styles = 0; -uint16 _enabled_new_signal_styles_mask = 0; +uint8_t _num_new_signal_styles = 0; +uint16_t _enabled_new_signal_styles_mask = 0; -/* virtual */ uint32 NewSignalsScopeResolver::GetRandomBits() const +/* virtual */ uint32_t NewSignalsScopeResolver::GetRandomBits() const { uint tmp = CountBits(this->tile + (TileX(this->tile) + TileY(this->tile)) * TILE_SIZE); return GB(tmp, 0, 2); } -static uint8 MapSignalStyle(uint8 style) +static uint8_t MapSignalStyle(uint8_t style) { return style != 0 ? _new_signal_styles[style - 1].grf_local_id : 0; } -uint32 GetNewSignalsSideVariable() +uint32_t GetNewSignalsSideVariable() { bool side; switch (_settings_game.construction.train_signal_side) { @@ -45,7 +45,7 @@ uint32 GetNewSignalsSideVariable() return side ? 1 : 0; } -/* virtual */ uint32 NewSignalsScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +/* virtual */ uint32_t NewSignalsScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const { if (this->tile == INVALID_TILE) { switch (variable) { @@ -98,14 +98,14 @@ GrfSpecFeature NewSignalsResolverObject::GetFeature() const * @param prog Routing restriction program. * @param z Signal pixel z. */ -NewSignalsResolverObject::NewSignalsResolverObject(const GRFFile *grffile, TileIndex tile, TileContext context, uint32 param1, uint32 param2, - CustomSignalSpriteContext signal_context, uint8 signal_style, const TraceRestrictProgram *prog, uint z) +NewSignalsResolverObject::NewSignalsResolverObject(const GRFFile *grffile, TileIndex tile, TileContext context, uint32_t param1, uint32_t param2, + CustomSignalSpriteContext signal_context, uint8_t signal_style, const TraceRestrictProgram *prog, uint z) : ResolverObject(grffile, CBID_NO_CALLBACK, param1, param2), newsignals_scope(*this, tile, context, signal_context, signal_style, prog, z) { this->root_spritegroup = grffile != nullptr ? grffile->new_signals_group : nullptr; } -uint GetNewSignalsRestrictedSignalsInfo(const TraceRestrictProgram *prog, TileIndex tile, uint8 signal_style) +uint GetNewSignalsRestrictedSignalsInfo(const TraceRestrictProgram *prog, TileIndex tile, uint8_t signal_style) { uint result = 0; if (signal_style != 0 && HasBit(_signal_style_masks.always_reserve_through, signal_style)) result |= 2; diff --git a/src/newgrf_newsignals.h b/src/newgrf_newsignals.h index e229383d60..e4e89150e4 100644 --- a/src/newgrf_newsignals.h +++ b/src/newgrf_newsignals.h @@ -40,31 +40,31 @@ enum NewSignalStyleFlags { struct NewSignalStyle { const GRFFile *grffile; StringID name; - uint8 grf_local_id; - uint8 style_flags; - uint8 lookahead_extra_aspects; - uint8 semaphore_mask; - uint8 electric_mask; + uint8_t grf_local_id; + uint8_t style_flags; + uint8_t lookahead_extra_aspects; + uint8_t semaphore_mask; + uint8_t electric_mask; PalSpriteID signals[SIGTYPE_END][2][2]; }; extern std::array _new_signal_styles; struct NewSignalStyleMapping { - uint32 grfid = 0; - uint8 grf_local_id = 0; + uint32_t grfid = 0; + uint8_t grf_local_id = 0; inline bool operator==(const NewSignalStyleMapping& o) const { return grfid == o.grfid && grf_local_id == o.grf_local_id; } }; extern std::array _new_signal_style_mapping; -extern uint8 _num_new_signal_styles; -extern uint16 _enabled_new_signal_styles_mask; +extern uint8_t _num_new_signal_styles; +extern uint16_t _enabled_new_signal_styles_mask; /** Resolver for the new signals scope. */ struct NewSignalsScopeResolver : public ScopeResolver { TileIndex tile; ///< Tracktile. For track on a bridge this is the southern bridgehead. TileContext context; ///< Are we resolving sprites for the upper halftile, or on a bridge? CustomSignalSpriteContext signal_context; - uint8 signal_style; + uint8_t signal_style; const TraceRestrictProgram *prog; uint z; @@ -75,21 +75,21 @@ struct NewSignalsScopeResolver : public ScopeResolver { * @param context Are we resolving sprites for the upper halftile, or on a bridge? * @param signal_context Signal context. */ - NewSignalsScopeResolver(ResolverObject &ro, TileIndex tile, TileContext context, CustomSignalSpriteContext signal_context, uint8 signal_style, const TraceRestrictProgram *prog, uint z) + NewSignalsScopeResolver(ResolverObject &ro, TileIndex tile, TileContext context, CustomSignalSpriteContext signal_context, uint8_t signal_style, const TraceRestrictProgram *prog, uint z) : ScopeResolver(ro), tile(tile), context(context), signal_context(signal_context), signal_style(signal_style), prog(prog), z(z) { } - uint32 GetRandomBits() const override; - uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const override; }; /** Resolver object for rail types. */ struct NewSignalsResolverObject : public ResolverObject { NewSignalsScopeResolver newsignals_scope; ///< Resolver for the new signals scope. - NewSignalsResolverObject(const GRFFile *grffile, TileIndex tile, TileContext context, uint32 param1, uint32 param2, - CustomSignalSpriteContext signal_context, uint8 signal_style, const TraceRestrictProgram *prog = nullptr, uint z = 0); + NewSignalsResolverObject(const GRFFile *grffile, TileIndex tile, TileContext context, uint32_t param1, uint32_t param2, + CustomSignalSpriteContext signal_context, uint8_t signal_style, const TraceRestrictProgram *prog = nullptr, uint z = 0); ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, VarSpriteGroupScopeOffset relative = 0) override { @@ -104,7 +104,7 @@ struct NewSignalsResolverObject : public ResolverObject { GrfSpecFeature GetFeature() const override; }; -uint GetNewSignalsRestrictedSignalsInfo(const TraceRestrictProgram *prog, TileIndex tile, uint8 signal_style); +uint GetNewSignalsRestrictedSignalsInfo(const TraceRestrictProgram *prog, TileIndex tile, uint8_t signal_style); uint GetNewSignalsVerticalClearanceInfo(TileIndex tile, uint z); inline uint GetNewSignalsSignalContext(CustomSignalSpriteContext signal_context, TileIndex tile) @@ -114,6 +114,6 @@ inline uint GetNewSignalsSignalContext(CustomSignalSpriteContext signal_context, return result; } -uint32 GetNewSignalsSideVariable(); +uint32_t GetNewSignalsSideVariable(); #endif /* NEWGRF_NEWSIGNALS_H */ diff --git a/src/newgrf_object.cpp b/src/newgrf_object.cpp index 546c266d78..26d3253514 100644 --- a/src/newgrf_object.cpp +++ b/src/newgrf_object.cpp @@ -128,7 +128,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; } @@ -153,7 +153,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; } @@ -164,7 +164,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; @@ -193,12 +193,12 @@ 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, uint32 mask) +static uint32_t GetNearbyObjectTileInformation(byte parameter, TileIndex tile, ObjectID index, bool grf_version8, uint32_t mask) { if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required bool is_same_object = (IsTileType(tile, MP_OBJECT) && GetObjectIndex(tile) == index); - uint32 result = (is_same_object ? 1 : 0) << 8; + uint32_t result = (is_same_object ? 1 : 0) << 8; if (mask & ~0x100) result |= GetNearbyTileInformation(tile, grf_version8, mask); return result; } @@ -210,9 +210,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; @@ -230,10 +230,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(uint32 local_id, uint32 grfid, TileIndex tile, const Object *current) +static uint32_t GetCountAndDistanceOfClosestInstance(uint32_t 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) { @@ -257,7 +257,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(uint32 local_id, uint32 grfid } /** Used by the resolver to get values for feature 0F deterministic spritegroups. */ -/* virtual */ uint32 ObjectScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +/* virtual */ uint32_t ObjectScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const { /* We get the town from the object, or we calculate the closest * town if we need to when there's no object. */ @@ -334,7 +334,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(uint32 local_id, uint32 grfid case 0x44: return GetTileOwner(this->tile); /* Get town zone and Manhattan distance of closest town */ - case 0x45: return (t == nullptr) ? 0 : (GetTownRadiusGroup(t, this->tile) << 16 | ClampTo(DistanceManhattan(this->tile, t->xy))); + case 0x45: return (t == nullptr) ? 0 : (GetTownRadiusGroup(t, this->tile) << 16 | ClampTo(DistanceManhattan(this->tile, t->xy))); /* Get square of Euclidian distance of closest town */ case 0x46: return (t == nullptr) ? 0 : DistanceSquare(this->tile, t->xy); @@ -398,8 +398,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; @@ -437,7 +437,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; } @@ -453,7 +453,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(); @@ -534,7 +534,7 @@ void DrawNewObjectTile(TileInfo *ti, const ObjectSpec *spec, int building_z_offs * @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(); @@ -576,7 +576,7 @@ void DrawNewObjectTileInGUI(int x, int y, const ObjectSpec *spec, uint8 view) * @param tile The tile the callback is called for. * @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); } @@ -602,7 +602,7 @@ void AnimateNewObjectTile(TileIndex tile) ObjectAnimationBase::AnimateTile(spec, Object::GetByTile(tile), tile, (spec->flags & OBJECT_FLAG_ANIM_RANDOM_BITS) != 0); } -uint8 GetNewObjectTileAnimationSpeed(TileIndex tile) +uint8_t GetNewObjectTileAnimationSpeed(TileIndex tile) { const ObjectSpec *spec = ObjectSpec::GetByTile(tile); if (spec == nullptr || !(spec->flags & OBJECT_FLAG_ANIMATION)) return 0; diff --git a/src/newgrf_object.h b/src/newgrf_object.h index 5f5cc3c89f..f7c7ec0452 100644 --- a/src/newgrf_object.h +++ b/src/newgrf_object.h @@ -22,7 +22,7 @@ #include /** 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. @@ -58,12 +58,12 @@ enum ObjectEdgeFoundationFlags { }; DECLARE_ENUM_AS_BIT_SET(ObjectEdgeFoundationFlags) -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 : uint16 { +enum ObjectClassID : uint16_t { OBJECT_CLASS_BEGIN = 0, ///< The lowest valid value OBJECT_CLASS_MAX = 0xFFFF, ///< Maximum number of classes. INVALID_OBJECT_CLASS = 0xFFFF, ///< Class for the less fortunate. @@ -91,26 +91,26 @@ enum ObjectViewportMapType { */ struct ObjectSpec { /* 2 because of the "normal" and "buy" sprite stacks. */ - GRFFilePropsBase<2> grf_prop; ///< Properties related the the grf file - AnimationInfo animation; ///< Information about the animation. - 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. - Date introduction_date; ///< From when can this object be built. - Date end_of_life_date; ///< When can't this object be built anymore. - ObjectFlags flags; ///< Flags/settings related to the object. - ObjectCtrlFlags ctrl_flags; ///< Extra control flags. - uint8 edge_foundation[4]; ///< Edge foundation flags - 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. + GRFFilePropsBase<2> grf_prop; ///< Properties related the the grf file + AnimationInfo animation; ///< Information about the animation. + ObjectClassID cls_id; ///< The class to which this spec belongs. + StringID name; ///< The name for this object. + + 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. + Date introduction_date; ///< From when can this object be built. + Date end_of_life_date; ///< When can't this object be built anymore. + ObjectFlags flags; ///< Flags/settings related to the object. + ObjectCtrlFlags ctrl_flags; ///< Extra control flags. + uint8_t edge_foundation[4]; ///< Edge foundation flags + 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. ObjectViewportMapType vport_map_type; ///< Viewport map type - uint16 vport_map_subtype; ///< Viewport map subtype + uint16_t vport_map_subtype; ///< Viewport map subtype /** * Test if this object is enabled. @@ -148,7 +148,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. @@ -157,13 +157,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(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const override; }; /** A resolver object to be used with feature 0F spritegroups. */ @@ -171,8 +171,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, VarSpriteGroupScopeOffset relative = 0) override @@ -193,7 +193,7 @@ struct ObjectResolverObject : public ResolverObject { } GrfSpecFeature GetFeature() const override; - uint32 GetDebugID() const override; + uint32_t GetDebugID() const override; private: TownScopeResolver *GetTown(); @@ -205,12 +205,12 @@ 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, int building_z_offset); -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); -uint8 GetNewObjectTileAnimationSpeed(TileIndex tile); +uint8_t GetNewObjectTileAnimationSpeed(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_optimiser.cpp b/src/newgrf_optimiser.cpp index c7c1e21428..b4700f3007 100644 --- a/src/newgrf_optimiser.cpp +++ b/src/newgrf_optimiser.cpp @@ -20,7 +20,7 @@ #include "safeguards.h" -static bool IsExpensiveVehicleVariable(uint16 variable) +static bool IsExpensiveVehicleVariable(uint16_t variable) { switch (variable) { case 0x45: @@ -38,7 +38,7 @@ static bool IsExpensiveVehicleVariable(uint16 variable) } } -static bool IsExpensiveStationVariable(uint16 variable) +static bool IsExpensiveStationVariable(uint16_t variable) { switch (variable) { case 0x66: @@ -53,7 +53,7 @@ static bool IsExpensiveStationVariable(uint16 variable) } } -static bool IsExpensiveIndustryTileVariable(uint16 variable) +static bool IsExpensiveIndustryTileVariable(uint16_t variable) { switch (variable) { case 0x60: @@ -66,7 +66,7 @@ static bool IsExpensiveIndustryTileVariable(uint16 variable) } } -static bool IsExpensiveObjectVariable(uint16 variable) +static bool IsExpensiveObjectVariable(uint16_t variable) { switch (variable) { case 0x41: @@ -85,7 +85,7 @@ static bool IsExpensiveObjectVariable(uint16 variable) } } -static bool IsExpensiveRoadStopsVariable(uint16 variable) +static bool IsExpensiveRoadStopsVariable(uint16_t variable) { switch (variable) { case 0x45: @@ -104,7 +104,7 @@ static bool IsExpensiveRoadStopsVariable(uint16 variable) } } -static bool IsExpensiveRailtypeVariable(uint16 variable) +static bool IsExpensiveRailtypeVariable(uint16_t variable) { switch (variable) { case A2VRI_RAILTYPE_SIGNAL_VERTICAL_CLEARANCE: @@ -116,7 +116,7 @@ static bool IsExpensiveRailtypeVariable(uint16 variable) } } -static bool IsExpensiveSignalVariable(uint16 variable) +static bool IsExpensiveSignalVariable(uint16_t variable) { switch (variable) { case A2VRI_SIGNALS_SIGNAL_VERTICAL_CLEARANCE: @@ -127,7 +127,7 @@ static bool IsExpensiveSignalVariable(uint16 variable) } } -static bool IsExpensiveVariable(uint16 variable, GrfSpecFeature scope_feature) +static bool IsExpensiveVariable(uint16_t variable, GrfSpecFeature scope_feature) { switch (scope_feature) { case GSF_TRAINS: @@ -159,7 +159,7 @@ static bool IsExpensiveVariable(uint16 variable, GrfSpecFeature scope_feature) } } -static bool IsVariableVeryCheap(uint16 variable, GrfSpecFeature scope_feature) +static bool IsVariableVeryCheap(uint16_t variable, GrfSpecFeature scope_feature) { switch (variable) { case 0x0C: @@ -269,7 +269,7 @@ static const DeterministicSpriteGroupAdjust *GetVarAction2PreviousSingleStoreAdj return nullptr; } -static int GetVarAction2AdjustOfPreviousTempStoreSource(const DeterministicSpriteGroupAdjust *adjusts, int start_index, uint8 store_var) +static int GetVarAction2AdjustOfPreviousTempStoreSource(const DeterministicSpriteGroupAdjust *adjusts, int start_index, uint8_t store_var) { for (int i = start_index - 1; i >= 0; i--) { const DeterministicSpriteGroupAdjust &prev = adjusts[i]; @@ -802,15 +802,15 @@ void OptimiseVarAction2Adjust(VarAction2OptimiseState &state, const VarAction2Ad const VarAction2AdjustInferenceFlags prev_inference = state.inference; state.inference = VA2AIF_NONE; - auto get_sign_bit = [&]() -> uint32 { + auto get_sign_bit = [&]() -> uint32_t { return (1 << ((info.varsize * 8) - 1)); }; - auto get_full_mask = [&]() -> uint32 { + auto get_full_mask = [&]() -> uint32_t { return UINT_MAX >> ((4 - info.varsize) * 8); }; - auto add_inferences_from_mask = [&](uint32 mask) { + auto add_inferences_from_mask = [&](uint32_t mask) { if (mask == 1) { state.inference |= VA2AIF_SIGNED_NON_NEGATIVE | VA2AIF_ONE_OR_ZERO; } else if ((mask & get_sign_bit()) == 0) { @@ -818,7 +818,7 @@ void OptimiseVarAction2Adjust(VarAction2OptimiseState &state, const VarAction2Ad } }; - auto replace_with_constant_load = [&](uint32 constant) { + auto replace_with_constant_load = [&](uint32_t constant) { group->adjusts.pop_back(); if ((prev_inference & VA2AIF_HAVE_CONSTANT) && constant == state.current_constant) { /* Don't create a new constant load for the same constant as was there previously */ @@ -899,7 +899,7 @@ void OptimiseVarAction2Adjust(VarAction2OptimiseState &state, const VarAction2Ad if (proc == nullptr) return false; byte shift_num = adjust.shift_num; - uint32 and_mask = adjust.and_mask; + uint32_t and_mask = adjust.and_mask; // Initial value state is 0 replace_with_constant_load(0); @@ -1112,7 +1112,7 @@ void OptimiseVarAction2Adjust(VarAction2OptimiseState &state, const VarAction2Ad std::bitset<256> seen_stores; bool seen_unpredictable_store = false; bool seen_special_store = false; - uint16 seen_special_store_mask = 0; + uint16_t seen_special_store_mask = 0; bool seen_perm_store = false; auto handle_proc_stores = y_combinator([&](auto handle_proc_stores, const SpriteGroup *sg) -> void { if (sg == nullptr) return; @@ -1230,7 +1230,7 @@ void OptimiseVarAction2Adjust(VarAction2OptimiseState &state, const VarAction2Ad } if (adjust.operation == DSGA_OP_RST && adjust.type == DSGA_TYPE_MOD && adjust.divmod_val == 2) { /* Non-negative value % 2 implies VA2AIF_ONE_OR_ZERO */ - if ((uint64)adjust.and_mask + (uint64)adjust.add_val < (uint64)get_sign_bit()) { + if ((uint64_t)adjust.and_mask + (uint64_t)adjust.add_val < (uint64_t)get_sign_bit()) { state.inference |= VA2AIF_SIGNED_NON_NEGATIVE | VA2AIF_ONE_OR_ZERO; } } @@ -1574,7 +1574,7 @@ void OptimiseVarAction2Adjust(VarAction2OptimiseState &state, const VarAction2Ad const DeterministicSpriteGroupAdjust &adj1 = group->adjusts[group->adjusts.size() - 4]; const DeterministicSpriteGroupAdjust &adj2 = group->adjusts[group->adjusts.size() - 3]; const DeterministicSpriteGroupAdjust &adj3 = group->adjusts[group->adjusts.size() - 2]; - auto is_expected_op = [](const DeterministicSpriteGroupAdjust &adj, DeterministicSpriteGroupAdjustOperation op, uint32 value) -> bool { + auto is_expected_op = [](const DeterministicSpriteGroupAdjust &adj, DeterministicSpriteGroupAdjustOperation op, uint32_t value) -> bool { return adj.operation == op && adj.type == DSGA_TYPE_NONE && adj.variable == 0x1A && adj.shift_num == 0 && adj.and_mask == value; }; if (is_expected_op(adj1, DSGA_OP_STO, (adjust.parameter & 0xFF)) && @@ -1587,10 +1587,10 @@ void OptimiseVarAction2Adjust(VarAction2OptimiseState &state, const VarAction2Ad break; } } - uint32 sign_bit = (1 << ((info.varsize * 8) - 1)); + uint32_t sign_bit = (1 << ((info.varsize * 8) - 1)); if ((prev_inference & VA2AIF_PREV_MASK_ADJUST) && (prev_inference & VA2AIF_SIGNED_NON_NEGATIVE) && adjust.variable == 0x1A && adjust.shift_num == 0 && (adjust.and_mask & sign_bit) == 0) { /* Determine whether the result will be always non-negative */ - if (((uint64)group->adjusts[group->adjusts.size() - 2].and_mask) * ((uint64)adjust.and_mask) < ((uint64)sign_bit)) { + if (((uint64_t)group->adjusts[group->adjusts.size() - 2].and_mask) * ((uint64_t)adjust.and_mask) < ((uint64_t)sign_bit)) { state.inference |= VA2AIF_SIGNED_NON_NEGATIVE; } } @@ -1871,15 +1871,15 @@ static bool CheckDeterministicSpriteGroupOutputVarBits(const DeterministicSprite static bool OptimiseVarAction2DeterministicSpriteGroupExpensiveVarsInner(DeterministicSpriteGroup *group, const GrfSpecFeature scope_feature, VarAction2GroupVariableTracking *var_tracking) { - btree::btree_map seen_expensive_variables; + btree::btree_map seen_expensive_variables; std::bitset<256> usable_vars; if (var_tracking != nullptr) { usable_vars = ~(var_tracking->out | var_tracking->proc_call_out); } else { usable_vars.set(); } - uint16 target_var = 0; - uint32 target_param = 0; + uint16_t target_var = 0; + uint32_t target_param = 0; auto found_target = [&]() -> bool { for (auto &iter : seen_expensive_variables) { if (iter.second >= 2) { @@ -1893,9 +1893,9 @@ static bool OptimiseVarAction2DeterministicSpriteGroupExpensiveVarsInner(Determi auto do_replacements = [&](int start, int end) { std::bitset<256> mask(UINT64_MAX); std::bitset<256> cur = usable_vars; - uint8 bit = 0; + uint8_t bit = 0; while (true) { - uint64 t = (cur & mask).to_ullong(); + uint64_t t = (cur & mask).to_ullong(); if (t != 0) { bit += FindFirstBit(t); break; @@ -1904,7 +1904,7 @@ static bool OptimiseVarAction2DeterministicSpriteGroupExpensiveVarsInner(Determi bit += 64; } int insert_pos = start; - uint32 and_mask = 0; + uint32_t and_mask = 0; uint condition_depth = 0; bool seen_first = false; int last_unused_jump = -1; @@ -1963,7 +1963,7 @@ static bool OptimiseVarAction2DeterministicSpriteGroupExpensiveVarsInner(Determi } else if (adjust.variable == 0x7D) { if (adjust.parameter < 0x100) usable_vars.set(adjust.parameter, false); } else if (IsExpensiveVariable(adjust.variable, scope_feature)) { - seen_expensive_variables[(((uint64)adjust.variable) << 32) | adjust.parameter]++; + seen_expensive_variables[(((uint64_t)adjust.variable) << 32) | adjust.parameter]++; } if (adjust.variable == 0x7E || (adjust.operation == DSGA_OP_STO && adjust.and_mask >= 0x100) || (adjust.operation == DSGA_OP_STO_NC && adjust.divmod_val >= 0x100)) { /* Can't cross this barrier, stop here */ @@ -2076,11 +2076,11 @@ static void OptimiseVarAction2DeterministicSpriteGroupAdjustOrdering(Determinist { if (HasGrfOptimiserFlag(NGOF_NO_OPT_VARACT2_ADJUST_ORDERING)) return; - auto acceptable_variable = [](uint16 variable) -> bool { + auto acceptable_variable = [](uint16_t variable) -> bool { return variable != 0x7E && variable != 0x7B; }; - auto get_variable_expense = [&](uint16 variable) -> int { + auto get_variable_expense = [&](uint16_t variable) -> int { if (variable == 0x1A) return -15; if (IsVariableVeryCheap(variable, scope_feature)) return -10; if (variable == 0x7D || variable == 0x7C) return -5; @@ -2230,10 +2230,10 @@ static VarAction2ProcedureAnnotation *OptimiseVarAction2GetFilledProcedureAnnota return anno; } -static uint OptimiseVarAction2InsertSpecialStoreOps(DeterministicSpriteGroup *group, uint offset, uint32 values[16], uint16 mask) +static uint OptimiseVarAction2InsertSpecialStoreOps(DeterministicSpriteGroup *group, uint offset, uint32_t values[16], uint16_t mask) { uint added = 0; - for (uint8 bit : SetBitIterator(mask)) { + for (uint8_t bit : SetBitIterator(mask)) { bool skip = false; for (size_t i = offset; i < group->adjusts.size(); i++) { const DeterministicSpriteGroupAdjust &next = group->adjusts[i]; @@ -2381,8 +2381,8 @@ static void OptimiseVarAction2DeterministicSpriteGroupInsertJumps(DeterministicS if (adjust.adjust_flags & DSGAF_JUMP_INS_HINT) { std::bitset<256> ok_stores; - uint32 special_stores[16]; - uint16 special_stores_mask = 0; + uint32_t special_stores[16]; + uint16_t special_stores_mask = 0; int j = i - 1; int skip_count = 0; const DeterministicSpriteGroupAdjustFlags skip_mask = adjust.adjust_flags & (DSGAF_SKIP_ON_ZERO | DSGAF_SKIP_ON_LSB_SET); @@ -2410,8 +2410,8 @@ static void OptimiseVarAction2DeterministicSpriteGroupInsertJumps(DeterministicS if ((anno.relevant_stores & ~ok_stores).any()) break; ok_stores |= anno.last_reads; - uint16 new_stores = anno.anno->special_register_mask & ~special_stores_mask; - for (uint8 bit : SetBitIterator(new_stores)) { + uint16_t new_stores = anno.anno->special_register_mask & ~special_stores_mask; + for (uint8_t bit : SetBitIterator(new_stores)) { special_stores[bit] = anno.anno->special_register_values[bit]; } special_stores_mask |= new_stores; @@ -2549,7 +2549,7 @@ static void OptimiseVarAction2DeterministicSpriteResolveJumps(DeterministicSprit static const size_t MAX_PROC_INLINE_ADJUST_COUNT = 8; -static bool IsVariableInlinable(uint16 variable, GrfSpecFeature feature) +static bool IsVariableInlinable(uint16_t variable, GrfSpecFeature feature) { /* Always available global variables */ if (variable <= 0x03) return true; @@ -2751,7 +2751,7 @@ void OptimiseVarAction2DeterministicSpriteGroup(VarAction2OptimiseState &state, } if (!found_zero_value && !found_random_cb_value) { group->ranges.insert(group->ranges.begin(), { group->default_group, 0, 1 }); - extern const CallbackResultSpriteGroup *NewCallbackResultSpriteGroupNoTransform(uint16 result); + extern const CallbackResultSpriteGroup *NewCallbackResultSpriteGroupNoTransform(uint16_t result); group->default_group = NewCallbackResultSpriteGroupNoTransform(CALLBACK_FAILED); } } @@ -2862,7 +2862,7 @@ static std::bitset<256> HandleVarAction2DeadStoreElimination(DeterministicSprite i++; } }; - auto try_variable_substitution = [&](DeterministicSpriteGroupAdjust &target, int prev_load_index, uint8 idx) -> bool { + auto try_variable_substitution = [&](DeterministicSpriteGroupAdjust &target, int prev_load_index, uint8_t idx) -> bool { assert(target.variable == 0x7D && target.parameter == idx); bool inverted = false; @@ -2891,7 +2891,7 @@ static std::bitset<256> HandleVarAction2DeadStoreElimination(DeterministicSprite const DeterministicSpriteGroupAdjust &adjust = group->adjusts[i]; if (adjust.operation == DSGA_OP_STO) { if (adjust.type == DSGA_TYPE_NONE && adjust.variable == 0x1A && adjust.shift_num == 0 && adjust.and_mask < 0x100) { - uint8 idx = adjust.and_mask; + uint8_t idx = adjust.and_mask; /* Predictable store */ for (size_t j = 0; j < substitution_candidates.size(); j++) { @@ -3115,7 +3115,7 @@ static std::bitset<256> HandleVarAction2DeadStoreElimination(DeterministicSprite } else { /* Flush any substitution candidates which reference stores made in the procedure */ for (size_t j = 0; j < substitution_candidates.size();) { - uint8 idx = substitution_candidates[j] & 0xFF; + uint8_t idx = substitution_candidates[j] & 0xFF; if (anno->stores[idx]) { all_bits.set(idx, true); propagate_bits.set(idx, true); @@ -3230,7 +3230,7 @@ const SpriteGroup *PruneTargetSpriteGroup(const SpriteGroup *result) const DeterministicSpriteGroup *sg = static_cast(result); if (sg->GroupMayBeBypassed()) { /* Deterministic sprite group can be trivially resolved, skip it */ - uint32 value = (sg->adjusts.size() == 1) ? EvaluateDeterministicSpriteGroupAdjust(sg->size, sg->adjusts[0], nullptr, 0, UINT_MAX) : 0; + uint32_t value = (sg->adjusts.size() == 1) ? EvaluateDeterministicSpriteGroupAdjust(sg->size, sg->adjusts[0], nullptr, 0, UINT_MAX) : 0; const SpriteGroup *candidate = sg->default_group; for (const auto &range : sg->ranges) { if (range.low <= value && value <= range.high) { diff --git a/src/newgrf_profiling.cpp b/src/newgrf_profiling.cpp index 63667d22fc..9d7d5f9316 100644 --- a/src/newgrf_profiling.cpp +++ b/src/newgrf_profiling.cpp @@ -48,7 +48,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 = _tick_counter; this->cur_call.cb = resolver.callback; this->cur_call.feat = resolver.GetFeature(); @@ -61,7 +61,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; @@ -91,7 +91,7 @@ void NewGRFProfiler::Start() this->start_tick = _tick_counter; } -uint32 NewGRFProfiler::Finish() +uint32_t NewGRFProfiler::Finish() { if (!this->active) return 0; @@ -108,7 +108,7 @@ uint32 NewGRFProfiler::Finish() FILE *f = FioFOpenFile(filename, "wt", Subdirectory::NO_DIRECTORY); FileCloser fcloser(f); - uint32 total_microseconds = 0; + uint32_t total_microseconds = 0; fputs("Tick,Sprite,Feature,Item,CallbackID,Microseconds,Depth,Result\n", f); for (const Call &c : this->calls) { @@ -141,12 +141,12 @@ std::string NewGRFProfiler::GetOutputFilename() const return std::string(filepath); } -/* 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(); @@ -172,7 +172,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 24cb059b4c..617ec79443 100644 --- a/src/newgrf_profiling.h +++ b/src/newgrf_profiling.h @@ -32,31 +32,31 @@ 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 - CallbackID cb; ///< Callback ID - GrfSpecFeature feat; ///< GRF feature being resolved for + 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 - Call cur_call; ///< Data for current call in progress - std::vector calls; ///< All calls collected so far + const GRFFile *grffile; ///< Which GRF is being profiled + bool active; ///< Is this profiler collecting data + 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 }; extern std::vector _newgrf_profilers; diff --git a/src/newgrf_railtype.cpp b/src/newgrf_railtype.cpp index 3ea0d33e41..4e5a1cab2a 100644 --- a/src/newgrf_railtype.cpp +++ b/src/newgrf_railtype.cpp @@ -21,13 +21,13 @@ #include "safeguards.h" -/* virtual */ uint32 RailTypeScopeResolver::GetRandomBits() const +/* virtual */ uint32_t RailTypeScopeResolver::GetRandomBits() const { uint tmp = CountBits(this->tile + (TileX(this->tile) + TileY(this->tile)) * TILE_SIZE); return GB(tmp, 0, 2); } -/* virtual */ uint32 RailTypeScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +/* virtual */ uint32_t RailTypeScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const { if (this->tile == INVALID_TILE) { switch (variable) { @@ -82,7 +82,7 @@ const DiagDirection dir_s = AxisToDiagDir(axis); const DiagDirection dir_n = ReverseDiagDir(dir_s); - uint32 result = 0; + uint32_t result = 0; auto test_dir = [&](DiagDirection dir, uint bit) { const TileIndex t = TileAddByDiagDir(this->tile, dir); if (t < MapSize() && IsLevelCrossingTile(t) && GetCrossingRoadAxis(t) == axis && is_usable_crossing(t)) { @@ -106,7 +106,7 @@ GrfSpecFeature RailTypeResolverObject::GetFeature() const return GSF_RAILTYPES; } -uint32 RailTypeResolverObject::GetDebugID() const +uint32_t RailTypeResolverObject::GetDebugID() const { return this->railtype_scope.rti->label; } @@ -123,7 +123,7 @@ uint32 RailTypeResolverObject::GetDebugID() const * @param z Signal pixel z. * @param prog Routing restriction program. */ -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, CustomSignalSpriteContext signal_context, const TraceRestrictProgram *prog, uint z) : ResolverObject(rti != nullptr ? rti->grffile[rtsg] : nullptr, CBID_NO_CALLBACK, param1, param2), railtype_scope(*this, rti, tile, context, signal_context, prog, z) { @@ -154,9 +154,9 @@ SpriteID GetCustomRailSprite(const RailTypeInfo *rti, TileIndex tile, RailTypeSp return group->GetResult(); } -inline uint8 RemapAspect(uint8 aspect, uint8 extra_aspects, uint8 style) +inline uint8_t RemapAspect(uint8_t aspect, uint8_t extra_aspects, uint8_t style) { - if (likely(extra_aspects == 0 || _extra_aspects == 0)) return std::min(aspect, 1); + if (likely(extra_aspects == 0 || _extra_aspects == 0)) return std::min(aspect, 1); if (aspect == 0) return 0; if (style != 0 && HasBit(_signal_style_masks.combined_normal_shunt, style)) { if (aspect == 1) { @@ -168,15 +168,15 @@ inline uint8 RemapAspect(uint8 aspect, uint8 extra_aspects, uint8 style) return aspect + 1; } -static PalSpriteID GetRailTypeCustomSignalSprite(const RailTypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, uint8 aspect, +static PalSpriteID GetRailTypeCustomSignalSprite(const RailTypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, uint8_t aspect, CustomSignalSpriteContext context, const TraceRestrictProgram *prog, uint z) { if (rti->group[RTSG_SIGNALS] == nullptr) return { 0, PAL_NONE }; if (type == SIGTYPE_PROG && !HasBit(rti->ctrl_flags, RTCF_PROGSIG)) return { 0, PAL_NONE }; if (type == SIGTYPE_NO_ENTRY && !HasBit(rti->ctrl_flags, RTCF_NOENTRYSIG)) return { 0, PAL_NONE }; - uint32 param1 = (context == CSSC_GUI) ? 0x10 : 0x00; - uint32 param2 = (type << 16) | (var << 8) | RemapAspect(aspect, rti->signal_extra_aspects, 0); + uint32_t param1 = (context == CSSC_GUI) ? 0x10 : 0x00; + uint32_t param2 = (type << 16) | (var << 8) | RemapAspect(aspect, rti->signal_extra_aspects, 0); if ((prog != nullptr) && HasBit(rti->ctrl_flags, RTCF_RESTRICTEDSIG)) SetBit(param2, 24); RailTypeResolverObject object(rti, tile, TCX_NORMAL, RTSG_SIGNALS, param1, param2, context, prog, z); @@ -197,8 +197,8 @@ static PalSpriteID GetRailTypeCustomSignalSprite(const RailTypeInfo *rti, TileIn * @param gui Is the sprite being used on the map or in the GUI? * @return The sprite to draw. */ -CustomSignalSpriteResult GetCustomSignalSprite(const RailTypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, uint8 aspect, - CustomSignalSpriteContext context, uint8 style, const TraceRestrictProgram *prog, uint z) +CustomSignalSpriteResult GetCustomSignalSprite(const RailTypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, uint8_t aspect, + CustomSignalSpriteContext context, uint8_t style, const TraceRestrictProgram *prog, uint z) { if (_settings_client.gui.show_all_signal_default == SSDM_ON && style == 0) return { { 0, PAL_NONE }, false }; @@ -214,8 +214,8 @@ CustomSignalSpriteResult GetCustomSignalSprite(const RailTypeInfo *rti, TileInde } if (!HasBit(grf->new_signal_style_mask, style)) continue; - uint32 param1 = (context == CSSC_GUI) ? 0x10 : 0x00; - uint32 param2 = (type << 16) | (var << 8) | RemapAspect(aspect, grf->new_signal_extra_aspects, style); + uint32_t param1 = (context == CSSC_GUI) ? 0x10 : 0x00; + uint32_t param2 = (type << 16) | (var << 8) | RemapAspect(aspect, grf->new_signal_extra_aspects, style); if ((prog != nullptr) && HasBit(grf->new_signal_ctrl_flags, NSCF_RESTRICTEDSIG)) SetBit(param2, 24); NewSignalsResolverObject object(grf, tile, TCX_NORMAL, param1, param2, context, style, prog, z); @@ -235,7 +235,7 @@ CustomSignalSpriteResult GetCustomSignalSprite(const RailTypeInfo *rti, TileInde * @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.empty()) { /* No railtype table present. Return railtype as-is (if valid), so it works for original railtypes. */ @@ -257,7 +257,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.empty()) return railtype; diff --git a/src/newgrf_railtype.h b/src/newgrf_railtype.h index 101258c02c..b2a12f26ab 100644 --- a/src/newgrf_railtype.h +++ b/src/newgrf_railtype.h @@ -37,15 +37,15 @@ struct RailTypeScopeResolver : public ScopeResolver { { } - uint32 GetRandomBits() const override; - uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) 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, CustomSignalSpriteContext signal_context = CSSC_GUI, const TraceRestrictProgram *prog = nullptr, uint z = 0); ScopeResolver *GetScope(VarSpriteGroupScope scope = VSG_SCOPE_SELF, VarSpriteGroupScopeOffset relative = 0) override @@ -57,7 +57,7 @@ struct RailTypeResolverObject : public ResolverObject { } GrfSpecFeature GetFeature() const override; - uint32 GetDebugID() const override; + uint32_t GetDebugID() const override; }; struct CustomSignalSpriteResult { @@ -66,10 +66,10 @@ struct CustomSignalSpriteResult { }; SpriteID GetCustomRailSprite(const RailTypeInfo *rti, TileIndex tile, RailTypeSpriteGroup rtsg, TileContext context = TCX_NORMAL, uint *num_results = nullptr); -CustomSignalSpriteResult GetCustomSignalSprite(const RailTypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, uint8 aspect, - CustomSignalSpriteContext context, uint8 style, const TraceRestrictProgram *prog = nullptr, uint z = 0); +CustomSignalSpriteResult GetCustomSignalSprite(const RailTypeInfo *rti, TileIndex tile, SignalType type, SignalVariant var, uint8_t aspect, + CustomSignalSpriteContext context, uint8_t style, const TraceRestrictProgram *prog = nullptr, uint z = 0); -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 9e9db4ebc4..910f21b90a 100644 --- a/src/newgrf_roadstop.cpp +++ b/src/newgrf_roadstop.cpp @@ -48,39 +48,39 @@ 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::GetNearbyRoadStopsInfo(uint32 parameter, RoadStopScopeResolver::NearbyRoadStopInfoMode mode) const +uint32_t RoadStopScopeResolver::GetNearbyRoadStopsInfo(uint32_t parameter, RoadStopScopeResolver::NearbyRoadStopInfoMode mode) const { if (this->tile == INVALID_TILE) return 0xFFFFFFFF; TileIndex nearby_tile = GetNearbyTile(parameter, this->tile); if (!IsAnyRoadStopTile(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 == STATION_ROADWAYPOINT) res |= (2 << 16); if (type == this->type) SetBit(res, 20); - uint16 localidx = 0; + uint16_t localidx = 0; if (IsCustomRoadStopSpecIndex(nearby_tile)) { const RoadStopSpecList ssl = BaseStation::GetByTile(nearby_tile)->roadstop_speclist[GetCustomRoadStopSpecIndex(nearby_tile)]; localidx = ssl.localidx; @@ -93,7 +93,7 @@ uint32 RoadStopScopeResolver::GetNearbyRoadStopsInfo(uint32 parameter, RoadStopS switch (mode) { case NearbyRoadStopInfoMode::Standard: default: - return res | ClampTo(localidx); + return res | ClampTo(localidx); case NearbyRoadStopInfoMode::Extended: return res | (localidx & 0xFF) | ((localidx & 0xFF00) << 16); @@ -103,9 +103,9 @@ uint32 RoadStopScopeResolver::GetNearbyRoadStopsInfo(uint32 parameter, RoadStopS } } -uint32 RoadStopScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +uint32_t RoadStopScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) 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; @@ -160,7 +160,7 @@ uint32 RoadStopScopeResolver::GetVariable(uint16 variable, uint32 parameter, Get /* Misc info */ case 0x50: { - uint32 result = 0; + uint32_t result = 0; if (this->tile != INVALID_TILE) { if (IsDriveThroughStopTile(this->tile)) { result |= GetDriveThroughStopDisallowedRoadDirections(this->tile); @@ -238,7 +238,7 @@ uint32 RoadStopScopeResolver::GetVariable(uint16 variable, uint32 parameter, Get case 0xF0: return this->st == nullptr ? 0 : this->st->facilities; // facilities - case 0xFA: return ClampTo((this->st == nullptr ? _date : this->st->build_date) - DAYS_TILL_ORIGINAL_BASE_YEAR); // build date + case 0xFA: return ClampTo((this->st == nullptr ? _date : this->st->build_date) - DAYS_TILL_ORIGINAL_BASE_YEAR); // build date } if (this->st != nullptr) return this->st->GetNewGRFVariable(this->ro, variable, parameter, &(extra->available)); @@ -254,8 +254,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) { @@ -307,7 +307,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(); @@ -382,7 +382,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)); } @@ -409,7 +409,7 @@ void AnimateRoadStopTile(TileIndex tile) RoadStopAnimationBase::AnimateTile(ss, BaseStation::GetByTile(tile), tile, HasBit(ss->flags, RSF_CB141_RANDOM_BITS)); } -uint8 GetRoadStopTileAnimationSpeed(TileIndex tile) +uint8_t GetRoadStopTileAnimationSpeed(TileIndex tile) { const RoadStopSpec *ss = GetRoadStopSpec(tile); if (ss == nullptr) return 0; @@ -426,7 +426,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)) { @@ -436,7 +436,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)); } }; @@ -468,12 +468,12 @@ void TriggerRoadStopRandomisation(Station *st, TileIndex tile, RoadStopRandomTri SetBit(st->waiting_triggers, trigger); - uint32 whole_reseed = 0; + uint32_t whole_reseed = 0; /* Bitmask of completely empty cargo types to be matched. */ CargoTypes empty_mask = (trigger == RSRT_CARGO_TAKEN) ? GetEmptyMask(st) : 0; - 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; @@ -493,13 +493,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 7e14f66119..3e80665ab5 100644 --- a/src/newgrf_roadstop.h +++ b/src/newgrf_roadstop.h @@ -87,19 +87,19 @@ 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(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override; + uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const override; private: enum class NearbyRoadStopInfoMode { @@ -107,7 +107,7 @@ private: Extended, V2, }; - uint32 GetNearbyRoadStopsInfo(uint32 parameter, NearbyRoadStopInfoMode mode) const; + uint32_t GetNearbyRoadStopsInfo(uint32_t parameter, NearbyRoadStopInfoMode mode) const; }; /** Road stop resolver. */ @@ -115,7 +115,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, VarSpriteGroupScopeOffset relative = 0) override { @@ -150,21 +150,21 @@ struct RoadStopSpec { RoadStopAvailabilityType stop_type = ROADSTOPTYPE_ALL; RoadStopDrawMode draw_mode = ROADSTOP_DRAW_MODE_ROAD | ROADSTOP_DRAW_MODE_OVERLAY; - uint8 callback_mask = 0; - uint16 flags = 0; - uint8 internal_flags = 0; ///< Bitmask of internal spec flags (RoadStopSpecIntlFlags) + uint8_t callback_mask = 0; + uint16_t flags = 0; + uint8_t internal_flags = 0; ///< Bitmask of internal spec flags (RoadStopSpecIntlFlags) - CargoTypes cargo_triggers = 0; ///< Bitmask of cargo types which cause trigger re-randomizing + CargoTypes cargo_triggers = 0; ///< Bitmask of cargo types which cause trigger re-randomizing AnimationInfo animation; - 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 + 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. - uint8 height; ///< The height of this structure, in heightlevels; max MAX_TILE_HEIGHT. + uint8_t height; ///< The height of this structure, in heightlevels; max MAX_TILE_HEIGHT. /** * Get the cost for building a road stop of this type. @@ -178,7 +178,7 @@ 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); }; template <> @@ -188,10 +188,10 @@ typedef NewGRFClass RoadStopC 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 dbc1e9f05f..be843e159e 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(this->tile + (TileX(this->tile) + TileY(this->tile)) * TILE_SIZE); return GB(tmp, 0, 2); } -/* virtual */ uint32 RoadTypeScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +/* virtual */ uint32_t RoadTypeScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) 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 6ffd2a3f57..c207b2b8d2 100644 --- a/src/newgrf_roadtype.h +++ b/src/newgrf_roadtype.h @@ -32,15 +32,15 @@ struct RoadTypeScopeResolver : public ScopeResolver { { } - uint32 GetRandomBits() const override; - uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override; + uint32_t GetRandomBits() const override; + uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const override; }; /** 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, VarSpriteGroupScopeOffset 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 83859d2edf..6ebe74892a 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(); char *name = AllocaM(char, name_len + 1); file.ReadBlock(name, 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 [%s]: Invalid RIFF", file.GetSimplifiedFilename().c_str()); @@ -189,7 +189,7 @@ bool PlayVehicleSound(const Vehicle *v, VehicleSoundEvent event, bool force) if ((!_settings_client.sound.vehicle || _settings_client.music.effect_vol == 0) && !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 ef6ae577a2..6590211cf6 100644 --- a/src/newgrf_spritegroup.cpp +++ b/src/newgrf_spritegroup.cpp @@ -25,7 +25,7 @@ SpriteGroupPool _spritegroup_pool("SpriteGroup"); INSTANTIATE_POOL_METHODS(SpriteGroup) -TemporaryStorageArray _temp_store; +TemporaryStorageArray _temp_store; std::map _deterministic_sg_shadows; std::map _randomized_sg_shadows; @@ -82,9 +82,9 @@ GrfSpecFeature GetGrfSpecFeatureForParentScope(GrfSpecFeature feature) } } -static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *scope, uint16 variable, uint32 parameter, GetVariableExtra *extra) +static inline uint32_t GetVariable(const ResolverObject &object, ScopeResolver *scope, uint16_t variable, uint32_t parameter, GetVariableExtra *extra) { - uint32 value; + uint32_t value; switch (variable) { case 0x0C: return object.callback; case 0x10: return object.callback_param1; @@ -112,7 +112,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; } @@ -121,7 +121,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; } @@ -133,7 +133,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(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +/* virtual */ uint32_t ScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const { DEBUG(grf, 1, "Unhandled scope variable 0x%X", variable); extra->available = false; @@ -143,7 +143,7 @@ static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *sc /** * Store a value into the persistent storage area (PSA). Default implementation does nothing (for newgrf classes without storage). */ -/* virtual */ void ScopeResolver::StorePSA(uint reg, int32 value) {} +/* virtual */ void ScopeResolver::StorePSA(uint reg, int32_t value) {} /** * Get the real sprites of the grf. @@ -170,7 +170,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, const DeterministicSpriteGroupAdjust **adjust_iter = nullptr) +static U EvalAdjustT(const DeterministicSpriteGroupAdjust &adjust, ScopeResolver *scope, U last_value, uint32_t value, const DeterministicSpriteGroupAdjust **adjust_iter = nullptr) { value >>= adjust.shift_num; value &= adjust.and_mask; @@ -212,12 +212,12 @@ 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); case DSGA_OP_TERNARY: return (last_value != 0) ? value : adjust.add_val; case DSGA_OP_EQ: return (last_value == value) ? 1 : 0; case DSGA_OP_SLT: return ((S)last_value < (S)value) ? 1 : 0; @@ -236,12 +236,12 @@ static U EvalAdjustT(const DeterministicSpriteGroupAdjust &adjust, ScopeResolver } } -uint32 EvaluateDeterministicSpriteGroupAdjust(DeterministicSpriteGroupSize size, const DeterministicSpriteGroupAdjust &adjust, ScopeResolver *scope, uint32 last_value, uint32 value) +uint32_t EvaluateDeterministicSpriteGroupAdjust(DeterministicSpriteGroupSize size, const DeterministicSpriteGroupAdjust &adjust, ScopeResolver *scope, uint32_t last_value, uint32_t value) { switch (size) { - case DSG_SIZE_BYTE: return EvalAdjustT (adjust, scope, last_value, value); break; - case DSG_SIZE_WORD: return EvalAdjustT(adjust, scope, last_value, value); break; - case DSG_SIZE_DWORD: return EvalAdjustT(adjust, scope, last_value, value); break; + case DSG_SIZE_BYTE: return EvalAdjustT (adjust, scope, last_value, value); break; + case DSG_SIZE_WORD: return EvalAdjustT(adjust, scope, last_value, value); break; + case DSG_SIZE_DWORD: return EvalAdjustT(adjust, scope, last_value, value); break; default: NOT_REACHED(); } } @@ -258,8 +258,8 @@ const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject &object) con return &cbfail; } - uint32 last_value = 0; - uint32 value = 0; + uint32_t last_value = 0; + uint32_t value = 0; ScopeResolver *scope = object.GetScope(this->var_scope, this->var_scope_count); @@ -313,9 +313,9 @@ const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject &object) con } switch (this->size) { - case DSG_SIZE_BYTE: value = EvalAdjustT (adjust, scope, last_value, value, &iter); break; - case DSG_SIZE_WORD: value = EvalAdjustT(adjust, scope, last_value, value, &iter); break; - case DSG_SIZE_DWORD: value = EvalAdjustT(adjust, scope, last_value, value, &iter); break; + case DSG_SIZE_BYTE: value = EvalAdjustT (adjust, scope, last_value, value, &iter); break; + case DSG_SIZE_WORD: value = EvalAdjustT(adjust, scope, last_value, value, &iter); break; + case DSG_SIZE_DWORD: value = EvalAdjustT(adjust, scope, last_value, value, &iter); break; default: NOT_REACHED(); } last_value = value; @@ -370,7 +370,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); @@ -388,7 +388,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); @@ -396,7 +396,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); @@ -480,7 +480,7 @@ static char *GetAdjustOperationName(char *str, const char *last, DeterministicSp return str + seprintf(str, last, "\?\?\?(0x%X)", operation); } -char *SpriteGroupDumper::DumpSpriteGroupAdjust(char *p, const char *last, const DeterministicSpriteGroupAdjust &adjust, const char *padding, uint32 &highlight_tag, uint &conditional_indent) +char *SpriteGroupDumper::DumpSpriteGroupAdjust(char *p, const char *last, const DeterministicSpriteGroupAdjust &adjust, const char *padding, uint32_t &highlight_tag, uint &conditional_indent) { if (adjust.variable == 0x7D) { /* Temp storage load */ @@ -591,7 +591,7 @@ char *SpriteGroupDumper::DumpSpriteGroupAdjust(char *p, const char *last, const void SpriteGroupDumper::DumpSpriteGroup(const SpriteGroup *sg, const char *padding, uint flags) { - uint32 highlight_tag = 0; + uint32_t highlight_tag = 0; auto print = [&]() { this->print_fn(sg, DSGPO_PRINT, highlight_tag, this->buffer); highlight_tag = 0; @@ -848,7 +848,7 @@ void SpriteGroupDumper::DumpSpriteGroup(const SpriteGroup *sg, const char *paddi } seprintf(b, lastof(this->buffer), ", register flags: %X", reg->flags); print(); - auto log_reg = [&](TileLayoutFlags flag, const char *name, uint8 flag_reg) { + auto log_reg = [&](TileLayoutFlags flag, const char *name, uint8_t flag_reg) { if (reg->flags & flag) { highlight_tag = (1 << 16) | flag_reg; seprintf(this->buffer, lastof(this->buffer), "%s %s reg: %X", padding, name, flag_reg); diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h index 0278605099..f6a2deb81a 100644 --- a/src/newgrf_spritegroup.h +++ b/src/newgrf_spritegroup.h @@ -33,12 +33,12 @@ */ inline uint32_t GetRegister(uint i) { - extern TemporaryStorageArray _temp_store; + extern TemporaryStorageArray _temp_store; return _temp_store.GetValue(i); } /* List of different sprite group types */ -enum SpriteGroupType : uint8 { +enum SpriteGroupType : uint8_t { SGT_REAL, SGT_DETERMINISTIC, SGT_RANDOMIZED, @@ -49,7 +49,7 @@ enum SpriteGroupType : uint8 { }; struct SpriteGroup; -typedef uint32 SpriteGroupID; +typedef uint32_t SpriteGroupID; struct ResolverObject; struct AnalyseCallbackOperation; @@ -59,7 +59,7 @@ struct AnalyseCallbackOperation; typedef Pool SpriteGroupPool; extern SpriteGroupPool _spritegroup_pool; -enum SpriteGroupFlags : uint8 { +enum SpriteGroupFlags : uint8_t { SGF_NONE = 0, SGF_ACTION6 = 1 << 0, SGF_INLINING = 1 << 1, @@ -77,14 +77,14 @@ protected: public: virtual ~SpriteGroup() = default; - uint32 nfo_line; + uint32_t nfo_line; SpriteGroupType type; GrfSpecFeature feature; SpriteGroupFlags sg_flags = SGF_NONE; 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; } virtual void AnalyseCallbacks(AnalyseCallbackOperation &op) const {}; static const SpriteGroup *Resolve(const SpriteGroup *group, ResolverObject &object, bool top_level = true); @@ -113,7 +113,7 @@ protected: }; /* Shared by deterministic and random groups. */ -enum VarSpriteGroupScope : uint8 { +enum VarSpriteGroupScope : uint8_t { VSG_BEGIN, VSG_SCOPE_SELF = VSG_BEGIN, ///< Resolved object itself @@ -124,7 +124,7 @@ enum VarSpriteGroupScope : uint8 { }; DECLARE_POSTFIX_INCREMENT(VarSpriteGroupScope) -enum VarSpriteGroupScopeRelativeMode : uint8 { +enum VarSpriteGroupScopeRelativeMode : uint8_t { VSGSRM_BACKWARD_SELF = 0, VSGSRM_FORWARD_SELF = 1, VSGSRM_BACKWARD_ENGINE = 2, @@ -138,7 +138,7 @@ enum VarSpriteGroupScopeRelativeMode : uint8 { * Bits 8..9: mode (VarSpriteGroupScopeRelativeMode) * Bit 15: use var 0x100 */ -typedef uint16 VarSpriteGroupScopeOffset; +typedef uint16_t VarSpriteGroupScopeOffset; GrfSpecFeature GetGrfSpecFeatureForParentScope(GrfSpecFeature feature); @@ -151,13 +151,13 @@ inline GrfSpecFeature GetGrfSpecFeatureForScope(GrfSpecFeature feature, VarSprit return feature; } -enum DeterministicSpriteGroupSize : uint8 { +enum DeterministicSpriteGroupSize : uint8_t { DSG_SIZE_BYTE, DSG_SIZE_WORD, DSG_SIZE_DWORD, }; -enum DeterministicSpriteGroupAdjustType : uint8 { +enum DeterministicSpriteGroupAdjustType : uint8_t { DSGA_TYPE_NONE, DSGA_TYPE_DIV, DSGA_TYPE_MOD, @@ -166,7 +166,7 @@ enum DeterministicSpriteGroupAdjustType : uint8 { DSGA_TYPE_NEQ, }; -enum DeterministicSpriteGroupAdjustOperation : uint8 { +enum DeterministicSpriteGroupAdjustOperation : uint8_t { DSGA_OP_ADD, ///< a + b DSGA_OP_SUB, ///< a - b DSGA_OP_SMIN, ///< (signed) min(a, b) @@ -214,7 +214,7 @@ enum DeterministicSpriteGroupAdjustOperation : uint8 { static_assert((DSGA_OP_SLT ^ 1) == DSGA_OP_SGE); static_assert((DSGA_OP_SLE ^ 1) == DSGA_OP_SGT); -enum DeterministicSpriteGroupAdjustFlags : uint8 { +enum DeterministicSpriteGroupAdjustFlags : uint8_t { DSGAF_NONE = 0, DSGAF_SKIP_ON_ZERO = 1 << 0, DSGAF_SKIP_ON_LSB_SET = 1 << 1, @@ -379,7 +379,7 @@ inline DeterministicSpriteGroupAdjustOperation InvertEvalAdjustRelationalCompari return (DeterministicSpriteGroupAdjustOperation)(op ^ 1); } -inline bool IsEvalAdjustOperationOnConstantEffectiveLoad(DeterministicSpriteGroupAdjustOperation op, uint32 constant) +inline bool IsEvalAdjustOperationOnConstantEffectiveLoad(DeterministicSpriteGroupAdjustOperation op, uint32_t constant) { switch (op) { case DSGA_OP_ADD: @@ -451,26 +451,26 @@ inline DeterministicSpriteGroupAdjustType InvertConstantComparisonAdjustType(Det struct DeterministicSpriteGroupAdjust { DeterministicSpriteGroupAdjustOperation operation; DeterministicSpriteGroupAdjustType type; - uint16 variable; + uint16_t variable; byte shift_num; DeterministicSpriteGroupAdjustFlags adjust_flags = DSGAF_NONE; - uint32 parameter; ///< Used for variables between 0x60 and 0x7F inclusive. - uint32 and_mask; - uint32 add_val; ///< Also used for DSGA_TYPE_EQ/DSGA_TYPE_NEQ constants and DSGA_OP_TERNARY false value - uint32 divmod_val; ///< Also used for DSGA_OP_STO_NC + uint32_t parameter; ///< Used for variables between 0x60 and 0x7F inclusive. + uint32_t and_mask; + uint32_t add_val; ///< Also used for DSGA_TYPE_EQ/DSGA_TYPE_NEQ constants and DSGA_OP_TERNARY false value + uint32_t divmod_val; ///< Also used for DSGA_OP_STO_NC union { const SpriteGroup *subroutine; - uint32 jump; + uint32_t jump; }; }; struct DeterministicSpriteGroupRange { const SpriteGroup *group; - uint32 low; - uint32 high; + uint32_t low; + uint32_t high; }; -enum DeterministicSpriteGroupFlags : uint8 { +enum DeterministicSpriteGroupFlags : uint8_t { DSGF_NONE = 0, DSGF_NO_DSE = 1 << 0, DSGF_CB_RESULT = 1 << 1, @@ -513,7 +513,7 @@ protected: const SpriteGroup *Resolve(ResolverObject &object) const override; }; -enum RandomizedSpriteGroupCompareMode : uint8 { +enum RandomizedSpriteGroupCompareMode : uint8_t { RSG_CMP_ANY, RSG_CMP_ALL, }; @@ -552,7 +552,7 @@ struct CallbackResultSpriteGroup : SpriteGroup { * Creates a spritegroup representing a callback result * @param result The result as returned from TransformResultValue */ - CallbackResultSpriteGroup(uint16 result) : + CallbackResultSpriteGroup(uint16_t result) : SpriteGroup(SGT_CALLBACK), result(result) {} @@ -561,7 +561,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. */ - static uint16 TransformResultValue(uint16 value, bool grf_version8) + static uint16_t TransformResultValue(uint16_t value, bool grf_version8) { /* Old style callback results (only valid for version < 8) have the highest byte 0xFF so signify it is a callback result. * New style ones only have the highest bit set (allows 15-bit results, instead of just 8) */ @@ -572,8 +572,8 @@ struct CallbackResultSpriteGroup : SpriteGroup { } } - uint16 result; - uint16 GetCallbackResult() const override { return this->result; } + uint16_t result; + uint16_t GetCallbackResult() const override { return this->result; } void AnalyseCallbacks(AnalyseCallbackOperation &op) const override; }; @@ -609,28 +609,28 @@ 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+) - 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+) - CargoID cargo_output[INDUSTRY_NUM_OUTPUTS]; ///< Which output cargoes to add to (only cb version 2) - uint8 again; + 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_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_t again; }; struct GetVariableExtra { bool available; - uint32 mask; + uint32_t mask; - GetVariableExtra(uint32 mask_ = 0xFFFFFFFF) + GetVariableExtra(uint32_t mask_ = 0xFFFFFFFF) : available(true), mask(mask_) {} }; @@ -646,11 +646,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(uint16 variable, uint32 parameter, GetVariableExtra *extra) const; - virtual void StorePSA(uint reg, int32 value); + virtual uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const; + virtual void StorePSA(uint reg, int32_t value); }; /** @@ -667,7 +667,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(); @@ -675,19 +675,19 @@ struct ResolverObject { virtual ~ResolverObject() = default; - ScopeResolver default_scope; ///< Default implementation of the grf scope. + 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. + CallbackID callback; ///< Callback being resolved. + 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 GRFFile *grffile; ///< GRFFile the resolved SpriteGroup belongs to const SpriteGroup *root_spritegroup; ///< Root SpriteGroup to use for resolving /** @@ -703,7 +703,7 @@ struct ResolverObject { * Resolve callback. * @return Callback result. */ - uint16 ResolveCallback() + uint16_t ResolveCallback() { const SpriteGroup *result = Resolve(); return result != nullptr ? result->GetCallbackResult() : CALLBACK_FAILED; @@ -716,7 +716,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; } @@ -726,9 +726,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]; } @@ -757,7 +757,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; } }; enum DumpSpriteGroupPrintOp { @@ -767,7 +767,7 @@ enum DumpSpriteGroupPrintOp { DSGPO_NFO_LINE, }; -using DumpSpriteGroupPrinter = std::function; +using DumpSpriteGroupPrinter = std::function; struct SpriteGroupDumper { bool use_shadows = false; @@ -786,7 +786,7 @@ private: SGDF_RANGE = 1 << 1, }; - char *DumpSpriteGroupAdjust(char *p, const char *last, const DeterministicSpriteGroupAdjust &adjust, const char *padding, uint32 &highlight_tag, uint &conditional_indent); + char *DumpSpriteGroupAdjust(char *p, const char *last, const DeterministicSpriteGroupAdjust &adjust, const char *padding, uint32_t &highlight_tag, uint &conditional_indent); void DumpSpriteGroup(const SpriteGroup *sg, const char *prefix, uint flags); public: @@ -803,6 +803,6 @@ public: } }; -uint32 EvaluateDeterministicSpriteGroupAdjust(DeterministicSpriteGroupSize size, const DeterministicSpriteGroupAdjust &adjust, ScopeResolver *scope, uint32 last_value, uint32 value); +uint32_t EvaluateDeterministicSpriteGroupAdjust(DeterministicSpriteGroupSize size, const DeterministicSpriteGroupAdjust &adjust, ScopeResolver *scope, uint32_t last_value, uint32_t value); #endif /* NEWGRF_SPRITEGROUP_H */ diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index f1527cec7e..41b54d4910 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -28,7 +28,7 @@ #include "safeguards.h" -uint64 _station_tile_cache_hash = 0; +uint64_t _station_tile_cache_hash = 0; template /* static */ void NewGRFClass::InsertDefaults() @@ -102,9 +102,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); @@ -163,7 +163,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); @@ -179,7 +179,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 }; @@ -195,7 +195,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++) { @@ -221,13 +221,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; } @@ -239,13 +239,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; /** @@ -268,18 +268,18 @@ TownScopeResolver *StationResolverObject::GetTown() return this->town_scope; } -uint32 StationScopeResolver::GetNearbyStationInfo(uint32 parameter, StationScopeResolver::NearbyStationInfoMode mode) const +uint32_t StationScopeResolver::GetNearbyStationInfo(uint32_t parameter, StationScopeResolver::NearbyStationInfoMode mode) const { TileIndex nearby_tile = GetNearbyTile(parameter, this->tile); 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; - uint16 localidx = 0; + uint16_t localidx = 0; if (IsCustomStationSpecIndex(nearby_tile)) { const StationSpecList ssl = BaseStation::GetByTile(nearby_tile)->speclist[GetCustomStationSpecIndex(nearby_tile)]; localidx = ssl.localidx; @@ -289,14 +289,14 @@ uint32 StationScopeResolver::GetNearbyStationInfo(uint32 parameter, StationScope switch (mode) { case NearbyStationInfoMode::Standard: default: - return res | ClampTo(localidx); + return res | ClampTo(localidx); case NearbyStationInfoMode::V2: return (res << 8) | localidx; } } -/* virtual */ uint32 StationScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +/* virtual */ uint32_t StationScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const { if (this->st == nullptr) { /* Station does not exist, so we're in a purchase list or the land slope check callback. */ @@ -314,7 +314,7 @@ uint32 StationScopeResolver::GetNearbyStationInfo(uint32 parameter, StationScope TileIndex tile = this->tile; if (parameter != 0) tile = GetNearbyTile(parameter, tile, true, this->axis); // only perform if it is required - uint32 result = GetNearbyTileInformation(tile, this->ro.grffile->grf_version >= 8, extra->mask); + uint32_t result = GetNearbyTileInformation(tile, this->ro.grffile->grf_version >= 8, extra->mask); if (extra->mask & SLOPE_EW) { Slope tileh = GetTileSlope(tile); if (this->axis == AXIS_Y && HasBit(tileh, CORNER_W) != HasBit(tileh, CORNER_E)) result ^= SLOPE_EW; @@ -323,7 +323,7 @@ uint32 StationScopeResolver::GetNearbyStationInfo(uint32 parameter, StationScope } break; - case 0xFA: return ClampTo(_date - DAYS_TILL_ORIGINAL_BASE_YEAR); // Build date, clamped to a 16 bit value + case 0xFA: return ClampTo(_date - DAYS_TILL_ORIGINAL_BASE_YEAR); // Build date, clamped to a 16 bit value } extra->available = false; @@ -375,7 +375,7 @@ uint32 StationScopeResolver::GetNearbyStationInfo(uint32 parameter, StationScope TileIndex tile = this->tile; if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required - uint32 result = GetNearbyTileInformation(tile, this->ro.grffile->grf_version >= 8, extra->mask); + uint32_t result = GetNearbyTileInformation(tile, this->ro.grffile->grf_version >= 8, extra->mask); if (extra->mask & SLOPE_EW) { Slope tileh = GetTileSlope(tile); if (axis == AXIS_Y && HasBit(tileh, CORNER_W) != HasBit(tileh, CORNER_E)) result ^= SLOPE_EW; @@ -414,7 +414,7 @@ uint32 StationScopeResolver::GetNearbyStationInfo(uint32 parameter, StationScope return this->st->GetNewGRFVariable(this->ro, variable, parameter, &(extra->available)); } -uint32 Station::GetNewGRFVariable(const ResolverObject &object, uint16 variable, byte parameter, bool *available) const +uint32_t Station::GetNewGRFVariable(const ResolverObject &object, uint16_t variable, byte parameter, bool *available) const { switch (variable) { case 0x48: { // Accepted cargo types @@ -444,7 +444,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject &object, uint16 variable, const GoodsEntry *ge = &this->goods[c]; switch (variable) { - case 0x60: return std::min(ge->CargoTotalCount(), 4095); + case 0x60: return std::min(ge->CargoTotalCount(), 4095); case 0x61: return ge->HasVehicleEverTriedLoading() && ge->IsSupplyAllowed() ? ge->time_since_pickup : 0; case 0x62: return ge->HasRating() ? ge->rating : 0xFFFFFFFF; case 0x63: return ge->data != nullptr ? ge->data->cargo.PeriodsInTransit() : 0; @@ -480,7 +480,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject &object, uint16 variable, return UINT_MAX; } -uint32 Waypoint::GetNewGRFVariable(const ResolverObject &object, uint16 variable, byte parameter, bool *available) const +uint32_t Waypoint::GetNewGRFVariable(const ResolverObject &object, uint16_t variable, byte parameter, bool *available) const { switch (variable) { case 0x48: return 0; // Accepted cargo types @@ -562,7 +562,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; } @@ -578,7 +578,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, RailType rt, - 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, rt), town_scope(nullptr) { @@ -625,7 +625,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, RailType rt, uint32 var10) +SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, RailType rt, uint32_t var10) { StationResolverObject object(statspec, st, tile, rt, CBID_NO_CALLBACK, var10); const SpriteGroup *group = object.Resolve(); @@ -655,7 +655,7 @@ SpriteID GetCustomStationFoundationRelocation(const StationSpec *statspec, BaseS } -uint16 GetStationCallback(CallbackID callback, uint32 param1, uint32 param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, RailType rt) +uint16_t GetStationCallback(CallbackID callback, uint32_t param1, uint32_t param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, RailType rt) { StationResolverObject object(statspec, st, tile, rt, callback, param1, param2); return object.ResolveCallback(); @@ -681,7 +681,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(); @@ -800,13 +800,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, railtype); + uint16_t callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0, 0, statspec, nullptr, INVALID_TILE, railtype); 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; @@ -823,9 +823,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, railtype, 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, railtype, var10); layout->ProcessRegisters(var10, var10_relocation, separate_ground); } @@ -870,7 +870,7 @@ const StationSpec *GetStationSpec(TileIndex t) } /** 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, INVALID_RAILTYPE); } @@ -892,7 +892,7 @@ void AnimateStationTile(TileIndex tile) StationAnimationBase::AnimateTile(ss, BaseStation::GetByTile(tile), tile, HasBit(ss->flags, SSF_CB141_RANDOM_BITS)); } -uint8 GetStationTileAnimationSpeed(TileIndex tile) +uint8_t GetStationTileAnimationSpeed(TileIndex tile) { const StationSpec *ss = GetStationSpec(tile); if (ss == nullptr) return 0; @@ -914,7 +914,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 */ @@ -928,7 +928,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)); } } } @@ -956,7 +956,7 @@ void TriggerStationRandomisation(Station *st, TileIndex trigger_tile, StationRan if (st->cached_cargo_triggers == 0) return; if (cargo_type != CT_INVALID && !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]); /* Bitmask of completely empty cargo types to be matched. */ @@ -964,7 +964,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) { @@ -987,13 +987,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 77b7ddfdc9..9a5864840e 100644 --- a/src/newgrf_station.h +++ b/src/newgrf_station.h @@ -43,17 +43,17 @@ struct StationScopeResolver : public ScopeResolver { { } - uint32 GetRandomBits() const override; - uint32 GetTriggers() const override; + uint32_t GetRandomBits() const override; + uint32_t GetTriggers() const override; - uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override; + uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const override; private: enum class NearbyStationInfoMode { Standard, V2, }; - uint32 GetNearbyStationInfo(uint32 parameter, NearbyStationInfoMode mode) const; + uint32_t GetNearbyStationInfo(uint32_t parameter, NearbyStationInfoMode mode) const; }; /** Station resolver. */ @@ -62,7 +62,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, RailType rt, - 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(); @@ -87,7 +87,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 { @@ -166,7 +166,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 @@ -201,11 +201,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, RailType rt, uint32 var10 = 0); +SpriteID GetCustomStationRelocation(const StationSpec *statspec, BaseStation *st, TileIndex tile, RailType rt, 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, RailType rt); +uint16_t GetStationCallback(CallbackID callback, uint32_t param1, uint32_t param2, const StationSpec *statspec, BaseStation *st, TileIndex tile, RailType rt); CommandCost PerformStationTileSlopeCheck(TileIndex north_tile, TileIndex cur_tile, RailType rt, const StationSpec *statspec, Axis axis, byte plat_len, byte numtracks); /* Allocate a StationSpec to a Station. This is called once per build operation. */ @@ -218,7 +218,7 @@ void DeallocateSpecFromStation(BaseStation *st, byte specindex); bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station); void AnimateStationTile(TileIndex tile); -uint8 GetStationTileAnimationSpeed(TileIndex tile); +uint8_t GetStationTileAnimationSpeed(TileIndex tile); void TriggerStationAnimation(BaseStation *st, TileIndex tile, StationAnimationTrigger trigger, CargoID cargo_type = CT_INVALID); void TriggerStationRandomisation(Station *st, TileIndex tile, StationRandomTrigger trigger, CargoID cargo_type = CT_INVALID); void StationUpdateCachedTriggers(BaseStation *st); diff --git a/src/newgrf_storage.h b/src/newgrf_storage.h index 70540c386f..80529c64ee 100644 --- a/src/newgrf_storage.h +++ b/src/newgrf_storage.h @@ -32,7 +32,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. @@ -78,7 +78,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; @@ -144,7 +144,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; @@ -185,9 +185,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; @@ -197,9 +197,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 8bb6e45993..c1a6654293 100644 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -73,8 +73,8 @@ enum GRFExtendedLanguages { struct GRFTextEntry { GRFTextList textholder; StringID def_string; - uint32 grfid; - uint16 stringid; + uint32_t grfid; + uint16_t stringid; }; @@ -164,13 +164,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; @@ -240,7 +240,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; @@ -249,7 +249,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) { @@ -263,7 +263,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); @@ -312,8 +312,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; @@ -357,8 +357,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; @@ -517,7 +517,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)); } @@ -531,7 +531,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); @@ -552,7 +552,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 @@ -573,7 +573,7 @@ StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool ne } uint id; - extern GRFFile *GetFileByGRFIDExpectCurrent(uint32 grfid); + extern GRFFile *GetFileByGRFIDExpectCurrent(uint32_t grfid); GRFFile *grf = GetFileByGRFIDExpectCurrent(grfid); if (grf == nullptr) return STR_EMPTY; @@ -609,11 +609,11 @@ 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) { if (stringid > UINT16_MAX) return STR_UNDEFINED; - extern GRFFile *GetFileByGRFIDExpectCurrent(uint32 grfid); + extern GRFFile *GetFileByGRFIDExpectCurrent(uint32_t grfid); GRFFile *grf = GetFileByGRFIDExpectCurrent(grfid); if (unlikely(grf == nullptr)) { for (uint id = 0; id < (uint)_grf_text.size(); id++) { @@ -670,7 +670,7 @@ const char *GetDefaultLangGRFStringFromGRFText(const GRFTextList &text_list) return default_text; } -static std::array, 16> _grf_string_ptr_log; +static std::array, 16> _grf_string_ptr_log; static unsigned int _grf_string_ptr_log_next = 0; /** @@ -693,7 +693,7 @@ const char *GetDefaultLangGRFStringFromGRFText(const GRFTextWrapper &text) /** * Get a C-string from a stringid set by a newgrf. */ -const char *GetGRFStringPtr(uint32 stringid) +const char *GetGRFStringPtr(uint32_t stringid) { #if 0 assert_msg(stringid < _grf_text.size(), "stringid: %u, size: %u", stringid, (uint)_grf_text.size()); @@ -711,7 +711,7 @@ const char *GetGRFStringPtr(uint32 stringid) str = GetStringPtr(_grf_text[stringid].def_string); } - _grf_string_ptr_log[_grf_string_ptr_log_next] = std::pair(stringid, str); + _grf_string_ptr_log[_grf_string_ptr_log_next] = std::pair(stringid, str); _grf_string_ptr_log_next = (_grf_string_ptr_log_next + 1) % _grf_string_ptr_log.size(); return str; @@ -768,29 +768,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() @@ -801,7 +801,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; @@ -871,15 +871,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++; @@ -906,10 +906,10 @@ uint RemapNewGRFStringControlCode(uint scc, std::string *buffer, const char **st { auto too_many_newgrf_params = [&]() { const char *buffer = *str; - uint32 grfid = 0; + uint32_t grfid = 0; for (uint entry = 0; entry < _grf_string_ptr_log.size(); entry++) { const char *txt = _grf_string_ptr_log[entry].second; - uint32 stringid = _grf_string_ptr_log[entry].first; + uint32_t stringid = _grf_string_ptr_log[entry].first; if (txt != nullptr && buffer >= txt && buffer < txt + 8192 && buffer < txt + strlen(txt) && @@ -919,7 +919,7 @@ uint RemapNewGRFStringControlCode(uint scc, std::string *buffer, const char **st } } if (grfid) { - extern GRFFile *GetFileByGRFID(uint32 grfid); + extern GRFFile *GetFileByGRFID(uint32_t grfid); const GRFFile *grffile = GetFileByGRFID(grfid); DEBUG(misc, 0, "Too many NewGRF string parameters (in %X, %s).", BSWAP32(grfid), grffile ? grffile->filename.c_str() : "????"); } else { @@ -1117,7 +1117,7 @@ uint RemapNewGRFStringControlCode(uint scc, std::string *buffer, const char **st } } -uint32 GetStringGRFID(StringID string) +uint32_t GetStringGRFID(StringID string) { switch (GetStringTab(string)) { case TEXT_TAB_NEWGRF_START: diff --git a/src/newgrf_text.h b/src/newgrf_text.h index 4252ff5559..a1bd184f41 100644 --- a/src/newgrf_text.h +++ b/src/newgrf_text.h @@ -18,7 +18,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 { @@ -31,23 +31,23 @@ 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 *GetDefaultLangGRFStringFromGRFText(const GRFTextList &text_list); const char *GetDefaultLangGRFStringFromGRFText(const GRFTextWrapper &text); -const char *GetGRFStringPtr(uint32 stringid); +const char *GetGRFStringPtr(uint32_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(); bool UsingNewGRFTextStack(); struct TextRefStack *CreateTextRefStackBackup(); @@ -76,7 +76,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 36461b9418..abec5c22fc 100644 --- a/src/newgrf_town.cpp +++ b/src/newgrf_town.cpp @@ -15,7 +15,7 @@ #include "safeguards.h" -/* virtual */ uint32 TownScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +/* virtual */ uint32_t TownScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const { switch (variable) { /* Larger towns */ @@ -30,7 +30,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; @@ -129,7 +129,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; @@ -138,7 +138,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; @@ -159,7 +159,7 @@ t->psa_list.push_back(psa); } -/* virtual */ uint32 FakeTownScopeResolver::GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const +/* virtual */ uint32_t FakeTownScopeResolver::GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const { switch (variable) { /* Town index */ diff --git a/src/newgrf_town.h b/src/newgrf_town.h index 332f43c733..2700c73ce0 100644 --- a/src/newgrf_town.h +++ b/src/newgrf_town.h @@ -34,8 +34,8 @@ struct TownScopeResolver : public ScopeResolver { { } - virtual uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override; - virtual void StorePSA(uint reg, int32 value) override; + virtual uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const override; + virtual void StorePSA(uint reg, int32_t value) override; }; /** @@ -53,7 +53,7 @@ struct FakeTownScopeResolver : public ScopeResolver { FakeTownScopeResolver(ResolverObject &ro) : ScopeResolver(ro) { } - virtual uint32 GetVariable(uint16 variable, uint32 parameter, GetVariableExtra *extra) const override; + virtual uint32_t GetVariable(uint16_t variable, uint32_t parameter, GetVariableExtra *extra) const override; }; /** Resolver of town properties. */ diff --git a/src/news_func.h b/src/news_func.h index 0e38d75f39..4c2b5050a5 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); inline void AddCompanyNewsItem(StringID string, CompanyNewsInformation *cni) { diff --git a/src/news_gui.cpp b/src/news_gui.cpp index c5b689bbc3..aeed218b0a 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -68,7 +68,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; @@ -261,8 +261,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). @@ -338,7 +338,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; @@ -805,7 +805,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(_date), type(type), flags(flags), reftype1(reftype1), reftype2(reftype2), ref1(ref1), ref2(ref2), data(data) { /* show this news message in colour? */ @@ -826,7 +826,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; @@ -866,7 +866,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(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdCustomNewsItem(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; diff --git a/src/news_type.h b/src/news_type.h index 44d40f1a9a..69afa792c9 100644 --- a/src/news_type.h +++ b/src/news_type.h @@ -134,14 +134,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. */ @@ -161,8 +161,8 @@ 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 - byte colour; ///< The colour related to the company + 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 eb96b461a3..3baa178583 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(); void ShowBuildObjectPickerAndSelect(const ObjectSpec *spec); diff --git a/src/object_base.h b/src/object_base.h index a0e791e8c0..ebce6dcde3 100644 --- a/src/object_base.h +++ b/src/object_base.h @@ -65,7 +65,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) { dbg_assert(type < NUM_OBJECTS); if (type >= counts.size()) return 0; @@ -79,7 +79,7 @@ struct Object : ObjectPool::PoolItem<&_object_pool> { } protected: - static std::vector counts; ///< Number of objects per type ingame + static std::vector counts; ///< Number of objects per type ingame }; /** diff --git a/src/object_cmd.cpp b/src/object_cmd.cpp index f6f155229d..0e500ebf97 100644 --- a/src/object_cmd.cpp +++ b/src/object_cmd.cpp @@ -41,7 +41,7 @@ ObjectPool _object_pool("Object"); INSTANTIATE_POOL_METHODS(Object) -std::vector Object::counts; +std::vector Object::counts; /** * Get the object associated with a tile. @@ -90,7 +90,7 @@ void SetObjectFoundationType(TileIndex tile, Slope tileh, ObjectType type, const return; } - uint8 flags = spec->edge_foundation[Object::GetByTile(tile)->view]; + uint8_t flags = spec->edge_foundation[Object::GetByTile(tile)->view]; DiagDirection edge = (DiagDirection)GB(flags, 0, 2); Slope incline = InclinedSlope(edge); @@ -133,7 +133,7 @@ void SetObjectFoundationType(TileIndex tile, Slope tileh, ObjectType type, const * @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); @@ -158,7 +158,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); @@ -264,13 +264,13 @@ static CommandCost ClearTile_Object(TileIndex tile, DoCommandFlag flags); * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { CommandCost cost(EXPENSES_CONSTRUCTION); ObjectType type = (ObjectType)GB(p1, 0, 16); if (type >= ObjectSpec::Count()) return CMD_ERROR; - uint8 view = GB(p2, 0, 2); + uint8_t view = GB(p2, 0, 2); const ObjectSpec *spec = ObjectSpec::Get(type); if (_game_mode == GM_NORMAL && !spec->IsAvailable() && !_generating_world) return CMD_ERROR; if ((_game_mode == GM_EDITOR || _generating_world) && !spec->WasEverAvailable()) return CMD_ERROR; @@ -333,7 +333,7 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 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); @@ -459,7 +459,7 @@ CommandCost CmdBuildObject(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdPurchaseLandArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdPurchaseLandArea(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (p1 >= MapSize()) return CMD_ERROR; if (_settings_game.construction.purchase_land_permitted == 0) return_cmd_error(STR_PURCHASE_LAND_NOT_PERMITTED); @@ -515,14 +515,14 @@ CommandCost CmdPurchaseLandArea(TileIndex tile, DoCommandFlag flags, uint32 p1, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildObjectArea(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildObjectArea(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (p1 >= MapSize()) return CMD_ERROR; if (!_settings_game.construction.build_object_area_permitted) return_cmd_error(STR_BUILD_OBJECT_NOT_PERMITTED_BULK); ObjectType type = (ObjectType)GB(p2, 3, 16); if (type >= ObjectSpec::Count()) return CMD_ERROR; - uint8 view = GB(p2, 1, 2); + uint8_t view = GB(p2, 1, 2); const ObjectSpec *spec = ObjectSpec::Get(type); if (view >= spec->views) return CMD_ERROR; @@ -582,7 +582,7 @@ static void DrawTile_Object(TileInfo *ti, DrawTileProcParams params) type = OBJECT_TRANSMITTER; } else if ((spec->flags & OBJECT_FLAG_HAS_NO_FOUNDATION) == 0) { if (spec->ctrl_flags & OBJECT_CTRL_FLAG_EDGE_FOUNDATION) { - uint8 flags = spec->edge_foundation[obj->view]; + uint8_t flags = spec->edge_foundation[obj->view]; DiagDirection edge = (DiagDirection)GB(flags, 0, 2); Slope incline = InclinedSlope(edge); Foundation foundation = GetFoundation_Object(ti->tile, ti->tileh); @@ -1105,7 +1105,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) { @@ -1131,7 +1131,7 @@ void GenerateObjects() break; default: - uint8 view = RandomRange(spec.views); + uint8_t view = RandomRange(spec.views); if (CmdBuildObject(RandomTile(), DC_EXEC | DC_AUTO | DC_NO_TEST_TOWN_RATING | DC_NO_MODIFY_TOWN_RATING, spec.Index(), view, nullptr).Succeeded()) amount--; break; } @@ -1175,7 +1175,7 @@ static void ChangeTileOwner_Object(TileIndex tile, Owner old_owner, Owner new_ow static int GetObjectEffectiveZ(TileIndex tile, const ObjectSpec *spec, int z, Slope tileh) { if ((spec->ctrl_flags & OBJECT_CTRL_FLAG_EDGE_FOUNDATION) && !(spec->flags & OBJECT_FLAG_HAS_NO_FOUNDATION)) { - uint8 flags = spec->edge_foundation[Object::GetByTile(tile)->view]; + uint8_t flags = spec->edge_foundation[Object::GetByTile(tile)->view]; DiagDirection edge = (DiagDirection)GB(flags, 0, 2); if (!(flags & OBJECT_EF_FLAG_FOUNDATION_LOWER) && !(tileh & InclinedSlope(edge))) return z; } @@ -1215,7 +1215,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)) { pre_success_checks(); return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]); diff --git a/src/object_gui.cpp b/src/object_gui.cpp index a86f996859..18194fb22c 100644 --- a/src/object_gui.cpp +++ b/src/object_gui.cpp @@ -34,7 +34,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 { @@ -384,7 +384,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 602b795a02..c78ee54958 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 3d6899ff30..0ec662e14a 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -127,7 +127,7 @@ extern void RebuildTownCaches(bool cargo_update_required, bool old_map_position) extern void ShowOSErrorBox(const char *buf, bool system); extern void NORETURN DoOSAbort(); extern std::string _config_file; -extern uint64 _station_tile_cache_hash; +extern uint64_t _station_tile_cache_hash; bool _save_config = false; bool _request_newgrf_scan = false; @@ -236,7 +236,7 @@ void CDECL assert_msg_error(int line, const char *file, const char *expr, const DoOSAbort(); } -const char *assert_tile_info(uint32 tile) { +const char *assert_tile_info(uint32_t tile) { static char buffer[128]; DumpTileInfo(buffer, lastof(buffer), tile); return buffer; @@ -346,7 +346,7 @@ static void WriteSavegameInfo(const char *name) extern SaveLoadVersion _sl_version; extern std::string _sl_xv_version_label; extern SaveLoadVersion _sl_xv_upstream_version; - uint32 last_ottd_rev = 0; + uint32_t last_ottd_rev = 0; byte ever_modified = 0; bool removed_newgrfs = false; @@ -617,14 +617,14 @@ void OpenBrowser(const std::string &url) /** Callback structure of statements to be executed after the NewGRF scan. */ struct AfterNewGRFScan : NewGRFScanCallback { - Year startyear = INVALID_YEAR; ///< The start year. - uint32 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. - 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. - bool save_config = true; ///< The save config setting. + Year startyear = INVALID_YEAR; ///< The start year. + uint32_t generation_seed = GENERATE_NEW_SEED; ///< Seed for the new game. + std::string dedicated_host; ///< Hostname 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. + bool save_config = true; ///< The save config setting. /** * Create a new callback. @@ -1510,7 +1510,7 @@ void WriteVehicleInfo(char *&p, const char *last, const Vehicle *u, const Vehicl (int)u->type, u->index, v->index, (int)u->owner, v->unitnumber, length); SetDParam(0, u->engine_type); p = strecpy(p, GetString(STR_ENGINE_NAME).c_str(), last, true); - uint32 grfid = u->GetGRFID(); + uint32_t grfid = u->GetGRFID(); if (grfid) { p += seprintf(p, last, ", GRF: %08X", BSWAP32(grfid)); GRFConfig *grfconfig = GetGRFConfig(grfid); @@ -1944,7 +1944,7 @@ void CheckCaches(bool force_check, std::function log, CheckC for (Vehicle *v : Vehicle::Iterate()) { Money old_feeder_share = v->cargo.GetFeederShare(); uint old_count = v->cargo.TotalCount(); - uint64 old_cargo_periods_in_transit = v->cargo.CargoPeriodsInTransit(); + uint64_t old_cargo_periods_in_transit = v->cargo.CargoPeriodsInTransit(); v->cargo.InvalidateCache(); @@ -1965,7 +1965,7 @@ void CheckCaches(bool force_check, std::function log, CheckC if (st->goods[c].data == nullptr) continue; uint old_count = st->goods[c].data->cargo.TotalCount(); - uint64 old_cargo_periods_in_transit = st->goods[c].data->cargo.CargoPeriodsInTransit(); + uint64_t old_cargo_periods_in_transit = st->goods[c].data->cargo.CargoPeriodsInTransit(); st->goods[c].data->cargo.InvalidateCache(); @@ -2031,7 +2031,7 @@ void CheckCaches(bool force_check, std::function log, CheckC if (!CargoPacket::ValidateDeferredCargoPayments()) CCLOG("Cargo packets deferred payments validation failed"); if (_order_destination_refcount_map_valid) { - btree::btree_map saved_order_destination_refcount_map = std::move(_order_destination_refcount_map); + btree::btree_map saved_order_destination_refcount_map = std::move(_order_destination_refcount_map); for (auto iter = saved_order_destination_refcount_map.begin(); iter != saved_order_destination_refcount_map.end();) { if (iter->second == 0) { iter = saved_order_destination_refcount_map.erase(iter); @@ -2069,7 +2069,7 @@ void CheckCaches(bool force_check, std::function log, CheckC * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdDesyncCheck(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdDesyncCheck(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (flags & DC_EXEC) { CheckCaches(true, nullptr, CHECK_CACHE_ALL | CHECK_CACHE_EMIT_LOG); @@ -2183,7 +2183,7 @@ void StateGameLoop() if (_networking) { RecordSyncEvent(NSRE_PRE_COMPANY_STATE); for (Company *c : Company::Iterate()) { - DEBUG_UPDATESTATECHECKSUM("Company: %u, Money: " OTTD_PRINTF64, c->index, (int64)c->money); + DEBUG_UPDATESTATECHECKSUM("Company: %u, Money: " OTTD_PRINTF64, c->index, (int64_t)c->money); UpdateStateChecksum(c->money); for (uint i = 0; i < ROADTYPE_END; i++) { diff --git a/src/openttd.h b/src/openttd.h index 1e48d24bd5..b8e1cb42e4 100644 --- a/src/openttd.h +++ b/src/openttd.h @@ -84,7 +84,7 @@ DECLARE_ENUM_AS_BIT_SET(PauseMode) /** The current pause mode */ extern PauseMode _pause_mode; -extern uint32 _pause_countdown; +extern uint32_t _pause_countdown; void AskExitGame(); void AskExitToGameMenu(); diff --git a/src/order_backup.cpp b/src/order_backup.cpp index 4283f51b29..45ba5eec42 100644 --- a/src/order_backup.cpp +++ b/src/order_backup.cpp @@ -45,7 +45,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; @@ -115,7 +115,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. */ @@ -133,7 +133,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; @@ -149,7 +149,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 @@ void OrderBackup::DoRestore(Vehicle *v) * @param text Unused. * @return The cost of this operation or an error. */ -CommandCost CmdClearOrderBackup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdClearOrderBackup(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { /* No need to check anything. If the tile or user don't exist we just ignore it. */ if (flags & DC_EXEC) OrderBackup::ResetOfUser(tile == 0 ? INVALID_TILE : tile, p2); @@ -179,7 +179,7 @@ CommandCost CmdClearOrderBackup(TileIndex tile, DoCommandFlag flags, uint32 p1, * @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); @@ -204,7 +204,7 @@ CommandCost CmdClearOrderBackup(TileIndex tile, DoCommandFlag flags, uint32 p1, * 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 4953a5b183..9f9cccfb90 100644 --- a/src/order_backup.h +++ b/src/order_backup.h @@ -20,7 +20,7 @@ #include /** Unique identifier for an order backup. */ -typedef uint8 OrderBackupID; +typedef uint8_t OrderBackupID; struct OrderBackup; /** The pool type for order backups. */ @@ -29,7 +29,7 @@ typedef Pool OrderBackupPool; extern OrderBackupPool _order_backup_pool; /** Flag to pass to the vehicle construction command when an order should be preserved. */ -static const uint32 MAKE_ORDER_BACKUP_FLAG = 1U << 31; +static const uint32_t MAKE_ORDER_BACKUP_FLAG = 1U << 31; namespace upstream_sl { SaveLoadTable GetOrderBackupDescription(); @@ -47,7 +47,7 @@ private: friend void Load_BKOR(); ///< Creating empty orders upon savegame loading. friend void Save_BKOR(); ///< Saving orders upon savegame saving. friend upstream_sl::BKORChunkHandler; - 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. @@ -60,18 +60,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 e835a129b3..748742234e 100644 --- a/src/order_base.h +++ b/src/order_base.h @@ -30,14 +30,14 @@ typedef Pool OrderPool; typedef Pool OrderListPool; extern OrderPool _order_pool; extern OrderListPool _orderlist_pool; -extern btree::btree_map _order_destination_refcount_map; +extern btree::btree_map _order_destination_refcount_map; extern bool _order_destination_refcount_map_valid; -inline uint32 OrderDestinationRefcountMapKey(DestinationID dest, CompanyID cid, OrderType order_type, VehicleType veh_type) +inline uint32_t OrderDestinationRefcountMapKey(DestinationID dest, CompanyID cid, OrderType order_type, VehicleType veh_type) { static_assert(sizeof(dest) == 2); static_assert(OT_END <= 16); - return (((uint32) dest) << 16) | (((uint32) cid) << 8) | (((uint32) order_type) << 4) | ((uint32) veh_type); + return (((uint32_t) dest) << 16) | (((uint32_t) cid) << 8) | (((uint32_t) order_type) << 4) | ((uint32_t) veh_type); } template void IterateOrderRefcountMapForDestinationID(DestinationID dest, F handler) @@ -80,12 +80,12 @@ void ClearOrderDestinationRefcountMap(); */ struct OrderExtraInfo { - uint8 cargo_type_flags[NUM_CARGO] = {}; ///< Load/unload types for each cargo type. - uint32 xdata = 0; ///< Extra arbitrary data - uint32 xdata2 = 0; ///< Extra arbitrary data - uint16 dispatch_index = 0; ///< Scheduled dispatch index + 1 - uint8 xflags = 0; ///< Extra flags - uint8 colour = 0; ///< Order colour + 1 + uint8_t cargo_type_flags[NUM_CARGO] = {}; ///< Load/unload types for each cargo type. + uint32_t xdata = 0; ///< Extra arbitrary data + uint32_t xdata2 = 0; ///< Extra arbitrary data + uint16_t dispatch_index = 0; ///< Scheduled dispatch index + 1 + uint8_t xflags = 0; ///< Extra flags + uint8_t colour = 0; ///< Order colour + 1 }; namespace upstream_sl { @@ -102,9 +102,9 @@ namespace upstream_sl { */ struct Order : OrderPool::PoolItem<&_order_pool> { private: - friend SaveLoadTable GetVehicleDescription(VehicleType vt); ///< Saving and loading the current order of vehicles. - friend void Load_VEHS(); ///< Loading of ancient vehicles. - friend SaveLoadTable GetOrderDescription(); ///< Saving and loading of orders. + friend SaveLoadTable GetVehicleDescription(VehicleType vt); ///< Saving and loading the current order of vehicles. + friend void Load_VEHS(); ///< Loading of ancient vehicles. + friend SaveLoadTable GetOrderDescription(); ///< Saving and loading of orders. friend upstream_sl::SaveLoadTable upstream_sl::GetOrderDescription(); ///< Saving and loading of orders. friend upstream_sl::SlVehicleCommon; friend upstream_sl::SlVehicleDisaster; @@ -115,17 +115,17 @@ private: std::unique_ptr extra; ///< Extra order info - uint16 flags; ///< Load/unload types, depot order/action types. + uint16_t flags; ///< Load/unload types, depot order/action types. DestinationID dest; ///< The destination of the order. - uint8 type; ///< The type of order + non-stop flags + uint8_t type; ///< The type of order + non-stop flags CargoID refit_cargo; ///< Refit CargoID - uint8 occupancy; ///< Estimate of vehicle occupancy on departure, for the current order, 0 indicates invalid, 1 - 101 indicate 0 - 100% + uint8_t occupancy; ///< Estimate of vehicle occupancy on departure, for the current order, 0 indicates invalid, 1 - 101 indicate 0 - 100% TimetableTicks wait_time; ///< How long in ticks to wait at the destination. TimetableTicks 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 max_speed; ///< How fast the vehicle may go on the way to the destination. void AllocExtraInfo(); void DeAllocExtraInfo(); @@ -135,35 +135,35 @@ private: if (!this->extra) this->AllocExtraInfo(); } - inline uint8 GetXFlags() const + inline uint8_t GetXFlags() const { return this->extra != nullptr ? this->extra->xflags : 0; } - inline uint8 &GetXFlagsRef() + inline uint8_t &GetXFlagsRef() { CheckExtraInfoAlloced(); return this->extra->xflags; } public: - inline uint32 GetXData() const + inline uint32_t GetXData() const { return this->extra != nullptr ? this->extra->xdata : 0; } - inline uint32 &GetXDataRef() + inline uint32_t &GetXDataRef() { CheckExtraInfoAlloced(); return this->extra->xdata; } - inline uint32 GetXData2() const + inline uint32_t GetXData2() const { return this->extra != nullptr ? this->extra->xdata2 : 0; } - inline uint32 &GetXData2Ref() + inline uint32_t &GetXData2Ref() { CheckExtraInfoAlloced(); return this->extra->xdata2; @@ -174,7 +174,7 @@ public: Order() : flags(0), refit_cargo(CT_NO_REFIT), max_speed(UINT16_MAX) {} ~Order(); - Order(uint64 packed); + Order(uint64_t packed); Order(const Order& other) { @@ -288,7 +288,7 @@ public: * @return whether to jump or not. * @pre IsType(OT_CONDITIONAL) && this->GetConditionVariable() == OCV_PERCENT. */ - bool UpdateJumpCounter(uint8 percent, bool dry_run); + bool UpdateJumpCounter(uint8_t percent, bool dry_run); /** How must the consist be loaded? */ inline OrderLoadFlags GetLoadType() const @@ -390,11 +390,11 @@ 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); } /** Get counter for the 'jump xx% of times' option */ - inline int8 GetJumpCounter() const { return GB(this->GetXData(), 0, 8); } + inline int8_t GetJumpCounter() const { return GB(this->GetXData(), 0, 8); } /** Get counter operation */ - inline uint8 GetCounterOperation() const { return GB(this->flags, 0, 8); } + inline uint8_t GetCounterOperation() const { return GB(this->flags, 0, 8); } /** Set how the consist must be loaded. */ inline void SetLoadType(OrderLoadFlags load_type) @@ -455,11 +455,11 @@ 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); } /** Set counter for the 'jump xx% of times' option */ - inline void SetJumpCounter(int8 jump_counter) { SB(this->GetXDataRef(), 0, 8, jump_counter); } + inline void SetJumpCounter(int8_t jump_counter) { SB(this->GetXDataRef(), 0, 8, jump_counter); } /** Set counter operation */ - inline void SetCounterOperation(uint8 op) { SB(this->flags, 0, 8, op); } + inline void SetCounterOperation(uint8_t op) { SB(this->flags, 0, 8, op); } /* 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 @@ -496,7 +496,7 @@ public: * 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) @@ -532,7 +532,7 @@ public: * 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; } /** Does this order have a fixed wait time? */ inline bool IsWaitFixed() const { return HasBit(this->GetXFlags(), 1); } @@ -574,13 +574,13 @@ public: * Get the occupancy value * @return occupancy */ - inline uint8 GetOccupancy() const { return this->occupancy; } + inline uint8_t GetOccupancy() const { return this->occupancy; } /** * Set the occupancy value * @param occupancy The occupancy to set */ - inline void SetOccupancy(uint8 occupancy) { this->occupancy = occupancy; } + inline void SetOccupancy(uint8_t occupancy) { this->occupancy = occupancy; } bool UseOccupancyValueForAverage() const; @@ -610,7 +610,7 @@ public: { if (schedule_index != this->GetDispatchScheduleIndex()) { this->CheckExtraInfoAlloced(); - this->extra->dispatch_index = (uint16)(schedule_index + 1); + this->extra->dispatch_index = (uint16_t)(schedule_index + 1); } } @@ -622,7 +622,7 @@ public: /** Get order colour */ inline Colours GetColour() const { - uint8 value = this->extra != nullptr ? this->extra->colour : 0; + uint8_t value = this->extra != nullptr ? this->extra->colour : 0; return (Colours)(value - 1); } @@ -631,7 +631,7 @@ public: { if (colour != this->GetColour()) { this->CheckExtraInfoAlloced(); - this->extra->colour = ((uint8)colour) + 1; + this->extra->colour = ((uint8_t)colour) + 1; } } @@ -651,8 +651,8 @@ public: void AssignOrder(const Order &other); bool Equals(const Order &other) const; - uint64 Pack() const; - uint16 MapOldOrder() const; + uint64_t Pack() const; + uint16_t MapOldOrder() const; void ConvertFromOldSavegame(); }; @@ -713,12 +713,12 @@ struct DispatchSchedule { private: friend SaveLoadTable GetDispatchScheduleDescription(); ///< Saving and loading of dispatch schedules - std::vector scheduled_dispatch; ///< Scheduled dispatch time - uint32 scheduled_dispatch_duration = 0; ///< Scheduled dispatch duration + std::vector scheduled_dispatch; ///< Scheduled dispatch time + uint32_t scheduled_dispatch_duration = 0; ///< Scheduled dispatch duration DateTicksScaled scheduled_dispatch_start_tick = -1; ///< Scheduled dispatch start tick /// this counts to (DAY_TICK * _settings_game.economy.day_length_factor) - int32 scheduled_dispatch_last_dispatch = 0; ///< Last vehicle dispatched offset - int32 scheduled_dispatch_max_delay = 0; ///< Maximum allowed delay + int32_t scheduled_dispatch_last_dispatch = 0; ///< Last vehicle dispatched offset + int32_t scheduled_dispatch_max_delay = 0; ///< Maximum allowed delay std::string name; ///< Name of dispatch schedule @@ -735,12 +735,12 @@ public: * Get the vector of all scheduled dispatch slot * @return first scheduled dispatch */ - inline const std::vector &GetScheduledDispatch() const { return this->scheduled_dispatch; } + inline const std::vector &GetScheduledDispatch() const { return this->scheduled_dispatch; } - void SetScheduledDispatch(std::vector dispatch_list); - void AddScheduledDispatch(uint32 offset); - void RemoveScheduledDispatch(uint32 offset); - void AdjustScheduledDispatch(int32 adjust); + void SetScheduledDispatch(std::vector dispatch_list); + void AddScheduledDispatch(uint32_t offset); + void RemoveScheduledDispatch(uint32_t offset); + void AdjustScheduledDispatch(int32_t adjust); void ClearScheduledDispatch() { this->scheduled_dispatch.clear(); } bool UpdateScheduledDispatchToDate(DateTicksScaled now); void UpdateScheduledDispatch(const Vehicle *v); @@ -749,13 +749,13 @@ public: * Set the scheduled dispatch duration, in scaled tick * @param duration New duration */ - inline void SetScheduledDispatchDuration(uint32 duration) { this->scheduled_dispatch_duration = duration; } + inline void SetScheduledDispatchDuration(uint32_t duration) { this->scheduled_dispatch_duration = duration; } /** * Get the scheduled dispatch duration, in scaled tick * @return scheduled dispatch duration */ - inline uint32 GetScheduledDispatchDuration() const { return this->scheduled_dispatch_duration; } + inline uint32_t GetScheduledDispatchDuration() const { return this->scheduled_dispatch_duration; } /** * Set the scheduled dispatch start @@ -782,25 +782,25 @@ public: * Set the scheduled dispatch last dispatch offset, in scaled tick * @param duration New last dispatch offset */ - inline void SetScheduledDispatchLastDispatch(int32 offset) { this->scheduled_dispatch_last_dispatch = offset; } + inline void SetScheduledDispatchLastDispatch(int32_t offset) { this->scheduled_dispatch_last_dispatch = offset; } /** * Get the scheduled dispatch last dispatch offset, in scaled tick * @return scheduled dispatch last dispatch */ - inline int32 GetScheduledDispatchLastDispatch() const { return this->scheduled_dispatch_last_dispatch; } + inline int32_t GetScheduledDispatchLastDispatch() const { return this->scheduled_dispatch_last_dispatch; } /** * Set the scheduled dispatch maximum allowed delay, in scaled tick * @param delay New maximum allow delay */ - inline void SetScheduledDispatchDelay(int32 delay) { this->scheduled_dispatch_max_delay = delay; } + inline void SetScheduledDispatchDelay(int32_t delay) { this->scheduled_dispatch_max_delay = delay; } /** * Get the scheduled dispatch maximum alowed delay, in scaled tick * @return scheduled dispatch last dispatch */ - inline int32 GetScheduledDispatchDelay() const { return this->scheduled_dispatch_max_delay; } + inline int32_t GetScheduledDispatchDelay() const { return this->scheduled_dispatch_max_delay; } inline void BorrowSchedule(DispatchSchedule &other) { diff --git a/src/order_cmd.cpp b/src/order_cmd.cpp index 8cb6c9af96..8d05bd01a9 100644 --- a/src/order_cmd.cpp +++ b/src/order_cmd.cpp @@ -58,7 +58,7 @@ INSTANTIATE_POOL_METHODS(Order) OrderListPool _orderlist_pool("OrderList"); INSTANTIATE_POOL_METHODS(OrderList) -btree::btree_map _order_destination_refcount_map; +btree::btree_map _order_destination_refcount_map; bool _order_destination_refcount_map_valid = false; CommandCost CmdInsertOrderIntl(DoCommandFlag flags, Vehicle *v, VehicleOrderID sel_ord, const Order &new_order, bool allow_load_by_cargo_type); @@ -180,7 +180,7 @@ void Order::MakeLoading(bool ordered) */ bool Order::UpdateJumpCounter(byte percent, bool dry_run) { - const int8 jump_counter = this->GetJumpCounter(); + const int8_t jump_counter = this->GetJumpCounter(); if (dry_run) return jump_counter >= 0; if (jump_counter >= 0) { this->SetJumpCounter(jump_counter + (percent - 100)); @@ -297,9 +297,9 @@ bool Order::Equals(const Order &other) const * @return the packed representation. * @note unpacking is done in the constructor. */ -uint64 Order::Pack() const +uint64_t Order::Pack() const { - return ((uint64) this->dest) << 24 | ((uint64) this->flags) << 8 | ((uint64) this->type); + return ((uint64_t) this->dest) << 24 | ((uint64_t) this->flags) << 8 | ((uint64_t) this->type); } /** @@ -307,9 +307,9 @@ uint64 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); @@ -333,7 +333,7 @@ uint16 Order::MapOldOrder() const * Create an order based on a packed representation of that order. * @param packed the packed representation. */ -Order::Order(uint64 packed) +Order::Order(uint64_t packed) { this->type = (OrderType)GB(packed, 0, 8); this->flags = GB(packed, 8, 16); @@ -986,7 +986,7 @@ uint GetOrderDistance(const Order *prev, const Order *cur, const Vehicle *v, int * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { VehicleID veh = GB(p1, 0, 20); VehicleOrderID sel_ord = GB(p2, 0, 16); @@ -1006,7 +1006,7 @@ CommandCost CmdInsertOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdDuplicateOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdDuplicateOrder(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh_id = GB(p1, 0, 20); VehicleOrderID sel_ord = GB(p2, 0, 16); @@ -1038,7 +1038,7 @@ CommandCost CmdDuplicateOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, ui order->SetRefit(new_order.GetRefitCargo()); order->SetMaxSpeed(new_order.GetMaxSpeed()); if (wait_fixed) { - extern void SetOrderFixedWaitTime(Vehicle *v, VehicleOrderID order_number, uint32 wait_time, bool wait_timetabled); + extern void SetOrderFixedWaitTime(Vehicle *v, VehicleOrderID order_number, uint32_t wait_time, bool wait_timetabled); SetOrderFixedWaitTime(v, sel_ord + 1, new_order.GetWaitTime(), wait_timetabled); } } @@ -1363,7 +1363,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) { @@ -1447,7 +1447,7 @@ static CargoID GetFirstValidCargo() * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdDeleteOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdDeleteOrder(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh_id = GB(p1, 0, 20); VehicleOrderID sel_ord = GB(p2, 0, 16); @@ -1569,7 +1569,7 @@ void DeleteOrder(Vehicle *v, VehicleOrderID sel_ord) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdSkipToOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSkipToOrder(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh_id = GB(p1, 0, 20); VehicleOrderID sel_ord = GB(p2, 0, 16); @@ -1620,7 +1620,7 @@ CommandCost CmdSkipToOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 * @note The target order will move one place down in the orderlist * if you move the order upwards else it'll move it one place down */ -CommandCost CmdMoveOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdMoveOrder(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); VehicleOrderID moving_order = GB(p2, 0, 16); @@ -1722,7 +1722,7 @@ CommandCost CmdMoveOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdReverseOrderList(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdReverseOrderList(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); @@ -1766,7 +1766,7 @@ CommandCost CmdReverseOrderList(TileIndex tile, DoCommandFlag flags, uint32 p1, order->SetRefit(new_order.GetRefitCargo()); order->SetMaxSpeed(new_order.GetMaxSpeed()); if (wait_fixed) { - extern void SetOrderFixedWaitTime(Vehicle *v, VehicleOrderID order_number, uint32 wait_time, bool wait_timetabled); + extern void SetOrderFixedWaitTime(Vehicle *v, VehicleOrderID order_number, uint32_t wait_time, bool wait_timetabled); SetOrderFixedWaitTime(v, order_count, new_order.GetWaitTime(), wait_timetabled); } } @@ -1798,12 +1798,12 @@ CommandCost CmdReverseOrderList(TileIndex tile, DoCommandFlag flags, uint32 p1, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { VehicleOrderID sel_ord = GB(p3, 0, 16); VehicleID veh = GB(p1, 0, 20); ModifyOrderFlags mof = Extract(p2); - uint16 data = GB(p2, 8, 16); + uint16_t data = GB(p2, 8, 16); CargoID cargo_id = (mof == MOF_CARGO_TYPE_UNLOAD || mof == MOF_CARGO_TYPE_LOAD) ? (CargoID) GB(p2, 24, 8) : (CargoID) CT_INVALID; if (mof >= MOF_END) return CMD_ERROR; @@ -2218,12 +2218,12 @@ CommandCost CmdModifyOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 case OCV_CARGO_ACCEPTANCE: case OCV_CARGO_WAITING: - if (!old_var_was_cargo) order->SetConditionValue((uint16) GetFirstValidCargo()); + if (!old_var_was_cargo) order->SetConditionValue((uint16_t) GetFirstValidCargo()); if (occ != OCC_IS_TRUE && occ != OCC_IS_FALSE) order->SetConditionComparator(OCC_IS_TRUE); break; case OCV_CARGO_LOAD_PERCENTAGE: case OCV_CARGO_WAITING_AMOUNT: - if (!old_var_was_cargo) order->SetConditionValue((uint16) GetFirstValidCargo()); + if (!old_var_was_cargo) order->SetConditionValue((uint16_t) GetFirstValidCargo()); order->GetXDataRef() = 0; order->SetConditionComparator(OCC_EQUALS); break; @@ -2489,7 +2489,7 @@ static bool ShouldResetOrderIndicesOnOrderCopy(const Vehicle *src, const Vehicle * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh_src = GB(p2, 0, 20); VehicleID veh_dst = GB(p1, 0, 20); @@ -2711,7 +2711,7 @@ CommandCost CmdCloneOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdOrderRefit(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdOrderRefit(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); VehicleOrderID order_number = GB(p2, 16, 16); @@ -2946,7 +2946,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); } @@ -2998,14 +2998,14 @@ bool OrderConditionCompare(OrderConditionComparator occ, int variable, int value * @param st_id The StationID of the station. * @return The number of free train platforms. */ -static uint16 GetFreeStationPlatforms(StationID st_id) +static uint16_t GetFreeStationPlatforms(StationID st_id) { assert(Station::IsValidID(st_id)); const Station *st = Station::Get(st_id); if (!(st->facilities & FACIL_TRAIN)) return 0; bool is_free; TileIndex t2; - uint16 counter = 0; + uint16_t counter = 0; for (TileIndex t1 : st->train_station) { if (st->TileBelongsToRailStation(t1)) { /* We only proceed if this tile is a track tile and the north(-east/-west) end of the platform */ @@ -3034,9 +3034,9 @@ bool EvaluateDispatchSlotConditionalOrder(const Order *order, const Vehicle *v, if (predicted != nullptr) *predicted = true; - int32 offset; + int32_t offset; if (order->GetConditionValue() & 2) { - int32 last = sched.GetScheduledDispatchLastDispatch(); + int32_t last = sched.GetScheduledDispatchLastDispatch(); if (last < 0) { last += sched.GetScheduledDispatchDuration() * (1 + (-last / sched.GetScheduledDispatchDuration())); } @@ -3059,8 +3059,8 @@ bool EvaluateDispatchSlotConditionalOrder(const Order *order, const Vehicle *v, static std::vector _pco_deferred_slot_acquires; static std::vector _pco_deferred_slot_releases; -static btree::btree_map _pco_deferred_counter_values; -static btree::btree_map _pco_deferred_original_percent_cond; +static btree::btree_map _pco_deferred_counter_values; +static btree::btree_map _pco_deferred_original_percent_cond; /** * Process a conditional order and determine the next order. @@ -3075,7 +3075,7 @@ VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle *v, Pro bool skip_order = false; OrderConditionComparator occ = order->GetConditionComparator(); - uint16 value = order->GetConditionValue(); + uint16_t value = order->GetConditionValue(); // OrderConditionCompare ignores the last parameter for occ == OCC_IS_TRUE or occ == OCC_IS_FALSE. switch (order->GetConditionVariable()) { @@ -3178,7 +3178,7 @@ VehicleOrderID ProcessConditionalOrder(const Order *order, const Vehicle *v, Pro case OCV_COUNTER_VALUE: { const TraceRestrictCounter* ctr = TraceRestrictCounter::GetIfValid(GB(order->GetXData(), 16, 16)); if (ctr != nullptr) { - int32 value = ctr->value; + int32_t value = ctr->value; if (mode == PCO_DEFERRED) { auto iter = _pco_deferred_counter_values.find(ctr->index); if (iter != _pco_deferred_counter_values.end()) value = iter->second; @@ -3403,7 +3403,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 { @@ -3648,7 +3648,7 @@ bool Order::CanLeaveWithCargo(bool has_cargo, CargoID cargo) const * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdMassChangeOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdMassChangeOrder(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { DestinationID from_dest = GB(p1, 0, 16); VehicleType vehtype = Extract(p1); @@ -3679,7 +3679,7 @@ CommandCost CmdMassChangeOrder(TileIndex tile, DoCommandFlag flags, uint32 p1, u order->SetRefit(new_order.GetRefitCargo()); order->SetMaxSpeed(new_order.GetMaxSpeed()); if (wait_fixed) { - extern void SetOrderFixedWaitTime(Vehicle *v, VehicleOrderID order_number, uint32 wait_time, bool wait_timetabled); + extern void SetOrderFixedWaitTime(Vehicle *v, VehicleOrderID order_number, uint32_t wait_time, bool wait_timetabled); SetOrderFixedWaitTime(v, index, new_order.GetWaitTime(), wait_timetabled); } changed = true; diff --git a/src/order_func.h b/src/order_func.h index 1d4dfac53a..31bfc86dbf 100644 --- a/src/order_func.h +++ b/src/order_func.h @@ -46,7 +46,7 @@ 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); bool OrderConditionCompare(OrderConditionComparator occ, int variable, int value); const char *GetOrderTypeName(OrderType order_type); diff --git a/src/order_gui.cpp b/src/order_gui.cpp index f131400455..a9a11e4c56 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -54,7 +54,7 @@ static const StringID _cargo_type_load_order_drowdown[] = { STR_ORDER_DROP_NO_LOADING, // OLFB_NO_LOAD INVALID_STRING_ID }; -static const uint32 _cargo_type_load_order_drowdown_hidden_mask = 0xA; // 01010 +static const uint32_t _cargo_type_load_order_drowdown_hidden_mask = 0xA; // 01010 /** Cargo type orders strings for unload dropdowns. */ static const StringID _cargo_type_unload_order_drowdown[] = { @@ -65,12 +65,12 @@ static const StringID _cargo_type_unload_order_drowdown[] = { STR_ORDER_DROP_NO_UNLOADING, // OUFB_NO_UNLOAD INVALID_STRING_ID }; -static const uint32 _cargo_type_unload_order_drowdown_hidden_mask = 0x8; // 01000 +static const uint32_t _cargo_type_unload_order_drowdown_hidden_mask = 0x8; // 01000 DropDownList GetSlotDropDownList(Owner owner, TraceRestrictSlotID slot_id, int &selected, VehicleType vehtype, bool show_other_types); DropDownList GetCounterDropDownList(Owner owner, TraceRestrictCounterID ctr_id, int &selected); -static bool ModifyOrder(const Vehicle *v, VehicleOrderID order_id, uint32 p2, bool error_msg = true, const char *text = nullptr) +static bool ModifyOrder(const Vehicle *v, VehicleOrderID order_id, uint32_t p2, bool error_msg = true, const char *text = nullptr) { return DoCommandPEx(v->tile, v->index, p2, order_id, CMD_MODIFY_ORDER | (error_msg ? CMD_MSG(STR_ERROR_CAN_T_MODIFY_THIS_ORDER) : 0), nullptr, text, nullptr); } @@ -85,11 +85,11 @@ private: VehicleOrderID order_count; ///< Count of the orders of the vehicle owning this window const Order *order; ///< Order pointer at construction time; - static const uint8 CARGO_ICON_WIDTH = 12; - static const uint8 CARGO_ICON_HEIGHT = 8; + static const uint8_t CARGO_ICON_WIDTH = 12; + static const uint8_t CARGO_ICON_HEIGHT = 8; const StringID *cargo_type_order_dropdown; ///< Strings used to populate order dropdowns. - uint32 cargo_type_order_dropdown_hmask; ///< Hidden mask for order dropdowns. + uint32_t cargo_type_order_dropdown_hmask; ///< Hidden mask for order dropdowns. uint max_cargo_name_width; ///< Greatest width of cargo names. uint max_cargo_dropdown_width; ///< Greatest width of order names. @@ -123,7 +123,7 @@ private: for (int i = 0; i < (int)_sorted_standard_cargo_specs.size(); i++) { const CargoSpec *cs = _sorted_cargo_specs[i]; const CargoID cargo_id = cs->Index(); - uint8 order_type = (this->variant == CTOWV_LOAD) ? (uint8) order->GetCargoLoadTypeRaw(cargo_id) : (uint8) order->GetCargoUnloadTypeRaw(cargo_id); + uint8_t order_type = (this->variant == CTOWV_LOAD) ? (uint8_t) order->GetCargoLoadTypeRaw(cargo_id) : (uint8_t) order->GetCargoUnloadTypeRaw(cargo_id); this->GetWidget(WID_CTO_CARGO_DROPDOWN_FIRST + i)->SetDataTip(this->cargo_type_order_dropdown[order_type], tooltip); } this->GetWidget(WID_CTO_SET_TO_ALL_DROPDOWN)->widget_data = this->cargo_type_order_dropdown[this->set_to_all_dropdown_sel]; @@ -134,10 +134,10 @@ private: * @param cargo_id The cargo index for wich we want the load/unload type. * @return an OrderLoadFlags if \c load_variant = true, an OrderUnloadFlags otherwise. */ - uint8 GetOrderActionTypeForCargo(CargoID cargo_id) + uint8_t GetOrderActionTypeForCargo(CargoID cargo_id) { const Order *order = this->vehicle->GetOrder(this->order_id); - return (this->variant == CTOWV_LOAD) ? (uint8) order->GetCargoLoadTypeRaw(cargo_id) : (uint8) order->GetCargoUnloadTypeRaw(cargo_id); + return (this->variant == CTOWV_LOAD) ? (uint8_t) order->GetCargoLoadTypeRaw(cargo_id) : (uint8_t) order->GetCargoUnloadTypeRaw(cargo_id); } bool CheckOrderStillValid() const @@ -255,7 +255,7 @@ public: if (WID_CTO_CARGO_DROPDOWN_FIRST <= widget && widget <= WID_CTO_CARGO_DROPDOWN_LAST) { const CargoSpec *cs = _sorted_cargo_specs[widget - WID_CTO_CARGO_DROPDOWN_FIRST]; const CargoID cargo_id = cs->Index(); - uint8 order_action_type = this->GetOrderActionTypeForCargo(cargo_id); + uint8_t order_action_type = this->GetOrderActionTypeForCargo(cargo_id); if (action_type == order_action_type) return; @@ -1570,12 +1570,12 @@ private: } } - bool InsertNewOrder(uint64 order_pack) + bool InsertNewOrder(uint64_t order_pack) { return DoCommandPEx(this->vehicle->tile, this->vehicle->index, this->OrderGetSel(), order_pack, CMD_INSERT_ORDER | CMD_MSG(STR_ERROR_CAN_T_INSERT_NEW_ORDER), nullptr, nullptr, 0); } - bool ModifyOrder(VehicleOrderID sel_ord, uint32 p2, bool error_msg = true, const char *text = nullptr) + bool ModifyOrder(VehicleOrderID sel_ord, uint32_t p2, bool error_msg = true, const char *text = nullptr) { return ::ModifyOrder(this->vehicle, sel_ord, p2, error_msg, text); } @@ -2465,7 +2465,7 @@ public: /* Don't draw anything if it extends past the end of the window. */ if (!this->vscroll->IsVisible(i)) break; - uint8 occupancy = order->GetOccupancy(); + uint8_t occupancy = order->GetOccupancy(); if (occupancy > 0) { SetDParam(0, occupancy - 1); TextColour colour; @@ -2859,7 +2859,7 @@ public: case OPOS_DEPARTURE_VIA: sel = 7; break; default: NOT_REACHED(); } - uint32 hidden_mask = 0; + uint32_t hidden_mask = 0; if (_settings_client.gui.show_adv_tracerestrict_features) { bool have_counters = false; for (const TraceRestrictCounter *ctr : TraceRestrictCounter::Iterate()) { @@ -3617,15 +3617,15 @@ static Hotkey order_hotkeys[] = { Hotkey('F', "delete", OHK_DELETE), Hotkey('G', "goto", OHK_GOTO), Hotkey('H', "nonstop", OHK_NONSTOP), - Hotkey((uint16)0, "via", OHK_VIA), + Hotkey((uint16_t)0, "via", OHK_VIA), Hotkey('J', "fullload", OHK_FULLLOAD), Hotkey('K', "unload", OHK_UNLOAD), - Hotkey((uint16)0, "nearest_depot", OHK_NEAREST_DEPOT), - Hotkey((uint16)0, "always_service", OHK_ALWAYS_SERVICE), - Hotkey((uint16)0, "transfer", OHK_TRANSFER), - Hotkey((uint16)0, "no_unload", OHK_NO_UNLOAD), - Hotkey((uint16)0, "no_load", OHK_NO_LOAD), - Hotkey((uint16)0, "close", OHK_CLOSE), + Hotkey((uint16_t)0, "nearest_depot", OHK_NEAREST_DEPOT), + Hotkey((uint16_t)0, "always_service", OHK_ALWAYS_SERVICE), + Hotkey((uint16_t)0, "transfer", OHK_TRANSFER), + Hotkey((uint16_t)0, "no_unload", OHK_NO_UNLOAD), + Hotkey((uint16_t)0, "no_load", OHK_NO_LOAD), + Hotkey((uint16_t)0, "close", OHK_CLOSE), HOTKEY_LIST_END }; HotkeyList OrdersWindow::hotkeys("order", order_hotkeys); diff --git a/src/order_type.h b/src/order_type.h index 2e19ce1a9d..c75e273f0c 100644 --- a/src/order_type.h +++ b/src/order_type.h @@ -12,11 +12,11 @@ #include "core/enum_type.hpp" -typedef uint16 VehicleOrderID; ///< The index of an order within its current vehicle (not pool related) -typedef uint32 OrderID; -typedef uint16 OrderListID; -typedef uint16 DestinationID; -typedef uint32 TimetableTicks; +typedef uint16_t VehicleOrderID; ///< The index of an order within its current vehicle (not pool related) +typedef uint32_t OrderID; +typedef uint16_t OrderListID; +typedef uint16_t DestinationID; +typedef uint32_t TimetableTicks; /** Invalid vehicle order index (sentinel) */ static const VehicleOrderID INVALID_VEH_ORDER_ID = 0xFFFF; diff --git a/src/os/macosx/font_osx.cpp b/src/os/macosx/font_osx.cpp index ae0a3d3320..b5b4c82630 100644 --- a/src/os/macosx/font_osx.cpp +++ b/src/os/macosx/font_osx.cpp @@ -182,7 +182,7 @@ void CoreTextFontCache::SetFontSize(int pixels) DEBUG(fontcache, 2, "Loaded font '%s' with size %d", this->font_name.c_str(), pixels); } -GlyphID CoreTextFontCache::MapCharToGlyph(WChar key) +GlyphID CoreTextFontCache::MapCharToGlyph(char32_t key) { assert(IsPrintable(key)); @@ -207,7 +207,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; @@ -249,8 +249,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 36b2359cff..33f016a34b 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 27a6bfcae9..c84a09ead9 100644 --- a/src/os/macosx/macos.mm +++ b/src/os/macosx/macos.mm @@ -261,7 +261,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 5b19fad793..4a4d4cc80b 100644 --- a/src/os/macosx/string_osx.cpp +++ b/src/os/macosx/string_osx.cpp @@ -115,7 +115,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; @@ -140,7 +140,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); } @@ -187,7 +187,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); @@ -380,7 +380,7 @@ int MacOSStringContains(const std::string_view str, const std::string_view value 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 d85c1691da..46abaaff4f 100644 --- a/src/os/macosx/string_osx.h +++ b/src/os/macosx/string_osx.h @@ -62,7 +62,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) { assert(buff < buffer_last); if (c >= 0x010000U) { diff --git a/src/os/windows/font_win32.cpp b/src/os/windows/font_win32.cpp index f1ea911d18..48ef580762 100644 --- a/src/os/windows/font_win32.cpp +++ b/src/os/windows/font_win32.cpp @@ -301,7 +301,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 27a9c7f180..7ef5568601 100644 --- a/src/os/windows/font_win32.h +++ b/src/os/windows/font_win32.h @@ -26,7 +26,7 @@ private: void SetFontSize(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: diff --git a/src/os/windows/string_uniscribe.cpp b/src/os/windows/string_uniscribe.cpp index 81bea579d1..1af78b811b 100644 --- a/src/os/windows/string_uniscribe.cpp +++ b/src/os/windows/string_uniscribe.cpp @@ -55,7 +55,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); @@ -248,7 +248,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; @@ -281,7 +281,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; @@ -555,7 +555,7 @@ const int *UniscribeParagraphLayout::UniscribeVisualRun::GetGlyphToCharMap() con if (!utf16_str.empty()) { /* 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.empty() && run != runs.end() - 1; run++) { /* Get information on valid word and character break.s */ diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp index 653e7961df..b0c07d2b03 100644 --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -233,16 +233,16 @@ void FiosGetDrives(FileList &file_list) bool FiosIsValidFile(const char *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 00c6ff7322..cbed715453 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; diff --git a/src/pathfinder/follow_track.hpp b/src/pathfinder/follow_track.hpp index 8b6fe5abae..7b020f7f3b 100644 --- a/src/pathfinder/follow_track.hpp +++ b/src/pathfinder/follow_track.hpp @@ -473,12 +473,12 @@ public: } /* Check for speed limit imposed by railtype */ if (IsRailTT()) { - uint16 rail_speed = GetRailTypeInfo(GetRailTypeByTrack(m_old_tile, TrackdirToTrack(m_old_td)))->max_speed; + uint16_t rail_speed = GetRailTypeInfo(GetRailTypeByTrack(m_old_tile, TrackdirToTrack(m_old_td)))->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.cpp b/src/pathfinder/npf/aystar.cpp index 227c73d389..050a479924 100644 --- a/src/pathfinder/npf/aystar.cpp +++ b/src/pathfinder/npf/aystar.cpp @@ -48,7 +48,7 @@ PathNode *AyStar::ClosedListIsInList(const AyStarNode *node) void AyStar::ClosedListAdd(const PathNode *node) { /* Add a node to the ClosedList */ - std::pair new_node = this->closedlist_nodes.Allocate(); + std::pair new_node = this->closedlist_nodes.Allocate(); *(new_node.second) = *node; this->closedlist_hash[this->HashKey(node->node.tile, node->node.direction)] = new_node.first; @@ -59,7 +59,7 @@ void AyStar::ClosedListAdd(const PathNode *node) * @param node Node to search. * @return If the node is available, it is returned, else \c UINT32_MAX is returned. */ -uint32 AyStar::OpenListIsInList(const AyStarNode *node) +uint32_t AyStar::OpenListIsInList(const AyStarNode *node) { const auto result = this->openlist_hash.find(this->HashKey(node->tile, node->direction)); @@ -71,11 +71,11 @@ uint32 AyStar::OpenListIsInList(const AyStarNode *node) * It deletes the returned node from the open list. * @returns the best node available, or \c nullptr of none is found. */ -std::pair AyStar::OpenListPop() +std::pair AyStar::OpenListPop() { /* Return the item the Queue returns.. the best next OpenList item. */ - uint32 idx = this->openlist_queue.Pop(); - if (idx == UINT32_MAX) return std::pair(idx, nullptr); + uint32_t idx = this->openlist_queue.Pop(); + if (idx == UINT32_MAX) return std::pair(idx, nullptr); OpenListNode *res = this->openlist_nodes[idx]; this->openlist_hash.erase(this->HashKey(res->path.node.tile, res->path.node.direction)); @@ -90,7 +90,7 @@ std::pair AyStar::OpenListPop() void AyStar::OpenListAdd(PathNode *parent, const AyStarNode *node, int f, int g) { /* Add a new Node to the OpenList */ - uint32 idx; + uint32_t idx; OpenListNode *new_node; std::tie(idx, new_node) = this->openlist_nodes.Allocate(); new_node->g = g; @@ -136,7 +136,7 @@ void AyStar::CheckTile(AyStarNode *current, OpenListNode *parent) closedlist_parent = this->ClosedListIsInList(&parent->path.node); /* Check if this item is already in the OpenList */ - uint32 check_idx = this->OpenListIsInList(current); + uint32_t check_idx = this->OpenListIsInList(current); if (check_idx != UINT32_MAX) { OpenListNode *check = this->openlist_nodes[check_idx]; @@ -174,7 +174,7 @@ int AyStar::Loop() /* Get the best node from OpenList */ OpenListNode *current; - uint32 current_idx; + uint32_t current_idx; std::tie(current_idx, current) = this->OpenListPop(); /* If empty, drop an error */ if (current == nullptr) return AYSTAR_EMPTY_OPENLIST; diff --git a/src/pathfinder/npf/aystar.h b/src/pathfinder/npf/aystar.h index dda930d3c8..7ba2b0288f 100644 --- a/src/pathfinder/npf/aystar.h +++ b/src/pathfinder/npf/aystar.h @@ -89,7 +89,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. @@ -97,14 +97,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. @@ -171,19 +171,19 @@ struct AyStar { protected: - inline uint32 HashKey(TileIndex tile, Trackdir td) const { return tile | (td << 28); } + inline uint32_t HashKey(TileIndex tile, Trackdir td) const { return tile | (td << 28); } PodPool closedlist_nodes; - robin_hood::unordered_flat_map closedlist_hash; + robin_hood::unordered_flat_map closedlist_hash; BinaryHeap openlist_queue; ///< The open queue. PodPool openlist_nodes; - robin_hood::unordered_flat_map openlist_hash; + robin_hood::unordered_flat_map openlist_hash; void OpenListAdd(PathNode *parent, const AyStarNode *node, int f, int g); - uint32 OpenListIsInList(const AyStarNode *node); - std::pair OpenListPop(); + uint32_t OpenListIsInList(const AyStarNode *node); + std::pair OpenListPop(); void ClosedListAdd(const PathNode *node); PathNode *ClosedListIsInList(const AyStarNode *node); diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp index 870e7e3ab3..dce96415bb 100644 --- a/src/pathfinder/npf/npf.cpp +++ b/src/pathfinder/npf/npf.cpp @@ -129,7 +129,7 @@ static uint NPFDistanceTrack(TileIndex t0, TileIndex t1) return diagTracks * NPF_TILE_LENGTH + straightTracks * NPF_TILE_LENGTH * STRAIGHT_TRACK_LENGTH; } -static int32 NPFCalcZero(AyStar *as, AyStarNode *current, OpenListNode *parent) +static int32_t NPFCalcZero(AyStar *as, AyStarNode *current, OpenListNode *parent) { return 0; } @@ -137,7 +137,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; @@ -293,9 +293,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 @@ -321,10 +321,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)) { @@ -385,11 +385,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; @@ -536,7 +536,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, @@ -546,7 +546,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); @@ -556,7 +556,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/npf/queue.cpp b/src/pathfinder/npf/queue.cpp index a2ff13c289..8864e5eefb 100644 --- a/src/pathfinder/npf/queue.cpp +++ b/src/pathfinder/npf/queue.cpp @@ -67,7 +67,7 @@ void BinaryHeap::Free() * Pushes an element into the queue, at the appropriate place for the queue. * Requires the queue pointer to be of an appropriate type, of course. */ -bool BinaryHeap::Push(uint32 item, int priority) +bool BinaryHeap::Push(uint32_t item, int priority) { if (this->size == this->max_size) return false; dbg_assert(this->size < this->max_size); @@ -113,7 +113,7 @@ bool BinaryHeap::Push(uint32 item, int priority) * known, which speeds up the deleting for some queue's. Should be -1 * if not known. */ -bool BinaryHeap::Delete(uint32 item, int priority) +bool BinaryHeap::Delete(uint32_t item, int priority) { uint i = 0; @@ -168,7 +168,7 @@ bool BinaryHeap::Delete(uint32 item, int priority) * Pops the first element from the queue. What exactly is the first element, * is defined by the exact type of queue. */ -uint32 BinaryHeap::Pop() +uint32_t BinaryHeap::Pop() { if (this->size == 0) return UINT32_MAX; diff --git a/src/pathfinder/npf/queue.h b/src/pathfinder/npf/queue.h index 99ec7244f6..1f0195a957 100644 --- a/src/pathfinder/npf/queue.h +++ b/src/pathfinder/npf/queue.h @@ -17,7 +17,7 @@ struct BinaryHeapNode { - uint32 item; + uint32_t item; int priority; }; @@ -33,9 +33,9 @@ struct BinaryHeap { void Init(uint max_size); - bool Push(uint32 item, int priority); - uint32 Pop(); - bool Delete(uint32 item, int priority); + bool Push(uint32_t item, int priority); + uint32_t Pop(); + bool Delete(uint32_t item, int priority); void Clear(); void Free(); diff --git a/src/pathfinder/yapf/yapf_node_rail.hpp b/src/pathfinder/yapf/yapf_node_rail.hpp index 1cbcc43d1b..9767bf3918 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,12 +123,12 @@ struct CYapfRailNodeT typedef CYapfRailSegment CachedData; CYapfRailSegment *m_segment; - uint16 m_num_signals_passed; - uint16 m_num_signals_res_through_passed; + uint16_t m_num_signals_passed; + uint16_t m_num_signals_res_through_passed; TileIndex m_last_non_reserve_through_signal_tile; Trackdir m_last_non_reserve_through_signal_td; 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/pbs.cpp b/src/pbs.cpp index b29bf340af..6eb86a46b5 100644 --- a/src/pbs.cpp +++ b/src/pbs.cpp @@ -356,10 +356,10 @@ static int LookaheadTileHeightForChunnel(int length, int offset) return 0; } -static uint16 ApplyTunnelBridgeLookaheadSignalSpeedRestriction(TileIndex tile, Trackdir trackdir, const Train *v, - uint16 initial_speed_restriction, TrainReservationLookAhead *lookahead, int offset, int16 z) +static uint16_t ApplyTunnelBridgeLookaheadSignalSpeedRestriction(TileIndex tile, Trackdir trackdir, const Train *v, + uint16_t initial_speed_restriction, TrainReservationLookAhead *lookahead, int offset, int16_t z) { - uint16 speed_restriction = initial_speed_restriction; + uint16_t speed_restriction = initial_speed_restriction; if (v != nullptr && IsTunnelBridgeRestrictedSignal(tile)) { if (trackdir == INVALID_TRACKDIR) { @@ -389,9 +389,9 @@ static uint16 ApplyTunnelBridgeLookaheadSignalSpeedRestriction(TileIndex tile, T return speed_restriction; } -static uint16 GetTrainSpeedLimitForRailtype(const Train *v, RailType rt, TileIndex tile, Track track) +static uint16_t GetTrainSpeedLimitForRailtype(const Train *v, RailType rt, TileIndex tile, Track track) { - uint16 speed = GetRailTypeInfo(rt)->max_speed; + uint16_t speed = GetRailTypeInfo(rt)->max_speed; if (v->tcache.cached_tflags & TCF_SPD_RAILTYPE) { for (const Train *u = v; u != nullptr; u = u->Next()) { if (u->GetEngine()->callbacks_used & SGCU_CB36_SPEED_RAILTYPE) { @@ -399,7 +399,7 @@ static uint16 GetTrainSpeedLimitForRailtype(const Train *v, RailType rt, TileInd const TrackBits prev_track = u->track; const_cast(u)->tile = tile; const_cast(u)->track = TrackToTrackBits(track); - uint16 cb_speed = GetVehicleProperty(u, PROP_TRAIN_SPEED, speed); + uint16_t cb_speed = GetVehicleProperty(u, PROP_TRAIN_SPEED, speed); if (cb_speed != 0 && (cb_speed < speed || speed == 0)) speed = cb_speed; const_cast(u)->tile = prev_tile; const_cast(u)->track = prev_track; @@ -409,7 +409,7 @@ static uint16 GetTrainSpeedLimitForRailtype(const Train *v, RailType rt, TileInd return speed; } -static void AddSignalToLookAhead(const Train *v, TrainReservationLookAhead *lookahead, uint16 signal_speed, uint16 signal_flags, TileIndex signal_tile, uint16 signal_track, int offset, int16 z_pos) +static void AddSignalToLookAhead(const Train *v, TrainReservationLookAhead *lookahead, uint16_t signal_speed, uint16_t signal_flags, TileIndex signal_tile, uint16_t signal_track, int offset, int16_t z_pos) { lookahead->AddSignal(signal_speed, offset, z_pos, signal_flags); if (_settings_game.vehicle.train_speed_adaptation) { @@ -462,7 +462,7 @@ static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Tra auto check_rail_type = [&](TileIndex t, Trackdir td, int offset) { RailType new_rt = GetRailTypeByTrack(t, TrackdirToTrack(td)); if (new_rt != rt) { - uint16 rail_speed = GetTrainSpeedLimitForRailtype(v, new_rt, t, TrackdirToTrack(td)); + uint16_t rail_speed = GetTrainSpeedLimitForRailtype(v, new_rt, t, TrackdirToTrack(td)); if (rail_speed > 0) lookahead->AddTrackSpeedLimit(rail_speed, offset, 4, z); if (GetRailTypeInfo(rt)->curve_speed != GetRailTypeInfo(new_rt)->curve_speed) { CheckCurveLookAhead(v, lookahead, lookahead->RealEndPosition() + 4 + offset, z, new_rt); @@ -577,7 +577,7 @@ static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Tra } check_direction(TrackdirToDirection(trackdir), ft.m_tiles_skipped * TILE_SIZE, tile); if (IsTileType(tile, MP_TUNNELBRIDGE) && TrackdirEntersTunnelBridge(tile, trackdir)) { - uint16 bridge_speed = 0; + uint16_t bridge_speed = 0; if (IsBridge(tile)) { bridge_speed = GetBridgeSpec(GetBridgeType(tile))->speed; lookahead->AddTrackSpeedLimit(bridge_speed, 0, 8, z); @@ -589,13 +589,13 @@ static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Tra const int spacing = GetTunnelBridgeSignalSimulationSpacing(tile); const int signals = length / spacing; - uint16 speed_restriction = ApplyTunnelBridgeLookaheadSignalSpeedRestriction(tile, trackdir, v, lookahead->speed_restriction, lookahead, 0, z); + uint16_t speed_restriction = ApplyTunnelBridgeLookaheadSignalSpeedRestriction(tile, trackdir, v, lookahead->speed_restriction, lookahead, 0, z); - uint16 signal_speed = GetRailTypeInfo(rt)->max_speed; + uint16_t signal_speed = GetRailTypeInfo(rt)->max_speed; if (signal_speed == 0 || (speed_restriction != 0 && speed_restriction < signal_speed)) signal_speed = speed_restriction; if (signal_speed == 0 || (bridge_speed != 0 && bridge_speed < signal_speed)) signal_speed = bridge_speed; - const uint16 signal_flags = GetTunnelBridgeSignalStyle(tile) << 8; + const uint16_t signal_flags = GetTunnelBridgeSignalStyle(tile) << 8; /* Entrance signal */ AddSignalToLookAhead(v, lookahead, signal_speed, signal_flags, tile, TrackdirToTrack(trackdir), 0, z); @@ -619,7 +619,7 @@ static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Tra /* Exit signal */ const int end_offset = start_offset + (TILE_SIZE * length); - uint16 exit_speed_restriction = ApplyTunnelBridgeLookaheadSignalSpeedRestriction(end, INVALID_TRACKDIR, v, lookahead->speed_restriction, lookahead, end_offset, z); + uint16_t exit_speed_restriction = ApplyTunnelBridgeLookaheadSignalSpeedRestriction(end, INVALID_TRACKDIR, v, lookahead->speed_restriction, lookahead, end_offset, z); if (exit_speed_restriction != speed_restriction) { speed_restriction = exit_speed_restriction; signal_speed = GetRailTypeInfo(rt)->max_speed; @@ -647,7 +647,7 @@ static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Tra /* Passing through a signal from the rear side */ au_flags = TRPAUF_SPEED_RESTRICTION | TRPAUF_REVERSE; } - uint16 speed_restriction = lookahead->speed_restriction; + uint16_t speed_restriction = lookahead->speed_restriction; if (v != nullptr) { const TraceRestrictProgram *prog = GetExistingTraceRestrictProgram(tile, TrackdirToTrack(trackdir)); if (prog && prog->actions_used_flags & au_flags) { @@ -668,10 +668,10 @@ static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Tra } if (!(au_flags & TRPAUF_REVERSE)) { /* Passing through a signal from the front side */ - uint16 signal_speed = GetRailTypeInfo(rt)->max_speed; + uint16_t signal_speed = GetRailTypeInfo(rt)->max_speed; if (signal_speed == 0 || (speed_restriction != 0 && speed_restriction < signal_speed)) signal_speed = speed_restriction; - uint8 signal_style = GetSignalStyle(tile, TrackdirToTrack(trackdir)); - uint16 signal_flags = signal_style << 8; + uint8_t signal_style = GetSignalStyle(tile, TrackdirToTrack(trackdir)); + uint16_t signal_flags = signal_style << 8; if (HasBit(_signal_style_masks.non_aspect_inc, signal_style)) { SetBit(signal_flags, TRSLAI_NO_ASPECT_INC); } @@ -859,7 +859,7 @@ static Vehicle *FindTrainOnTrackEnum(Vehicle *v, void *data) void TrainReservationLookAhead::SetNextExtendPosition() { - int32 threshold = this->current_position + 24; + int32_t threshold = this->current_position + 24; for (const TrainReservationLookAheadItem &item : this->items) { if (item.type == TRLIT_SIGNAL && item.start > threshold) { this->next_extend_position = item.start - 24; @@ -972,7 +972,7 @@ void FillLookAheadCurveDataFromTrainPosition(Train *t) { TileIndex tile = TileVirtXY(t->x_pos, t->y_pos); Direction dir = t->direction; - int32 current_pos = t->lookahead->reservation_end_position + 4 - ((dir & 1) ? 16 : 8); + int32_t current_pos = t->lookahead->reservation_end_position + 4 - ((dir & 1) ? 16 : 8); for (Train *u = t->Next(); u != nullptr; u = u->Next()) { TileIndex cur_tile = TileVirtXY(u->x_pos, u->y_pos); if (cur_tile == tile) continue; @@ -1021,7 +1021,7 @@ static int ScanTrainPositionForLookAheadStation(Train *t, TileIndex start_tile) TileIndex new_tile = tile + (i * diff); RailType new_rt = GetRailTypeByTrack(new_tile, TrackdirToTrack(trackdir)); if (new_rt != rt) { - uint16 rail_speed = GetTrainSpeedLimitForRailtype(t, new_rt, new_tile, TrackdirToTrack(trackdir)); + uint16_t rail_speed = GetTrainSpeedLimitForRailtype(t, new_rt, new_tile, TrackdirToTrack(trackdir)); if (rail_speed > 0) t->lookahead->AddTrackSpeedLimit(rail_speed, (i - 1) * TILE_SIZE, 4, z); rt = new_rt; } @@ -1064,20 +1064,20 @@ void TryCreateLookAheadForTrainInTunnelBridge(Train *t) if (IsTunnel(t->tile) && Tunnel::GetByTile(t->tile)->is_chunnel) SetBit(t->lookahead->flags, TRLF_CHUNNEL); if (IsTunnelBridgeSignalSimulationEntrance(t->tile)) { - const uint16 bridge_speed = IsBridge(t->tile) ? GetBridgeSpec(GetBridgeType(t->tile))->speed : 0; + const uint16_t bridge_speed = IsBridge(t->tile) ? GetBridgeSpec(GetBridgeType(t->tile))->speed : 0; const TileIndex end = GetOtherTunnelBridgeEnd(t->tile); const int length = GetTunnelBridgeLength(t->tile, end); const int spacing = GetTunnelBridgeSignalSimulationSpacing(t->tile); const int signals = length / spacing; const RailType rt = GetRailTypeByTrack(t->tile, TrackdirToTrack(t->lookahead->reservation_end_trackdir)); - uint16 signal_speed = GetRailTypeInfo(rt)->max_speed; + uint16_t signal_speed = GetRailTypeInfo(rt)->max_speed; if (signal_speed == 0 || (t->speed_restriction != 0 && t->speed_restriction < signal_speed)) signal_speed = t->speed_restriction; if (signal_speed == 0 || (bridge_speed != 0 && bridge_speed < signal_speed)) signal_speed = bridge_speed; int z = IsBridge(t->tile) ? GetBridgeHeight(t->tile) : GetTilePixelZ(t->tile); - const uint16 signal_flags = GetTunnelBridgeSignalStyle(t->tile) << 8; + const uint16_t signal_flags = GetTunnelBridgeSignalStyle(t->tile) << 8; /* Middle signals */ int offset = -(int)TILE_SIZE; @@ -1090,7 +1090,7 @@ void TryCreateLookAheadForTrainInTunnelBridge(Train *t) /* Exit signal */ const int end_offset = TILE_SIZE * length; - uint16 exit_speed_restriction = ApplyTunnelBridgeLookaheadSignalSpeedRestriction(end, INVALID_TRACKDIR, t, t->speed_restriction, t->lookahead.get(), end_offset, z); + uint16_t exit_speed_restriction = ApplyTunnelBridgeLookaheadSignalSpeedRestriction(end, INVALID_TRACKDIR, t, t->speed_restriction, t->lookahead.get(), end_offset, z); if (exit_speed_restriction != t->speed_restriction) { signal_speed = GetRailTypeInfo(rt)->max_speed; if (signal_speed == 0 || (exit_speed_restriction != 0 && exit_speed_restriction < signal_speed)) signal_speed = exit_speed_restriction; @@ -1118,8 +1118,8 @@ int AdvanceTrainReservationLookaheadEnd(const Train *v, int lookahead_end_positi if (lookahead_end_position > v->lookahead->reservation_end_position) return lookahead_end_position; - int32 threshold = v->lookahead->current_position + 24; - uint8 known_signals_ahead = 1; + int32_t threshold = v->lookahead->current_position + 24; + uint8_t known_signals_ahead = 1; bool allow_skip_no_aspect_inc = false; if (v->IsInDepot()) { known_signals_ahead = _extra_aspects + 1; @@ -1142,8 +1142,8 @@ int AdvanceTrainReservationLookaheadEnd(const Train *v, int lookahead_end_positi if (item.start <= threshold) { /* Signal is within visual range */ - uint8 style = item.data_aux >> 8; - uint8 max_aspect = (style == 0) ? _extra_aspects : _new_signal_styles[style - 1].lookahead_extra_aspects; + uint8_t style = item.data_aux >> 8; + uint8_t max_aspect = (style == 0) ? _extra_aspects : _new_signal_styles[style - 1].lookahead_extra_aspects; if (max_aspect == 0xFF) { /* This signal has unlimited lookahead */ return v->lookahead->reservation_end_position + 1; @@ -1185,7 +1185,7 @@ void FillTrainReservationLookAhead(Train *v) if (v->lookahead == nullptr) return; } - int32 old_reservation_end_position = 0; + int32_t old_reservation_end_position = 0; if (v->lookahead == nullptr) { v->lookahead.reset(new TrainReservationLookAhead()); @@ -1281,7 +1281,7 @@ void FillTrainReservationLookAhead(Train *v) if (_settings_game.vehicle.train_speed_adaptation && v->signal_speed_restriction > 0 && v->lookahead->reservation_end_position > old_reservation_end_position) { for (const TrainReservationLookAheadItem &item : v->lookahead->items) { if (item.type == TRLIT_SPEED_ADAPTATION && item.end + 1 >= old_reservation_end_position && item.end + 1 < v->lookahead->reservation_end_position) { - uint16 signal_speed = GetLowestSpeedTrainAdaptationSpeedAtSignal(item.data_id, item.data_aux); + uint16_t signal_speed = GetLowestSpeedTrainAdaptationSpeedAtSignal(item.data_id, item.data_aux); if (signal_speed == 0) { /* unrestricted signal ahead, remove current speed adaptation */ diff --git a/src/pbs.h b/src/pbs.h index 467e2a9747..ae368a59c7 100644 --- a/src/pbs.h +++ b/src/pbs.h @@ -68,18 +68,18 @@ enum TrainReservationSignalLookAheadItemFlags { }; struct TrainReservationLookAheadItem { - int32 start; - int32 end; - int16 z_pos; + int32_t start; + int32_t end; + int16_t z_pos; /* gap: 2 bytes */ - uint32 data_id; - uint16 data_aux; + uint32_t data_id; + uint16_t data_aux; TrainReservationLookAheadItemType type; /* gap: 1 byte */ }; struct TrainReservationLookAheadCurve { - int32 position; + int32_t position; DirDiff dir_diff; }; @@ -93,62 +93,62 @@ enum TrainReservationLookAheadFlags { struct TrainReservationLookAhead { TileIndex reservation_end_tile; ///< Tile the reservation ends. Trackdir reservation_end_trackdir; ///< The reserved trackdir on the end tile. - int32 current_position; ///< Current position of the train on the reservation - int32 reservation_end_position; ///< Position of the end of the reservation - int32 lookahead_end_position; ///< Position of the end of the reservation within the lookahead distance - int32 next_extend_position; ///< Next position to try extending the reservation at the sighting distance of the next mid-reservation signal - int16 reservation_end_z; ///< The z coordinate of the reservation end - int16 tunnel_bridge_reserved_tiles; ///< How many tiles a reservation into the tunnel/bridge currently extends into the wormhole - uint16 flags; ///< Flags (TrainReservationLookAheadFlags) - uint16 speed_restriction; + int32_t current_position; ///< Current position of the train on the reservation + int32_t reservation_end_position; ///< Position of the end of the reservation + int32_t lookahead_end_position; ///< Position of the end of the reservation within the lookahead distance + int32_t next_extend_position; ///< Next position to try extending the reservation at the sighting distance of the next mid-reservation signal + int16_t reservation_end_z; ///< The z coordinate of the reservation end + int16_t tunnel_bridge_reserved_tiles; ///< How many tiles a reservation into the tunnel/bridge currently extends into the wormhole + uint16_t flags; ///< Flags (TrainReservationLookAheadFlags) + uint16_t speed_restriction; ring_buffer items; ring_buffer curves; - int32 cached_zpos = 0; ///< Cached z position as used in TrainDecelerationStats - uint8 zpos_refresh_remaining = 0; ///< Remaining position updates before next refresh of cached_zpos + int32_t cached_zpos = 0; ///< Cached z position as used in TrainDecelerationStats + uint8_t zpos_refresh_remaining = 0; ///< Remaining position updates before next refresh of cached_zpos - int32 RealEndPosition() const + int32_t RealEndPosition() const { return this->reservation_end_position - (this->tunnel_bridge_reserved_tiles * TILE_SIZE); } - void AddStation(int tiles, StationID id, int16 z_pos) + void AddStation(int tiles, StationID id, int16_t z_pos) { int end = this->RealEndPosition(); this->items.push_back({ end, end + (((int)TILE_SIZE) * tiles), z_pos, id, 0, TRLIT_STATION }); } - void AddReverse(int16 z_pos) + void AddReverse(int16_t z_pos) { int end = this->RealEndPosition(); this->items.push_back({ end, end, z_pos, 0, 0, TRLIT_REVERSE }); } - void AddTrackSpeedLimit(uint16 speed, int offset, int duration, int16 z_pos) + void AddTrackSpeedLimit(uint16_t speed, int offset, int duration, int16_t z_pos) { int end = this->RealEndPosition(); this->items.push_back({ end + offset, end + offset + duration, z_pos, speed, 0, TRLIT_TRACK_SPEED }); } - void AddSpeedRestriction(uint16 speed, int offset, int duration, int16 z_pos) + void AddSpeedRestriction(uint16_t speed, int offset, int duration, int16_t z_pos) { int end = this->RealEndPosition(); this->items.push_back({ end + offset, end + offset + duration, z_pos, speed, 0, TRLIT_SPEED_RESTRICTION }); this->speed_restriction = speed; } - void AddSignal(uint16 target_speed, int offset, int16 z_pos, uint16 flags) + void AddSignal(uint16_t target_speed, int offset, int16_t z_pos, uint16_t flags) { int end = this->RealEndPosition(); this->items.push_back({ end + offset, end + offset, z_pos, target_speed, flags, TRLIT_SIGNAL }); } - void AddCurveSpeedLimit(uint16 target_speed, int offset, int16 z_pos) + void AddCurveSpeedLimit(uint16_t target_speed, int offset, int16_t z_pos) { int end = this->RealEndPosition(); this->items.push_back({ end + offset, end + offset, z_pos, target_speed, 0, TRLIT_CURVE_SPEED }); } - void AddSpeedAdaptation(TileIndex signal_tile, uint16 signal_track, int offset, int16 z_pos) + void AddSpeedAdaptation(TileIndex signal_tile, uint16_t signal_track, int offset, int16_t z_pos) { int end = this->RealEndPosition(); this->items.push_back({ end + offset, end + offset, z_pos, signal_tile, signal_track, TRLIT_SPEED_ADAPTATION }); diff --git a/src/plans_base.h b/src/plans_base.h index 52bb30b479..7b528c1cdb 100644 --- a/src/plans_base.h +++ b/src/plans_base.h @@ -110,7 +110,7 @@ struct PlanLine { } } - void AddLineToCalculateCentreTile(uint64 &x, uint64 &y, uint32 &count) const + void AddLineToCalculateCentreTile(uint64_t &x, uint64_t &y, uint32_t &count) const { for (size_t i = 0; i < this->tiles.size(); i++) { TileIndex t = this->tiles[i]; @@ -122,9 +122,9 @@ struct PlanLine { TileIndex CalculateCentreTile() const { - uint64 x = 0; - uint64 y = 0; - uint32 count = 0; + uint64_t x = 0; + uint64_t y = 0; + uint32_t count = 0; this->AddLineToCalculateCentreTile(x, y, count); if (count == 0) return INVALID_TILE; return TileXY(x / count, y / count); @@ -237,9 +237,9 @@ struct Plan : PlanPool::PoolItem<&_plan_pool> { TileIndex CalculateCentreTile() const { - uint64 x = 0; - uint64 y = 0; - uint32 count = 0; + uint64_t x = 0; + uint64_t y = 0; + uint32_t count = 0; for (PlanLineVector::const_iterator it = lines.begin(); it != lines.end(); it++) { (*it)->AddLineToCalculateCentreTile(x, y, count); } diff --git a/src/plans_cmd.cpp b/src/plans_cmd.cpp index 4aa67b0ec3..8852869de3 100644 --- a/src/plans_cmd.cpp +++ b/src/plans_cmd.cpp @@ -27,7 +27,7 @@ * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdAddPlan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdAddPlan(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (!Plan::CanAllocateItem()) return_cmd_error(STR_ERROR_TOO_MANY_PLANS); Owner o = (Owner) p1; @@ -49,7 +49,7 @@ struct PlanLineCmdData : public CommandAuxiliarySerialisable { virtual void Serialise(CommandSerialisationBuffer &buffer) const override { - buffer.Send_uint32((uint32)this->tiles.size()); + buffer.Send_uint32((uint32_t)this->tiles.size()); for (TileIndex t : this->tiles) { buffer.Send_uint32(t); } @@ -57,7 +57,7 @@ struct PlanLineCmdData : public CommandAuxiliarySerialisable { CommandCost Deserialise(CommandDeserialisationBuffer &buffer) { - uint32 size = buffer.Recv_uint32(); + uint32_t size = buffer.Recv_uint32(); if (!buffer.CanRecvBytes(size * 4)) return CMD_ERROR; this->tiles.resize(size); for (uint i = 0; i < size; i++) { @@ -84,7 +84,7 @@ bool AddPlanLine(PlanID plan, TileVector tiles) * @param aux_data auxiliary data * @return the cost of this operation or an error */ -CommandCost CmdAddPlanLine(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdAddPlanLine(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { Plan *p = Plan::GetIfValid(p1); if (p == nullptr) return CMD_ERROR; @@ -120,7 +120,7 @@ CommandCost CmdAddPlanLine(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdChangePlanVisibility(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdChangePlanVisibility(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Plan *p = Plan::GetIfValid(p1); if (p == nullptr) return CMD_ERROR; @@ -151,7 +151,7 @@ CommandCost CmdChangePlanVisibility(TileIndex tile, DoCommandFlag flags, uint32 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdChangePlanColour(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdChangePlanColour(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Plan *p = Plan::GetIfValid(p1); if (p == nullptr) return CMD_ERROR; @@ -179,7 +179,7 @@ CommandCost CmdChangePlanColour(TileIndex tile, DoCommandFlag flags, uint32 p1, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdRemovePlan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRemovePlan(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Plan *p = Plan::GetIfValid(p1); if (p == nullptr) return CMD_ERROR; @@ -206,7 +206,7 @@ CommandCost CmdRemovePlan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdRemovePlanLine(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRemovePlanLine(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Plan *p = Plan::GetIfValid(p1); if (p == nullptr) return CMD_ERROR; @@ -236,7 +236,7 @@ CommandCost CmdRemovePlanLine(TileIndex tile, DoCommandFlag flags, uint32 p1, ui * @param text the new name * @return the cost of this operation or an error */ -CommandCost CmdRenamePlan(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRenamePlan(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (text == nullptr) return CMD_ERROR; diff --git a/src/plans_gui.cpp b/src/plans_gui.cpp index eaebd32320..4e2c68a4e2 100644 --- a/src/plans_gui.cpp +++ b/src/plans_gui.cpp @@ -280,7 +280,7 @@ struct PlansWindow : Window { uint text_right = (rtl ? btn_left - 4 : ir.right); const_cast(this)->vis_btn_left = btn_left; - 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++) { Plan *p = Plan::Get(list[i].plan_id); if (i == this->selected) GfxFillRect(r.left + 1, y, r.right, y + this->resize.step_height, PC_DARK_GREY); @@ -353,7 +353,7 @@ struct PlansWindow : Window { case WID_PLN_COLOUR: { Dimension dim = GetStringBoundingBox(STR_PLANS_COLOUR); - for (uint8 colour = COLOUR_BEGIN; colour != COLOUR_END; ++colour) { + for (uint8_t colour = COLOUR_BEGIN; colour != COLOUR_END; ++colour) { dim = maxdim(dim, GetStringBoundingBox(STR_COLOUR_DARK_BLUE + colour)); } *size = adddim(dim, padding); @@ -491,7 +491,7 @@ void ShowPlansWindow() * Only the creator of a plan executes this function. * The other players should not be bothered with these changes. */ -void CcAddPlan(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcAddPlan(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; diff --git a/src/plans_type.h b/src/plans_type.h index 309468e15e..902933ec7c 100644 --- a/src/plans_type.h +++ b/src/plans_type.h @@ -13,7 +13,7 @@ #include "stdafx.h" #include "tile_type.h" -typedef uint16 PlanID; +typedef uint16_t PlanID; struct PlanLine; struct Plan; diff --git a/src/programmable_signals.cpp b/src/programmable_signals.cpp index 17250755b6..05253841b1 100644 --- a/src/programmable_signals.cpp +++ b/src/programmable_signals.cpp @@ -80,7 +80,7 @@ SignalSimpleCondition::SignalSimpleCondition(SignalConditionCode code) } } -bool SignalConditionComparable::EvaluateComparable(uint32 var_val) +bool SignalConditionComparable::EvaluateComparable(uint32_t var_val) { switch (this->comparator) { case SGC_EQUALS: return var_val == this->value; @@ -108,7 +108,7 @@ SignalVariableCondition::SignalVariableCondition(SignalConditionCode code) /*virtual*/ bool SignalVariableCondition::Evaluate(SignalVM &vm) { - uint32 var_val; + uint32_t var_val; switch (this->cond_code) { case PSC_NUM_GREEN: var_val = vm.num_green; break; case PSC_NUM_RED: var_val = vm.num_exits - vm.num_green; break; @@ -662,7 +662,7 @@ void SignalProgram::DebugPrintProgram() * - Colour to set the signal to * @param text unused */ -CommandCost CmdInsertSignalInstruction(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdInsertSignalInstruction(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Track track = Extract(p1); uint instruction_id = GB(p1, 3, 16); @@ -737,7 +737,7 @@ CommandCost CmdInsertSignalInstruction(TileIndex tile, DoCommandFlag flags, uint * - Bits 5-31: Tile on which signal is located * @param text unused */ -CommandCost CmdModifySignalInstruction(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdModifySignalInstruction(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Track track = Extract(p1); uint instruction_id = GB(p1, 3, 16); @@ -817,7 +817,7 @@ CommandCost CmdModifySignalInstruction(TileIndex tile, DoCommandFlag flags, uint case PSC_NUM_RED: { SignalVariableCondition *vc = static_cast(si->condition); SignalConditionField f = (SignalConditionField) GB(p2, 1, 2); - uint32 val = GB(p2, 3, 27); + uint32_t val = GB(p2, 3, 27); if (f == SCF_COMPARATOR) { if (val > SGC_LAST) return_cmd_error(STR_ERR_PROGSIG_INVALID_COMPARATOR); if (!exec) return CommandCost(); @@ -846,7 +846,7 @@ CommandCost CmdModifySignalInstruction(TileIndex tile, DoCommandFlag flags, uint case PSC_SLOT_OCC_REM: { SignalSlotCondition *sc = static_cast(si->condition); SignalConditionField f = (SignalConditionField) GB(p2, 1, 2); - uint32 val = GB(p2, 3, 27); + uint32_t val = GB(p2, 3, 27); if (f == SCF_COMPARATOR) { if (val > SGC_LAST) return_cmd_error(STR_ERR_PROGSIG_INVALID_COMPARATOR); if (!exec) return CommandCost(); @@ -866,7 +866,7 @@ CommandCost CmdModifySignalInstruction(TileIndex tile, DoCommandFlag flags, uint case PSC_COUNTER: { SignalCounterCondition *sc = static_cast(si->condition); SignalConditionField f = (SignalConditionField) GB(p2, 1, 2); - uint32 val = GB(p2, 3, 27); + uint32_t val = GB(p2, 3, 27); if (f == SCF_COMPARATOR) { if (val > SGC_LAST) return_cmd_error(STR_ERR_PROGSIG_INVALID_COMPARATOR); if (!exec) return CommandCost(); @@ -911,7 +911,7 @@ CommandCost CmdModifySignalInstruction(TileIndex tile, DoCommandFlag flags, uint * @param p2 unused * @param text unused */ -CommandCost CmdRemoveSignalInstruction(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRemoveSignalInstruction(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Track track = Extract(p1); uint instruction_id = GB(p1, 3, 16); @@ -1048,7 +1048,7 @@ static void CloneInstructions(SignalProgram *prog, SignalInstruction *insert_bef * - Tile of clone source signal * @param text unused */ -CommandCost CmdSignalProgramMgmt(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSignalProgramMgmt(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { bool exec = (flags & DC_EXEC) != 0; diff --git a/src/programmable_signals.h b/src/programmable_signals.h index d438839db4..26ba6a627c 100644 --- a/src/programmable_signals.h +++ b/src/programmable_signals.h @@ -188,12 +188,12 @@ enum SignalConditionField { class SignalConditionComparable: public SignalCondition { protected: - bool EvaluateComparable(uint32 var_val); + bool EvaluateComparable(uint32_t var_val); public: SignalConditionComparable(SignalConditionCode code) : SignalCondition(code) {} SignalComparator comparator; - uint32 value; + uint32_t value; }; /** A conditon based upon comparing a variable and a value. This condition can be diff --git a/src/programmable_signals_gui.cpp b/src/programmable_signals_gui.cpp index f3495f6a5a..e11341b8ce 100644 --- a/src/programmable_signals_gui.cpp +++ b/src/programmable_signals_gui.cpp @@ -294,7 +294,7 @@ public: SignalInstruction *ins = GetSelected(); if (ins == nullptr) return; - uint32 p1 = 0; + uint32_t p1 = 0; SB(p1, 0, 3, this->track); SB(p1, 3, 16, ins->Id()); @@ -498,7 +498,7 @@ public: return; } - uint32 p1 = 0, p2 = 0; + uint32_t p1 = 0, p2 = 0; SB(p1, 0, 3, this->track); SB(p1, 3, 16, si->Id()); @@ -522,7 +522,7 @@ public: uint value = atoi(str); - uint32 p1 = 0, p2 = 0; + uint32_t p1 = 0, p2 = 0; SB(p1, 0, 3, this->track); SB(p1, 3, 16, si->Id()); @@ -541,7 +541,7 @@ public: switch (widget) { case PROGRAM_WIDGET_INSERT: { - uint64 p1 = 0; + uint64_t p1 = 0; SB(p1, 0, 3, this->track); SB(p1, 3, 16, ins->Id()); SB(p1, 19, 8, OpcodeForIndex(index)); @@ -552,7 +552,7 @@ public: } case PROGRAM_WIDGET_SET_STATE: { - uint64 p1 = 0; + uint64_t p1 = 0; SB(p1, 0, 3, this->track); SB(p1, 3, 16, ins->Id()); @@ -561,7 +561,7 @@ public: } case PROGRAM_WIDGET_COND_VARIABLE: { - uint64 p1 = 0, p2 = 0; + uint64_t p1 = 0, p2 = 0; SB(p1, 0, 3, this->track); SB(p1, 3, 16, ins->Id()); @@ -573,7 +573,7 @@ public: } case PROGRAM_WIDGET_COND_COMPARATOR: { - uint64 p1 = 0, p2 = 0; + uint64_t p1 = 0, p2 = 0; SB(p1, 0, 3, this->track); SB(p1, 3, 16, ins->Id()); @@ -587,7 +587,7 @@ public: case PROGRAM_WIDGET_COND_SLOT: case PROGRAM_WIDGET_COND_COUNTER: { - uint64 p1 = 0, p2 = 0; + uint64_t p1 = 0, p2 = 0; SB(p1, 0, 3, this->track); SB(p1, 3, 16, ins->Id()); @@ -971,7 +971,7 @@ static WindowDesc _program_desc(__FILE__, __LINE__, void ShowSignalProgramWindow(SignalReference ref) { - uint32 window_id = (ref.tile << 3) | ref.track; + uint32_t window_id = (ref.tile << 3) | ref.track; if (BringWindowToFrontById(WC_SIGNAL_PROGRAM, window_id) != nullptr) return; new ProgramWindow(&_program_desc, ref); diff --git a/src/querystring_gui.h b/src/querystring_gui.h index 111cea490a..1abc2ef98b 100644 --- a/src/querystring_gui.h +++ b/src/querystring_gui.h @@ -37,7 +37,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 40c6c77aec..d937e150d5 100644 --- a/src/rail.h +++ b/src/rail.h @@ -229,27 +229,27 @@ public: /** * Signal extra aspects */ - uint8 signal_extra_aspects; + uint8_t signal_extra_aspects; /** * 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 diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index a95bebe59e..de124719b3 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -70,7 +70,7 @@ void ResetRailTypes() _railtypes_hidden_mask = RAILTYPES_NONE; } -void ResolveRailTypeGUISignalSprites(RailTypeInfo *rti, uint8 style, PalSpriteID signals[SIGTYPE_END][2][2]) +void ResolveRailTypeGUISignalSprites(RailTypeInfo *rti, uint8_t style, PalSpriteID signals[SIGTYPE_END][2][2]) { /* Array of default GUI signal sprite numbers. */ const SpriteID _signal_lookup[2][SIGTYPE_END] = { @@ -213,7 +213,7 @@ void UpdateRailGuiSprites() ResolveRailTypeGUISprites(&_railtypes[rt]); } - for (uint8 style = 0; style < _num_new_signal_styles; style++) { + for (uint8_t style = 0; style < _num_new_signal_styles; style++) { ResolveRailTypeGUISignalSprites(nullptr, style + 1, _new_signal_styles[style].signals); } } @@ -659,7 +659,7 @@ static inline bool ValParamTrackOrientation(Track track) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { RailType railtype = Extract(p1); Track track = Extract(p2); @@ -928,7 +928,7 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Track track = Extract(p2); CommandCost cost(EXPENSES_CONSTRUCTION); @@ -1273,7 +1273,7 @@ static CommandCost ValidateAutoDrag(Trackdir *trackdir, TileIndex start, TileInd * @param text unused * @return the cost of this operation or an error */ -static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { CommandCost total_cost(EXPENSES_CONSTRUCTION); RailType railtype = Extract(p2); @@ -1345,7 +1345,7 @@ static CommandCost CmdRailTrackHelper(TileIndex tile, DoCommandFlag flags, uint3 * @return the cost of this operation or an error * @see CmdRailTrackHelper */ -CommandCost CmdBuildRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { return CmdRailTrackHelper(tile, flags, p1, ClrBit(p2, 9), text); } @@ -1368,7 +1368,7 @@ CommandCost CmdBuildRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1 * @return the cost of this operation or an error * @see CmdRailTrackHelper */ -CommandCost CmdRemoveRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRemoveRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { return CmdRailTrackHelper(tile, flags, p1, SetBit(p2, 9), text); } @@ -1385,7 +1385,7 @@ CommandCost CmdRemoveRailroadTrack(TileIndex tile, DoCommandFlag flags, uint32 p * @todo When checking for the tile slope, * distinguish between "Flat land required" and "land sloped in wrong direction" */ -CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { /* check railtype and valid direction for depot (0 through 3), 4 in total */ RailType railtype = Extract(p1); @@ -1488,7 +1488,7 @@ static void ReReserveTrainPath(Train *v) * @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(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Track track = Extract(p1); bool ctrl_pressed = HasBit(p1, 3); // was the CTRL button pressed @@ -1521,7 +1521,7 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, CommandCost ret = CheckTileOwnership(tile); if (ret.Failed()) return ret; - auto is_style_usable = [](SignalVariant sigvar, uint8 style_id, uint8 mask) { + auto is_style_usable = [](SignalVariant sigvar, uint8_t style_id, uint8_t mask) { if (style_id == 0) return true; const NewSignalStyle &style = _new_signal_styles[style_id - 1]; @@ -1571,8 +1571,8 @@ CommandCost CmdBuildSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, const bool is_semaphore = IsTunnelBridgeSemaphore(tile); bool will_be_semaphore = is_semaphore; bool will_be_pbs = IsTunnelBridgePBS(tile); - const uint8 is_style = GetTunnelBridgeSignalStyle(tile); - uint8 will_be_style = is_style; + const uint8_t is_style = GetTunnelBridgeSignalStyle(tile); + uint8_t will_be_style = is_style; if (!p2_active) { if (convert_signal) { will_be_bidi = bidirectional && !ctrl_pressed; @@ -1988,7 +1988,7 @@ static bool CheckSignalAutoFill(TileIndex &tile, Trackdir &trackdir, int &signal * @param text unused * @return the cost of this operation or an error */ -static CommandCost CmdSignalTrackHelper(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text) +static CommandCost CmdSignalTrackHelper(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text) { CommandCost total_cost(EXPENSES_CONSTRUCTION); TileIndex start_tile = tile; @@ -2000,7 +2000,7 @@ static CommandCost CmdSignalTrackHelper(TileIndex tile, DoCommandFlag flags, uin bool autofill = HasBit(p2, 6); bool minimise_gaps = HasBit(p2, 10); byte signal_density = GB(p2, 24, 8); - uint8 signal_style = GB(p2, 11, 4); + uint8_t signal_style = GB(p2, 11, 4); bool allow_station = HasBit(p3, 0); if (p1 >= MapSize() || !ValParamTrackOrientation(track)) return CMD_ERROR; @@ -2083,7 +2083,7 @@ static CommandCost CmdSignalTrackHelper(TileIndex tile, DoCommandFlag flags, uin /* only build/remove signals with the specified density */ if (tile_ok && (remove || minimise_gaps || signal_ctr % signal_density == 0 || IsTileType(tile, MP_TUNNELBRIDGE))) { - uint32 param1 = GB(TrackdirToTrack(trackdir), 0, 3); + uint32_t param1 = GB(TrackdirToTrack(trackdir), 0, 3); SB(param1, 3, 1, mode); SB(param1, 4, 1, semaphores); SB(param1, 5, 3, sigtype); @@ -2189,7 +2189,7 @@ static CommandCost CmdSignalTrackHelper(TileIndex tile, DoCommandFlag flags, uin * @return the cost of this operation or an error * @see CmdSignalTrackHelper */ -CommandCost CmdBuildSignalTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdBuildSignalTrack(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { return CmdSignalTrackHelper(tile, flags, p1, p2, p3, text); } @@ -2206,7 +2206,7 @@ CommandCost CmdBuildSignalTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Track track = Extract(p1); Money cost = _price[PR_CLEAR_SIGNALS]; @@ -2344,7 +2344,7 @@ CommandCost CmdRemoveSingleSignal(TileIndex tile, DoCommandFlag flags, uint32 p1 * @return the cost of this operation or an error * @see CmdSignalTrackHelper */ -CommandCost CmdRemoveSignalTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdRemoveSignalTrack(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { return CmdSignalTrackHelper(tile, flags, p1, SetBit(p2, 5), p3, text); // bit 5 is remove bit } @@ -2464,7 +2464,7 @@ CommandCost EnsureNoIncompatibleRailtypeTrainOnTrackBits(TileIndex tile, TrackBi * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { RailType totype = Extract(p2); TileIndex area_start = p1; @@ -2738,7 +2738,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdConvertRailTrack(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdConvertRailTrack(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { const RailType totype = Extract(p2); const TileIndex end_tile = p1; @@ -3220,7 +3220,7 @@ void DrawSingleSignal(TileIndex tile, const RailTypeInfo *rti, Track track, Sign if (type == SIGTYPE_NO_ENTRY) pos ^= 1; - uint8 style = 0; + uint8_t style = 0; if (_num_new_signal_styles > 0) { switch (context) { case CSSC_TRACK: @@ -3240,7 +3240,7 @@ void DrawSingleSignal(TileIndex tile, const RailTypeInfo *rti, Track track, Sign uint x, y; GetSignalXY(tile, pos, HasBit(_signal_style_masks.signal_opposite_side, style), x, y); - uint8 aspect; + uint8_t aspect; if (condition == SIGNAL_STATE_GREEN) { aspect = 1; if (_extra_aspects > 0) { @@ -3347,7 +3347,7 @@ static void DrawSingleSignal(TileIndex tile, const RailTypeInfo *rti, Track trac static void GetSignalXYByTrackdir(TileIndex tile, Trackdir td, bool opposite, uint &x, uint &y) { - static const uint8 trackdir_to_pos[TRACKDIR_END] = { + static const uint8_t trackdir_to_pos[TRACKDIR_END] = { 8, // TRACKDIR_X_NE 10, // TRACKDIR_Y_SE 4, // TRACKDIR_UPPER_E @@ -3412,7 +3412,7 @@ void MarkSingleSignalDirtyAtZ(TileIndex tile, Trackdir td, bool opposite_side, u }); } -static uint32 _drawtile_track_palette; +static uint32_t _drawtile_track_palette; @@ -4131,7 +4131,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); @@ -4545,7 +4545,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, _settings_game.vehicle.rail_depot_speed_limit); + td->rail_speed = std::min(td->rail_speed, _settings_game.vehicle.rail_depot_speed_limit); } else { td->rail_speed = _settings_game.vehicle.rail_depot_speed_limit; } @@ -4594,7 +4594,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_gui.cpp b/src/rail_gui.cpp index 853e0e778e..ea795a2dde 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -58,7 +58,7 @@ static bool _trace_restrict_button; ///< trace restrict button in the s static bool _program_signal_button; ///< program signal button in the signal GUI pressed static SignalVariant _cur_signal_variant; ///< set the signal variant (for signal GUI) static SignalType _cur_signal_type; ///< set the signal type (for signal GUI) -static uint8 _cur_signal_style; ///< set the signal style (for signal GUI) +static uint8_t _cur_signal_style; ///< set the signal style (for signal GUI) static uint _cur_signal_button; ///< set the signal button (for signal GUI) extern TileIndex _rail_track_endtile; // rail_cmd.cpp @@ -71,8 +71,8 @@ struct RailStationGUISettings { bool newstations; ///< Are custom station definitions available? StationClassID station_class; ///< Currently selected custom station class (if newstations is \c true ) - uint16 station_type; ///< %Station type within the currently selected custom station class (if newstations is \c true ) - uint16 station_count; ///< Number of custom stations (if newstations is \c true ) + uint16_t station_type; ///< %Station type within the currently selected custom station class (if newstations is \c true ) + uint16_t station_count; ///< Number of custom stations (if newstations is \c true ) }; static RailStationGUISettings _railstation; ///< Settings of the station builder GUI @@ -91,13 +91,13 @@ 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, _cur_railtype); + uint16_t cb_res = GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, nullptr, INVALID_TILE, _cur_railtype); if (cb_res == CALLBACK_FAILED) return true; return Convert8bitBooleanCallback(statspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res); } -void CcPlaySound_CONSTRUCTION_RAIL(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcPlaySound_CONSTRUCTION_RAIL(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile); } @@ -108,7 +108,7 @@ static CommandContainer GenericPlaceRailCmd(TileIndex tile, Track track) tile, // tile _cur_railtype, // p1 track | (_settings_client.gui.auto_remove_signals << 3), // p2 - (uint32) (_remove_button_clicked ? + (uint32_t) (_remove_button_clicked ? CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK) : CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK)), // cmd CcPlaySound_CONSTRUCTION_RAIL // callback @@ -147,7 +147,7 @@ static const DiagDirection _place_depot_extra_dir[12] = { DIAGDIR_NW, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_NE, }; -void CcRailDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcRailDepot(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; @@ -188,7 +188,7 @@ static void PlaceRail_Waypoint(TileIndex tile) } } -void CcStation(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcStation(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; @@ -210,9 +210,9 @@ static void PlaceRail_Station(TileIndex tile) VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION); VpSetPlaceSizingLimit(_settings_game.station.station_spread); } else { - uint32 p1 = _cur_railtype | _railstation.orientation << 6 | _settings_client.gui.station_numtracks << 8 | _settings_client.gui.station_platlength << 16 | _ctrl_pressed << 24; - uint32 p2 = _railstation.station_class | INVALID_STATION << 16; - uint64 p3 = _railstation.station_type; + uint32_t p1 = _cur_railtype | _railstation.orientation << 6 | _settings_client.gui.station_numtracks << 8 | _settings_client.gui.station_platlength << 16 | _ctrl_pressed << 24; + uint32_t p2 = _railstation.station_class | INVALID_STATION << 16; + uint64_t p3 = _railstation.station_type; int w = _settings_client.gui.station_numtracks; int h = _settings_client.gui.station_platlength; @@ -280,10 +280,10 @@ static void GenericPlaceSignals(TileIndex tile) const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0); /* various bitstuffed elements for CmdBuildSingleSignal() */ - uint32 p1 = track; + uint32_t p1 = track; /* Which signals should we cycle through? */ - uint8 cycle_types; + uint8_t cycle_types; if (_settings_client.gui.cycle_signal_types == SIGNAL_CYCLE_ALL && (_settings_client.gui.signal_gui_mode == SIGNAL_GUI_ALL || _settings_game.vehicle.train_braking_model == TBM_REALISTIC)) { cycle_types = SIGNAL_CYCLE_ALL; @@ -332,7 +332,7 @@ static void PlaceRail_Bridge(TileIndex tile, Window *w) } /** Command callback for building a tunnel */ -void CcBuildRailTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcBuildRailTunnel(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Succeeded()) { if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile); @@ -420,8 +420,8 @@ static CommandContainer DoRailroadTrackCmd(TileIndex start_tile, TileIndex end_t CommandContainer ret = NewCommandContainerBasic( start_tile, // tile end_tile, // p1 - (uint32) (_cur_railtype | (track << 6) | (_settings_client.gui.auto_remove_signals << 13)), // p2 - (uint32) (_remove_button_clicked ? + (uint32_t) (_cur_railtype | (track << 6) | (_settings_client.gui.auto_remove_signals << 13)), // p2 + (uint32_t) (_remove_button_clicked ? CMD_REMOVE_RAILROAD_TRACK | CMD_MSG(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK) : CMD_BUILD_RAILROAD_TRACK | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK)), // cmd CcPlaySound_CONSTRUCTION_RAIL // callback @@ -463,8 +463,8 @@ static void HandleAutodirPlacement() */ static void HandleAutoSignalPlacement() { - uint32 p2 = GB(_thd.drawstyle, 0, 3); // 0..5 - uint64 p3 = 0; + uint32_t p2 = GB(_thd.drawstyle, 0, 3); // 0..5 + uint64_t p3 = 0; if ((_thd.drawstyle & HT_DRAG_MASK) == HT_RECT) { // one tile case GenericPlaceSignals(TileVirtXY(_thd.selend.x, _thd.selend.y)); @@ -915,9 +915,9 @@ struct BuildRailToolbarWindow : Window { DoCommandP(end_tile, start_tile, _ctrl_pressed ? 0 : 1, CMD_REMOVE_FROM_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_REMOVE_TRAIN_WAYPOINT), CcPlaySound_CONSTRUCTION_RAIL); } else { TileArea ta(start_tile, end_tile); - uint32 p1 = _cur_railtype | (select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y) << 6 | ta.w << 8 | ta.h << 16 | _ctrl_pressed << 24; - uint32 p2 = STAT_CLASS_WAYP | INVALID_STATION << 16; - uint64 p3 = _cur_waypoint_type; + uint32_t p1 = _cur_railtype | (select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y) << 6 | ta.w << 8 | ta.h << 16 | _ctrl_pressed << 24; + uint32_t p2 = STAT_CLASS_WAYP | INVALID_STATION << 16; + uint64_t p3 = _cur_waypoint_type; CommandContainer cmdcont = NewCommandContainerBasic(ta.tile, p1, p2, CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT), CcPlaySound_CONSTRUCTION_RAIL); cmdcont.p3 = p3; @@ -993,9 +993,9 @@ static EventState RailToolbarGlobalHotkeys(int hotkey) return w->OnHotkey(hotkey); } -const uint16 _railtoolbar_autorail_keys[] = {'5', 'A' | WKC_GLOBAL_HOTKEY, 0}; -const uint16 _railtoolbar_polyrail_keys[] = {'Y', 'A' | WKC_CTRL | WKC_GLOBAL_HOTKEY, 0}; -const uint16 _railtoolbar_new_poly_keys[] = {'Y' | WKC_CTRL, 'A' | WKC_CTRL | WKC_SHIFT | WKC_GLOBAL_HOTKEY, 0}; +const uint16_t _railtoolbar_autorail_keys[] = {'5', 'A' | WKC_GLOBAL_HOTKEY, 0}; +const uint16_t _railtoolbar_polyrail_keys[] = {'Y', 'A' | WKC_CTRL | WKC_GLOBAL_HOTKEY, 0}; +const uint16_t _railtoolbar_new_poly_keys[] = {'Y' | WKC_CTRL, 'A' | WKC_CTRL | WKC_SHIFT | WKC_GLOBAL_HOTKEY, 0}; static Hotkey railtoolbar_hotkeys[] = { Hotkey('1', "build_ns", WID_RAT_BUILD_NS), @@ -1103,9 +1103,9 @@ static void HandleStationPlacement(TileIndex start, TileIndex end) if (_railstation.orientation == AXIS_X) Swap(numtracks, platlength); - uint32 p1 = _cur_railtype | _railstation.orientation << 6 | numtracks << 8 | platlength << 16 | _ctrl_pressed << 24; - uint32 p2 = _railstation.station_class | INVALID_STATION << 16; - uint64 p3 = _railstation.station_type; + uint32_t p1 = _cur_railtype | _railstation.orientation << 6 | numtracks << 8 | platlength << 16 | _ctrl_pressed << 24; + uint32_t p2 = _railstation.station_class | INVALID_STATION << 16; + uint64_t p3 = _railstation.station_type; CommandContainer cmdcont = NewCommandContainerBasic(ta.tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation); cmdcont.p3 = p3; @@ -2250,23 +2250,23 @@ public: static Hotkey signaltoolbar_hotkeys[] = { Hotkey('N', "routing_restriction", WID_BS_TRACE_RESTRICT), Hotkey('K', "convert", WID_BS_CONVERT), - Hotkey((uint16)0, "program_signal", WID_BS_PROGRAM), - Hotkey((uint16)0, "semaphore_normal", WID_BS_SEMAPHORE_NORM), - Hotkey((uint16)0, "semaphore_entry", WID_BS_SEMAPHORE_ENTRY), - Hotkey((uint16)0, "semaphore_exit", WID_BS_SEMAPHORE_EXIT), - Hotkey((uint16)0, "semaphore_combo", WID_BS_SEMAPHORE_COMBO), - Hotkey((uint16)0, "semaphore_prog", WID_BS_SEMAPHORE_PROG), - Hotkey((uint16)0, "semaphore_pbs", WID_BS_SEMAPHORE_PBS), - Hotkey((uint16)0, "semaphore_pbs_oneway", WID_BS_SEMAPHORE_PBS_OWAY), - Hotkey((uint16)0, "semaphore_no_entry", WID_BS_SEMAPHORE_NO_ENTRY), + Hotkey((uint16_t)0, "program_signal", WID_BS_PROGRAM), + Hotkey((uint16_t)0, "semaphore_normal", WID_BS_SEMAPHORE_NORM), + Hotkey((uint16_t)0, "semaphore_entry", WID_BS_SEMAPHORE_ENTRY), + Hotkey((uint16_t)0, "semaphore_exit", WID_BS_SEMAPHORE_EXIT), + Hotkey((uint16_t)0, "semaphore_combo", WID_BS_SEMAPHORE_COMBO), + Hotkey((uint16_t)0, "semaphore_prog", WID_BS_SEMAPHORE_PROG), + Hotkey((uint16_t)0, "semaphore_pbs", WID_BS_SEMAPHORE_PBS), + Hotkey((uint16_t)0, "semaphore_pbs_oneway", WID_BS_SEMAPHORE_PBS_OWAY), + Hotkey((uint16_t)0, "semaphore_no_entry", WID_BS_SEMAPHORE_NO_ENTRY), Hotkey('G', "signal_normal", WID_BS_ELECTRIC_NORM), - Hotkey((uint16)0, "signal_entry", WID_BS_ELECTRIC_ENTRY), - Hotkey((uint16)0, "signal_exit", WID_BS_ELECTRIC_EXIT), - Hotkey((uint16)0, "signal_combo", WID_BS_ELECTRIC_COMBO), - Hotkey((uint16)0, "signal_prog", WID_BS_ELECTRIC_PROG), + Hotkey((uint16_t)0, "signal_entry", WID_BS_ELECTRIC_ENTRY), + Hotkey((uint16_t)0, "signal_exit", WID_BS_ELECTRIC_EXIT), + Hotkey((uint16_t)0, "signal_combo", WID_BS_ELECTRIC_COMBO), + Hotkey((uint16_t)0, "signal_prog", WID_BS_ELECTRIC_PROG), Hotkey('H', "signal_pbs", WID_BS_ELECTRIC_PBS), Hotkey('J', "signal_pbs_oneway", WID_BS_ELECTRIC_PBS_OWAY), - Hotkey((uint16)0, "signal_no_entry", WID_BS_ELECTRIC_NO_ENTRY), + Hotkey((uint16_t)0, "signal_no_entry", WID_BS_ELECTRIC_NO_ENTRY), HOTKEY_LIST_END }; HotkeyList BuildSignalWindow::hotkeys("signaltoolbar", signaltoolbar_hotkeys); @@ -2616,7 +2616,7 @@ struct BuildRailWaypointWindow : PickerWindowBase { CheckRedrawWaypointCoverage(this, false); } - void SelectWaypointSpec(uint16 spec_id) + void SelectWaypointSpec(uint16_t spec_id) { for (uint i = 0; i < (uint)this->list.size(); i++) { if (this->list[i] == spec_id) { @@ -2757,7 +2757,7 @@ static void SetDefaultRailGui() * Updates the current signal variant used in the signal GUI * to the one adequate to current year. */ -void ResetSignalVariant(int32 new_value) +void ResetSignalVariant(int32_t new_value) { SignalVariant new_variant = (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC); @@ -2892,7 +2892,7 @@ void ShowBuildRailStationPickerAndSelect(StationType station_type, const Station trigger_widget(WID_RAT_BUILD_WAYPOINT); BuildRailWaypointWindow *waypoint_window = dynamic_cast(FindWindowById(WC_BUILD_WAYPOINT, TRANSPORT_RAIL)); - if (waypoint_window != nullptr) waypoint_window->SelectWaypointSpec((uint16)spec_id); + if (waypoint_window != nullptr) waypoint_window->SelectWaypointSpec((uint16_t)spec_id); } else { trigger_widget(WID_RAT_BUILD_STATION); @@ -2901,7 +2901,7 @@ void ShowBuildRailStationPickerAndSelect(StationType station_type, const Station } } -static void OpenBuildSignalWindow(BuildRailToolbarWindow *w, SignalVariant variant, SignalType type, uint8 style) +static void OpenBuildSignalWindow(BuildRailToolbarWindow *w, SignalVariant variant, SignalType type, uint8_t style) { if (!w->IsWidgetLowered(WID_RAT_BUILD_SIGNALS)) { w->OnHotkey(WID_RAT_BUILD_SIGNALS); diff --git a/src/rail_gui.h b/src/rail_gui.h index eba1fe581f..0af8acbf44 100644 --- a/src/rail_gui.h +++ b/src/rail_gui.h @@ -18,7 +18,7 @@ struct Window *ShowBuildRailToolbar(RailType railtype); void ShowBuildRailToolbarWithPickTile(RailType railtype, TileIndex tile); void ShowBuildRailStationPickerAndSelect(StationType station_type, const StationSpec *spec); 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); diff --git a/src/rail_gui_type.h b/src/rail_gui_type.h index 3b9082c2aa..f1f1f1b804 100644 --- a/src/rail_gui_type.h +++ b/src/rail_gui_type.h @@ -11,13 +11,13 @@ #define RAIL_GUI_TYPE_H /** 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_map.h b/src/rail_map.h index 791c8491c2..c2a2e58b66 100644 --- a/src/rail_map.h +++ b/src/rail_map.h @@ -383,14 +383,14 @@ inline void SetSignalVariant(TileIndex t, Track track, SignalVariant v) if (track == INVALID_TRACK) SB(_m[t].m2, 7, 1, v); } -inline uint8 GetSignalAspect(TileIndex t, Track track) +inline uint8_t GetSignalAspect(TileIndex t, Track track) { dbg_assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t); byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 3 : 0; return GB(_me[t].m7, pos, 3); } -inline void SetSignalAspect(TileIndex t, Track track, uint8 aspect) +inline void SetSignalAspect(TileIndex t, Track track, uint8_t aspect) { dbg_assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t); byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 3 : 0; @@ -402,14 +402,14 @@ inline bool NonZeroSignalStylePossiblyOnTile(TileIndex t) return _me[t].m6 != 0; } -inline uint8 GetSignalStyle(TileIndex t, Track track) +inline uint8_t GetSignalStyle(TileIndex t, Track track) { dbg_assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t); byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0; return GB(_me[t].m6, pos, 4); } -inline uint8 GetSignalStyleGeneric(TileIndex t, Track track) +inline uint8_t GetSignalStyleGeneric(TileIndex t, Track track) { switch (GetTileType(t)) { case MP_RAILWAY: @@ -421,7 +421,7 @@ inline uint8 GetSignalStyleGeneric(TileIndex t, Track track) } } -inline void SetSignalStyle(TileIndex t, Track track, uint8 style) +inline void SetSignalStyle(TileIndex t, Track track, uint8_t style) { dbg_assert_tile(GetRailTileType(t) == RAIL_TILE_SIGNALS, t); byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0; diff --git a/src/rail_type.h b/src/rail_type.h index 20e65d30f2..e49e517810 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_LABEL_RAIL = 'RAIL'; static const RailTypeLabel RAILTYPE_LABEL_ELECTRIC = 'ELRL'; @@ -41,9 +41,9 @@ template <> struct EnumPropsT : MakeEnumPropsTReadByteIntl(); return (this->ReadByteIntl() << 8) | b; @@ -124,7 +124,7 @@ uint16 RandomAccessFile::ReadWordIntl() * Read a double word (32 bits) from the file (in low endian format). * @return Read word. */ -uint32 RandomAccessFile::ReadDwordIntl() +uint32_t RandomAccessFile::ReadDwordIntl() { uint b = this->ReadWordIntl(); return (this->ReadWordIntl() << 16) | b; diff --git a/src/random_access_file_type.h b/src/random_access_file_type.h index 1c3e6e78e5..54c2f6edae 100644 --- a/src/random_access_file_type.h +++ b/src/random_access_file_type.h @@ -36,8 +36,8 @@ class RandomAccessFile { byte buffer_start[BUFFER_SIZE]; ///< Local buffer when read from file. byte ReadByteIntl(); - uint16 ReadWordIntl(); - uint32 ReadDwordIntl(); + uint16_t ReadWordIntl(); + uint32_t ReadDwordIntl(); public: RandomAccessFile(const std::string &filename, Subdirectory subdir); @@ -58,13 +58,13 @@ public: return this->ReadByteIntl(); } - inline uint16 ReadWord() + inline uint16_t ReadWord() { if (likely(this->buffer + 1 < this->buffer_end)) { #if OTTD_ALIGNMENT == 0 - uint16 x = FROM_LE16(*((const unaligned_uint16*) this->buffer)); + uint16_t x = FROM_LE16(*((const unaligned_uint16 *) this->buffer)); #else - uint16 x = ((uint16)this->buffer[1] << 8) | this->buffer[0]; + uint16_t x = ((uint16_t)this->buffer[1] << 8) | this->buffer[0]; #endif this->buffer += 2; return x; @@ -72,13 +72,13 @@ public: return this->ReadWordIntl(); } - inline uint32 ReadDword() + inline uint32_t ReadDword() { if (likely(this->buffer + 3 < this->buffer_end)) { #if OTTD_ALIGNMENT == 0 - uint32 x = FROM_LE32(*((const unaligned_uint32*) this->buffer)); + uint32_t x = FROM_LE32(*((const unaligned_uint32 *) this->buffer)); #else - uint32 x = ((uint32)this->buffer[3] << 24) | ((uint32)this->buffer[2] << 16) | ((uint32)this->buffer[1] << 8) | this->buffer[0]; + uint32_t x = ((uint32_t)this->buffer[3] << 24) | ((uint32_t)this->buffer[2] << 16) | ((uint32_t)this->buffer[1] << 8) | this->buffer[0]; #endif this->buffer += 4; return x; diff --git a/src/rev.cpp.in b/src/rev.cpp.in index 87b2af0e30..ffdfa0614b 100644 --- a/src/rev.cpp.in +++ b/src/rev.cpp.in @@ -103,4 +103,4 @@ const char _openttd_content_version[] = "13.4"; * have to adjust the major by 16. */ /** ${REV_ISSTABLETAG} removed */ -const uint32 _openttd_newgrf_version = (${REV_MAJOR} + 16) << 24 | ${REV_MINOR} << 20 | 0 << 19 | 28004; +const uint32_t _openttd_newgrf_version = (${REV_MAJOR} + 16) << 24 | ${REV_MINOR} << 20 | 0 << 19 | 28004; diff --git a/src/rev.h b/src/rev.h index e3bee3538a..48dabfb51e 100644 --- a/src/rev.h +++ b/src/rev.h @@ -19,7 +19,7 @@ extern const char _openttd_build_configure_defines[]; 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.cpp b/src/road.cpp index 3bf12df2c7..56980b74b7 100644 --- a/src/road.cpp +++ b/src/road.cpp @@ -40,7 +40,7 @@ #include "command_func.h" #include "safeguards.h" -uint32 _road_layout_change_counter = 0; +uint32_t _road_layout_change_counter = 0; /** Whether to build public roads */ enum PublicRoadsConstruction { @@ -312,9 +312,9 @@ RoadType GetRoadTypeByLabel(RoadTypeLabel label, bool allow_alternate_labels) /* PUBLIC ROADS */ /* ========================================================================= */ -CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text = nullptr); -CommandCost CmdBuildTunnel(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text = nullptr); -CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text = nullptr); +CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text = nullptr); +CommandCost CmdBuildTunnel(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text = nullptr); +CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text = nullptr); static RoadType _public_road_type; static const uint _public_road_hash_size = 8U; ///< The number of bits the hash for river finding should have. @@ -450,7 +450,7 @@ static TileIndex BuildBridge(PathNode *current, TileIndex end_tile = INVALID_TIL assert(!build_bridge || !available_bridge_types.empty()); if (available_bridge_types.empty()) return INVALID_TILE; - const auto bridge_type = available_bridge_types[build_bridge ? RandomRange(uint32(available_bridge_types.size())) : 0]; + const auto bridge_type = available_bridge_types[build_bridge ? RandomRange((uint32_t)available_bridge_types.size()) : 0]; Backup cur_company(_current_company, OWNER_DEITY, FILE_LINE); const auto build_bridge_cmd = CmdBuildBridge(end_tile, DC_AUTO | (build_bridge ? DC_EXEC : DC_NONE), start_tile, bridge_type | (_public_road_type << 8) | (TRANSPORT_ROAD << 15)); @@ -481,7 +481,7 @@ static TileIndex BuildRiverBridge(PathNode *current, const DiagDirection road_di // should not force that on them. This is just to bridge rivers, not to make long bridges. for (; IsValidTile(tile) && - (GetTunnelBridgeLength(start_tile, tile) <= std::min(_settings_game.construction.max_bridge_length, (uint16)3)) && + (GetTunnelBridgeLength(start_tile, tile) <= std::min(_settings_game.construction.max_bridge_length, (uint16_t)3)) && (start_tile_z < (GetTileZ(tile) + _settings_game.construction.max_bridge_height)) && (GetTileZ(tile) <= start_tile_z); tile += TileOffsByDiagDir(road_direction)) { @@ -509,7 +509,7 @@ static TileIndex BuildRiverBridge(PathNode *current, const DiagDirection road_di } } - const auto bridge_type = available_bridge_types[build_bridge ? RandomRange(uint32(available_bridge_types.size())) : 0]; + const auto bridge_type = available_bridge_types[build_bridge ? RandomRange((uint32_t)available_bridge_types.size()) : 0]; Backup cur_company(_current_company, OWNER_DEITY, FILE_LINE); const auto build_bridge_cmd = CmdBuildBridge(end_tile, DC_AUTO | (build_bridge ? DC_EXEC : DC_NONE), start_tile, bridge_type | (_public_road_type << 8) | (TRANSPORT_ROAD << 15)); @@ -782,7 +782,7 @@ static void PublicRoad_GetNeighbours(AyStar *aystar, OpenListNode *current) } /** AyStar callback for checking whether we reached our destination. */ -static int32 PublicRoad_EndNodeCheck(const AyStar *aystar, const OpenListNode *current) +static int32_t PublicRoad_EndNodeCheck(const AyStar *aystar, const OpenListNode *current) { return current->path.node.tile == static_cast(reinterpret_cast(aystar->user_target)) ? AYSTAR_FOUND_END_NODE : AYSTAR_DONE; } @@ -858,16 +858,16 @@ static void PublicRoad_FoundEndNode(AyStar *aystar, OpenListNode *current) } } -static const int32 BASE_COST_PER_TILE = 1; // Cost for existing road or tunnel/bridge. -static const int32 COST_FOR_NEW_ROAD = 10; // Cost for building a new road. -static const int32 COST_FOR_SLOPE = 50; // Additional cost if the road heads up or down a slope. +static const int32_t BASE_COST_PER_TILE = 1; ///< Cost for existing road or tunnel/bridge. +static const int32_t COST_FOR_NEW_ROAD = 10; ///< Cost for building a new road. +static const int32_t COST_FOR_SLOPE = 50; ///< Additional cost if the road heads up or down a slope. /** AyStar callback for getting the cost of the current node. */ -static int32 PublicRoad_CalculateG(AyStar *, AyStarNode *current, OpenListNode *parent) +static int32_t PublicRoad_CalculateG(AyStar *, AyStarNode *current, OpenListNode *parent) { - int32 cost = 0; + int32_t cost = 0; - const int32 distance = DistanceManhattan(parent->path.node.tile, current->tile); + const int32_t distance = DistanceManhattan(parent->path.node.tile, current->tile); if (IsTileType(current->tile, MP_ROAD) || IsTileType(current->tile, MP_TUNNELBRIDGE)) { cost += distance * BASE_COST_PER_TILE; @@ -912,7 +912,7 @@ static int32 PublicRoad_CalculateG(AyStar *, AyStarNode *current, OpenListNode * } /** AyStar callback for getting the estimated cost to the destination. */ -static int32 PublicRoad_CalculateH(AyStar *aystar, AyStarNode *current, OpenListNode *parent) +static int32_t PublicRoad_CalculateH(AyStar *aystar, AyStarNode *current, OpenListNode *parent) { return DistanceManhattan(static_cast(reinterpret_cast(aystar->user_target)), current->tile) * BASE_COST_PER_TILE; } diff --git a/src/road.h b/src/road.h index 004d67a62b..2ce565f80a 100644 --- a/src/road.h +++ b/src/road.h @@ -27,7 +27,7 @@ enum RoadTramType : bool { RTT_TRAM, }; -enum RoadTramTypes : uint8 { +enum RoadTramTypes : uint8_t { RTTB_ROAD = 1 << RTT_ROAD, RTTB_TRAM = 1 << RTT_TRAM, }; @@ -61,7 +61,7 @@ enum RoadTypeExtraFlag { }; /** Roadtype extra flags. */ -enum RoadTypeExtraFlags : uint8 { +enum RoadTypeExtraFlags : uint8_t { RXTFB_NONE = 0, ///< All flags cleared. RXTFB_NOT_AVAILABLE_AI_GS = 1 << RXTF_NOT_AVAILABLE_AI_GS, RXTFB_NO_TOWN_MODIFICATION = 1 << RXTF_NO_TOWN_MODIFICATION, @@ -70,7 +70,7 @@ enum RoadTypeExtraFlags : uint8 { }; DECLARE_ENUM_AS_BIT_SET(RoadTypeExtraFlags) -enum RoadTypeCollisionMode : uint8 { +enum RoadTypeCollisionMode : uint8_t { RTCM_NORMAL = 0, RTCM_NONE, RTCM_ELEVATED, @@ -164,17 +164,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 23ed5184b4..0b07303cb8 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -224,7 +224,7 @@ static DiagDirection OneWaySideJunctionRoadRoadBitsToDiagDir(RoadBits bits) * ROAD_NW (bit 0) -> DIAGDIR_SW (2) * ROAD_NE (bit 3) -> DIAGDIR_NW (3) */ - uint8 bit = FIND_FIRST_BIT(bits ^ ROAD_ALL); + uint8_t bit = FIND_FIRST_BIT(bits ^ ROAD_ALL); bit ^= 3; return (DiagDirection)((bit + 3 + (_settings_game.vehicle.road_side * 2)) % 4); } @@ -236,7 +236,7 @@ inline bool IsOneWaySideJunctionRoadDRDsPresent(TileIndex tile, DiagDirection di TileIndexDiffC ti = TileIndexDiffCByDiagDir(dir); TileIndex ahead = AddTileIndexDiffCWrap(tile, ti); if (ahead == INVALID_TILE || GetOneWayRoadTileDisallowedRoadDirections(ahead) != diagdir_to_drd[dir]) return false; - TileIndex behind = AddTileIndexDiffCWrap(tile, { (int16)(-ti.x), (int16)(-ti.y) }); + TileIndex behind = AddTileIndexDiffCWrap(tile, { (int16_t)(-ti.x), (int16_t)(-ti.y) }); if (behind == INVALID_TILE || GetOneWayRoadTileDisallowedRoadDirections(behind) != diagdir_to_drd[dir]) return false; return true; } @@ -298,7 +298,7 @@ enum InterpolateRoadResult { IRR_IN }; -static TileIndex InterpolateRoadFollowTileStep(TileIndex tile, uint8 bit) +static TileIndex InterpolateRoadFollowTileStep(TileIndex tile, uint8_t bit) { DiagDirection outgoing = (DiagDirection)(bit ^ 3); if (IsTileType(tile, MP_TUNNELBRIDGE) && GetTunnelBridgeDirection(tile) == outgoing) { @@ -313,7 +313,7 @@ static TileIndex InterpolateRoadFollowTileStep(TileIndex tile, uint8 bit) return next; } -static InterpolateRoadResult InterpolateRoadFollowRoadBit(TileIndex tile, uint8 bit) +static InterpolateRoadResult InterpolateRoadFollowRoadBit(TileIndex tile, uint8_t bit) { const TileIndex start = tile; do { @@ -337,14 +337,14 @@ static InterpolateRoadResult InterpolateRoadFollowRoadBit(TileIndex tile, uint8 return IRR_NONE; } -static void InterpolateRoadFollowRoadBitSetState(TileIndex tile, uint8 bit, InterpolateRoadResult irr) +static void InterpolateRoadFollowRoadBitSetState(TileIndex tile, uint8_t bit, InterpolateRoadResult irr) { const TileIndex start = tile; do { if (irr == IRR_NONE) { SetRoadCachedOneWayState(tile, RCOWS_NORMAL); } else { - uint8 inbit = FIND_FIRST_BIT(GetAnyRoadBits(tile, RTT_ROAD, true) & ~(1 << bit)); + uint8_t inbit = FIND_FIRST_BIT(GetAnyRoadBits(tile, RTT_ROAD, true) & ~(1 << bit)); /* inbit bit piece Outgoing Trackdir IRR_IN case * * 0 1 ROAD_W TRACKDIR_LEFT_S RCOWS_NON_JUNCTION_A @@ -364,7 +364,7 @@ static void InterpolateRoadFollowRoadBitSetState(TileIndex tile, uint8 bit, Inte * 3 2 ROAD_E TRACKDIR_RIGHT_S RCOWS_NON_JUNCTION_A */ - const uint16 bits_to_rcows = 0x3B10; + const uint16_t bits_to_rcows = 0x3B10; SetRoadCachedOneWayState(tile, (RoadCachedOneWayState)(irr ^ (HasBit(bits_to_rcows, (inbit << 2) | bit) ? 0 : 3))); } _road_cache_one_way_state_pending_interpolate_tiles.erase(tile); @@ -396,8 +396,8 @@ static void InterpolateRoadCachedOneWayStates() const RoadBits bits = GetAnyRoadBits(tile, RTT_ROAD, true); if (CountBits(bits) != 2) continue; - uint8 first_bit = FIND_FIRST_BIT(bits); - uint8 second_bit = FIND_FIRST_BIT(KillFirstBit(bits)); + uint8_t first_bit = FIND_FIRST_BIT(bits); + uint8_t second_bit = FIND_FIRST_BIT(KillFirstBit(bits)); InterpolateRoadResult first_irr = InterpolateRoadFollowRoadBit(tile, first_bit); InterpolateRoadResult second_irr = first_irr; if (first_irr != IRR_NONE) { @@ -979,7 +979,7 @@ static bool CanConvertUnownedRoadType(Owner owner, RoadTramType rtt) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { CompanyID company = _current_company; CommandCost cost(EXPENSES_CONSTRUCTION); @@ -1548,7 +1548,7 @@ static bool CanConnectToRoad(TileIndex tile, RoadType rt, DiagDirection dir) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { DisallowedRoadDirections drd = DRD_NORTHBOUND; @@ -1650,7 +1650,7 @@ CommandCost CmdBuildLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdRemoveLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRemoveLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { CommandCost cost(EXPENSES_CONSTRUCTION); @@ -1738,7 +1738,7 @@ CommandCost CmdRemoveLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 * @todo When checking for the tile slope, * distinguish between "Flat land required" and "land sloped in wrong direction" */ -CommandCost CmdBuildRoadDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildRoadDepot(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { DiagDirection dir = Extract(p1); @@ -1862,7 +1862,7 @@ static CommandCost ClearTile_Road(TileIndex tile, DoCommandFlag flags) struct DrawRoadTileStruct { - uint16 image; + uint16_t image; byte subcoord_x; byte subcoord_y; }; @@ -2747,7 +2747,7 @@ static TrackStatus GetTileTrackStatus_Road(TileIndex tile, TransportType mode, u trackdirbits = TrackBitsToTrackdirBits(AxisToTrackBits(axis)); auto is_non_colliding = [&]() -> bool { - uint8 rtfield = GB(sub_mode, 8, 8); + uint8_t rtfield = GB(sub_mode, 8, 8); if (rtfield == 0) return false; RoadType rt = (RoadType)(rtfield - 1); return HasBit(_roadtypes_non_train_colliding, rt); @@ -3058,7 +3058,7 @@ static void ConvertRoadTypeOwner(TileIndex tile, uint num_pieces, Owner owner, R * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdConvertRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdConvertRoad(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { RoadType to_type = Extract(p2); diff --git a/src/road_gui.cpp b/src/road_gui.cpp index d418f54f76..5d618f5265 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -62,8 +62,8 @@ struct RoadStopGUISettings { DiagDirection orientation; // This replaces _road_station_picker_orientation RoadStopClassID roadstop_class; - uint16 roadstop_type; - uint16 roadstop_count; + uint16_t roadstop_type; + uint16_t roadstop_count; }; static RoadStopGUISettings _roadstop_gui_settings; @@ -110,13 +110,13 @@ 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); } -void CcPlaySound_CONSTRUCTION_OTHER(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcPlaySound_CONSTRUCTION_OTHER(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile); } @@ -146,7 +146,7 @@ static void PlaceRoad_Bridge(TileIndex tile, Window *w) * @param p2 unused * @param cmd unused */ -void CcBuildRoadTunnel(const CommandCost &result, TileIndex start_tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcBuildRoadTunnel(const CommandCost &result, TileIndex start_tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Succeeded()) { if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, start_tile); @@ -179,7 +179,7 @@ void ConnectRoadToStructure(TileIndex tile, DiagDirection direction) } } -void CcRoadDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcRoadDepot(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; @@ -207,7 +207,7 @@ void CcRoadDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2 * @param cmd Unused. * @see CmdBuildRoadStop */ -void CcRoadStop(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcRoadStop(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; @@ -218,7 +218,7 @@ void CcRoadStop(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, bool connect_to_road = true; RoadStopClassID spec_class = Extract(p3); - uint16 spec_index = GB(p3, 16, 16); + uint16_t spec_index = GB(p3, 16, 16); if ((uint)spec_class < RoadStopClass::GetClassCount() && spec_index < RoadStopClass::Get(spec_class)->GetSpecCount()) { const RoadStopSpec *roadstopspec = RoadStopClass::Get(spec_class)->GetSpec(spec_index); if (roadstopspec != nullptr && HasBit(roadstopspec->flags, RSF_NO_AUTO_ROAD_CONNECTION)) connect_to_road = false; @@ -244,9 +244,9 @@ void CcRoadStop(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, * @param cmd Command to use. * @see CcRoadStop() */ -static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, uint32 p2, uint32 cmd) +static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, uint32_t p2, uint32_t cmd) { - uint8 ddir = _roadstop_gui_settings.orientation; + uint8_t ddir = _roadstop_gui_settings.orientation; if (ddir >= DIAGDIR_END) { SetBit(p2, 1); // It's a drive-through stop. @@ -256,7 +256,7 @@ static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, uint32 p2, u p2 |= INVALID_STATION << 16; // no station to join TileArea ta(start_tile, end_tile); - CommandContainer cmdcont = NewCommandContainerBasic(ta.tile, (uint32)(ta.w | ta.h << 8), p2, cmd, CcRoadStop); + CommandContainer cmdcont = NewCommandContainerBasic(ta.tile, (uint32_t)(ta.w | ta.h << 8), p2, cmd, CcRoadStop); cmdcont.p3 = (_roadstop_gui_settings.roadstop_type << 16) | _roadstop_gui_settings.roadstop_class; ShowSelectStationIfNeeded(cmdcont, ta); } @@ -776,7 +776,7 @@ struct BuildRoadToolbarWindow : Window { * else use the last 2 bits (X dir has * not the 3rd bit set) */ - /* Even if _cur_roadtype_id is a uint8 we only use 5 bits so + /* Even if _cur_roadtype_id is a uint8_t we only use 5 bits so * we could ignore the last 3 bits and reuse them for other * flags */ _place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3)); @@ -794,8 +794,8 @@ struct BuildRoadToolbarWindow : Window { if (_remove_button_clicked) { DoCommandP(ta.tile, ta.w | ta.h << 8, (1 << 2), CMD_REMOVE_ROAD_STOP | CMD_MSG(STR_ERROR_CAN_T_REMOVE_ROAD_WAYPOINT), CcPlaySound_CONSTRUCTION_OTHER); } else { - uint32 p1 = ta.w | ta.h << 8 | _ctrl_pressed << 16 | (select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y) << 17; - uint32 p2 = ROADSTOP_CLASS_WAYP | INVALID_STATION << 16; + uint32_t p1 = ta.w | ta.h << 8 | _ctrl_pressed << 16 | (select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y) << 17; + uint32_t p2 = ROADSTOP_CLASS_WAYP | INVALID_STATION << 16; CommandContainer cmdcont = NewCommandContainerBasic(ta.tile, p1, p2, CMD_BUILD_ROAD_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_BUILD_ROAD_WAYPOINT), CcPlaySound_CONSTRUCTION_OTHER); cmdcont.p3 = _cur_waypoint_type; @@ -1636,7 +1636,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); } } if (!IsRoadStopAvailable(spec, st)) { @@ -2114,7 +2114,7 @@ struct BuildRoadWaypointWindow : PickerWindowBase { CheckRedrawWaypointCoverage(this, true); } - void SelectWaypointSpec(uint16 spec_id) + void SelectWaypointSpec(uint16_t spec_id) { for (uint i = 0; i < (uint)this->list.size(); i++) { if (this->list[i] == spec_id) { @@ -2418,7 +2418,7 @@ void ShowBuildRoadStopPickerAndSelect(StationType station_type, const RoadStopSp trigger_widget(WID_ROT_BUILD_WAYPOINT); BuildRoadWaypointWindow *waypoint_window = dynamic_cast(FindWindowById(WC_BUILD_WAYPOINT, TRANSPORT_ROAD)); - if (waypoint_window != nullptr) waypoint_window->SelectWaypointSpec((uint16)spec_id); + if (waypoint_window != nullptr) waypoint_window->SelectWaypointSpec((uint16_t)spec_id); } else { trigger_widget((station_type == STATION_BUS) ? WID_ROT_BUS_STATION : WID_ROT_TRUCK_STATION); diff --git a/src/road_type.h b/src/road_type.h index fad768d8cd..c195081514 100644 --- a/src/road_type.h +++ b/src/road_type.h @@ -12,9 +12,9 @@ #include "core/enum_type.hpp" -extern uint32 _road_layout_change_counter; +extern uint32_t _road_layout_change_counter; -typedef uint32 RoadTypeLabel; +typedef uint32_t RoadTypeLabel; static const RoadTypeLabel ROADTYPE_LABEL_ROAD = 'ROAD'; static const RoadTypeLabel ROADTYPE_LABEL_TRAM = 'ELRL'; @@ -36,9 +36,9 @@ template <> struct EnumPropsT : MakeEnumPropsT tile; std::array td; - uint32 layout_ctr = 0; - uint8 start = 0; - uint8 count = 0; + uint32_t layout_ctr = 0; + uint8_t start = 0; + uint8_t count = 0; inline bool empty() const { return this->count == 0; } - inline uint8 size() const { return this->count; } + inline uint8_t size() const { return this->count; } inline bool full() const { return this->count >= RV_PATH_CACHE_SEGMENTS; } inline void clear() @@ -107,7 +107,7 @@ struct RoadVehPathCache { inline TileIndex front_tile() const { return this->tile[this->start]; } inline Trackdir front_td() const { return this->td[this->start]; } - inline uint8 back_index() const { return (this->start + this->count - 1) & RV_PATH_CACHE_SEGMENT_MASK; } + inline uint8_t back_index() const { return (this->start + this->count - 1) & RV_PATH_CACHE_SEGMENT_MASK; } inline TileIndex back_tile() const { return this->tile[this->back_index()]; } inline Trackdir back_td() const { return this->td[this->back_index()]; } @@ -143,18 +143,18 @@ struct RoadVehicle FINAL : public GroundVehicle { std::unique_ptr cached_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. - RoadTypes compatible_roadtypes; //!< Roadtypes this consist is powered on. + RoadType roadtype; ///< Roadtype of this vehicle. + RoadTypes compatible_roadtypes; ///< Roadtypes this consist is powered on. - byte critical_breakdown_count; ///< Counter for the number of critical breakdowns since last service + byte critical_breakdown_count; ///< Counter for the number of critical breakdowns since last service - uint8 rvflags; ///< Road vehicle flags + uint8_t rvflags; ///< Road vehicle flags /** We don't want GCC to zero our struct! It already is zeroed and has an index! */ RoadVehicle() : GroundVehicleBase() {} @@ -223,7 +223,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()) { @@ -237,7 +237,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; } @@ -246,9 +246,9 @@ protected: // These functions should not be called outside acceleration code. * Allows to know the weight value that this vehicle will use (excluding cargo). * @return Weight value from the engine in tonnes. */ - inline uint16 GetWeightWithoutCargo() const + inline uint16_t GetWeightWithoutCargo() const { - uint16 weight = 0; + uint16_t weight = 0; /* Vehicle weight is not added for articulated parts. */ if (!this->IsArticulatedPart()) { @@ -268,7 +268,7 @@ protected: // These functions should not be called outside acceleration code. * Allows to know the weight value that this vehicle will use (cargo only). * @return Weight value from the engine in tonnes. */ - inline uint16 GetCargoWeight() const + inline uint16_t GetCargoWeight() const { return CargoSpec::Get(this->cargo_type)->WeightOfNUnits(this->cargo.StoredCount()); } @@ -277,7 +277,7 @@ 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 { return this->GetWeightWithoutCargo() + this->GetCargoWeight(); } @@ -286,7 +286,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. @@ -329,7 +329,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; } @@ -338,11 +338,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; @@ -361,7 +361,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; } @@ -370,7 +370,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 853460bd71..4c69a6a892 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -44,7 +44,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, @@ -55,7 +55,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, @@ -68,7 +68,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); } @@ -106,7 +106,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); @@ -121,7 +121,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); @@ -396,7 +396,7 @@ static bool MayReverseOnOneWayRoadTile(TileIndex tile, DiagDirection dir) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdTurnRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdTurnRoadVeh(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { RoadVehicle *v = RoadVehicle::GetIfValid(p1); if (v == nullptr) return CMD_ERROR; @@ -437,7 +437,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 @@ -452,7 +452,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]; @@ -477,7 +477,7 @@ int RoadVehicle::GetEffectiveMaxSpeed() const } /* clamp speed to be no less than lower of 5mph and 1/8 of base speed */ - return std::max(max_speed, std::min(10, (this->vcache.cached_max_speed + 7) >> 3)); + return std::max(max_speed, std::min(10, (this->vcache.cached_max_speed + 7) >> 3)); } /** @@ -535,7 +535,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); @@ -697,8 +697,8 @@ struct RoadVehFindData { static Vehicle *EnumCheckRoadVehClose(Vehicle *veh, 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; RoadVehicle *v = RoadVehicle::From(veh); @@ -1149,7 +1149,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 @@ static Trackdir RoadFindPathToDest(RoadVehicle *v, TileIndex tile, DiagDirection default: NOT_REACHED(); } DEBUG_UPDATESTATECHECKSUM("RoadFindPathToDest: v: %u, path_found: %d, best_track: %d", v->index, path_found, best_track); - UpdateStateChecksum((((uint64) v->index) << 32) | (path_found << 16) | best_track); + UpdateStateChecksum((((uint64_t) v->index) << 32) | (path_found << 16) | best_track); v->HandlePathfindingResult(path_found); found_best_track:; @@ -1466,7 +1466,7 @@ struct FinishOvertakeData { const Vehicle *v; int min_coord; int max_coord; - uint8 not_road_pos; + uint8_t not_road_pos; RoadTypeCollisionMode collision_mode; }; @@ -1828,7 +1828,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; @@ -1944,7 +1944,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; @@ -2097,7 +2097,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; @@ -2219,9 +2219,9 @@ Money RoadVehicle::GetRunningCost() const bool RoadVehicle::Tick() { DEBUG_UPDATESTATECHECKSUM("RoadVehicle::Tick 1: v: %u, x: %d, y: %d", this->index, this->x_pos, this->y_pos); - UpdateStateChecksum((((uint64) this->x_pos) << 32) | this->y_pos); + UpdateStateChecksum((((uint64_t) this->x_pos) << 32) | this->y_pos); DEBUG_UPDATESTATECHECKSUM("RoadVehicle::Tick 2: v: %u, state: %d, frame: %d", this->index, this->state, this->frame); - UpdateStateChecksum((((uint64) this->state) << 32) | this->frame); + UpdateStateChecksum((((uint64_t) this->state) << 32) | this->frame); if (this->IsFrontEngine()) { if (!(this->IsRoadVehicleStopped() || this->IsWaitingInDepot())) this->running_ticks++; return RoadVehController(this); @@ -2346,9 +2346,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 c6ab0ad65f..818ddbd835 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -858,7 +858,7 @@ bool AfterLoadGame() } } if (SlXvIsFeatureMissing(XSLFI_VARIABLE_DAY_LENGTH, 3)) { - _scaled_tick_counter = (uint64)((_tick_counter * _settings_game.economy.day_length_factor) + _tick_skip_counter); + _scaled_tick_counter = (uint64_t)((_tick_counter * _settings_game.economy.day_length_factor) + _tick_skip_counter); } /* Update current year @@ -1586,7 +1586,7 @@ bool AfterLoadGame() /* m2 signal state bit allocation has shrunk */ for (TileIndex t = 0; t < map_size; t++) { if (IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL && IsBridge(t) && IsTunnelBridgeSignalSimulationEntrance(t)) { - extern void ShiftBridgeEntranceSimulatedSignalsExtended(TileIndex t, int shift, uint64 in); + extern void ShiftBridgeEntranceSimulatedSignalsExtended(TileIndex t, int shift, uint64_t in); const uint shift = 15 - BRIDGE_M2_SIGNAL_STATE_COUNT; ShiftBridgeEntranceSimulatedSignalsExtended(t, shift, GB(_m[t].m2, BRIDGE_M2_SIGNAL_STATE_COUNT, shift)); SB(_m[t].m2, 0, 15, GB(_m[t].m2, 0, 15) << shift); @@ -2313,7 +2313,7 @@ bool AfterLoadGame() /* Replace "house construction year" with "house age" */ if (IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)) { - _m[t].m5 = ClampTo(_cur_year - (_m[t].m5 + ORIGINAL_BASE_YEAR)); + _m[t].m5 = ClampTo(_cur_year - (_m[t].m5 + ORIGINAL_BASE_YEAR)); } } } @@ -2684,7 +2684,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; @@ -3134,7 +3134,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)); } } @@ -3335,7 +3335,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; } @@ -3364,7 +3364,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); @@ -3606,7 +3606,7 @@ bool AfterLoadGame() v->timetable_start += _scaled_date_ticks.base() - _tick_counter; } } else if (!SlXvIsFeaturePresent(XSLFI_TIMETABLES_START_TICKS, 3)) { - extern btree::btree_map _old_timetable_start_subticks_map; + extern btree::btree_map _old_timetable_start_subticks_map; for (Vehicle *v : Vehicle::Iterate()) { if (v->timetable_start == 0) continue; @@ -3885,7 +3885,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); } @@ -3902,7 +3902,7 @@ bool AfterLoadGame() /* Use current order time to approximate last loading time */ if (IsSavegameVersionBefore(SLV_LAST_LOADING_TICK) && SlXvIsFeatureMissing(XSLFI_LAST_LOADING_TICK)) { for (Vehicle *v : Vehicle::Iterate()) { - v->last_loading_tick = std::max(_scaled_tick_counter, static_cast(v->current_order_time)) - v->current_order_time; + v->last_loading_tick = std::max(_scaled_tick_counter, static_cast(v->current_order_time)) - v->current_order_time; } } else if (SlXvIsFeaturePresent(XSLFI_LAST_LOADING_TICK, 1, 1)) { for (Vehicle *v : Vehicle::Iterate()) { @@ -4192,7 +4192,7 @@ bool AfterLoadGame() } } if (SlXvIsFeaturePresent(XSLFI_SCHEDULED_DISPATCH, 1, 4)) { - extern btree::btree_map _old_scheduled_dispatch_start_full_date_fract_map; + extern btree::btree_map _old_scheduled_dispatch_start_full_date_fract_map; for (OrderList *order_list : OrderList::Iterate()) { for (DispatchSchedule &ds : order_list->GetScheduledDispatchScheduleSet()) { diff --git a/src/saveload/animated_tile_sl.cpp b/src/saveload/animated_tile_sl.cpp index 764d2266c5..b4370ca03a 100644 --- a/src/saveload/animated_tile_sl.cpp +++ b/src/saveload/animated_tile_sl.cpp @@ -51,7 +51,7 @@ struct ANITChunkHandler : ChunkHandler { } if (IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY)) { - size_t count = SlGetFieldLength() / sizeof(uint32); + size_t count = SlGetFieldLength() / sizeof(uint32_t); _animated_tiles.clear(); for (uint i = 0; i < count; i++) { _animated_tiles[SlReadUint32()] = {}; diff --git a/src/saveload/cargomonitor_sl.cpp b/src/saveload/cargomonitor_sl.cpp index ba0b598fab..a61391d377 100644 --- a/src/saveload/cargomonitor_sl.cpp +++ b/src/saveload/cargomonitor_sl.cpp @@ -21,7 +21,7 @@ namespace upstream_sl { /** 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. */ @@ -83,7 +83,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); } } @@ -127,7 +127,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 213e2d08a4..6f508c574f 100644 --- a/src/saveload/company_sl.cpp +++ b/src/saveload/company_sl.cpp @@ -31,7 +31,7 @@ namespace upstream_sl { /* 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 { @@ -155,7 +155,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/game_sl.cpp b/src/saveload/game_sl.cpp index 14ff8bfed4..049724be58 100644 --- a/src/saveload/game_sl.cpp +++ b/src/saveload/game_sl.cpp @@ -121,7 +121,7 @@ struct GSDTChunkHandler : ChunkHandler { }; static std::string _game_saveload_string; -static uint32 _game_saveload_strings; +static uint32_t _game_saveload_strings; class SlGameLanguageString : public DefaultSaveLoadHandler { public: @@ -142,9 +142,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 f218ce0ebf..20eea07ee5 100644 --- a/src/saveload/labelmaps_sl.cpp +++ b/src/saveload/labelmaps_sl.cpp @@ -25,7 +25,7 @@ namespace upstream_sl { /** 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 adb4dad1be..3f212ad4a4 100644 --- a/src/saveload/linkgraph_sl.cpp +++ b/src/saveload/linkgraph_sl.cpp @@ -24,7 +24,7 @@ namespace upstream_sl { 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. static NodeID _edge_dest_node; @@ -50,7 +50,7 @@ public: void Load(Node *bn) const override { - uint16 max_size = _linkgraph->Size(); + uint16_t max_size = _linkgraph->Size(); if (IsSavegameVersionBefore(SLV_191)) { NOT_REACHED(); @@ -109,7 +109,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 afea07a59d..4f7993bab1 100644 --- a/src/saveload/map_sl.cpp +++ b/src/saveload/map_sl.cpp @@ -22,8 +22,8 @@ namespace upstream_sl { -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), @@ -156,7 +156,7 @@ struct MAP2ChunkHandler : ChunkHandler { void Load() const override { - std::array buf; + std::array buf; TileIndex size = MapSize(); for (TileIndex i = 0; i != size;) { @@ -170,10 +170,10 @@ struct MAP2ChunkHandler : ChunkHandler { void Save() const override { - std::array buf; + std::array buf; TileIndex size = MapSize(); - 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] = _m[i++].m2; SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT16); @@ -334,7 +334,7 @@ struct MAP8ChunkHandler : ChunkHandler { void Load() const override { - std::array buf; + std::array buf; TileIndex size = MapSize(); for (TileIndex i = 0; i != size;) { @@ -345,10 +345,10 @@ struct MAP8ChunkHandler : ChunkHandler { void Save() const override { - std::array buf; + std::array buf; TileIndex size = MapSize(); - 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] = _me[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 f33911e36c..8c023e294c 100644 --- a/src/saveload/misc_sl.cpp +++ b/src/saveload/misc_sl.cpp @@ -28,7 +28,7 @@ extern TileIndex _cur_tileloop_tile; extern TileIndex _aux_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 91e90fb77a..44f32714dd 100644 --- a/src/saveload/newgrf_sl.h +++ b/src/saveload/newgrf_sl.h @@ -17,7 +17,7 @@ namespace upstream_sl { 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/order_sl.cpp b/src/saveload/order_sl.cpp index ea08cbdcca..1c87d78712 100644 --- a/src/saveload/order_sl.cpp +++ b/src/saveload/order_sl.cpp @@ -26,7 +26,7 @@ namespace upstream_sl { * @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)); } @@ -36,7 +36,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); @@ -88,9 +88,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); @@ -99,8 +99,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 c828363123..9b88cace34 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -294,7 +294,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: @@ -343,7 +343,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]; } @@ -359,7 +359,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]; } @@ -454,7 +454,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: @@ -516,18 +516,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_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_BL: return (*(const bool *)ptr != 0); + case SLE_VAR_I8: return *(const int8_t *)ptr; + case SLE_VAR_U8: return *(const byte *)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(); } @@ -540,18 +540,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_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_BL: *(bool *)ptr = (val != 0); break; + case SLE_VAR_I8: *(int8_t *)ptr = val; break; + case SLE_VAR_U8: *(byte *)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(); @@ -570,7 +570,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)) { @@ -580,7 +580,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(); @@ -589,18 +589,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_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_I8: x = (int8_t )SlReadByte(); break; + case SLE_FILE_U8: x = (byte )SlReadByte(); 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(); } @@ -832,7 +832,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; } @@ -889,7 +889,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) { @@ -1050,7 +1050,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: @@ -1246,14 +1246,14 @@ static inline size_t SlCalcRingLen(const void *ring, VarType conv) { switch (GetVarMemType(conv)) { case SLE_VAR_BL: return SlStorageHelper::SlCalcLen(ring, conv); - case SLE_VAR_I8: return SlStorageHelper::SlCalcLen(ring, conv); - case SLE_VAR_U8: return SlStorageHelper::SlCalcLen(ring, conv); - case SLE_VAR_I16: return SlStorageHelper::SlCalcLen(ring, conv); - case SLE_VAR_U16: return SlStorageHelper::SlCalcLen(ring, conv); - case SLE_VAR_I32: return SlStorageHelper::SlCalcLen(ring, conv); - case SLE_VAR_U32: return SlStorageHelper::SlCalcLen(ring, conv); - case SLE_VAR_I64: return SlStorageHelper::SlCalcLen(ring, conv); - case SLE_VAR_U64: return SlStorageHelper::SlCalcLen(ring, conv); + case SLE_VAR_I8: return SlStorageHelper::SlCalcLen(ring, conv); + case SLE_VAR_U8: return SlStorageHelper::SlCalcLen(ring, conv); + case SLE_VAR_I16: return SlStorageHelper::SlCalcLen(ring, conv); + case SLE_VAR_U16: return SlStorageHelper::SlCalcLen(ring, conv); + case SLE_VAR_I32: return SlStorageHelper::SlCalcLen(ring, conv); + case SLE_VAR_U32: return SlStorageHelper::SlCalcLen(ring, conv); + case SLE_VAR_I64: return SlStorageHelper::SlCalcLen(ring, conv); + case SLE_VAR_U64: return SlStorageHelper::SlCalcLen(ring, conv); default: NOT_REACHED(); } } @@ -1267,14 +1267,14 @@ static void SlRing(void *ring, VarType conv) { switch (GetVarMemType(conv)) { case SLE_VAR_BL: SlStorageHelper::SlSaveLoad(ring, conv); break; - case SLE_VAR_I8: SlStorageHelper::SlSaveLoad(ring, conv); break; - case SLE_VAR_U8: SlStorageHelper::SlSaveLoad(ring, conv); break; - case SLE_VAR_I16: SlStorageHelper::SlSaveLoad(ring, conv); break; - case SLE_VAR_U16: SlStorageHelper::SlSaveLoad(ring, conv); break; - case SLE_VAR_I32: SlStorageHelper::SlSaveLoad(ring, conv); break; - case SLE_VAR_U32: SlStorageHelper::SlSaveLoad(ring, conv); break; - case SLE_VAR_I64: SlStorageHelper::SlSaveLoad(ring, conv); break; - case SLE_VAR_U64: SlStorageHelper::SlSaveLoad(ring, conv); break; + case SLE_VAR_I8: SlStorageHelper::SlSaveLoad(ring, conv); break; + case SLE_VAR_U8: SlStorageHelper::SlSaveLoad(ring, conv); break; + case SLE_VAR_I16: SlStorageHelper::SlSaveLoad(ring, conv); break; + case SLE_VAR_U16: SlStorageHelper::SlSaveLoad(ring, conv); break; + case SLE_VAR_I32: SlStorageHelper::SlSaveLoad(ring, conv); break; + case SLE_VAR_U32: SlStorageHelper::SlSaveLoad(ring, conv); break; + case SLE_VAR_I64: SlStorageHelper::SlSaveLoad(ring, conv); break; + case SLE_VAR_U64: SlStorageHelper::SlSaveLoad(ring, conv); break; default: NOT_REACHED(); } } @@ -1288,14 +1288,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(); } } @@ -1309,14 +1309,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(); } } @@ -1462,7 +1462,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: @@ -1635,7 +1635,7 @@ std::vector SlTableHeader(const SaveLoadTable &slt) } while (true) { - uint8 type = 0; + uint8_t type = 0; SlSaveLoadConv(&type, SLE_UINT8); if (type == SLE_FILE_END) break; @@ -1676,7 +1676,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 '%s' was expected to be 0x%02X but 0x%02X was found", key.c_str(), correct_type, type); SlErrorCorrupt("Field type is different than expected"); @@ -1705,7 +1705,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); @@ -1713,7 +1713,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. */ @@ -1944,7 +1944,7 @@ static void SlLoadCheckChunk(const ChunkHandler &ch) * @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; @@ -1955,7 +1955,7 @@ void SlLoadChunks() { _sl.action = SLA_LOAD; - uint32 id; + uint32_t id; const ChunkHandler *ch; for (id = SlReadUint32(); id != 0; id = SlReadUint32()) { @@ -1968,7 +1968,7 @@ void SlLoadChunks() } /** Load a chunk */ -void SlLoadChunkByID(uint32 id) +void SlLoadChunkByID(uint32_t id) { _sl.action = SLA_LOAD; @@ -1984,7 +1984,7 @@ void SlLoadCheckChunks() { _sl.action = SLA_LOAD_CHECK; - uint32 id; + uint32_t id; const ChunkHandler *ch; for (id = SlReadUint32(); id != 0; id = SlReadUint32()) { @@ -1997,7 +1997,7 @@ void SlLoadCheckChunks() } /** Load a chunk for savegame checking */ -void SlLoadCheckChunkByID(uint32 id) +void SlLoadCheckChunkByID(uint32_t id) { _sl.action = SLA_LOAD_CHECK; @@ -2021,7 +2021,7 @@ void SlFixPointers() assert(_sl.action == SLA_PTRS); } -void SlFixPointerChunkByID(uint32 id) +void SlFixPointerChunkByID(uint32_t id) { const ChunkHandler *ch = SlFindChunkHandler(id); if (ch == nullptr) SlErrorCorrupt("Unknown chunk type"); @@ -2070,7 +2070,7 @@ static void SlSaveChunk(const ChunkHandler &ch) } /** Save a chunk of data */ -void SlSaveChunkChunkByID(uint32 id) +void SlSaveChunkChunkByID(uint32_t id) { const ChunkHandler *ch = SlFindChunkHandler(id); if (ch == nullptr) SlErrorCorrupt("Unknown chunk type"); diff --git a/src/saveload/saveload.h b/src/saveload/saveload.h index 0aa1b9e603..881a2c7161 100644 --- a/src/saveload/saveload.h +++ b/src/saveload/saveload.h @@ -44,10 +44,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; @@ -263,7 +263,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 { @@ -294,7 +294,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. @@ -313,7 +313,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. }; @@ -888,8 +888,8 @@ 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/settings_sl.cpp b/src/saveload/settings_sl.cpp index ee7c1f6404..e0bd468dc2 100644 --- a/src/saveload/settings_sl.cpp +++ b/src/saveload/settings_sl.cpp @@ -116,7 +116,7 @@ static std::vector GetSettingsDesc(bool is_loading) error("Unexpected save conv for %s: 0x%02X", sd->name, sd->save.conv); } - /* economy.town_growth_rate is int8 here, but uint8 in upstream saves */ + /* economy.town_growth_rate is int8_t here, but uint8_t in upstream saves */ if (is_loading && !SlXvIsFeaturePresent(XSLFI_TABLE_PATS) && strcmp(sd->name, "economy.town_growth_rate") == 0) { SB(new_type, 0, 4, SLE_FILE_U8); } diff --git a/src/saveload/station_sl.cpp b/src/saveload/station_sl.cpp index 366b165390..a13059289e 100644 --- a/src/saveload/station_sl.cpp +++ b/src/saveload/station_sl.cpp @@ -31,22 +31,22 @@ 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; CargoPacketList _packets; -uint32 _old_num_dests; +uint32_t _old_num_dests; uint _cargo_reserved_count; struct FlowSaveLoad { FlowSaveLoad() : source(0), via(0), share(0), restricted(false) {} StationID source; StationID via; - uint32 share; + uint32_t share; bool restricted; }; @@ -96,7 +96,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->speclist.resize(num_specs); for (uint i = 0; i < num_specs; i++) { @@ -124,7 +124,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++) { @@ -191,7 +191,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->data->flows.insert(ge->data->flows.end(), FlowStat(flow.source, flow.via, flow.share, flow.restricted)))); @@ -344,7 +344,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 { @@ -356,7 +356,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 bde9941058..38af40d053 100644 --- a/src/saveload/story_sl.cpp +++ b/src/saveload/story_sl.cpp @@ -46,7 +46,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); @@ -88,7 +88,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/town_sl.cpp b/src/saveload/town_sl.cpp index 4a8a973411..19e3da4574 100644 --- a/src/saveload/town_sl.cpp +++ b/src/saveload/town_sl.cpp @@ -29,10 +29,10 @@ typedef TileMatrix AcceptanceMatrix; 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; @@ -68,10 +68,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 c8af7a1c8a..1315323203 100644 --- a/src/saveload/vehicle_sl.cpp +++ b/src/saveload/vehicle_sl.cpp @@ -38,11 +38,11 @@ static std::vector _path_tile; namespace upstream_sl { -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; class SlVehicleCommon : public DefaultSaveLoadHandler { @@ -271,7 +271,7 @@ public: if (!_path_td.empty() && _path_td.size() <= RV_PATH_CACHE_SEGMENTS && _path_td.size() == _path_tile.size()) { RoadVehicle *rv = RoadVehicle::From(v); rv->cached_path.reset(new RoadVehPathCache()); - rv->cached_path->count = (uint8)_path_td.size(); + rv->cached_path->count = (uint8_t)_path_td.size(); for (size_t i = 0; i < _path_td.size(); i++) { rv->cached_path->td[i] = _path_td[i]; rv->cached_path->tile[i] = _path_tile[i]; @@ -312,7 +312,7 @@ public: if (!_path_td.empty() && _path_td.size() <= SHIP_PATH_CACHE_LENGTH) { Ship *s = Ship::From(v); s->cached_path.reset(new ShipPathCache()); - s->cached_path->count = (uint8)_path_td.size(); + s->cached_path->count = (uint8_t)_path_td.size(); for (size_t i = 0; i < _path_td.size(); i++) { s->cached_path->td[i] = _path_td[i]; } diff --git a/src/schdispatch_cmd.cpp b/src/schdispatch_cmd.cpp index 2a891d11c1..536dccd0b0 100644 --- a/src/schdispatch_cmd.cpp +++ b/src/schdispatch_cmd.cpp @@ -37,7 +37,7 @@ * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdScheduledDispatch(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdScheduledDispatch(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); @@ -73,12 +73,12 @@ CommandCost CmdScheduledDispatch(TileIndex tile, DoCommandFlag flags, uint32 p1, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdScheduledDispatchAdd(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdScheduledDispatchAdd(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { VehicleID veh = GB(p1, 0, 20); uint schedule_index = GB(p1, 20, 12); - uint32 offset = GB(p3, 0, 32); - uint32 extra_slots = GB(p3, 32, 16); + uint32_t offset = GB(p3, 0, 32); + uint32_t extra_slots = GB(p3, 32, 16); Vehicle *v = Vehicle::GetIfValid(veh); if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR; @@ -116,7 +116,7 @@ CommandCost CmdScheduledDispatchAdd(TileIndex tile, DoCommandFlag flags, uint32 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdScheduledDispatchRemove(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdScheduledDispatchRemove(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); uint schedule_index = GB(p1, 20, 12); @@ -149,7 +149,7 @@ CommandCost CmdScheduledDispatchRemove(TileIndex tile, DoCommandFlag flags, uint * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdScheduledDispatchSetDuration(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdScheduledDispatchSetDuration(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); uint schedule_index = GB(p1, 20, 12); @@ -185,7 +185,7 @@ CommandCost CmdScheduledDispatchSetDuration(TileIndex tile, DoCommandFlag flags, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdScheduledDispatchSetStartDate(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdScheduledDispatchSetStartDate(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { VehicleID veh = GB(p1, 0, 20); uint schedule_index = GB(p1, 20, 12); @@ -220,7 +220,7 @@ CommandCost CmdScheduledDispatchSetStartDate(TileIndex tile, DoCommandFlag flags * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdScheduledDispatchSetDelay(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdScheduledDispatchSetDelay(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); uint schedule_index = GB(p1, 20, 12); @@ -258,7 +258,7 @@ CommandCost CmdScheduledDispatchSetDelay(TileIndex tile, DoCommandFlag flags, ui * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdScheduledDispatchResetLastDispatch(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdScheduledDispatchResetLastDispatch(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); uint schedule_index = GB(p1, 20, 12); @@ -291,7 +291,7 @@ CommandCost CmdScheduledDispatchResetLastDispatch(TileIndex tile, DoCommandFlag * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdScheduledDispatchClear(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdScheduledDispatchClear(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); uint schedule_index = GB(p1, 20, 12); @@ -325,7 +325,7 @@ CommandCost CmdScheduledDispatchClear(TileIndex tile, DoCommandFlag flags, uint3 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdScheduledDispatchAddNewSchedule(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdScheduledDispatchAddNewSchedule(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { VehicleID veh = GB(p1, 0, 20); @@ -360,7 +360,7 @@ CommandCost CmdScheduledDispatchAddNewSchedule(TileIndex tile, DoCommandFlag fla * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdScheduledDispatchRemoveSchedule(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdScheduledDispatchRemoveSchedule(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); uint schedule_index = GB(p1, 20, 12); @@ -386,13 +386,13 @@ CommandCost CmdScheduledDispatchRemoveSchedule(TileIndex tile, DoCommandFlag fla o->SetDispatchScheduleIndex(idx - 1); } if (o->IsType(OT_CONDITIONAL) && o->GetConditionVariable() == OCV_DISPATCH_SLOT) { - uint16 dispatch_slot = GB(o->GetXData(), 0, 16); + uint16_t dispatch_slot = GB(o->GetXData(), 0, 16); if (dispatch_slot == UINT16_MAX) { /* do nothing */ } else if (dispatch_slot == schedule_index) { SB(o->GetXDataRef(), 0, 16, UINT16_MAX); } else if (dispatch_slot > schedule_index) { - SB(o->GetXDataRef(), 0, 16, (uint16)(dispatch_slot - 1)); + SB(o->GetXDataRef(), 0, 16, (uint16_t)(dispatch_slot - 1)); } } } @@ -412,7 +412,7 @@ CommandCost CmdScheduledDispatchRemoveSchedule(TileIndex tile, DoCommandFlag fla * @param text name * @return the cost of this operation or an error */ -CommandCost CmdScheduledDispatchRenameSchedule(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdScheduledDispatchRenameSchedule(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); uint schedule_index = GB(p1, 20, 12); @@ -455,7 +455,7 @@ CommandCost CmdScheduledDispatchRenameSchedule(TileIndex tile, DoCommandFlag fla * @param text name * @return the cost of this operation or an error */ -CommandCost CmdScheduledDispatchDuplicateSchedule(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdScheduledDispatchDuplicateSchedule(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); uint schedule_index = GB(p1, 20, 12); @@ -491,7 +491,7 @@ CommandCost CmdScheduledDispatchDuplicateSchedule(TileIndex tile, DoCommandFlag * @param text name * @return the cost of this operation or an error */ -CommandCost CmdScheduledDispatchAppendVehicleSchedules(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdScheduledDispatchAppendVehicleSchedules(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh1 = GB(p1, 0, 20); VehicleID veh2 = GB(p2, 0, 20); @@ -531,11 +531,11 @@ CommandCost CmdScheduledDispatchAppendVehicleSchedules(TileIndex tile, DoCommand * @param text name * @return the cost of this operation or an error */ -CommandCost CmdScheduledDispatchAdjust(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdScheduledDispatchAdjust(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); uint schedule_index = GB(p1, 20, 12); - int32 adjustment = p2; + int32_t adjustment = p2; Vehicle *v = Vehicle::GetIfValid(veh); if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR; @@ -572,7 +572,7 @@ CommandCost CmdScheduledDispatchAdjust(TileIndex tile, DoCommandFlag flags, uint * @param unused * @return the cost of this operation or an error */ -CommandCost CmdScheduledDispatchSwapSchedules(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdScheduledDispatchSwapSchedules(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); uint schedule_index_1 = GB(p2, 0, 16); @@ -600,7 +600,7 @@ CommandCost CmdScheduledDispatchSwapSchedules(TileIndex tile, DoCommandFlag flag o->SetDispatchScheduleIndex((int)schedule_index_1); } if (o->IsType(OT_CONDITIONAL) && o->GetConditionVariable() == OCV_DISPATCH_SLOT) { - uint16 dispatch_slot = GB(o->GetXData(), 0, 16); + uint16_t dispatch_slot = GB(o->GetXData(), 0, 16); if (dispatch_slot == schedule_index_1) { SB(o->GetXDataRef(), 0, 16, schedule_index_2); } else if (dispatch_slot == schedule_index_2) { @@ -619,7 +619,7 @@ CommandCost CmdScheduledDispatchSwapSchedules(TileIndex tile, DoCommandFlag flag * Set scheduled dispatch slot list. * @param dispatch_list The offset time list, must be correctly sorted. */ -void DispatchSchedule::SetScheduledDispatch(std::vector dispatch_list) +void DispatchSchedule::SetScheduledDispatch(std::vector dispatch_list) { this->scheduled_dispatch = std::move(dispatch_list); assert(std::is_sorted(this->scheduled_dispatch.begin(), this->scheduled_dispatch.end())); @@ -630,7 +630,7 @@ void DispatchSchedule::SetScheduledDispatch(std::vector dispatch_list) * Add new scheduled dispatch slot at offsets time. * @param offset The offset time to add. */ -void DispatchSchedule::AddScheduledDispatch(uint32 offset) +void DispatchSchedule::AddScheduledDispatch(uint32_t offset) { /* Maintain sorted list status */ auto insert_position = std::lower_bound(this->scheduled_dispatch.begin(), this->scheduled_dispatch.end(), offset); @@ -645,7 +645,7 @@ void DispatchSchedule::AddScheduledDispatch(uint32 offset) * Remove scheduled dispatch slot at offsets time. * @param offset The offset time to remove. */ -void DispatchSchedule::RemoveScheduledDispatch(uint32 offset) +void DispatchSchedule::RemoveScheduledDispatch(uint32_t offset) { /* Maintain sorted list status */ auto erase_position = std::lower_bound(this->scheduled_dispatch.begin(), this->scheduled_dispatch.end(), offset); @@ -659,13 +659,13 @@ void DispatchSchedule::RemoveScheduledDispatch(uint32 offset) * Adjust all scheduled dispatch slots by time adjustment. * @param adjust The time adjustment to add to each time slot. */ -void DispatchSchedule::AdjustScheduledDispatch(int32 adjust) +void DispatchSchedule::AdjustScheduledDispatch(int32_t adjust) { - for (uint32 &time : this->scheduled_dispatch) { - int32 t = (int32)time + adjust; + for (uint32_t &time : this->scheduled_dispatch) { + int32_t t = (int32_t)time + adjust; if (t < 0) t += GetScheduledDispatchDuration(); - if (t >= (int32)GetScheduledDispatchDuration()) t -= (int32)GetScheduledDispatchDuration(); - time = (uint32)t; + if (t >= (int32_t)GetScheduledDispatchDuration()) t -= (int32_t)GetScheduledDispatchDuration(); + time = (uint32_t)t; } std::sort(this->scheduled_dispatch.begin(), this->scheduled_dispatch.end()); } @@ -676,13 +676,13 @@ bool DispatchSchedule::UpdateScheduledDispatchToDate(DateTicksScaled now) if (this->GetScheduledDispatchStartTick() == 0) { DateTicksScaled start = now - (now.base() % this->GetScheduledDispatchDuration()); this->SetScheduledDispatchStartTick(start); - int64 last_dispatch = -(start.base()); + int64_t last_dispatch = -(start.base()); if (last_dispatch < INT_MIN && _settings_game.game_time.time_in_minutes) { /* Advance by multiples of 24 hours */ - const int64 day = 24 * 60 * _settings_game.game_time.ticks_per_minute; - this->scheduled_dispatch_last_dispatch = last_dispatch + (CeilDivT(INT_MIN - last_dispatch, day) * day); + const int64_t day = 24 * 60 * _settings_game.game_time.ticks_per_minute; + this->scheduled_dispatch_last_dispatch = last_dispatch + (CeilDivT(INT_MIN - last_dispatch, day) * day); } else { - this->scheduled_dispatch_last_dispatch = ClampTo(last_dispatch); + this->scheduled_dispatch_last_dispatch = ClampTo(last_dispatch); } } /* Most of the time this loop does not run. It makes sure start date in in past */ diff --git a/src/schdispatch_gui.cpp b/src/schdispatch_gui.cpp index 988385228a..a992b4389c 100644 --- a/src/schdispatch_gui.cpp +++ b/src/schdispatch_gui.cpp @@ -66,9 +66,9 @@ enum SchdispatchWidgets { * @param p1 The p1 parameter to send to CmdScheduledDispatchSetStartDate * @param date the actually chosen date */ -static void SetScheduleStartDateIntl(uint32 p1, DateTicksScaled date) +static void SetScheduleStartDateIntl(uint32_t p1, DateTicksScaled date) { - DoCommandPEx(0, p1, 0, (uint64)date.base(), CMD_SCHEDULED_DISPATCH_SET_START_DATE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), nullptr, nullptr, 0); + DoCommandPEx(0, p1, 0, (uint64_t)date.base(), CMD_SCHEDULED_DISPATCH_SET_START_DATE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), nullptr, nullptr, 0); } /** @@ -86,7 +86,7 @@ static void SetScheduleStartDateCallback(const Window *w, DateTicksScaled date) * @param p1 The p1 parameter to send to CmdScheduledDispatchAdd * @param date the actually chosen date */ -static void ScheduleAddIntl(uint32 p1, DateTicksScaled date, uint extra_slots, uint offset, bool wrap_mode = false) +static void ScheduleAddIntl(uint32_t p1, DateTicksScaled date, uint extra_slots, uint offset, bool wrap_mode = false) { VehicleID veh = GB(p1, 0, 20); uint schedule_index = GB(p1, 20, 12); @@ -97,18 +97,18 @@ static void ScheduleAddIntl(uint32 p1, DateTicksScaled date, uint extra_slots, u /* Make sure the time is the closest future to the timetable start */ DateTicksScaled start_tick = ds.GetScheduledDispatchStartTick(); - uint32 duration = ds.GetScheduledDispatchDuration(); + uint32_t duration = ds.GetScheduledDispatchDuration(); while (date > start_tick) date -= duration; while (date < start_tick) date += duration; if (extra_slots > 0 && offset > 0 && !wrap_mode) { DateTicksScaled end_tick = start_tick + duration; - int64 max_extra_slots = (end_tick - 1 - date).base() / offset; - if (max_extra_slots < extra_slots) extra_slots = static_cast(std::max(0, max_extra_slots)); + int64_t max_extra_slots = (end_tick - 1 - date).base() / offset; + if (max_extra_slots < extra_slots) extra_slots = static_cast(std::max(0, max_extra_slots)); extra_slots = std::min(extra_slots, UINT16_MAX); } - DoCommandPEx(0, p1, (uint32)(date - start_tick).base(), (((uint64)extra_slots) << 32) | offset, CMD_SCHEDULED_DISPATCH_ADD | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), nullptr, nullptr, 0); + DoCommandPEx(0, p1, (uint32_t)(date - start_tick).base(), (((uint64_t)extra_slots) << 32) | offset, CMD_SCHEDULED_DISPATCH_ADD | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), nullptr, nullptr, 0); } /** @@ -128,7 +128,7 @@ static void ScheduleAddCallback(const Window *w, DateTicksScaled date) * @param offsets list of all dispatch offsets in the schedule * @return maxinum number of vehicle required */ -static int CalculateMaxRequiredVehicle(Ticks timetable_duration, uint32 schedule_duration, std::vector offsets) +static int CalculateMaxRequiredVehicle(Ticks timetable_duration, uint32_t schedule_duration, std::vector offsets) { if (timetable_duration == INVALID_TICKS) return -1; if (offsets.size() == 0) return -1; @@ -137,9 +137,9 @@ static int CalculateMaxRequiredVehicle(Ticks timetable_duration, uint32 schedule int required_loop = CeilDiv(timetable_duration, schedule_duration) + 1; /* Create indice array to count maximum overlapping range */ - std::vector> indices; + std::vector> indices; for (int i = 0; i < required_loop; i++) { - for (uint32 offset : offsets) { + for (uint32_t offset : offsets) { if (offset >= schedule_duration) continue; indices.push_back(std::make_pair(i * schedule_duration + offset, 1)); indices.push_back(std::make_pair(i * schedule_duration + offset + timetable_duration, -1)); @@ -159,7 +159,7 @@ static int CalculateMaxRequiredVehicle(Ticks timetable_duration, uint32 schedule static void AddNewScheduledDispatchSchedule(VehicleID vindex) { DateTicksScaled start_tick; - uint32 duration; + uint32_t duration; const Company *c = Company::GetIfValid(_local_company); if (c != nullptr && c->settings.default_sched_dispatch_duration != 0) { @@ -181,7 +181,7 @@ static void AddNewScheduledDispatchSchedule(VehicleID vindex) duration = 365 * DAY_TICKS; } - DoCommandPEx(0, vindex, duration, (uint64)start_tick.base(), CMD_SCHEDULED_DISPATCH_ADD_NEW_SCHEDULE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), CcAddNewSchDispatchSchedule, nullptr, 0); + DoCommandPEx(0, vindex, duration, (uint64_t)start_tick.base(), CMD_SCHEDULED_DISPATCH_ADD_NEW_SCHEDULE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), CcAddNewSchDispatchSchedule, nullptr, 0); } struct SchdispatchWindow : GeneralVehicleWindow { @@ -453,7 +453,7 @@ struct SchdispatchWindow : GeneralVehicleWindow { /* Set the row and number of boxes in each row based on the number of boxes drawn in the matrix */ const NWidgetCore *wid = this->GetWidget(WID_SCHDISPATCH_MATRIX); - const uint16 rows_in_display = wid->current_y / wid->resize_y; + const uint16_t rows_in_display = wid->current_y / wid->resize_y; const DispatchSchedule &ds = this->GetSelectedSchedule(); @@ -590,9 +590,9 @@ struct SchdispatchWindow : GeneralVehicleWindow { DrawString(ir.left, ir.right, y, STR_SCHDISPATCH_SUMMARY_L4); y += GetCharacterHeight(FS_NORMAL); - uint32 duration = ds.GetScheduledDispatchDuration(); + uint32_t duration = ds.GetScheduledDispatchDuration(); uint warnings = 0; - for (uint32 slot : ds.GetScheduledDispatch()) { + for (uint32_t slot : ds.GetScheduledDispatch()) { if (slot >= duration) { draw_warning(STR_SCHDISPATCH_SLOT_OUTSIDE_SCHEDULE); warnings++; @@ -645,7 +645,7 @@ struct SchdispatchWindow : GeneralVehicleWindow { } } - int32 ProcessDurationForQueryString(int32 duration) const + int32_t ProcessDurationForQueryString(int32_t duration) const { if (!_settings_client.gui.timetable_in_ticks) duration = RoundDivSU(duration, DATE_UNIT_SIZE); return duration; @@ -673,7 +673,7 @@ struct SchdispatchWindow : GeneralVehicleWindow { } case WID_SCHDISPATCH_ENABLED: { - uint32 p2 = 0; + uint32_t p2 = 0; if (!HasBit(v->vehicle_flags, VF_SCHEDULED_DISPATCH)) SetBit(p2, 0); DoCommandP(0, v->index, p2, CMD_SCHEDULED_DISPATCH | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE)); @@ -865,7 +865,7 @@ struct SchdispatchWindow : GeneralVehicleWindow { if (StrEmpty(str)) break; char *end; - int32 val = std::strtoul(str, &end, 10); + int32_t val = std::strtoul(str, &end, 10); if (val >= 0 && end != nullptr && *end == 0) { uint minutes = (val % 100) % 60; uint hours = (val / 100) % 24; @@ -881,7 +881,7 @@ struct SchdispatchWindow : GeneralVehicleWindow { if (StrEmpty(str)) break; char *end; - int32 val = std::strtoul(str, &end, 10); + int32_t val = std::strtoul(str, &end, 10); if (val >= 0 && end != nullptr && *end == 0) { uint minutes = (val % 100) % 60; uint hours = (val / 100) % 24; @@ -977,7 +977,7 @@ struct SchdispatchWindow : GeneralVehicleWindow { } }; -void CcAddNewSchDispatchSchedule(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcAddNewSchDispatchSchedule(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { SchdispatchWindow *w = dynamic_cast(FindWindowById(WC_SCHDISPATCH_SLOTS, p1)); if (w != nullptr) { @@ -987,7 +987,7 @@ void CcAddNewSchDispatchSchedule(const CommandCost &result, TileIndex tile, uint } } -void CcSwapSchDispatchSchedules(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcSwapSchDispatchSchedules(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { SchdispatchWindow *w = dynamic_cast(FindWindowById(WC_SCHDISPATCH_SLOTS, p1)); if (w != nullptr) { @@ -1086,7 +1086,7 @@ struct ScheduledDispatchAddSlotsWindow : Window { this->FinishInitNested(window_number); } - 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/screenshot.cpp b/src/screenshot.cpp index d7e4944dc8..2dbab8a38f 100644 --- a/src/screenshot.cpp +++ b/src/screenshot.cpp @@ -93,19 +93,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); @@ -193,8 +193,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 = AllocaM(uint8, bytewidth); // one line, stored to file + uint8_t *buff = MallocT(maxlines * w * pixelformat / 8); // buffer which is rendered to + uint8_t *line = AllocaM(uint8_t, bytewidth); // one line, stored to file memset(line, 0, bytewidth); /* Start at the bottom, since bitmaps are stored bottom up */ @@ -326,7 +326,7 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user text[0].text_length = strlen(_openttd_revision); text[0].compression = PNG_TEXT_COMPRESSION_NONE; - const uint32 text_buf_length = 65536; + const uint32_t text_buf_length = 65536; char * const text_buf = MallocT(text_buf_length); auto guard = scope_guard([=]() { free(text_buf); @@ -399,7 +399,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 { @@ -436,16 +436,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); @@ -506,7 +506,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 { @@ -520,14 +520,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) { @@ -758,7 +758,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: @@ -847,7 +847,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); @@ -970,7 +970,7 @@ static void ShowScreenshotResultMessage(ScreenshotType t, bool ret) * @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 @@ -1042,7 +1042,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. */ @@ -1271,7 +1271,7 @@ static byte GetIndustryValue(TileIndex tile) template void MinimapScreenCallback(void *userdata, void *buf, uint y, uint pitch, uint n, T colorCallback) { - 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); @@ -1280,7 +1280,7 @@ void MinimapScreenCallback(void *userdata, void *buf, uint y, uint pitch, uint n TileIndex tile = TileXY(col, row); byte val = colorCallback(tile); - 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 79b7611452..616354a7ac 100644 --- a/src/screenshot.h +++ b/src/screenshot.h @@ -31,11 +31,11 @@ enum ScreenshotType { class SmallMapWindow; -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); bool MakeSmallMapScreenshot(unsigned int width, unsigned int height, SmallMapWindow *window); 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(const char *name); bool MakeTopographyScreenshot(const char *name); bool MakeIndustryScreenshot(const char *name); diff --git a/src/script/api/script_airport.cpp b/src/script/api/script_airport.cpp index 7fa3dcdb62..7a0d92164f 100644 --- a/src/script/api/script_airport.cpp +++ b/src/script/api/script_airport.cpp @@ -16,7 +16,7 @@ #include "../../safeguards.h" extern Town *AirportGetNearestTown(const struct AirportSpec *as, Direction rotation, TileIndex tile, TileIterator &&it, uint &mindist); -extern uint8 GetAirportNoiseLevelForDistance(const struct AirportSpec *as, uint distance); +extern uint8_t GetAirportNoiseLevelForDistance(const struct AirportSpec *as, uint distance); /* static */ bool ScriptAirport::IsValidAirportType(AirportType type) { @@ -171,5 +171,5 @@ extern uint8 GetAirportNoiseLevelForDistance(const struct AirportSpec *as, uint { 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 81653bbdd4..e7c672515c 100644 --- a/src/script/api/script_bridge.hpp +++ b/src/script/api/script_bridge.hpp @@ -87,7 +87,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 2bd80a06d6..e137a6766b 100644 --- a/src/script/api/script_cargo.cpp +++ b/src/script/api/script_cargo.cpp @@ -40,11 +40,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 817dfe60f7..ca3c1e7f68 100644 --- a/src/script/api/script_cargo.hpp +++ b/src/script/api/script_cargo.hpp @@ -143,7 +143,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. @@ -162,7 +162,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 8ec2d2a2a1..8850e5cee2 100644 --- a/src/script/api/script_client.hpp +++ b/src/script/api/script_client.hpp @@ -25,7 +25,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 bd43611da1..a329bcd576 100644 --- a/src/script/api/script_company.cpp +++ b/src/script/api/script_company.cpp @@ -169,7 +169,7 @@ return ::Company::Get(company)->old_economy[quarter - 1].company_value; } -/* static */ Money ScriptCompany::GetAnnualExpenseValue(CompanyID company, uint32 year_offset, ExpensesType expenses_type) +/* static */ Money ScriptCompany::GetAnnualExpenseValue(CompanyID company, uint32_t year_offset, ExpensesType expenses_type) { EnforcePrecondition(false, expenses_type < (ExpensesType)::EXPENSES_END); EnforcePrecondition(false, year_offset <= 2); @@ -211,7 +211,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); @@ -229,7 +229,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()); @@ -249,7 +249,7 @@ EnforcePrecondition(false, company != COMPANY_INVALID); /* Network commands only allow 0 to indicate invalid tiles, not INVALID_TILE */ - return ScriptObject::DoCommandEx(tile == INVALID_TILE ? 0 : tile, company | expenses_type << 8, 0, (uint64)(delta), CMD_CHANGE_BANK_BALANCE); + return ScriptObject::DoCommandEx(tile == INVALID_TILE ? 0 : tile, company | expenses_type << 8, 0, (uint64_t)(delta), CMD_CHANGE_BANK_BALANCE); } /* static */ bool ScriptCompany::BuildCompanyHQ(TileIndex tile) @@ -303,7 +303,7 @@ { EnforceCompanyModeValid(false); EnforcePrecondition(false, money >= 0); - EnforcePrecondition(false, (int64)money <= UINT32_MAX); + EnforcePrecondition(false, (int64_t)money <= UINT32_MAX); return ScriptObject::DoCommand(0, 0, money, CMD_CHANGE_COMPANY_SETTING, "company.engine_renew_money"); } diff --git a/src/script/api/script_company.hpp b/src/script/api/script_company.hpp index 7aa590c975..e4efa6fb4e 100644 --- a/src/script/api/script_company.hpp +++ b/src/script/api/script_company.hpp @@ -321,7 +321,7 @@ public: * @pre year_offset <= 2. * @return The value of the company in the given quarter. */ - static Money GetAnnualExpenseValue(CompanyID company, uint32 year_offset, ExpensesType expenses_type); + static Money GetAnnualExpenseValue(CompanyID company, uint32_t year_offset, ExpensesType expenses_type); /** * Build your company's HQ on the given tile. @@ -364,7 +364,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_engine.cpp b/src/script/api/script_engine.cpp index 31f554fd7d..7f0ec96d16 100644 --- a/src/script/api/script_engine.cpp +++ b/src/script/api/script_engine.cpp @@ -275,7 +275,7 @@ EnforcePrecondition(false, IsValidEngine(engine_id)); EnforcePrecondition(false, company != ScriptCompany::COMPANY_INVALID); - return ScriptObject::DoCommand(0, engine_id, (uint32)company | (1 << 31), CMD_ENGINE_CTRL); + return ScriptObject::DoCommand(0, engine_id, (uint32_t)company | (1 << 31), CMD_ENGINE_CTRL); } /* static */ bool ScriptEngine::DisableForCompany(EngineID engine_id, ScriptCompany::CompanyID company) diff --git a/src/script/api/script_event_types.cpp b/src/script/api/script_event_types.cpp index c7c0a5c68c..366281efd1 100644 --- a/src/script/api/script_event_types.cpp +++ b/src/script/api/script_event_types.cpp @@ -46,7 +46,7 @@ CargoID ScriptEventEnginePreview::GetCargoType() return CargoID(std::distance(std::cbegin(cap), it)); } -int32 ScriptEventEnginePreview::GetCapacity() +int32_t ScriptEventEnginePreview::GetCapacity() { if (!this->IsEngineValid()) return -1; const Engine *e = ::Engine::Get(this->engine); @@ -68,11 +68,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; } @@ -89,7 +89,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 62dc95c847..1716d62c7c 100644 --- a/src/script/api/script_event_types.hpp +++ b/src/script/api/script_event_types.hpp @@ -254,7 +254,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. @@ -263,7 +263,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. @@ -285,7 +285,7 @@ public: #ifdef DOXYGEN_API ScriptVehicle::VehicleType GetVehicleType(); #else - int32 GetVehicleType(); + int32_t GetVehicleType(); #endif /* DOXYGEN_API */ /** @@ -950,7 +950,7 @@ 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. @@ -978,7 +978,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), @@ -997,7 +997,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. @@ -1012,7 +1012,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 ff66a39ba5..712f8325c4 100644 --- a/src/script/api/script_goal.cpp +++ b/src/script/api/script_goal.cpp @@ -116,7 +116,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); @@ -136,7 +136,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 9b0a95659b..92d5964cc8 100644 --- a/src/script/api/script_group.cpp +++ b/src/script/api/script_group.cpp @@ -198,8 +198,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_industry.cpp b/src/script/api/script_industry.cpp index b9908a2b8b..c170bf8cb0 100644 --- a/src/script/api/script_industry.cpp +++ b/src/script/api/script_industry.cpp @@ -270,7 +270,7 @@ auto company = ScriptCompany::ResolveCompanyID(company_id); ::Owner owner = (company == ScriptCompany::COMPANY_INVALID ? ::INVALID_OWNER : (::Owner)company); - return ScriptObject::DoCommand(0, industry_id, (1 << 8) | ((uint8)owner), CMD_INDUSTRY_SET_EXCLUSIVITY); + return ScriptObject::DoCommand(0, industry_id, (1 << 8) | ((uint8_t)owner), CMD_INDUSTRY_SET_EXCLUSIVITY); } /* static */ ScriptCompany::CompanyID ScriptIndustry::GetExclusiveConsumer(IndustryID industry_id) @@ -290,7 +290,7 @@ auto company = ScriptCompany::ResolveCompanyID(company_id); ::Owner owner = (company == ScriptCompany::COMPANY_INVALID ? ::INVALID_OWNER : (::Owner)company); - return ScriptObject::DoCommand(0, industry_id, ((uint8)owner), CMD_INDUSTRY_SET_EXCLUSIVITY); + return ScriptObject::DoCommand(0, industry_id, ((uint8_t)owner), CMD_INDUSTRY_SET_EXCLUSIVITY); } /* static */ SQInteger ScriptIndustry::GetProductionLevel(IndustryID industry_id) @@ -308,5 +308,5 @@ EnforcePrecondition(false, IsValidIndustry(industry_id)); EnforcePrecondition(false, prod_level >= PRODLEVEL_MINIMUM && prod_level <= PRODLEVEL_MAXIMUM); - return ScriptObject::DoCommand(0, industry_id, ((uint8)prod_level) | (show_news ? (1 << 8) : 0), CMD_INDUSTRY_SET_PRODUCTION, custom_news != nullptr ? custom_news->GetEncodedText() : std::string{}); + return ScriptObject::DoCommand(0, industry_id, ((uint8_t)prod_level) | (show_news ? (1 << 8) : 0), CMD_INDUSTRY_SET_PRODUCTION, custom_news != nullptr ? custom_news->GetEncodedText() : std::string{}); } diff --git a/src/script/api/script_industrytype.cpp b/src/script/api/script_industrytype.cpp index 0543187205..ae9b06fe1c 100644 --- a/src/script/api/script_industrytype.cpp +++ b/src/script/api/script_industrytype.cpp @@ -122,8 +122,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::DoCommand(tile, (1 << 16) | (layout_index << 8) | industry_type, seed, CMD_BUILD_INDUSTRY); } @@ -132,7 +132,7 @@ EnforceDeityOrCompanyModeValid(false); EnforcePrecondition(false, CanProspectIndustry(industry_type)); - uint32 seed = ScriptBase::Rand(); + uint32_t seed = ScriptBase::Rand(); return ScriptObject::DoCommand(0, industry_type, seed, CMD_BUILD_INDUSTRY); } diff --git a/src/script/api/script_inflation.cpp b/src/script/api/script_inflation.cpp index c565d89be0..a0ab056ed1 100644 --- a/src/script/api/script_inflation.cpp +++ b/src/script/api/script_inflation.cpp @@ -16,26 +16,26 @@ #include "../../safeguards.h" -/* static */ int64 ScriptInflation::GetPriceFactor() +/* static */ int64_t ScriptInflation::GetPriceFactor() { return _economy.inflation_prices; } -/* static */ int64 ScriptInflation::GetPaymentFactor() +/* static */ int64_t ScriptInflation::GetPaymentFactor() { return _economy.inflation_payment; } -/* static */ bool ScriptInflation::SetPriceFactor(int64 factor) +/* static */ bool ScriptInflation::SetPriceFactor(int64_t factor) { - EnforcePrecondition(false, factor >= 1 << 16 && factor <= (int64)MAX_INFLATION); - if ((uint64)factor == _economy.inflation_prices) return true; - return ScriptObject::DoCommand(0, CHT_INFLATION_COST, (uint32)factor, CMD_CHEAT_SETTING); + EnforcePrecondition(false, factor >= 1 << 16 && factor <= (int64_t)MAX_INFLATION); + if ((uint64_t)factor == _economy.inflation_prices) return true; + return ScriptObject::DoCommand(0, CHT_INFLATION_COST, (uint32_t)factor, CMD_CHEAT_SETTING); } -/* static */ bool ScriptInflation::SetPaymentFactor(int64 factor) +/* static */ bool ScriptInflation::SetPaymentFactor(int64_t factor) { - EnforcePrecondition(false, factor >= 1 << 16 && factor <= (int64)MAX_INFLATION); - if ((uint64)factor == _economy.inflation_payment) return true; - return ScriptObject::DoCommand(0, CHT_INFLATION_INCOME, (uint32)factor, CMD_CHEAT_SETTING); + EnforcePrecondition(false, factor >= 1 << 16 && factor <= (int64_t)MAX_INFLATION); + if ((uint64_t)factor == _economy.inflation_payment) return true; + return ScriptObject::DoCommand(0, CHT_INFLATION_INCOME, (uint32_t)factor, CMD_CHEAT_SETTING); } diff --git a/src/script/api/script_inflation.hpp b/src/script/api/script_inflation.hpp index 9cc969378a..0ca5503f61 100644 --- a/src/script/api/script_inflation.hpp +++ b/src/script/api/script_inflation.hpp @@ -23,13 +23,13 @@ public: * Get the inflation factor for prices. * @return Inflation factor, 16 bit fixed point. */ - static int64 GetPriceFactor(); + static int64_t GetPriceFactor(); /** * Get the inflation factor for payments. * @return Inflation factor, 16 bit fixed point. */ - static int64 GetPaymentFactor(); + static int64_t GetPaymentFactor(); /** * Set the inflation factor for prices. @@ -37,7 +37,7 @@ public: * @return True, if the inflation factor was changed. * @api -ai */ - static bool SetPriceFactor(int64 factor); + static bool SetPriceFactor(int64_t factor); /** * Set the inflation factor for payments. @@ -45,7 +45,7 @@ public: * @return True, if the inflation factor was changed. * @api -ai */ - static bool SetPaymentFactor(int64 factor); + static bool SetPaymentFactor(int64_t factor); }; #endif /* SCRIPT_INFLATION_HPP */ 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 85853c8159..3d6bdd2fcc 100644 --- a/src/script/api/script_infrastructure.cpp +++ b/src/script/api/script_infrastructure.cpp @@ -91,7 +91,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); } @@ -103,7 +103,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 f5ba88f4dd..4ae977c45a 100644 --- a/src/script/api/script_news.cpp +++ b/src/script/api/script_news.cpp @@ -35,7 +35,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_object.cpp b/src/script/api/script_object.cpp index b6a0385f77..25c8a3c688 100644 --- a/src/script/api/script_object.cpp +++ b/src/script/api/script_object.cpp @@ -102,7 +102,7 @@ ScriptObject::ActiveInstance::~ActiveInstance() return GetStorage()->async_mode_instance; } -/* static */ void ScriptObject::SetLastCommand(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +/* static */ void ScriptObject::SetLastCommand(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { ScriptStorage *s = GetStorage(); DEBUG(script, 6, "SetLastCommand company=%02d tile=%06x p1=%08x p2=%08x p3=" OTTD_PRINTFHEX64PAD " cmd=%d", s->root_company, tile, p1, p2, p3, cmd); @@ -113,7 +113,7 @@ ScriptObject::ActiveInstance::~ActiveInstance() s->last_cmd = cmd & CMD_ID_MASK; } -/* static */ bool ScriptObject::CheckLastCommand(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +/* static */ bool ScriptObject::CheckLastCommand(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { ScriptStorage *s = GetStorage(); DEBUG(script, 6, "CheckLastCommand company=%02d tile=%06x p1=%08x p2=%08x p3=" OTTD_PRINTFHEX64PAD " cmd=%d", s->root_company, tile, p1, p2, p3, cmd); @@ -160,12 +160,12 @@ ScriptObject::ActiveInstance::~ActiveInstance() return GetStorage()->last_cost; } -/* static */ void ScriptObject::SetLastCommandResultData(uint32 last_result) +/* static */ void ScriptObject::SetLastCommandResultData(uint32_t last_result) { GetStorage()->last_result = last_result; } -/* static */ uint32 ScriptObject::GetLastCommandResultData() +/* static */ uint32_t ScriptObject::GetLastCommandResultData() { return GetStorage()->last_result; } @@ -327,7 +327,7 @@ ScriptObject::ActiveInstance::~ActiveInstance() return GetStorage()->callback_value[index]; } -/* static */ bool ScriptObject::DoCommandEx(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint cmd, const char *text, const CommandAuxiliaryBase *aux_data, Script_SuspendCallbackProc *callback) +/* static */ bool ScriptObject::DoCommandEx(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint cmd, const char *text, const CommandAuxiliaryBase *aux_data, Script_SuspendCallbackProc *callback) { if (!ScriptObject::CanSuspend()) { throw Script_FatalError("You are not allowed to execute any DoCommand (even indirect) in your constructor, Save(), Load(), and any valuator."); diff --git a/src/script/api/script_object.hpp b/src/script/api/script_object.hpp index cee1a17ec7..1430f613f4 100644 --- a/src/script/api/script_object.hpp +++ b/src/script/api/script_object.hpp @@ -93,19 +93,19 @@ protected: /** * Executes a raw DoCommand for the script. */ - static bool DoCommandEx(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint cmd, const char *text = nullptr, const CommandAuxiliaryBase *aux_data = nullptr, Script_SuspendCallbackProc *callback = nullptr); + static bool DoCommandEx(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint cmd, const char *text = nullptr, const CommandAuxiliaryBase *aux_data = nullptr, Script_SuspendCallbackProc *callback = nullptr); - static bool DoCommandEx(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint cmd, const std::string &text, const CommandAuxiliaryBase *aux_data = nullptr, Script_SuspendCallbackProc *callback = nullptr) + static bool DoCommandEx(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint cmd, const std::string &text, const CommandAuxiliaryBase *aux_data = nullptr, Script_SuspendCallbackProc *callback = nullptr) { return ScriptObject::DoCommandEx(tile, p1, p2, p3, cmd, text.c_str(), aux_data, callback); } - static bool DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint cmd, const char *text = nullptr, Script_SuspendCallbackProc *callback = nullptr) + static bool DoCommand(TileIndex tile, uint32_t p1, uint32_t p2, uint cmd, const char *text = nullptr, Script_SuspendCallbackProc *callback = nullptr) { return ScriptObject::DoCommandEx(tile, p1, p2, 0, cmd, text, nullptr, callback); } - static bool DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint cmd, const std::string &text, Script_SuspendCallbackProc *callback = nullptr) + static bool DoCommand(TileIndex tile, uint32_t p1, uint32_t p2, uint cmd, const std::string &text, Script_SuspendCallbackProc *callback = nullptr) { return ScriptObject::DoCommandEx(tile, p1, p2, 0, cmd, text.c_str(), nullptr, callback); } @@ -113,12 +113,12 @@ protected: /** * Store the latest command executed by the script. */ - static void SetLastCommand(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint cmd); + static void SetLastCommand(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint cmd); /** * Check if it's the latest command executed by the script. */ - static bool CheckLastCommand(TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint cmd); + static bool CheckLastCommand(TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint cmd); /** * Sets the DoCommand costs counter to a value. @@ -289,12 +289,12 @@ protected: /** * Set the result data of the last command. */ - static void SetLastCommandResultData(uint32 last_result); + static void SetLastCommandResultData(uint32_t last_result); /** * Get the result data of the last command. */ - static uint32 GetLastCommandResultData(); + static uint32_t GetLastCommandResultData(); /** * Set a variable that can be used by callback functions to pass information. diff --git a/src/script/api/script_order.cpp b/src/script/api/script_order.cpp index 2de64137fe..008c2d2704 100644 --- a/src/script/api/script_order.cpp +++ b/src/script/api/script_order.cpp @@ -103,7 +103,7 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr return res; } -/* static */ bool ScriptOrder::ScriptOrderModifyOrder(VehicleID vehicle_id, VehicleOrderID order_position, uint32 p2, Script_SuspendCallbackProc *callback) +/* static */ bool ScriptOrder::ScriptOrderModifyOrder(VehicleID vehicle_id, VehicleOrderID order_position, uint32_t p2, Script_SuspendCallbackProc *callback) { return ScriptObject::DoCommandEx(0, vehicle_id, p2, order_position, CMD_MODIFY_ORDER, nullptr, 0, callback); } @@ -449,8 +449,8 @@ static int ScriptOrderPositionToRealOrderPosition(VehicleID vehicle_id, ScriptOr EnforcePrecondition(false, IsGotoStationOrder(vehicle_id, order_position) || (IsGotoDepotOrder(vehicle_id, order_position) && refit_cargo != CT_AUTO_REFIT)); EnforcePrecondition(false, ScriptCargo::IsValidCargo(refit_cargo) || refit_cargo == CT_AUTO_REFIT || refit_cargo == CT_NO_REFIT); - uint32 p1 = vehicle_id; - uint32 p2 = refit_cargo | ScriptOrderPositionToRealOrderPosition(vehicle_id, ScriptOrder::ResolveOrderPosition(vehicle_id, order_position)) << 16; + uint32_t p1 = vehicle_id; + uint32_t p2 = refit_cargo | ScriptOrderPositionToRealOrderPosition(vehicle_id, ScriptOrder::ResolveOrderPosition(vehicle_id, order_position)) << 16; return ScriptObject::DoCommand(0, p1, p2, CMD_ORDER_REFIT); } diff --git a/src/script/api/script_order.hpp b/src/script/api/script_order.hpp index dc1288b9dc..bc0100d970 100644 --- a/src/script/api/script_order.hpp +++ b/src/script/api/script_order.hpp @@ -604,7 +604,7 @@ public: static SQInteger GetOrderDistance(ScriptVehicle::VehicleType vehicle_type, TileIndex origin_tile, TileIndex dest_tile); protected: - static bool ScriptOrderModifyOrder(VehicleID vehicle_id, VehicleOrderID order_position, uint32 p2, Script_SuspendCallbackProc *callback = nullptr); + static bool ScriptOrderModifyOrder(VehicleID vehicle_id, VehicleOrderID order_position, uint32_t p2, Script_SuspendCallbackProc *callback = nullptr); }; DECLARE_ENUM_AS_BIT_SET(ScriptOrder::ScriptOrderFlags) diff --git a/src/script/api/script_rail.cpp b/src/script/api/script_rail.cpp index 9ac1be9b77..1d057b0261 100644 --- a/src/script/api/script_rail.cpp +++ b/src/script/api/script_rail.cpp @@ -155,7 +155,7 @@ EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType())); EnforcePrecondition(false, station_id == ScriptStation::STATION_NEW || station_id == ScriptStation::STATION_JOIN_ADJACENT || ScriptStation::IsValidStation(station_id)); - uint32 p1 = GetCurrentRailType() | (platform_length << 16) | (num_platforms << 8); + uint32_t p1 = GetCurrentRailType() | (platform_length << 16) | (num_platforms << 8); if (direction == RAILTRACK_NW_SE) p1 |= (1 << 6); if (station_id != ScriptStation::STATION_JOIN_ADJACENT) p1 |= (1 << 24); return ScriptObject::DoCommand(tile, p1, (ScriptStation::IsValidStation(station_id) ? station_id : INVALID_STATION) << 16, CMD_BUILD_RAIL_STATION); @@ -174,12 +174,12 @@ EnforcePrecondition(false, source_industry == ScriptIndustryType::INDUSTRYTYPE_UNKNOWN || source_industry == ScriptIndustryType::INDUSTRYTYPE_TOWN || ScriptIndustryType::IsValidIndustryType(source_industry)); EnforcePrecondition(false, goal_industry == ScriptIndustryType::INDUSTRYTYPE_UNKNOWN || goal_industry == ScriptIndustryType::INDUSTRYTYPE_TOWN || ScriptIndustryType::IsValidIndustryType(goal_industry)); - uint32 p1 = GetCurrentRailType() | (platform_length << 16) | (num_platforms << 8); + uint32_t p1 = GetCurrentRailType() | (platform_length << 16) | (num_platforms << 8); if (direction == RAILTRACK_NW_SE) p1 |= 1 << 6; if (station_id != ScriptStation::STATION_JOIN_ADJACENT) p1 |= (1 << 24); const GRFFile *file; - uint16 res = GetAiPurchaseCallbackResult( + uint16_t res = GetAiPurchaseCallbackResult( GSF_STATIONS, cargo_id, 0, @@ -191,7 +191,7 @@ std::min(15u, num_platforms) << 4 | std::min(15u, platform_length), &file ); - uint32 p2 = (ScriptStation::IsValidStation(station_id) ? station_id : INVALID_STATION) << 16; + uint32_t p2 = (ScriptStation::IsValidStation(station_id) ? station_id : INVALID_STATION) << 16; if (res != CALLBACK_FAILED) { int index = 0; const StationSpec *spec = StationClass::GetByGrf(file->grfid, res, &index); @@ -293,10 +293,10 @@ * Prepare the second parameter for CmdBuildRailroadTrack and CmdRemoveRailroadTrack. The direction * depends on all three tiles. Sometimes the third tile needs to be adjusted. */ -static uint32 SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to) +static uint32_t SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to) { int diag_offset = abs(abs((int)::TileX(*to) - (int)::TileX(tile)) - abs((int)::TileY(*to) - (int)::TileY(tile))); - uint32 p2 = 0; + uint32_t p2 = 0; if (::TileY(from) == ::TileY(*to)) { p2 |= (TRACK_X << 6); *to -= Clamp((int)::TileX(*to) - (int)::TileX(tile), -1, 1); @@ -365,7 +365,7 @@ static uint32 SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to) (::TileX(from) == ::TileX(tile) && ::TileX(tile) == ::TileX(to)) || (::TileY(from) == ::TileY(tile) && ::TileY(tile) == ::TileY(to))); - uint32 p2 = SimulateDrag(from, tile, &to) | 1 << 10 | 1 << 11 | ScriptRail::GetCurrentRailType();; + uint32_t p2 = SimulateDrag(from, tile, &to) | 1 << 10 | 1 << 11 | ScriptRail::GetCurrentRailType();; return ScriptObject::DoCommand(tile, to, p2, CMD_BUILD_RAILROAD_TRACK); } @@ -382,7 +382,7 @@ static uint32 SimulateDrag(TileIndex from, TileIndex tile, TileIndex *to) (::TileX(from) == ::TileX(tile) && ::TileX(tile) == ::TileX(to)) || (::TileY(from) == ::TileY(tile) && ::TileY(tile) == ::TileY(to))); - uint32 p2 = SimulateDrag(from, tile, &to); + uint32_t p2 = SimulateDrag(from, tile, &to); return ScriptObject::DoCommand(tile, to, p2, CMD_REMOVE_RAILROAD_TRACK); } diff --git a/src/script/api/script_road.cpp b/src/script/api/script_road.cpp index 1417cfb35f..fe6b8526a2 100644 --- a/src/script/api/script_road.cpp +++ b/src/script/api/script_road.cpp @@ -189,7 +189,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); } @@ -204,7 +204,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. */ @@ -231,7 +231,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; @@ -247,7 +247,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; @@ -268,7 +268,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)) { @@ -326,7 +326,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); } @@ -404,7 +404,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)) { @@ -421,8 +421,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; @@ -496,7 +496,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 0c45b27606..67988e6f0a 100644 --- a/src/script/api/script_road.hpp +++ b/src/script/api/script_road.hpp @@ -62,7 +62,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 d155b5ea10..449946ad4a 100644 --- a/src/script/api/script_station.cpp +++ b/src/script/api/script_station.cpp @@ -64,7 +64,7 @@ template const StationCargoList &cargo_list = ge.data->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()), @@ -164,7 +164,7 @@ template if (station_type == STATION_AIRPORT) return -1; if (!HasExactlyOneBit(station_type)) return -1; - const int32 inc = _settings_game.station.catchment_increase; + const int32_t inc = _settings_game.station.catchment_increase; if (!_settings_game.station.modified_catchment) return CA_UNMODIFIED + inc; diff --git a/src/script/api/script_story_page.cpp b/src/script/api/script_story_page.cpp index 6616777345..292932caca 100644 --- a/src/script/api/script_story_page.cpp +++ b/src/script/api/script_story_page.cpp @@ -44,7 +44,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::DoCommand(0, @@ -76,7 +76,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: @@ -126,7 +126,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_town.cpp b/src/script/api/script_town.cpp index ab4552d4bf..d314753e9d 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; @@ -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) @@ -304,7 +304,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)) { ScriptController::DecreaseOps(50000); ScriptObject::SetLastError(ScriptError::ERR_NAME_IS_NOT_UNIQUE); @@ -360,7 +360,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::DoCommand(0, town_id | (company_id << 16), new_rating, CMD_TOWN_RATING); diff --git a/src/script/api/script_town.hpp b/src/script/api/script_town.hpp index 7f91f317ea..82967c1f76 100644 --- a/src/script/api/script_town.hpp +++ b/src/script/api/script_town.hpp @@ -236,7 +236,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(). @@ -393,7 +393,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 0d652a2d2d..86e13b7cb8 100644 --- a/src/script/api/script_types.hpp +++ b/src/script/api/script_types.hpp @@ -85,24 +85,24 @@ #include /* Define all types here, so we don't have to include the whole _type.h maze */ -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 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 uint32 TileIndex; ///< The ID of a tile (just named differently). -typedef uint16 TownID; ///< The ID of a town. -typedef uint32 VehicleID; ///< The ID of a vehicle. +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_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_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 uint32_t TileIndex; ///< The ID of a tile (just named differently). +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 a7c501874d..f780274460 100644 --- a/src/script/api/script_vehicle.cpp +++ b/src/script/api/script_vehicle.cpp @@ -416,7 +416,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; } @@ -429,7 +429,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 84cc33e3f8..b3e14371e9 100644 --- a/src/script/api/script_window.hpp.in +++ b/src/script/api/script_window.hpp.in @@ -83,7 +83,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); @@ -92,7 +92,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. */ @@ -102,9 +102,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 14ebb44f64..38e7b4884b 100644 --- a/src/script/script_gui.cpp +++ b/src/script/script_gui.cpp @@ -535,7 +535,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); } @@ -1248,15 +1248,15 @@ static Hotkey scriptdebug_hotkeys[] = { Hotkey('7', "company_7", WID_SCRD_COMPANY_BUTTON_START + 6), Hotkey('8', "company_8", WID_SCRD_COMPANY_BUTTON_START + 7), Hotkey('9', "company_9", WID_SCRD_COMPANY_BUTTON_START + 8), - Hotkey((uint16)0, "company_10", WID_SCRD_COMPANY_BUTTON_START + 9), - Hotkey((uint16)0, "company_11", WID_SCRD_COMPANY_BUTTON_START + 10), - Hotkey((uint16)0, "company_12", WID_SCRD_COMPANY_BUTTON_START + 11), - Hotkey((uint16)0, "company_13", WID_SCRD_COMPANY_BUTTON_START + 12), - Hotkey((uint16)0, "company_14", WID_SCRD_COMPANY_BUTTON_START + 13), - Hotkey((uint16)0, "company_15", WID_SCRD_COMPANY_BUTTON_START + 14), + Hotkey((uint16_t)0, "company_10", WID_SCRD_COMPANY_BUTTON_START + 9), + Hotkey((uint16_t)0, "company_11", WID_SCRD_COMPANY_BUTTON_START + 10), + Hotkey((uint16_t)0, "company_12", WID_SCRD_COMPANY_BUTTON_START + 11), + Hotkey((uint16_t)0, "company_13", WID_SCRD_COMPANY_BUTTON_START + 12), + Hotkey((uint16_t)0, "company_14", WID_SCRD_COMPANY_BUTTON_START + 13), + Hotkey((uint16_t)0, "company_15", WID_SCRD_COMPANY_BUTTON_START + 14), Hotkey('S', "settings", WID_SCRD_SETTINGS), Hotkey('0', "game_script", WID_SCRD_SCRIPT_GAME), - Hotkey((uint16)0, "reload", WID_SCRD_RELOAD_TOGGLE), + Hotkey((uint16_t)0, "reload", WID_SCRD_RELOAD_TOGGLE), Hotkey('B', "break_toggle", WID_SCRD_BREAK_STR_ON_OFF_BTN), Hotkey('F', "break_string", WID_SCRD_BREAK_STR_EDIT_BOX), Hotkey('C', "match_case", WID_SCRD_MATCH_CASE_BTN), diff --git a/src/script/script_instance.cpp b/src/script/script_instance.cpp index 39c28f0716..5f4d206b48 100644 --- a/src/script/script_instance.cpp +++ b/src/script/script_instance.cpp @@ -366,7 +366,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'). @@ -394,7 +394,7 @@ ScriptLogTypes::LogData &ScriptInstance::GetLogData() SlWriteByte(SQSL_INT); SQInteger res; sq_getinteger(vm, index, &res); - int64 value = (int64)res; + int64_t value = (int64_t)res; SlArray(&value, 1, SLE_INT64); return true; } @@ -564,7 +564,7 @@ bool ScriptInstance::IsPaused() byte type = SlReadByte(); switch (type) { case SQSL_INT: { - int64 value; + int64_t value; SlArray(&value, 1, (IsSavegameVersionBefore(SLV_SCRIPT_INT64) && SlXvIsFeatureMissing(XSLFI_SCRIPT_INT64)) ? SLE_FILE_I32 | SLE_VAR_I64 : SLE_INT64); if (data != nullptr) data->push_back((SQInteger)value); return true; @@ -758,16 +758,16 @@ void ScriptInstance::LimitOpsTillSuspend(SQInteger suspend) } } -uint32 ScriptInstance::GetMaxOpsTillSuspend() const +uint32_t ScriptInstance::GetMaxOpsTillSuspend() const { if (this->script_type == ScriptType::GS && (_pause_mode & PM_PAUSED_GAME_SCRIPT) != PM_UNPAUSED) { /* Boost opcodes till suspend when paused due to game script */ - return std::min(250000, _settings_game.script.script_max_opcode_till_suspend * 10); + return std::min(250000, _settings_game.script.script_max_opcode_till_suspend * 10); } return _settings_game.script.script_max_opcode_till_suspend; } -bool ScriptInstance::DoCommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +bool ScriptInstance::DoCommandCallback(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { ScriptObject::ActiveInstance active(this); diff --git a/src/script/script_instance.hpp b/src/script/script_instance.hpp index bd5c685838..4b34e66cc8 100644 --- a/src/script/script_instance.hpp +++ b/src/script/script_instance.hpp @@ -217,7 +217,7 @@ public: void LimitOpsTillSuspend(SQInteger suspend); - uint32 GetMaxOpsTillSuspend() const; + uint32_t GetMaxOpsTillSuspend() const; /** * DoCommand callback function for all commands executed by scripts. @@ -229,7 +229,7 @@ public: * @param cmd cmd as given to DoCommandPInternal. * @return true if we handled result. */ - bool DoCommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd); + bool DoCommandCallback(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd); /** * Insert an event for this script. diff --git a/src/script/script_scanner.cpp b/src/script/script_scanner.cpp index ecb27d88a0..8ded24f284 100644 --- a/src/script/script_scanner.cpp +++ b/src/script/script_scanner.cpp @@ -168,7 +168,7 @@ struct ScriptFileChecksumCreator : FileScanner { bool AddFile(const std::string &filename, size_t, const std::string &) override { Md5 checksum; - uint8 buffer[1024]; + uint8_t buffer[1024]; size_t len, size; /* Open the file ... */ @@ -203,7 +203,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/script_storage.hpp b/src/script/script_storage.hpp index 5cd14980ad..c0802e4d22 100644 --- a/src/script/script_storage.hpp +++ b/src/script/script_storage.hpp @@ -39,27 +39,27 @@ typedef bool (ScriptAsyncModeProc)(); class ScriptStorage { friend class ScriptObject; private: - ScriptModeProc *mode; ///< The current build mode we are int. - class ScriptObject *mode_instance; ///< The instance belonging to the current build mode. + ScriptModeProc *mode; ///< The current build mode we are int. + class ScriptObject *mode_instance; ///< The instance belonging to the current build mode. ScriptAsyncModeProc *async_mode; ///< The current command async mode we are in. class ScriptObject *async_mode_instance; ///< The instance belonging to the current command async mode. - CompanyID root_company; ///< The root company, the company that the script really belongs to. - CompanyID company; ///< The current company. + CompanyID root_company; ///< The root company, the company that the script really belongs to. + CompanyID company; ///< The current company. uint delay; ///< The ticks of delay each DoCommand has. bool allow_do_command; ///< Is the usage of DoCommands restricted? CommandCost costs; ///< The costs the script is tracking. Money last_cost; ///< The last cost of the command. - uint32 last_result; ///< The last result data of the command. + uint32_t last_result; ///< The last result data of the command. uint last_error; ///< The last error of the command. bool last_command_res; ///< The last result of the command. TileIndex last_tile; ///< The last tile passed to a command. - uint32 last_p1; ///< The last p1 passed to a command. - uint32 last_p2; ///< The last p2 passed to a command. - uint64 last_p3; ///< The last p3 passed to a command. - uint32 last_cmd; ///< The last cmd passed to a command. + uint32_t last_p1; ///< The last p1 passed to a command. + uint32_t last_p2; ///< The last p2 passed to a command. + uint64_t last_p3; ///< The last p3 passed to a command. + uint32_t last_cmd; ///< The last cmd passed to a command. VehicleID new_vehicle_id; ///< The ID of the new Vehicle. SignID new_sign_id; ///< The ID of the new Sign. diff --git a/src/script/squirrel.cpp b/src/script/squirrel.cpp index 144b2c8e57..a9970b7a55 100644 --- a/src/script/squirrel.cpp +++ b/src/script/squirrel.cpp @@ -598,14 +598,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]; @@ -618,25 +618,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 2373ed98ca..6a6549e85b 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. */ }; @@ -62,14 +62,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 05f3824fd9..da8032b189 100644 --- a/src/script/squirrel_helper_type.hpp +++ b/src/script/squirrel_helper_type.hpp @@ -13,7 +13,7 @@ #include /** 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 4d6d9648c2..025e23e6b1 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -185,7 +185,7 @@ typedef void SettingDescProc(IniFile &ini, const SettingTable &desc, const char typedef void SettingDescProcList(IniFile &ini, const char *grpname, StringList &list); static bool IsSignedVarMemType(VarType vt); -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); /** @@ -214,7 +214,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. @@ -226,7 +226,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 | @@ -287,7 +287,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; } @@ -371,12 +371,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(); @@ -402,12 +402,12 @@ void ListSettingDesc::FormatValue(char *buf, const char *last, const void *objec for (i = 0; i != this->save.length; i++) { 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 (IsSignedVarMemType(this->save.conv)) { @@ -426,12 +426,12 @@ char *OneOfManySettingDesc::FormatSingleValue(char *buf, const char *last, uint return strecpy(buf, this->many[id].c_str(), last); } -void OneOfManySettingDesc::FormatIntValue(char *buf, const char *last, uint32 value) const +void OneOfManySettingDesc::FormatIntValue(char *buf, const char *last, uint32_t value) const { this->FormatSingleValue(buf, last, value); } -void ManyOfManySettingDesc::FormatIntValue(char *buf, const char *last, uint32 value) const +void ManyOfManySettingDesc::FormatIntValue(char *buf, const char *last, uint32_t value) const { uint bitmask = (uint)value; if (bitmask == 0) { @@ -512,7 +512,7 @@ size_t BoolSettingDesc::ParseValue(const char *str) const return this->def; } -static bool ValidateEnumSetting(const IntSettingDesc *sdb, int32 &val) +static bool ValidateEnumSetting(const IntSettingDesc *sdb, int32_t &val) { if (sdb->flags & SF_ENUM_PRE_CB_VALIDATE && sdb->pre_check != nullptr && !sdb->pre_check(val)) return false; for (const SettingDescEnumEntry *enumlist = sdb->enumlist; enumlist != nullptr && enumlist->str != STR_NULL; enumlist++) { @@ -529,7 +529,7 @@ static bool ValidateEnumSetting(const IntSettingDesc *sdb, int32 &val) * @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); @@ -544,9 +544,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 @@ -562,11 +562,11 @@ void IntSettingDesc::MakeValueValid(int32 &val) const /* Override the minimum value. No value below this->min, except special value 0 */ if (!(this->flags & SF_GUI_0_IS_SPECIAL) || val != 0) { if (this->flags & SF_ENUM) { - if (!ValidateEnumSetting(this, val)) val = (int32)(size_t)this->def; + if (!ValidateEnumSetting(this, val)) val = (int32_t)(size_t)this->def; } else 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; } @@ -575,23 +575,23 @@ 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_ENUM) { if (!ValidateEnumSetting(this, val)) { - uval = (uint32)(size_t)this->def; + uval = (uint32_t)(size_t)this->def; } else { - uval = (uint32)val; + uval = (uint32_t)val; } } else 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: @@ -605,10 +605,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); } /** @@ -616,10 +616,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); } /** @@ -733,7 +733,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 @@ -810,24 +810,24 @@ static void IniSaveSettings(IniFile &ini, const SettingTable &settings_table, co void IntSettingDesc::FormatValue(char *buf, const char *last, const void *object) const { - uint32 i = (uint32)this->Read(object); + uint32_t i = (uint32_t)this->Read(object); this->FormatIntValue(buf, last, i); } -void IntSettingDesc::FormatIntValue(char *buf, const char *last, uint32 value) const +void IntSettingDesc::FormatIntValue(char *buf, const char *last, uint32_t value) const { seprintf(buf, last, IsSignedVarMemType(this->save.conv) ? "%d" : "%u", value); } -void BoolSettingDesc::FormatIntValue(char *buf, const char *last, uint32 value) const +void BoolSettingDesc::FormatIntValue(char *buf, const char *last, uint32_t value) const { strecpy(buf, (value != 0) ? "true" : "false", last); } 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; } @@ -997,13 +997,13 @@ const StringSettingDesc *SettingDesc::AsStringSetting() const /* 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); @@ -1016,7 +1016,7 @@ static void v_PositionStatusbar(int32 new_value) * Redraw the smallmap after a colour scheme change. * @param p1 Callback parameter. */ -static void RedrawSmallmap(int32 new_value) +static void RedrawSmallmap(int32_t new_value) { BuildLandLegend(); BuildOwnerLegend(); @@ -1026,7 +1026,7 @@ static void RedrawSmallmap(int32 new_value) MarkAllViewportMapLandscapesDirty(); } -static void StationSpreadChanged(int32 new_value) +static void StationSpreadChanged(int32_t new_value) { InvalidateWindowData(WC_SELECT_STATION, 0); InvalidateWindowData(WC_BUILD_STATION, 0); @@ -1034,7 +1034,7 @@ static void StationSpreadChanged(int32 new_value) InvalidateWindowData(WC_TRUCK_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. */ @@ -1057,7 +1057,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; @@ -1096,7 +1096,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)) { @@ -1106,11 +1106,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()) { @@ -1123,7 +1123,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()) { @@ -1145,7 +1145,7 @@ static void TrainAccelerationModelChanged(int32 new_value) SetWindowClassesDirty(WC_CREATE_TEMPLATE); } -static bool CheckTrainBrakingModelChange(int32 &new_value) +static bool CheckTrainBrakingModelChange(int32_t &new_value) { if (new_value == TBM_REALISTIC && (_game_mode == GM_NORMAL || _game_mode == GM_EDITOR)) { for (TileIndex t = 0; t < MapSize(); t++) { @@ -1173,7 +1173,7 @@ static bool CheckTrainBrakingModelChange(int32 &new_value) return true; } -static void TrainBrakingModelChanged(int32 new_value) +static void TrainBrakingModelChanged(int32_t new_value) { for (Train *t : Train::Iterate()) { if (!(t->vehstatus & VS_CRASHED)) { @@ -1244,7 +1244,7 @@ static void TrainBrakingModelChanged(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()) { @@ -1258,7 +1258,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()) { @@ -1286,19 +1286,19 @@ 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 ProgrammableSignalsShownChanged(int32 new_value) +static void ProgrammableSignalsShownChanged(int32_t new_value) { InvalidateWindowData(WC_BUILD_SIGNAL, 0); } -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); @@ -1307,19 +1307,19 @@ static void TownFoundingChanged(int32 new_value) } } -static void InvalidateVehTimetableWindow(int32 new_value) +static void InvalidateVehTimetableWindow(int32_t new_value) { InvalidateWindowClassesData(WC_VEHICLE_TIMETABLE, VIWD_MODIFY_ORDERS); InvalidateWindowClassesData(WC_SCHDISPATCH_SLOTS, VIWD_MODIFY_ORDERS); } -static void ChangeTimetableInTicksMode(int32 new_value) +static void ChangeTimetableInTicksMode(int32_t new_value) { SetWindowClassesDirty(WC_VEHICLE_ORDERS); InvalidateVehTimetableWindow(new_value); } -static void UpdateTimeSettings(int32 new_value) +static void UpdateTimeSettings(int32_t new_value) { SetupTimeSettings(); InvalidateVehTimetableWindow(new_value); @@ -1330,13 +1330,13 @@ static void UpdateTimeSettings(int32 new_value) MarkWholeScreenDirty(); } -static void ChangeTimeOverrideMode(int32 new_value) +static void ChangeTimeOverrideMode(int32_t new_value) { InvalidateWindowClassesData(WC_GAME_OPTIONS); UpdateTimeSettings(new_value); } -static void ZoomMinMaxChanged(int32 new_value) +static void ZoomMinMaxChanged(int32_t new_value) { extern void ConstrainAllViewportsZoom(); extern void UpdateFontHeightCache(); @@ -1348,14 +1348,14 @@ 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 */ MarkWholeScreenDirty(); } -static void DeveloperModeChanged(int32 new_value) +static void DeveloperModeChanged(int32_t new_value) { DebugReconsiderSendRemoteMessages(); } @@ -1366,21 +1366,21 @@ static void DeveloperModeChanged(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(); MarkWholeScreenDirty(); } -static void ScriptMaxOpsChange(int32 new_value) +static void ScriptMaxOpsChange(int32_t new_value) { if (_networking && !_network_server) return; @@ -1396,7 +1396,7 @@ static void ScriptMaxOpsChange(int32 new_value) } } -static bool CheckScriptMaxMemoryChange(int32 &new_value) +static bool CheckScriptMaxMemoryChange(int32_t &new_value) { if (_networking && !_network_server) return true; @@ -1416,7 +1416,7 @@ static bool CheckScriptMaxMemoryChange(int32 &new_value) return true; } -static void ScriptMaxMemoryChange(int32 new_value) +static void ScriptMaxMemoryChange(int32_t new_value) { if (_networking && !_network_server) return; @@ -1439,13 +1439,13 @@ static void ScriptMaxMemoryChange(int32 new_value) * @param p1 Unused. * @return Always true. */ -static void InvalidateCompanyWindow(int32 new_value) +static void InvalidateCompanyWindow(int32_t new_value) { InvalidateWindowClassesData(WC_COMPANY); InvalidateWindowClassesData(WC_GAME_OPTIONS); } -static void EnableSingleVehSharedOrderGuiChanged(int32 new_value) +static void EnableSingleVehSharedOrderGuiChanged(int32_t new_value) { for (VehicleType type = VEH_BEGIN; type < VEH_COMPANY_END; type++) { InvalidateWindowClassesData(GetWindowClassForVehicleType(type), 0); @@ -1454,13 +1454,13 @@ static void EnableSingleVehSharedOrderGuiChanged(int32 new_value) InvalidateWindowClassesData(WC_VEHICLE_ORDERS, 0); } -static void CheckYapfRailSignalPenalties(int32 new_value) +static void CheckYapfRailSignalPenalties(int32_t new_value) { extern void YapfCheckRailSignalPenalties(); YapfCheckRailSignalPenalties(); } -static void ViewportMapShowTunnelModeChanged(int32 new_value) +static void ViewportMapShowTunnelModeChanged(int32_t new_value) { extern void ViewportMapBuildTunnelCache(); ViewportMapBuildTunnelCache(); @@ -1469,13 +1469,13 @@ static void ViewportMapShowTunnelModeChanged(int32 new_value) MarkAllViewportMapLandscapesDirty(); } -static void ViewportMapLandscapeModeChanged(int32 new_value) +static void ViewportMapLandscapeModeChanged(int32_t new_value) { extern void MarkAllViewportMapLandscapesDirty(); MarkAllViewportMapLandscapesDirty(); } -static void MarkAllViewportsDirty(int32 new_value) +static void MarkAllViewportsDirty(int32_t new_value) { extern void MarkAllViewportMapLandscapesDirty(); MarkAllViewportMapLandscapesDirty(); @@ -1484,35 +1484,35 @@ static void MarkAllViewportsDirty(int32 new_value) MarkWholeNonMapViewportsDirty(); } -static void UpdateLinkgraphColours(int32 new_value) +static void UpdateLinkgraphColours(int32_t new_value) { BuildLinkStatsLegend(); MarkWholeScreenDirty(); } -static void ClimateThresholdModeChanged(int32 new_value) +static void ClimateThresholdModeChanged(int32_t new_value) { InvalidateWindowClassesData(WC_GENERATE_LANDSCAPE); InvalidateWindowClassesData(WC_GAME_OPTIONS); } -static void VelocityUnitsChanged(int32 new_value) { +static void VelocityUnitsChanged(int32_t new_value) { InvalidateWindowClassesData(WC_PAYMENT_RATES); InvalidateWindowClassesData(WC_TRACE_RESTRICT); MarkWholeScreenDirty(); } -static void ChangeTrackTypeSortMode(int32 new_value) { +static void ChangeTrackTypeSortMode(int32_t new_value) { extern void SortRailTypes(); SortRailTypes(); MarkWholeScreenDirty(); } -static void PublicRoadsSettingChange(int32 new_value) { +static void PublicRoadsSettingChange(int32_t new_value) { InvalidateWindowClassesData(WC_SCEN_LAND_GEN); } -static void TrainSpeedAdaptationChanged(int32 new_value) { +static void TrainSpeedAdaptationChanged(int32_t new_value) { extern void ClearAllSignalSpeedRestrictions(); ClearAllSignalSpeedRestrictions(); for (Train *t : Train::Iterate()) { @@ -1520,7 +1520,7 @@ static void TrainSpeedAdaptationChanged(int32 new_value) { } } -static void AutosaveModeChanged(int32 new_value) { +static void AutosaveModeChanged(int32_t new_value) { extern void ChangeAutosaveFrequency(bool reset); ChangeAutosaveFrequency(false); InvalidateWindowClassesData(WC_GAME_OPTIONS); @@ -1536,13 +1536,13 @@ static void ValidateSettings() } } -static bool TownCouncilToleranceAdjust(int32 &new_value) +static bool TownCouncilToleranceAdjust(int32_t &new_value) { if (new_value == 255) new_value = TOWN_COUNCIL_PERMISSIVE; return true; } -static void DifficultyNoiseChange(int32 new_value) +static void DifficultyNoiseChange(int32_t new_value) { if (_game_mode == GM_NORMAL) { UpdateAirportsNoise(); @@ -1552,22 +1552,22 @@ static void DifficultyNoiseChange(int32 new_value) } } -static void DifficultyMoneyCheatMultiplayerChange(int32 new_value) +static void DifficultyMoneyCheatMultiplayerChange(int32_t new_value) { CloseWindowById(WC_CHEATS, 0); } -static void DifficultyRenameTownsMultiplayerChange(int32 new_value) +static void DifficultyRenameTownsMultiplayerChange(int32_t new_value) { SetWindowClassesDirty(WC_TOWN_VIEW); } -static void DifficultyOverrideTownSettingsMultiplayerChange(int32 new_value) +static void DifficultyOverrideTownSettingsMultiplayerChange(int32_t new_value) { SetWindowClassesDirty(WC_TOWN_AUTHORITY); } -static void MaxNoAIsChange(int32 new_value) +static void MaxNoAIsChange(int32_t new_value) { if (GetGameSettings().difficulty.max_no_competitors != 0 && AI::GetInfoList()->size() == 0 && @@ -1583,13 +1583,13 @@ 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) { extern bool RoadVehiclesExistOutsideDepots(); return (_game_mode == GM_MENU || !RoadVehiclesExistOutsideDepots()); } -static void RoadSideChanged(int32 new_value) +static void RoadSideChanged(int32_t new_value) { extern void RecalculateRoadCachedOneWayStates(); RecalculateRoadCachedOneWayStates(); @@ -1609,7 +1609,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) { @@ -1656,7 +1656,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; @@ -1694,7 +1694,7 @@ bool CheckMapEdgesAreWater() return true; } -static bool CheckMapEdgeMode(int32 &new_value) +static bool CheckMapEdgeMode(int32_t &new_value) { if (_game_mode == GM_MENU || !_settings_game.construction.freeform_edges || new_value == 0) return true; @@ -1710,7 +1710,7 @@ static bool CheckMapEdgeMode(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; @@ -1722,7 +1722,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; @@ -1730,7 +1730,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 < MapSize(); 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; @@ -1740,52 +1740,52 @@ static bool CheckMaxHeightLevel(int32 &new_value) return true; } -static void StationCatchmentChanged(int32 new_value) +static void StationCatchmentChanged(int32_t new_value) { Station::RecomputeCatchmentForAll(); for (Station *st : Station::Iterate()) UpdateStationAcceptance(st, true); MarkWholeScreenDirty(); } -static bool CheckSharingRail(int32 &new_value) +static bool CheckSharingRail(int32_t &new_value) { return CheckSharingChangePossible(VEH_TRAIN, new_value); } -static void SharingRailChanged(int32 new_value) +static void SharingRailChanged(int32_t new_value) { UpdateAllBlockSignals(); } -static bool CheckSharingRoad(int32 &new_value) +static bool CheckSharingRoad(int32_t &new_value) { return CheckSharingChangePossible(VEH_ROAD, new_value); } -static bool CheckSharingWater(int32 &new_value) +static bool CheckSharingWater(int32_t &new_value) { return CheckSharingChangePossible(VEH_SHIP, new_value); } -static bool CheckSharingAir(int32 &new_value) +static bool CheckSharingAir(int32_t &new_value) { return CheckSharingChangePossible(VEH_AIRCRAFT, new_value); } -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->cached_path.reset(); } } -static void ImprovedBreakdownsSettingChanged(int32 new_value) +static void ImprovedBreakdownsSettingChanged(int32_t new_value) { if (!_settings_game.vehicle.improved_breakdowns) return; @@ -1810,16 +1810,16 @@ static void ImprovedBreakdownsSettingChanged(int32 new_value) } } -static uint8 _pre_change_day_length_factor; +static uint8_t _pre_change_day_length_factor; -static bool DayLengthPreChange(int32 &new_value) +static bool DayLengthPreChange(int32_t &new_value) { _pre_change_day_length_factor = _settings_game.economy.day_length_factor; return true; } -static void DayLengthChanged(int32 new_value) +static void DayLengthChanged(int32_t new_value) { extern void RebaseScaledDateTicksBase(); RebaseScaledDateTicksBase(); @@ -1829,13 +1829,13 @@ static void DayLengthChanged(int32 new_value) MarkWholeScreenDirty(); } -static void TownZoneModeChanged(int32 new_value) +static void TownZoneModeChanged(int32_t new_value) { InvalidateWindowClassesData(WC_GAME_OPTIONS); UpdateTownRadii(); } -static void TownZoneCustomValueChanged(int32 new_value) +static void TownZoneCustomValueChanged(int32_t new_value) { if (_settings_game.economy.town_zone_calc_mode) UpdateTownRadii(); } @@ -1882,14 +1882,14 @@ static bool IsValidHex256BitKeyString(std::string &newval) static void ParseCompanyPasswordStorageToken(const std::string &value) { - extern uint8 _network_company_password_storage_token[16]; + extern uint8_t _network_company_password_storage_token[16]; if (value.size() != 32) return; DecodeHexText(value.c_str(), _network_company_password_storage_token, 16); } static void ParseCompanyPasswordStorageSecret(const std::string &value) { - extern uint8 _network_company_password_storage_key[32]; + extern uint8_t _network_company_password_storage_key[32]; if (value.size() != 64) return; DecodeHexText(value.c_str(), _network_company_password_storage_key, 32); } @@ -1908,7 +1908,7 @@ static void UpdateClientConfigValues() /* Begin - xref conversion callbacks */ -static int64 LinkGraphDistModeXrefChillPP(int64 val) +static int64_t LinkGraphDistModeXrefChillPP(int64_t val) { return val ^ 2; } @@ -2068,7 +2068,7 @@ static 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); } } @@ -2145,7 +2145,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]); @@ -2210,7 +2210,7 @@ static GRFConfig *GRFLoadConfig(const IniFile &ini, const char *grpname, bool is for (const IniItem &item : group->items) { 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; @@ -2223,7 +2223,7 @@ static GRFConfig *GRFLoadConfig(const IniFile &ini, const char *grpname, bool is 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); @@ -2308,7 +2308,7 @@ static IniFileVersion LoadVersionFromConfig(const 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; IntFromChars(version_number->value->data(), version_number->value->data() + version_number->value->size(), version); return static_cast(version); @@ -2796,9 +2796,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, SaveToConfigFlags ini_save_flags) const +void IntSettingDesc::ChangeValue(const void *object, int32_t newval, SaveToConfigFlags ini_save_flags) 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; @@ -2906,7 +2906,7 @@ SaveToConfigFlags ConfigSaveFlagsUsingGameSettingsFor(const SettingDesc *sd) * @return the cost of this operation or an error * @see _settings */ -CommandCost CmdChangeSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdChangeSetting(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (StrEmpty(text)) return CMD_ERROR; const SettingDesc *sd = GetSettingFromName(text); @@ -2936,7 +2936,7 @@ CommandCost CmdChangeSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uin * @param text the name of the company setting to change * @return the cost of this operation or an error */ -CommandCost CmdChangeCompanySetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdChangeCompanySetting(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (StrEmpty(text)) return CMD_ERROR; const SettingDesc *sd = GetCompanySettingFromName(text); @@ -2953,7 +2953,7 @@ CommandCost CmdChangeCompanySetting(TileIndex tile, DoCommandFlag flags, uint32 return CommandCost(); } -const char *GetCompanySettingNameByIndex(uint32 idx) +const char *GetCompanySettingNameByIndex(uint32_t idx) { if (idx >= _company_settings.size()) return nullptr; @@ -2967,7 +2967,7 @@ const char *GetCompanySettingNameByIndex(uint32 idx) * @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) { @@ -3031,8 +3031,8 @@ void SyncCompanySettings() for (auto &sd : _company_settings) { if (!sd->IsIntSetting()) continue; if (!SlIsObjectCurrentlyValid(sd->save.version_from, sd->save.version_to, sd->save.ext_feature_test)) continue; - 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) NetworkSendCommand(0, 0, new_value, 0, CMD_CHANGE_COMPANY_SETTING, nullptr, sd->name, _local_company, nullptr); } } @@ -3106,7 +3106,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) { @@ -3147,8 +3147,8 @@ void IConsoleGetSetting(const char *name, bool force_newgame) const IntSettingDesc *int_setting = sd->AsIntSetting(); bool show_min_max = true; - int64 min_value = int_setting->min; - int64 max_value = int_setting->max; + int64_t min_value = int_setting->min; + int64_t max_value = int_setting->max; if (sd->flags & SF_ENUM) { min_value = INT64_MAX; max_value = INT64_MIN; @@ -3158,7 +3158,7 @@ void IConsoleGetSetting(const char *name, bool force_newgame) if (enumlist->val > max_value) max_value = enumlist->val; count++; } - if (max_value - min_value != (int64)(count - 1)) { + if (max_value - min_value != (int64_t)(count - 1)) { /* Discontinuous range */ show_min_max = false; } @@ -3286,7 +3286,7 @@ static void LoadSettings(std::initializer_list settings, std::init if (!SlObjectMember(object, sld)) continue; if (item.setting->IsIntSetting()) { const IntSettingDesc *int_setting = item.setting->AsIntSetting(); - int64 val = int_setting->Read(object); + int64_t val = int_setting->Read(object); if (item.compat.xrefconv != nullptr) val = item.compat.xrefconv(val); int_setting->MakeValueValidAndWrite(object, val); } @@ -3304,12 +3304,12 @@ static void LoadSettings(std::initializer_list settings, std::init * * The PATX chunk contents has the following format: * - * uint32 chunk flags (unused) - * uint32 number of settings + * uint32_t chunk flags (unused) + * uint32_t number of settings * For each of N settings: - * uint32 setting flags (unused) + * uint32_t setting flags (unused) * SLE_STR setting name - * uint32 length of setting field + * uint32_t length of setting field * N bytes setting field */ @@ -3337,9 +3337,9 @@ static std::vector MakeSettingsPatxList(std::initializer_li * Internal structure used in LoadSettingsPatx() and LoadSettingsPlyx() */ struct SettingsExtLoad { - uint32 flags; + uint32_t flags; char name[256]; - uint32 setting_length; + uint32_t setting_length; }; static const SaveLoad _settings_ext_load_desc[] = { @@ -3352,9 +3352,9 @@ static const SaveLoad _settings_ext_load_desc[] = { * Internal structure used in SaveSettingsPlyx() */ struct SettingsExtSave { - uint32 flags; + uint32_t flags; const char *name; - uint32 setting_length; + uint32_t setting_length; }; static const SaveLoad _settings_ext_save_desc[] = { @@ -3377,12 +3377,12 @@ static void LoadSettingsPatx(void *object) SettingsExtLoad current_setting; - uint32 flags = SlReadUint32(); + uint32_t flags = SlReadUint32(); // flags are not in use yet, reserve for future expansion if (flags != 0) SlErrorCorruptFmt("PATX chunk: unknown chunk header flags: 0x%X", flags); - uint32 settings_count = SlReadUint32(); - for (uint32 i = 0; i < settings_count; i++) { + uint32_t settings_count = SlReadUint32(); + for (uint32_t i = 0; i < settings_count; i++) { SlObject(¤t_setting, _settings_ext_load_desc); // flags are not in use yet, reserve for future expansion @@ -3426,16 +3426,16 @@ static void LoadSettingsPatx(void *object) * * The PLYX chunk contents has the following format: * - * uint32 chunk flags (unused) - * uint32 number of companies + * uint32_t chunk flags (unused) + * uint32_t number of companies * For each of N companies: - * uint32 company ID - * uint32 company flags (unused) - * uint32 number of settings + * uint32_t company ID + * uint32_t company flags (unused) + * uint32_t number of settings * For each of N settings: - * uint32 setting flags (unused) + * uint32_t setting flags (unused) * SLE_STR setting name - * uint32 length of setting field + * uint32_t length of setting field * N bytes setting field */ @@ -3447,13 +3447,13 @@ void LoadSettingsPlyx(bool skip) { SettingsExtLoad current_setting; - uint32 chunk_flags = SlReadUint32(); + uint32_t chunk_flags = SlReadUint32(); // flags are not in use yet, reserve for future expansion if (chunk_flags != 0) SlErrorCorruptFmt("PLYX chunk: unknown chunk header flags: 0x%X", chunk_flags); - uint32 company_count = SlReadUint32(); - for (uint32 i = 0; i < company_count; i++) { - uint32 company_id = SlReadUint32(); + uint32_t company_count = SlReadUint32(); + for (uint32_t i = 0; i < company_count; i++) { + uint32_t company_id = SlReadUint32(); if (company_id >= MAX_COMPANIES) SlErrorCorruptFmt("PLYX chunk: invalid company ID: %u", company_id); const Company *c = nullptr; @@ -3462,12 +3462,12 @@ void LoadSettingsPlyx(bool skip) if (c == nullptr) SlErrorCorruptFmt("PLYX chunk: non-existant company ID: %u", company_id); } - uint32 company_flags = SlReadUint32(); + uint32_t company_flags = SlReadUint32(); // flags are not in use yet, reserve for future expansion if (company_flags != 0) SlErrorCorruptFmt("PLYX chunk: unknown company flags: 0x%X", company_flags); - uint32 settings_count = SlReadUint32(); - for (uint32 j = 0; j < settings_count; j++) { + uint32_t settings_count = SlReadUint32(); + for (uint32_t j = 0; j < settings_count; j++) { SlObject(¤t_setting, _settings_ext_load_desc); // flags are not in use yet, reserve for future expansion @@ -3515,18 +3515,18 @@ void SaveSettingsPlyx() { SettingsExtSave current_setting; - std::vector company_setting_counts; + std::vector company_setting_counts; size_t length = 8; - uint32 companies_count = 0; + uint32_t companies_count = 0; for (Company *c : Company::Iterate()) { length += 12; companies_count++; - uint32 setting_count = 0; + uint32_t setting_count = 0; for (auto &sd : _company_settings) { if (sd->patx_name == nullptr) continue; - uint32 setting_length = (uint32)SlCalcObjMemberLength(&(c->settings), sd->save); + uint32_t setting_length = (uint32_t)SlCalcObjMemberLength(&(c->settings), sd->save); if (!setting_length) continue; current_setting.name = sd->patx_name; @@ -3557,7 +3557,7 @@ void SaveSettingsPlyx() for (auto &sd : _company_settings) { if (sd->patx_name == nullptr) continue; - uint32 setting_length = (uint32)SlCalcObjMemberLength(&(c->settings), sd->save); + uint32_t setting_length = (uint32_t)SlCalcObjMemberLength(&(c->settings), sd->save); if (!setting_length) continue; current_setting.flags = 0; diff --git a/src/settings_func.h b/src/settings_func.h index 9eb3220f53..295a2f527d 100644 --- a/src/settings_func.h +++ b/src/settings_func.h @@ -16,13 +16,13 @@ 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, bool show_defaults); void LoadFromConfig(bool minimal = false); -enum SaveToConfigFlags : uint32 { +enum SaveToConfigFlags : uint32_t { STCF_NONE = 0, STCF_GENERIC = 1 << 0, STCF_PRIVATE = 1 << 1, @@ -47,6 +47,6 @@ void SyncCompanySettings(); void SetupTimeSettings(); -const char *GetCompanySettingNameByIndex(uint32 idx); +const char *GetCompanySettingNameByIndex(uint32_t idx); #endif /* SETTINGS_FUNC_H */ diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index b2bd224e66..99f50e292c 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -69,7 +69,7 @@ static const StringID _autosave_dropdown[] = { }; /** Available settings for autosave intervals. */ -static const uint32 _autosave_dropdown_to_minutes[] = { +static const uint32_t _autosave_dropdown_to_minutes[] = { 0, ///< never 10, 30, @@ -223,7 +223,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) { @@ -1082,12 +1082,12 @@ struct SettingEntry : BaseSettingEntry { void SetButtons(byte new_val); StringID GetHelpText() const; - void SetValueDParams(uint first_param, int32 value) const; + void SetValueDParams(uint first_param, int32_t value) const; protected: SettingEntry(const IntSettingDesc *setting); virtual void DrawSetting(GameSettings *settings_ptr, int left, int right, int y, bool highlight) const override; - virtual void DrawSettingString(uint left, uint right, int y, bool highlight, int32 value) const; + virtual void DrawSettingString(uint left, uint right, int y, bool highlight, int32_t value) const; private: bool IsVisibleByRestrictionMode(RestrictionMode mode) const; @@ -1120,7 +1120,7 @@ struct CargoDestPerCargoSettingEntry : SettingEntry { bool UpdateFilterState(SettingFilter &filter, bool force_visible) override; protected: - void DrawSettingString(uint left, uint right, int y, bool highlight, int32 value) const override; + void DrawSettingString(uint left, uint right, int y, bool highlight, int32_t value) const override; }; /** Conditionally hidden standard setting */ @@ -1369,8 +1369,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. */ @@ -1452,7 +1452,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); @@ -1461,7 +1461,7 @@ void SettingEntry::SetValueDParams(uint first_param, int32 value) const int log = -std::min(0, (int)std::floor(std::log10(scale)) - 2); SetDParam(first_param++, STR_JUST_RAW_STRING); - auto tmp_params = MakeParameters(value, (int64)(scale * std::pow(10.f, (float)log)), log); + auto tmp_params = MakeParameters(value, (int64_t)(scale * std::pow(10.f, (float)log)), log); SetDParamStr(first_param++, GetStringWithArgs(this->setting->str_val, tmp_params)); } else { if ((this->setting->flags & SF_ENUM) != 0) { @@ -1508,7 +1508,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); @@ -1518,12 +1518,12 @@ 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->DrawSettingString(text_left, text_right, y + (SETTING_HEIGHT - GetCharacterHeight(FS_NORMAL)) / 2, highlight, value); } -void SettingEntry::DrawSettingString(uint left, uint right, int y, bool highlight, int32 value) const +void SettingEntry::DrawSettingString(uint left, uint right, int y, bool highlight, int32_t value) const { this->SetValueDParams(1, value); int edge = DrawString(left, right, y, this->setting->str, highlight ? TC_WHITE : TC_LIGHT_BLUE); @@ -1546,7 +1546,7 @@ void CargoDestPerCargoSettingEntry::Init(byte level) BaseSettingEntry::Init(level); } -void CargoDestPerCargoSettingEntry::DrawSettingString(uint left, uint right, int y, bool highlight, int32 value) const +void CargoDestPerCargoSettingEntry::DrawSettingString(uint left, uint right, int y, bool highlight, int32_t value) const { assert(this->setting->str == STR_CONFIG_SETTING_DISTRIBUTION_PER_CARGO); SetDParam(0, CargoSpec::Get(this->cargo)->name); @@ -2858,7 +2858,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 | SF_ENUM))) { @@ -2915,7 +2915,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; @@ -2924,7 +2924,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 */ @@ -2937,10 +2937,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 { @@ -2967,7 +2967,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 | SF_ENUM))) { - int64 value64 = value; + int64_t value64 = value; /* Show the correct currency or velocity translated value */ if (sd->flags & SF_GUI_CURRENCY) value64 *= _currency->rate; if (sd->flags & SF_GUI_VELOCITY) value64 = ConvertKmhishSpeedToDisplaySpeed((uint)value64, VEH_TRAIN); @@ -3009,7 +3009,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; if (sd->flags & SF_DECIMAL1 || (sd->flags & SF_GUI_VELOCITY && _settings_game.locale.units_velocity == 3)) { @@ -3021,7 +3021,7 @@ struct GameSettingsWindow : Window { /* Save the correct currency-translated value */ if (sd->flags & SF_GUI_CURRENCY) llvalue /= _currency->rate; - value = ClampTo(llvalue); + value = ClampTo(llvalue); /* Save the correct velocity-translated value */ if (sd->flags & SF_GUI_VELOCITY) value = ConvertDisplaySpeedToKmhishSpeed(value, VEH_TRAIN); diff --git a/src/settings_internal.h b/src/settings_internal.h index 8ed380eabe..83e850b90a 100644 --- a/src/settings_internal.h +++ b/src/settings_internal.h @@ -16,9 +16,9 @@ #include #include -enum SaveToConfigFlags : uint32; +enum SaveToConfigFlags : uint32_t; -enum SettingFlag : uint32 { +enum SettingFlag : uint32_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"). @@ -100,11 +100,11 @@ struct SettingOnGuiCtrlData { struct IniItem; typedef bool OnGuiCtrl(SettingOnGuiCtrlData &data); ///< callback prototype for GUI operations -typedef int64 OnXrefValueConvert(int64 val); ///< callback prototype for xref value conversion +typedef int64_t OnXrefValueConvert(int64_t val); ///< callback prototype for xref value conversion /** The last entry in an array of struct SettingDescEnumEntry must use STR_NULL. */ struct SettingDescEnumEntry { - int32 val; + int32_t val; StringID str; }; @@ -185,24 +185,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, const char *name, SettingFlag flags, OnGuiCtrl *guiproc, bool startup, const char *patx_name, int32 def, - int32 min, uint32 max, int32 interval, StringID str, StringID str_help, StringID str_val, + IntSettingDesc(const SaveLoad &save, const char *name, SettingFlag flags, OnGuiCtrl *guiproc, bool startup, const char *patx_name, 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, const SettingDescEnumEntry *enumlist) : SettingDesc(save, name, flags, guiproc, startup, patx_name), 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), enumlist(enumlist) {} - 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. @@ -219,20 +219,20 @@ struct IntSettingDesc : SettingDesc { virtual bool IsBoolSetting() const { return false; } bool IsIntSetting() const override { return true; } - void ChangeValue(const void *object, int32 newvalue, SaveToConfigFlags ini_save_flags) const; - void MakeValueValidAndWrite(const void *object, int32 value) const; + void ChangeValue(const void *object, int32_t newvalue, SaveToConfigFlags ini_save_flags) const; + void MakeValueValidAndWrite(const void *object, int32_t value) const; virtual size_t ParseValue(const char *str) const; void FormatValue(char *buf, const char *last, const void *object) const override; - virtual void FormatIntValue(char *buf, const char *last, uint32 value) const; + virtual void FormatIntValue(char *buf, const char *last, uint32_t value) const; void ParseValue(const IniItem *item, void *object) const override; bool IsSameValue(const IniItem *item, void *object) const override; bool IsDefaultValue(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. */ @@ -246,7 +246,7 @@ struct BoolSettingDesc : IntSettingDesc { bool IsBoolSetting() const override { return true; } size_t ParseValue(const char *str) const override; - void FormatIntValue(char *buf, const char *last, uint32 value) const override; + void FormatIntValue(char *buf, const char *last, uint32_t value) const override; }; /** One of many setting. */ @@ -254,7 +254,7 @@ struct OneOfManySettingDesc : IntSettingDesc { typedef size_t OnConvert(const char *value); ///< callback prototype for conversion error OneOfManySettingDesc(const SaveLoad &save, const char *name, SettingFlag flags, OnGuiCtrl *guiproc, bool startup, const char *patx_name, - int32 def, int32 max, StringID str, StringID str_help, StringID str_val, SettingCategory cat, + 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, name, flags, guiproc, startup, patx_name, def, 0, max, 0, str, str_help, str_val, cat, pre_check, post_callback, nullptr), many_cnvt(many_cnvt) @@ -269,20 +269,20 @@ struct OneOfManySettingDesc : IntSettingDesc { char *FormatSingleValue(char *buf, const char *last, uint id) const; size_t ParseValue(const char *str) const override; - void FormatIntValue(char *buf, const char *last, uint32 value) const override; + void FormatIntValue(char *buf, const char *last, uint32_t value) const override; }; /** Many of many setting. */ struct ManyOfManySettingDesc : OneOfManySettingDesc { ManyOfManySettingDesc(const SaveLoad &save, const char *name, SettingFlag flags, OnGuiCtrl *guiproc, bool startup, const char *patx_name, - 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, name, flags, guiproc, startup, patx_name, def, (1 << many.size()) - 1, str, str_help, str_val, cat, pre_check, post_callback, many, many_cnvt) {} size_t ParseValue(const char *str) const override; - void FormatIntValue(char *buf, const char *last, uint32 value) const override; + void FormatIntValue(char *buf, const char *last, uint32_t value) const override; }; /** String settings. */ @@ -303,12 +303,12 @@ struct StringSettingDesc : SettingDesc { typedef void PostChangeCallback(const std::string &value); StringSettingDesc(const SaveLoad &save, const char *name, SettingFlag flags, OnGuiCtrl *guiproc, bool startup, const char *patx_name, const char *def, - uint32 max_length, PreChangeCheck pre_check, PostChangeCallback post_callback) : + uint32_t max_length, PreChangeCheck pre_check, PostChangeCallback post_callback) : SettingDesc(save, name, flags, guiproc, startup, patx_name), 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. @@ -360,7 +360,7 @@ inline const SettingDesc *GetSettingFromName(const std::string &name) return GetSettingFromName(name.c_str()); } -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); void IterateSettingsTables(std::function handler); @@ -430,7 +430,7 @@ struct IterateSettingTables { SettingTablesIterator end() { return SettingTablesIterator(this->tables, this->tables.end(), SettingTable::iterator()); } }; -enum class SettingsCompatType : uint8 { +enum class SettingsCompatType : uint8_t { Null, Setting, Xref, @@ -439,7 +439,7 @@ enum class SettingsCompatType : uint8 { struct SettingsCompat { std::string name; ///< Name of the field. SettingsCompatType type; ///< Compat type - 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. SlXvFeatureTest ext_feature_test; ///< Extended feature test diff --git a/src/settings_type.h b/src/settings_type.h index e711f6df24..8189ad8418 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -91,18 +91,18 @@ 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 - uint8 vehicle_costs_in_depot; ///< amount of money spent on vehicle running cost when in depot - uint8 vehicle_costs_when_stopped; ///< amount of money spent on vehicle running cost when vehicle is stopped + uint8_t vehicle_costs_in_depot; ///< amount of money spent on vehicle running cost when in depot + uint8_t vehicle_costs_when_stopped; ///< amount of money spent on vehicle running cost when vehicle is stopped 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 @@ -133,8 +133,8 @@ enum ShowSignalDefaultMode { /** Settings related to time display. This may be loaded from the savegame and/or overriden by the client. */ struct TimeSettings { bool time_in_minutes; ///< whether to use the hh:mm conversion when printing dates - uint16 ticks_per_minute; ///< how many ticks per minute - uint16 clock_offset; ///< clock offset in minutes + uint16_t ticks_per_minute; ///< how many ticks per minute + uint16_t clock_offset; ///< clock offset in minutes TickMinutes ToTickMinutes(DateTicksScaled ticks) const { @@ -155,184 +155,184 @@ struct TimeSettings { /** Settings related to the GUI and other stuff that is not saved in the savegame. */ struct GUISettings : public TimeSettings { - 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 - bool restriction_wait_vehicle_warn; ///< if a vehicle is waiting for an extended time due to a routing restriction, show a warning - uint8 order_review_system; ///< perform order reviews on vehicles - uint8 no_depot_order_warn; ///< if a non-air vehicle doesn't have at least one depot order, show a warning - 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) - byte errmsg_duration; ///< duration of error message - uint16 hover_delay_ms; ///< time required to activate a hover event, in milliseconds - bool instant_tile_tooltip; ///< don't require a right click to activate a hover event to show a tooltip for an in-game tile (e.g. industry). - uint8 town_name_tooltip_mode; ///< when to display town names when hovering over roads and houses. (0 = never, 1 = only if town names are hidden, 2 = always) - bool industry_tooltip_show; ///< whether to display tooltips, when hovering over industry tiles. - bool industry_tooltip_show_name; ///< whether to display the name of the industry, when hovering over one of its tiles. - bool industry_tooltip_show_required; ///< whether to display cargoes required by the industry, when hovering over one of its tiles. - bool industry_tooltip_show_stockpiled; ///< whether to display cargoes stockpiled by the industry, when hovering over one of its tiles. - bool industry_tooltip_show_produced; ///< whether to display cargoes produced by the industry, when hovering over one of its tiles. - uint8 depot_tooltip_mode; ///< Display mode for depot viewport tooltips. (0 = never, 1 = just a total number of vehicles, 2 = total number of vehicles in the depot along with a breakdown of numbers) - uint8 waypoint_viewport_tooltip_name; ///< Show the name of the waypoint or buoy in a viewport tooltip. (0 = never, 1 = only if waypoint names are hidden, 2 = always) - uint8 station_viewport_tooltip_name; ///< Show the name of the station in a viewport tooltip. (0 = never, 1 = only if station names are hidden, 2 = always) - bool station_viewport_tooltip_cargo; ///< Show a list of cargo details at the station in a viewport tooltip. - uint8 station_rating_tooltip_mode; ///< Station rating tooltip mode - 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 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 default_road_type; ///< the default road/tram types for the road/tram 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) - 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 - uint32 autosave_interval; ///< how often should we do autosaves? - bool autosave_realtime; ///< autosaves based on real elapsed time (with pause handling) - bool threaded_saves; ///< should we do threaded saves? - 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) - byte max_num_autosaves; ///< controls how many autosavegames are made before the game starts to overwrite (names them 0 to max_num_autosaves - 1) - byte max_num_lt_autosaves; ///< controls how many long-term autosavegames are made before the game starts to overwrite (names them 0 to max_num_lt_autosaves - 1) - uint8 savegame_overwrite_confirm; ///< Mode for when to warn about overwriting an existing savegame - bool population_in_label; ///< show the population of a town in its label? - bool city_in_label; ///< show cities in 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? - bool show_slopes_on_viewport_map; ///< use slope orientation to render the ground - bool show_height_on_viewport_map; ///< use height for shading when rendering the ground - uint32 default_viewport_map_mode; ///< the mode to use by default when a viewport is in map mode, 0=owner, 1=industry, 2=vegetation - uint32 action_when_viewport_map_is_dblclicked; ///< what to do when a doubleclick occurs on the viewport map - uint32 show_scrolling_viewport_on_map; ///< when a no map viewport is scrolled, its location is marked on the other map viewports - bool show_bridges_on_map; ///< bridges are rendered on a viewport in map mode - bool show_tunnels_on_map; ///< tunnels are rendered on a viewport in map mode - bool use_owner_colour_for_tunnelbridge;///< bridges and tunnels are rendered with their owner's colour - bool timetable_arrival_departure; ///< show arrivals and departures in vehicle timetables - uint8 max_departures; ///< maximum number of departures to show per station - uint16 max_departure_time; ///< maximum time in advance to show departures (days) - uint16 max_departure_time_minutes; ///< maximum time in advance to show departures (minutes) - uint16 departure_calc_frequency; ///< how often to calculate departures (in ticks) - bool departure_show_vehicle; ///< whether to show vehicle names with departures - bool departure_show_group; ///< whether to show group names with departures - bool departure_show_company; ///< whether to show company names with departures - bool departure_show_vehicle_type; ///< whether to show vehicle type icons with departures - bool departure_show_vehicle_color; ///< whether to show vehicle type icons in silver instead of orange - bool departure_larger_font; ///< whether to show the calling at list in a larger font - bool departure_destination_type; ///< whether to show destination types for ports and airports - bool departure_show_both; ///< whether to show departure and arrival times on the same line - bool departure_only_passengers; ///< whether to only show passenger services - bool departure_smart_terminus; ///< whether to only show passenger services - uint8 departure_conditionals; ///< how to handle conditional orders - bool departure_show_all_stops; ///< whether to show stops regardless of loading/unloading done at them - bool departure_merge_identical; ///< whether to merge identical departures - RightClickClose right_click_wnd_close; ///< close window with right click - bool pause_on_newgame; ///< whether to start new games paused or not - SignalGUISettings signal_gui_mode; ///< select which signal types are shown in the signal GUI - SignalCycleSettings cycle_signal_types; ///< Which signal types to cycle with the build signal tool. - SignalType default_signal_type; ///< The default signal type, which is set automatically by the last signal used. Not available in Settings. - Year coloured_news_year; ///< when does newspaper become coloured? - bool override_time_settings; ///< Whether to override time display settings stored in savegame. - bool timetable_in_ticks; ///< whether to show the timetable in ticks rather than days - bool timetable_leftover_ticks; ///< whether to show leftover ticks after converting to minutes/days, in the timetable - bool timetable_start_text_entry; ///< whether to enter timetable start times as text (hhmm format) - uint8 date_with_time; ///< whether to show the month and year with the time - bool quick_goto; ///< Allow quick access to 'goto button' in vehicle orders window - bool auto_euro; ///< automatically switch to euro in 2002 - byte drag_signals_density; ///< many signals density - bool drag_signals_fixed_distance; ///< keep fixed distance between signals when dragging - bool drag_signals_skip_stations; ///< continue past station/waypoint tiles when auto-fill dragging signals - Year semaphore_build_before; ///< build semaphore signals automatically before this year - byte news_message_timeout; ///< how much longer than the news message "age" should we keep the message in the history - bool show_track_reservation; ///< highlight reserved tracks. - byte station_numtracks; ///< the number of platforms to default on for rail stations - byte station_platlength; ///< the platform length, in tiles, for rail stations - bool station_dragdrop; ///< whether drag and drop is enabled for stations - bool station_show_coverage; ///< whether to highlight coverage area - bool persistent_buildingtools; ///< keep the building tools active after usage - uint32 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 - bool show_train_length_in_details; ///< show train length in vehicle details window top widget - bool show_train_weight_ratios_in_details; ///< show train weight ratios in vehicle details window top widget - bool show_vehicle_group_in_details; ///< show vehicle group in vehicle details window top widget - bool show_restricted_signal_recolour; ///< Show restricted electric signals with recoloured signal post - uint8 show_all_signal_default; ///< Show all signals using the default sprite - bool show_adv_tracerestrict_features; ///< Show advanced trace restrict features in UI - bool show_progsig_ui; ///< Show programmable pre-signals feature in UI - bool show_noentrysig_ui; ///< Show no-entry signals feature in UI - uint8 osk_activation; ///< Mouse gesture to trigger the OSK. - byte starting_colour; ///< default color scheme for the company to start a new game with - byte starting_colour_secondary; ///< default secondary 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 show_wagon_intro_year; ///< Show the introduction year for wagons in the build vehicle window - 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. - uint8 show_vehicle_route_mode; ///< How to show a vehicle's route when one of its windows is focused - bool show_vehicle_route; ///< Show route lines when vehicles route overlay is being shown - bool show_vehicle_route_steps; ///< Show route step markers when vehicles route overlay is being shown - uint8 dash_level_of_route_lines; ///< the dash level passed to GfxDrawLine() (plain if 0) - bool show_vehicle_list_company_colour; ///< show the company colour of vehicles which have an owner different to the owner of the vehicle list - bool enable_single_veh_shared_order_gui; ///< enable showing a single vehicle in the shared order GUI window - bool show_adv_load_mode_features; ///< enable advanced loading mode features in UI - bool disable_top_veh_list_mass_actions; ///< disable mass actions buttons for non-group vehicle lists - bool adv_sig_bridge_tun_modes; ///< Enable advanced modes for signals on bridges/tunnels. - bool sort_track_types_by_speed; ///< Sorts track types by compatibility first, and speed next, instead of newGRF slot - bool show_depot_sell_gui; ///< Show go to depot and sell in UI - bool open_vehicle_gui_clone_share; ///< Open vehicle GUI when share-cloning vehicle from depot GUI - uint8 linkgraph_colours; ///< linkgraph overlay colours - uint8 vehicle_names; ///< Vehicle naming scheme - bool shade_trees_on_slopes; ///< Shade trees on slopes - uint8 demolish_confirm_mode; ///< Demolition confirmation mode - bool dual_pane_train_purchase_window; ///< Dual pane train purchase window - bool dual_pane_train_purchase_window_dual_buttons; ///< Dual pane train purchase window: dual buttons - bool allow_hiding_waypoint_labels; ///< Allow hiding waypoint viewport labels - uint8 disable_water_animation; ///< Disable water animation depending on zoom level - bool show_order_occupancy_by_default; ///< Show order occupancy by default in vehicle order window - bool show_group_hierarchy_name; ///< Show the full hierarchy in group names - bool show_vehicle_group_hierarchy_name;///< Show the full group hierarchy in vehicle names - bool show_order_number_vehicle_view; ///< Show order number in vehicle view window - bool hide_default_stop_location; ///< Hide default stop location for orders - bool show_rail_polyline_tool; ///< Show rail polyline tool - - 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. - - 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 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 - 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 - bool console_show_unlisted; ///< whether to show unlisted console commands - bool newgrf_disable_big_gui; ///< whether to disable "big GUI" NewGRFs - - bool scale_bevels; ///< bevels are scaled with GUI scale. - bool bigger_main_toolbar; ///< bigger main toolbar. + 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 + bool restriction_wait_vehicle_warn; ///< if a vehicle is waiting for an extended time due to a routing restriction, show a warning + uint8_t order_review_system; ///< perform order reviews on vehicles + uint8_t no_depot_order_warn; ///< if a non-air vehicle doesn't have at least one depot order, show a warning + 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_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_t hover_delay_ms; ///< time required to activate a hover event, in milliseconds + bool instant_tile_tooltip; ///< don't require a right click to activate a hover event to show a tooltip for an in-game tile (e.g. industry). + uint8_t town_name_tooltip_mode; ///< when to display town names when hovering over roads and houses. (0 = never, 1 = only if town names are hidden, 2 = always) + bool industry_tooltip_show; ///< whether to display tooltips, when hovering over industry tiles. + bool industry_tooltip_show_name; ///< whether to display the name of the industry, when hovering over one of its tiles. + bool industry_tooltip_show_required; ///< whether to display cargoes required by the industry, when hovering over one of its tiles. + bool industry_tooltip_show_stockpiled; ///< whether to display cargoes stockpiled by the industry, when hovering over one of its tiles. + bool industry_tooltip_show_produced; ///< whether to display cargoes produced by the industry, when hovering over one of its tiles. + uint8_t depot_tooltip_mode; ///< Display mode for depot viewport tooltips. (0 = never, 1 = just a total number of vehicles, 2 = total number of vehicles in the depot along with a breakdown of numbers) + uint8_t waypoint_viewport_tooltip_name; ///< Show the name of the waypoint or buoy in a viewport tooltip. (0 = never, 1 = only if waypoint names are hidden, 2 = always) + uint8_t station_viewport_tooltip_name; ///< Show the name of the station in a viewport tooltip. (0 = never, 1 = only if station names are hidden, 2 = always) + bool station_viewport_tooltip_cargo; ///< Show a list of cargo details at the station in a viewport tooltip. + uint8_t station_rating_tooltip_mode; ///< Station rating tooltip mode + bool link_terraform_toolbar; ///< display terraform toolbar when displaying rail, road, water and airport toolbars + uint8_t smallmap_land_colour; ///< colour used for land and heightmap at the smallmap + 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_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 default_road_type; ///< the default road/tram types for the road/tram 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 + uint32_t autosave_interval; ///< how often should we do autosaves? + bool autosave_realtime; ///< autosaves based on real elapsed time (with pause handling) + bool threaded_saves; ///< should we do threaded saves? + 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_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) + byte max_num_lt_autosaves; ///< controls how many long-term autosavegames are made before the game starts to overwrite (names them 0 to max_num_lt_autosaves - 1) + uint8_t savegame_overwrite_confirm; ///< Mode for when to warn about overwriting an existing savegame + bool population_in_label; ///< show the population of a town in its label? + bool city_in_label; ///< show cities in label? + 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 show_slopes_on_viewport_map; ///< use slope orientation to render the ground + bool show_height_on_viewport_map; ///< use height for shading when rendering the ground + uint32_t default_viewport_map_mode; ///< the mode to use by default when a viewport is in map mode, 0=owner, 1=industry, 2=vegetation + uint32_t action_when_viewport_map_is_dblclicked; ///< what to do when a doubleclick occurs on the viewport map + uint32_t show_scrolling_viewport_on_map; ///< when a no map viewport is scrolled, its location is marked on the other map viewports + bool show_bridges_on_map; ///< bridges are rendered on a viewport in map mode + bool show_tunnels_on_map; ///< tunnels are rendered on a viewport in map mode + bool use_owner_colour_for_tunnelbridge; ///< bridges and tunnels are rendered with their owner's colour + bool timetable_arrival_departure; ///< show arrivals and departures in vehicle timetables + uint8_t max_departures; ///< maximum number of departures to show per station + uint16_t max_departure_time; ///< maximum time in advance to show departures (days) + uint16_t max_departure_time_minutes; ///< maximum time in advance to show departures (minutes) + uint16_t departure_calc_frequency; ///< how often to calculate departures (in ticks) + bool departure_show_vehicle; ///< whether to show vehicle names with departures + bool departure_show_group; ///< whether to show group names with departures + bool departure_show_company; ///< whether to show company names with departures + bool departure_show_vehicle_type; ///< whether to show vehicle type icons with departures + bool departure_show_vehicle_color; ///< whether to show vehicle type icons in silver instead of orange + bool departure_larger_font; ///< whether to show the calling at list in a larger font + bool departure_destination_type; ///< whether to show destination types for ports and airports + bool departure_show_both; ///< whether to show departure and arrival times on the same line + bool departure_only_passengers; ///< whether to only show passenger services + bool departure_smart_terminus; ///< whether to only show passenger services + uint8_t departure_conditionals; ///< how to handle conditional orders + bool departure_show_all_stops; ///< whether to show stops regardless of loading/unloading done at them + bool departure_merge_identical; ///< whether to merge identical departures + RightClickClose right_click_wnd_close; ///< close window with right click + bool pause_on_newgame; ///< whether to start new games paused or not + SignalGUISettings signal_gui_mode; ///< select which signal types are shown in the signal GUI + SignalCycleSettings cycle_signal_types; ///< Which signal types to cycle with the build signal tool. + SignalType default_signal_type; ///< The default signal type, which is set automatically by the last signal used. Not available in Settings. + Year coloured_news_year; ///< when does newspaper become coloured? + bool override_time_settings; ///< Whether to override time display settings stored in savegame. + bool timetable_in_ticks; ///< whether to show the timetable in ticks rather than days + bool timetable_leftover_ticks; ///< whether to show leftover ticks after converting to minutes/days, in the timetable + bool timetable_start_text_entry; ///< whether to enter timetable start times as text (hhmm format) + uint8_t date_with_time; ///< whether to show the month and year with the time + bool quick_goto; ///< Allow quick access to 'goto button' in vehicle orders window + bool auto_euro; ///< automatically switch to euro in 2002 + byte drag_signals_density; ///< many signals density + bool drag_signals_fixed_distance; ///< keep fixed distance between signals when dragging + bool drag_signals_skip_stations; ///< continue past station/waypoint tiles when auto-fill dragging signals + Year semaphore_build_before; ///< build semaphore signals automatically before this year + byte news_message_timeout; ///< how much longer than the news message "age" should we keep the message in the history + bool show_track_reservation; ///< highlight reserved tracks. + byte station_numtracks; ///< the number of platforms to default on for rail stations + byte station_platlength; ///< the platform length, in tiles, for rail stations + bool station_dragdrop; ///< whether drag and drop is enabled for stations + bool station_show_coverage; ///< whether to highlight coverage area + bool persistent_buildingtools; ///< keep the building tools active after usage + 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_t graph_line_thickness; ///< the thickness of the lines in the various graph guis + bool show_train_length_in_details; ///< show train length in vehicle details window top widget + bool show_train_weight_ratios_in_details; ///< show train weight ratios in vehicle details window top widget + bool show_vehicle_group_in_details; ///< show vehicle group in vehicle details window top widget + bool show_restricted_signal_recolour; ///< Show restricted electric signals with recoloured signal post + uint8_t show_all_signal_default; ///< Show all signals using the default sprite + bool show_adv_tracerestrict_features; ///< Show advanced trace restrict features in UI + bool show_progsig_ui; ///< Show programmable pre-signals feature in UI + bool show_noentrysig_ui; ///< Show no-entry signals feature in UI + 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 + byte starting_colour_secondary; ///< default secondary 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 show_wagon_intro_year; ///< Show the introduction year for wagons in the build vehicle window + bool auto_remove_signals; ///< automatically remove signals when in the way during rail construction + 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. + uint8_t show_vehicle_route_mode; ///< How to show a vehicle's route when one of its windows is focused + bool show_vehicle_route; ///< Show route lines when vehicles route overlay is being shown + bool show_vehicle_route_steps; ///< Show route step markers when vehicles route overlay is being shown + uint8_t dash_level_of_route_lines; ///< the dash level passed to GfxDrawLine() (plain if 0) + bool show_vehicle_list_company_colour; ///< show the company colour of vehicles which have an owner different to the owner of the vehicle list + bool enable_single_veh_shared_order_gui; ///< enable showing a single vehicle in the shared order GUI window + bool show_adv_load_mode_features; ///< enable advanced loading mode features in UI + bool disable_top_veh_list_mass_actions; ///< disable mass actions buttons for non-group vehicle lists + bool adv_sig_bridge_tun_modes; ///< Enable advanced modes for signals on bridges/tunnels. + bool sort_track_types_by_speed; ///< Sorts track types by compatibility first, and speed next, instead of newGRF slot + bool show_depot_sell_gui; ///< Show go to depot and sell in UI + bool open_vehicle_gui_clone_share; ///< Open vehicle GUI when share-cloning vehicle from depot GUI + uint8_t linkgraph_colours; ///< linkgraph overlay colours + uint8_t vehicle_names; ///< Vehicle naming scheme + bool shade_trees_on_slopes; ///< Shade trees on slopes + uint8_t demolish_confirm_mode; ///< Demolition confirmation mode + bool dual_pane_train_purchase_window; ///< Dual pane train purchase window + bool dual_pane_train_purchase_window_dual_buttons; ///< Dual pane train purchase window: dual buttons + bool allow_hiding_waypoint_labels; ///< Allow hiding waypoint viewport labels + uint8_t disable_water_animation; ///< Disable water animation depending on zoom level + bool show_order_occupancy_by_default; ///< Show order occupancy by default in vehicle order window + bool show_group_hierarchy_name; ///< Show the full hierarchy in group names + bool show_vehicle_group_hierarchy_name; ///< Show the full group hierarchy in vehicle names + bool show_order_number_vehicle_view; ///< Show order number in vehicle view window + bool hide_default_stop_location; ///< Hide default stop location for orders + bool show_rail_polyline_tool; ///< Show rail polyline tool + + 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_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_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_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_t newgrf_default_palette; ///< default palette to use for NewGRFs without action 14 palette information + bool console_show_unlisted; ///< whether to show unlisted console commands + bool newgrf_disable_big_gui; ///< whether to disable "big GUI" NewGRFs + + bool scale_bevels; ///< bevels are scaled with GUI scale. + bool bigger_main_toolbar; ///< bigger main toolbar. /** * Returns true when the user has sufficient privileges to edit newgrfs on a running game @@ -384,41 +384,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. @@ -434,15 +434,15 @@ struct NetworkSettings { std::string network_id; ///< network ID for servers std::string company_password_storage_token; ///< company password storage token std::string company_password_storage_secret; ///< company password storage secret - uint8 max_auth_failures; ///< maximum auth failures before client is kicked + uint8_t max_auth_failures; ///< maximum auth failures before client is kicked 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 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 @@ -452,12 +452,12 @@ struct NetworkSettings { /** Settings related to the creation of games. */ struct GameCreationSettings { - uint32 generation_seed; ///< noise seed for world generation - uint32 generation_unique_id; ///< random id to differentiate savegames + uint32_t generation_seed; ///< noise seed for world generation + uint32_t generation_unique_id; ///< random id to differentiate savegames Year starting_year; ///< starting date 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") @@ -473,8 +473,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 @@ -482,45 +482,45 @@ struct GameCreationSettings { byte river_route_random; ///< the amount of randomicity for the route finding byte amount_of_rivers; ///< the amount of rivers bool rivers_top_of_hill; ///< do rivers require starting near the tops of hills? - uint8 river_tropics_width; ///< the configured width of tropics around rivers - uint8 lake_tropics_width; ///< the configured width of tropics around lakes - uint8 coast_tropics_width; ///< the configured width of tropics around coasts - uint8 lake_size; ///< how large can lakes get? + uint8_t river_tropics_width; ///< the configured width of tropics around rivers + uint8_t lake_tropics_width; ///< the configured width of tropics around lakes + uint8_t coast_tropics_width; ///< the configured width of tropics around coasts + uint8_t lake_size; ///< how large can lakes get? bool lakes_allowed_in_deserts; ///< are lakes allowed in deserts? - uint8 amount_of_rocks; ///< the amount of rocks - uint8 height_affects_rocks; ///< the affect that map height has on rocks - uint8 build_public_roads; ///< build public roads connecting towns + uint8_t amount_of_rocks; ///< the amount of rocks + uint8_t height_affects_rocks; ///< the affect that map height has on rocks + uint8_t build_public_roads; ///< build public roads connecting towns }; /** 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 bool crossing_with_competitor; ///< allow building of level crossings with competitor roads or rails - 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 bool flood_from_edges; ///< whether water floods from map edges - uint8 map_edge_mode; ///< map edge mode - uint8 extra_tree_placement; ///< (dis)allow building extra trees in-game - uint8 trees_around_snow_line_range; ///< range around snowline for mixed and arctic forest. + uint8_t map_edge_mode; ///< map edge mode + uint8_t extra_tree_placement; ///< (dis)allow building extra trees in-game + uint8_t trees_around_snow_line_range; ///< range around snowline for mixed and arctic forest. bool trees_around_snow_line_enabled; ///< enable mixed and arctic forest around snowline, and no trees above snowline - uint8 trees_around_snow_line_dynamic_range; ///< how much of the snow line dynamic range to use as the snowline for arctic tree placement - uint8 command_pause_level; ///< level/amount of commands that can't be executed while paused - uint16 maximum_signal_evaluations; ///< maximum number of programmable pre-signals which may be evaluated in one pass + uint8_t trees_around_snow_line_dynamic_range; ///< how much of the snow line dynamic range to use as the snowline for arctic tree placement + uint8_t command_pause_level; ///< level/amount of commands that can't be executed while paused + uint16_t maximum_signal_evaluations; ///< maximum number of programmable pre-signals which may be evaluated in one pass bool enable_build_river; ///< enable building rivers in-game bool enable_remove_water; ///< enable removing sea and rivers in-game - uint8 road_custom_bridge_heads; ///< allow construction of road custom bridge heads + uint8_t road_custom_bridge_heads; ///< allow construction of road custom bridge heads bool chunnel; ///< allow construction of tunnels under water - uint8 rail_custom_bridge_heads; ///< allow construction of rail custom bridge heads + uint8_t rail_custom_bridge_heads; ///< allow construction of rail custom bridge heads bool allow_grf_objects_under_bridges; ///< allow all NewGRF objects under bridges bool allow_stations_under_bridges; ///< allow NewGRF rail station/waypoint tiles that do not specify clearance under bridges bool allow_road_stops_under_bridges; ///< allow road/tram stops under bridges @@ -531,17 +531,17 @@ struct ConstructionSettings { bool ignore_object_intro_dates; ///< allow players to build objects before their introduction dates (does not include during map generation) bool convert_town_road_no_houses; ///< allow converting town roads to a type which does not allow houses - 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 purchase_land_per_64k_frames; ///< how many tiles may, over a long period, be purchased per 65536 frames? - uint16 purchase_land_frame_burst; ///< how many tiles may, over a short period, be purchased? - uint32 build_object_per_64k_frames; ///< how many tiles may, over a long period, have objects built on them per 65536 frames? - uint16 build_object_frame_burst; ///< how many tiles may, over a short period, have objects built on them? - uint8 tree_growth_rate; ///< tree growth rate + 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 purchase_land_per_64k_frames; ///< how many tiles may, over a long period, be purchased per 65536 frames? + uint16_t purchase_land_frame_burst; ///< how many tiles may, over a short period, be purchased? + uint32_t build_object_per_64k_frames; ///< how many tiles may, over a long period, have objects built on them per 65536 frames? + uint16_t build_object_frame_burst; ///< how many tiles may, over a short period, have objects built on them? + uint8_t tree_growth_rate; ///< tree growth rate byte old_simulated_wormhole_signals; ///< moved to company settings: simulate signals in tunnel }; @@ -557,9 +557,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. */ @@ -569,80 +569,80 @@ 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 - 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 - 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 + bool disable_node_optimization; ///< whether to use exit-dir instead of trackdir in node key + 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_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_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 bool forbid_90_deg; ///< forbid trains to make 90 deg turns bool back_of_one_way_pbs_waiting_point;///< whether the back of one-way PBS signals is a safe waiting point - uint8 reroute_rv_on_layout_change; ///< whether to re-route road vehicles when the layout changes + uint8_t reroute_rv_on_layout_change; ///< whether to re-route road vehicles when the layout changes bool reverse_at_signals; ///< whether to reverse at signals at all byte wait_oneway_signal; ///< waitingtime in days before a oneway signal @@ -666,52 +666,52 @@ struct OrderSettings { bool station_length_loading_penalty; ///< make trains longer than the station load more slowly bool nonstop_only; ///< allow non-stop orders only - uint8 old_occupancy_smoothness; ///< moved to company settings: percentage smoothness of occupancy measurement changes + uint8_t old_occupancy_smoothness; ///< moved to company settings: percentage smoothness of occupancy measurement changes bool old_timetable_separation; ///< moved to company settings: whether to perform automatic separation based on timetable - uint8 old_timetable_separation_rate; ///< moved to company settings: percentage of timetable separation change to apply + uint8_t old_timetable_separation_rate; ///< moved to company settings: percentage of timetable separation change to apply }; /** 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 train_braking_model; ///< braking model for trains - uint8 realistic_braking_aspect_limited; ///< realistic braking lookahead is aspect limited - bool limit_train_acceleration; ///< when using realistic braking, also limit train acceleration - 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 - bool wagon_speed_limits; ///< enable wagon speed limits - bool train_speed_adaptation; ///< Faster trains slow down when behind slower trains - bool slow_road_vehicles_in_curves; ///< Road vehicles slow down in curves. - 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 - bool dynamic_engines; ///< enable dynamic allocation of engine data - bool never_expire_vehicles; ///< never expire vehicles - Year no_expire_vehicles_after; ///< do not expire vehicles after this year - Year no_introduce_vehicles_after; ///< do not introduce vehicles after this year - 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 - bool adjacent_crossings; ///< enable closing of adjacent level crossings - bool safer_crossings; ///< enable safer level crossings - bool improved_breakdowns; ///< different types, chances and severities of breakdowns - bool pay_for_repair; ///< pay for repairing vehicle - uint8 repair_cost; ///< cost of repairing vehicle - bool ship_collision_avoidance; ///< ships try to avoid colliding with each other - bool no_train_crash_other_company; ///< trains cannot crash with trains from other companies - bool roadveh_articulated_overtaking; ///< enable articulated road vehicles overtaking other vehicles - bool roadveh_cant_quantum_tunnel; ///< enable or disable vehicles quantum tunelling through over vehicles when blocked - bool drive_through_train_depot; ///< enable drive-through train depot emulation - uint16 through_load_speed_limit; ///< maximum speed for through load - uint16 rail_depot_speed_limit; ///< maximum speed entering/existing rail depots - bool non_leading_engines_keep_name; ///< allow engines moved to a non-leading position to retain their custom name + 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 train_braking_model; ///< braking model for trains + uint8_t realistic_braking_aspect_limited; ///< realistic braking lookahead is aspect limited + bool limit_train_acceleration; ///< when using realistic braking, also limit train acceleration + 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 train_speed_adaptation; ///< Faster trains slow down when behind slower trains + bool slow_road_vehicles_in_curves; ///< Road vehicles slow down in curves. + 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_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 + Year no_expire_vehicles_after; ///< do not expire vehicles after this year + Year no_introduce_vehicles_after; ///< do not introduce vehicles after this year + byte extend_vehicle_life; ///< extend vehicle life by this many years + byte road_side; ///< the side of the road vehicles drive on + uint8_t plane_crashes; ///< number of plane crashes, 0 = none, 1 = reduced, 2 = normal + bool adjacent_crossings; ///< enable closing of adjacent level crossings + bool safer_crossings; ///< enable safer level crossings + bool improved_breakdowns; ///< different types, chances and severities of breakdowns + bool pay_for_repair; ///< pay for repairing vehicle + uint8_t repair_cost; ///< cost of repairing vehicle + bool ship_collision_avoidance; ///< ships try to avoid colliding with each other + bool no_train_crash_other_company; ///< trains cannot crash with trains from other companies + bool roadveh_articulated_overtaking; ///< enable articulated road vehicles overtaking other vehicles + bool roadveh_cant_quantum_tunnel; ///< enable or disable vehicles quantum tunelling through over vehicles when blocked + bool drive_through_train_depot; ///< enable drive-through train depot emulation + uint16_t through_load_speed_limit; ///< maximum speed for through load + uint16_t rail_depot_speed_limit; ///< maximum speed entering/existing rail depots + bool non_leading_engines_keep_name; ///< allow engines moved to a non-leading position to retain their custom name }; /** Settings related to the economy. */ @@ -721,8 +721,8 @@ struct EconomySettings { bool bribe; ///< enable bribing the local authority EconomyType type; ///< economy type (original/smooth/frozen) bool allow_shares; ///< allow the buying/selling of shares - uint8 min_years_for_shares; ///< minimum age of a company for it to trade shares - uint8 feeder_payment_share; ///< percentage of leg payment to virtually pay in feeder systems + uint8_t min_years_for_shares; ///< minimum age of a company for it to trade shares + 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 @@ -730,62 +730,62 @@ 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 - int8 town_growth_rate; ///< town growth rate - uint8 town_growth_cargo_transported; ///< percentage of town growth rate which depends on proportion of transported cargo in the last month + int8_t town_growth_rate; ///< town growth rate + uint8_t town_growth_cargo_transported; ///< percentage of town growth rate which depends on proportion of transported cargo in the last month bool town_zone_calc_mode; ///< calc mode for town zones - uint16 town_zone_0_mult; ///< multiplier for the size of town zone 0 - uint16 town_zone_1_mult; ///< multiplier for the size of town zone 1 - uint16 town_zone_2_mult; ///< multiplier for the size of town zone 2 - uint16 town_zone_3_mult; ///< multiplier for the size of town zone 3 - uint16 town_zone_4_mult; ///< multiplier for the size of town zone 4 - uint16 city_zone_0_mult; ///< multiplier for the size of city zone 0 - uint16 city_zone_1_mult; ///< multiplier for the size of city zone 1 - uint16 city_zone_2_mult; ///< multiplier for the size of city zone 2 - uint16 city_zone_3_mult; ///< multiplier for the size of city zone 3 - uint16 city_zone_4_mult; ///< multiplier for the size of city zone 4 - 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 + uint16_t town_zone_0_mult; ///< multiplier for the size of town zone 0 + uint16_t town_zone_1_mult; ///< multiplier for the size of town zone 1 + uint16_t town_zone_2_mult; ///< multiplier for the size of town zone 2 + uint16_t town_zone_3_mult; ///< multiplier for the size of town zone 3 + uint16_t town_zone_4_mult; ///< multiplier for the size of town zone 4 + uint16_t city_zone_0_mult; ///< multiplier for the size of city zone 0 + uint16_t city_zone_1_mult; ///< multiplier for the size of city zone 1 + uint16_t city_zone_2_mult; ///< multiplier for the size of city zone 2 + uint16_t city_zone_3_mult; ///< multiplier for the size of city zone 3 + uint16_t city_zone_4_mult; ///< multiplier for the size of city zone 4 + 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) - uint16 town_min_distance; ///< minimum distance between towns - uint8 max_town_heightlevel; ///< maximum height level for towns - uint16 min_town_land_area; ///< minimum contiguous lang area for towns. - uint16 min_city_land_area; ///< minimum contiguous lang area for cities. + uint16_t town_min_distance; ///< minimum distance between towns + uint8_t max_town_heightlevel; ///< maximum height level for towns + uint16_t min_town_land_area; ///< minimum contiguous lang area for towns. + uint16_t min_city_land_area; ///< minimum contiguous lang area for cities. 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[3]; ///< population to base decision on noise evaluation (@see town_council_tolerance) + uint16_t town_noise_population[3]; ///< population to base decision on noise evaluation (@see town_council_tolerance) bool infrastructure_sharing[4]; ///< enable infrastructure sharing for rail/road/water/air uint sharing_fee[4]; ///< fees for infrastructure sharing for rail/road/water/air bool sharing_payment_in_debt; ///< allow fee payment for companies with more loan than money (switch off to prevent MP exploits) bool allow_town_level_crossings; ///< towns are allowed to build level crossings TownTunnelMode town_build_tunnels; ///< if/when towns are allowed to build road tunnels - uint8 town_max_road_slope; ///< maximum number of consecutive sloped road tiles which towns are allowed to build + uint8_t town_max_road_slope; ///< maximum number of consecutive sloped road tiles which towns are allowed to build bool allow_town_bridges; ///< towns are allowed to build bridges - int8 old_town_cargo_factor; ///< old power-of-two multiplier for town (passenger, mail) generation. May be negative. - int16 town_cargo_scale_factor; ///< scaled power-of-two multiplier for town (passenger, mail) generation. May be negative. - int16 industry_cargo_scale_factor; ///< scaled power-of-two multiplier for primary industry generation. May be negative. + int8_t old_town_cargo_factor; ///< old power-of-two multiplier for town (passenger, mail) generation. May be negative. + int16_t town_cargo_scale_factor; ///< scaled power-of-two multiplier for town (passenger, mail) generation. May be negative. + int16_t industry_cargo_scale_factor; ///< scaled power-of-two multiplier for primary industry generation. May be negative. bool infrastructure_maintenance; ///< enable monthly maintenance fee for owner infrastructure - uint8 day_length_factor; ///< factor which the length of day is multiplied - uint16 random_road_reconstruction; ///< chance out of 1000 per tile loop for towns to start random road re-construction + uint8_t day_length_factor; ///< factor which the length of day is multiplied + uint16_t random_road_reconstruction; ///< chance out of 1000 per tile loop for towns to start random road re-construction bool disable_inflation_newgrf_flag; ///< Disable NewGRF inflation flag CargoPaymentAlgorithm payment_algorithm; ///< Cargo payment algorithm TickRateMode tick_rate; ///< Tick rate mode }; 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. - 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 + 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 DistributionType distribution_per_cargo[NUM_CARGO]; ///< per cargo distribution types - 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 - uint16 aircraft_link_scale; ///< scale effective distance of aircraft links + 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 + uint16_t aircraft_link_scale; ///< scale effective distance of aircraft links inline DistributionType GetDistributionType(CargoID cargo) const { @@ -814,10 +814,10 @@ 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 bool auto_timetable_by_default; ///< use automatic timetables by default bool auto_separation_by_default; ///< use automatic timetable separation by default }; @@ -825,33 +825,33 @@ struct VehicleDefaultSettings { /** 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 - uint8 order_occupancy_smoothness; ///< percentage smoothness of occupancy measurement changes - uint8 auto_timetable_separation_rate; ///< percentage of auto timetable separation change to apply + uint8_t order_occupancy_smoothness; ///< percentage smoothness of occupancy measurement changes + uint8_t auto_timetable_separation_rate; ///< percentage of auto timetable separation change to apply bool infra_others_buy_in_depot[4]; ///< other companies can buy/autorenew in this companies depots (where infra sharing enabled) - uint16 timetable_autofill_rounding; ///< round up timetable times to be a multiple of this number of ticks + uint16_t timetable_autofill_rounding; ///< round up timetable times to be a multiple of this number of ticks bool advance_order_on_clone; ///< when cloning a vehicle or copying/sharing an order list, advance the current order to a suitable point bool copy_clone_add_to_group; ///< whether to add cloned vehicles to the source vehicle's group, when cloning a vehicle without sharing orders bool remain_if_next_order_same_station; ///< if the next order is for the same station, start loading/unloading again instead of leaving. - uint16 default_sched_dispatch_duration; ///< default scheduled dispatch duration + uint16_t default_sched_dispatch_duration;///< default scheduled dispatch duration byte old_simulated_wormhole_signals; ///< no longer needs a setting: tunnel/bridge signal simulation spacing }; /** Debug settings. */ struct DebugSettings { - uint32 chicken_bits; ///< chicken bits - uint32 newgrf_optimiser_flags; ///< NewGRF optimiser flags + uint32_t chicken_bits; ///< chicken bits + uint32_t newgrf_optimiser_flags; ///< NewGRF optimiser flags }; /** Scenario editor settings. */ struct ScenarioSettings { bool multiple_buildings; ///< allow manually adding more than one church/stadium bool house_ignore_dates; ///< allow manually adding houses regardless of date restrictions - uint8 house_ignore_zones; ///< allow manually adding houses regardless of zone restrictions + uint8_t house_ignore_zones; ///< allow manually adding houses regardless of zone restrictions bool house_ignore_grf; ///< allow manually adding houses regardless of GRF restrictions }; diff --git a/src/ship.h b/src/ship.h index 048932d105..951b9f12cd 100644 --- a/src/ship.h +++ b/src/ship.h @@ -21,17 +21,17 @@ void GetShipSpriteSize(EngineID engine, uint &width, uint &height, int &xoffs, i WaterClass GetEffectiveWaterClass(TileIndex tile); /** Maximum segments of ship path cache */ -static const uint8 SHIP_PATH_CACHE_LENGTH = 32; -static const uint8 SHIP_PATH_CACHE_MASK = (SHIP_PATH_CACHE_LENGTH - 1); +static const uint8_t SHIP_PATH_CACHE_LENGTH = 32; +static const uint8_t SHIP_PATH_CACHE_MASK = (SHIP_PATH_CACHE_LENGTH - 1); static_assert((SHIP_PATH_CACHE_LENGTH & SHIP_PATH_CACHE_MASK) == 0, ""); // Must be a power of 2 struct ShipPathCache { std::array td; - uint8 start = 0; - uint8 count = 0; + uint8_t start = 0; + uint8_t count = 0; inline bool empty() const { return this->count == 0; } - inline uint8 size() const { return this->count; } + inline uint8_t size() const { return this->count; } inline bool full() const { return this->count >= SHIP_PATH_CACHE_LENGTH; } inline void clear() @@ -67,12 +67,12 @@ struct ShipPathCache { * All ships have this type. */ struct Ship FINAL : public SpecializedVehicle { - TrackBits state; ///< The "track" the ship is following. + TrackBits state; ///< The "track" the ship is following. std::unique_ptr cached_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. - uint8 lost_count; ///< Count of number of failed pathfinder attempts + Direction rotation; ///< Visible direction. + int16_t rotation_x_pos; ///< NOSAVE: X Position before rotation. + int16_t rotation_y_pos; ///< NOSAVE: Y Position before rotation. + uint8_t lost_count; ///< Count of number of failed pathfinder attempts byte critical_breakdown_count; ///< Counter for the number of critical breakdowns since last service /** We don't want GCC to zero our struct! It already is zeroed and has an index! */ diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index ea54bbd802..0ee751cb08 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -72,10 +72,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); } @@ -88,7 +88,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); @@ -138,7 +138,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; @@ -327,7 +327,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 @@ -339,7 +339,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]; @@ -382,7 +382,7 @@ int Ship::GetEffectiveMaxSpeed() const } /* clamp speed to be no less than lower of 5mph and 1/8 of base speed */ - return std::max(max_speed, std::min(10, (this->vcache.cached_max_speed + 7) >> 3)); + return std::max(max_speed, std::min(10, (this->vcache.cached_max_speed + 7) >> 3)); } /** @@ -587,7 +587,7 @@ static Track ChooseShipTrack(Ship *v, TileIndex tile, DiagDirection enterdir, Tr } } DEBUG_UPDATESTATECHECKSUM("ChooseShipTrack: v: %u, path_found: %d, track: %d", v->index, path_found, track); - UpdateStateChecksum((((uint64) v->index) << 32) | (path_found << 16) | track); + UpdateStateChecksum((((uint64_t) v->index) << 32) | (path_found << 16) | track); v->HandlePathfindingResult(path_found); return track; @@ -1096,7 +1096,7 @@ static void ShipController(Ship *v) bool Ship::Tick() { DEBUG_UPDATESTATECHECKSUM("Ship::Tick: v: %u, x: %d, y: %d", this->index, this->x_pos, this->y_pos); - UpdateStateChecksum((((uint64) this->x_pos) << 32) | this->y_pos); + UpdateStateChecksum((((uint64_t) this->x_pos) << 32) | this->y_pos); if (!((this->vehstatus & VS_STOPPED) || this->IsWaitingInDepot())) this->running_ticks++; ShipController(this); diff --git a/src/signal.cpp b/src/signal.cpp index 98de49885a..accc6c8432 100644 --- a/src/signal.cpp +++ b/src/signal.cpp @@ -29,8 +29,8 @@ #include "safeguards.h" -uint8 _extra_aspects = 0; -uint64 _aspect_cfg_hash = 0; +uint8_t _extra_aspects = 0; +uint64_t _aspect_cfg_hash = 0; SignalStyleMasks _signal_style_masks = {}; bool _signal_sprite_oversized = false; @@ -550,13 +550,13 @@ static SigInfo ExploreSegment(Owner owner) return info; } -static uint8 GetSignalledTunnelBridgeEntranceForwardAspect(TileIndex tile, TileIndex tile_exit) +static uint8_t GetSignalledTunnelBridgeEntranceForwardAspect(TileIndex tile, TileIndex tile_exit) { if (!IsTunnelBridgeSignalSimulationEntrance(tile)) return 0; const uint spacing = GetTunnelBridgeSignalSimulationSpacing(tile); const uint signal_count = GetTunnelBridgeLength(tile, tile_exit) / spacing; if (IsBridge(tile)) { - uint8 aspect = 0; + uint8_t aspect = 0; for (uint i = 0; i < signal_count; i++) { if (GetBridgeEntranceSimulatedSignalState(tile, i) == SIGNAL_STATE_GREEN) { aspect++; @@ -579,7 +579,7 @@ static uint8 GetSignalledTunnelBridgeEntranceForwardAspect(TileIndex tile, TileI } } -uint8 GetForwardAspectFollowingTrack(TileIndex tile, Trackdir trackdir) +uint8_t GetForwardAspectFollowingTrack(TileIndex tile, Trackdir trackdir) { Owner owner = GetTileOwner(tile); DiagDirection exitdir = TrackdirToExitdir(trackdir); @@ -623,7 +623,7 @@ uint8 GetForwardAspectFollowingTrack(TileIndex tile, Trackdir trackdir) if (HasSignalOnTrack(tile, track)) { // now check whole track, not trackdir if (HasSignalOnTrackdir(tile, trackdir)) { if (GetSignalStateByTrackdir(tile, trackdir) == SIGNAL_STATE_RED) return 0; - uint8 aspect = GetSignalAspect(tile, track); + uint8_t aspect = GetSignalAspect(tile, track); AdjustSignalAspectIfNonIncStyle(tile, track, aspect); return aspect; } else if (IsOnewaySignal(tile, track)) { @@ -700,7 +700,7 @@ uint8 GetForwardAspectFollowingTrack(TileIndex tile, Trackdir trackdir) } } -static uint8 GetForwardAspect(const SigInfo &info, TileIndex tile, Trackdir trackdir) +static uint8_t GetForwardAspect(const SigInfo &info, TileIndex tile, Trackdir trackdir) { if (info.flags & (SF_JUNCTION | SF_PBS)) { return GetForwardAspectFollowingTrack(tile, trackdir); @@ -709,7 +709,7 @@ static uint8 GetForwardAspect(const SigInfo &info, TileIndex tile, Trackdir trac } } -static uint8 GetForwardAspectAndIncrement(const SigInfo &info, TileIndex tile, Trackdir trackdir, bool combined_normal_mode = false) +static uint8_t GetForwardAspectAndIncrement(const SigInfo &info, TileIndex tile, Trackdir trackdir, bool combined_normal_mode = false) { return IncrementAspectForSignal(GetForwardAspect(info, tile, trackdir), combined_normal_mode); } @@ -740,7 +740,7 @@ static void UpdateSignalsAroundSegment(SigInfo info) if (IsTunnelBridgePBS(tile) || (_settings_game.vehicle.train_braking_model == TBM_REALISTIC && HasAcrossTunnelBridgeReservation(tile))) { if (_extra_aspects > 0 && GetTunnelBridgeExitSignalState(tile) == SIGNAL_STATE_GREEN) { Trackdir exit_td = GetTunnelBridgeExitTrackdir(tile); - uint8 aspect = GetForwardAspectAndIncrement(info, tile, exit_td); + uint8_t aspect = GetForwardAspectAndIncrement(info, tile, exit_td); if (aspect != GetTunnelBridgeExitSignalAspect(tile)) { SetTunnelBridgeExitSignalAspect(tile, aspect); MarkTunnelBridgeSignalDirty(tile, true); @@ -757,8 +757,8 @@ static void UpdateSignalsAroundSegment(SigInfo info) refresh = true; } if (_extra_aspects > 0) { - const uint8 current_aspect = (old_state == SIGNAL_STATE_GREEN) ? GetTunnelBridgeExitSignalAspect(tile) : 0; - uint8 aspect; + const uint8_t current_aspect = (old_state == SIGNAL_STATE_GREEN) ? GetTunnelBridgeExitSignalAspect(tile) : 0; + uint8_t aspect; if (new_state == SIGNAL_STATE_GREEN) { aspect = GetForwardAspectAndIncrement(info, tile, trackdir); } else { @@ -785,8 +785,8 @@ static void UpdateSignalsAroundSegment(SigInfo info) /* don't change signal state if tile is reserved in realistic braking mode */ if ((_settings_game.vehicle.train_braking_model == TBM_REALISTIC && HasBit(GetRailReservationTrackBits(tile), track))) { if (_extra_aspects > 0 && GetSignalStateByTrackdir(tile, trackdir) == SIGNAL_STATE_GREEN && !IsRailSpecialSignalAspect(tile, track)) { - uint8 aspect = GetForwardAspectAndIncrement(info, tile, trackdir, IsRailCombinedNormalShuntSignalStyle(tile, TrackdirToTrack(trackdir))); - uint8 old_aspect = GetSignalAspect(tile, track); + uint8_t aspect = GetForwardAspectAndIncrement(info, tile, trackdir, IsRailCombinedNormalShuntSignalStyle(tile, TrackdirToTrack(trackdir))); + uint8_t old_aspect = GetSignalAspect(tile, track); if (aspect != old_aspect) { SetSignalAspect(tile, track, aspect); if (old_aspect != 0) MarkSingleSignalDirty(tile, trackdir); @@ -839,8 +839,8 @@ static void UpdateSignalsAroundSegment(SigInfo info) const SignalState current_state = GetSignalStateByTrackdir(tile, trackdir); if (_extra_aspects > 0) { - const uint8 current_aspect = (current_state == SIGNAL_STATE_GREEN) ? GetSignalAspect(tile, track) : 0; - uint8 aspect; + const uint8_t current_aspect = (current_state == SIGNAL_STATE_GREEN) ? GetSignalAspect(tile, track) : 0; + uint8_t aspect; if (newstate == SIGNAL_STATE_GREEN) { aspect = 1; if (info.out_signal_tile != INVALID_TILE) { @@ -881,16 +881,16 @@ static void UpdateSignalsAroundSegment(SigInfo info) while (_tbpset.Get(&tile, &trackdir)) { if (IsTileType(tile, MP_TUNNELBRIDGE)) { - uint8 aspect = GetForwardAspectAndIncrement(info, tile, trackdir); - uint8 old_aspect = GetTunnelBridgeExitSignalAspect(tile); + uint8_t aspect = GetForwardAspectAndIncrement(info, tile, trackdir); + uint8_t old_aspect = GetTunnelBridgeExitSignalAspect(tile); if (aspect != old_aspect) { SetTunnelBridgeExitSignalAspect(tile, aspect); if (old_aspect != 0) MarkTunnelBridgeSignalDirty(tile, true); PropagateAspectChange(tile, trackdir, aspect); } } else { - uint8 aspect = GetForwardAspectAndIncrement(info, tile, trackdir, IsRailCombinedNormalShuntSignalStyle(tile, TrackdirToTrack(trackdir))); - uint8 old_aspect = GetSignalAspect(tile, track); + uint8_t aspect = GetForwardAspectAndIncrement(info, tile, trackdir, IsRailCombinedNormalShuntSignalStyle(tile, TrackdirToTrack(trackdir))); + uint8_t old_aspect = GetSignalAspect(tile, track); Track track = TrackdirToTrack(trackdir); if (aspect != old_aspect) { SetSignalAspect(tile, track, aspect); @@ -1242,12 +1242,12 @@ void CheckRemoveSignal(TileIndex tile, Track track) } } -uint8 GetSignalAspectGeneric(TileIndex tile, Trackdir trackdir, bool check_non_inc_style) +uint8_t GetSignalAspectGeneric(TileIndex tile, Trackdir trackdir, bool check_non_inc_style) { switch (GetTileType(tile)) { case MP_RAILWAY: if (HasSignalOnTrackdir(tile, trackdir) && GetSignalStateByTrackdir(tile, trackdir) == SIGNAL_STATE_GREEN) { - uint8 aspect = GetSignalAspect(tile, TrackdirToTrack(trackdir)); + uint8_t aspect = GetSignalAspect(tile, TrackdirToTrack(trackdir)); if (check_non_inc_style) AdjustSignalAspectIfNonIncStyle(tile, TrackdirToTrack(trackdir), aspect); return aspect; } @@ -1269,10 +1269,10 @@ uint8 GetSignalAspectGeneric(TileIndex tile, Trackdir trackdir, bool check_non_i return 0; } -void AdjustSignalAspectIfNonIncStyleIntl(TileIndex tile, Track track, uint8 &aspect) +void AdjustSignalAspectIfNonIncStyleIntl(TileIndex tile, Track track, uint8_t &aspect) { if (IsTileType(tile, MP_RAILWAY)) { - uint8 style = GetSignalStyle(tile, track); + uint8_t style = GetSignalStyle(tile, track); if (HasBit(_signal_style_masks.combined_normal_shunt, style)) { aspect--; if (aspect == 0) return; @@ -1297,11 +1297,11 @@ static void RefreshBridgeOnExitAspectChange(TileIndex entrance, TileIndex exit) } } -void PropagateAspectChange(TileIndex tile, Trackdir trackdir, uint8 aspect) +void PropagateAspectChange(TileIndex tile, Trackdir trackdir, uint8_t aspect) { AdjustSignalAspectIfNonIncStyle(tile, TrackdirToTrack(trackdir), aspect); - aspect = std::min(aspect + 1, GetMaximumSignalAspect()); + aspect = std::min(aspect + 1, GetMaximumSignalAspect()); Owner owner = GetTileOwner(tile); DiagDirection exitdir = TrackdirToExitdir(ReverseTrackdir(trackdir)); DiagDirection enterdir = ReverseDiagDir(exitdir); @@ -1346,17 +1346,17 @@ void PropagateAspectChange(TileIndex tile, Trackdir trackdir, uint8 aspect) if (HasSignalOnTrackdir(tile, reversedir)) { if (GetSignalStateByTrackdir(tile, reversedir) == SIGNAL_STATE_RED) return; bool combined_mode = IsRailCombinedNormalShuntSignalStyle(tile, track); - const uint8 current_aspect = GetSignalAspect(tile, track); + const uint8_t current_aspect = GetSignalAspect(tile, track); if (combined_mode && current_aspect == 1) { /* Don't change special combined_normal_shunt aspect */ return; } - if (combined_mode && aspect > 0) aspect = std::min(aspect + 1, 7); + if (combined_mode && aspect > 0) aspect = std::min(aspect + 1, 7); if (current_aspect == aspect) return; // aspect already correct SetSignalAspect(tile, track, aspect); MarkSingleSignalDirty(tile, reversedir); AdjustSignalAspectIfNonIncStyle(tile, TrackdirToTrack(trackdir), aspect); - aspect = std::min(aspect + 1, GetMaximumSignalAspect()); + aspect = std::min(aspect + 1, GetMaximumSignalAspect()); } else if (IsOnewaySignal(tile, track)) { return; // one-way signal facing the wrong way } @@ -1500,7 +1500,7 @@ void FlushDeferredAspectUpdates() switch (GetTileType(tile)) { case MP_RAILWAY: if (HasSignalOnTrackdir(tile, trackdir) && GetSignalStateByTrackdir(tile, trackdir) == SIGNAL_STATE_GREEN && GetSignalAspect(tile, TrackdirToTrack(trackdir)) == 0) { - uint8 aspect = GetForwardAspectFollowingTrackAndIncrement(tile, trackdir, IsRailCombinedNormalShuntSignalStyle(tile, TrackdirToTrack(trackdir))); + uint8_t aspect = GetForwardAspectFollowingTrackAndIncrement(tile, trackdir, IsRailCombinedNormalShuntSignalStyle(tile, TrackdirToTrack(trackdir))); SetSignalAspect(tile, TrackdirToTrack(trackdir), aspect); PropagateAspectChange(tile, trackdir, aspect); } @@ -1509,13 +1509,13 @@ void FlushDeferredAspectUpdates() case MP_TUNNELBRIDGE: if (IsTunnelBridgeSignalSimulationEntrance(tile) && TrackdirEntersTunnelBridge(tile, trackdir) && GetTunnelBridgeEntranceSignalState(tile) == SIGNAL_STATE_GREEN && GetTunnelBridgeEntranceSignalAspect(tile) == 0) { - uint8 aspect = GetForwardAspectFollowingTrackAndIncrement(tile, trackdir); + uint8_t aspect = GetForwardAspectFollowingTrackAndIncrement(tile, trackdir); SetTunnelBridgeEntranceSignalAspect(tile, aspect); PropagateAspectChange(tile, trackdir, aspect); } if (IsTunnelBridgeSignalSimulationExit(tile) && TrackdirExitsTunnelBridge(tile, trackdir) && GetTunnelBridgeExitSignalState(tile) == SIGNAL_STATE_GREEN && GetTunnelBridgeExitSignalAspect(tile) == 0) { - uint8 aspect = GetForwardAspectFollowingTrackAndIncrement(tile, trackdir); + uint8_t aspect = GetForwardAspectFollowingTrackAndIncrement(tile, trackdir); SetTunnelBridgeExitSignalAspect(tile, aspect); PropagateAspectChange(tile, trackdir, aspect); } @@ -1676,7 +1676,7 @@ void UpdateAllSignalAspects() Trackdir trackdir = TrackToTrackdir(track); if (!HasSignalOnTrackdir(tile, trackdir)) trackdir = ReverseTrackdir(trackdir); if (GetSignalStateByTrackdir(tile, trackdir) == SIGNAL_STATE_GREEN && !IsRailSpecialSignalAspect(tile, track)) { - uint8 aspect = GetForwardAspectFollowingTrackAndIncrement(tile, trackdir, IsRailCombinedNormalShuntSignalStyle(tile, track)); + uint8_t aspect = GetForwardAspectFollowingTrackAndIncrement(tile, trackdir, IsRailCombinedNormalShuntSignalStyle(tile, track)); SetSignalAspect(tile, track, aspect); PropagateAspectChange(tile, trackdir, aspect); } @@ -1685,13 +1685,13 @@ void UpdateAllSignalAspects() } else if (IsTunnelBridgeWithSignalSimulation(tile)) { if (IsTunnelBridgeSignalSimulationEntrance(tile) && GetTunnelBridgeEntranceSignalState(tile) == SIGNAL_STATE_GREEN) { Trackdir trackdir = GetTunnelBridgeEntranceTrackdir(tile); - uint8 aspect = GetForwardAspectFollowingTrackAndIncrement(tile, trackdir); + uint8_t aspect = GetForwardAspectFollowingTrackAndIncrement(tile, trackdir); SetTunnelBridgeEntranceSignalAspect(tile, aspect); PropagateAspectChange(tile, trackdir, aspect); } if (IsTunnelBridgeSignalSimulationExit(tile) && GetTunnelBridgeExitSignalState(tile) == SIGNAL_STATE_GREEN) { Trackdir trackdir = GetTunnelBridgeExitTrackdir(tile); - uint8 aspect = GetForwardAspectFollowingTrackAndIncrement(tile, trackdir); + uint8_t aspect = GetForwardAspectFollowingTrackAndIncrement(tile, trackdir); SetTunnelBridgeExitSignalAspect(tile, aspect); PropagateAspectChange(tile, trackdir, aspect); } @@ -1709,10 +1709,10 @@ static bool RemapNewSignalStyles(const std::array old_mapping = _new_signal_style_mapping; _new_signal_style_mapping = new_mapping; - uint8 remap_table[MAX_NEW_SIGNAL_STYLES + 1] = {}; + uint8_t remap_table[MAX_NEW_SIGNAL_STYLES + 1] = {}; remap_table[0] = 0; - uint8 next_free = _num_new_signal_styles; + uint8_t next_free = _num_new_signal_styles; std::array usage_table; const bool assume_all_styles_in_use = _networking && !_network_server; @@ -1726,13 +1726,13 @@ static bool RemapNewSignalStyles(const std::array 0) usage_table[old_style - 1] = true; } } if (IsRailTunnelBridgeTile(t) && GetTunnelBridgeDirection(t) < DIAGDIR_SW) { /* Only process west end of tunnel/bridge */ - uint8 old_style = GetTunnelBridgeSignalStyle(t); + uint8_t old_style = GetTunnelBridgeSignalStyle(t); if (old_style > 0) usage_table[old_style - 1] = true; } } @@ -1784,8 +1784,8 @@ static bool RemapNewSignalStyles(const std::array(new_extra_aspects, rti->signal_extra_aspects); + new_extra_aspects = std::max(new_extra_aspects, rti->signal_extra_aspects); } for (const GRFFile *grf : _new_signals_grfs) { - new_extra_aspects = std::max(new_extra_aspects, grf->new_signal_extra_aspects); + new_extra_aspects = std::max(new_extra_aspects, grf->new_signal_extra_aspects); } } @@ -1850,7 +1850,7 @@ static bool DetermineExtraAspectsVariable() SetBit(_signal_style_masks.next_only, i + 1); } else if (HasBit(_new_signal_styles[i].style_flags, NSSF_LOOKAHEAD_ASPECTS_SET)) { if (_new_signal_styles[i].lookahead_extra_aspects != 255) { - _new_signal_styles[i].lookahead_extra_aspects = std::min(_new_signal_styles[i].lookahead_extra_aspects, _new_signal_styles[i].grffile->new_signal_extra_aspects); + _new_signal_styles[i].lookahead_extra_aspects = std::min(_new_signal_styles[i].lookahead_extra_aspects, _new_signal_styles[i].grffile->new_signal_extra_aspects); } } else { _new_signal_styles[i].lookahead_extra_aspects = _new_signal_styles[i].grffile->new_signal_extra_aspects; @@ -1864,7 +1864,7 @@ static bool DetermineExtraAspectsVariable() _new_signal_styles[i].electric_mask &= (1 << SIGTYPE_PBS) | (1 << SIGTYPE_PBS_ONEWAY) | (1 << SIGTYPE_NO_ENTRY); _new_signal_styles[i].semaphore_mask &= (1 << SIGTYPE_PBS) | (1 << SIGTYPE_PBS_ONEWAY) | (1 << SIGTYPE_NO_ENTRY); } - uint8 mask = 0xFF; + uint8_t mask = 0xFF; if (HasBit(_new_signal_styles[i].style_flags, NSSF_REALISTIC_BRAKING_ONLY) && _settings_game.vehicle.train_braking_model != TBM_REALISTIC) { mask = 0; } else if (_settings_game.vehicle.train_braking_model == TBM_REALISTIC) { diff --git a/src/signal_func.h b/src/signal_func.h index a0cee98b00..45e72971ea 100644 --- a/src/signal_func.h +++ b/src/signal_func.h @@ -19,21 +19,21 @@ #include "settings_type.h" #include "vehicle_type.h" -extern uint8 _extra_aspects; -extern uint64 _aspect_cfg_hash; +extern uint8_t _extra_aspects; +extern uint64_t _aspect_cfg_hash; -inline uint8 GetMaximumSignalAspect() +inline uint8_t GetMaximumSignalAspect() { return _extra_aspects + 1; } struct SignalStyleMasks { - uint16 non_aspect_inc = 0; - uint16 next_only = 0; - uint16 always_reserve_through = 0; - uint16 no_tunnel_bridge = 0; - uint16 signal_opposite_side = 0; - uint16 combined_normal_shunt = 0; + uint16_t non_aspect_inc = 0; + uint16_t next_only = 0; + uint16_t always_reserve_through = 0; + uint16_t no_tunnel_bridge = 0; + uint16_t signal_opposite_side = 0; + uint16_t combined_normal_shunt = 0; }; extern SignalStyleMasks _signal_style_masks; @@ -186,9 +186,9 @@ void AddTrackToSignalBuffer(TileIndex tile, Track track, Owner owner); void AddSideToSignalBuffer(TileIndex tile, DiagDirection side, Owner owner); void UpdateSignalsInBuffer(); void UpdateSignalsInBufferIfOwnerNotAddable(Owner owner); -uint8 GetForwardAspectFollowingTrack(TileIndex tile, Trackdir trackdir); -uint8 GetSignalAspectGeneric(TileIndex tile, Trackdir trackdir, bool check_non_inc_style); -void PropagateAspectChange(TileIndex tile, Trackdir trackdir, uint8 aspect); +uint8_t GetForwardAspectFollowingTrack(TileIndex tile, Trackdir trackdir); +uint8_t GetSignalAspectGeneric(TileIndex tile, Trackdir trackdir, bool check_non_inc_style); +void PropagateAspectChange(TileIndex tile, Trackdir trackdir, uint8_t aspect); void UpdateAspectDeferred(TileIndex tile, Trackdir trackdir); void UpdateAspectDeferredWithVehicle(const Train *v, TileIndex tile, Trackdir trackdir, bool check_combined_normal_aspect); void UpdateLookaheadCombinedNormalShuntSignalDeferred(TileIndex tile, Trackdir trackdir, int lookahead_position); @@ -199,20 +199,20 @@ void UpdateExtraAspectsVariable(bool update_always_reserve_through = false); void InitialiseExtraAspectsVariable(); bool IsRailSpecialSignalAspect(TileIndex tile, Track track); -inline void AdjustSignalAspectIfNonIncStyle(TileIndex tile, Track track, uint8 &aspect) +inline void AdjustSignalAspectIfNonIncStyle(TileIndex tile, Track track, uint8_t &aspect) { - extern void AdjustSignalAspectIfNonIncStyleIntl(TileIndex tile, Track track, uint8 &aspect); + extern void AdjustSignalAspectIfNonIncStyleIntl(TileIndex tile, Track track, uint8_t &aspect); if (aspect > 0 && (_signal_style_masks.non_aspect_inc != 0 || _signal_style_masks.combined_normal_shunt != 0)) AdjustSignalAspectIfNonIncStyleIntl(tile, track, aspect); } -inline uint8 IncrementAspectForSignal(uint8 aspect, bool combined_normal_mode) +inline uint8_t IncrementAspectForSignal(uint8_t aspect, bool combined_normal_mode) { - aspect = std::min(aspect + 1, GetMaximumSignalAspect()); - if (combined_normal_mode) aspect = std::min(aspect + 1, 7); + aspect = std::min(aspect + 1, GetMaximumSignalAspect()); + if (combined_normal_mode) aspect = std::min(aspect + 1, 7); return aspect; } -inline uint8 GetForwardAspectFollowingTrackAndIncrement(TileIndex tile, Trackdir trackdir, bool combined_normal_mode = false) +inline uint8_t GetForwardAspectFollowingTrackAndIncrement(TileIndex tile, Trackdir trackdir, bool combined_normal_mode = false) { return IncrementAspectForSignal(GetForwardAspectFollowingTrack(tile, trackdir), combined_normal_mode); } diff --git a/src/signal_type.h b/src/signal_type.h index 10097c7c22..b1ad3f135f 100644 --- a/src/signal_type.h +++ b/src/signal_type.h @@ -23,7 +23,7 @@ enum SignalVariant { /** Type of signal, i.e. how does the signal behave? */ -enum SignalType : uint8 { +enum SignalType : uint8_t { SIGTYPE_NORMAL = 0, ///< normal signal SIGTYPE_ENTRY = 1, ///< presignal block entry SIGTYPE_EXIT = 2, ///< presignal block exit diff --git a/src/signs_base.h b/src/signs_base.h index fe9a22554f..c51c952010 100644 --- a/src/signs_base.h +++ b/src/signs_base.h @@ -23,9 +23,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_cmd.cpp b/src/signs_cmd.cpp index 1dc369a021..e1baa432ab 100644 --- a/src/signs_cmd.cpp +++ b/src/signs_cmd.cpp @@ -36,7 +36,7 @@ SignID _new_sign_id; * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdPlaceSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdPlaceSign(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { /* Try to locate a new sign */ if (!Sign::CanAllocateItem()) return_cmd_error(STR_ERROR_TOO_MANY_SIGNS); @@ -75,7 +75,7 @@ CommandCost CmdPlaceSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 * @param text the new name or an empty string when resetting to the default * @return the cost of this operation or an error */ -CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Sign *si = Sign::GetIfValid(p1); if (si == nullptr) return CMD_ERROR; @@ -116,7 +116,7 @@ CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 * @param p2 unused * @param cmd unused */ -void CcPlaceSign(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcPlaceSign(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index 861427b43b..8d0abe59bc 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -208,7 +208,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 eb29d126c3..1e49c62c1e 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/sl/bridge_signal_sl.cpp b/src/sl/bridge_signal_sl.cpp index 70c66e4546..7ae34e8095 100644 --- a/src/sl/bridge_signal_sl.cpp +++ b/src/sl/bridge_signal_sl.cpp @@ -14,7 +14,7 @@ /** stub save header struct */ struct LongBridgeSignalStorageStub { - uint32 length; + uint32_t length; }; static const SaveLoad _long_bridge_signal_storage_stub_desc[] = { @@ -36,9 +36,9 @@ static void Load_XBSS() static void RealSave_XBSS(const LongBridgeSignalStorage *lbss) { LongBridgeSignalStorageStub stub; - stub.length = (uint32)lbss->signal_red_bits.size(); + stub.length = (uint32_t)lbss->signal_red_bits.size(); SlObject(&stub, _long_bridge_signal_storage_stub_desc); - SlArray(const_cast(lbss->signal_red_bits.data()), stub.length, SLE_UINT64); + SlArray(const_cast(lbss->signal_red_bits.data()), stub.length, SLE_UINT64); } static void Save_XBSS() @@ -52,7 +52,7 @@ static void Save_XBSS() static void Load_XBST() { - size_t count = SlGetFieldLength() / sizeof(uint32); + size_t count = SlGetFieldLength() / sizeof(uint32_t); for (size_t i = 0; i < count; i++) { _bridge_signal_style_map.insert(SlReadUint32()); } @@ -60,8 +60,8 @@ static void Load_XBST() static void Save_XBST() { - SlSetLength(_bridge_signal_style_map.size() * sizeof(uint32)); - for (uint32 val : _bridge_signal_style_map) { + SlSetLength(_bridge_signal_style_map.size() * sizeof(uint32_t)); + for (uint32_t val : _bridge_signal_style_map) { SlWriteUint32(val); } } diff --git a/src/sl/cargomonitor_sl.cpp b/src/sl/cargomonitor_sl.cpp index abb0d59b99..45712abe66 100644 --- a/src/sl/cargomonitor_sl.cpp +++ b/src/sl/cargomonitor_sl.cpp @@ -17,7 +17,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. */ @@ -73,7 +73,7 @@ static void LoadDelivery() 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); } } @@ -111,7 +111,7 @@ static void LoadPickup() 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/sl/cargopacket_sl.cpp b/src/sl/cargopacket_sl.cpp index f3713beea0..40d3edb90a 100644 --- a/src/sl/cargopacket_sl.cpp +++ b/src/sl/cargopacket_sl.cpp @@ -17,7 +17,7 @@ #include "../safeguards.h" -extern btree::btree_map _cargo_packet_deferred_payments; +extern btree::btree_map _cargo_packet_deferred_payments; /** * Savegame conversion for cargopackets. @@ -223,8 +223,8 @@ void Load_CPDP() uint last_cargo_packet_id = std::numeric_limits::max(); for (uint i = 0; i < count; i++) { - uint64 k = SlReadUint64(); - uint64 v = SlReadUint64(); + uint64_t k = SlReadUint64(); + uint64_t v = SlReadUint64(); _cargo_packet_deferred_payments[k] = v; if (k >> 32 != last_cargo_packet_id) { last_cargo_packet_id = k >> 32; diff --git a/src/sl/cheat_sl.cpp b/src/sl/cheat_sl.cpp index 75d4a09a96..aac0fd2b9b 100644 --- a/src/sl/cheat_sl.cpp +++ b/src/sl/cheat_sl.cpp @@ -106,12 +106,12 @@ static void Load_CHTX() CheatsExtLoad current_cheat; - uint32 chunk_flags = SlReadUint32(); + uint32_t chunk_flags = SlReadUint32(); // flags are not in use yet, reserve for future expansion if (chunk_flags != 0) SlErrorCorruptFmt("CHTX chunk: unknown chunk header flags: 0x%X", chunk_flags); - uint32 cheat_count = SlReadUint32(); - for (uint32 i = 0; i < cheat_count; i++) { + uint32_t cheat_count = SlReadUint32(); + for (uint32_t i = 0; i < cheat_count; i++) { SlObject(¤t_cheat, _cheats_ext_load_desc); bool found = false; @@ -148,7 +148,7 @@ static void Save_CHTX() SlAutolength([](void *) { SlWriteUint32(0); // flags - SlWriteUint32((uint32)(lengthof(_extra_cheat_descs) + _unknown_cheats.size())); // cheat count + SlWriteUint32((uint32_t)(lengthof(_extra_cheat_descs) + _unknown_cheats.size())); // cheat count for (uint j = 0; j < lengthof(_extra_cheat_descs); j++) { CheatsExtSave save = { _extra_cheat_descs[j].name, *(_extra_cheat_descs[j].cht) }; @@ -165,9 +165,9 @@ static void Save_CHTX() * Internal structure used in SaveSettingsPatx() and SaveSettingsPlyx() */ struct SettingsExtSave { - uint32 flags; + uint32_t flags; const char *name; - uint32 setting_length; + uint32_t setting_length; }; static const SaveLoad _settings_ext_save_desc[] = { diff --git a/src/sl/company_sl.cpp b/src/sl/company_sl.cpp index 2f91742eb8..9c78f137f5 100644 --- a/src/sl/company_sl.cpp +++ b/src/sl/company_sl.cpp @@ -48,7 +48,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; @@ -365,7 +365,7 @@ static const SaveLoad _company_economy_desc[] = { /* 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; }; static const SaveLoad _company_ai_desc[] = { @@ -584,7 +584,7 @@ static void Load_PLYP() } if (!_network_server) { extern CompanyMask _saved_PLYP_invalid_mask; - extern std::vector _saved_PLYP_data; + extern std::vector _saved_PLYP_data; _saved_PLYP_invalid_mask = invalid_mask; _saved_PLYP_data.resize(size); @@ -592,7 +592,7 @@ static void Load_PLYP() return; } - uint8 token[16]; + uint8_t token[16]; ReadBuffer::GetCurrent()->CopyBytes(token, 16); if (memcmp(token, _network_company_password_storage_token, 16) != 0) { DEBUG(sl, 2, "Skipping encrypted company passwords"); @@ -600,25 +600,25 @@ static void Load_PLYP() return; } - uint8 nonce[24]; - uint8 mac[16]; + uint8_t nonce[24]; + uint8_t mac[16]; ReadBuffer::GetCurrent()->CopyBytes(nonce, 24); ReadBuffer::GetCurrent()->CopyBytes(mac, 16); - std::vector buffer(size - 16 - 24 - 16); + std::vector buffer(size - 16 - 24 - 16); ReadBuffer::GetCurrent()->CopyBytes(buffer.data(), buffer.size()); if (crypto_aead_unlock(buffer.data(), mac, _network_company_password_storage_key, nonce, nullptr, 0, buffer.data(), buffer.size()) == 0) { SlLoadFromBuffer(buffer.data(), buffer.size(), [invalid_mask]() { _network_company_server_id.resize(SlReadUint32()); - ReadBuffer::GetCurrent()->CopyBytes((uint8 *)_network_company_server_id.data(), _network_company_server_id.size()); + ReadBuffer::GetCurrent()->CopyBytes((uint8_t *)_network_company_server_id.data(), _network_company_server_id.size()); while (true) { - uint16 cid = SlReadUint16(); + uint16_t cid = SlReadUint16(); if (cid >= MAX_COMPANIES) break; std::string password; password.resize(SlReadUint32()); - ReadBuffer::GetCurrent()->CopyBytes((uint8 *)password.data(), password.size()); + ReadBuffer::GetCurrent()->CopyBytes((uint8_t *)password.data(), password.size()); if (!HasBit(invalid_mask, cid)) { NetworkServerSetCompanyPassword((CompanyID)cid, password, true); } @@ -640,19 +640,19 @@ static void Save_PLYP() } if (!_network_server) { extern CompanyMask _saved_PLYP_invalid_mask; - extern std::vector _saved_PLYP_data; + extern std::vector _saved_PLYP_data; if (_saved_PLYP_data.empty()) { SlSetLength(0); } else { SlSetLength(2 + _saved_PLYP_data.size()); SlWriteUint16(_saved_PLYP_invalid_mask); - MemoryDumper::GetCurrent()->CopyBytes((const uint8 *)_saved_PLYP_data.data(), _saved_PLYP_data.size()); + MemoryDumper::GetCurrent()->CopyBytes((const uint8_t *)_saved_PLYP_data.data(), _saved_PLYP_data.size()); } return; } - uint8 nonce[24]; /* Use only once per key: random */ + uint8_t nonce[24]; /* Use only once per key: random */ if (randombytes(nonce, 24) < 0) { /* Can't get a random nonce, just give up */ SlSetLength(0); @@ -660,21 +660,21 @@ static void Save_PLYP() } std::vector buffer = SlSaveToVector([]() { - SlWriteUint32((uint32)_network_company_server_id.size()); - MemoryDumper::GetCurrent()->CopyBytes((const uint8 *)_network_company_server_id.data(), _network_company_server_id.size()); + SlWriteUint32((uint32_t)_network_company_server_id.size()); + MemoryDumper::GetCurrent()->CopyBytes((const uint8_t *)_network_company_server_id.data(), _network_company_server_id.size()); for (const Company *c : Company::Iterate()) { SlWriteUint16(c->index); const std::string &password = _network_company_states[c->index].password; - SlWriteUint32((uint32)password.size()); - MemoryDumper::GetCurrent()->CopyBytes((const uint8 *)password.data(), password.size()); + SlWriteUint32((uint32_t)password.size()); + MemoryDumper::GetCurrent()->CopyBytes((const uint8_t *)password.data(), password.size()); } SlWriteUint16(0xFFFF); /* Add some random length padding to not make it too obvious from the length whether passwords are set or not */ - uint8 padding[256]; + uint8_t padding[256]; if (randombytes(padding, 256) >= 0) { SlWriteByte(padding[0]); MemoryDumper::GetCurrent()->CopyBytes(padding + 1, padding[0]); @@ -684,7 +684,7 @@ static void Save_PLYP() }); - uint8 mac[16]; /* Message authentication code */ + uint8_t mac[16]; /* Message authentication code */ /* Encrypt in place */ crypto_aead_lock(buffer.data(), mac, _network_company_password_storage_key, nonce, nullptr, 0, buffer.data(), buffer.size()); diff --git a/src/sl/economy_sl.cpp b/src/sl/economy_sl.cpp index 6cc2a8629b..1c76a5fdce 100644 --- a/src/sl/economy_sl.cpp +++ b/src/sl/economy_sl.cpp @@ -18,7 +18,7 @@ /** Prices in pre 126 savegames */ static void Load_PRIC() { - /* 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; SlArray(nullptr, 49, vt | SLE_VAR_NULL); SlArray(nullptr, 49, SLE_FILE_U16 | SLE_VAR_NULL); diff --git a/src/sl/engine_sl.cpp b/src/sl/engine_sl.cpp index 9f1eebefe7..72e6672210 100644 --- a/src/sl/engine_sl.cpp +++ b/src/sl/engine_sl.cpp @@ -54,7 +54,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/sl/extended_ver_sl.cpp b/src/sl/extended_ver_sl.cpp index e48ded96b9..2e23640c2d 100644 --- a/src/sl/extended_ver_sl.cpp +++ b/src/sl/extended_ver_sl.cpp @@ -13,17 +13,17 @@ * chunk IDs which are associated with an extended feature, these can be discarded if the feature is discarded. * This information is stored in the SLXI chunk, the contents of which has the following format: * - * uint32 chunk version - * uint32 chunk flags - * uint32 number of sub chunks/features + * uint32_t chunk version + * uint32_t chunk flags + * uint32_t number of sub chunks/features * For each of N sub chunk/feature: - * uint32 feature flags (SlxiSubChunkFlags) - * uint16 feature version + * uint32_t feature flags (SlxiSubChunkFlags) + * uint16_t feature version * SLE_STR feature name - * uint32* extra data length [only present iff feature flags & XSCF_EXTRA_DATA_PRESENT] + * uint32_t* extra data length [only present iff feature flags & XSCF_EXTRA_DATA_PRESENT] * N bytes extra data - * uint32* chunk ID list count [only present iff feature flags & XSCF_CHUNK_ID_LIST_PRESENT] - * N x uint32 chunk ID list + * uint32_t* chunk ID list count [only present iff feature flags & XSCF_CHUNK_ID_LIST_PRESENT] + * N x uint32_t chunk ID list * * Extended features as recorded in the SLXI chunk, above, MAY add, remove, change, or otherwise modify fields in chunks * not owned by the feature and therefore not listed in the sub chunk/feature information in the SLXI chunk. @@ -51,27 +51,27 @@ #include "../safeguards.h" -std::array _sl_xv_feature_versions; ///< array of all known feature types and their current versions -std::array _sl_xv_feature_static_versions; ///< array of all known feature types and their static current version versions -bool _sl_is_ext_version; ///< is this an extended savegame version, with more info in the SLXI chunk? -bool _sl_is_faked_ext; ///< is this a faked extended savegame version, with no SLXI chunk? See: SlXvCheckSpecialSavegameVersions. -bool _sl_maybe_springpp; ///< is this possibly a SpringPP savegame? -bool _sl_maybe_chillpp; ///< is this possibly a ChillPP v8 savegame? -bool _sl_upstream_mode; ///< load game using upstream loader -std::vector _sl_xv_discardable_chunk_ids; ///< list of chunks IDs which we can discard if no chunk loader exists -std::string _sl_xv_version_label; ///< optional SLXI version label -SaveLoadVersion _sl_xv_upstream_version; ///< optional SLXI upstream version - -static const uint32 _sl_xv_slxi_chunk_version = 0; ///< current version of SLXI chunk - -static void loadVL(const SlxiSubChunkInfo *info, uint32 length); -static uint32 saveVL(const SlxiSubChunkInfo *info, bool dry_run); -static void loadUV(const SlxiSubChunkInfo *info, uint32 length); -static uint32 saveUV(const SlxiSubChunkInfo *info, bool dry_run); -static void loadLC(const SlxiSubChunkInfo *info, uint32 length); -static uint32 saveLC(const SlxiSubChunkInfo *info, bool dry_run); -static void loadSTC(const SlxiSubChunkInfo *info, uint32 length); -static uint32 saveSTC(const SlxiSubChunkInfo *info, bool dry_run); +std::array _sl_xv_feature_versions; ///< array of all known feature types and their current versions +std::array _sl_xv_feature_static_versions; ///< array of all known feature types and their static current version versions +bool _sl_is_ext_version; ///< is this an extended savegame version, with more info in the SLXI chunk? +bool _sl_is_faked_ext; ///< is this a faked extended savegame version, with no SLXI chunk? See: SlXvCheckSpecialSavegameVersions. +bool _sl_maybe_springpp; ///< is this possibly a SpringPP savegame? +bool _sl_maybe_chillpp; ///< is this possibly a ChillPP v8 savegame? +bool _sl_upstream_mode; ///< load game using upstream loader +std::vector _sl_xv_discardable_chunk_ids; ///< list of chunks IDs which we can discard if no chunk loader exists +std::string _sl_xv_version_label; ///< optional SLXI version label +SaveLoadVersion _sl_xv_upstream_version; ///< optional SLXI upstream version + +static const uint32_t _sl_xv_slxi_chunk_version = 0; ///< current version of SLXI chunk + +static void loadVL(const SlxiSubChunkInfo *info, uint32_t length); +static uint32_t saveVL(const SlxiSubChunkInfo *info, bool dry_run); +static void loadUV(const SlxiSubChunkInfo *info, uint32_t length); +static uint32_t saveUV(const SlxiSubChunkInfo *info, bool dry_run); +static void loadLC(const SlxiSubChunkInfo *info, uint32_t length); +static uint32_t saveLC(const SlxiSubChunkInfo *info, bool dry_run); +static void loadSTC(const SlxiSubChunkInfo *info, uint32_t length); +static uint32_t saveSTC(const SlxiSubChunkInfo *info, bool dry_run); const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = { { XSLFI_VERSION_LABEL, XSCF_IGNORABLE_ALL, 1, 1, "version_label", saveVL, loadVL, nullptr }, @@ -222,7 +222,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = { * and return the combination of the two tests using the operator defined in the constructor. * Otherwise just returns the result of the savegame version test */ -bool SlXvFeatureTest::IsFeaturePresent(const std::array &feature_versions, SaveLoadVersion savegame_version, SaveLoadVersion savegame_version_from, SaveLoadVersion savegame_version_to) const +bool SlXvFeatureTest::IsFeaturePresent(const std::array &feature_versions, SaveLoadVersion savegame_version, SaveLoadVersion savegame_version_from, SaveLoadVersion savegame_version_to) const { bool savegame_version_ok = savegame_version >= savegame_version_from && savegame_version < savegame_version_to; @@ -248,7 +248,7 @@ bool SlXvFeatureTest::IsFeaturePresent(const std::array &fea /** * Returns true if @p feature is present and has a version inclusively bounded by @p min_version and @p max_version */ -bool SlXvIsFeaturePresent(const std::array &feature_versions, SlXvFeatureIndex feature, uint16 min_version, uint16 max_version) +bool SlXvIsFeaturePresent(const std::array &feature_versions, SlXvFeatureIndex feature, uint16_t min_version, uint16_t max_version) { assert(feature < XSLFI_SIZE); return feature_versions[feature] >= min_version && feature_versions[feature] <= max_version; @@ -498,7 +498,7 @@ void SlXvChillPPSpecialSavegameVersions() /** * Return true if this chunk has been marked as discardable */ -bool SlXvIsChunkDiscardable(uint32 id) +bool SlXvIsChunkDiscardable(uint32_t id) { for (size_t i = 0; i < _sl_xv_discardable_chunk_ids.size(); i++) { if (_sl_xv_discardable_chunk_ids[i] == id) { @@ -512,7 +512,7 @@ bool SlXvIsChunkDiscardable(uint32 id) * Writes a chunk ID list string to the savegame, returns the number of chunks written * In dry run mode, only returns the number of chunk which would have been written */ -static uint32 WriteChunkIdList(const char *chunk_list, bool dry_run) +static uint32_t WriteChunkIdList(const char *chunk_list, bool dry_run) { unsigned int chunk_count = 0; // number of chunks output unsigned int id_offset = 0; // how far are we into the ID @@ -543,10 +543,10 @@ static void Save_SLXI() }; // calculate lengths - uint32 item_count = 0; - uint32 length = 12; - std::vector extra_data_lengths; - std::vector chunk_counts; + uint32_t item_count = 0; + uint32_t length = 12; + std::vector extra_data_lengths; + std::vector chunk_counts; extra_data_lengths.resize(XSLFI_SIZE); chunk_counts.resize(XSLFI_SIZE); const SlxiSubChunkInfo *info = _sl_xv_sub_chunk_infos; @@ -554,16 +554,16 @@ static void Save_SLXI() if (_sl_xv_feature_versions[info->index] > 0) { item_count++; length += 6; - length += (uint32)SlCalcObjLength(info, _xlsi_sub_chunk_desc); + length += (uint32_t)SlCalcObjLength(info, _xlsi_sub_chunk_desc); if (info->save_proc) { - uint32 extra_data_length = info->save_proc(info, true); + uint32_t extra_data_length = info->save_proc(info, true); if (extra_data_length) { extra_data_lengths[info->index] = extra_data_length; length += 4 + extra_data_length; } } if (info->chunk_list) { - uint32 chunk_count = WriteChunkIdList(info->chunk_list, true); + uint32_t chunk_count = WriteChunkIdList(info->chunk_list, true); if (chunk_count) { chunk_counts[info->index] = chunk_count; length += 4 * (1 + chunk_count); @@ -581,12 +581,12 @@ static void Save_SLXI() // write data info = _sl_xv_sub_chunk_infos; for (; info->index != XSLFI_NULL; ++info) { - uint16 save_version = _sl_xv_feature_versions[info->index]; + uint16_t save_version = _sl_xv_feature_versions[info->index]; if (save_version > 0) { SlxiSubChunkFlags flags = info->flags; assert(!(flags & (XSCF_EXTRA_DATA_PRESENT | XSCF_CHUNK_ID_LIST_PRESENT))); - uint32 extra_data_length = extra_data_lengths[info->index]; - uint32 chunk_count = chunk_counts[info->index]; + uint32_t extra_data_length = extra_data_lengths[info->index]; + uint32_t chunk_count = chunk_counts[info->index]; if (extra_data_length > 0) flags |= XSCF_EXTRA_DATA_PRESENT; if (chunk_count > 0) flags |= XSCF_CHUNK_ID_LIST_PRESENT; SlWriteUint32(flags); @@ -618,10 +618,10 @@ static void Load_SLXI() SlXvResetState(); _sl_is_ext_version = true; - uint32 version = SlReadUint32(); + uint32_t version = SlReadUint32(); if (version > _sl_xv_slxi_chunk_version) SlErrorCorruptFmt("SLXI chunk: version: %u is too new (expected max: %u)", version, _sl_xv_slxi_chunk_version); - uint32 chunk_flags = SlReadUint32(); + uint32_t chunk_flags = SlReadUint32(); // flags are not in use yet, reserve for future expansion if (chunk_flags != 0) SlErrorCorruptFmt("SLXI chunk: unknown chunk header flags: 0x%X", chunk_flags); @@ -630,15 +630,15 @@ static void Load_SLXI() SLEG_STR(name_buffer, SLE_STRB), }; - auto version_error = [](StringID str, const char *feature, int64 p1, int64 p2) { + auto version_error = [](StringID str, const char *feature, int64_t p1, int64_t p2) { auto tmp_params = MakeParameters(_sl_xv_version_label.empty() ? STR_EMPTY : STR_GAME_SAVELOAD_FROM_VERSION, _sl_xv_version_label, feature, p1, p2); SlError(STR_JUST_RAW_STRING, GetStringWithArgs(str, tmp_params)); }; - uint32 item_count = SlReadUint32(); - for (uint32 i = 0; i < item_count; i++) { + uint32_t item_count = SlReadUint32(); + for (uint32_t i = 0; i < item_count; i++) { SlxiSubChunkFlags flags = static_cast(SlReadUint32()); - uint16 version = SlReadUint16(); + uint16_t version = SlReadUint16(); SlGlobList(xlsi_sub_chunk_name_desc); // linearly scan through feature list until found name match @@ -669,7 +669,7 @@ static void Load_SLXI() _sl_xv_feature_versions[info->index] = version; if (flags & XSCF_EXTRA_DATA_PRESENT) { - uint32 extra_data_size = SlReadUint32(); + uint32_t extra_data_size = SlReadUint32(); if (extra_data_size) { if (info->load_proc) { size_t read = SlGetBytesRead(); @@ -701,9 +701,9 @@ static void Load_SLXI() // at this point the extra data field should have been consumed // handle chunk ID list field if (flags & XSCF_CHUNK_ID_LIST_PRESENT) { - uint32 chunk_count = SlReadUint32(); - for (uint32 j = 0; j < chunk_count; j++) { - uint32 chunk_id = SlReadUint32(); + uint32_t chunk_count = SlReadUint32(); + for (uint32_t j = 0; j < chunk_count; j++) { + uint32_t chunk_id = SlReadUint32(); if (discard_chunks) { _sl_xv_discardable_chunk_ids.push_back(chunk_id); DEBUG(sl, 2, "SLXI chunk: unknown feature: '%s', discarding chunk: %c%c%c%c", name_buffer, chunk_id >> 24, chunk_id >> 16, chunk_id >> 8, chunk_id); @@ -713,27 +713,27 @@ static void Load_SLXI() } } -static void IgnoreWrongLengthExtraData(const SlxiSubChunkInfo *info, uint32 length) +static void IgnoreWrongLengthExtraData(const SlxiSubChunkInfo *info, uint32_t length) { DEBUG(sl, 1, "SLXI chunk: feature: '%s', version: %d, has data of wrong length: %u", info->name, _sl_xv_feature_versions[info->index], length); ReadBuffer::GetCurrent()->SkipBytes(length); } -static void loadVL(const SlxiSubChunkInfo *info, uint32 length) +static void loadVL(const SlxiSubChunkInfo *info, uint32_t length) { _sl_xv_version_label.resize(length); ReadBuffer::GetCurrent()->CopyBytes(reinterpret_cast(_sl_xv_version_label.data()), length); DEBUG(sl, 2, "SLXI version label: %s", _sl_xv_version_label.c_str()); } -static uint32 saveVL(const SlxiSubChunkInfo *info, bool dry_run) +static uint32_t saveVL(const SlxiSubChunkInfo *info, bool dry_run) { const size_t length = strlen(_openttd_revision); if (!dry_run) MemoryDumper::GetCurrent()->CopyBytes(reinterpret_cast(_openttd_revision), length); - return static_cast(length); + return static_cast(length); } -static void loadUV(const SlxiSubChunkInfo *info, uint32 length) +static void loadUV(const SlxiSubChunkInfo *info, uint32_t length) { if (length == 2) { _sl_xv_upstream_version = (SaveLoadVersion)SlReadUint16(); @@ -743,13 +743,13 @@ static void loadUV(const SlxiSubChunkInfo *info, uint32 length) } } -static uint32 saveUV(const SlxiSubChunkInfo *info, bool dry_run) +static uint32_t saveUV(const SlxiSubChunkInfo *info, bool dry_run) { if (!dry_run) SlWriteUint16(SL_MAX_VERSION - 1); return 2; } -static void loadLC(const SlxiSubChunkInfo *info, uint32 length) +static void loadLC(const SlxiSubChunkInfo *info, uint32_t length) { if (length == 1) { _loaded_local_company = (CompanyID) ReadBuffer::GetCurrent()->ReadByte(); @@ -758,15 +758,15 @@ static void loadLC(const SlxiSubChunkInfo *info, uint32 length) } } -static uint32 saveLC(const SlxiSubChunkInfo *info, bool dry_run) +static uint32_t saveLC(const SlxiSubChunkInfo *info, bool dry_run) { if (!dry_run) MemoryDumper::GetCurrent()->WriteByte(_local_company); return 1; } -static void loadSTC(const SlxiSubChunkInfo *info, uint32 length) +static void loadSTC(const SlxiSubChunkInfo *info, uint32_t length) { - extern uint64 _station_tile_cache_hash; + extern uint64_t _station_tile_cache_hash; if (length == 8) { _station_tile_cache_hash = SlReadUint64(); } else { @@ -774,9 +774,9 @@ static void loadSTC(const SlxiSubChunkInfo *info, uint32 length) } } -static uint32 saveSTC(const SlxiSubChunkInfo *info, bool dry_run) +static uint32_t saveSTC(const SlxiSubChunkInfo *info, bool dry_run) { - extern uint64 _station_tile_cache_hash; + extern uint64_t _station_tile_cache_hash; if (!dry_run) SlWriteUint64(_station_tile_cache_hash); return 8; } diff --git a/src/sl/extended_ver_sl.h b/src/sl/extended_ver_sl.h index d21334940a..82c828f71c 100644 --- a/src/sl/extended_ver_sl.h +++ b/src/sl/extended_ver_sl.h @@ -16,7 +16,7 @@ #include #include -enum SaveLoadVersion : uint16; +enum SaveLoadVersion : uint16_t; /** * List of extended features, each feature has its own (16 bit) version @@ -173,8 +173,8 @@ enum SlXvFeatureIndex { XSLFI_SIZE, ///< Total count of features, including null feature }; -extern std::array _sl_xv_feature_versions; -extern std::array _sl_xv_feature_static_versions; +extern std::array _sl_xv_feature_versions; +extern std::array _sl_xv_feature_static_versions; /** * Operator to use when combining traditional savegame number test with an extended feature version test @@ -188,11 +188,11 @@ enum SlXvFeatureTestOperator { * Structure to describe an extended feature version test, and how it combines with a traditional savegame version test */ struct SlXvFeatureTest { - using TestFunctorPtr = bool (*)(uint16, bool, const std::array &); ///< Return true if feature present, first parameter is standard savegame version, second is whether standard savegame version is within bounds + using TestFunctorPtr = bool (*)(uint16_t, bool, const std::array &); ///< Return true if feature present, first parameter is standard savegame version, second is whether standard savegame version is within bounds private: - uint16 min_version; - uint16 max_version; + uint16_t min_version; + uint16_t max_version; SlXvFeatureIndex feature; SlXvFeatureTestOperator op; TestFunctorPtr functor = nullptr; @@ -201,13 +201,13 @@ public: SlXvFeatureTest() : min_version(0), max_version(0), feature(XSLFI_NULL), op(XSLFTO_OR) { } - SlXvFeatureTest(SlXvFeatureTestOperator op_, SlXvFeatureIndex feature_, uint16 min_version_ = 1, uint16 max_version_ = 0xFFFF) + SlXvFeatureTest(SlXvFeatureTestOperator op_, SlXvFeatureIndex feature_, uint16_t min_version_ = 1, uint16_t max_version_ = 0xFFFF) : min_version(min_version_), max_version(max_version_), feature(feature_), op(op_) { } SlXvFeatureTest(TestFunctorPtr functor_) : min_version(0), max_version(0), feature(XSLFI_NULL), op(XSLFTO_OR), functor(functor_) { } - bool IsFeaturePresent(const std::array &feature_versions, SaveLoadVersion savegame_version, SaveLoadVersion savegame_version_from, SaveLoadVersion savegame_version_to) const; + bool IsFeaturePresent(const std::array &feature_versions, SaveLoadVersion savegame_version, SaveLoadVersion savegame_version_from, SaveLoadVersion savegame_version_to) const; inline bool IsFeaturePresent(SaveLoadVersion savegame_version, SaveLoadVersion savegame_version_from, SaveLoadVersion savegame_version_to) const { @@ -215,9 +215,9 @@ public: } }; -bool SlXvIsFeaturePresent(const std::array &feature_versions, SlXvFeatureIndex feature, uint16 min_version = 1, uint16 max_version = 0xFFFF); +bool SlXvIsFeaturePresent(const std::array &feature_versions, SlXvFeatureIndex feature, uint16_t min_version = 1, uint16_t max_version = 0xFFFF); -inline bool SlXvIsFeaturePresent(SlXvFeatureIndex feature, uint16 min_version = 1, uint16 max_version = 0xFFFF) +inline bool SlXvIsFeaturePresent(SlXvFeatureIndex feature, uint16_t min_version = 1, uint16_t max_version = 0xFFFF) { return SlXvIsFeaturePresent(_sl_xv_feature_versions, feature, min_version, max_version); } @@ -225,7 +225,7 @@ inline bool SlXvIsFeaturePresent(SlXvFeatureIndex feature, uint16 min_version = /** * Returns true if @p feature is missing (i.e. has a version of 0, or less than the specified minimum version) */ -inline bool SlXvIsFeatureMissing(SlXvFeatureIndex feature, uint16 min_version = 1) +inline bool SlXvIsFeatureMissing(SlXvFeatureIndex feature, uint16_t min_version = 1) { return !SlXvIsFeaturePresent(feature, min_version); } @@ -233,7 +233,7 @@ inline bool SlXvIsFeatureMissing(SlXvFeatureIndex feature, uint16 min_version = /** * Returns true if @p feature is missing (i.e. has a version of 0, or less than the specified minimum version) */ -inline bool SlXvIsFeatureMissing(const std::array &feature_versions, SlXvFeatureIndex feature, uint16 min_version = 1) +inline bool SlXvIsFeatureMissing(const std::array &feature_versions, SlXvFeatureIndex feature, uint16_t min_version = 1) { return !SlXvIsFeaturePresent(feature_versions, feature, min_version); } @@ -257,15 +257,15 @@ DECLARE_ENUM_AS_BIT_SET(SlxiSubChunkFlags) struct SlxiSubChunkInfo; -typedef uint32 SlxiSubChunkSaveProc(const SlxiSubChunkInfo *info, bool dry_run); ///< sub chunk save procedure type, must return length and write no data when dry_run is true -typedef void SlxiSubChunkLoadProc(const SlxiSubChunkInfo *info, uint32 length); ///< sub chunk load procedure, must consume length bytes +typedef uint32_t SlxiSubChunkSaveProc(const SlxiSubChunkInfo *info, bool dry_run); ///< sub chunk save procedure type, must return length and write no data when dry_run is true +typedef void SlxiSubChunkLoadProc(const SlxiSubChunkInfo *info, uint32_t length); ///< sub chunk load procedure, must consume length bytes /** Handlers and description of chunk. */ struct SlxiSubChunkInfo { SlXvFeatureIndex index; ///< feature index, this is saved SlxiSubChunkFlags flags; ///< flags, this is saved - uint16 save_version; ///< version to save - uint16 max_version; ///< maximum version to accept on load + uint16_t save_version; ///< version to save + uint16_t max_version; ///< maximum version to accept on load const char *name; ///< feature name, this *IS* saved, so must be globally unique SlxiSubChunkSaveProc *save_proc; ///< save procedure of the sub chunk, this may be nullptr in which case no extra chunk data is saved SlxiSubChunkLoadProc *load_proc; ///< load procedure of the sub chunk, this may be nullptr in which case the extra chunk data must be missing or of 0 length @@ -279,6 +279,6 @@ void SlXvSetStaticCurrentVersions(); bool SlXvCheckSpecialSavegameVersions(); -bool SlXvIsChunkDiscardable(uint32 id); +bool SlXvIsChunkDiscardable(uint32_t id); #endif /* SL_EXTENDED_VER_SL_H */ diff --git a/src/sl/labelmaps_sl.cpp b/src/sl/labelmaps_sl.cpp index cc6f8344cd..3d4fda1cfc 100644 --- a/src/sl/labelmaps_sl.cpp +++ b/src/sl/labelmaps_sl.cpp @@ -99,7 +99,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/sl/linkgraph_sl.cpp b/src/sl/linkgraph_sl.cpp index 9368dd38bd..b46ab558ab 100644 --- a/src/sl/linkgraph_sl.cpp +++ b/src/sl/linkgraph_sl.cpp @@ -20,7 +20,7 @@ typedef LinkGraph::BaseNode Node; typedef LinkGraph::BaseEdge Edge; -static uint16 _num_nodes; +static uint16_t _num_nodes; /** * Get a SaveLoad array for a link graph. @@ -153,7 +153,7 @@ static void FilterDescs() */ void Save_LinkGraph(LinkGraph &lg) { - uint16 size = lg.Size(); + uint16_t size = lg.Size(); auto edge_iter = lg.edges.begin(); auto edge_end = lg.edges.end(); for (NodeID from = 0; from < size; ++from) { diff --git a/src/sl/map_sl.cpp b/src/sl/map_sl.cpp index 80d8771fd9..dde10ba351 100644 --- a/src/sl/map_sl.cpp +++ b/src/sl/map_sl.cpp @@ -21,8 +21,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; extern bool _sl_maybe_chillpp; @@ -88,7 +88,7 @@ static void Load_MAPH() if (SlXvIsFeaturePresent(XSLFI_CHILLPP)) { if (SlGetFieldLength() != 0) { _sl_xv_feature_versions[XSLFI_HEIGHT_8_BIT] = 2; - std::array buf; + std::array buf; TileIndex size = MapSize(); for (TileIndex i = 0; i != size;) { @@ -121,7 +121,7 @@ static void Load_MAP1() static void Load_MAP2() { - std::array buf; + std::array buf; TileIndex size = MapSize(); for (TileIndex i = 0; i != size;) { @@ -203,7 +203,7 @@ static void Load_MAP7() static void Load_MAP8() { - std::array buf; + std::array buf; TileIndex size = MapSize(); for (TileIndex i = 0; i != size;) { @@ -228,8 +228,8 @@ static void Load_WMAP() reader->CheckBytes(8); _m[i].type = reader->RawReadByte(); _m[i].height = reader->RawReadByte(); - uint16 m2 = reader->RawReadByte(); - m2 |= ((uint16) reader->RawReadByte()) << 8; + uint16_t m2 = reader->RawReadByte(); + m2 |= ((uint16_t) reader->RawReadByte()) << 8; _m[i].m2 = m2; _m[i].m1 = reader->RawReadByte(); _m[i].m3 = reader->RawReadByte(); @@ -252,8 +252,8 @@ static void Load_WMAP() reader->CheckBytes(4); _me[i].m6 = reader->RawReadByte(); _me[i].m7 = reader->RawReadByte(); - uint16 m8 = reader->RawReadByte(); - m8 |= ((uint16) reader->RawReadByte()) << 8; + uint16_t m8 = reader->RawReadByte(); + m8 |= ((uint16_t) reader->RawReadByte()) << 8; _me[i].m8 = m8; } #endif @@ -298,52 +298,52 @@ static void Save_WMAP() } struct MAPT { - typedef uint8 FieldT; + typedef uint8_t FieldT; static const FieldT &GetField(TileIndex t) { return _m[t].type; } }; struct MAPH { - typedef uint8 FieldT; + typedef uint8_t FieldT; static const FieldT &GetField(TileIndex t) { return _m[t].height; } }; struct MAP1 { - typedef uint8 FieldT; + typedef uint8_t FieldT; static const FieldT &GetField(TileIndex t) { return _m[t].m1; } }; struct MAP2 { - typedef uint16 FieldT; + typedef uint16_t FieldT; static const FieldT &GetField(TileIndex t) { return _m[t].m2; } }; struct MAP3 { - typedef uint8 FieldT; + typedef uint8_t FieldT; static const FieldT &GetField(TileIndex t) { return _m[t].m3; } }; struct MAP4 { - typedef uint8 FieldT; + typedef uint8_t FieldT; static const FieldT &GetField(TileIndex t) { return _m[t].m4; } }; struct MAP5 { - typedef uint8 FieldT; + typedef uint8_t FieldT; static const FieldT &GetField(TileIndex t) { return _m[t].m5; } }; struct MAP6 { - typedef uint8 FieldT; + typedef uint8_t FieldT; static const FieldT &GetField(TileIndex t) { return _me[t].m6; } }; struct MAP7 { - typedef uint8 FieldT; + typedef uint8_t FieldT; static const FieldT &GetField(TileIndex t) { return _me[t].m7; } }; struct MAP8 { - typedef uint16 FieldT; + typedef uint16_t FieldT; static const FieldT &GetField(TileIndex t) { return _me[t].m8; } }; @@ -351,13 +351,13 @@ template struct MAP_VarType {}; template <> -struct MAP_VarType +struct MAP_VarType { static const VarType var_type = SLE_UINT8; }; template <> -struct MAP_VarType +struct MAP_VarType { static const VarType var_type = SLE_UINT16; }; @@ -377,7 +377,7 @@ static void Save_MAP() } } -static ChunkSaveLoadSpecialOpResult Special_WMAP(uint32 chunk_id, ChunkSaveLoadSpecialOp op) +static ChunkSaveLoadSpecialOpResult Special_WMAP(uint32_t chunk_id, ChunkSaveLoadSpecialOp op) { switch (op) { case CSLSO_SHOULD_SAVE_CHUNK: @@ -390,7 +390,7 @@ static ChunkSaveLoadSpecialOpResult Special_WMAP(uint32 chunk_id, ChunkSaveLoadS return CSLSOR_NONE; } -static ChunkSaveLoadSpecialOpResult Special_MAP_Chunks(uint32 chunk_id, ChunkSaveLoadSpecialOp op) +static ChunkSaveLoadSpecialOpResult Special_MAP_Chunks(uint32_t chunk_id, ChunkSaveLoadSpecialOp op) { switch (op) { case CSLSO_SHOULD_SAVE_CHUNK: diff --git a/src/sl/misc_sl.cpp b/src/sl/misc_sl.cpp index e0860f5189..8592284850 100644 --- a/src/sl/misc_sl.cpp +++ b/src/sl/misc_sl.cpp @@ -29,9 +29,9 @@ extern TileIndex _cur_tileloop_tile; extern TileIndex _aux_tileloop_tile; -extern uint16 _disaster_delay; +extern uint16_t _disaster_delay; extern byte _trees_tick_ctr; -extern uint64 _aspect_cfg_hash; +extern uint64_t _aspect_cfg_hash; extern std::string _savegame_id; /* Keep track of current game position */ diff --git a/src/sl/oldloader.cpp b/src/sl/oldloader.cpp index 376ba2e060..ecb470d420 100644 --- a/src/sl/oldloader.cpp +++ b/src/sl/oldloader.cpp @@ -26,7 +26,7 @@ static const int TTO_HEADER_SIZE = 41; static const int TTD_HEADER_SIZE = 49; -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);} @@ -82,7 +82,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 */ @@ -139,15 +139,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(); } @@ -160,14 +160,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(); } @@ -211,7 +211,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 - 2; i++) { sum += title[i]; sum = ROL(sum, 1); @@ -219,7 +219,7 @@ static bool VerifyOldNameChecksum(char *title, uint len) sum ^= 0xAAAA; // computed checksum - uint16 sum2 = title[len - 2]; // checksum in file + uint16_t sum2 = title[len - 2]; // checksum in file SB(sum2, 8, 8, title[len - 1]); return sum == sum2; diff --git a/src/sl/oldloader.h b/src/sl/oldloader.h index 78b5e0cc25..62e08d7dad 100644 --- a/src/sl/oldloader.h +++ b/src/sl/oldloader.h @@ -85,7 +85,7 @@ typedef bool OldChunkProc(LoadgameState *ls, int num); 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 (may only be set if offset is 0) uint offset; ///< Offset from basepointer (may only be set if ptr is nullptr) @@ -110,7 +110,7 @@ inline uint16_t ReadUint16(LoadgameState *ls) inline uint32_t ReadUint32(LoadgameState *ls) { - uint16 x = ReadUint16(ls); + uint16_t x = ReadUint16(ls); return x | ReadUint16(ls) << 16; } diff --git a/src/sl/oldloader_sl.cpp b/src/sl/oldloader_sl.cpp index 664570d59b..94a41a46e3 100644 --- a/src/sl/oldloader_sl.cpp +++ b/src/sl/oldloader_sl.cpp @@ -41,10 +41,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() { @@ -120,7 +120,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 @@ -491,9 +491,9 @@ static inline uint RemapOrderIndex(uint x) 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() { @@ -610,7 +610,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() @@ -678,9 +678,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 ), @@ -856,7 +856,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 ), @@ -1023,8 +1023,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[] = { @@ -1124,7 +1124,7 @@ static bool LoadOldVehicleUnion(LoadgameState *ls, int) return res; } -static uint16 _cargo_count; +static uint16_t _cargo_count; static const OldChunks vehicle_chunk[] = { OCL_SVAR( OC_UINT8, Vehicle, subtype ), @@ -1524,8 +1524,8 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int) DEBUG(oldloader, 2, "Found %d 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 @@ -1537,7 +1537,7 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int) 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"); @@ -1574,11 +1574,11 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int) } 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/sl/order_sl.cpp b/src/sl/order_sl.cpp index 90bf42c10f..45756e7e47 100644 --- a/src/sl/order_sl.cpp +++ b/src/sl/order_sl.cpp @@ -16,12 +16,12 @@ #include "../safeguards.h" -static uint32 _jokerpp_separation_mode; +static uint32_t _jokerpp_separation_mode; std::vector _jokerpp_auto_separation; std::vector _jokerpp_non_auto_separation; -static uint16 _old_scheduled_dispatch_start_full_date_fract; -btree::btree_map _old_scheduled_dispatch_start_full_date_fract_map; +static uint16_t _old_scheduled_dispatch_start_full_date_fract; +btree::btree_map _old_scheduled_dispatch_start_full_date_fract_map; /** * Converts this order from an old savegame's version; @@ -29,7 +29,7 @@ btree::btree_map _old_scheduled_dispatch_start_full_ */ 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 */ @@ -83,9 +83,9 @@ void Order::ConvertFromOldSavegame() * @param packed packed order * @return unpacked order */ -static Order UnpackVersion4Order(uint16 packed) +static Order UnpackVersion4Order(uint16_t packed) { - return Order(((uint64) GB(packed, 8, 8)) << 24 | ((uint64) GB(packed, 4, 4)) << 8 | ((uint64) GB(packed, 0, 4))); + return Order(((uint64_t) GB(packed, 8, 8)) << 24 | ((uint64_t) GB(packed, 4, 4)) << 8 | ((uint64_t) GB(packed, 0, 4))); } /** @@ -93,9 +93,9 @@ static Order UnpackVersion4Order(uint16 packed) * @param packed packed order * @return unpacked order */ -static Order UnpackVersion5Order(uint32 packed) +static Order UnpackVersion5Order(uint32_t packed) { - return Order(((uint64) GB(packed, 16, 16)) << 24 | ((uint64) GB(packed, 8, 8)) << 8 | ((uint64) GB(packed, 0, 8))); + return Order(((uint64_t) GB(packed, 16, 16)) << 24 | ((uint64_t) GB(packed, 8, 8)) << 8 | ((uint64_t) GB(packed, 0, 8))); } /** @@ -103,7 +103,7 @@ static Order UnpackVersion5Order(uint32 packed) * @param packed packed order * @return unpacked order */ -Order UnpackOldOrder(uint16 packed) +Order UnpackOldOrder(uint16_t packed) { Order order = UnpackVersion4Order(packed); @@ -163,9 +163,9 @@ static void Load_ORDR() if (IsSavegameVersionBefore(SLV_5)) { /* Pre-version 5 had another layout for orders - * (uint16 instead of uint32) */ - len /= sizeof(uint16); - uint16 *orders = MallocT(len + 1); + * (uint16_t instead of uint32_t) */ + len /= sizeof(uint16_t); + uint16_t *orders = MallocT(len + 1); SlArray(orders, len, SLE_UINT16); @@ -176,8 +176,8 @@ static void Load_ORDR() free(orders); } else if (IsSavegameVersionBefore(SLV_5, 2)) { - len /= sizeof(uint32); - uint32 *orders = MallocT(len + 1); + len /= sizeof(uint32_t); + uint32_t *orders = MallocT(len + 1); SlArray(orders, len, SLE_UINT32); diff --git a/src/sl/plans_sl.cpp b/src/sl/plans_sl.cpp index 6af13c120f..d1ad20c0c0 100644 --- a/src/sl/plans_sl.cpp +++ b/src/sl/plans_sl.cpp @@ -27,10 +27,10 @@ static const SaveLoad _plan_desc[] = { static void RealSave_PLAN(Plan *p) { SlObject(p, _plan_desc); - SlWriteUint32((uint32)p->lines.size()); + SlWriteUint32((uint32_t)p->lines.size()); for (size_t i = 0; i < p->lines.size(); i++) { PlanLine *pl = p->lines[i]; - SlWriteUint32((uint32)pl->tiles.size()); + SlWriteUint32((uint32_t)pl->tiles.size()); SlArray(pl->tiles.data(), pl->tiles.size(), SLE_UINT32); } } diff --git a/src/sl/saveload.cpp b/src/sl/saveload.cpp index bda9dcc8ca..2713dc985a 100644 --- a/src/sl/saveload.cpp +++ b/src/sl/saveload.cpp @@ -74,10 +74,10 @@ extern const SaveLoadVersion MAX_LOAD_SAVEGAME_VERSION = (SaveLoadVersion)(SL_MA const SaveLoadVersion SAVEGAME_VERSION_EXT = (SaveLoadVersion)(0x8000); ///< Savegame extension indicator mask -SavegameType _savegame_type; ///< type of savegame we are loading +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 @@ -91,12 +91,12 @@ extern bool _sl_upstream_mode; namespace upstream_sl { void SlNullPointers(); void SlLoadChunks(); - void SlLoadChunkByID(uint32 id); + void SlLoadChunkByID(uint32_t id); void SlLoadCheckChunks(); - void SlLoadCheckChunkByID(uint32 id); + void SlLoadCheckChunkByID(uint32_t id); void SlFixPointers(); - void SlFixPointerChunkByID(uint32 id); - void SlSaveChunkChunkByID(uint32 id); + void SlFixPointerChunkByID(uint32_t id); + void SlSaveChunkChunkByID(uint32_t id); void SlResetLoadState(); } @@ -531,13 +531,13 @@ int SlReadUint16() return _sl.reader->RawReadUint16(); } -uint32 SlReadUint32() +uint32_t SlReadUint32() { _sl.reader->CheckBytes(4); return _sl.reader->RawReadUint32(); } -uint64 SlReadUint64() +uint64_t SlReadUint64() { _sl.reader->CheckBytes(8); return _sl.reader->RawReadUint64(); @@ -552,19 +552,19 @@ void SlWriteByte(byte b) _sl.dumper->WriteByte(b); } -void SlWriteUint16(uint16 v) +void SlWriteUint16(uint16_t v) { _sl.dumper->CheckBytes(2); _sl.dumper->RawWriteUint16(v); } -void SlWriteUint32(uint32 v) +void SlWriteUint32(uint32_t v) { _sl.dumper->CheckBytes(4); _sl.dumper->RawWriteUint32(v); } -void SlWriteUint64(uint64 v) +void SlWriteUint64(uint64_t v) { _sl.dumper->CheckBytes(8); _sl.dumper->RawWriteUint64(v); @@ -713,7 +713,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]; } @@ -727,7 +727,7 @@ static inline uint SlCalcConvMemLen(VarType conv) */ static inline byte SlCalcConvFileLen(VarType conv) { - uint8 type = GetVarFileType(conv); + uint8_t type = GetVarFileType(conv); if (type == SLE_FILE_VEHORDERID) return SlXvIsFeaturePresent(XSLFI_MORE_VEHICLE_ORDERS) ? 2 : 1; static const byte conv_file_size[] = {1, 1, 2, 2, 4, 4, 8, 8, 2}; assert(type < lengthof(conv_file_size)); @@ -813,7 +813,7 @@ void SlSetLength(size_t length) * The lower 24 bits are normal * The uppermost 4 bits are bits 24:27 * - * If we have more than 28 bits, use an extra uint32 and + * If we have more than 28 bits, use an extra uint32_t and * signal this using the extended chunk header */ #ifdef POINTER_IS_64BIT assert(length < (1LL << 32)); @@ -821,11 +821,11 @@ void SlSetLength(size_t length) if (length >= (1 << 28)) { /* write out extended chunk header */ SlWriteByte(CH_EXT_HDR); - SlWriteUint32(static_cast(SLCEHF_BIG_RIFF)); + SlWriteUint32(static_cast(SLCEHF_BIG_RIFF)); } - SlWriteUint32(static_cast((length & 0xFFFFFF) | ((length >> 24) << 28))); + SlWriteUint32(static_cast((length & 0xFFFFFF) | ((length >> 24) << 28))); if (length >= (1 << 28)) { - SlWriteUint32(static_cast(length >> 28)); + SlWriteUint32(static_cast(length >> 28)); } break; case CH_ARRAY: @@ -882,18 +882,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_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_BL: return (*(const bool *)ptr != 0); + case SLE_VAR_I8: return *(const int8_t *)ptr; + case SLE_VAR_U8: return *(const byte *)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(); } @@ -906,18 +906,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_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_BL: *(bool *)ptr = (val != 0); break; + case SLE_VAR_I8: *(int8_t *)ptr = val; break; + case SLE_VAR_U8: *(byte *)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_CNAME: *(TinyString*)ptr = CopyFromOldName(val); break; case SLE_VAR_NULL: break; @@ -938,7 +938,7 @@ static void SlSaveLoadConvGeneric(void *ptr, VarType conv) { switch (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)) { @@ -949,7 +949,7 @@ static void SlSaveLoadConvGeneric(void *ptr, VarType conv) case SLE_FILE_VEHORDERID: 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(); @@ -958,21 +958,21 @@ static void SlSaveLoadConvGeneric(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_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_I8: x = (int8_t )SlReadByte(); break; + case SLE_FILE_U8: x = (byte )SlReadByte(); 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; case SLE_FILE_VEHORDERID: if (SlXvIsFeaturePresent(XSLFI_MORE_VEHICLE_ORDERS)) { - x = (uint16)SlReadUint16(); + x = (uint16_t)SlReadUint16(); } else { VehicleOrderID id = (byte)SlReadByte(); x = (id == 0xFF) ? INVALID_VEH_ORDER_ID : id; @@ -1204,7 +1204,7 @@ static inline size_t SlCalcArrayLen(size_t length, VarType conv) * Save/Load an array. * @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.) */ void SlArray(void *array, size_t length, VarType conv) { @@ -1227,7 +1227,7 @@ void SlArray(void *array, 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*)array)[i] = (int32)BSWAP32(SlReadUint32()); + ((int64_t*)array)[i] = (int32_t)BSWAP32(SlReadUint32()); } return; } @@ -1377,7 +1377,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: @@ -1441,7 +1441,7 @@ public: switch (_sl.action) { case SLA_SAVE: - SlWriteUint32((uint32)list->size()); + SlWriteUint32((uint32_t)list->size()); for (auto &item : *list) { SlSaveLoadMember(cmd, &item, conv); @@ -1526,11 +1526,11 @@ static void SlRefList(void *list, SLRefType conv) switch (_sl.action) { case SLA_SAVE: { - SlWriteUint32((uint32)l->size()); + SlWriteUint32((uint32_t)l->size()); for (auto iter = l->begin(); iter != l->end(); ++iter) { void *ptr = *iter; - SlWriteUint32((uint32)ReferenceToInt(ptr, conv)); + SlWriteUint32((uint32_t)ReferenceToInt(ptr, conv)); } break; } @@ -1579,7 +1579,7 @@ static void SlVarList(void *list, VarType conv) switch (_sl.action) { case SLA_SAVE: { - SlWriteUint32((uint32)l->size()); + SlWriteUint32((uint32_t)l->size()); typename PtrList::iterator iter; for (iter = l->begin(); iter != l->end(); ++iter) { @@ -1618,14 +1618,14 @@ static inline size_t SlCalcRingLen(const void *ring, VarType conv) { switch (GetVarMemType(conv)) { case SLE_VAR_BL: return SlStorageHelper::SlCalcLen(ring, conv); - case SLE_VAR_I8: return SlStorageHelper::SlCalcLen(ring, conv); - case SLE_VAR_U8: return SlStorageHelper::SlCalcLen(ring, conv); - case SLE_VAR_I16: return SlStorageHelper::SlCalcLen(ring, conv); - case SLE_VAR_U16: return SlStorageHelper::SlCalcLen(ring, conv); - case SLE_VAR_I32: return SlStorageHelper::SlCalcLen(ring, conv); - case SLE_VAR_U32: return SlStorageHelper::SlCalcLen(ring, conv); - case SLE_VAR_I64: return SlStorageHelper::SlCalcLen(ring, conv); - case SLE_VAR_U64: return SlStorageHelper::SlCalcLen(ring, conv); + case SLE_VAR_I8: return SlStorageHelper::SlCalcLen(ring, conv); + case SLE_VAR_U8: return SlStorageHelper::SlCalcLen(ring, conv); + case SLE_VAR_I16: return SlStorageHelper::SlCalcLen(ring, conv); + case SLE_VAR_U16: return SlStorageHelper::SlCalcLen(ring, conv); + case SLE_VAR_I32: return SlStorageHelper::SlCalcLen(ring, conv); + case SLE_VAR_U32: return SlStorageHelper::SlCalcLen(ring, conv); + case SLE_VAR_I64: return SlStorageHelper::SlCalcLen(ring, conv); + case SLE_VAR_U64: return SlStorageHelper::SlCalcLen(ring, conv); default: NOT_REACHED(); } } @@ -1639,14 +1639,14 @@ static void SlRing(void *ring, VarType conv) { switch (GetVarMemType(conv)) { case SLE_VAR_BL: SlStorageHelper::SlSaveLoad(ring, conv); break; - case SLE_VAR_I8: SlStorageHelper::SlSaveLoad(ring, conv); break; - case SLE_VAR_U8: SlStorageHelper::SlSaveLoad(ring, conv); break; - case SLE_VAR_I16: SlStorageHelper::SlSaveLoad(ring, conv); break; - case SLE_VAR_U16: SlStorageHelper::SlSaveLoad(ring, conv); break; - case SLE_VAR_I32: SlStorageHelper::SlSaveLoad(ring, conv); break; - case SLE_VAR_U32: SlStorageHelper::SlSaveLoad(ring, conv); break; - case SLE_VAR_I64: SlStorageHelper::SlSaveLoad(ring, conv); break; - case SLE_VAR_U64: SlStorageHelper::SlSaveLoad(ring, conv); break; + case SLE_VAR_I8: SlStorageHelper::SlSaveLoad(ring, conv); break; + case SLE_VAR_U8: SlStorageHelper::SlSaveLoad(ring, conv); break; + case SLE_VAR_I16: SlStorageHelper::SlSaveLoad(ring, conv); break; + case SLE_VAR_U16: SlStorageHelper::SlSaveLoad(ring, conv); break; + case SLE_VAR_I32: SlStorageHelper::SlSaveLoad(ring, conv); break; + case SLE_VAR_U32: SlStorageHelper::SlSaveLoad(ring, conv); break; + case SLE_VAR_I64: SlStorageHelper::SlSaveLoad(ring, conv); break; + case SLE_VAR_U64: SlStorageHelper::SlSaveLoad(ring, conv); break; default: NOT_REACHED(); } } @@ -1705,9 +1705,9 @@ size_t SlCalcObjMemberLength(const void *object, const SaveLoad &sld) const size_t size_len = SlCalcConvMemLen(sld.conv); switch (size_len) { case 1: return SlCalcVarListLen>(GetVariableAddress(object, sld), 1); - case 2: return SlCalcVarListLen>(GetVariableAddress(object, sld), 2); - case 4: return SlCalcVarListLen>(GetVariableAddress(object, sld), 4); - case 8: return SlCalcVarListLen>(GetVariableAddress(object, sld), 8); + case 2: return SlCalcVarListLen>(GetVariableAddress(object, sld), 2); + case 4: return SlCalcVarListLen>(GetVariableAddress(object, sld), 4); + case 8: return SlCalcVarListLen>(GetVariableAddress(object, sld), 8); default: NOT_REACHED(); } } @@ -1827,7 +1827,7 @@ bool SlObjectMemberGeneric(void *object, const SaveLoad &sld) case SL_REF: // Reference variable, translate switch (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: @@ -1852,9 +1852,9 @@ bool SlObjectMemberGeneric(void *object, const SaveLoad &sld) const size_t size_len = SlCalcConvMemLen(sld.conv); switch (size_len) { case 1: SlVarList>(ptr, conv); break; - case 2: SlVarList>(ptr, conv); break; - case 4: SlVarList>(ptr, conv); break; - case 8: SlVarList>(ptr, conv); break; + case 2: SlVarList>(ptr, conv); break; + case 4: SlVarList>(ptr, conv); break; + case 8: SlVarList>(ptr, conv); break; default: NOT_REACHED(); } break; @@ -1869,7 +1869,7 @@ bool SlObjectMemberGeneric(void *object, const SaveLoad &sld) * object description to use. */ case SL_WRITEBYTE: switch (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: @@ -1995,7 +1995,7 @@ void SlAutolength(AutolengthProc *proc, void *arg) _sl.dumper->CopyBytes(result.first, result.second); } -uint8 SlSaveToTempBufferSetup() +uint8_t SlSaveToTempBufferSetup() { assert(_sl.action == SLA_SAVE); NeedLength orig_need_length = _sl.need_length; @@ -2003,10 +2003,10 @@ uint8 SlSaveToTempBufferSetup() _sl.need_length = NL_NONE; _sl.dumper->StartAutoLength(); - return (uint8) orig_need_length; + return (uint8_t) orig_need_length; } -std::pair SlSaveToTempBufferRestore(uint8 state) +std::pair SlSaveToTempBufferRestore(uint8_t state) { NeedLength orig_need_length = (NeedLength)state; @@ -2224,7 +2224,7 @@ static void SlLoadCheckChunk(const ChunkHandler *ch) if (ext_flags & SLCEHF_BIG_RIFF) SlErrorCorrupt("XSLFI_RIFF_HEADER_60_BIT and SLCEHF_BIG_RIFF both present"); } if (ext_flags & SLCEHF_BIG_RIFF) { - uint64 full_len = len | (static_cast(SlReadUint32()) << 28); + uint64_t full_len = len | (static_cast(SlReadUint32()) << 28); if (full_len >= (1LL << 32)) { SlErrorCorruptFmt("Chunk size too large: " OTTD_PRINTFHEX64, full_len); } @@ -2321,7 +2321,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 (auto &ch : ChunkHandlers()) if (ch.id == id) return &ch; return nullptr; @@ -2335,7 +2335,7 @@ static void SlLoadChunks() return; } - for (uint32 id = SlReadUint32(); id != 0; id = SlReadUint32()) { + for (uint32_t id = SlReadUint32(); id != 0; id = SlReadUint32()) { DEBUG(sl, 2, "Loading chunk %c%c%c%c", id >> 24, id >> 16, id >> 8, id); size_t read = 0; if (_debug_sl_level >= 3) read = SlGetBytesRead(); @@ -2363,7 +2363,7 @@ static void SlLoadCheckChunks() return; } - uint32 id; + uint32_t id; const ChunkHandler *ch; for (id = SlReadUint32(); id != 0; id = SlReadUint32()) { @@ -2508,16 +2508,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]); @@ -2527,13 +2527,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; } @@ -2555,17 +2555,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; @@ -2981,7 +2981,7 @@ DECLARE_ENUM_AS_BIT_SET(SaveLoadFormatFlags); /** 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. @@ -3175,7 +3175,7 @@ static SaveOrLoadResult SaveFileToDisk(bool threaded) DEBUG(sl, 3, "Using compression format: %s, level: %u", fmt->name, compression); /* We have written our stuff to memory, now write it to file! */ - uint32 hdr[2] = { fmt->tag, TO_BE32((uint32) (SAVEGAME_VERSION | SAVEGAME_VERSION_EXT) << 16) }; + uint32_t hdr[2] = { fmt->tag, TO_BE32((uint32_t) (SAVEGAME_VERSION | SAVEGAME_VERSION_EXT) << 16) }; _sl.sf->Write((byte*)hdr, sizeof(hdr)); _sl.sf = fmt->init_write(_sl.sf, compression); @@ -3413,7 +3413,7 @@ static SaveOrLoadResult DoLoad(LoadFilter *reader, bool load_check) SlResetTNNC(); }); - 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); SaveLoadVersion original_sl_version = SL_MIN_VERSION; diff --git a/src/sl/saveload.h b/src/sl/saveload.h index c79bd6a837..98be735dfa 100644 --- a/src/sl/saveload.h +++ b/src/sl/saveload.h @@ -98,7 +98,7 @@ enum ChunkSaveLoadSpecialOpResult { CSLSOR_DONT_SAVE_CHUNK, CSLSOR_UPSTREAM_SAVE_CHUNK, }; -typedef ChunkSaveLoadSpecialOpResult ChunkSaveLoadSpecialProc(uint32, ChunkSaveLoadSpecialOp); +typedef ChunkSaveLoadSpecialOpResult ChunkSaveLoadSpecialProc(uint32_t, ChunkSaveLoadSpecialOp); /** Type of a chunk. */ enum ChunkType { @@ -112,7 +112,7 @@ enum ChunkType { /** Handlers and description of chunk. */ struct ChunkHandler { - uint32 id; ///< Unique ID (4 letters). + uint32_t id; ///< Unique ID (4 letters). ChunkSaveLoadProc *save_proc; ///< Save procedure of the chunk. ChunkSaveLoadProc *load_proc; ///< Load procedure of the chunk. ChunkSaveLoadProc *ptrs_proc; ///< Manipulate pointers in the chunk. @@ -134,12 +134,12 @@ void SlExecWithSlVersion(SaveLoadVersion use_version, F proc) } namespace upstream_sl { - template + template ChunkHandler MakeUpstreamChunkHandler() { - extern void SlLoadChunkByID(uint32); - extern void SlLoadCheckChunkByID(uint32); - extern void SlFixPointerChunkByID(uint32); + extern void SlLoadChunkByID(uint32_t); + extern void SlLoadCheckChunkByID(uint32_t); + extern void SlFixPointerChunkByID(uint32_t); ChunkHandler ch = { id, @@ -149,7 +149,7 @@ namespace upstream_sl { SlUnreachablePlaceholder, CH_UNUSED }; - ch.special_proc = [](uint32 chunk_id, ChunkSaveLoadSpecialOp op) -> ChunkSaveLoadSpecialOpResult { + ch.special_proc = [](uint32_t chunk_id, ChunkSaveLoadSpecialOp op) -> ChunkSaveLoadSpecialOpResult { assert(id == chunk_id); switch (op) { case CSLSO_PRE_LOAD: @@ -176,12 +176,12 @@ namespace upstream_sl { return ch; } - template + template ChunkHandler MakeConditionallyUpstreamChunkHandler(ChunkSaveLoadProc *save_proc, ChunkSaveLoadProc *load_proc, ChunkSaveLoadProc *ptrs_proc, ChunkSaveLoadProc *load_check_proc, ChunkType type) { - extern void SlLoadChunkByID(uint32); - extern void SlLoadCheckChunkByID(uint32); - extern void SlFixPointerChunkByID(uint32); + extern void SlLoadChunkByID(uint32_t); + extern void SlLoadCheckChunkByID(uint32_t); + extern void SlFixPointerChunkByID(uint32_t); ChunkHandler ch = { id, @@ -191,7 +191,7 @@ namespace upstream_sl { load_check_proc, type }; - ch.special_proc = [](uint32 chunk_id, ChunkSaveLoadSpecialOp op) -> ChunkSaveLoadSpecialOpResult { + ch.special_proc = [](uint32_t chunk_id, ChunkSaveLoadSpecialOp op) -> ChunkSaveLoadSpecialOpResult { assert(id == chunk_id); switch (op) { case CSLSO_PRE_LOAD: @@ -307,16 +307,16 @@ inline constexpr size_t SlVarSize(VarType type) return sizeof(bool); case SLE_VAR_I8: case SLE_VAR_U8: - return sizeof(int8); + return sizeof(int8_t); case SLE_VAR_I16: case SLE_VAR_U16: - return sizeof(int16); + return sizeof(int16_t); case SLE_VAR_I32: case SLE_VAR_U32: - return sizeof(int32); + return sizeof(int32_t); case SLE_VAR_I64: case SLE_VAR_U64: - return sizeof(int64); + return sizeof(int64_t); case SLE_VAR_NAME: return sizeof(std::string); default: @@ -925,8 +925,8 @@ inline void *GetVariableAddress(const void *object, const SaveLoad &sld) return const_cast((const byte *)object + (ptrdiff_t)sld.address); } -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(); @@ -945,10 +945,10 @@ size_t SlCalcObjLength(const void *object, const SaveLoadTable &slt); template span SlSaveToTempBuffer(F proc) { - extern uint8 SlSaveToTempBufferSetup(); - extern std::pair SlSaveToTempBufferRestore(uint8 state); + extern uint8_t SlSaveToTempBufferSetup(); + extern std::pair SlSaveToTempBufferRestore(uint8_t state); - uint8 state = SlSaveToTempBufferSetup(); + uint8_t state = SlSaveToTempBufferSetup(); proc(); auto result = SlSaveToTempBufferRestore(state); return span(result.first, result.second); @@ -961,15 +961,15 @@ span SlSaveToTempBuffer(F proc) * @return a vector containing the saved data */ template -std::vector SlSaveToVector(F proc) +std::vector SlSaveToVector(F proc) { span result = SlSaveToTempBuffer(proc); - return std::vector(result.begin(), result.end()); + return std::vector(result.begin(), result.end()); } struct SlConditionallySaveState { size_t current_len; - uint8 need_length; + uint8_t need_length; bool nested; }; diff --git a/src/sl/saveload_buffer.h b/src/sl/saveload_buffer.h index 45946441da..2809348d9a 100644 --- a/src/sl/saveload_buffer.h +++ b/src/sl/saveload_buffer.h @@ -77,7 +77,7 @@ struct ReadBuffer { inline int RawReadUint16() { #if OTTD_ALIGNMENT == 0 - int x = FROM_BE16(*((const unaligned_uint16*) this->bufp)); + int x = FROM_BE16(*((const unaligned_uint16 *) this->bufp)); this->bufp += 2; return x; #else @@ -86,28 +86,28 @@ struct ReadBuffer { #endif } - inline uint32 RawReadUint32() + inline uint32_t RawReadUint32() { #if OTTD_ALIGNMENT == 0 - uint32 x = FROM_BE32(*((const unaligned_uint32*) this->bufp)); + uint32_t x = FROM_BE32(*((const unaligned_uint32 *) this->bufp)); this->bufp += 4; return x; #else - uint32 x = this->RawReadUint16() << 16; + uint32_t x = this->RawReadUint16() << 16; return x | this->RawReadUint16(); #endif } - inline uint64 RawReadUint64() + inline uint64_t RawReadUint64() { #if OTTD_ALIGNMENT == 0 - uint64 x = FROM_BE64(*((const unaligned_uint64*) this->bufp)); + uint64_t x = FROM_BE64(*((const unaligned_uint64 *) this->bufp)); this->bufp += 8; return x; #else - uint32 x = this->RawReadUint32(); - uint32 y = this->RawReadUint32(); - return (uint64)x << 32 | y; + uint32_t x = this->RawReadUint32(); + uint32_t y = this->RawReadUint32(); + return (uint64_t)x << 32 | y; #endif } @@ -214,7 +214,7 @@ struct MemoryDumper { *this->buf++ = b; } - inline void RawWriteUint16(uint16 v) + inline void RawWriteUint16(uint16_t v) { #if OTTD_ALIGNMENT == 0 *((unaligned_uint16 *) this->buf) = TO_BE16(v); @@ -225,7 +225,7 @@ struct MemoryDumper { this->buf += 2; } - inline void RawWriteUint32(uint32 v) + inline void RawWriteUint32(uint32_t v) { #if OTTD_ALIGNMENT == 0 *((unaligned_uint32 *) this->buf) = TO_BE32(v); @@ -238,7 +238,7 @@ struct MemoryDumper { this->buf += 4; } - inline void RawWriteUint64(uint64 v) + inline void RawWriteUint64(uint64_t v) { #if OTTD_ALIGNMENT == 0 *((unaligned_uint64 *) this->buf) = TO_BE64(v); diff --git a/src/sl/saveload_common.h b/src/sl/saveload_common.h index e113227c38..6cf6c720ec 100644 --- a/src/sl/saveload_common.h +++ b/src/sl/saveload_common.h @@ -38,7 +38,7 @@ namespace upstream_sl { * * 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 @@ -292,7 +292,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 @@ -410,12 +410,12 @@ byte SlReadByte(); void SlWriteByte(byte b); int SlReadUint16(); -uint32 SlReadUint32(); -uint64 SlReadUint64(); +uint32_t SlReadUint32(); +uint64_t SlReadUint64(); -void SlWriteUint16(uint16 v); -void SlWriteUint32(uint32 v); -void SlWriteUint64(uint64 v); +void SlWriteUint16(uint16_t v); +void SlWriteUint32(uint32_t v); +void SlWriteUint64(uint64_t v); void SlSkipBytes(size_t length); diff --git a/src/sl/saveload_internal.h b/src/sl/saveload_internal.h index 3ed4443b8f..c9d9b26382 100644 --- a/src/sl/saveload_internal.h +++ b/src/sl/saveload_internal.h @@ -56,15 +56,15 @@ void AfterLoadTemplateVehiclesUpdate(); void AfterLoadTemplateVehiclesUpdateImages(); void AfterLoadTemplateVehiclesUpdateProperties(); -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 /* SL_SAVELOAD_INTERNAL_H */ diff --git a/src/sl/saveload_types.h b/src/sl/saveload_types.h index f6ebaf3d84..bc8ce11430 100644 --- a/src/sl/saveload_types.h +++ b/src/sl/saveload_types.h @@ -91,7 +91,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 SaveLoadTypes { @@ -120,7 +120,7 @@ struct SaveLoad { bool global; ///< should we load a global variable or a non-global one 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, int - 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 until this savegame version /* NOTE: This element either denotes the address of the variable for a global diff --git a/src/sl/station_sl.cpp b/src/sl/station_sl.cpp index 3e9e83016b..aedcb34165 100644 --- a/src/sl/station_sl.cpp +++ b/src/sl/station_sl.cpp @@ -23,11 +23,11 @@ #include "../safeguards.h" static byte _old_last_vehicle_type; -static uint8 _num_specs; -static uint8 _num_roadstop_specs; -static uint32 _num_roadstop_custom_tiles; +static uint8_t _num_specs; +static uint8_t _num_roadstop_specs; +static uint32_t _num_roadstop_custom_tiles; static std::vector _custom_road_stop_tiles; -static std::vector _custom_road_stop_data; +static std::vector _custom_road_stop_data; /** * Update the buoy orders to be waypoint orders. @@ -231,11 +231,11 @@ static const SaveLoad _old_station_desc[] = { SLE_CONDNULL(32, SLV_2, SL_MAX_VERSION), }; -static uint16 _waiting_acceptance; -static uint32 _num_flows; -static uint16 _cargo_source; -static uint32 _cargo_source_xy; -static uint8 _cargo_periods; +static uint16_t _waiting_acceptance; +static uint32_t _num_flows; +static uint16_t _cargo_source; +static uint32_t _cargo_source_xy; +static uint8_t _cargo_periods; static Money _cargo_feeder_share; static uint _cargo_reserved_count; @@ -252,13 +252,13 @@ static const SaveLoad _roadstop_speclist_desc[] = { }; CargoPacketList _packets; -uint32 _num_dests; +uint32_t _num_dests; struct FlowSaveLoad { FlowSaveLoad() : source(0), via(0), share(0), restricted(false) {} StationID source; StationID via; - uint32 share; + uint32_t share; bool restricted; }; @@ -537,9 +537,9 @@ static void SetupDescs_ROADSTOP() static void RealSave_STNN(BaseStation *bst) { - _num_specs = (uint8)bst->speclist.size(); - _num_roadstop_specs = (uint8)bst->roadstop_speclist.size(); - _num_roadstop_custom_tiles = (uint32)bst->custom_roadstop_tile_data.size(); + _num_specs = (uint8_t)bst->speclist.size(); + _num_roadstop_specs = (uint8_t)bst->roadstop_speclist.size(); + _num_roadstop_custom_tiles = (uint32_t)bst->custom_roadstop_tile_data.size(); bool waypoint = (bst->facilities & FACIL_WAYPOINT) != 0; SlObjectSaveFiltered(bst, waypoint ? SaveLoadTable(_filtered_waypoint_desc) : SaveLoadTable(_filtered_station_desc)); @@ -552,8 +552,8 @@ static void RealSave_STNN(BaseStation *bst) const GoodsEntryData *ged = st->goods[i].data.get(); if (ged != nullptr) { _cargo_reserved_count = ged->cargo.ReservedCount(); - _num_dests = (uint32)ged->cargo.Packets()->MapSize(); - _num_flows = (uint32)ged->flows.size(); + _num_dests = (uint32_t)ged->cargo.Packets()->MapSize(); + _num_flows = (uint32_t)ged->flows.size(); } else { _cargo_reserved_count = 0; _num_dests = 0; @@ -562,12 +562,12 @@ static void RealSave_STNN(BaseStation *bst) SlObjectSaveFiltered(&st->goods[i], _filtered_goods_desc); if (ged == nullptr) continue; for (FlowStatMap::const_iterator outer_it(ged->flows.begin()); outer_it != ged->flows.end(); ++outer_it) { - uint32 sum_shares = 0; + uint32_t sum_shares = 0; FlowSaveLoad flow; flow.source = outer_it->GetOrigin(); dumper->CheckBytes(2 + 4); dumper->RawWriteUint16(flow.source); - dumper->RawWriteUint32((uint32)outer_it->size()); + dumper->RawWriteUint32((uint32_t)outer_it->size()); FlowStat::const_iterator inner_it(outer_it->begin()); const FlowStat::const_iterator end(outer_it->end()); for (; inner_it != end; ++inner_it) { @@ -673,18 +673,18 @@ static void Load_STNN() StationID prev_source = INVALID_STATION; if (SlXvIsFeaturePresent(XSLFI_FLOW_STAT_FLAGS)) { ge.data->flows.reserve(_num_flows); - for (uint32 j = 0; j < _num_flows; ++j) { + for (uint32_t j = 0; j < _num_flows; ++j) { FlowSaveLoad flow; buffer->CheckBytes(2 + 4); flow.source = buffer->RawReadUint16(); - uint32 flow_count = buffer->RawReadUint32(); + uint32_t flow_count = buffer->RawReadUint32(); buffer->CheckBytes(2 + 4 + 1); flow.via = buffer->RawReadUint16(); flow.share = buffer->RawReadUint32(); flow.restricted = (buffer->RawReadByte() != 0); FlowStat *fs = &(*(ge.data->flows.insert(ge.data->flows.end(), FlowStat(flow.source, flow.via, flow.share, flow.restricted)))); - for (uint32 k = 1; k < flow_count; ++k) { + for (uint32_t k = 1; k < flow_count; ++k) { buffer->CheckBytes(2 + 4 + 1); flow.via = buffer->RawReadUint16(); flow.share = buffer->RawReadUint32(); @@ -696,7 +696,7 @@ static void Load_STNN() } else if (SlXvIsFeatureMissing(XSLFI_CHILLPP)) { FlowSaveLoad flow; FlowStat *fs = nullptr; - for (uint32 j = 0; j < _num_flows; ++j) { + for (uint32_t j = 0; j < _num_flows; ++j) { // SlObject(&flow, _flow_desc); /* this is highly performance-sensitive, manually unroll */ buffer->CheckBytes(2 + 2 + 4); flow.source = buffer->RawReadUint16(); @@ -740,13 +740,13 @@ static void Load_STNN() st->station_cargo_history.resize(CountBits(st->station_cargo_history_cargoes)); buffer->CheckBytes(st->station_cargo_history.size() * MAX_STATION_CARGO_HISTORY_DAYS * 2); for (auto &history : st->station_cargo_history) { - for (uint16 &amount : history) { + for (uint16_t &amount : history) { amount = buffer->RawReadUint16(); } } if (SlXvIsFeaturePresent(XSLFI_STATION_CARGO_HISTORY, 1, 1)) { for (auto &history : st->station_cargo_history) { - for (uint16 &amount : history) { + for (uint16_t &amount : history) { amount = RXCompressUint(amount); } } @@ -780,7 +780,7 @@ static void Load_STNN() if (SlXvIsFeaturePresent(XSLFI_GRF_ROADSTOPS, 1, 1)) { for (size_t i = 0; i < _custom_road_stop_tiles.size(); i++) { - bst->custom_roadstop_tile_data.push_back({ _custom_road_stop_tiles[i], (uint8)GB(_custom_road_stop_data[i], 0, 8), (uint8)GB(_custom_road_stop_data[i], 8, 8) }); + bst->custom_roadstop_tile_data.push_back({ _custom_road_stop_tiles[i], (uint8_t)GB(_custom_road_stop_data[i], 0, 8), (uint8_t)GB(_custom_road_stop_data[i], 8, 8) }); } _custom_road_stop_tiles.clear(); _custom_road_stop_data.clear(); diff --git a/src/sl/story_sl.cpp b/src/sl/story_sl.cpp index fa3c70b2b1..85ca8f4fe2 100644 --- a/src/sl/story_sl.cpp +++ b/src/sl/story_sl.cpp @@ -47,7 +47,7 @@ static void Save_STORY_PAGE_ELEMENT() static void Load_STORY_PAGE_ELEMENT() { int index; - uint32 max_sort_value = 0; + uint32_t max_sort_value = 0; while ((index = SlIterateArray()) != -1) { StoryPageElement *s = new (index) StoryPageElement(); SlObject(s, _story_page_elements_desc); @@ -81,7 +81,7 @@ static void Save_STORY_PAGE() static void Load_STORY_PAGE() { int index; - uint32 max_sort_value = 0; + uint32_t max_sort_value = 0; while ((index = SlIterateArray()) != -1) { StoryPage *s = new (index) StoryPage(); SlObject(s, _story_pages_desc); diff --git a/src/sl/strings_sl.cpp b/src/sl/strings_sl.cpp index 52f70b8d58..3ac00ca0e1 100644 --- a/src/sl/strings_sl.cpp +++ b/src/sl/strings_sl.cpp @@ -69,7 +69,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/sl/tbtr_template_veh_sl.cpp b/src/sl/tbtr_template_veh_sl.cpp index 5deb72e4bf..2fbd92e369 100644 --- a/src/sl/tbtr_template_veh_sl.cpp +++ b/src/sl/tbtr_template_veh_sl.cpp @@ -132,7 +132,7 @@ void AfterLoadTemplateVehiclesUpdateProperties() StringID err; Train* t = VirtualTrainFromTemplateVehicle(tv, err, 0); if (t != nullptr) { - uint32 full_cargo_weight = 0; + uint32_t full_cargo_weight = 0; for (Train *u = t; u != nullptr; u = u->Next()) { full_cargo_weight += u->GetCargoWeight(u->cargo_cap); } diff --git a/src/sl/town_sl.cpp b/src/sl/town_sl.cpp index f427496900..da66957340 100644 --- a/src/sl/town_sl.cpp +++ b/src/sl/town_sl.cpp @@ -259,24 +259,24 @@ static const SaveLoad _town_desc[] = { }; static const SaveLoad _town_supplied_desc[] = { - 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), }; static const SaveLoad _town_received_desc[] = { - 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), }; static const SaveLoad _town_received_desc_spp[] = { - SLE_CONDVAR(TransportedCargoStat, old_max, SLE_FILE_U32 | SLE_VAR_U16, SLV_165, SL_MAX_VERSION), - SLE_CONDVAR(TransportedCargoStat, new_max, SLE_FILE_U32 | SLE_VAR_U16, SLV_165, SL_MAX_VERSION), - SLE_CONDVAR(TransportedCargoStat, old_act, SLE_FILE_U32 | SLE_VAR_U16, SLV_165, SL_MAX_VERSION), - SLE_CONDVAR(TransportedCargoStat, new_act, SLE_FILE_U32 | SLE_VAR_U16, SLV_165, SL_MAX_VERSION), + SLE_CONDVAR(TransportedCargoStat, old_max, SLE_FILE_U32 | SLE_VAR_U16, SLV_165, SL_MAX_VERSION), + SLE_CONDVAR(TransportedCargoStat, new_max, SLE_FILE_U32 | SLE_VAR_U16, SLV_165, SL_MAX_VERSION), + SLE_CONDVAR(TransportedCargoStat, old_act, SLE_FILE_U32 | SLE_VAR_U16, SLV_165, SL_MAX_VERSION), + SLE_CONDVAR(TransportedCargoStat, new_act, SLE_FILE_U32 | SLE_VAR_U16, SLV_165, SL_MAX_VERSION), }; std::vector _filtered_town_desc; @@ -350,8 +350,8 @@ static void Load_TOWN() if ((!IsSavegameVersionBefore(SLV_166) && IsSavegameVersionBefore(SLV_REMOVE_TOWN_CARGO_CACHE)) || SlXvIsFeaturePresent(XSLFI_TOWN_CARGO_MATRIX)) { SlSkipBytes(4); // tile - uint16 w = SlReadUint16(); - uint16 h = SlReadUint16(); + uint16_t w = SlReadUint16(); + uint16_t h = SlReadUint16(); if (w != 0) { SlSkipBytes((SlXvIsFeaturePresent(XSLFI_TOWN_CARGO_MATRIX) ? 8 : 4) * ((uint)(w / 4) * (uint)(h / 4))); } @@ -387,7 +387,7 @@ void Save_TNNC() } size_t length = 8 + (Town::GetNumItems() * 6); - uint32 flags = 0; + uint32_t flags = 0; if (IsGetTownZonesCallbackHandlerPresent()) { flags |= 1; @@ -397,7 +397,7 @@ void Save_TNNC() SlSetLength(length); SlWriteUint32(flags); - SlWriteUint32((uint32)Town::GetNumItems()); + SlWriteUint32((uint32_t)Town::GetNumItems()); for (const Town *t : Town::Iterate()) { SlWriteUint32(t->index); @@ -419,13 +419,13 @@ void Load_TNNC() return; } - const uint32 flags = SlReadUint32(); - const uint32 count = SlReadUint32(); + const uint32_t flags = SlReadUint32(); + const uint32_t count = SlReadUint32(); _town_noise_no_update = true; _town_zone_radii_no_update = (flags & 1); - for (uint32 idx = 0; idx < count; idx++) { + for (uint32_t idx = 0; idx < count; idx++) { Town *t = Town::Get(SlReadUint32()); t->noise_reached = SlReadUint16(); if (flags & 1) { @@ -436,7 +436,7 @@ void Load_TNNC() } } -static ChunkSaveLoadSpecialOpResult Special_TNNC(uint32 chunk_id, ChunkSaveLoadSpecialOp op) +static ChunkSaveLoadSpecialOpResult Special_TNNC(uint32_t chunk_id, ChunkSaveLoadSpecialOp op) { switch (op) { case CSLSO_SHOULD_SAVE_CHUNK: diff --git a/src/sl/tracerestrict_sl.cpp b/src/sl/tracerestrict_sl.cpp index c923da5cc8..1ebfea95e8 100644 --- a/src/sl/tracerestrict_sl.cpp +++ b/src/sl/tracerestrict_sl.cpp @@ -44,7 +44,7 @@ static void Save_TRRM() /** program length save header struct */ struct TraceRestrictProgramStub { - uint32 length; + uint32_t length; }; static const SaveLoad _trace_restrict_program_stub_desc[] = { @@ -95,7 +95,7 @@ static void Load_TRRP() static void RealSave_TRRP(TraceRestrictProgram *prog) { TraceRestrictProgramStub stub; - stub.length = (uint32)prog->items.size(); + stub.length = (uint32_t)prog->items.size(); SlObject(&stub, _trace_restrict_program_stub_desc); SlArray(prog->items.data(), stub.length, SLE_UINT32); } @@ -113,7 +113,7 @@ static void Save_TRRP() /** program length save header struct */ struct TraceRestrictSlotStub { - uint32 length; + uint32_t length; }; static const SaveLoad _trace_restrict_slot_stub_desc[] = { @@ -151,7 +151,7 @@ static void RealSave_TRRS(TraceRestrictSlot *slot) { SlObject(slot, _trace_restrict_slot_desc); TraceRestrictSlotStub stub; - stub.length = (uint32)slot->occupants.size(); + stub.length = (uint32_t)slot->occupants.size(); SlObject(&stub, _trace_restrict_slot_stub_desc); if (stub.length) SlArray(slot->occupants.data(), stub.length, SLE_UINT32); } diff --git a/src/sl/vehicle_sl.cpp b/src/sl/vehicle_sl.cpp index 287fd25d03..431b1b3c34 100644 --- a/src/sl/vehicle_sl.cpp +++ b/src/sl/vehicle_sl.cpp @@ -635,22 +635,22 @@ 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; CargoPacketList _cpp_packets; std::map _veh_cpp_packets; static std::vector _path_td; static std::vector _path_tile; -static uint32 _path_layout_ctr; +static uint32_t _path_layout_ctr; -static uint32 _old_ahead_separation; -static uint16 _old_timetable_start_subticks; +static uint32_t _old_ahead_separation; +static uint16_t _old_timetable_start_subticks; -btree::btree_map _old_timetable_start_subticks_map; +btree::btree_map _old_timetable_start_subticks_map; /** * Make it possible to make the saveload tables "friends" of other classes. @@ -715,10 +715,10 @@ SaveLoadTable GetVehicleDescription(VehicleType vt) SLE_VAR(Vehicle, day_counter, SLE_UINT8), SLE_VAR(Vehicle, tick_counter, SLE_UINT8), - SLE_CONDVAR_X(Vehicle, running_ticks, SLE_FILE_U8 | SLE_VAR_U16, SLV_88, SL_MAX_VERSION, SlXvFeatureTest([](uint16 version, bool version_in_range, const std::array &feature_versions) -> bool { + SLE_CONDVAR_X(Vehicle, running_ticks, SLE_FILE_U8 | SLE_VAR_U16, SLV_88, SL_MAX_VERSION, SlXvFeatureTest([](uint16_t version, bool version_in_range, const std::array &feature_versions) -> bool { return version_in_range && !(SlXvIsFeaturePresent(feature_versions, XSLFI_SPRINGPP, 3) || SlXvIsFeaturePresent(feature_versions, XSLFI_JOKERPP) || SlXvIsFeaturePresent(feature_versions, XSLFI_CHILLPP) || SlXvIsFeaturePresent(feature_versions, XSLFI_VARIABLE_DAY_LENGTH, 2)); })), - SLE_CONDVAR_X(Vehicle, running_ticks, SLE_UINT16, SLV_88, SL_MAX_VERSION, SlXvFeatureTest([](uint16 version, bool version_in_range, const std::array &feature_versions) -> bool { + SLE_CONDVAR_X(Vehicle, running_ticks, SLE_UINT16, SLV_88, SL_MAX_VERSION, SlXvFeatureTest([](uint16_t version, bool version_in_range, const std::array &feature_versions) -> bool { return version_in_range && (SlXvIsFeaturePresent(feature_versions, XSLFI_SPRINGPP, 2) || SlXvIsFeaturePresent(feature_versions, XSLFI_JOKERPP) || SlXvIsFeaturePresent(feature_versions, XSLFI_CHILLPP) || SlXvIsFeaturePresent(feature_versions, XSLFI_VARIABLE_DAY_LENGTH, 2)); })), @@ -1139,7 +1139,7 @@ void Load_VEHS() if (vtype == VEH_ROAD && !_path_td.empty() && _path_td.size() <= RV_PATH_CACHE_SEGMENTS && _path_td.size() == _path_tile.size()) { RoadVehicle *rv = RoadVehicle::From(v); rv->cached_path.reset(new RoadVehPathCache()); - rv->cached_path->count = (uint8)_path_td.size(); + rv->cached_path->count = (uint8_t)_path_td.size(); for (size_t i = 0; i < _path_td.size(); i++) { rv->cached_path->td[i] = _path_td[i]; rv->cached_path->tile[i] = _path_tile[i]; @@ -1148,7 +1148,7 @@ void Load_VEHS() } else if (vtype == VEH_SHIP && !_path_td.empty() && _path_td.size() <= SHIP_PATH_CACHE_LENGTH) { Ship *s = Ship::From(v); s->cached_path.reset(new ShipPathCache()); - s->cached_path->count = (uint8)_path_td.size(); + s->cached_path->count = (uint8_t)_path_td.size(); for (size_t i = 0; i < _path_td.size(); i++) { s->cached_path->td[i] = _path_td[i]; } @@ -1232,13 +1232,13 @@ struct train_venc { VehicleID id; GroundVehicleCache gvcache; int cached_curve_speed_mod; - uint8 cached_tflags; - uint8 cached_num_engines; - uint16 cached_centre_mass; - uint16 cached_braking_length; - uint16 cached_veh_weight; - uint16 cached_uncapped_decel; - uint8 cached_deceleration; + uint8_t cached_tflags; + uint8_t cached_num_engines; + uint16_t cached_centre_mass; + uint16_t cached_braking_length; + uint16_t cached_veh_weight; + uint16_t cached_uncapped_decel; + uint8_t cached_deceleration; byte user_def_data; int cached_max_curve_speed; }; @@ -1250,7 +1250,7 @@ struct roadvehicle_venc { struct aircraft_venc { VehicleID id; - uint16 cached_max_range; + uint16_t cached_max_range; }; static std::vector _vehicle_vencs; @@ -1485,7 +1485,7 @@ void SlProcessVENC() } } -static ChunkSaveLoadSpecialOpResult Special_VENC(uint32 chunk_id, ChunkSaveLoadSpecialOp op) +static ChunkSaveLoadSpecialOpResult Special_VENC(uint32_t chunk_id, ChunkSaveLoadSpecialOp op) { switch (op) { case CSLSO_SHOULD_SAVE_CHUNK: @@ -1546,11 +1546,11 @@ const SaveLoadTable GetVehicleLookAheadCurveDescription() static void RealSave_VLKA(TrainReservationLookAhead *lookahead) { SlObject(lookahead, GetVehicleLookAheadDescription()); - SlWriteUint32((uint32)lookahead->items.size()); + SlWriteUint32((uint32_t)lookahead->items.size()); for (TrainReservationLookAheadItem &item : lookahead->items) { SlObject(&item, GetVehicleLookAheadItemDescription()); } - SlWriteUint32((uint32)lookahead->curves.size()); + SlWriteUint32((uint32_t)lookahead->curves.size()); for (TrainReservationLookAheadCurve &curve : lookahead->curves) { SlObject(&curve, GetVehicleLookAheadCurveDescription()); } @@ -1574,12 +1574,12 @@ void Load_VLKA() assert(t != nullptr); t->lookahead.reset(new TrainReservationLookAhead()); SlObject(t->lookahead.get(), GetVehicleLookAheadDescription()); - uint32 items = SlReadUint32(); + uint32_t items = SlReadUint32(); t->lookahead->items.resize(items); for (uint i = 0; i < items; i++) { SlObject(&t->lookahead->items[i], GetVehicleLookAheadItemDescription()); } - uint32 curves = SlReadUint32(); + uint32_t curves = SlReadUint32(); t->lookahead->curves.resize(curves); for (uint i = 0; i < curves; i++) { SlObject(&t->lookahead->curves[i], GetVehicleLookAheadCurveDescription()); diff --git a/src/sl/waypoint_sl.cpp b/src/sl/waypoint_sl.cpp index 3e9c777904..dc966cfa99 100644 --- a/src/sl/waypoint_sl.cpp +++ b/src/sl/waypoint_sl.cpp @@ -27,13 +27,13 @@ struct OldWaypoint { TileIndex xy; TownID town_index; Town *town; - uint16 town_cn; + uint16_t town_cn; StringID string_id; TinyString name; - uint8 delete_ctr; + uint8_t delete_ctr; Date build_date; - uint8 localidx; - uint32 grfid; + uint8_t localidx; + uint32_t grfid; const StationSpec *spec; Owner owner; diff --git a/src/slope_type.h b/src/slope_type.h index d0829af96e..b05bb7d484 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_colours.h b/src/smallmap_colours.h index 441ceceff1..36dd13bcc8 100644 --- a/src/smallmap_colours.h +++ b/src/smallmap_colours.h @@ -34,20 +34,20 @@ /** 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 - size_t colour_count; ///< The number of colours. - uint32 default_colour; ///< Default colour of the land. + 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_t default_colour; ///< Default colour of the land. }; extern SmallMapColourScheme _heightmap_schemes[]; struct AndOr { - uint32 mor; - uint32 mand; + uint32_t mor; + uint32_t mand; }; -inline uint32 ApplyMask(uint32 colour, const AndOr *mask) +inline uint32_t ApplyMask(uint32_t colour, const AndOr *mask) { return (colour & mask->mand) | mask->mor; } @@ -84,7 +84,7 @@ static const AndOr _smallmap_vehicles_andor[] = { {MKCOLOUR_0XX0(PC_BLACK ), MKCOLOUR_F00F}, }; -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 diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index a87ff78411..714ead1d15 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -42,7 +42,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}; /** Macro for ordinary entry of LegendAndColour */ #define MK(a, b) {a, b, INVALID_INDUSTRYTYPE, 0, INVALID_COMPANY, true, false, false} @@ -390,7 +390,7 @@ static TileType GetSmallMapTileType(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 "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[GetSmallMapTileType(tile, t)]); @@ -403,7 +403,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[GetSmallMapTileType(tile, t)]); @@ -416,7 +416,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[GetSmallMapTileType(tile, t)]); @@ -429,7 +429,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: @@ -485,7 +485,7 @@ 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); } @@ -497,7 +497,7 @@ static inline uint32 GetSmallMapLinkStatsPixels(TileIndex tile, TileType t) * @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: @@ -595,7 +595,7 @@ static inline uint32 GetSmallMapVegetationPixels(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 "Owner" */ -static inline uint32 GetSmallMapOwnerPixels(TileIndex tile, TileType t) +static inline uint32_t GetSmallMapOwnerPixels(TileIndex tile, TileType t) { Owner o; @@ -713,7 +713,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. @@ -829,8 +829,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; if (this->ui_zoom == 1) { int idx = std::max(0, -start_pos); if (y >= 0 && y < end_y) { @@ -1100,7 +1100,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; @@ -1241,7 +1241,7 @@ void SmallMapWindow::RebuildColourIndexIfNecessary() i = 1; } - uint8 legend_colour = tbl->colour; + uint8_t legend_colour = tbl->colour; switch (this->map_type) { case SMT_INDUSTRY: @@ -1679,11 +1679,11 @@ Point SmallMapWindow::GetStationMiddle(const Station *st) const */ void SmallMapWindow::TakeScreenshot() { - int32 width = (((MapMaxX() + MapMaxY()) * 2) * this->ui_zoom) / this->tile_zoom; - int32 height = ((MapMaxX() + MapMaxY() + 1) * this->ui_zoom) / this->tile_zoom; + int32_t width = (((MapMaxX() + MapMaxY()) * 2) * this->ui_zoom) / this->tile_zoom; + int32_t height = ((MapMaxX() + MapMaxY() + 1) * this->ui_zoom) / this->tile_zoom; - int32 saved_scroll_x = this->scroll_x; - int32 saved_scroll_y = this->scroll_y; + int32_t saved_scroll_x = this->scroll_x; + int32_t saved_scroll_y = this->scroll_y; MakeSmallMapScreenshot(width, height, this); this->scroll_x = saved_scroll_x; this->scroll_y = saved_scroll_y; diff --git a/src/smallmap_gui.h b/src/smallmap_gui.h index f43906ccbc..3950fc8df6 100644 --- a/src/smallmap_gui.h +++ b/src/smallmap_gui.h @@ -55,10 +55,10 @@ void BuildOwnerLegend(); /** 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. @@ -90,7 +90,7 @@ protected: static bool show_towns; ///< Display town names in the smallmap. static int map_height_limit; ///< Currently used/cached map height limit. - static const uint INDUSTRY_MIN_NUMBER_OF_COLUMNS = 2; ///< Minimal number of columns in the #WID_SM_LEGEND widget for the #SMT_INDUSTRY legend. + static const uint INDUSTRY_MIN_NUMBER_OF_COLUMNS = 2; ///< Minimal number of columns in the #WID_SM_LEGEND widget for the #SMT_INDUSTRY legend. static const uint FORCE_REFRESH_PERIOD = 930; ///< map is redrawn after that many milliseconds (default). static const uint FORCE_REFRESH_PERIOD_VEH = 240; ///< map is redrawn after that many milliseconds (modes with vehicles). static const uint FORCE_REFRESH_PERIOD_LINK_GRAPH = 2850; ///< map is redrawn after that many milliseconds (link graph mode). @@ -101,11 +101,11 @@ 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. - int tile_zoom; ///< Tile zoom level. Bigger number means more zoom-out (further away). - int ui_zoom; ///< UI (pixel doubling) Zoom level. Bigger number means more zoom-in (closer). - int zoom = 1; ///< Zoom level. Bigger number means more zoom-out (further away). + 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. + int tile_zoom; ///< Tile zoom level. Bigger number means more zoom-out (further away). + int ui_zoom; ///< UI (pixel doubling) Zoom level. Bigger number means more zoom-in (closer). + int zoom = 1; ///< Zoom level. Bigger number means more zoom-out (further away). GUITimer refresh; ///< Refresh timer. std::unique_ptr overlay; @@ -192,7 +192,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 4ebc077ad7..a2439fee3f 100644 --- a/src/sortlist_type.h +++ b/src/sortlist_type.h @@ -54,10 +54,10 @@ 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 - uint16 resort_interval; ///< value to re-initialise resort_timer with after sorting + 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 + uint16_t resort_interval; ///< value to re-initialise resort_timer with after sorting /* If sort parameters are used then params must be a reference, however if not then params cannot be a reference as * it will not be able to reference anything. */ @@ -114,7 +114,7 @@ public: * * @return The current sorttype */ - uint8 SortType() const + uint8_t SortType() const { return this->sort_type; } @@ -124,7 +124,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); @@ -166,7 +166,7 @@ public: * * @return The current filtertype */ - uint8 FilterType() const + uint8_t FilterType() const { return this->filter_type; } @@ -176,7 +176,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; @@ -239,10 +239,10 @@ public: SETBITS(this->flags, VL_RESORT); } - void SetResortInterval(uint16 resort_interval) + void SetResortInterval(uint16_t resort_interval) { - this->resort_interval = std::max(1, resort_interval); - this->resort_timer = std::min(this->resort_timer, this->resort_interval); + this->resort_interval = std::max(1, resort_interval); + this->resort_timer = std::min(this->resort_timer, this->resort_interval); } /** diff --git a/src/sound.cpp b/src/sound.cpp index 6fb582bae1..9faeb7c18c 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 @@ -132,7 +132,7 @@ static bool SetBankSource(MixerChannel *mc, const SoundEntry *sound) 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; @@ -152,7 +152,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 09198100bf..0397d18502 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 9539ce03e4..a3ec2648e4 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 7b474aaaae..9c6c1bca64 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,8 +78,8 @@ 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. diff --git a/src/spritecache.cpp b/src/spritecache.cpp index cec3a3ba28..cecaae6ed8 100644 --- a/src/spritecache.cpp +++ b/src/spritecache.cpp @@ -38,8 +38,8 @@ uint _sprite_cache_size = 4; size_t _spritecache_bytes_used = 0; -static uint32 _sprite_lru_counter; -static uint32 _spritecache_prune_events = 0; +static uint32_t _sprite_lru_counter; +static uint32_t _spritecache_prune_events = 0; static size_t _spritecache_prune_entries = 0; static size_t _spritecache_prune_total = 0; @@ -102,13 +102,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; @@ -161,7 +161,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; @@ -206,7 +206,7 @@ uint GetMaxSpriteID() static bool ResizeSpriteIn(SpriteLoader::SpriteCollection &sprite, ZoomLevel src, ZoomLevel tgt, bool dry_run) { - 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; @@ -374,7 +374,7 @@ static bool PadSprites(SpriteLoader::SpriteCollection &sprite, unsigned int spri return true; } -static bool ResizeSprites(SpriteLoader::SpriteCollection &sprite, unsigned int sprite_avail, SpriteEncoder *encoder, uint8 zoom_levels) +static bool ResizeSprites(SpriteLoader::SpriteCollection &sprite, unsigned int sprite_avail, SpriteEncoder *encoder, uint8_t zoom_levels) { ZoomLevel first_avail = static_cast(FindFirstBit(sprite_avail)); ZoomLevel first_needed = static_cast(FindFirstBit(zoom_levels)); @@ -496,7 +496,7 @@ static const char *GetSpriteTypeName(SpriteType type) * @param encoder Sprite encoder to use. * @return Read sprite data. */ -static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_type, AllocatorProc *allocator, SpriteEncoder *encoder, uint8 zoom_levels) +static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_type, AllocatorProc *allocator, SpriteEncoder *encoder, uint8_t zoom_levels) { /* Use current blitter if no other sprite encoder is given. */ if (encoder == nullptr) { @@ -519,7 +519,7 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty DEBUG(sprite, 9, "Load sprite %d", id); SpriteLoader::SpriteCollection sprite; - uint8 sprite_avail = 0; + uint8_t sprite_avail = 0; sprite[ZOOM_LVL_NORMAL].type = sprite_type; SpriteLoaderGrf sprite_loader(file.GetContainerVersion()); @@ -595,18 +595,18 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty struct GrfSpriteOffset { size_t file_pos; uint count; - uint16 control_flags; + uint16_t control_flags; }; /** Map from sprite numbers to position in the GRF file. */ -static btree::btree_map _grf_sprite_offsets; +static btree::btree_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) { auto iter = _grf_sprite_offsets.find(id); return iter != _grf_sprite_offsets.end() ? iter->second.file_pos : SIZE_MAX; @@ -630,7 +630,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; @@ -678,14 +678,14 @@ bool LoadNextSprite(int load_index, SpriteFile &file, uint file_sprite_id) SCOPE_INFO_FMT([&], "LoadNextSprite: pos: " PRINTF_SIZE ", file: %s, load_index: %d, file_sprite_id: %u, container_ver: %u", file_pos, file.GetSimplifiedFilename().c_str(), load_index, file_sprite_id, file.GetContainerVersion()); /* 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(); SpriteType type; void *data = nullptr; uint count = 0; - uint16 control_flags = 0; + uint16_t control_flags = 0; if (grf_type == 0xFF) { /* Some NewGRF files have "empty" pseudo-sprites which are 1 * byte long. Catch these so the sprites won't be displayed. */ @@ -786,10 +786,10 @@ static void DeleteEntriesFromSpriteCache(size_t target) const size_t initial_in_use = GetSpriteCacheUsage(); struct SpriteInfo { - uint32 lru; + uint32_t lru; SpriteID id; - uint32 size; - uint8 missing_zoom_levels; + uint32_t size; + uint8_t missing_zoom_levels; bool operator<(const SpriteInfo &other) const { @@ -894,7 +894,7 @@ void IncreaseSpriteLRU() static void *AllocSprite(size_t mem_req) { assert(_last_sprite_allocation.GetPtr() == nullptr); - _last_sprite_allocation.Allocate((uint32)mem_req); + _last_sprite_allocation.Allocate((uint32_t)mem_req); return _last_sprite_allocation.GetPtr(); } @@ -953,7 +953,7 @@ static void *HandleInvalidSpriteRequest(SpriteID sprite, SpriteType requested, S * @param encoder Sprite encoder to use. Set to nullptr to use the currently active blitter. * @return Sprite raw data */ -void *GetRawSprite(SpriteID sprite, SpriteType type, uint8 zoom_levels, AllocatorProc *allocator, SpriteEncoder *encoder) +void *GetRawSprite(SpriteID sprite, SpriteType type, uint8_t zoom_levels, AllocatorProc *allocator, SpriteEncoder *encoder) { assert(type != SpriteType::MapGen || IsMapgenSpriteID(sprite)); assert(type < SpriteType::Invalid); @@ -986,10 +986,10 @@ void *GetRawSprite(SpriteID sprite, SpriteType type, uint8 zoom_levels, Allocato } if (type != SpriteType::Recolour) { - uint8 lvls = zoom_levels; + uint8_t lvls = zoom_levels; Sprite *sp = (Sprite *)sc->GetPtr(); while (lvls != 0 && sp != nullptr) { - uint8 usable = ~sp->missing_zoom_levels; + uint8_t usable = ~sp->missing_zoom_levels; if (usable & lvls) { /* Update LRU */ sp->lru = ++_sprite_lru_counter; @@ -1012,7 +1012,7 @@ void *GetRawSprite(SpriteID sprite, SpriteType type, uint8 zoom_levels, Allocato * @param palette_id Palette for remapping colours. * @return if blitter supports 32bpp, average Colour.data else a palette index. */ -uint32 GetSpriteMainColour(SpriteID sprite_id, PaletteID palette_id) +uint32_t GetSpriteMainColour(SpriteID sprite_id, PaletteID palette_id) { if (!SpriteExists(sprite_id)) return 0; @@ -1027,10 +1027,10 @@ uint32 GetSpriteMainColour(SpriteID sprite_id, PaletteID palette_id) SpriteLoader::SpriteCollection sprites; sprites[ZOOM_LVL_NORMAL].type = SpriteType::Normal; SpriteLoaderGrf sprite_loader(file.GetContainerVersion()); - uint8 sprite_avail; - const uint8 screen_depth = BlitterFactory::GetCurrentBlitter()->GetScreenDepth(); + uint8_t sprite_avail; + const uint8_t screen_depth = BlitterFactory::GetCurrentBlitter()->GetScreenDepth(); - auto zoom_mask = [&](bool is32bpp) -> uint8 { + auto zoom_mask = [&](bool is32bpp) -> uint8_t { return 1 << FindFirstBit(GB(sc->flags, is32bpp ? SCC_32BPP_ZOOM_START : SCC_PAL_ZOOM_START, 6)); }; @@ -1040,7 +1040,7 @@ uint32 GetSpriteMainColour(SpriteID sprite_id, PaletteID palette_id) if (sprite_avail != 0) { SpriteLoader::Sprite *sprite = &sprites[FindFirstBit(sprite_avail)]; /* Return the average colour. */ - uint32 r = 0, g = 0, b = 0, cnt = 0; + uint32_t r = 0, g = 0, b = 0, cnt = 0; SpriteLoader::CommonPixel *pixel = sprite->data; for (uint x = sprite->width * sprite->height; x != 0; x--) { if (pixel->a) { @@ -1072,7 +1072,7 @@ uint32 GetSpriteMainColour(SpriteID sprite_id, PaletteID palette_id) SpriteLoader::CommonPixel *pixel = sprite->data; if (screen_depth == 32) { /* Return the average colour. */ - uint32 r = 0, g = 0, b = 0, cnt = 0; + uint32_t r = 0, g = 0, b = 0, cnt = 0; for (uint x = sprite->width * sprite->height; x != 0; x--) { if (pixel->a) { const uint col_index = remap ? remap[pixel->m] : pixel->m; @@ -1094,7 +1094,7 @@ uint32 GetSpriteMainColour(SpriteID sprite_id, PaletteID palette_id) pixel++; } int cnt_max = -1; - uint32 rk = 0; + uint32_t rk = 0; for (uint x = 1; x < lengthof(cnt); x++) { if (cnt[x] > cnt_max) { rk = x; diff --git a/src/spritecache.h b/src/spritecache.h index b8d8dd8815..7df1476355 100644 --- a/src/spritecache.h +++ b/src/spritecache.h @@ -17,15 +17,15 @@ /** Data structure describing a sprite. */ struct Sprite { - uint32 size; ///< Size of the allocation for this sprite structure - 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. - uint32 lru; ///< Sprite cache LRU of this sprite structure. - uint8 missing_zoom_levels; ///< Bitmask of zoom levels missing in data - Sprite *next = nullptr; ///< Next sprite structure, this is the only member which may be changed after the sprite has been inserted in the sprite cache - byte data[]; ///< Sprite data. + uint32_t size; ///< Size of the allocation for this sprite structure + 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. + uint32_t lru; ///< Sprite cache LRU of this sprite structure. + uint8_t missing_zoom_levels; ///< Bitmask of zoom levels missing in data + Sprite *next = nullptr; ///< Next sprite structure, this is the only member which may be changed after the sprite has been inserted in the sprite cache + byte data[]; ///< Sprite data. }; /* @@ -43,16 +43,16 @@ extern uint _sprite_cache_size; typedef void *AllocatorProc(size_t size); void *SimpleSpriteAlloc(size_t size); -void *GetRawSprite(SpriteID sprite, SpriteType type, uint8 zoom_levels, AllocatorProc *allocator = nullptr, SpriteEncoder *encoder = nullptr); +void *GetRawSprite(SpriteID sprite, SpriteType type, uint8_t zoom_levels, AllocatorProc *allocator = nullptr, SpriteEncoder *encoder = nullptr); 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(); -inline const Sprite *GetSprite(SpriteID sprite, SpriteType type, uint8 zoom_levels) +inline const Sprite *GetSprite(SpriteID sprite, SpriteType type, uint8_t zoom_levels) { dbg_assert(type != SpriteType::Recolour); return (Sprite*)GetRawSprite(sprite, type, zoom_levels); @@ -72,26 +72,26 @@ 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); -uint32 GetSpriteMainColour(SpriteID sprite_id, PaletteID palette_id); +uint32_t GetSpriteMainColour(SpriteID sprite_id, PaletteID palette_id); struct SpritePointerHolder { private: - btree::btree_map cache; + btree::btree_map cache; public: inline const Sprite *GetSprite(SpriteID sprite, SpriteType type) const { - return (const Sprite*)(this->cache.find(sprite | (static_cast(type) << 29))->second); + return (const Sprite*)(this->cache.find(sprite | (static_cast(type) << 29))->second); } inline const byte *GetRecolourSprite(SpriteID sprite) const { - return (const byte*)(this->cache.find(sprite | (static_cast(SpriteType::Recolour) << 29))->second); + return (const byte*)(this->cache.find(sprite | (static_cast(SpriteType::Recolour) << 29))->second); } void Clear() @@ -101,12 +101,12 @@ public: inline void CacheSprite(SpriteID sprite, SpriteType type, ZoomLevel zoom_level) { - this->cache[sprite | (static_cast(type) << 29)] = GetRawSprite(sprite, type, ZoomMask(zoom_level)); + this->cache[sprite | (static_cast(type) << 29)] = GetRawSprite(sprite, type, ZoomMask(zoom_level)); } inline void CacheRecolourSprite(SpriteID sprite) { - this->cache[sprite | (static_cast(SpriteType::Recolour) << 29)] = GetRawSprite(sprite, SpriteType::Recolour, 0); + this->cache[sprite | (static_cast(SpriteType::Recolour) << 29)] = GetRawSprite(sprite, SpriteType::Recolour, 0); } }; diff --git a/src/spritecache_internal.h b/src/spritecache_internal.h index 7f5049084c..7beb139814 100644 --- a/src/spritecache_internal.h +++ b/src/spritecache_internal.h @@ -30,13 +30,13 @@ class SpriteDataBuffer { friend SpriteCache; std::unique_ptr ptr; - uint32 size = 0; + uint32_t size = 0; public: void *GetPtr() { return this->ptr.get(); } - uint32 GetSize() { return this->size; } + uint32_t GetSize() { return this->size; } - void Allocate(uint32 size) + void Allocate(uint32_t size) { this->ptr.reset(MallocT(size)); this->size = size; @@ -57,12 +57,12 @@ private: std::unique_ptr ptr; public: - uint32 id; + uint32_t id; uint count; 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. - uint8 total_missing_zoom_levels = 0; ///< Zoom levels missing entirely - uint16 flags; ///< Control flags, see SpriteCacheCtrlFlags + uint8_t total_missing_zoom_levels = 0; ///< Zoom levels missing entirely + uint16_t flags; ///< Control flags, see SpriteCacheCtrlFlags void *GetPtr() { return this->ptr.get(); } const void *GetPtr() const { return this->ptr.get(); } @@ -103,7 +103,7 @@ public: this->total_missing_zoom_levels = 0; } - void RemoveByMissingZoomLevels(uint8 lvls) + void RemoveByMissingZoomLevels(uint8_t lvls) { Sprite *base = this->GetSpritePtr(); if (base == nullptr) { diff --git a/src/spriteloader/grf.cpp b/src/spriteloader/grf.cpp index 99a54b30dd..927e12ff9f 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::SpriteCollection &sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp) +uint8_t LoadSpriteV1(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp) { /* Check the requested colour depth. */ if (load_32bpp) return 0; @@ -256,7 +256,7 @@ uint8 LoadSpriteV1(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, siz return 0; } -uint8 LoadSpriteV2(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, uint count, uint16 control_flags, uint8 zoom_levels) +uint8_t LoadSpriteV2(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, uint count, uint16_t control_flags, uint8_t zoom_levels) { 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}; @@ -266,8 +266,8 @@ uint8 LoadSpriteV2(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, siz /* clamp to first 6 zoom levels, as in zoom_lvl_map */ zoom_levels &= 0x3F; - uint8 available_levels = GB(control_flags, load_32bpp ? SCC_32BPP_ZOOM_START : SCC_PAL_ZOOM_START, 6); - uint8 skip_levels = 0; + uint8_t available_levels = GB(control_flags, load_32bpp ? SCC_32BPP_ZOOM_START : SCC_PAL_ZOOM_START, 6); + uint8_t skip_levels = 0; ZoomLevel zoom_min = sprite_type == SpriteType::Font ? ZOOM_LVL_NORMAL : _settings_client.gui.sprite_zoom_min; if (unlikely(sprite_type == SpriteType::MapGen)) { @@ -284,14 +284,14 @@ uint8 LoadSpriteV2(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, siz if (zoom_levels == 0) { skip_levels = available_levels; } else if (zoom_levels != 0x3F) { - uint8 keep_levels = 0; - for (uint8 bit : SetBitIterator(zoom_levels)) { + uint8_t keep_levels = 0; + for (uint8_t bit : SetBitIterator(zoom_levels)) { if (HasBit(available_levels, bit)) { SetBit(keep_levels, bit); continue; } - uint8 below = ((1 << bit) - 1) & available_levels; + uint8_t below = ((1 << bit) - 1) & available_levels; if (below != 0) { SetBit(keep_levels, FindLastBit(below)); } else { @@ -305,11 +305,11 @@ uint8 LoadSpriteV2(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, siz /* 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(); @@ -404,7 +404,7 @@ uint8 LoadSpriteV2(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, siz return loaded_sprites; } -uint8 SpriteLoaderGrf::LoadSprite(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, uint count, uint16 control_flags, uint8 zoom_levels) +uint8_t SpriteLoaderGrf::LoadSprite(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, uint count, uint16_t control_flags, uint8_t zoom_levels) { if (this->container_ver >= 2) { return LoadSpriteV2(sprite, file, file_pos, sprite_type, load_32bpp, count, control_flags, zoom_levels); diff --git a/src/spriteloader/grf.hpp b/src/spriteloader/grf.hpp index 24c8131a6a..500e988365 100644 --- a/src/spriteloader/grf.hpp +++ b/src/spriteloader/grf.hpp @@ -17,7 +17,7 @@ class SpriteLoaderGrf FINAL : public SpriteLoader { byte container_ver; public: SpriteLoaderGrf(byte container_ver) : container_ver(container_ver) {} - uint8 LoadSprite(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, uint count, uint16 control_flags, uint8 zoom_levels) override; + uint8_t LoadSprite(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, uint count, uint16_t control_flags, uint8_t zoom_levels) override; }; #endif /* SPRITELOADER_GRF_HPP */ diff --git a/src/spriteloader/sprite_file_type.hpp b/src/spriteloader/sprite_file_type.hpp index c9c91f7989..7820d33058 100644 --- a/src/spriteloader/sprite_file_type.hpp +++ b/src/spriteloader/sprite_file_type.hpp @@ -12,7 +12,7 @@ #include "../random_access_file_type.h" -enum SpriteFileFlags : uint8 { +enum SpriteFileFlags : uint8_t { SFF_NONE = 0, SFF_USERGRF = 1 << 0, SFF_PROGSIG = 1 << 1, diff --git a/src/spriteloader/spriteloader.hpp b/src/spriteloader/spriteloader.hpp index e2e740c5e0..5c4559e7cc 100644 --- a/src/spriteloader/spriteloader.hpp +++ b/src/spriteloader/spriteloader.hpp @@ -33,11 +33,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 }; /** @@ -47,10 +47,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 @@ -81,7 +81,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::SpriteCollection &sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, uint count, uint16 control_flags, uint8 zoom_levels) = 0; + virtual uint8_t LoadSprite(SpriteLoader::SpriteCollection &sprite, SpriteFile &file, size_t file_pos, SpriteType sprite_type, bool load_32bpp, uint count, uint16_t control_flags, uint8_t zoom_levels) = 0; virtual ~SpriteLoader() = default; }; diff --git a/src/station.cpp b/src/station.cpp index 1ccc88d80a..043596c2e5 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -40,7 +40,7 @@ INSTANTIATE_POOL_METHODS(Station) std::array _extra_station_names; uint _extra_station_names_used; -uint8 _extra_station_names_probability; +uint8_t _extra_station_names_probability; const StationCargoList _empty_cargo_list{}; const FlowStatMap _empty_flows{}; @@ -189,7 +189,7 @@ bool BaseStation::SetRoadStopTileData(TileIndex tile, byte data, bool animation) { for (RoadStopTileData &tile_data : this->custom_roadstop_tile_data) { if (tile_data.tile == tile) { - uint8 &value = animation ? tile_data.animation_frame : tile_data.random_bits; + uint8_t &value = animation ? tile_data.animation_frame : tile_data.random_bits; if (value == data) return false; value = data; return true; @@ -331,7 +331,7 @@ static uint GetTileCatchmentRadius(TileIndex tile, const Station *st) { dbg_assert(IsTileType(tile, MP_STATION)); - const int32 inc = _settings_game.station.catchment_increase; + const int32_t inc = _settings_game.station.catchment_increase; if (_settings_game.station.modified_catchment) { switch (GetStationType(tile)) { diff --git a/src/station_base.h b/src/station_base.h index dfaab71b88..686d15bb16 100644 --- a/src/station_base.h +++ b/src/station_base.h @@ -47,12 +47,12 @@ enum ExtraStationNameInfoFlags { /** Extra station name string */ struct ExtraStationNameInfo { StringID str; - uint16 flags; + uint16_t flags; }; extern std::array _extra_station_names; extern uint _extra_station_names_used; -extern uint8 _extra_station_names_probability; +extern uint8_t _extra_station_names_probability; class FlowStatMap; @@ -73,7 +73,7 @@ public: #if OTTD_ALIGNMENT == 0 unaligned_uint32 first; #else - uint32 first; + uint32_t first; #endif StationID second; }; @@ -197,8 +197,8 @@ public: inline const_iterator begin() const { return this->data(); } inline iterator end() { return this->data() + this->count; } inline const_iterator end() const { return this->data() + this->count; } - inline iterator upper_bound(uint32 key) { return std::upper_bound(this->begin(), this->end(), key); } - inline const_iterator upper_bound(uint32 key) const { return std::upper_bound(this->begin(), this->end(), key); } + inline iterator upper_bound(uint32_t key) { return std::upper_bound(this->begin(), this->end(), key); } + inline const_iterator upper_bound(uint32_t key) const { return std::upper_bound(this->begin(), this->end(), key); } /** * Add some flow to the end of the shares map. Only do that if you know @@ -211,7 +211,7 @@ public: inline void AppendShare(StationID st, uint flow, bool restricted = false) { assert(flow > 0); - uint32 key = this->GetLastKey() + flow; + uint32_t key = this->GetLastKey() + flow; if (unlikely(this->count >= 2)) { if (this->count == 2) { // convert inline buffer to ptr @@ -222,7 +222,7 @@ public: this->storage.ptr_shares.elem_capacity = 4; } else if (this->count == this->storage.ptr_shares.elem_capacity) { // grow buffer - uint16 new_size = this->storage.ptr_shares.elem_capacity * 2; + uint16_t new_size = this->storage.ptr_shares.elem_capacity * 2; this->storage.ptr_shares.buffer = ReallocT(this->storage.ptr_shares.buffer, new_size); this->storage.ptr_shares.elem_capacity = new_size; } @@ -318,26 +318,26 @@ public: } /* for save/load use only */ - inline uint16 GetRawFlags() const + inline uint16_t GetRawFlags() const { return this->flags; } /* for save/load use only */ - inline void SetRawFlags(uint16 flags) + inline void SetRawFlags(uint16_t flags) { this->flags = flags;; } private: - uint32 GetLastKey() const + uint32_t GetLastKey() const { return this->data()[this->count - 1].first; } struct ptr_buffer { ShareEntry *buffer; - uint16 elem_capacity; + uint16_t elem_capacity; } #if OTTD_ALIGNMENT == 0 && (defined(__GNUC__) || defined(__clang__)) __attribute__((packed, aligned(4))) @@ -353,9 +353,9 @@ private: }; storage_union storage; ///< Shares of flow to be sent via specified station (or consumed locally). uint unrestricted; ///< Limit for unrestricted shares. - uint16 count; + uint16_t count; StationID origin; - uint16 flags; + uint16_t flags; }; static_assert(std::is_nothrow_move_constructible::value, "FlowStat must be nothrow move constructible"); #if OTTD_ALIGNMENT == 0 && (defined(__GNUC__) || defined(__clang__)) @@ -366,8 +366,8 @@ template class FlowStatMapIterator { friend FlowStatMap; - friend FlowStatMapIterator::iterator>; - friend FlowStatMapIterator::const_iterator>; + friend FlowStatMapIterator::iterator>; + friend FlowStatMapIterator::const_iterator>; public: typedef FlowStat value_type; typedef cv_value& reference; @@ -378,7 +378,7 @@ public: FlowStatMapIterator(cv_container *fsm, cv_index_iter current) : fsm(fsm), current(current) {} - FlowStatMapIterator(const FlowStatMapIterator::iterator> &other) : + FlowStatMapIterator(const FlowStatMapIterator::iterator> &other) : fsm(other.fsm), current(other.current) {} FlowStatMapIterator &operator=(const FlowStatMapIterator &) = default; @@ -403,11 +403,11 @@ private: /** Flow descriptions by origin stations. */ class FlowStatMap { std::vector flows_storage; - btree::btree_map flows_index; + btree::btree_map flows_index; public: - using iterator = FlowStatMapIterator::iterator>; - using const_iterator = FlowStatMapIterator::const_iterator>; + using iterator = FlowStatMapIterator::iterator>; + using const_iterator = FlowStatMapIterator::const_iterator>; friend iterator; friend const_iterator; @@ -424,9 +424,9 @@ public: void FinalizeLocalConsumption(StationID self); private: - btree::btree_map::iterator erase_priv(btree::btree_map::iterator iter) + btree::btree_map::iterator erase_priv(btree::btree_map::iterator iter) { - uint16 index = iter->second; + uint16_t index = iter->second; iter = this->flows_index.erase(iter); if (index != this->flows_storage.size() - 1) { this->flows_storage[index] = std::move(this->flows_storage.back()); @@ -477,7 +477,7 @@ public: std::pair insert(FlowStat flow_stat) { StationID st = flow_stat.GetOrigin(); - auto res = this->flows_index.insert(std::pair(st, (uint16)this->flows_storage.size())); + auto res = this->flows_index.insert(std::pair(st, (uint16_t)this->flows_storage.size())); if (res.second) { this->flows_storage.push_back(std::move(flow_stat)); } @@ -486,7 +486,7 @@ public: iterator insert(iterator hint, FlowStat flow_stat) { - auto res = this->flows_index.insert(hint.current, std::pair(flow_stat.GetOrigin(), (uint16)this->flows_storage.size())); + auto res = this->flows_index.insert(hint.current, std::pair(flow_stat.GetOrigin(), (uint16_t)this->flows_storage.size())); if (res->second == this->flows_storage.size()) { this->flows_storage.push_back(std::move(flow_stat)); } @@ -717,7 +717,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. @@ -886,8 +886,8 @@ public: TileArea docking_station; ///< Tile area the docking tiles cover std::vector docking_tiles; ///< Tile vector the docking tiles cover - IndustryType indtype; ///< Industry type to get the name from - uint16 extra_name_index; ///< Extra name index in use (or UINT16_MAX) + IndustryType indtype; ///< Industry type to get the name from + uint16_t extra_name_index; ///< Extra name index in use (or UINT16_MAX) BitmapTileArea catchment_tiles; ///< NOSAVE: Set of individual tiles covered by catchment area uint station_tiles; ///< NOSAVE: Count of station tiles owned by this station @@ -904,9 +904,9 @@ public: IndustryList industries_near; ///< Cached list of industries near the station that can accept cargo, @see DeliverGoodsToIndustry() Industry *industry; ///< NOSAVE: Associated industry for neutral stations. (Rebuilt on load from Industry->st) - CargoTypes station_cargo_history_cargoes; ///< Bitmask of cargoes in station_cargo_history - uint8 station_cargo_history_offset; ///< Start offset in station_cargo_history cargo ring buffer - std::vector> station_cargo_history; ///< Station history of waiting cargo, dynamic range compressed (see RXCompressUint) + CargoTypes station_cargo_history_cargoes; ///< Bitmask of cargoes in station_cargo_history + uint8_t station_cargo_history_offset; ///< Start offset in station_cargo_history cargo ring buffer + std::vector> station_cargo_history; ///< Station history of waiting cargo, dynamic range compressed (see RXCompressUint) Station(TileIndex tile = INVALID_TILE); ~Station(); @@ -962,7 +962,7 @@ public: bool IsWithinRangeOfDockingTile(TileIndex tile, uint max_distance) const; - uint32 GetNewGRFVariable(const ResolverObject &object, uint16 variable, byte parameter, bool *available) const override; + uint32_t GetNewGRFVariable(const ResolverObject &object, uint16_t 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 8dd470aa55..ab6ebb86c7 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -241,7 +241,7 @@ static bool FindNearIndustryName(TileIndex tile, void *user_data) static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming name_class, bool force_change = false) { - 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 @@ -301,7 +301,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n /* Oil rigs/mines name could be marked not free by looking for a near by industry. */ /* check default names */ - uint32 tmp = sni.free_names & _gen_station_name_bits[name_class]; + uint32_t tmp = sni.free_names & _gen_station_name_bits[name_class]; if (tmp != 0) return STR_SV_STNAME + FindFirstBit(tmp); /* check mine? */ @@ -323,7 +323,7 @@ static StringID GenerateStationName(Station *st, TileIndex tile, StationNaming n if (use_extra_names) { use_extra_names = false; const bool near_water = CountMapSquareAround(tile, CMSAWater) >= 5; - std::vector candidates; + std::vector candidates; for (uint i = 0; i < _extra_station_names_used; i++) { const ExtraStationNameInfo &info = _extra_station_names[i]; if (extra_names[i]) continue; @@ -384,7 +384,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)) ), @@ -941,7 +941,7 @@ CommandCost IsRailStationBridgeAboveOk(TileIndex tile, const StationSpec *statsp disallowed_pillar_flags = (BridgePiecePillarFlags) statspec->bridge_disallowed_pillars[layout]; } else if (!statspec) { // default stations/waypoints - static const uint8 st_flags[8] = { 0x50, 0xA0, 0x50, 0xA0, 0x50 | 0x26, 0xA0 | 0x1C, 0x50 | 0x89, 0xA0 | 0x43 }; + static const uint8_t st_flags[8] = { 0x50, 0xA0, 0x50, 0xA0, 0x50 | 0x26, 0xA0 | 0x1C, 0x50 | 0x89, 0xA0 | 0x43 }; disallowed_pillar_flags = (BridgePiecePillarFlags) st_flags[layout]; } else if (HasBit(statspec->blocked, layout)) { // non-track station tiles @@ -1474,7 +1474,7 @@ static void RestoreTrainReservation(Train *v) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { /* Unpack parameters */ RailType rt = Extract(p1); @@ -1484,7 +1484,7 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 bool adjacent = HasBit(p1, 24); StationClassID spec_class = Extract(p2); - uint16 spec_index = GB(p3, 0, 16); + uint16_t spec_index = GB(p3, 0, 16); StationID station_to_join = GB(p2, 16, 16); /* Does the authority allow this? */ @@ -1580,7 +1580,7 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 /* 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, rt); + uint16_t cb_res = GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, nullptr, INVALID_TILE, rt); if (cb_res != CALLBACK_FAILED && !Convert8bitBooleanCallback(statspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res)) return CMD_ERROR; } } @@ -1641,10 +1641,10 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32 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, rt); + uint16_t callback = GetStationCallback(CBID_STATION_TILE_LAYOUT, platinfo, 0, statspec, nullptr, tile, rt); if (callback != CALLBACK_FAILED) { if (callback < 8) { SetStationGfx(tile, (callback & ~1) + axis); @@ -1932,7 +1932,7 @@ CommandCost RemoveFromRailBaseStation(TileArea ta, std::vector &affected_st * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdRemoveFromRailStation(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRemoveFromRailStation(TileIndex start, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { TileIndex end = p1 == 0 ? start : p1; if (start >= MapSize() || end >= MapSize()) return CMD_ERROR; @@ -1966,7 +1966,7 @@ CommandCost CmdRemoveFromRailStation(TileIndex start, DoCommandFlag flags, uint3 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdRemoveFromRailWaypoint(TileIndex start, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRemoveFromRailWaypoint(TileIndex start, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { TileIndex end = p1 == 0 ? start : p1; if (start >= MapSize() || end >= MapSize()) return CMD_ERROR; @@ -2110,7 +2110,7 @@ static CommandCost FindJoiningRoadStop(StationID existing_stop, StationID statio * @param text Unused. * @return The cost of this operation or an error. */ -CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { bool type = HasBit(p2, 0); bool is_drive_through = HasBit(p2, 1); @@ -2121,11 +2121,11 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin if (!reuse) station_to_join = INVALID_STATION; bool distant_join = (station_to_join != INVALID_STATION); - uint8 width = (uint8)GB(p1, 0, 8); - uint8 length = (uint8)GB(p1, 8, 8); + uint8_t width = (uint8_t)GB(p1, 0, 8); + uint8_t length = (uint8_t)GB(p1, 8, 8); RoadStopClassID spec_class = Extract(p3); - uint16 spec_index = GB(p3, 16, 16); + uint16_t spec_index = GB(p3, 16, 16); /* Check if the given station class is valid */ if ((uint)spec_class >= RoadStopClass::GetClassCount() || spec_class == ROADSTOP_CLASS_WAYP) return CMD_ERROR; @@ -2199,7 +2199,7 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin /* 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, type ? STATION_TRUCK : STATION_BUS, 0); + uint16_t cb_res = GetRoadStopCallback(CBID_STATION_AVAILABILITY, 0, 0, roadstopspec, nullptr, INVALID_TILE, rt, type ? STATION_TRUCK : STATION_BUS, 0); if (cb_res != CALLBACK_FAILED && !Convert8bitBooleanCallback(roadstopspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res)) return CMD_ERROR; } } @@ -2492,10 +2492,10 @@ CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags, int replacement_ * @param text Unused. * @return The cost of this operation or an error. */ -CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { - uint8 width = (uint8)GB(p1, 0, 8); - uint8 height = (uint8)GB(p1, 8, 8); + uint8_t width = (uint8_t)GB(p1, 0, 8); + uint8_t height = (uint8_t)GB(p1, 8, 8); bool keep_drive_through_roads = !HasBit(p2, 1) || HasBit(p2, 2); /* Check for incorrect width / height. */ @@ -2517,7 +2517,7 @@ CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, ui if (!IsTileType(cur_tile, MP_STATION) || !IsRoadWaypoint(cur_tile)) continue; } else { /* Make sure the specified tile is a road stop of the correct type */ - if (!IsTileType(cur_tile, MP_STATION) || !IsStationRoadStop(cur_tile) || (uint32)GetRoadStopType(cur_tile) != GB(p2, 0, 1)) continue; + if (!IsTileType(cur_tile, MP_STATION) || !IsStationRoadStop(cur_tile) || (uint32_t)GetRoadStopType(cur_tile) != GB(p2, 0, 1)) continue; } /* Save information on to-be-restored roads before the stop is removed. */ @@ -2570,7 +2570,7 @@ CommandCost CmdRemoveRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, ui * @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*/ @@ -2582,7 +2582,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. */ @@ -2711,7 +2711,7 @@ static CommandCost CanRemoveAirport(Station *st, DoCommandFlag flags) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { StationID station_to_join = GB(p2, 16, 16); bool reuse = (station_to_join != NEW_STATION); @@ -2976,7 +2976,7 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdOpenCloseAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdOpenCloseAirport(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (!Station::IsValidID(p1)) return CMD_ERROR; Station *st = Station::Get(p1); @@ -3002,7 +3002,7 @@ CommandCost CmdOpenCloseAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, bool HasStationInUse(StationID station, bool include_company, CompanyID company) { bool found = false; - IterateOrderRefcountMapForDestinationID(station, [&](CompanyID cid, OrderType order_type, VehicleType veh_type, uint32 refcount) { + IterateOrderRefcountMapForDestinationID(station, [&](CompanyID cid, OrderType order_type, VehicleType veh_type, uint32_t refcount) { if ((cid == company) == include_company) { if (order_type == OT_GOTO_STATION || order_type == OT_GOTO_WAYPOINT) { found = true; @@ -3032,7 +3032,7 @@ static const byte _dock_h_chk[4] = { 1, 2, 1, 2 }; * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { StationID station_to_join = GB(p2, 16, 16); bool reuse = (station_to_join != NEW_STATION); @@ -3331,10 +3331,10 @@ static void DrawTile_Station(TileInfo *ti, DrawTileProcParams params) 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; @@ -3352,7 +3352,7 @@ static void DrawTile_Station(TileInfo *ti, DrawTileProcParams params) 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, INVALID_RAILTYPE); + uint16_t callback = GetStationCallback(CBID_STATION_SPRITE_LAYOUT, 0, 0, statspec, st, ti->tile, INVALID_RAILTYPE); if (callback != CALLBACK_FAILED) tile_layout = (callback & ~1) + GetRailStationAxis(ti->tile); } @@ -3430,7 +3430,7 @@ static void DrawTile_Station(TileInfo *ti, DrawTileProcParams params) 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 @@ -3443,7 +3443,7 @@ static void DrawTile_Station(TileInfo *ti, DrawTileProcParams params) /* 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) */ @@ -3454,7 +3454,7 @@ static void DrawTile_Station(TileInfo *ti, DrawTileProcParams params) 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. */ @@ -3514,9 +3514,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, INVALID_RAILTYPE, 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, INVALID_RAILTYPE, var10); layout->ProcessRegisters(var10, var10_relocation, separate_ground); } tmp_rail_layout.seq = layout->GetLayout(&tmp_rail_layout.ground); @@ -3642,7 +3642,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; @@ -3939,7 +3939,7 @@ void AnimateTile_Station(TileIndex tile) } } -uint8 GetAnimatedTileSpeed_Station(TileIndex tile) +uint8_t GetAnimatedTileSpeed_Station(TileIndex tile) { if (HasStationRail(tile)) { return GetStationTileAnimationSpeed(tile); @@ -4041,7 +4041,7 @@ static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, i return VETSB_CONTINUE; } front->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 < front->cur_speed) front->cur_speed = spd; } } @@ -4152,12 +4152,12 @@ bool GetNewGrfRating(const Station *st, const CargoSpec *cs, const GoodsEntry *g /* NewGRFs expect last speed to be 0xFF when no vehicle has arrived yet. */ uint last_speed = ge->HasVehicleEverTriedLoading() && ge->IsSupplyAllowed() ? ge->last_speed : 0xFF; - uint32 var18 = std::min(ge->time_since_pickup, 0xFFu) + uint32_t var18 = std::min(ge->time_since_pickup, 0xFFu) | (std::min(ge->max_waiting_cargo, 0xFFFFu) << 8) | (std::min(last_speed, 0xFFu) << 24); /* Convert to the 'old' vehicle types */ - uint32 var10 = (ge->last_vehicle_type == VEH_INVALID) ? 0x0 : (ge->last_vehicle_type + 0x10); - uint16 callback = GetCargoCallback(CBID_CARGO_STATION_RATING_CALC, var10, var18, cs); + uint32_t var10 = (ge->last_vehicle_type == VEH_INVALID) ? 0x0 : (ge->last_vehicle_type + 0x10); + uint16_t callback = GetCargoCallback(CBID_CARGO_STATION_RATING_CALC, var10, var18, cs); if (callback != CALLBACK_FAILED) { is_using_newgrf_rating = true; *new_grf_rating = GB(callback, 0, 14); @@ -4268,7 +4268,7 @@ int GetTargetRating(const Station *st, const CargoSpec *cs, const GoodsEntry *ge rating += GetStatueRating(st); rating += GetVehicleAgeRating(ge); - return ClampTo(rating); + return ClampTo(rating); } static void UpdateStationRating(Station *st) @@ -4334,7 +4334,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); @@ -4562,7 +4562,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); @@ -4758,7 +4758,7 @@ static bool IsUniqueStationName(const char *name) * @param text the new name or an empty string when resetting to the default * @return the cost of this operation or an error */ -CommandCost CmdRenameStation(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRenameStation(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Station *st = Station::GetIfValid(p1); if (st == nullptr) return CMD_ERROR; @@ -4813,7 +4813,7 @@ CommandCost CmdRenameStation(TileIndex tile, DoCommandFlag flags, uint32 p1, uin * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdExchangeStationNames(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdExchangeStationNames(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Station *st = Station::GetIfValid(p1); if (st == nullptr) return CMD_ERROR; @@ -4858,7 +4858,7 @@ CommandCost CmdExchangeStationNames(TileIndex tile, DoCommandFlag flags, uint32 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdSetStationCargoAllowedSupply(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSetStationCargoAllowedSupply(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Station *st = Station::GetIfValid(p1); if (st == nullptr) return CMD_ERROR; @@ -4992,7 +4992,7 @@ uint MoveGoodsToStation(CargoID type, uint amount, SourceType source_type, Sourc uint owner = p.first->owner; /* Multiply the amount by (company best / sum of best for each company) to get cargo allocated to a company * and by (station rating / sum of ratings in a company) to get the result for a single station. */ - p.second = ((uint64) amount) * ((uint64) company_best[owner]) * ((uint64) p.first->goods[type].rating) / (best_sum * company_sum[owner]); + p.second = ((uint64_t) amount) * ((uint64_t) company_best[owner]) * ((uint64_t) p.first->goods[type].rating) / (best_sum * company_sum[owner]); moving += p.second; } @@ -5343,7 +5343,7 @@ FlowStat::iterator FlowStat::erase_item(FlowStat::iterator iter, uint flow_reduc */ uint FlowStat::GetShare(StationID st) const { - uint32 prev = 0; + uint32_t prev = 0; for (const_iterator it = this->begin(); it != this->end(); ++it) { if (it->second == st) { return it->first - prev; @@ -5520,7 +5520,7 @@ void FlowStat::ScaleToMonthly(uint runtime) assert(runtime > 0); uint share = 0; for (iterator i = this->begin(); i != this->end(); ++i) { - share = std::max(share + 1, ClampTo((static_cast(i->first) * 30 * DAY_TICKS * _settings_game.economy.day_length_factor) / runtime)); + share = std::max(share + 1, ClampTo((static_cast(i->first) * 30 * DAY_TICKS * _settings_game.economy.day_length_factor) / runtime)); if (this->unrestricted == i->first) this->unrestricted = share; i->first = share; } @@ -5682,7 +5682,7 @@ void FlowStatMap::SortStorage() std::sort(this->flows_storage.begin(), this->flows_storage.end(), [](const FlowStat &a, const FlowStat &b) -> bool { return a.origin < b.origin; }); - uint16 index = 0; + uint16_t index = 0; for (auto &it : this->flows_index) { it.second = index; index++; @@ -5698,7 +5698,7 @@ void DumpStationFlowStats(char *b, const char *last) const GoodsEntry &ge = st->goods[i]; if (ge.data == nullptr) continue; for (FlowStatMap::const_iterator it(ge.data->flows.begin()); it != ge.data->flows.end(); ++it) { - count_map[(uint32)it->size()]++; + count_map[(uint32_t)it->size()]++; invalid_map[it->GetRawFlags() & 0x1F]++; } } diff --git a/src/station_func.h b/src/station_func.h index bd02531785..60ddd129b8 100644 --- a/src/station_func.h +++ b/src/station_func.h @@ -47,7 +47,7 @@ void UpdateAirportsNoise(); bool SplitGroundSpriteForOverlay(const TileInfo *ti, SpriteID *ground, RailTrackOffset *overlay_offset); -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); void RerouteCargo(Station *st, CargoID c, StationID avoid, StationID avoid2); void RerouteCargoFromSource(Station *st, CargoID c, StationID source, StationID avoid, StationID avoid2); diff --git a/src/station_gui.cpp b/src/station_gui.cpp index c92c680038..0e2f8882ed 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -474,7 +474,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->filter.cargoes, cs->Index())) { this->LowerWidget(WID_STL_CARGOSTART + index); @@ -1584,7 +1584,7 @@ struct StationViewWindow : public Window { this->vscroll->SetCount(cargo.GetNumChildren()); // update scrollbar byte have_veh_types = 0; - IterateOrderRefcountMapForDestinationID(st->index, [&](CompanyID cid, OrderType order_type, VehicleType veh_type, uint32 refcount) { + IterateOrderRefcountMapForDestinationID(st->index, [&](CompanyID cid, OrderType order_type, VehicleType veh_type, uint32_t refcount) { SetBit(have_veh_types, veh_type); return true; }); @@ -1667,7 +1667,7 @@ struct StationViewWindow : public Window { for (const auto &it : flows) { StationID from = it.GetOrigin(); CargoDataEntry *source_entry = cargo_entry->InsertOrRetrieve(from); - uint32 prev_count = 0; + uint32_t prev_count = 0; for (const auto &flow_it : it) { StationID via = flow_it.second; CargoDataEntry *via_entry = source_entry->InsertOrRetrieve(via); @@ -1700,7 +1700,7 @@ struct StationViewWindow : public Window { const FlowStatMap &flowmap = ge.data->flows; FlowStatMap::const_iterator map_it = flowmap.find(source); if (map_it != flowmap.end()) { - uint32 prev_count = 0; + uint32_t prev_count = 0; for (FlowStat::const_iterator i = map_it->begin(); i != map_it->end(); ++i) { tmp.InsertOrRetrieve(i->second)->Update(i->first - prev_count); prev_count = i->first; @@ -2790,7 +2790,7 @@ public: 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 { const int scr_top = GetMainViewTop() + 2; const int scr_bot = GetMainViewBottom() - 2; diff --git a/src/station_kdtree.h b/src/station_kdtree.h index a4e6c12b6e..a8d48113ee 100644 --- a/src/station_kdtree.h +++ b/src/station_kdtree.h @@ -15,8 +15,8 @@ #include "station_base.h" #include "map_func.h" -inline uint32 Kdtree_StationXYFunc(StationID stid, int dim) { return (dim == 0) ? TileX(BaseStation::Get(stid)->xy) : TileY(BaseStation::Get(stid)->xy); } -typedef Kdtree StationKdtree; +inline uint32_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) { - uint32 x1, y1, x2, y2; - x1 = (uint32)std::max(0, TileX(center) - radius); - x2 = (uint32)std::min(TileX(center) + radius + 1, MapSizeX()); - y1 = (uint32)std::max(0, TileY(center) - radius); - y2 = (uint32)std::min(TileY(center) + radius + 1, MapSizeY()); + uint32_t x1, y1, x2, y2; + x1 = (uint32_t)std::max(0, TileX(center) - radius); + x2 = (uint32_t)std::min(TileX(center) + radius + 1, MapSizeX()); + y1 = (uint32_t)std::max(0, TileY(center) - radius); + y2 = (uint32_t)std::min(TileY(center) + radius + 1, MapSizeY()); _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 84309897ca..01d67d8bd5 100644 --- a/src/station_type.h +++ b/src/station_type.h @@ -14,9 +14,9 @@ #include "tilearea_type.h" #include "3rdparty/cpp-btree/btree_set.h" -typedef uint16 StationID; -typedef uint16 RoadStopID; -typedef uint16 DockID; +typedef uint16_t StationID; +typedef uint16_t RoadStopID; +typedef uint16_t DockID; struct BaseStation; struct Station; diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index f9f24c88fe..0db68b608c 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -77,7 +77,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; @@ -98,8 +98,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/stdafx.h b/src/stdafx.h index 594f17aa64..4ca7bce42a 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -427,13 +427,13 @@ static_assert(SIZE_MAX >= UINT32_MAX); #endif /* __GNUC__ || __clang__ */ #if defined(__GNUC__) || defined(__clang__) -__attribute__((aligned(1))) typedef uint16 unaligned_uint16; -__attribute__((aligned(1))) typedef uint32 unaligned_uint32; -__attribute__((aligned(1))) typedef uint64 unaligned_uint64; +__attribute__((aligned(1))) typedef uint16_t unaligned_uint16; +__attribute__((aligned(1))) typedef uint32_t unaligned_uint32; +__attribute__((aligned(1))) typedef uint64_t unaligned_uint64; #else -typedef uint16 unaligned_uint16; -typedef uint32 unaligned_uint32; -typedef uint64 unaligned_uint64; +typedef uint16_t unaligned_uint16; +typedef uint32_t unaligned_uint32; +typedef uint64_t unaligned_uint64; #endif /* __GNUC__ || __clang__ */ /* For the FMT library we only want to use the headers, not link to some library. */ @@ -442,7 +442,7 @@ typedef uint64 unaligned_uint64; void NORETURN CDECL usererror(const char *str, ...) WARN_FORMAT(1, 2); void NORETURN CDECL error(const char *str, ...) WARN_FORMAT(1, 2); void NORETURN CDECL assert_msg_error(int line, const char *file, const char *expr, const char *extra, const char *str, ...) WARN_FORMAT(5, 6); -const char *assert_tile_info(uint32 tile); +const char *assert_tile_info(uint32_t tile); #define NOT_REACHED() error("NOT_REACHED triggered at line %i of %s", __LINE__, __FILE__) /* Asserts are enabled if NDEBUG isn't defined or WITH_ASSERT is defined. */ diff --git a/src/story.cpp b/src/story.cpp index 1f2484ce2b..673511848d 100644 --- a/src/story.cpp +++ b/src/story.cpp @@ -31,8 +31,8 @@ StoryPageElementID _new_story_page_element_id; StoryPageID _new_story_page_id; -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"); @@ -49,7 +49,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 }; @@ -93,7 +93,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: @@ -204,7 +204,7 @@ bool StoryPageButtonData::ValidateVehicleType() const * @param text Title of the story page. Null is allowed in which case a generic page title is provided by OpenTTD. * @return the cost of this operation or an error */ -CommandCost CmdCreateStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdCreateStoryPage(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (!StoryPage::CanAllocateItem()) return CMD_ERROR; @@ -250,7 +250,7 @@ CommandCost CmdCreateStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, u * @param text Text content in case it is a text or location page element * @return the cost of this operation or an error */ -CommandCost CmdCreateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdCreateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (!StoryPageElement::CanAllocateItem()) return CMD_ERROR; @@ -258,7 +258,7 @@ CommandCost CmdCreateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint3 StoryPageElementType type = Extract(p1); /* 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++; } @@ -300,7 +300,7 @@ CommandCost CmdCreateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint3 * @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(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdUpdateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { StoryPageElementID page_element_id = (StoryPageElementID)GB(p1, 0, 16); @@ -330,7 +330,7 @@ CommandCost CmdUpdateStoryPageElement(TileIndex tile, DoCommandFlag flags, uint3 * @param text title text of the story page. * @return the cost of this operation or an error */ -CommandCost CmdSetStoryPageTitle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSetStoryPageTitle(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; StoryPageID page_id = (StoryPageID)GB(p1, 0, 16); @@ -359,7 +359,7 @@ CommandCost CmdSetStoryPageTitle(TileIndex tile, DoCommandFlag flags, uint32 p1, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdSetStoryPageDate(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSetStoryPageDate(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; StoryPageID page_id = (StoryPageID)GB(p1, 0, 16); @@ -386,7 +386,7 @@ CommandCost CmdSetStoryPageDate(TileIndex tile, DoCommandFlag flags, uint32 p1, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdShowStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdShowStoryPage(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; StoryPageID page_id = (StoryPageID)GB(p1, 0, 16); @@ -408,7 +408,7 @@ CommandCost CmdShowStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uin * @param text unused. * @return the cost of this operation or an error */ -CommandCost CmdRemoveStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRemoveStoryPage(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; StoryPageID page_id = (StoryPageID)p1; @@ -441,7 +441,7 @@ CommandCost CmdRemoveStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, u * @param text unused. * @return the cost of this operation or an error */ -CommandCost CmdRemoveStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRemoveStoryPageElement(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; StoryPageElementID page_element_id = (StoryPageElementID)p1; @@ -468,7 +468,7 @@ CommandCost CmdRemoveStoryPageElement(TileIndex tile, DoCommandFlag flags, uint3 * @param text Unused. * @return The cost of the operation, or an error. */ -CommandCost CmdStoryPageButton(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdStoryPageButton(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { StoryPageElementID page_element_id = (StoryPageElementID)GB(p1, 0, 16); diff --git a/src/story_base.h b/src/story_base.h index 258c3293df..07ed408ed5 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. @@ -115,7 +115,7 @@ template <> struct EnumPropsT : MakeEnumPropsT { - 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 /** @@ -157,7 +157,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. 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_gui.cpp b/src/story_gui.cpp index 0cc8fea4d4..678947642c 100644 --- a/src/story_gui.cpp +++ b/src/story_gui.cpp @@ -252,7 +252,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()) { @@ -635,7 +635,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(); @@ -1045,7 +1045,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 1dce00008b..519ce00222 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; diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp index 00322461d1..b4f2a0df72 100644 --- a/src/strgen/strgen.cpp +++ b/src/strgen/strgen.cpp @@ -132,7 +132,7 @@ struct FileStringReader : StringReader { char *ReadLine(char *buffer, const char *last) override { - char *result = fgets(buffer, ClampTo(last - buffer + 1), this->fh); + char *result = fgets(buffer, ClampTo(last - buffer + 1), this->fh); if (result == nullptr && this->fh2 != nullptr) { fclose(this->fh); this->fh = this->fh2; @@ -190,14 +190,14 @@ void FileStringReader::HandlePragma(char *str) if (langid > (long)UINT16_MAX || langid < 0) { error("Invalid winlangid %s", 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) { error("Invalid grflangid %s", buf); } - _lang.newgrflangid = (uint8)langid; + _lang.newgrflangid = (uint8_t)langid; } else if (!memcmp(str, "gender ", 7)) { if (this->master) error("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 0297ee0c2f..f08039200f 100644 --- a/src/strgen/strgen_base.cpp +++ b/src/strgen/strgen_base.cpp @@ -183,7 +183,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); @@ -207,7 +207,7 @@ struct Buffer : std::vector { size_t Utf8Validate(const char *s) { - uint32 c; + uint32_t c; if (!HasBit(s[0], 7)) { /* 1 byte */ @@ -429,7 +429,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) strgen_fatal("Invalid case-name '%s'", case_str); return case_idx + 1; } @@ -657,7 +657,7 @@ void StringReader::HandleString(char *str) size_t len = Utf8Validate(tmp); if (len == 0) strgen_fatal("Invalid UTF-8 sequence in '%s'", 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 b68112f71c..7a70cce256 100644 --- a/src/string.cpp +++ b/src/string.cpp @@ -192,7 +192,7 @@ const char *str_fix_scc_encoded(char *str, const char *last) size_t len = Utf8EncodedCharLen(*str); if ((len == 0 && str + 4 > last) || str + len > last) break; - WChar c; + char32_t c; Utf8Decode(&c, str); if (c == '\0') break; @@ -244,7 +244,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. @@ -371,7 +371,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; @@ -539,7 +539,7 @@ bool StrEqualsIgnoreCase(const std::string_view str1, const std::string_view str void str_strip_colours(char *str) { char *dst = str; - WChar c; + char32_t c; size_t len; for (len = Utf8Decode(&c, str); c != '\0'; len = Utf8Decode(&c, str)) { @@ -577,7 +577,7 @@ std::string str_strip_all_scc(const char *str) std::string out; if (!str) return out; - WChar c; + char32_t c; size_t len; for (len = Utf8Decode(&c, str); c != '\0'; len = Utf8Decode(&c, str)) { @@ -601,7 +601,7 @@ std::string str_strip_all_scc(const char *str) * @param replace The character to replace, may be 0 to not insert any character * @return The pointer to the terminating null-character in the string buffer */ -char *str_replace_wchar(char *str, const char *last, WChar find, WChar replace) +char *str_replace_wchar(char *str, const char *last, char32_t find, char32_t replace) { char *dst = str; @@ -614,7 +614,7 @@ char *str_replace_wchar(char *str, const char *last, WChar find, WChar replace) * within the encoding of an UTF8 character. */ if ((len == 0 && str + 4 > last) || str + len > last) break; - WChar c; + char32_t c; len = Utf8Decode(&c, str); /* It's possible to encode the string termination character * into a multiple bytes. This prevents those termination @@ -707,10 +707,10 @@ 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) { #if !defined(STRGEN) && !defined(SETTINGSGEN) - extern WChar GetDecimalSeparatorChar(); + extern char32_t GetDecimalSeparatorChar(); #endif switch (afilter) { case CS_ALPHANUMERAL: return IsPrintable(key); @@ -797,7 +797,7 @@ int CDECL seprintf(char *str, const char *last, const char *format, ...) * @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) { dbg_assert(c != nullptr); @@ -838,7 +838,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; @@ -864,12 +864,12 @@ 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); } @@ -1148,7 +1148,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 { @@ -1203,7 +1203,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. */ @@ -1235,7 +1235,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. */ @@ -1297,13 +1297,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)) { @@ -1339,7 +1339,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 d696011b2a..f9dbe8200d 100644 --- a/src/string_func.h +++ b/src/string_func.h @@ -59,7 +59,7 @@ inline const char *strip_leading_colours(const std::string &str) std::string str_strip_all_scc(const char *str); -char *str_replace_wchar(char *str, const char *last, WChar find, WChar replace); +char *str_replace_wchar(char *str, const char *last, char32_t find, char32_t replace); bool strtolower(char *str); bool strtolower(std::string &str, std::string::size_type offs = 0); diff --git a/src/string_type.h b/src/string_type.h index b61e0028d5..bd2e595163 100644 --- a/src/string_type.h +++ b/src/string_type.h @@ -39,13 +39,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 20696d1c95..f184ec4633 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 99665e2289..925c0e74dd 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -427,9 +427,9 @@ static void FormatHexNumber(StringBuilder builder, uint64_t number) fmt::format_to(builder, "0x{:X}", number); } -WChar GetDecimalSeparatorChar() +char32_t GetDecimalSeparatorChar() { - WChar decimal_char = '.'; + char32_t decimal_char = '.'; const char *decimal_separator = _settings_game.locale.digit_decimal_separator.c_str(); if (StrEmpty(decimal_separator)) decimal_separator = _langpack.langpack->digit_decimal_separator; if (!StrEmpty(decimal_separator)) Utf8Decode(&decimal_char, decimal_separator); @@ -1903,7 +1903,7 @@ static void FormatString(StringBuilder builder, const char *str_arg, StringParam case SCC_VIEWPORT_TOWN_LABEL1: case SCC_VIEWPORT_TOWN_LABEL2: { // {VIEWPORT_TOWN_LABEL1..2} int32_t t = args.GetNextParameter(); - uint64 data = args.GetNextParameter(); + uint64_t data = args.GetNextParameter(); bool tiny = (b == SCC_VIEWPORT_TOWN_LABEL2); StringID string_id = STR_VIEWPORT_TOWN_COLOUR; diff --git a/src/strings_func.h b/src/strings_func.h index f6e4b71ddb..e4fe4c1454 100644 --- a/src/strings_func.h +++ b/src/strings_func.h @@ -67,7 +67,7 @@ inline StringID MakeStringID(StringTab tab, uint index) std::string GetString(StringID string); const char *GetStringPtr(StringID string); -uint32 GetStringGRFID(StringID string); +uint32_t GetStringGRFID(StringID string); uint ConvertKmhishSpeedToDisplaySpeed(uint speed, VehicleType type); uint ConvertDisplaySpeedToKmhishSpeed(uint speed, VehicleType type); @@ -82,10 +82,10 @@ 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); } -WChar GetDecimalSeparatorChar(); +char32_t GetDecimalSeparatorChar(); /** * Set a string parameter \a v at index \a n in the global string parameter array. @@ -97,7 +97,7 @@ inline void SetDParam(size_t n, T &&v) { _global_string_params.SetParam(n, std::forward(v)); } -void SetDParamMaxValue(size_t n, uint64 max_value, uint min_count = 0, FontSize size = FS_NORMAL); +void SetDParamMaxValue(size_t n, uint64_t max_value, uint min_count = 0, FontSize size = FS_NORMAL); void SetDParamMaxDigits(size_t n, uint count, FontSize size = FS_NORMAL); void SetDParamStr(size_t n, const char *str); @@ -112,7 +112,7 @@ bool HaveDParamChanged(const std::vector &backup); * @param n Index of the string parameter. * @return Value of the requested string parameter. */ -inline uint64 GetDParam(size_t n) +inline uint64_t GetDParam(size_t n) { return _global_string_params.GetParam(n); } diff --git a/src/strings_type.h b/src/strings_type.h index 245eb0c5f0..2fe79339a4 100644 --- a/src/strings_type.h +++ b/src/strings_type.h @@ -15,7 +15,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 e540071e8e..addba4307e 100644 --- a/src/subsidy.cpp +++ b/src/subsidy.cpp @@ -243,7 +243,7 @@ void CreateSubsidy(CargoID cid, SourceType src_type, SourceID src, SourceType ds * @param text unused. * @return the cost of this operation or an error */ -CommandCost CmdCreateSubsidy(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdCreateSubsidy(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (!Subsidy::CanAllocateItem()) return CMD_ERROR; @@ -341,13 +341,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..6684268f35 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..c1c0cab878 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 bc7ad87dc1..c9d4d77d01 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 0eccc0895d..55667dd972 100644 --- a/src/table/newgrf_debug_data.h +++ b/src/table/newgrf_debug_data.h @@ -48,7 +48,7 @@ static uint GetTownInspectWindowNumber(const Town *town) return GetInspectWindowNumber(GSF_FAKE_TOWNS, town->index); } -static bool IsLabelPrintable(uint32 l) +static bool IsLabelPrintable(uint32_t l) { for (uint i = 0; i < 4; i++) { if ((l & 0xFF) < 0x20 || (l & 0xFF) > 0x7F) return false; @@ -58,7 +58,7 @@ static bool IsLabelPrintable(uint32 l) } struct label_dumper { - inline const char *Label(uint32 label) + inline const char *Label(uint32_t label) { if (IsLabelPrintable(label)) { seprintf(this->buffer, lastof(this->buffer), "%c%c%c%c", label >> 24, label >> 16, label >> 8, label); @@ -169,7 +169,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, Vehicle::Get(index)->First()->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, GetVariableExtra *extra) const override { @@ -404,7 +404,7 @@ class NIHVehicle : public NIHelper { break; case TRLIT_SPEED_ADAPTATION: { TileIndex tile = item.data_id; - uint16 td = item.data_aux; + uint16_t td = item.data_aux; b += seprintf(b, lastof(buffer), "speed adaptation: tile: %X, trackdir: %X", tile, td); if (item.end + 1 < l.reservation_end_position) { b += seprintf(b, lastof(buffer), " --> %u", GetLowestSpeedTrainAdaptationSpeedAtSignal(tile, td)); @@ -518,7 +518,7 @@ class NIHVehicle : public NIHelper { seprintf(buffer, lastof(buffer), " Callbacks: 0x%X, CB36 Properties: 0x" OTTD_PRINTFHEX64, e->callbacks_used, e->cb36_properties_used); output.print(buffer); - uint64 cb36_properties = e->cb36_properties_used; + uint64_t cb36_properties = e->cb36_properties_used; if (!e->sprite_group_cb36_properties_used.empty()) { const SpriteGroup *root_spritegroup = nullptr; if (v->IsGroundVehicle()) root_spritegroup = GetWagonOverrideSpriteSet(v->engine_type, v->cargo_type, v->GetGroundVehicleCache()->first_engine); @@ -535,11 +535,11 @@ class NIHVehicle : public NIHelper { } } if (cb36_properties != UINT64_MAX) { - uint64 props = cb36_properties; + uint64_t props = cb36_properties; while (props) { PropertyID prop = (PropertyID)FindFirstBit(props); props = KillFirstBit(props); - uint16 res = GetVehicleProperty(v, prop, CALLBACK_FAILED); + uint16_t res = GetVehicleProperty(v, prop, CALLBACK_FAILED); if (res == CALLBACK_FAILED) { seprintf(buffer, lastof(buffer), " CB36: 0x%X --> FAILED", prop); } else { @@ -723,7 +723,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, GetVariableExtra *extra) const override { @@ -761,7 +761,7 @@ class NIHStation : public NIHelper { } seprintf(b, lastof(buffer), ", register flags: %X", reg->flags); output.print(buffer); - auto log_reg = [&](TileLayoutFlags flag, const char *name, uint8 flag_reg) { + auto log_reg = [&](TileLayoutFlags flag, const char *name, uint8_t flag_reg) { if (reg->flags & flag) { seprintf(buffer, lastof(buffer), " %s reg: %X", name, flag_reg); output.print(buffer); @@ -877,7 +877,7 @@ class NIHHouse : public NIHelper { const void *GetInstance(uint)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, GetVariableExtra *extra) const override { @@ -966,7 +966,7 @@ class NIHIndustryTile : public NIHelper { const void *GetInstance(uint)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, GetVariableExtra *extra) const override { @@ -1099,7 +1099,7 @@ class NIHIndustry : public NIHelper { bool ShowSpriteDumpButton(uint index) const override { return true; } uint GetParent(uint index) const override { return HasBit(index, 26) ? UINT32_MAX : GetTownInspectWindowNumber(Industry::Get(index)->town); } const void *GetInstance(uint index)const override { return HasBit(index, 26) ? nullptr : Industry::Get(index); } - uint32 GetGRFID(uint index) const override { return (!this->ShowExtraInfoOnly(index)) ? ((const IndustrySpec *)this->GetSpec(index))->grf_prop.grffile->grfid : 0; } + uint32_t GetGRFID(uint index) const override { return (!this->ShowExtraInfoOnly(index)) ? ((const IndustrySpec *)this->GetSpec(index))->grf_prop.grffile->grfid : 0; } bool ShowExtraInfoOnly(uint index) const override { @@ -1138,16 +1138,16 @@ class NIHIndustry : public NIHelper { return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, extra); } - 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); } - std::vector GetPSAGRFIDs(uint index) const override + std::vector GetPSAGRFIDs(uint index) const override { return { 0 }; } @@ -1261,7 +1261,7 @@ class NIHCargo : public NIHelper { const void *GetInstance(uint index)const override { return nullptr; } const void *GetSpec(uint index) const override { return CargoSpec::Get(index); } void SetStringParameters(uint index) const override { SetDParam(0, CargoSpec::Get(index)->name); } - uint32 GetGRFID(uint index) const override { return (!this->ShowExtraInfoOnly(index)) ? CargoSpec::Get(index)->grffile->grfid : 0; } + uint32_t GetGRFID(uint index) const override { return (!this->ShowExtraInfoOnly(index)) ? CargoSpec::Get(index)->grffile->grfid : 0; } uint Resolve(uint index, uint var, uint param, GetVariableExtra *extra) const override { @@ -1300,7 +1300,7 @@ class NIHCargo : public NIHelper { seprintf(buffer, lastof(buffer), " Weight: %u, Capacity multiplier: %u", spec->weight, spec->multiplier); output.print(buffer); seprintf(buffer, lastof(buffer), " Initial payment: %d, Current payment: " OTTD_PRINTF64 ", Transit periods: (%u, %u)", - spec->initial_payment, (int64)spec->current_payment, spec->transit_periods[0], spec->transit_periods[1]); + spec->initial_payment, (int64_t)spec->current_payment, spec->transit_periods[0], spec->transit_periods[1]); output.print(buffer); seprintf(buffer, lastof(buffer), " Freight: %s, Town effect: %u", spec->is_freight ? "yes" : "no", spec->town_effect); output.print(buffer); @@ -1376,13 +1376,13 @@ class NIHSignals : 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_SIGNALS, 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, GetVariableExtra *extra) const override { extern TraceRestrictProgram *GetFirstTraceRestrictProgramOnTile(TileIndex t); CustomSignalSpriteContext ctx = CSSC_TRACK; - uint8 style = 0; + uint8_t style = 0; uint z = 0; if (IsTunnelBridgeWithSignalSimulation(index)) { ctx = IsTunnelBridgeSignalSimulationEntrance(index) ? CSSC_TUNNEL_BRIDGE_ENTRANCE : CSSC_TUNNEL_BRIDGE_EXIT; @@ -1510,7 +1510,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->ShowExtraInfoOnly(index)) ? ObjectSpec::GetByTile(index)->grf_prop.grffile->grfid : 0; } + uint32_t GetGRFID(uint index) const override { return (!this->ShowExtraInfoOnly(index)) ? ObjectSpec::GetByTile(index)->grf_prop.grffile->grfid : 0; } uint Resolve(uint index, uint var, uint param, GetVariableExtra *extra) const override { @@ -1621,14 +1621,14 @@ static const NIVariable _niv_railtypes[] = { NIV_END() }; -static void PrintTypeLabels(char *buffer, const char *last, const char *prefix, uint32 label, const uint32 *alternate_labels, size_t alternate_labels_count, std::function &print) +static void PrintTypeLabels(char *buffer, const char *last, const char *prefix, uint32_t label, const uint32_t *alternate_labels, size_t alternate_labels_count, std::function &print) { if (alternate_labels_count > 0) { char *b = buffer; b += seprintf(b, last, "%sAlternate labels: ", prefix); for (size_t i = 0; i < alternate_labels_count; i++) { if (i != 0) b += seprintf(b, last, ", "); - uint32 l = alternate_labels[i]; + uint32_t l = alternate_labels[i]; b += seprintf(b, last, "%s", label_dumper().Label(l)); } print(buffer); @@ -1642,7 +1642,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, GetVariableExtra *extra) const override { @@ -1693,7 +1693,7 @@ class NIHRailType : public NIHelper { dump_railtypes("Compatible", info->compatible_railtypes, RAILTYPES_NONE); dump_railtypes("All compatible", info->all_compatible_railtypes, ~info->compatible_railtypes); - PrintTypeLabels(buffer, lastof(buffer), " ", info->label, (const uint32*) info->alternate_labels.data(), info->alternate_labels.size(), output.print); + PrintTypeLabels(buffer, lastof(buffer), " ", info->label, (const uint32_t*) info->alternate_labels.data(), info->alternate_labels.size(), output.print); seprintf(buffer, lastof(buffer), " Cost multiplier: %u/8, Maintenance multiplier: %u/8", info->cost_multiplier, info->maintenance_multiplier); output.print(buffer); @@ -1791,7 +1791,7 @@ class NIHAirportTile : public NIHelper { const void *GetInstance(uint)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, GetVariableExtra *extra) const override { @@ -1902,9 +1902,9 @@ class NIHTown : public NIHelper { const void *GetInstance(uint index)const override { return Town::Get(index); } const void *GetSpec(uint) 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, GetVariableExtra *extra) const override { @@ -1912,7 +1912,7 @@ class NIHTown : public NIHelper { return ro.GetScope(VSG_SCOPE_SELF)->GetVariable(var, param, extra); } - 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); @@ -1923,11 +1923,11 @@ class NIHTown : public NIHelper { return nullptr; } - virtual std::vector GetPSAGRFIDs(uint index) const override + virtual std::vector GetPSAGRFIDs(uint index) const override { Town *t = Town::Get(index); - std::vector output; + std::vector output; for (const auto &iter : t->psa_list) { output.push_back(iter->grfid); } @@ -1958,7 +1958,7 @@ class NIHTown : public NIHelper { if (t->have_ratings != 0) { output.print(" Company ratings:"); - for (uint8 bit : SetBitIterator(t->have_ratings)) { + for (uint8_t bit : SetBitIterator(t->have_ratings)) { seprintf(buffer, lastof(buffer), " %u: %d", bit, t->ratings[bit]); output.print(buffer); } @@ -1996,7 +1996,7 @@ class NIHStationStruct : public NIHelper { } } - 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, GetVariableExtra *extra) const override { @@ -2142,7 +2142,7 @@ class NIHTraceRestrict : public NIHelper { SetDParam(2, GetTraceRestrictRefIdTrack(static_cast(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, GetVariableExtra *extra) const override { @@ -2199,7 +2199,7 @@ class NIHTraceRestrict : public NIHelper { seprintf(buffer, lastof(buffer), "Ref count: %u", prog->refcount); output.print(buffer); const TraceRestrictRefId *refs = prog->GetRefIdsPtr(); - for (uint32 i = 0; i < prog->refcount; i++) { + for (uint32_t i = 0; i < prog->refcount; i++) { TileIndex tile = GetTraceRestrictRefIdTileIndex(refs[i]); seprintf(buffer, lastof(buffer), " %X x %X, track: %X", TileX(tile), TileY(tile), GetTraceRestrictRefIdTrack(refs[i])); output.print(buffer); @@ -2248,7 +2248,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_ROAD_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, GetVariableExtra *extra) const override { @@ -2291,7 +2291,7 @@ class NIHRoadType : public NIHelper { if (output.flags & (1 << rtt)) { DumpRoadTypeList(output, " ", rti->powered_roadtypes); } - PrintTypeLabels(buffer, lastof(buffer), " ", rti->label, (const uint32*) rti->alternate_labels.data(), rti->alternate_labels.size(), output.print); + PrintTypeLabels(buffer, lastof(buffer), " ", rti->label, (const uint32_t*) rti->alternate_labels.data(), rti->alternate_labels.size(), output.print); seprintf(buffer, lastof(buffer), " Cost multiplier: %u/8, Maintenance multiplier: %u/8", rti->cost_multiplier, rti->maintenance_multiplier); output.print(buffer); }; @@ -2382,7 +2382,7 @@ 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, uint param, GetVariableExtra *extra) const override { @@ -2452,7 +2452,7 @@ class NIHNewLandscape : 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_LAI_CLEAR_DESCRIPTION_ROCKS, 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, GetVariableExtra *extra) const override { diff --git a/src/table/object_land.h b/src/table/object_land.h index fe3b055369..3749e956c0 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 cd3848bcf3..d285badaec 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 0b2ca5a684..573c041cbd 100644 --- a/src/table/settings.h.preamble +++ b/src/table/settings.h.preamble @@ -11,7 +11,7 @@ static size_t ConvertLandscape(const char *value); /* Callback function used in _settings[] as well as _gui_settings[] */ -static void UpdateTimeSettings(int32 new_value); +static void UpdateTimeSettings(int32_t new_value); /* Callback function used for various settings */ static bool CheckTTDPatchSettingFlag(uint flag); @@ -42,7 +42,7 @@ static bool CheckTTDPatchSettingFlag(uint flag); * * 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_t * - 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/difficulty_settings.ini b/src/table/settings/difficulty_settings.ini index f0e49785ed..50b24816c4 100644 --- a/src/table/settings/difficulty_settings.ini +++ b/src/table/settings/difficulty_settings.ini @@ -10,15 +10,15 @@ [pre-amble] static const uint GAME_DIFFICULTY_NUM = 18; static 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"}; -static uint16 _old_diff_custom[GAME_DIFFICULTY_NUM]; -uint8 _old_diff_level; ///< Old difficulty level from old savegames +static uint16_t _old_diff_custom[GAME_DIFFICULTY_NUM]; +uint8_t _old_diff_level; ///< Old difficulty level from old savegames static void DifficultyNoiseChange(int32_t new_value); static void MaxNoAIsChange(int32_t new_value); -static bool TownCouncilToleranceAdjust(int32 &new_value); -static void DifficultyMoneyCheatMultiplayerChange(int32 new_value); -static void DifficultyRenameTownsMultiplayerChange(int32 new_value); -static void DifficultyOverrideTownSettingsMultiplayerChange(int32 new_value); +static bool TownCouncilToleranceAdjust(int32_t &new_value); +static void DifficultyMoneyCheatMultiplayerChange(int32_t new_value); +static void DifficultyRenameTownsMultiplayerChange(int32_t new_value); +static void DifficultyOverrideTownSettingsMultiplayerChange(int32_t new_value); static const SettingDescEnumEntry _town_council_approval[] = { { 0, STR_CITY_APPROVAL_LENIENT }, diff --git a/src/table/settings/economy_settings.ini b/src/table/settings/economy_settings.ini index 5ae94c716c..bfe1d0efe1 100644 --- a/src/table/settings/economy_settings.ini +++ b/src/table/settings/economy_settings.ini @@ -9,16 +9,16 @@ [pre-amble] static void TownFoundingChanged(int32_t new_value); -static void InvalidateCompanyWindow(int32 new_value); -static bool DayLengthPreChange(int32 &new_value); -static void DayLengthChanged(int32 new_value); -static bool CheckSharingRail(int32 &new_value); -static void SharingRailChanged(int32 new_value); -static bool CheckSharingRoad(int32 &new_value); -static bool CheckSharingWater(int32 &new_value); -static bool CheckSharingAir(int32 &new_value); -static void TownZoneModeChanged(int32 new_value); -static void TownZoneCustomValueChanged(int32 new_value); +static void InvalidateCompanyWindow(int32_t new_value); +static bool DayLengthPreChange(int32_t &new_value); +static void DayLengthChanged(int32_t new_value); +static bool CheckSharingRail(int32_t &new_value); +static void SharingRailChanged(int32_t new_value); +static bool CheckSharingRoad(int32_t &new_value); +static bool CheckSharingWater(int32_t &new_value); +static bool CheckSharingAir(int32_t &new_value); +static void TownZoneModeChanged(int32_t new_value); +static void TownZoneCustomValueChanged(int32_t new_value); static bool OrderTownGrowthRate(SettingOnGuiCtrlData &data); @@ -71,7 +71,7 @@ from = SLV_113 def = true str = STR_CONFIG_SETTING_ALLOW_TOWN_ROADS strhelp = STR_CONFIG_SETTING_ALLOW_TOWN_ROADS_HELPTEXT -pre_cb = [](int32 &new_value) -> bool { return CheckTTDPatchSettingFlag(0x62); } +pre_cb = [](int32_t &new_value) -> bool { return CheckTTDPatchSettingFlag(0x62); } [SDT_VAR] var = economy.found_town @@ -242,7 +242,7 @@ def = false str = STR_CONFIG_SETTING_INFLATION strhelp = STR_CONFIG_SETTING_INFLATION_HELPTEXT cat = SC_BASIC -pre_cb = [](int32 &new_value) -> bool { return CheckTTDPatchSettingFlag(0x81); } +pre_cb = [](int32_t &new_value) -> bool { return CheckTTDPatchSettingFlag(0x81); } [SDT_BOOL] var = economy.inflation_fixed_dates diff --git a/src/table/settings/game_settings.ini b/src/table/settings/game_settings.ini index 041006f46b..f7f4883797 100644 --- a/src/table/settings/game_settings.ini +++ b/src/table/settings/game_settings.ini @@ -14,18 +14,18 @@ static constexpr std::initializer_list _roadsides{"left", "right"}; static void StationSpreadChanged(int32_t new_value); static void UpdateConsists(int32_t new_value); static void TrainAccelerationModelChanged(int32_t new_value); -static bool CheckTrainBrakingModelChange(int32 &new_value); -static void TrainBrakingModelChanged(int32 new_value); +static bool CheckTrainBrakingModelChange(int32_t &new_value); +static void TrainBrakingModelChanged(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 void RoadSideChanged(int32 new_value); +static void RoadSideChanged(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 void ImprovedBreakdownsSettingChanged(int32 new_value); -static void TrainSpeedAdaptationChanged(int32 new_value); +static void ImprovedBreakdownsSettingChanged(int32_t new_value); +static void TrainSpeedAdaptationChanged(int32_t new_value); static const SettingDescEnumEntry _train_braking_model[] = { { TBM_ORIGINAL, STR_CONFIG_SETTING_ORIGINAL }, @@ -171,7 +171,7 @@ var = station.never_expire_airports def = false str = STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS strhelp = STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS_HELPTEXT -pre_cb = [](int32 &new_value) -> bool { return CheckTTDPatchSettingFlag(0x0C); } +pre_cb = [](int32_t &new_value) -> bool { return CheckTTDPatchSettingFlag(0x0C); } [SDT_VAR] var = station.station_spread @@ -508,7 +508,7 @@ var = vehicle.wagon_speed_limits def = true str = STR_CONFIG_SETTING_WAGONSPEEDLIMITS strhelp = STR_CONFIG_SETTING_WAGONSPEEDLIMITS_HELPTEXT -pre_cb = [](int32 &new_value) -> bool { return CheckTTDPatchSettingFlag(0x5D); } +pre_cb = [](int32_t &new_value) -> bool { return CheckTTDPatchSettingFlag(0x5D); } post_cb = UpdateConsists [SDT_BOOL] @@ -551,7 +551,7 @@ interval = 1 str = STR_CONFIG_SETTING_FREIGHT_TRAINS strhelp = STR_CONFIG_SETTING_FREIGHT_TRAINS_HELPTEXT strval = STR_JUST_COMMA -pre_cb = [](int32 &new_value) -> bool { return CheckTTDPatchSettingFlag(0x58); } +pre_cb = [](int32_t &new_value) -> bool { return CheckTTDPatchSettingFlag(0x58); } post_cb = UpdateConsists [SDT_VAR] diff --git a/src/table/settings/gui_settings.ini b/src/table/settings/gui_settings.ini index 4a008c4117..290927839e 100644 --- a/src/table/settings/gui_settings.ini +++ b/src/table/settings/gui_settings.ini @@ -15,16 +15,16 @@ 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 void AutosaveModeChanged(int32 new_value); -static void ViewportMapShowTunnelModeChanged(int32 new_value); -static void ViewportMapLandscapeModeChanged(int32 new_value); -static void ChangeTimetableInTicksMode(int32 new_value); -static void InvalidateVehTimetableWindow(int32 new_value); -static void ChangeTimeOverrideMode(int32 new_value); -static void ProgrammableSignalsShownChanged(int32 new_value); -static void EnableSingleVehSharedOrderGuiChanged(int32 new_value); -static void ChangeTrackTypeSortMode(int32 new_value); -static void DeveloperModeChanged(int32 new_value); +static void AutosaveModeChanged(int32_t new_value); +static void ViewportMapShowTunnelModeChanged(int32_t new_value); +static void ViewportMapLandscapeModeChanged(int32_t new_value); +static void ChangeTimetableInTicksMode(int32_t new_value); +static void InvalidateVehTimetableWindow(int32_t new_value); +static void ChangeTimeOverrideMode(int32_t new_value); +static void ProgrammableSignalsShownChanged(int32_t new_value); +static void EnableSingleVehSharedOrderGuiChanged(int32_t new_value); +static void ChangeTrackTypeSortMode(int32_t new_value); +static void DeveloperModeChanged(int32_t new_value); /* Begin - GUI callbacks */ diff --git a/src/table/settings/linkgraph_settings.ini b/src/table/settings/linkgraph_settings.ini index 215c73843c..f2861168f4 100644 --- a/src/table/settings/linkgraph_settings.ini +++ b/src/table/settings/linkgraph_settings.ini @@ -9,7 +9,7 @@ [pre-amble] -static int64 LinkGraphDistModeXrefChillPP(int64 val); +static int64_t LinkGraphDistModeXrefChillPP(int64_t val); static bool LinkGraphDistributionSettingGUI(SettingOnGuiCtrlData &data); static const SettingDescEnumEntry _linkgraph_mode_symmetric[] = { @@ -97,7 +97,7 @@ strhelp = STR_CONFIG_SETTING_LINKGRAPH_RECALC_TIME_HELPTEXT [SDT_NAMED_NULL] name = ""linkgraph.recalc_not_scaled_by_daylength"" length = 1 -extver = SlXvFeatureTest([](uint16 version, bool version_in_range, const std::array &feature_versions) -> bool { return version_in_range && SlXvIsFeaturePresent(feature_versions, XSLFI_LINKGRAPH_DAY_SCALE, 1, 1) && !SlXvIsFeaturePresent(feature_versions, XSLFI_JOKERPP); }) +extver = SlXvFeatureTest([](uint16_t version, bool version_in_range, const std::array &feature_versions) -> bool { return version_in_range && SlXvIsFeaturePresent(feature_versions, XSLFI_LINKGRAPH_DAY_SCALE, 1, 1) && !SlXvIsFeaturePresent(feature_versions, XSLFI_JOKERPP); }) patxname = ""linkgraph_day_scale.linkgraph.recalc_not_scaled_by_daylength"" [SDT_ENUM] diff --git a/src/table/settings/locale_settings.ini b/src/table/settings/locale_settings.ini index 3c3c020908..dbb087c2ce 100644 --- a/src/table/settings/locale_settings.ini +++ b/src/table/settings/locale_settings.ini @@ -15,7 +15,7 @@ static constexpr std::initializer_list _locale_units{"imperial", "m static_assert(_locale_currencies.size() == CURRENCY_END); -static void VelocityUnitsChanged(int32 new_value); +static void VelocityUnitsChanged(int32_t new_value); static const SettingTable _locale_settings{ [post-amble] diff --git a/src/table/settings/pathfinding_settings.ini b/src/table/settings/pathfinding_settings.ini index 9324a9508b..27834b8e04 100644 --- a/src/table/settings/pathfinding_settings.ini +++ b/src/table/settings/pathfinding_settings.ini @@ -9,7 +9,7 @@ [pre-amble] static void InvalidateShipPathCache(int32_t new_value); -static void CheckYapfRailSignalPenalties(int32 new_value); +static void CheckYapfRailSignalPenalties(int32_t new_value); static const SettingTable _pathfinding_settings{ [post-amble] diff --git a/src/table/settings/script_settings.ini b/src/table/settings/script_settings.ini index 89ad17461c..d4caaffac7 100644 --- a/src/table/settings/script_settings.ini +++ b/src/table/settings/script_settings.ini @@ -10,9 +10,9 @@ [pre-amble] static constexpr std::initializer_list _settings_profiles{"easy", "medium", "hard"}; -static void ScriptMaxOpsChange(int32 new_value); -static bool CheckScriptMaxMemoryChange(int32 &new_value); -static void ScriptMaxMemoryChange(int32 new_value); +static void ScriptMaxOpsChange(int32_t new_value); +static bool CheckScriptMaxMemoryChange(int32_t &new_value); +static void ScriptMaxMemoryChange(int32_t new_value); const SettingTable _script_settings = { [post-amble] diff --git a/src/table/settings/world_settings.ini b/src/table/settings/world_settings.ini index a1c385f0f3..bf52b3dfcd 100644 --- a/src/table/settings/world_settings.ini +++ b/src/table/settings/world_settings.ini @@ -14,9 +14,9 @@ static bool CheckMaxHeightLevel(int32_t &new_value); static bool CheckFreeformEdges(int32_t &new_value); static void UpdateFreeformEdges(int32_t new_value); static bool CheckMapEdgeMode(int32_t &new_value); -static void ClimateThresholdModeChanged(int32 new_value); -static void PublicRoadsSettingChange(int32 new_value); -static void MarkAllViewportsDirty(int32 new_value); +static void ClimateThresholdModeChanged(int32_t new_value); +static void PublicRoadsSettingChange(int32_t new_value); +static void MarkAllViewportsDirty(int32_t new_value); static bool AllowRoadStopsUnderBridgesSettingGUI(SettingOnGuiCtrlData &data); static bool TreePlacerSettingGUI(SettingOnGuiCtrlData &data); @@ -678,7 +678,7 @@ interval = 1 str = STR_CONFIG_SETTING_MAX_BRIDGE_LENGTH strhelp = STR_CONFIG_SETTING_MAX_BRIDGE_LENGTH_HELPTEXT strval = STR_CONFIG_SETTING_TILE_LENGTH -pre_cb = [](int32 &new_value) -> bool { return CheckTTDPatchSettingFlag(0x0F); } +pre_cb = [](int32_t &new_value) -> bool { return CheckTTDPatchSettingFlag(0x0F); } [SDT_VAR] var = construction.max_bridge_height @@ -740,7 +740,7 @@ max = 2 str = STR_CONFIG_SETTING_SIGNALSIDE strhelp = STR_CONFIG_SETTING_SIGNALSIDE_HELPTEXT strval = STR_CONFIG_SETTING_SIGNALSIDE_LEFT -pre_cb = [](int32 &new_value) -> bool { return CheckTTDPatchSettingFlag(0x3B); } +pre_cb = [](int32_t &new_value) -> bool { return CheckTTDPatchSettingFlag(0x3B); } post_cb = [](auto) { MarkWholeScreenDirty(); } cat = SC_BASIC diff --git a/src/table/sprites.h b/src/table/sprites.h index 7a36c21746..c50cc84483 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,39 +287,39 @@ 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; /* Programmable pre-signal sprites */ static const SpriteID SPR_PROGSIGNAL_BASE = SPR_PALETTE_BASE + PALETTE_SPRITE_COUNT; -static const uint16 PROGSIGNAL_SPRITE_COUNT = 32; +static const uint16_t PROGSIGNAL_SPRITE_COUNT = 32; static const SpriteID SPR_DUP_PROGSIGNAL_BASE = SPR_PROGSIGNAL_BASE + PROGSIGNAL_SPRITE_COUNT; /* Extra signal sprites */ static const SpriteID SPR_EXTRASIGNAL_BASE = SPR_DUP_PROGSIGNAL_BASE + PROGSIGNAL_SPRITE_COUNT; -static const uint16 EXTRASIGNAL_SPRITE_COUNT = 16; +static const uint16_t EXTRASIGNAL_SPRITE_COUNT = 16; static const SpriteID SPR_DUP_EXTRASIGNAL_BASE = SPR_EXTRASIGNAL_BASE + EXTRASIGNAL_SPRITE_COUNT; /* Zoning sprites */ static const SpriteID SPR_ZONING_INNER_HIGHLIGHT_BASE = SPR_DUP_EXTRASIGNAL_BASE + EXTRASIGNAL_SPRITE_COUNT; -static const uint16 ZONING_INNER_HIGHLIGHT_SPRITE_COUNT = 32; +static const uint16_t ZONING_INNER_HIGHLIGHT_SPRITE_COUNT = 32; static const SpriteID SPR_ZONING_INNER_HIGHLIGHT_RED = SPR_ZONING_INNER_HIGHLIGHT_BASE + 19; static const SpriteID SPR_ZONING_INNER_HIGHLIGHT_GREEN = SPR_ZONING_INNER_HIGHLIGHT_BASE + 20; static const SpriteID SPR_ZONING_INNER_HIGHLIGHT_BLACK = SPR_ZONING_INNER_HIGHLIGHT_BASE + 21; @@ -340,11 +340,11 @@ static const SpriteID ROUTE_STEP_SPRITE_COUNT = 4; /* Tracerestrict sprites */ static const SpriteID SPR_TRACERESTRICT_BASE = SPR_ROUTE_STEP_BASE + ROUTE_STEP_SPRITE_COUNT; -static const uint16 TRACERESTRICT_SPRITE_COUNT = 3; +static const uint16_t TRACERESTRICT_SPRITE_COUNT = 3; /* Misc GUI sprites */ static const SpriteID SPR_MISC_GUI_BASE = SPR_TRACERESTRICT_BASE + TRACERESTRICT_SPRITE_COUNT; -static const uint16 MISC_GUI_SPRITE_COUNT = 1; +static const uint16_t MISC_GUI_SPRITE_COUNT = 1; /* Road waypoints sprites */ static const SpriteID SPR_ROAD_WAYPOINTS_BASE = SPR_MISC_GUI_BASE + MISC_GUI_SPRITE_COUNT; @@ -352,13 +352,13 @@ static const SpriteID SPR_ROAD_WAYPOINT_Y_W = SPR_ROAD_WAYPOINTS_BASE; static const SpriteID SPR_ROAD_WAYPOINT_Y_E = SPR_ROAD_WAYPOINTS_BASE + 1; static const SpriteID SPR_ROAD_WAYPOINT_X_W = SPR_ROAD_WAYPOINTS_BASE + 2; static const SpriteID SPR_ROAD_WAYPOINT_X_E = SPR_ROAD_WAYPOINTS_BASE + 3; -static const uint16 ROAD_WAYPOINTS_SPRITE_COUNT = 4; +static const uint16_t ROAD_WAYPOINTS_SPRITE_COUNT = 4; /* Duplicated signal sprites */ static const SpriteID SPR_DUP_ORIGINAL_SIGNALS_BASE = SPR_ROAD_WAYPOINTS_BASE + ROAD_WAYPOINTS_SPRITE_COUNT; -static const uint16 DUP_ORIGINAL_SIGNALS_SPRITE_COUNT = 16; +static const uint16_t DUP_ORIGINAL_SIGNALS_SPRITE_COUNT = 16; static const SpriteID SPR_DUP_SIGNALS_BASE = SPR_DUP_ORIGINAL_SIGNALS_BASE + DUP_ORIGINAL_SIGNALS_SPRITE_COUNT; -static const uint16 DUP_SIGNALS_SPRITE_COUNT = PRESIGNAL_SEMAPHORE_AND_PBS_SPRITE_COUNT; +static const uint16_t DUP_SIGNALS_SPRITE_COUNT = PRESIGNAL_SEMAPHORE_AND_PBS_SPRITE_COUNT; /* From where can we start putting NewGRFs? */ static const SpriteID SPR_NEWGRFS_BASE = SPR_DUP_SIGNALS_BASE + DUP_SIGNALS_SPRITE_COUNT; diff --git a/src/table/station_land.h b/src/table/station_land.h index 7caab7eba2..21bc5f34c8 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 50c32c516f..2086dad0dd 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 e610dc7737..e1e36bee6f 100644 --- a/src/table/tree_land.h +++ b/src/table/tree_land.h @@ -17,8 +17,8 @@ static const byte _tree_count_by_landscape[4] = {12, 8, 12, 9}; #define MAX_TREE_COUNT_BY_LANDSCAPE 12 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..c8eeba6e7f 100644 --- a/src/table/unicode.h +++ b/src/table/unicode.h @@ -8,8 +8,8 @@ /** @file unicode.h Character mapping for using Unicode characters in OTTD. */ struct DefaultUnicodeMapping { - WChar code; ///< Unicode value - byte key; ///< Character index of sprite + char32_t code; ///< Unicode value + byte key; ///< Character index of sprite }; static const byte CLRA = 0; ///< Identifier to clear all glyphs at this codepoint 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/tbtr_template_gui_create.cpp b/src/tbtr_template_gui_create.cpp index e57bcc37eb..cf4d992550 100644 --- a/src/tbtr_template_gui_create.cpp +++ b/src/tbtr_template_gui_create.cpp @@ -51,7 +51,7 @@ class TemplateReplaceWindow; // some space in front of the virtual train in the matrix -uint16 TRAIN_FRONT_SPACE = 16; +uint16_t TRAIN_FRONT_SPACE = 16; enum TemplateReplaceCreateWindowWidgets { TCW_CAPTION, @@ -135,7 +135,7 @@ private: VehicleID sel; VehicleID vehicle_over; bool sell_hovered; ///< A vehicle is being dragged/hovered over the sell button. - uint32 template_index; + uint32_t template_index; btree::btree_set pending_deletions; ///< Vehicle IDs where deletion is in progress public: @@ -345,7 +345,7 @@ public: SetDParam(0, gcache->cached_weight); SetDParam(3, gcache->cached_max_te); DrawString(left, right, y, original_acceleration ? STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED : STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE); - uint32 full_cargo_weight = 0; + uint32_t full_cargo_weight = 0; for (Train *train = this->virtual_train; train != nullptr; train = train->Next()) { full_cargo_weight += train->GetCargoWeight(train->cargo_cap); } @@ -558,7 +558,7 @@ public: if (virtual_train != nullptr) { bool buildable = true; - uint32 full_cargo_weight = 0; + uint32_t full_cargo_weight = 0; for (Train *train = virtual_train; train != nullptr; train = train->GetNextUnit()) { width += train->GetDisplayImageWidth(); cargo_caps[train->cargo_type] += train->cargo_cap; @@ -711,7 +711,7 @@ void ShowTemplateCreateWindow(TemplateVehicle *to_edit, bool *create_window_open new TemplateCreateWindow(&_template_create_window_desc, to_edit, create_window_open); } -void CcSetVirtualTrain(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcSetVirtualTrain(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; @@ -723,7 +723,7 @@ void CcSetVirtualTrain(const CommandCost &result, TileIndex tile, uint32 p1, uin } } -void CcVirtualTrainWagonsMoved(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcVirtualTrainWagonsMoved(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; @@ -734,7 +734,7 @@ void CcVirtualTrainWagonsMoved(const CommandCost &result, TileIndex tile, uint32 } } -void CcDeleteVirtualTrain(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcDeleteVirtualTrain(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; diff --git a/src/tbtr_template_gui_main.cpp b/src/tbtr_template_gui_main.cpp index 5590c6469b..78d4a26e54 100644 --- a/src/tbtr_template_gui_main.cpp +++ b/src/tbtr_template_gui_main.cpp @@ -414,7 +414,7 @@ public: switch (widget) { case TRW_WIDGET_TMPL_BUTTONS_CONFIGTMPL_REUSE: { if ((this->selected_template_index >= 0) && (this->selected_template_index < (int)this->templates.size())) { - uint32 template_index = ((this->templates)[selected_template_index])->index; + uint32_t template_index = ((this->templates)[selected_template_index])->index; DoCommandP(0, template_index, 0, CMD_TOGGLE_REUSE_DEPOT_VEHICLES, nullptr); } @@ -422,7 +422,7 @@ public: } case TRW_WIDGET_TMPL_BUTTONS_CONFIGTMPL_KEEP: { if ((this->selected_template_index >= 0) && (this->selected_template_index < (int)this->templates.size())) { - uint32 template_index = ((this->templates)[selected_template_index])->index; + uint32_t template_index = ((this->templates)[selected_template_index])->index; DoCommandP(0, template_index, 0, CMD_TOGGLE_KEEP_REMAINING_VEHICLES, nullptr); } @@ -431,7 +431,7 @@ public: case TRW_WIDGET_TMPL_BUTTONS_CONFIGTMPL_REFIT_AS_TEMPLATE: case TRW_WIDGET_TMPL_BUTTONS_CONFIGTMPL_REFIT_AS_INCOMING: { if ((this->selected_template_index >= 0) && (this->selected_template_index < (int)this->templates.size())) { - uint32 template_index = ((this->templates)[selected_template_index])->index; + uint32_t template_index = ((this->templates)[selected_template_index])->index; DoCommandP(0, template_index, (widget == TRW_WIDGET_TMPL_BUTTONS_CONFIGTMPL_REFIT_AS_TEMPLATE) ? 1 : 0, CMD_SET_REFIT_AS_TEMPLATE, nullptr); } @@ -439,7 +439,7 @@ public: } case TRW_WIDGET_TMPL_BUTTONS_CONFIGTMPL_OLD_ONLY: { if ((this->selected_template_index >= 0) && (this->selected_template_index < (int)this->templates.size())) { - uint32 template_index = ((this->templates)[selected_template_index])->index; + uint32_t template_index = ((this->templates)[selected_template_index])->index; DoCommandP(0, template_index, 0, CMD_TOGGLE_TMPL_REPLACE_OLD_ONLY, nullptr); } @@ -474,7 +474,7 @@ public: case TRW_WIDGET_TMPL_BUTTONS_DELETE: if ((this->selected_template_index >= 0) && (this->selected_template_index < (int)this->templates.size()) && !editInProgress) { - uint32 template_index = ((this->templates)[selected_template_index])->index; + uint32_t template_index = ((this->templates)[selected_template_index])->index; bool succeeded = DoCommandP(0, template_index, 0, CMD_DELETE_TEMPLATE_VEHICLE, nullptr); @@ -495,7 +495,7 @@ public: ShowDropDownList(this, GetRailTypeDropDownList(true, true), this->sel_railtype, TRW_WIDGET_TRAIN_RAILTYPE_DROPDOWN); break; case TRW_WIDGET_TOP_MATRIX: { - uint16 newindex = (uint16)((pt.y - this->GetWidget(TRW_WIDGET_TOP_MATRIX)->pos_y) / (GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.matrix.Vertical()) ) + this->vscroll[0]->GetPosition(); + uint16_t newindex = (uint16_t)((pt.y - this->GetWidget(TRW_WIDGET_TOP_MATRIX)->pos_y) / (GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.matrix.Vertical()) ) + this->vscroll[0]->GetPosition(); if (newindex == this->selected_group_index || newindex >= this->groups.size()) { this->selected_group_index = -1; } else if (newindex < this->groups.size()) { @@ -505,7 +505,7 @@ public: break; } case TRW_WIDGET_BOTTOM_MATRIX: { - uint16 newindex = (uint16)((pt.y - this->GetWidget(TRW_WIDGET_BOTTOM_MATRIX)->pos_y) / this->bottom_matrix_item_size) + this->vscroll[1]->GetPosition(); + uint16_t newindex = (uint16_t)((pt.y - this->GetWidget(TRW_WIDGET_BOTTOM_MATRIX)->pos_y) / this->bottom_matrix_item_size) + this->vscroll[1]->GetPosition(); if (newindex == this->selected_template_index || newindex >= templates.size()) { this->selected_template_index = -1; } else if (newindex < templates.size()) { @@ -519,7 +519,7 @@ public: case TRW_WIDGET_START: { if ((this->selected_template_index >= 0) && (this->selected_template_index < (int)this->templates.size()) && (this->selected_group_index >= 0) && (this->selected_group_index < (int)this->groups.size())) { - uint32 tv_index = ((this->templates)[selected_template_index])->index; + uint32_t tv_index = ((this->templates)[selected_template_index])->index; int current_group_index = (this->groups)[this->selected_group_index]->index; DoCommandP(0, current_group_index, tv_index, CMD_ISSUE_TEMPLATE_REPLACEMENT, nullptr); @@ -609,7 +609,7 @@ public: { if (tid == INVALID_TEMPLATE) return -1; - for (uint32 i = 0; i < this->templates.size(); ++i) { + for (uint32_t i = 0; i < this->templates.size(); ++i) { if (templates[i]->index == tid) { return i; } @@ -748,7 +748,7 @@ public: v = (this->templates)[i]; /* Fill the background of the current cell in a darker tone for the currently selected template */ - if (this->selected_template_index == (int32) i) { + if (this->selected_template_index == (int32_t) i) { GfxFillRect(r.left + 1, y, r.right, y + this->bottom_matrix_item_size, _colour_gradient[COLOUR_GREY][3]); } diff --git a/src/tbtr_template_vehicle.cpp b/src/tbtr_template_vehicle.cpp index bfe83c6fc3..d2e6f87101 100644 --- a/src/tbtr_template_vehicle.cpp +++ b/src/tbtr_template_vehicle.cpp @@ -47,7 +47,7 @@ INSTANTIATE_POOL_METHODS(TemplateReplacement) robin_hood::unordered_flat_map _template_replacement_index; robin_hood::unordered_flat_map _template_replacement_index_recursive; -static uint32 _template_replacement_index_recursive_guard = 0; +static uint32_t _template_replacement_index_recursive_guard = 0; static void MarkTrainsInGroupAsPendingTemplateReplacement(GroupID gid, const TemplateVehicle *tv); diff --git a/src/tbtr_template_vehicle.h b/src/tbtr_template_vehicle.h index 60f0f0305a..e3efedebd7 100644 --- a/src/tbtr_template_vehicle.h +++ b/src/tbtr_template_vehicle.h @@ -34,11 +34,11 @@ struct TemplateVehicle; struct TemplateReplacement; -typedef uint16 TemplateID; +typedef uint16_t TemplateID; static const TemplateID INVALID_TEMPLATE = 0xFFFF; -static const uint16 CONSIST_HEAD = 0x0; -static const uint16 CONSIST_TAIL = 0xffff; +static const uint16_t CONSIST_HEAD = 0x0; +static const uint16_t CONSIST_TAIL = 0xffff; /** A pool allowing to store up to ~64k templates */ typedef Pool TemplatePool; @@ -102,7 +102,7 @@ public: EngineID engine_type; ///< The type of engine used for this vehicle. CargoID cargo_type; ///< type of cargo this vehicle is carrying - uint16 cargo_cap; ///< total capacity + uint16_t cargo_cap; ///< total capacity byte cargo_subtype; byte subtype; @@ -110,16 +110,16 @@ public: VehicleID index; - uint16 real_consist_length; + uint16_t real_consist_length; - uint16 max_speed; - uint32 power; - uint32 empty_weight; - uint32 full_weight; - uint32 max_te; - uint32 air_drag; + uint16_t max_speed; + uint32_t power; + uint32_t empty_weight; + uint32_t full_weight; + uint32_t max_te; + uint32_t air_drag; - uint32 ctrl_flags; ///< See: TemplateVehicleControlFlags + uint32_t ctrl_flags; ///< See: TemplateVehicleControlFlags std::string name; VehicleSpriteSeq sprite_seq; ///< NOSAVE: Vehicle appearance. @@ -184,8 +184,8 @@ public: inline void SetWagon() { SetBit(this->subtype, GVSF_WAGON); } inline void SetFreeWagon() { SetBit(this->subtype, GVSF_FREE_WAGON); } - inline uint16 GetRealLength() const { return this->real_consist_length; } - inline void SetRealLength(uint16 len) { this->real_consist_length = len; } + inline uint16_t GetRealLength() const { return this->real_consist_length; } + inline void SetRealLength(uint16_t len) { this->real_consist_length = len; } int Length() const; @@ -198,7 +198,7 @@ public: // TemplateReplacement stuff -typedef Pool TemplateReplacementPool; +typedef Pool TemplateReplacementPool; extern TemplateReplacementPool _template_replacement_pool; struct TemplateReplacement : TemplateReplacementPool::PoolItem<&_template_replacement_pool> { diff --git a/src/tbtr_template_vehicle_func.cpp b/src/tbtr_template_vehicle_func.cpp index b1bcfcfd78..cf83b44887 100644 --- a/src/tbtr_template_vehicle_func.cpp +++ b/src/tbtr_template_vehicle_func.cpp @@ -129,8 +129,8 @@ void SetupTemplateVehicleFromVirtual(TemplateVehicle *tmp, TemplateVehicle *prev const GroundVehicleCache *gcache = virt->GetGroundVehicleCache(); tmp->max_speed = virt->GetDisplayMaxSpeed(); tmp->power = gcache->cached_power; - tmp->empty_weight = std::max(gcache->cached_weight - cargo_weight, 1); - tmp->full_weight = std::max(gcache->cached_weight + full_cargo_weight - cargo_weight, 1); + tmp->empty_weight = std::max(gcache->cached_weight - cargo_weight, 1); + tmp->full_weight = std::max(gcache->cached_weight + full_cargo_weight - cargo_weight, 1); tmp->max_te = gcache->cached_max_te; tmp->air_drag = gcache->cached_air_drag; } @@ -160,7 +160,7 @@ TemplateVehicle* TemplateVehicleFromVirtualTrain(Train *virt) } // forward declaration, defined in train_cmd.cpp -CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, uint16 data, uint32 user); +CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, uint16_t data, uint32_t user); Train *DeleteVirtualTrain(Train *chain, Train *to_del) { @@ -342,7 +342,7 @@ CommandCost CmdRefitTrainFromTemplate(Train *t, TemplateVehicle *tv, DoCommandFl while (t && tv) { // refit t as tv - uint32 cb = GetCmdRefitVeh(t); + uint32_t cb = GetCmdRefitVeh(t); cost.AddCost(DoCommand(t->tile, t->index, tv->cargo_type | tv->cargo_subtype << 8 | (1 << 16) | (1 << 31), flags, cb)); diff --git a/src/tbtr_template_vehicle_func.h b/src/tbtr_template_vehicle_func.h index d57c0ab34e..81d9a811bf 100644 --- a/src/tbtr_template_vehicle_func.h +++ b/src/tbtr_template_vehicle_func.h @@ -15,7 +15,7 @@ #include "tbtr_template_vehicle.h" #include "3rdparty/cpp-btree/btree_set.h" -Train* VirtualTrainFromTemplateVehicle(const TemplateVehicle* tv, StringID &err, uint32 user); +Train* VirtualTrainFromTemplateVehicle(const TemplateVehicle* tv, StringID &err, uint32_t user); void BuildTemplateGuiList(GUITemplateList*, Scrollbar*, Owner, RailType); diff --git a/src/terraform_cmd.cpp b/src/terraform_cmd.cpp index cf80425342..11db6890b4 100644 --- a/src/terraform_cmd.cpp +++ b/src/terraform_cmd.cpp @@ -184,7 +184,7 @@ static CommandCost TerraformTileHeight(TerraformerState *ts, TileIndex tile, int * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { CommandCost total_cost(EXPENSES_CONSTRUCTION); int direction = (p2 != 0 ? 1 : -1); @@ -330,7 +330,7 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin 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; } @@ -347,7 +347,7 @@ CommandCost CmdTerraformLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uin * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdLevelLand(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (p1 >= MapSize()) return CMD_ERROR; diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 87d4065f10..0d35d78784 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -47,7 +47,7 @@ enum DemolishConfirmMode { DCM_INDUSTRY_RAIL_STATION, }; -void CcTerraform(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcTerraform(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Succeeded()) { if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile); @@ -325,7 +325,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; @@ -473,7 +473,7 @@ static void CommonRaiseLowerBigLand(TileIndex tile, int mode) StringID msg = mode ? STR_ERROR_CAN_T_RAISE_LAND_HERE : STR_ERROR_CAN_T_LOWER_LAND_HERE; - DoCommandP(tile, SLOPE_N, (uint32)mode, CMD_TERRAFORM_LAND | CMD_MSG(msg), CcTerraform); + DoCommandP(tile, SLOPE_N, (uint32_t)mode, CMD_TERRAFORM_LAND | CMD_MSG(msg), CcTerraform); } else { assert(_terraform_size != 0); TileArea ta(tile, _terraform_size, _terraform_size); @@ -500,13 +500,13 @@ static void CommonRaiseLowerBigLand(TileIndex tile, int mode) for (TileIndex tile2 : ta) { if (TileHeight(tile2) == h) { - DoCommandP(tile2, SLOPE_N, (uint32)mode, CMD_TERRAFORM_LAND); + DoCommandP(tile2, SLOPE_N, (uint32_t)mode, CMD_TERRAFORM_LAND); } } } } -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}, @@ -644,7 +644,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/bitmath_func.cpp b/src/tests/bitmath_func.cpp index 5f5f7c79bb..55e0b0eeea 100644 --- a/src/tests/bitmath_func.cpp +++ b/src/tests/bitmath_func.cpp @@ -13,43 +13,43 @@ #include "../core/bitmath_func.hpp" -extern uint8 FindLastBit64(uint64 x); +extern uint8_t FindLastBit64(uint64_t x); TEST_CASE("FindLastBit tests") { - CHECK(FindLastBit(0) == 0); - CHECK(FindLastBit(0) == 0); - CHECK(FindLastBit(0) == 0); - CHECK(FindLastBit(0) == 0); + CHECK(FindLastBit(0) == 0); + CHECK(FindLastBit(0) == 0); + CHECK(FindLastBit(0) == 0); + CHECK(FindLastBit(0) == 0); CHECK(FindLastBit64(0) == 0); for (uint i = 0; i < 8; i++) { - uint8 t = (uint8)(1 << i); - CHECK(FindLastBit(t) == i); - CHECK(FindLastBit(t) == i); - CHECK(FindLastBit(t) == i); - CHECK(FindLastBit(t) == i); + uint8_t t = (uint8_t)(1 << i); + CHECK(FindLastBit(t) == i); + CHECK(FindLastBit(t) == i); + CHECK(FindLastBit(t) == i); + CHECK(FindLastBit(t) == i); CHECK(FindLastBit64(t) == i); } for (uint i = 8; i < 16; i++) { - uint16 t = (uint16)(1 << i); - CHECK(FindLastBit(t) == i); - CHECK(FindLastBit(t) == i); - CHECK(FindLastBit(t) == i); + uint16_t t = (uint16_t)(1 << i); + CHECK(FindLastBit(t) == i); + CHECK(FindLastBit(t) == i); + CHECK(FindLastBit(t) == i); CHECK(FindLastBit64(t) == i); } for (uint i = 16; i < 32; i++) { - uint32 t = (1 << i); - CHECK(FindLastBit(t) == i); - CHECK(FindLastBit(t) == i); + uint32_t t = (1 << i); + CHECK(FindLastBit(t) == i); + CHECK(FindLastBit(t) == i); CHECK(FindLastBit64(t) == i); } for (uint i = 32; i < 64; i++) { - uint64 t = (((uint64)1) << i); - CHECK(FindLastBit(t) == i); + uint64_t t = (((uint64_t)1) << i); + CHECK(FindLastBit(t) == i); CHECK(FindLastBit64(t) == i); } diff --git a/src/tests/mock_spritecache.cpp b/src/tests/mock_spritecache.cpp index 09d5161dbb..0d0bdd0b89 100644 --- a/src/tests/mock_spritecache.cpp +++ b/src/tests/mock_spritecache.cpp @@ -18,7 +18,7 @@ static bool MockLoadNextSprite(int load_index) { SpriteDataBuffer buffer; - buffer.Allocate((uint32)sizeof(Sprite)); + buffer.Allocate((uint32_t)sizeof(Sprite)); memset(buffer.GetPtr(), 0, buffer.GetSize()); bool is_mapgen = IsMapgenSpriteID(load_index); diff --git a/src/tests/ring_buffer.cpp b/src/tests/ring_buffer.cpp index 5075af538b..b47ae84504 100644 --- a/src/tests/ring_buffer.cpp +++ b/src/tests/ring_buffer.cpp @@ -13,17 +13,17 @@ #include "../core/ring_buffer.hpp" -std::ostream &operator<<(std::ostream &os, const ring_buffer::iterator &iter) { +std::ostream &operator<<(std::ostream &os, const ring_buffer::iterator &iter) { return os << "Position: " << std::hex << iter.debug_raw_position(); } -void DumpRing(const ring_buffer &ring) +void DumpRing(const ring_buffer &ring) { char buffer[1024]; char *b = buffer; const char *end = buffer + 1024; b += snprintf(b, end - b, "Ring: Size: %u, Cap: %u, {", (uint)ring.size(), (uint)ring.capacity()); - for (uint32 it : ring) { + for (uint32_t it : ring) { b += snprintf(b, end - b, " %u,", it); } b--; @@ -32,7 +32,7 @@ void DumpRing(const ring_buffer &ring) WARN(buffer); } -bool Matches(const ring_buffer &ring, std::initializer_list data) +bool Matches(const ring_buffer &ring, std::initializer_list data) { if (ring.size() != data.size()) { DumpRing(ring); @@ -40,7 +40,7 @@ bool Matches(const ring_buffer &ring, std::initializer_list data } auto data_iter = data.begin(); - for (uint32 it : ring) { + for (uint32_t it : ring) { if (it != *data_iter) { DumpRing(ring); return false; @@ -53,7 +53,7 @@ bool Matches(const ring_buffer &ring, std::initializer_list data TEST_CASE("RingBuffer - basic tests") { - ring_buffer ring({ 1, 2, 3, 4, 5, 6 }); + ring_buffer ring({ 1, 2, 3, 4, 5, 6 }); CHECK(Matches(ring, { 1, 2, 3, 4, 5, 6 })); ring.push_front(0); @@ -77,7 +77,7 @@ TEST_CASE("RingBuffer - basic tests") TEST_CASE("RingBuffer - front resize") { - ring_buffer ring({ 1, 2, 3, 4, 5, 6, 7, 8 }); + ring_buffer ring({ 1, 2, 3, 4, 5, 6, 7, 8 }); CHECK(ring.size() == 8); CHECK(ring.capacity() == 8); @@ -89,7 +89,7 @@ TEST_CASE("RingBuffer - front resize") TEST_CASE("RingBuffer - front resize 2") { - ring_buffer ring({ 1, 2, 3, 4, 5, 6, 7, 8 }); + ring_buffer ring({ 1, 2, 3, 4, 5, 6, 7, 8 }); CHECK(ring.size() == 8); CHECK(ring.capacity() == 8); @@ -109,7 +109,7 @@ TEST_CASE("RingBuffer - front resize 2") TEST_CASE("RingBuffer - back resize") { - ring_buffer ring({ 1, 2, 3, 4, 5, 6, 7, 8 }); + ring_buffer ring({ 1, 2, 3, 4, 5, 6, 7, 8 }); CHECK(ring.size() == 8); CHECK(ring.capacity() == 8); @@ -121,7 +121,7 @@ TEST_CASE("RingBuffer - back resize") TEST_CASE("RingBuffer - back resize 2") { - ring_buffer ring({ 1, 2, 3, 4, 5, 6, 7, 8 }); + ring_buffer ring({ 1, 2, 3, 4, 5, 6, 7, 8 }); CHECK(ring.size() == 8); CHECK(ring.capacity() == 8); @@ -141,7 +141,7 @@ TEST_CASE("RingBuffer - back resize 2") TEST_CASE("RingBuffer - insert at ends no grow") { - ring_buffer ring({ 1, 2, 3, 4, 5, 6, 7 }); + ring_buffer ring({ 1, 2, 3, 4, 5, 6, 7 }); CHECK(ring.size() == 7); CHECK(ring.capacity() == 8); @@ -151,7 +151,7 @@ TEST_CASE("RingBuffer - insert at ends no grow") CHECK(ring.capacity() == 8); CHECK(iter == ring.begin()); - ring = ring_buffer({ 1, 2, 3, 4, 5, 6, 7 }); + ring = ring_buffer({ 1, 2, 3, 4, 5, 6, 7 }); CHECK(Matches(ring, { 1, 2, 3, 4, 5, 6, 7 })); CHECK(ring.size() == 7); CHECK(ring.capacity() == 8); @@ -165,7 +165,7 @@ TEST_CASE("RingBuffer - insert at ends no grow") TEST_CASE("RingBuffer - insert at ends shifted no grow") { - ring_buffer ring({ 1, 2, 3, 4, 5, 6, 7 }); + ring_buffer ring({ 1, 2, 3, 4, 5, 6, 7 }); ring.pop_front(); ring.pop_front(); ring.push_back(20); @@ -179,7 +179,7 @@ TEST_CASE("RingBuffer - insert at ends shifted no grow") CHECK(ring.capacity() == 8); CHECK(iter == ring.begin()); - ring = ring_buffer({ 1, 2, 3, 4, 5, 6, 7 }); + ring = ring_buffer({ 1, 2, 3, 4, 5, 6, 7 }); ring.pop_front(); ring.pop_front(); ring.push_back(20); @@ -196,7 +196,7 @@ TEST_CASE("RingBuffer - insert at ends shifted no grow") TEST_CASE("RingBuffer - insert in middle (begin) no grow") { - ring_buffer ring({ 1, 2, 3, 4, 5, 6, 7 }); + ring_buffer ring({ 1, 2, 3, 4, 5, 6, 7 }); ring.pop_front(); ring.pop_front(); ring.push_back(20); @@ -205,8 +205,8 @@ TEST_CASE("RingBuffer - insert in middle (begin) no grow") CHECK(ring.capacity() == 8); /* Insert closer to beginning, beginning should be shifted backwards */ - uint32 *pre_begin = &ring[0]; - uint32 *pre_end = &ring[ring.size() - 1]; + uint32_t *pre_begin = &ring[0]; + uint32_t *pre_end = &ring[ring.size() - 1]; auto iter = ring.insert(ring.begin() + 2, 10); CHECK(Matches(ring, { 3, 4, 10, 5, 6, 7, 20, 21 })); CHECK(ring.size() == 8); @@ -218,7 +218,7 @@ TEST_CASE("RingBuffer - insert in middle (begin) no grow") TEST_CASE("RingBuffer - insert in middle (end) no grow") { - ring_buffer ring({ 1, 2, 3, 4, 5, 6, 7 }); + ring_buffer ring({ 1, 2, 3, 4, 5, 6, 7 }); ring.pop_front(); ring.pop_front(); ring.push_back(20); @@ -227,8 +227,8 @@ TEST_CASE("RingBuffer - insert in middle (end) no grow") CHECK(ring.capacity() == 8); /* Insert closer to end, end should be shifted forwards */ - uint32 *pre_begin = &ring[0]; - uint32 *pre_end = &ring[ring.size() - 1]; + uint32_t *pre_begin = &ring[0]; + uint32_t *pre_end = &ring[ring.size() - 1]; auto iter = ring.insert(ring.begin() + 5, 10); CHECK(Matches(ring, { 3, 4, 5, 6, 7, 10, 20, 21 })); CHECK(ring.size() == 8); @@ -240,7 +240,7 @@ TEST_CASE("RingBuffer - insert in middle (end) no grow") TEST_CASE("RingBuffer - insert at beginning grow") { - ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); + ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); ring.push_front(2); ring.push_front(1); CHECK(Matches(ring, { 1, 2, 3, 4, 5, 6, 7, 8 })); @@ -254,7 +254,7 @@ TEST_CASE("RingBuffer - insert at beginning grow") TEST_CASE("RingBuffer - insert at end grow") { - ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); + ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); ring.push_front(2); ring.push_front(1); CHECK(Matches(ring, { 1, 2, 3, 4, 5, 6, 7, 8 })); @@ -268,7 +268,7 @@ TEST_CASE("RingBuffer - insert at end grow") TEST_CASE("RingBuffer - insert in middle (begin) grow") { - ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); + ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); ring.push_front(2); ring.push_front(1); CHECK(Matches(ring, { 1, 2, 3, 4, 5, 6, 7, 8 })); @@ -283,7 +283,7 @@ TEST_CASE("RingBuffer - insert in middle (begin) grow") TEST_CASE("RingBuffer - insert in middle (end) grow") { - ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); + ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); ring.push_front(2); ring.push_front(1); CHECK(Matches(ring, { 1, 2, 3, 4, 5, 6, 7, 8 })); @@ -298,7 +298,7 @@ TEST_CASE("RingBuffer - insert in middle (end) grow") TEST_CASE("RingBuffer - insert multi at start") { - ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); + ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); auto iter = ring.insert(ring.begin(), { 1, 2 }); CHECK(Matches(ring, { 1, 2, 3, 4, 5, 6, 7, 8 })); CHECK(ring.capacity() == 8); @@ -317,7 +317,7 @@ TEST_CASE("RingBuffer - insert multi at start") TEST_CASE("RingBuffer - insert multi at end") { - ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); + ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); auto iter = ring.insert(ring.end(), { 1, 2 }); CHECK(Matches(ring, { 3, 4, 5, 6, 7, 8, 1, 2 })); CHECK(ring.capacity() == 8); @@ -336,7 +336,7 @@ TEST_CASE("RingBuffer - insert multi at end") TEST_CASE("RingBuffer - insert multi in middle") { - ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); + ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); auto iter = ring.insert(ring.begin() + 3, { 1, 2 }); CHECK(Matches(ring, { 3, 4, 5, 1, 2, 6, 7, 8 })); CHECK(ring.capacity() == 8); @@ -355,9 +355,9 @@ TEST_CASE("RingBuffer - insert multi in middle") TEST_CASE("RingBuffer - erase") { - ring_buffer ring; + ring_buffer ring; auto setup_ring = [&]() { - ring = ring_buffer({ 3, 4, 5, 6, 7, 8 }); + ring = ring_buffer({ 3, 4, 5, 6, 7, 8 }); ring.push_front(2); ring.push_front(1); CHECK(Matches(ring, { 1, 2, 3, 4, 5, 6, 7, 8 })); @@ -365,7 +365,7 @@ TEST_CASE("RingBuffer - erase") }; setup_ring(); - uint32 *expect_front = &ring[1]; + uint32_t *expect_front = &ring[1]; auto iter = ring.erase(ring.begin()); CHECK(Matches(ring, { 2, 3, 4, 5, 6, 7, 8 })); CHECK(ring.capacity() == 8); @@ -373,7 +373,7 @@ TEST_CASE("RingBuffer - erase") CHECK(expect_front == &ring[0]); setup_ring(); - uint32 *expect_back = &ring[ring.size() - 2]; + uint32_t *expect_back = &ring[ring.size() - 2]; iter = ring.erase(ring.end() - 1); CHECK(Matches(ring, { 1, 2, 3, 4, 5, 6, 7 })); CHECK(ring.capacity() == 8); @@ -399,9 +399,9 @@ TEST_CASE("RingBuffer - erase") TEST_CASE("RingBuffer - erase multi") { - ring_buffer ring; + ring_buffer ring; auto setup_ring = [&]() { - ring = ring_buffer({ 3, 4, 5, 6, 7, 8 }); + ring = ring_buffer({ 3, 4, 5, 6, 7, 8 }); ring.push_front(2); ring.push_front(1); CHECK(Matches(ring, { 1, 2, 3, 4, 5, 6, 7, 8 })); @@ -409,7 +409,7 @@ TEST_CASE("RingBuffer - erase multi") }; setup_ring(); - uint32 *expect_front = &ring[2]; + uint32_t *expect_front = &ring[2]; auto iter = ring.erase(ring.begin(), ring.begin() + 2); CHECK(Matches(ring, { 3, 4, 5, 6, 7, 8 })); CHECK(ring.capacity() == 8); @@ -417,7 +417,7 @@ TEST_CASE("RingBuffer - erase multi") CHECK(expect_front == &ring[0]); setup_ring(); - uint32 *expect_back = &ring[ring.size() - 3]; + uint32_t *expect_back = &ring[ring.size() - 3]; iter = ring.erase(ring.end() - 2, ring.end()); CHECK(Matches(ring, { 1, 2, 3, 4, 5, 6 })); CHECK(ring.capacity() == 8); @@ -449,7 +449,7 @@ TEST_CASE("RingBuffer - erase multi") TEST_CASE("RingBuffer - shrink to fit") { - ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); + ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); ring.push_front(2); ring.push_front(1); CHECK(Matches(ring, { 1, 2, 3, 4, 5, 6, 7, 8 })); @@ -472,7 +472,7 @@ TEST_CASE("RingBuffer - shrink to fit") TEST_CASE("RingBuffer - reserve") { - ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); + ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); ring.push_front(2); ring.push_front(1); CHECK(Matches(ring, { 1, 2, 3, 4, 5, 6, 7, 8 })); @@ -485,7 +485,7 @@ TEST_CASE("RingBuffer - reserve") TEST_CASE("RingBuffer - resize") { - ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); + ring_buffer ring({ 3, 4, 5, 6, 7, 8 }); ring.push_front(2); ring.push_front(1); CHECK(Matches(ring, { 1, 2, 3, 4, 5, 6, 7, 8 })); diff --git a/src/texteff.cpp b/src/texteff.cpp index 2bcce3cab2..ca12ffad87 100644 --- a/src/texteff.cpp +++ b/src/texteff.cpp @@ -24,10 +24,10 @@ static TextEffectID _free_text_effect = 0; /** Container for all information about a text effect */ struct TextEffect : public ViewportSign { - uint64 params_1; ///< DParam parameter - uint64 params_2; ///< second DParam parameter + uint64_t params_1; ///< DParam parameter + uint64_t params_2; ///< second DParam parameter 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 */ @@ -42,7 +42,7 @@ struct TextEffect : public ViewportSign { }; /* Text Effects */ -TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, TextEffectMode mode, uint64 param1, uint64 param2) +TextEffectID AddTextEffect(StringID msg, int center, int y, uint8_t duration, TextEffectMode mode, uint64_t param1, uint64_t param2) { if (_game_mode == GM_MENU) return INVALID_TE_ID; @@ -72,7 +72,7 @@ TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, Text return i; } -void UpdateTextEffect(TextEffectID te_id, StringID msg, uint64 param1, uint64 param2) +void UpdateTextEffect(TextEffectID te_id, StringID msg, uint64_t param1, uint64_t param2) { /* Update details */ TextEffect *te = _text_effects.data() + te_id; diff --git a/src/texteff.hpp b/src/texteff.hpp index 35bdf81c36..4072280a3a 100644 --- a/src/texteff.hpp +++ b/src/texteff.hpp @@ -29,16 +29,16 @@ using TextEffectID = uint16_t; static const TextEffectID INVALID_TE_ID = UINT16_MAX; void MoveAllTextEffects(uint delta_ms); -TextEffectID AddTextEffect(StringID msg, int x, int y, uint8 duration, TextEffectMode mode, uint64 param1 = 0, uint64 param2 = 0); +TextEffectID AddTextEffect(StringID msg, int x, int y, uint8_t duration, TextEffectMode mode, uint64_t param1 = 0, uint64_t param2 = 0); void InitTextEffects(); void DrawTextEffects(ViewportDrawerDynamic *vdd, DrawPixelInfo *dpi, bool load_transparent); -void UpdateTextEffect(TextEffectID effect_id, StringID msg, uint64 param1 = 0, uint64 param2 = 0); +void UpdateTextEffect(TextEffectID effect_id, StringID msg, uint64_t param1 = 0, uint64_t param2 = 0); 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 ddcb8e5f0e..93e59e220b 100644 --- a/src/tgp.cpp +++ b/src/tgp.cpp @@ -25,7 +25,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. @@ -151,7 +151,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) */ @@ -421,7 +421,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 */ @@ -677,7 +677,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); @@ -688,7 +688,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++) { @@ -735,7 +735,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; @@ -828,7 +828,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 f0ec5a7453..099008cd04 100644 --- a/src/tile_cmd.h +++ b/src/tile_cmd.h @@ -60,15 +60,15 @@ struct TileDesc { StringID airport_name; ///< Name of the airport StringID airport_tile_name; ///< Name of the airport tile const char *grf; ///< newGRF used for the tile contents - uint64 dparam[4]; ///< Parameters of the \a str string + uint64_t dparam[4]; ///< Parameters of the \a str string StringID railtype; ///< Type of rail on the tile. StringID railtype2; ///< Type of second rail on the tile. - uint16 rail_speed; ///< Speed limit of rail (bridges and track) - uint16 rail_speed2; ///< Speed limit of second rail (bridges and track) + uint16_t rail_speed; ///< Speed limit of rail (bridges and track) + uint16_t rail_speed2; ///< Speed limit of second 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) }; struct DrawTileProcParams { diff --git a/src/tile_type.h b/src/tile_type.h index 852708afa4..13bb24d42d 100644 --- a/src/tile_type.h +++ b/src/tile_type.h @@ -84,7 +84,7 @@ enum TropicZone { /** * The index/ID of a Tile. */ -typedef uint32 TileIndex; +typedef uint32_t TileIndex; /** * The very nice invalid tile marker diff --git a/src/tilearea_type.h b/src/tilearea_type.h index 11422ecd8b..37e86ba296 100644 --- a/src/tilearea_type.h +++ b/src/tilearea_type.h @@ -20,8 +20,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 @@ -29,7 +29,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) { } @@ -78,8 +78,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. @@ -87,7 +87,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/timetable_cmd.cpp b/src/timetable_cmd.cpp index fab6b49cb9..d95ba9c980 100644 --- a/src/timetable_cmd.cpp +++ b/src/timetable_cmd.cpp @@ -33,7 +33,7 @@ * @param timetabled If the new value is explicitly timetabled. * @param ignore_lock If the change should be applied even if the value is locked. */ -static void ChangeTimetable(Vehicle *v, VehicleOrderID order_number, uint32 val, ModifyTimetableFlags mtf, bool timetabled, bool ignore_lock = false) +static void ChangeTimetable(Vehicle *v, VehicleOrderID order_number, uint32_t val, ModifyTimetableFlags mtf, bool timetabled, bool ignore_lock = false) { Order *order = v->GetOrder(order_number); assert(order != nullptr); @@ -165,7 +165,7 @@ static void ChangeTimetable(Vehicle *v, VehicleOrderID order_number, uint32 val, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { VehicleID veh = GB(p1, 0, 20); @@ -340,7 +340,7 @@ CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, u * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBulkChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBulkChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); @@ -381,7 +381,7 @@ CommandCost CmdBulkChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdSetVehicleOnTime(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSetVehicleOnTime(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); bool apply_to_group = HasBit(p1, 20); @@ -398,7 +398,7 @@ CommandCost CmdSetVehicleOnTime(TileIndex tile, DoCommandFlag flags, uint32 p1, 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()) { /* A vehicle can't be late if its timetable hasn't started. */ if (!HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) continue; @@ -477,7 +477,7 @@ static bool VehicleTimetableSorter(Vehicle * const &a, Vehicle * const &b) * @param text Not used. * @return The error or cost of the operation. */ -CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { bool timetable_all = HasBit(p1, 20); Vehicle *v = Vehicle::GetIfValid(GB(p1, 0, 20)); @@ -544,7 +544,7 @@ CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdAutofillTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdAutofillTimetable(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); @@ -596,7 +596,7 @@ CommandCost CmdAutofillTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, * @return the cost of this operation or an error */ -CommandCost CmdAutomateTimetable(TileIndex index, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdAutomateTimetable(TileIndex index, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); @@ -642,7 +642,7 @@ CommandCost CmdAutomateTimetable(TileIndex index, DoCommandFlag flags, uint32 p1 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdTimetableSeparation(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdTimetableSeparation(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID veh = GB(p1, 0, 20); @@ -778,7 +778,7 @@ void UpdateSeparationOrder(Vehicle *v_start) } Company *owner = Company::GetIfValid(v->owner); - uint8 timetable_separation_rate = owner ? owner->settings.auto_timetable_separation_rate : 100; + uint8_t timetable_separation_rate = owner ? owner->settings.auto_timetable_separation_rate : 100; int new_lateness = separation_delta / 2; v->lateness_counter = (new_lateness * timetable_separation_rate + v->lateness_counter * (100 - timetable_separation_rate)) / 100; @@ -791,14 +791,14 @@ DateTicksScaled GetScheduledDispatchTime(const DispatchSchedule &ds, DateTicksSc { DateTicksScaled first_slot = -1; const DateTicksScaled begin_time = ds.GetScheduledDispatchStartTick(); - const int32 last_dispatched_offset = ds.GetScheduledDispatchLastDispatch(); - const uint32 dispatch_duration = ds.GetScheduledDispatchDuration(); - const int32 max_delay = ds.GetScheduledDispatchDelay(); + const int32_t last_dispatched_offset = ds.GetScheduledDispatchLastDispatch(); + const uint32_t dispatch_duration = ds.GetScheduledDispatchDuration(); + const int32_t max_delay = ds.GetScheduledDispatchDelay(); /* Find next available slots */ for (auto current_offset : ds.GetScheduledDispatch()) { if (current_offset >= dispatch_duration) continue; - if (int32(current_offset) <= last_dispatched_offset) { + if ((int32_t)current_offset <= last_dispatched_offset) { current_offset += dispatch_duration * ((last_dispatched_offset + dispatch_duration - current_offset) / dispatch_duration); } @@ -965,10 +965,10 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling) /* Update the timetable to gradually shift order times towards the actual travel times. */ if (timetabled != 0 && HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE)) { - int32 new_time; + int32_t new_time; if (travelling) { new_time = time_taken; - if (new_time > (int32)timetabled * 4 && new_time > (int32)timetabled + 3000 && !(real_timetable_order->IsType(OT_GOTO_DEPOT) && (real_timetable_order->GetDepotOrderType() & ODTFB_SERVICE))) { + if (new_time > (int32_t)timetabled * 4 && new_time > (int32_t)timetabled + 3000 && !(real_timetable_order->IsType(OT_GOTO_DEPOT) && (real_timetable_order->GetDepotOrderType() & ODTFB_SERVICE))) { /* Possible jam, clear time and restart timetable for all vehicles. * Otherwise we risk trains blocking 1-lane stations for long times. */ ChangeTimetable(v, v->cur_timetable_order_index, 0, travel_field ? MTF_TRAVEL_TIME : MTF_WAIT_TIME, false); @@ -979,13 +979,13 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling) } SetTimetableWindowsDirty(v); return; - } else if (new_time >= (int32)timetabled / 2) { + } else if (new_time >= (int32_t)timetabled / 2) { /* Compute running average, with sign conversion to avoid negative overflow. * This is biased to favour negative adjustments */ - if (new_time < (int32)timetabled) { - new_time = ((int32)timetabled * 3 + new_time * 2 + 2) / 5; + if (new_time < (int32_t)timetabled) { + new_time = ((int32_t)timetabled * 3 + new_time * 2 + 2) / 5; } else { - new_time = ((int32)timetabled * 9 + new_time + 5) / 10; + new_time = ((int32_t)timetabled * 9 + new_time + 5) / 10; } } else { /* new time is less than half the old time, set value directly */ @@ -994,20 +994,20 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling) new_time = time_loading; /* Compute running average, with sign conversion to avoid negative overflow. * This is biased to favour positive adjustments */ - if (new_time > (int32)timetabled) { - new_time = ((int32)timetabled * 3 + new_time * 2 + 2) / 5; + if (new_time > (int32_t)timetabled) { + new_time = ((int32_t)timetabled * 3 + new_time * 2 + 2) / 5; } else { - new_time = ((int32)timetabled * 9 + new_time + 5) / 10; + new_time = ((int32_t)timetabled * 9 + new_time + 5) / 10; } } if (new_time < 1) new_time = 1; - if (new_time != (int32)timetabled) { + if (new_time != (int32_t)timetabled) { ChangeTimetable(v, v->cur_timetable_order_index, new_time, travel_field ? MTF_TRAVEL_TIME : MTF_WAIT_TIME, true); } } else if (timetabled == 0 && HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE)) { /* Add times for orders that are not yet timetabled, even while not autofilling */ - const int32 new_time = travelling ? time_taken : time_loading; + const int32_t new_time = travelling ? time_taken : time_loading; if (travel_field) { ChangeTimetable(v, v->cur_timetable_order_index, new_time, MTF_TRAVEL_TIME, true); } else { @@ -1050,7 +1050,7 @@ void UpdateVehicleTimetable(Vehicle *v, bool travelling) SetTimetableWindowsDirty(v); } -void SetOrderFixedWaitTime(Vehicle *v, VehicleOrderID order_number, uint32 wait_time, bool wait_timetabled) { +void SetOrderFixedWaitTime(Vehicle *v, VehicleOrderID order_number, uint32_t wait_time, bool wait_timetabled) { ChangeTimetable(v, order_number, wait_time, MTF_WAIT_TIME, wait_timetabled, true); ChangeTimetable(v, order_number, 1, MTF_SET_WAIT_FIXED, false, true); } diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index 22ce0d626a..8d61a07d91 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -237,9 +237,9 @@ static void FillTimetableArrivalDepartureTable(const Vehicle *v, VehicleOrderID * @param p1 The p1 parameter to send to CmdSetTimetableStart * @param date the actually chosen date */ -static void ChangeTimetableStartIntl(uint32 p1, DateTicksScaled date) +static void ChangeTimetableStartIntl(uint32_t p1, DateTicksScaled date) { - DoCommandPEx(0, p1, 0, (uint64)date.base(), CMD_SET_TIMETABLE_START | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), nullptr, nullptr, 0); + DoCommandPEx(0, p1, 0, (uint64_t)date.base(), CMD_SET_TIMETABLE_START | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE), nullptr, nullptr, 0); } /** @@ -992,7 +992,7 @@ struct TimetableWindow : GeneralVehicleWindow { break; case WID_VT_AUTOFILL: { // Autofill the timetable. - uint32 p2 = 0; + uint32_t p2 = 0; if (!HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE)) SetBit(p2, 0); if (_ctrl_pressed) SetBit(p2, 1); DoCommandP(0, v->index, p2, CMD_AUTOFILL_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE)); @@ -1005,14 +1005,14 @@ struct TimetableWindow : GeneralVehicleWindow { } case WID_VT_AUTOMATE: { - uint32 p2 = 0; + uint32_t p2 = 0; if (!HasBit(v->vehicle_flags, VF_AUTOMATE_TIMETABLE)) SetBit(p2, 0); DoCommandP(0, v->index, p2, CMD_AUTOMATE_TIMETABLE | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE)); break; } case WID_VT_AUTO_SEPARATION: { - uint32 p2 = 0; + uint32_t p2 = 0; if (!HasBit(v->vehicle_flags, VF_TIMETABLE_SEPARATION)) SetBit(p2, 0); DoCommandP(0, v->index, p2, CMD_TIMETABLE_SEPARATION | CMD_MSG(STR_ERROR_CAN_T_TIMETABLE_VEHICLE)); break; @@ -1099,10 +1099,10 @@ struct TimetableWindow : GeneralVehicleWindow { case WID_VT_CHANGE_SPEED: case WID_VT_CHANGE_TIME: { - uint32 p2; + uint32_t p2; if (this->query_is_speed_query) { - uint64 display_speed = StrEmpty(str) ? 0 : std::strtoul(str, nullptr, 10); - uint64 val = ConvertDisplaySpeedToKmhishSpeed(display_speed, v->type); + uint64_t display_speed = StrEmpty(str) ? 0 : std::strtoul(str, nullptr, 10); + uint64_t val = ConvertDisplaySpeedToKmhishSpeed(display_speed, v->type); p2 = std::min(val, UINT16_MAX); } else { p2 = ParseTimetableDuration(str); @@ -1115,7 +1115,7 @@ struct TimetableWindow : GeneralVehicleWindow { case WID_VT_START_DATE: { if (StrEmpty(str)) break; char *end; - int32 val = std::strtol(str, &end, 10); + int32_t val = std::strtol(str, &end, 10); if (val >= 0 && end && *end == 0) { uint minutes = (val % 100) % 60; uint hours = (val / 100) % 24; diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 941cda8a16..73dc0a5ab4 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -2260,29 +2260,29 @@ struct MainToolbarWindow : Window { static HotkeyList hotkeys; }; -const uint16 _maintoolbar_pause_keys[] = {WKC_F1, WKC_PAUSE, 0}; -const uint16 _maintoolbar_zoomin_keys[] = {WKC_NUM_PLUS, WKC_EQUALS, WKC_SHIFT | WKC_EQUALS, WKC_SHIFT | WKC_F5, 0}; -const uint16 _maintoolbar_zoomout_keys[] = {WKC_NUM_MINUS, WKC_MINUS, WKC_SHIFT | WKC_MINUS, WKC_SHIFT | WKC_F6, 0}; -const uint16 _maintoolbar_smallmap_keys[] = {WKC_F4, 'M', 0}; +const uint16_t _maintoolbar_pause_keys[] = {WKC_F1, WKC_PAUSE, 0}; +const uint16_t _maintoolbar_zoomin_keys[] = {WKC_NUM_PLUS, WKC_EQUALS, WKC_SHIFT | WKC_EQUALS, WKC_SHIFT | WKC_F5, 0}; +const uint16_t _maintoolbar_zoomout_keys[] = {WKC_NUM_MINUS, WKC_MINUS, WKC_SHIFT | WKC_MINUS, WKC_SHIFT | WKC_F6, 0}; +const uint16_t _maintoolbar_smallmap_keys[] = {WKC_F4, 'M', 0}; static Hotkey maintoolbar_hotkeys[] = { Hotkey(_maintoolbar_pause_keys, "pause", MTHK_PAUSE), - Hotkey((uint16)0, "fastforward", MTHK_FASTFORWARD), + Hotkey((uint16_t)0, "fastforward", MTHK_FASTFORWARD), Hotkey(WKC_F2, "settings", MTHK_SETTINGS), Hotkey(WKC_F3, "saveload", MTHK_SAVEGAME), - Hotkey((uint16)0, "load_game", MTHK_LOADGAME), + Hotkey((uint16_t)0, "load_game", MTHK_LOADGAME), Hotkey(_maintoolbar_smallmap_keys, "smallmap", MTHK_SMALLMAP), Hotkey(WKC_F5, "town_list", MTHK_TOWNDIRECTORY), Hotkey(WKC_F6, "subsidies", MTHK_SUBSIDIES), Hotkey(WKC_F7, "station_list", MTHK_STATIONS), Hotkey(WKC_F8, "finances", MTHK_FINANCES), Hotkey(WKC_F9, "companies", MTHK_COMPANIES), - Hotkey((uint16)0, "story_book", MTHK_STORY), - Hotkey((uint16)0, "goal_list", MTHK_GOAL), + Hotkey((uint16_t)0, "story_book", MTHK_STORY), + Hotkey((uint16_t)0, "goal_list", MTHK_GOAL), Hotkey(WKC_F10, "graphs", MTHK_GRAPHS), Hotkey(WKC_F11, "league", MTHK_LEAGUE), Hotkey(WKC_F12, "industry_list", MTHK_INDUSTRIES), - Hotkey((uint16)0, "industry_chains", MTHK_INDUSTRY_CHAINS), + Hotkey((uint16_t)0, "industry_chains", MTHK_INDUSTRY_CHAINS), Hotkey(WKC_SHIFT | WKC_F1, "train_list", MTHK_TRAIN_LIST), Hotkey(WKC_SHIFT | WKC_F2, "roadveh_list", MTHK_ROADVEH_LIST), Hotkey(WKC_SHIFT | WKC_F3, "ship_list", MTHK_SHIP_LIST), @@ -2291,29 +2291,29 @@ static Hotkey maintoolbar_hotkeys[] = { Hotkey(_maintoolbar_zoomout_keys, "zoomout", MTHK_ZOOM_OUT), Hotkey(WKC_SHIFT | WKC_F7, "build_rail", MTHK_BUILD_RAIL), Hotkey(WKC_SHIFT | WKC_F8, "build_road", MTHK_BUILD_ROAD), - Hotkey((uint16)0, "build_tram", MTHK_BUILD_TRAM), + Hotkey((uint16_t)0, "build_tram", MTHK_BUILD_TRAM), Hotkey(WKC_SHIFT | WKC_F9, "build_docks", MTHK_BUILD_DOCKS), Hotkey(WKC_SHIFT | WKC_F10, "build_airport", MTHK_BUILD_AIRPORT), Hotkey(WKC_SHIFT | WKC_F11, "build_trees", MTHK_BUILD_TREES), Hotkey(WKC_SHIFT | WKC_F12, "music", MTHK_MUSIC), - Hotkey((uint16)0, "ai_debug", MTHK_SCRIPT_DEBUG), + Hotkey((uint16_t)0, "ai_debug", MTHK_SCRIPT_DEBUG), Hotkey(WKC_CTRL | 'S', "small_screenshot", MTHK_SMALL_SCREENSHOT), Hotkey(WKC_CTRL | 'P', "zoomedin_screenshot", MTHK_ZOOMEDIN_SCREENSHOT), Hotkey(WKC_CTRL | 'D', "defaultzoom_screenshot", MTHK_DEFAULTZOOM_SCREENSHOT), - Hotkey((uint16)0, "giant_screenshot", MTHK_GIANT_SCREENSHOT), + Hotkey((uint16_t)0, "giant_screenshot", MTHK_GIANT_SCREENSHOT), Hotkey(WKC_CTRL | WKC_ALT | 'C', "cheats", MTHK_CHEATS), Hotkey('L', "terraform", MTHK_TERRAFORM), Hotkey('V', "extra_viewport", MTHK_EXTRA_VIEWPORT), - Hotkey((uint16)0, "client_list", MTHK_CLIENT_LIST), - Hotkey((uint16)0, "sign_list", MTHK_SIGN_LIST), - Hotkey((uint16)0, "land_info", MTHK_LANDINFO), - Hotkey((uint16)0, "picker_tool", MTHK_PICKER), + Hotkey((uint16_t)0, "client_list", MTHK_CLIENT_LIST), + Hotkey((uint16_t)0, "sign_list", MTHK_SIGN_LIST), + Hotkey((uint16_t)0, "land_info", MTHK_LANDINFO), + Hotkey((uint16_t)0, "picker_tool", MTHK_PICKER), Hotkey('P', "plan_list", MTHK_PLAN_LIST), Hotkey('Y', "link_graph_legend", MTHK_LINK_GRAPH_LEGEND), - Hotkey((uint16)0, "message_history", MTHK_MESSAGE_HISTORY), - Hotkey((uint16)0, "template_replacement", MTHK_TEMPLATE_REPLACEMENT), - Hotkey((uint16)0, "train_slots", MTHK_TRAIN_SLOTS), - Hotkey((uint16)0, "train_counters", MTHK_TRAIN_COUNTERS), + Hotkey((uint16_t)0, "message_history", MTHK_MESSAGE_HISTORY), + Hotkey((uint16_t)0, "template_replacement", MTHK_TEMPLATE_REPLACEMENT), + Hotkey((uint16_t)0, "train_slots", MTHK_TRAIN_SLOTS), + Hotkey((uint16_t)0, "train_counters", MTHK_TRAIN_COUNTERS), HOTKEY_LIST_END }; HotkeyList MainToolbarWindow::hotkeys("maintoolbar", maintoolbar_hotkeys); @@ -2656,7 +2656,7 @@ struct ScenarioEditorToolbarWindow : Window { /* Was 'cancel' pressed? */ if (str == nullptr) return; - int32 value; + int32_t value; if (!StrEmpty(str)) { value = atoi(str); } else { @@ -2673,24 +2673,24 @@ struct ScenarioEditorToolbarWindow : Window { static Hotkey scenedit_maintoolbar_hotkeys[] = { Hotkey(_maintoolbar_pause_keys, "pause", MTEHK_PAUSE), - Hotkey((uint16)0, "fastforward", MTEHK_FASTFORWARD), + Hotkey((uint16_t)0, "fastforward", MTEHK_FASTFORWARD), Hotkey(WKC_F2, "settings", MTEHK_SETTINGS), Hotkey(WKC_F3, "saveload", MTEHK_SAVEGAME), Hotkey(WKC_F4, "gen_land", MTEHK_GENLAND), Hotkey(WKC_F5, "gen_town", MTEHK_GENTOWN), Hotkey(WKC_F6, "gen_industry", MTEHK_GENINDUSTRY), Hotkey(WKC_F7, "build_road", MTEHK_BUILD_ROAD), - Hotkey((uint16)0, "build_tram", MTEHK_BUILD_TRAM), + Hotkey((uint16_t)0, "build_tram", MTEHK_BUILD_TRAM), Hotkey(WKC_F8, "build_docks", MTEHK_BUILD_DOCKS), Hotkey(WKC_F9, "build_trees", MTEHK_BUILD_TREES), Hotkey(WKC_F10, "build_sign", MTEHK_SIGN), Hotkey(WKC_F11, "music", MTEHK_MUSIC), Hotkey(WKC_F12, "land_info", MTEHK_LANDINFO), - Hotkey((uint16)0, "picker_tool", MTEHK_PICKER), + Hotkey((uint16_t)0, "picker_tool", MTEHK_PICKER), Hotkey(WKC_CTRL | 'S', "small_screenshot", MTEHK_SMALL_SCREENSHOT), Hotkey(WKC_CTRL | 'P', "zoomedin_screenshot", MTEHK_ZOOMEDIN_SCREENSHOT), Hotkey(WKC_CTRL | 'D', "defaultzoom_screenshot", MTEHK_DEFAULTZOOM_SCREENSHOT), - Hotkey((uint16)0, "giant_screenshot", MTEHK_GIANT_SCREENSHOT), + Hotkey((uint16_t)0, "giant_screenshot", MTEHK_GIANT_SCREENSHOT), Hotkey(_maintoolbar_zoomin_keys, "zoomin", MTEHK_ZOOM_IN), Hotkey(_maintoolbar_zoomout_keys, "zoomout", MTEHK_ZOOM_OUT), Hotkey('L', "terraform", MTEHK_TERRAFORM), @@ -2773,7 +2773,7 @@ MainToolbarScaleAdjuster::MainToolbarScaleAdjuster() /* Bump scale to next integer multiple */ _gui_scale = Clamp(100 * ((_gui_scale / 100) + 1), 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; _gui_zoom = static_cast(Clamp(new_zoom, _settings_client.gui.zoom_min, _settings_client.gui.zoom_max)); SetupWidgetDimensions(); } diff --git a/src/town.h b/src/town.h index 56ef7f9263..1db79ba205 100644 --- a/src/town.h +++ b/src/town.h @@ -29,14 +29,14 @@ struct BuildingCounts { }; static const uint CUSTOM_TOWN_NUMBER_DIFFICULTY = 4; ///< value for custom town number in difficulty settings -static const uint CUSTOM_TOWN_MAX_NUMBER = 5000; ///< this is the maximum number of towns a user can specify in customisation +static const uint CUSTOM_TOWN_MAX_NUMBER = 5000; ///< this is the maximum number of towns a user can specify in customisation 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 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_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 /** Settings for town council attitudes. */ enum TownCouncilAttitudes { @@ -51,12 +51,12 @@ 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 - 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 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_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 setting override flags */ @@ -76,37 +76,37 @@ 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; TinyString 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. + byte flags; ///< See #TownFlags. - byte override_flags; ///< Bitmask of enabled flag overrides. See #TownSettingOverrideFlags. - byte override_values; ///< Bitmask of flag override values. See #TownSettingOverrideFlags. - TownTunnelMode build_tunnels; ///< If/when towns are allowed to build road tunnels (if TSOF_OVERRIDE_BUILD_TUNNELS set in override_flags) - uint8 max_road_slope; ///< Maximum number of consecutive sloped road tiles which towns are allowed to build (if TSOF_OVERRIDE_BUILD_INCLINED_ROADS set in override_flags) + byte override_flags; ///< Bitmask of enabled flag overrides. See #TownSettingOverrideFlags. + byte override_values; ///< Bitmask of flag override values. See #TownSettingOverrideFlags. + TownTunnelMode build_tunnels; ///< If/when towns are allowed to build road tunnels (if TSOF_OVERRIDE_BUILD_TUNNELS set in override_flags) + uint8_t max_road_slope; ///< Maximum number of consecutive sloped road tiles which towns are allowed to build (if TSOF_OVERRIDE_BUILD_INCLINED_ROADS set in override_flags) - uint16 church_count; ///< Number of church buildings in the town. - uint16 stadium_count; ///< Number of stadium buildings in the town. + uint16_t church_count; ///< Number of church buildings in the town. + uint16_t stadium_count; ///< Number of stadium buildings in the town. - 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? + 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) - 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 town_label_rating; ///< Label dependent on _local_company rating. + CompanyMask have_ratings; ///< which companies have a rating + uint8_t unwanted[MAX_COMPANIES]; ///< how many months companies aren't wanted by towns (bribe) + CompanyID exclusivity; ///< which company has exclusivity + uint8_t exclusive_counter; ///< months till the exclusivity expires + int16_t ratings[MAX_COMPANIES]; ///< ratings of each company for this town + uint8_t town_label_rating; ///< Label dependent on _local_company rating. - 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. @@ -114,10 +114,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? @@ -141,7 +141,7 @@ struct Town : TownPool::PoolItem<&_town_pool> { void InitializeLayout(TownLayout layout); void UpdateLabel(); - uint64 LabelParam2() const; + uint64_t LabelParam2() const; /** * Calculate the max town noise. @@ -149,7 +149,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 (_settings_game.difficulty.town_council_tolerance == TOWN_COUNCIL_PERMISSIVE) return UINT16_MAX; @@ -193,7 +193,7 @@ struct Town : TownPool::PoolItem<&_town_pool> { return HasBit(this->override_flags, TSOF_OVERRIDE_BUILD_TUNNELS) ? this->build_tunnels : _settings_game.economy.town_build_tunnels; } - inline uint8 GetBuildMaxRoadSlope() const + inline uint8_t GetBuildMaxRoadSlope() const { return HasBit(this->override_flags, TSOF_OVERRIDE_BUILD_INCLINED_ROADS) ? this->max_road_slope : _settings_game.economy.town_max_road_slope; } @@ -210,7 +210,7 @@ private: void FillCachedName() const; }; -uint32 GetWorldPopulation(); +uint32_t GetWorldPopulation(); void UpdateAllTownVirtCoords(); void ClearAllTownCachedNames(); @@ -322,10 +322,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); @@ -359,7 +359,7 @@ 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... } /* diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index b8aad6d5e6..f8a8f39731 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -194,7 +194,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) { @@ -229,7 +229,7 @@ void Town::UpdateLabel() if (r > RATING_GOOD) town_rating++; // Very Good if (r > RATING_VERYGOOD) town_rating++; // Excellent and Outstanding - static const uint8 tcs[] = { TC_RED, TC_ORANGE, TC_YELLOW, TC_WHITE, TC_GREEN }; + static const uint8_t tcs[] = { TC_RED, TC_ORANGE, TC_YELLOW, TC_WHITE, TC_GREEN }; this->town_label_rating = tcs[town_rating]; } } @@ -237,9 +237,9 @@ void Town::UpdateLabel() /** * Get the second dparam value for town viewport labels */ -uint64 Town::LabelParam2() const +uint64_t Town::LabelParam2() const { - uint64 value = this->cache.population; + uint64_t value = this->cache.population; if (!(_game_mode == GM_EDITOR) && (_local_company < MAX_COMPANIES)) { SB(value, 32, 8, this->town_label_rating); } else { @@ -275,7 +275,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) { @@ -451,14 +451,14 @@ 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; } } return FlatteningFoundation(tileh); } -uint8 GetAnimatedTileSpeed_Town(TileIndex tile) +uint8_t GetAnimatedTileSpeed_Town(TileIndex tile) { if (GetHouseType(tile) >= NEW_HOUSE_OFFSET) { return GetNewHouseTileAnimationSpeed(tile); @@ -580,11 +580,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; } @@ -707,13 +707,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; @@ -748,7 +748,7 @@ static void TileLoop_Town(TileIndex tile) if (GB(_tick_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 */ @@ -852,7 +852,7 @@ void AddProducedHouseCargo(HouseID house_id, TileIndex tile, CargoArray &produce if (HasBit(hs->callback_mask, CBM_HOUSE_PRODUCE_CARGO)) { Town *t = (tile == INVALID_TILE) ? nullptr : Town::GetByTile(tile); 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; @@ -890,13 +890,13 @@ void AddAcceptedHouseCargo(HouseID house_id, TileIndex tile, CargoArray &accepta 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, house_id, t, tile); + uint16_t callback = GetHouseCallback(CBID_HOUSE_ACCEPT_CARGO, 0, 0, house_id, t, 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); @@ -907,7 +907,7 @@ void AddAcceptedHouseCargo(HouseID house_id, TileIndex tile, CargoArray &accepta /* Check for custom cargo acceptance */ if (HasBit(hs->callback_mask, CBM_HOUSE_CARGO_ACCEPTANCE)) { - uint16 callback = GetHouseCallback(CBID_HOUSE_CARGO_ACCEPTANCE, 0, 0, house_id, t, tile); + uint16_t callback = GetHouseCallback(CBID_HOUSE_CARGO_ACCEPTANCE, 0, 0, house_id, t, 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); @@ -922,7 +922,7 @@ void AddAcceptedHouseCargo(HouseID house_id, TileIndex tile, CargoArray &accepta } /* 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); } } @@ -978,7 +978,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; @@ -1016,7 +1016,7 @@ RoadType GetTownRoadType() { 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; @@ -1488,7 +1488,7 @@ static bool GrowTownWithTunnel(const Town *t, const TileIndex tile, const DiagDi /* 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; @@ -1502,7 +1502,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. */ @@ -1657,7 +1657,7 @@ static void GrowTownInTile(TileIndex *tile_ptr, RoadBits cur_rb, DiagDirection t break; } - const uint8 max_road_slope = t1->GetBuildMaxRoadSlope(); + const uint8_t max_road_slope = t1->GetBuildMaxRoadSlope(); if (max_road_slope > 0 && ((rcmd == ROAD_X) || (rcmd == ROAD_Y))) { /* Limit consecutive sloped road tiles */ @@ -1998,7 +1998,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; @@ -2118,7 +2118,7 @@ void UpdateTownRadius(Town *t) MemSetT(t->cache.squared_town_zone_radius, 0, lengthof(t->cache.squared_town_zone_radius)); - uint16 cb_result = GetTownZonesCallback(t); + uint16_t cb_result = GetTownZonesCallback(t); if (cb_result == 0) { t->cache.squared_town_zone_radius[0] = GetRegister(0x100); t->cache.squared_town_zone_radius[1] = GetRegister(0x101); @@ -2170,7 +2170,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; @@ -2308,14 +2308,14 @@ static bool IsUniqueTownName(const char *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. */ -CommandCost CmdFoundTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdFoundTown(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { TownSize size = Extract(p1); bool city = HasBit(p1, 2); TownLayout layout = Extract(p1); TownNameParams par(_settings_game.game_creation.town_name); bool random = HasBit(p1, 6); - uint32 townnameparts = p2; + uint32_t townnameparts = p2; if (size >= TSZ_END) return CMD_ERROR; if (layout >= NUM_TLS) return CMD_ERROR; @@ -2535,7 +2535,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 @@ -2593,7 +2593,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 : ScaleByMapSize(_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); @@ -2985,7 +2985,7 @@ static void DoBuildHouse(Town *t, TileIndex tile, HouseID house, byte random_bit byte construction_stage = 0; if (_generating_world || _game_mode == GM_EDITOR) { - uint32 r = Random(); + uint32_t r = Random(); construction_stage = TOWN_HOUSE_COMPLETED; if (Chance16(1, 7)) construction_stage = GB(r, 0, 2); @@ -3014,7 +3014,7 @@ static void DoBuildHouse(Town *t, TileIndex tile, HouseID house, byte random_bit * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildHouse(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildHouse(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_game_mode != GM_EDITOR && // in scenario editor anyone can build a house _current_company != OWNER_TOWN && // towns naturally can build houses @@ -3226,7 +3226,7 @@ void ClearTownHouse(Town *t, TileIndex tile) * @param text the new name or an empty string when resetting to the default * @return the cost of this operation or an error */ -CommandCost CmdRenameTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRenameTown(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Town *t = Town::GetIfValid(p1); if (t == nullptr) return CMD_ERROR; @@ -3265,7 +3265,7 @@ CommandCost CmdRenameTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 * @param text the new name or an empty string when resetting to the default * @return the cost of this operation or an error */ -CommandCost CmdRenameTownNonAdmin(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRenameTownNonAdmin(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_networking && !_settings_game.difficulty.rename_towns_in_multiplayer) return CMD_ERROR; @@ -3296,14 +3296,14 @@ const CargoSpec *FindFirstCargoWithTownEffect(TownEffect effect) * @param text Unused. * @return Empty cost or an error. */ -CommandCost CmdTownCargoGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdTownCargoGoal(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; TownEffect te = (TownEffect)GB(p1, 16, 8); if (te < TE_BEGIN || te >= TE_END) return CMD_ERROR; - uint16 index = GB(p1, 0, 16); + uint16_t index = GB(p1, 0, 16); Town *t = Town::GetIfValid(index); if (t == nullptr) return CMD_ERROR; @@ -3329,7 +3329,7 @@ CommandCost CmdTownCargoGoal(TileIndex tile, DoCommandFlag flags, uint32 p1, uin * @param text The new text (empty to remove the text). * @return Empty cost or an error. */ -CommandCost CmdTownSetText(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdTownSetText(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; Town *t = Town::GetIfValid(p1); @@ -3353,7 +3353,7 @@ CommandCost CmdTownSetText(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 * @param text Unused. * @return Empty cost or an error. */ -CommandCost CmdTownGrowthRate(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdTownGrowthRate(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; if (GB(p2, 16, 16) != 0) return CMD_ERROR; @@ -3389,11 +3389,11 @@ CommandCost CmdTownGrowthRate(TileIndex tile, DoCommandFlag flags, uint32 p1, ui * @param tile Unused. * @param flags Type of operation. * @param p1 Bit 0..15 = Town ID to change, bit 16..23 = Company ID to change. - * @param p2 Bit 0..15 = New rating of company (signed int16). + * @param p2 Bit 0..15 = New rating of company (signed int16_t). * @param text Unused. * @return Empty cost or an error. */ -CommandCost CmdTownRating(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdTownRating(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; @@ -3404,7 +3404,7 @@ CommandCost CmdTownRating(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 CompanyID company_id = (CompanyID)GB(p1, 16, 8); if (!Company::IsValidID(company_id)) return CMD_ERROR; - int16 new_rating = Clamp((int16)GB(p2, 0, 16), RATING_MINIMUM, RATING_MAXIMUM); + int16_t new_rating = Clamp((int16_t)GB(p2, 0, 16), RATING_MINIMUM, RATING_MAXIMUM); if (_cheats.town_rating.value) { new_rating = RATING_MAXIMUM; } @@ -3425,7 +3425,7 @@ CommandCost CmdTownRating(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 * @param text Unused. * @return Empty cost or an error. */ -CommandCost CmdExpandTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdExpandTown(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_game_mode != GM_EDITOR && _current_company != OWNER_DEITY) return CMD_ERROR; Town *t = Town::GetIfValid(p1); @@ -3434,7 +3434,7 @@ CommandCost CmdExpandTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 if (flags & DC_EXEC) { /* The more houses, the faster we grow */ if (p2 == 0) { - uint amount = RandomRange(ClampTo(t->cache.num_houses / 10)) + 3; + uint amount = RandomRange(ClampTo(t->cache.num_houses / 10)) + 3; t->cache.num_houses += amount; UpdateTownRadius(t); @@ -3465,7 +3465,7 @@ CommandCost CmdExpandTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 * @param text Unused. * @return Empty cost or an error. */ -CommandCost CmdDeleteTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdDeleteTown(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_game_mode != GM_EDITOR && !_generating_world) return CMD_ERROR; Town *t = Town::GetIfValid(p1); @@ -3748,7 +3748,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); } @@ -3904,7 +3904,7 @@ uint GetMaskOfTownActions(int *nump, CompanyID cid, const Town *t) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdDoTownAction(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdDoTownAction(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Town *t = Town::GetIfValid(p1); if (t == nullptr || p2 >= lengthof(_town_action_proc)) return CMD_ERROR; @@ -3935,14 +3935,14 @@ CommandCost CmdDoTownAction(TileIndex tile, DoCommandFlag flags, uint32 p1, uint * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdOverrideTownSetting(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdOverrideTownSetting(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Town *t = Town::GetIfValid(p1); if (t == nullptr) return CMD_ERROR; - const uint8 setting = GB(p2, 0, 8); + const uint8_t setting = GB(p2, 0, 8); const bool is_override = HasBit(p2, 16); - const uint8 value = GB(p2, 8, 8); + const uint8_t value = GB(p2, 8, 8); switch (setting) { case TSOF_OVERRIDE_GROWTH: if (is_override && value != 0) return CMD_ERROR; @@ -4002,7 +4002,7 @@ CommandCost CmdOverrideTownSetting(TileIndex tile, DoCommandFlag flags, uint32 p * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdOverrideTownSettingNonAdmin(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdOverrideTownSettingNonAdmin(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_networking && !_settings_game.difficulty.override_town_settings_in_multiplayer) return CMD_ERROR; @@ -4069,14 +4069,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 || t->IsTownGrowthDisabledByOverride()) 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); } /** @@ -4108,13 +4108,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)]; int growth_multiplier; if (_settings_game.economy.town_growth_rate == 0) { @@ -4137,19 +4137,19 @@ static uint GetNormalGrowthRate(Town *t) * town_growth_cargo_transported percent of the growth rate is multiplied by the proportion of town cargoes transported. * The growth rate can only be decreased by this setting, not increased. */ - uint32 inverse_m = UINT32_MAX / m; - auto calculate_cargo_ratio_fix15 = [](const TransportedCargoStat &stat) -> uint32 { - return stat.old_max ? ((uint64) (stat.old_act << 15)) / stat.old_max : 1 << 15; + uint32_t inverse_m = UINT32_MAX / m; + auto calculate_cargo_ratio_fix15 = [](const TransportedCargoStat &stat) -> uint32_t { + return stat.old_max ? ((uint64_t) (stat.old_act << 15)) / stat.old_max : 1 << 15; }; - uint32 cargo_ratio_fix16 = calculate_cargo_ratio_fix15(t->supplied[CT_PASSENGERS]) + calculate_cargo_ratio_fix15(t->supplied[CT_MAIL]); - uint64 cargo_dependant_part = (((uint64) cargo_ratio_fix16) * ((uint64) inverse_m) * _settings_game.economy.town_growth_cargo_transported) >> 16; - uint64 non_cargo_dependant_part = ((uint64) inverse_m) * (100 - _settings_game.economy.town_growth_cargo_transported); - uint64 total = (cargo_dependant_part + non_cargo_dependant_part); + uint32_t cargo_ratio_fix16 = calculate_cargo_ratio_fix15(t->supplied[CT_PASSENGERS]) + calculate_cargo_ratio_fix15(t->supplied[CT_MAIL]); + uint64_t cargo_dependant_part = (((uint64_t) cargo_ratio_fix16) * ((uint64_t) inverse_m) * _settings_game.economy.town_growth_cargo_transported) >> 16; + uint64_t non_cargo_dependant_part = ((uint64_t) inverse_m) * (100 - _settings_game.economy.town_growth_cargo_transported); + uint64_t total = (cargo_dependant_part + non_cargo_dependant_part); if (total == 0) { ClrBit(t->flags, TOWN_IS_GROWING); return UINT16_MAX; } - m = ((uint64) UINT32_MAX * 100) / total; + m = ((uint64_t) UINT32_MAX * 100) / total; } return TownTicksToGameTicks(m / (t->cache.num_houses / 50 + 1)); @@ -4388,7 +4388,7 @@ void UpdateAllTownRatings() if (Company::IsValidID(_local_company) && HasBit(t->have_ratings, _local_company) && t->ratings[_local_company] <= 0) { ZoningTownAuthorityRatingChange(); } - for (uint8 c : SetBitIterator(t->have_ratings)) { + for (uint8_t c : SetBitIterator(t->have_ratings)) { t->ratings[c] = RATING_MAXIMUM; } if (t->have_ratings != 0) { @@ -4494,7 +4494,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_gui.cpp b/src/town_gui.cpp index 81b7ed7f2d..d8918c0f7f 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -97,7 +97,7 @@ private: * @param n The Nth set bit from which we want to know the position * @return The position of the Nth set bit */ - static int GetNthSetBit(uint32 bits, int n) + static int GetNthSetBit(uint32_t bits, int n) { if (n >= 0) { for (uint i : SetBitIterator(bits)) { @@ -322,7 +322,7 @@ public: } case TSOF_OVERRIDE_BUILD_INCLINED_ROADS: { - uint8 max_slope = this->town->GetBuildMaxRoadSlope(); + uint8_t max_slope = this->town->GetBuildMaxRoadSlope(); SetDParam(2, STR_CONFIG_SETTING_TOWN_MAX_ROAD_SLOPE_VALUE + ((max_slope == 0) ? 1 : 0)); SetDParam(3, max_slope); break; @@ -419,7 +419,7 @@ public: break; case WID_TA_SETTING: { - uint8 idx = this->sel_index - 0x100; + uint8_t idx = this->sel_index - 0x100; switch (idx) { case TSOF_OVERRIDE_BUILD_ROADS: case TSOF_OVERRIDE_BUILD_LEVEL_CROSSINGS: @@ -478,7 +478,7 @@ public: switch (widget) { case WID_TA_SETTING: { if (index < 0) break; - uint32 p2 = this->sel_index - 0x100; + uint32_t p2 = this->sel_index - 0x100; if (index > 0) { SetBit(p2, 16); p2 |= (index - 1) << 8; @@ -636,7 +636,7 @@ public: /* only show the town noise, if the noise option is activated. */ if (_settings_game.economy.station_noise_level) { - uint16 max_noise = this->town->MaxTownNoise(); + uint16_t max_noise = this->town->MaxTownNoise(); SetDParam(0, this->town->noise_reached); SetDParam(1, max_noise); DrawString(tr, max_noise == UINT16_MAX ? STR_TOWN_VIEW_NOISE_IN_TOWN_NO_LIMIT : STR_TOWN_VIEW_NOISE_IN_TOWN); @@ -1250,7 +1250,7 @@ void ShowTownDirectory() new TownDirectoryWindow(&_town_directory_desc); } -void CcFoundTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcFoundTown(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; @@ -1258,7 +1258,7 @@ void CcFoundTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } -void CcFoundRandomTown(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcFoundRandomTown(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Succeeded()) ScrollMainWindowToTile(Town::Get(_new_town_id)->xy); } @@ -1322,7 +1322,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: @@ -1484,7 +1484,7 @@ void ShowFoundTownWindow() class GUIHouseList : public std::vector { protected: - std::vector house_sets; ///< list of house sets, each item points the first house of the set in the houses array + std::vector house_sets; ///< list of house sets, each item points the first house of the set in the houses array static bool HouseSorter(const HouseID &a, const HouseID &b) { @@ -1602,7 +1602,7 @@ public: } } /* put a terminator on the list to make counting easier */ - this->house_sets.push_back((uint16)this->size()); + this->house_sets.push_back((uint16_t)this->size()); } }; @@ -1828,7 +1828,7 @@ public: case WID_HP_HOUSE_SUPPLY: { CargoArray cargo{}; AddProducedHouseCargo(this->display_house, INVALID_TILE, cargo); - uint32 cargo_mask = 0; + uint32_t cargo_mask = 0; for (uint i = 0; i < NUM_CARGO; i++) if (cargo[i] != 0) SetBit(cargo_mask, i); SetDParam(0, cargo_mask); break; diff --git a/src/town_kdtree.h b/src/town_kdtree.h index af48227ad9..d736c255bb 100644 --- a/src/town_kdtree.h +++ b/src/town_kdtree.h @@ -13,8 +13,8 @@ #include "core/kdtree.hpp" #include "town.h" -inline uint32 Kdtree_TownXYFunc(TownID tid, int dim) { return (dim == 0) ? TileX(Town::Get(tid)->xy) : TileY(Town::Get(tid)->xy); } -typedef Kdtree TownKdtree; +inline uint32_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 b7e327ce15..9a1d2a0494 100644 --- a/src/town_type.h +++ b/src/town_type.h @@ -13,7 +13,7 @@ #include "core/enum_type.hpp" #include -typedef uint16 TownID; +typedef uint16_t TownID; struct Town; typedef std::vector TownList; diff --git a/src/tracerestrict.cpp b/src/tracerestrict.cpp index 6c72cf1c30..c5f1e6c7e1 100644 --- a/src/tracerestrict.cpp +++ b/src/tracerestrict.cpp @@ -89,7 +89,7 @@ TraceRestrictMapping _tracerestrictprogram_mapping; * List of pre-defined pathfinder penalty values * This is indexed by TraceRestrictPathfinderPenaltyPresetIndex */ -const uint16 _tracerestrict_pathfinder_penalty_preset_values[] = { +const uint16_t _tracerestrict_pathfinder_penalty_preset_values[] = { 500, 2000, 8000, @@ -273,7 +273,7 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp condstack.pop_back(); } } else { - uint16 condvalue = GetTraceRestrictValue(item); + uint16_t condvalue = GetTraceRestrictValue(item); bool result = false; switch(type) { case TRIT_COND_UNDEFINED: @@ -658,7 +658,7 @@ void TraceRestrictProgram::Execute(const Train* v, const TraceRestrictProgramInp break; case TRPPAF_PRESET: { - uint16 index = GetTraceRestrictValue(item); + uint16_t index = GetTraceRestrictValue(item); assert(index < TRPPPI_END); out.penalty += _tracerestrict_pathfinder_penalty_preset_values[index]; break; @@ -1602,7 +1602,7 @@ void SetTraceRestrictValueDefault(TraceRestrictItem &item, TraceRestrictValueTyp /** * Set the type field of a TraceRestrictItem, and resets any other fields which are no longer valid/meaningful to sensible defaults */ -void SetTraceRestrictTypeAndNormalise(TraceRestrictItem &item, TraceRestrictItemType type, uint8 aux_data) +void SetTraceRestrictTypeAndNormalise(TraceRestrictItem &item, TraceRestrictItemType type, uint8_t aux_data) { if (item != 0) { assert(GetTraceRestrictType(item) != TRIT_NULL); @@ -1816,9 +1816,9 @@ void TraceRestrictNotifySignalRemoval(TileIndex tile, Track track) /** * Helper function to perform parameter bit-packing and call DoCommandP, for instruction modification actions */ -void TraceRestrictDoCommandP(TileIndex tile, Track track, TraceRestrictDoCommandType type, uint32 offset, uint32 value, StringID error_msg) +void TraceRestrictDoCommandP(TileIndex tile, Track track, TraceRestrictDoCommandType type, uint32_t offset, uint32_t value, StringID error_msg) { - uint32 p1 = 0; + uint32_t p1 = 0; SB(p1, 0, 3, track); SB(p1, 3, 5, type); assert(offset < (1 << 16)); @@ -1868,7 +1868,7 @@ static CommandCost TraceRestrictCheckTileIsUsable(TileIndex tile, Track track) * Returns an appropriate default value for the second item of a dual-item instruction * @p item is the first item of the instruction */ -static uint32 GetDualInstructionInitialValue(TraceRestrictItem item) +static uint32_t GetDualInstructionInitialValue(TraceRestrictItem item) { switch (GetTraceRestrictType(item)) { case TRIT_COND_PBS_ENTRY_SIGNAL: @@ -1898,7 +1898,7 @@ template void InstructionIteratorAdvance(T &iter) iter = InstructionIteratorNext(iter); } -CommandCost TraceRestrictProgramRemoveItemAt(std::vector &items, uint32 offset, bool shallow_mode) +CommandCost TraceRestrictProgramRemoveItemAt(std::vector &items, uint32_t offset, bool shallow_mode) { TraceRestrictItem old_item = *TraceRestrictProgram::InstructionAt(items, offset); if (IsTraceRestrictConditional(old_item) && GetTraceRestrictCondFlags(old_item) != TRCF_OR) { @@ -1913,7 +1913,7 @@ CommandCost TraceRestrictProgramRemoveItemAt(std::vector &ite } } - uint32 recursion_depth = 1; + uint32_t recursion_depth = 1; std::vector::iterator remove_start = TraceRestrictProgram::InstructionAt(items, offset); std::vector::iterator remove_end = InstructionIteratorNext(remove_start); @@ -1984,7 +1984,7 @@ static CommandCost AdvanceItemEndIteratorForBlock(const std::vector &items, uint32 &offset, bool up, bool shallow_mode) +CommandCost TraceRestrictProgramMoveItemAt(std::vector &items, uint32_t &offset, bool up, bool shallow_mode) { std::vector::iterator move_start = TraceRestrictProgram::InstructionAt(items, offset); std::vector::iterator move_end = InstructionIteratorNext(move_start); @@ -2057,7 +2057,7 @@ CommandCost TraceRestrictProgramMoveItemAt(std::vector &items return CommandCost(); } -CommandCost TraceRestrictProgramDuplicateItemAt(std::vector &items, uint32 offset) +CommandCost TraceRestrictProgramDuplicateItemAt(std::vector &items, uint32_t offset) { std::vector::iterator dup_start = TraceRestrictProgram::InstructionAt(items, offset); std::vector::iterator dup_end = InstructionIteratorNext(dup_start); @@ -2074,7 +2074,7 @@ CommandCost TraceRestrictProgramDuplicateItemAt(std::vector & return CommandCost(); } -bool TraceRestrictProgramDuplicateItemAtDryRun(const std::vector &items, uint32 offset) +bool TraceRestrictProgramDuplicateItemAtDryRun(const std::vector &items, uint32_t offset) { std::vector::iterator dup_start = TraceRestrictProgram::InstructionAt(const_cast &>(items), offset); std::vector::iterator dup_end = InstructionIteratorNext(dup_start); @@ -2092,7 +2092,7 @@ bool TraceRestrictProgramDuplicateItemAtDryRun(const std::vector(GB(p1, 3, 5)); @@ -2101,7 +2101,7 @@ CommandCost CmdProgramSignalTraceRestrict(TileIndex tile, DoCommandFlag flags, u } Track track = static_cast(GB(p1, 0, 3)); - uint32 offset = GB(p1, 8, 16); + uint32_t offset = GB(p1, 8, 16); TraceRestrictItem item = static_cast(p2); CommandCost ret = TraceRestrictCheckTileIsUsable(tile, track); @@ -2116,7 +2116,7 @@ CommandCost CmdProgramSignalTraceRestrict(TileIndex tile, DoCommandFlag flags, u return_cmd_error(STR_TRACE_RESTRICT_ERROR_NO_PROGRAM); } - uint32 offset_limit_exclusive = ((type == TRDCT_INSERT_ITEM) ? 1 : 0); + uint32_t offset_limit_exclusive = ((type == TRDCT_INSERT_ITEM) ? 1 : 0); if (prog) offset_limit_exclusive += (uint)prog->items.size(); if (offset >= offset_limit_exclusive) { @@ -2231,7 +2231,7 @@ CommandCost CmdProgramSignalTraceRestrict(TileIndex tile, DoCommandFlag flags, u void TraceRestrictProgMgmtWithSourceDoCommandP(TileIndex tile, Track track, TraceRestrictDoCommandType type, TileIndex source_tile, Track source_track, StringID error_msg) { - uint32 p1 = 0; + uint32_t p1 = 0; SB(p1, 0, 3, track); SB(p1, 3, 5, type); SB(p1, 8, 3, source_track); @@ -2246,7 +2246,7 @@ void TraceRestrictProgMgmtWithSourceDoCommandP(TileIndex tile, Track track, Trac * @param p2 Source tile, for share/copy operations * @return the cost of this operation (which is free), or an error */ -CommandCost CmdProgramSignalTraceRestrictProgMgmt(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdProgramSignalTraceRestrictProgMgmt(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { TraceRestrictDoCommandType type = static_cast(GB(p1, 3, 5)); Track track = static_cast(GB(p1, 0, 3)); @@ -2439,7 +2439,7 @@ int GetTraceRestrictTimeDateValueFromDate(TraceRestrictTimeDateValueField type, * This is called when a station, waypoint or depot is about to be deleted * Scan program pool and change any references to it to the invalid station ID, to avoid dangling references */ -void TraceRestrictRemoveDestinationID(TraceRestrictOrderCondAuxField type, uint16 index) +void TraceRestrictRemoveDestinationID(TraceRestrictOrderCondAuxField type, uint16_t index) { for (TraceRestrictProgram *prog : TraceRestrictProgram::Iterate()) { for (size_t i = 0; i < prog->items.size(); i++) { @@ -2817,7 +2817,7 @@ static bool IsUniqueSlotName(const char *name) * @param text new slot name * @return the cost of this operation or an error */ -CommandCost CmdCreateTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdCreateTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (!TraceRestrictSlot::CanAllocateItem()) return CMD_ERROR; if (StrEmpty(text)) return CMD_ERROR; @@ -2853,7 +2853,7 @@ CommandCost CmdCreateTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, uint * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdDeleteTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdDeleteTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { TraceRestrictSlot *slot = TraceRestrictSlot::GetIfValid(p1); if (slot == nullptr || slot->owner != _current_company) return CMD_ERROR; @@ -2884,7 +2884,7 @@ CommandCost CmdDeleteTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, uint * @param text the new name * @return the cost of this operation or an error */ -CommandCost CmdAlterTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdAlterTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { TraceRestrictSlot *slot = TraceRestrictSlot::GetIfValid(GB(p1, 0, 16)); if (slot == nullptr || slot->owner != _current_company) return CMD_ERROR; @@ -2932,7 +2932,7 @@ CommandCost CmdAlterTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, uint3 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdAddVehicleTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdAddVehicleTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { TraceRestrictSlot *slot = TraceRestrictSlot::GetIfValid(p1); Vehicle *v = Vehicle::GetIfValid(p2); @@ -2958,7 +2958,7 @@ CommandCost CmdAddVehicleTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdRemoveVehicleTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRemoveVehicleTraceRestrictSlot(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { TraceRestrictSlot *slot = TraceRestrictSlot::GetIfValid(p1); Vehicle *v = Vehicle::GetIfValid(p2); @@ -2972,9 +2972,9 @@ CommandCost CmdRemoveVehicleTraceRestrictSlot(TileIndex tile, DoCommandFlag flag return CommandCost(); } -void TraceRestrictCounter::UpdateValue(int32 new_value) +void TraceRestrictCounter::UpdateValue(int32_t new_value) { - new_value = std::max(0, new_value); + new_value = std::max(0, new_value); if (new_value != this->value) { this->value = new_value; InvalidateWindowClassesData(WC_TRACE_RESTRICT_COUNTERS); @@ -2985,17 +2985,17 @@ void TraceRestrictCounter::UpdateValue(int32 new_value) } } -int32 TraceRestrictCounter::ApplyValue(int32 current, TraceRestrictCounterCondOpField op, int32 value) +int32_t TraceRestrictCounter::ApplyValue(int32_t current, TraceRestrictCounterCondOpField op, int32_t value) { switch (op) { case TRCCOF_INCREASE: - return std::max(0, current + value); + return std::max(0, current + value); case TRCCOF_DECREASE: - return std::max(0, current - value); + return std::max(0, current - value); case TRCCOF_SET: - return std::max(0, value); + return std::max(0, value); default: NOT_REACHED(); @@ -3065,7 +3065,7 @@ void TraceRestrictRemoveCounterID(TraceRestrictCounterID index) * @param text new counter name * @return the cost of this operation or an error */ -CommandCost CmdCreateTraceRestrictCounter(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdCreateTraceRestrictCounter(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (!TraceRestrictCounter::CanAllocateItem()) return CMD_ERROR; if (StrEmpty(text)) return CMD_ERROR; @@ -3098,7 +3098,7 @@ CommandCost CmdCreateTraceRestrictCounter(TileIndex tile, DoCommandFlag flags, u * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdDeleteTraceRestrictCounter(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdDeleteTraceRestrictCounter(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { TraceRestrictCounter *ctr = TraceRestrictCounter::GetIfValid(p1); if (ctr == nullptr || ctr->owner != _current_company) return CMD_ERROR; @@ -3129,7 +3129,7 @@ CommandCost CmdDeleteTraceRestrictCounter(TileIndex tile, DoCommandFlag flags, u * @param text the new name * @return the cost of this operation or an error */ -CommandCost CmdAlterTraceRestrictCounter(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdAlterTraceRestrictCounter(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { TraceRestrictCounter *ctr = TraceRestrictCounter::GetIfValid(GB(p1, 0, 16)); if (ctr == nullptr || ctr->owner != _current_company) return CMD_ERROR; diff --git a/src/tracerestrict.h b/src/tracerestrict.h index 626a9c4e9c..a28424e1a7 100644 --- a/src/tracerestrict.h +++ b/src/tracerestrict.h @@ -28,11 +28,11 @@ struct Train; /** Program pool ID type. */ -typedef uint32 TraceRestrictProgramID; +typedef uint32_t TraceRestrictProgramID; struct TraceRestrictProgram; /** Tile/track mapping type. */ -typedef uint32 TraceRestrictRefId; +typedef uint32_t TraceRestrictRefId; /** Type of the pool for trace restrict programs. */ typedef Pool TraceRestrictProgramPool; @@ -40,7 +40,7 @@ typedef Pool TraceRest extern TraceRestrictProgramPool _tracerestrictprogram_pool; /** Slot pool ID type. */ -typedef uint16 TraceRestrictSlotID; +typedef uint16_t TraceRestrictSlotID; struct TraceRestrictSlot; /** Type of the pool for trace restrict slots. */ @@ -53,7 +53,7 @@ static const TraceRestrictSlotID ALL_TRAINS_TRACE_RESTRICT_SLOT_ID = 0xFFFE; // static const TraceRestrictSlotID INVALID_TRACE_RESTRICT_SLOT_ID = 0xFFFF; /** Counter pool ID type. */ -typedef uint16 TraceRestrictCounterID; +typedef uint16_t TraceRestrictCounterID; struct TraceRestrictCounter; /** Type of the pool for trace restrict counters. */ @@ -64,7 +64,7 @@ extern TraceRestrictCounterPool _tracerestrictcounter_pool; static const TraceRestrictCounterID NEW_TRACE_RESTRICT_COUNTER_ID = 0xFFFE; // for GUI use only static const TraceRestrictCounterID INVALID_TRACE_RESTRICT_COUNTER_ID = 0xFFFF; -extern const uint16 _tracerestrict_pathfinder_penalty_preset_values[]; +extern const uint16_t _tracerestrict_pathfinder_penalty_preset_values[]; /** Type used for the TraceRestrictRefId -> TraceRestrictProgramID mapping */ struct TraceRestrictMappingItem { @@ -84,7 +84,7 @@ extern TraceRestrictMapping _tracerestrictprogram_mapping; void ClearTraceRestrictMapping(); /** Type of a single instruction, this is bit-packed as per TraceRestrictItemFlagAllocation */ -typedef uint32 TraceRestrictItem; +typedef uint32_t TraceRestrictItem; /** * Describes the allocation of bits to fields in TraceRestrictItem. @@ -463,7 +463,7 @@ DECLARE_ENUM_AS_BIT_SET(TraceRestrictProgramActionsUsedFlags) /** * Enumeration for TraceRestrictProgramInput::permitted_slot_operations */ -enum TraceRestrictProgramInputSlotPermissions : uint8 { +enum TraceRestrictProgramInputSlotPermissions : uint8_t { TRPISP_ACQUIRE = 1 << 0, ///< Slot acquire is permitted TRPISP_RELEASE_BACK = 1 << 1, ///< Slot release (back) is permitted TRPISP_RELEASE_FRONT = 1 << 2, ///< Slot release (front) is permitted @@ -478,7 +478,7 @@ DECLARE_ENUM_AS_BIT_SET(TraceRestrictProgramInputSlotPermissions) /** * Enumeration for TraceRestrictProgramInput::input_flags */ -enum TraceRestrictProgramInputFlags : uint8 { +enum TraceRestrictProgramInputFlags : uint8_t { TRPIF_PASSED_STOP = 1 << 0, ///< Train has passed stop }; DECLARE_ENUM_AS_BIT_SET(TraceRestrictProgramInputFlags) @@ -506,9 +506,9 @@ struct TraceRestrictProgramInput { * Execution result of a TraceRestrictProgram */ struct TraceRestrictProgramResult { - uint32 penalty; ///< Total additional pathfinder penalty + uint32_t penalty; ///< Total additional pathfinder penalty TraceRestrictProgramResultFlags flags; ///< Flags of other actions to take - uint16 speed_restriction; ///< Speed restriction to apply (if TRPRF_SPEED_RESTRICTION_SET flag present) + uint16_t speed_restriction; ///< Speed restriction to apply (if TRPRF_SPEED_RESTRICTION_SET flag present) TraceRestrictProgramResult() : penalty(0), flags(static_cast(0)) { } @@ -520,14 +520,14 @@ struct TraceRestrictProgramResult { */ struct TraceRestrictProgram : TraceRestrictProgramPool::PoolItem<&_tracerestrictprogram_pool> { std::vector items; - uint32 refcount; + uint32_t refcount; TraceRestrictProgramActionsUsedFlags actions_used_flags; private: struct ptr_buffer { TraceRestrictRefId *buffer; - uint32 elem_capacity; + uint32_t elem_capacity; }; union refid_list_union { TraceRestrictRefId inline_ref_ids[4]; @@ -629,15 +629,15 @@ inline TraceRestrictCondOp GetTraceRestrictCondOp(TraceRestrictItem item) } /** Get TraceRestrictItem auxiliary field */ -inline uint8 GetTraceRestrictAuxField(TraceRestrictItem item) +inline uint8_t GetTraceRestrictAuxField(TraceRestrictItem item) { return GB(item, TRIFA_AUX_FIELD_OFFSET, TRIFA_AUX_FIELD_COUNT); } /** Get TraceRestrictItem value field */ -inline uint16 GetTraceRestrictValue(TraceRestrictItem item) +inline uint16_t GetTraceRestrictValue(TraceRestrictItem item) { - return static_cast(GB(item, TRIFA_VALUE_OFFSET, TRIFA_VALUE_COUNT)); + return static_cast(GB(item, TRIFA_VALUE_OFFSET, TRIFA_VALUE_COUNT)); } /** Set TraceRestrictItem type field */ @@ -659,13 +659,13 @@ inline void SetTraceRestrictCondFlags(TraceRestrictItem &item, TraceRestrictCond } /** Set TraceRestrictItem auxiliary field */ -inline void SetTraceRestrictAuxField(TraceRestrictItem &item, uint8 data) +inline void SetTraceRestrictAuxField(TraceRestrictItem &item, uint8_t data) { SB(item, TRIFA_AUX_FIELD_OFFSET, TRIFA_AUX_FIELD_COUNT, data); } /** Set TraceRestrictItem value field */ -inline void SetTraceRestrictValue(TraceRestrictItem &item, uint16 value) +inline void SetTraceRestrictValue(TraceRestrictItem &item, uint16_t value) { SB(item, TRIFA_VALUE_OFFSET, TRIFA_VALUE_COUNT, value); } @@ -750,7 +750,7 @@ struct TraceRestrictTypePropertySet { }; void SetTraceRestrictValueDefault(TraceRestrictItem &item, TraceRestrictValueType value_type); -void SetTraceRestrictTypeAndNormalise(TraceRestrictItem &item, TraceRestrictItemType type, uint8 aux_data = 0); +void SetTraceRestrictTypeAndNormalise(TraceRestrictItem &item, TraceRestrictItemType type, uint8_t aux_data = 0); /** * Get TraceRestrictTypePropertySet for a given instruction, only looks at value field @@ -1065,7 +1065,7 @@ enum TraceRestrictDoCommandType { TRDCT_PROG_RESET, ///< reset program state of signal }; -void TraceRestrictDoCommandP(TileIndex tile, Track track, TraceRestrictDoCommandType type, uint32 offset, uint32 value, StringID error_msg); +void TraceRestrictDoCommandP(TileIndex tile, Track track, TraceRestrictDoCommandType type, uint32_t offset, uint32_t value, StringID error_msg); void TraceRestrictProgMgmtWithSourceDoCommandP(TileIndex tile, Track track, TraceRestrictDoCommandType type, TileIndex source_tile, Track source_track, StringID error_msg); @@ -1078,20 +1078,20 @@ inline void TraceRestrictProgMgmtDoCommandP(TileIndex tile, Track track, TraceRe TraceRestrictProgMgmtWithSourceDoCommandP(tile, track, type, static_cast(0), static_cast(0), error_msg); } -CommandCost CmdProgramSignalTraceRestrict(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text); -CommandCost CmdProgramSignalTraceRestrictProgMgmt(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text); +CommandCost CmdProgramSignalTraceRestrict(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text); +CommandCost CmdProgramSignalTraceRestrictProgMgmt(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text); -CommandCost TraceRestrictProgramRemoveItemAt(std::vector &items, uint32 offset, bool shallow_mode); -CommandCost TraceRestrictProgramMoveItemAt(std::vector &items, uint32 &offset, bool up, bool shallow_mode); -CommandCost TraceRestrictProgramDuplicateItemAt(std::vector &items, uint32 offset); -bool TraceRestrictProgramDuplicateItemAtDryRun(const std::vector &items, uint32 offset); +CommandCost TraceRestrictProgramRemoveItemAt(std::vector &items, uint32_t offset, bool shallow_mode); +CommandCost TraceRestrictProgramMoveItemAt(std::vector &items, uint32_t &offset, bool up, bool shallow_mode); +CommandCost TraceRestrictProgramDuplicateItemAt(std::vector &items, uint32_t offset); +bool TraceRestrictProgramDuplicateItemAtDryRun(const std::vector &items, uint32_t offset); void ShowTraceRestrictProgramWindow(TileIndex tile, Track track); int GetTraceRestrictTimeDateValue(TraceRestrictTimeDateValueField type); int GetTraceRestrictTimeDateValueFromDate(TraceRestrictTimeDateValueField type, DateTicksScaled scaled_date_ticks); -void TraceRestrictRemoveDestinationID(TraceRestrictOrderCondAuxField type, uint16 index); +void TraceRestrictRemoveDestinationID(TraceRestrictOrderCondAuxField type, uint16_t index); void TraceRestrictRemoveGroupID(GroupID index); void TraceRestrictUpdateCompanyID(CompanyID old_company, CompanyID new_company); void TraceRestrictRemoveSlotID(TraceRestrictSlotID index); @@ -1108,7 +1108,7 @@ static const uint MAX_LENGTH_TRACE_RESTRICT_SLOT_NAME_CHARS = 128; ///< The maxi */ struct TraceRestrictSlot : TraceRestrictSlotPool::PoolItem<&_tracerestrictslot_pool> { std::vector occupants; - uint32 max_occupancy = 1; + uint32_t max_occupancy = 1; std::string name; Owner owner; VehicleType vehicle_type; @@ -1159,7 +1159,7 @@ private: * Counter type */ struct TraceRestrictCounter : TraceRestrictCounterPool::PoolItem<&_tracerestrictcounter_pool> { - int32 value = 0; + int32_t value = 0; std::string name; Owner owner; @@ -1170,11 +1170,11 @@ struct TraceRestrictCounter : TraceRestrictCounterPool::PoolItem<&_tracerestrict this->owner = owner; } - void UpdateValue(int32 new_value); + void UpdateValue(int32_t new_value); - static int32 ApplyValue(int32 current, TraceRestrictCounterCondOpField op, int32 value); + static int32_t ApplyValue(int32_t current, TraceRestrictCounterCondOpField op, int32_t value); - void ApplyUpdate(TraceRestrictCounterCondOpField op, int32 value) + void ApplyUpdate(TraceRestrictCounterCondOpField op, int32_t value) { this->UpdateValue(TraceRestrictCounter::ApplyValue(this->value, op, value)); } diff --git a/src/tracerestrict_gui.cpp b/src/tracerestrict_gui.cpp index a7487567b0..d1af054e1e 100644 --- a/src/tracerestrict_gui.cpp +++ b/src/tracerestrict_gui.cpp @@ -174,16 +174,16 @@ static const StringID _program_insert_str[] = { STR_TRACE_RESTRICT_SIGNAL_MODE_CONTROL, INVALID_STRING_ID }; -static const uint32 _program_insert_else_hide_mask = 8; ///< disable bitmask for else -static const uint32 _program_insert_or_if_hide_mask = 4; ///< disable bitmask for orif -static const uint32 _program_insert_else_if_hide_mask = 2; ///< disable bitmask for elif -static const uint32 _program_wait_pbs_hide_mask = 0x200; ///< disable bitmask for wait at PBS -static const uint32 _program_reverse_hide_mask = 0x400; ///< disable bitmask for reverse -static const uint32 _program_speed_res_hide_mask = 0x800; ///< disable bitmask for speed restriction -static const uint32 _program_counter_hide_mask = 0x2000; ///< disable bitmask for counter -static const uint32 _program_penalty_adj_hide_mask = 0x4000; ///< disable bitmask for penalty adjust -static const uint32 _program_speed_adapt_hide_mask = 0x8000; ///< disable bitmask for speed adaptation -static const uint32 _program_signal_mode_hide_mask = 0x10000; ///< disable bitmask for signal mode control +static const uint32_t _program_insert_else_hide_mask = 8; ///< disable bitmask for else +static const uint32_t _program_insert_or_if_hide_mask = 4; ///< disable bitmask for orif +static const uint32_t _program_insert_else_if_hide_mask = 2; ///< disable bitmask for elif +static const uint32_t _program_wait_pbs_hide_mask = 0x200; ///< disable bitmask for wait at PBS +static const uint32_t _program_reverse_hide_mask = 0x400; ///< disable bitmask for reverse +static const uint32_t _program_speed_res_hide_mask = 0x800; ///< disable bitmask for speed restriction +static const uint32_t _program_counter_hide_mask = 0x2000; ///< disable bitmask for counter +static const uint32_t _program_penalty_adj_hide_mask = 0x4000; ///< disable bitmask for penalty adjust +static const uint32_t _program_speed_adapt_hide_mask = 0x8000; ///< disable bitmask for speed adaptation +static const uint32_t _program_signal_mode_hide_mask = 0x10000; ///< disable bitmask for signal mode control static const uint _program_insert_val[] = { TRIT_COND_UNDEFINED, // if block TRIT_COND_UNDEFINED | (TRCF_ELSE << 16), // elif block @@ -532,7 +532,7 @@ static TraceRestrictItemType ItemTypeFromGuiType(TraceRestrictGuiItemType type) return static_cast(type & 0xFFFF); } -enum TraceRestrictDropDownListItemFlags : uint8 { +enum TraceRestrictDropDownListItemFlags : uint8_t { TRDDLIF_NONE = 0, TRDDLIF_ADVANCED = 1 << 0, ///< requires _settings_client.gui.show_adv_tracerestrict_features TRDDLIF_REALISTIC_BRAKING = 1 << 1, ///< requires realistic braking @@ -999,7 +999,7 @@ static uint ConvertIntegerValue(TraceRestrictValueType type, uint in, bool to_di case TRVT_FORCE: return to_display - ? ConvertForceToDisplayForce(static_cast(in) * 1000) + ? ConvertForceToDisplayForce(static_cast(in) * 1000) : static_cast(ConvertDisplayForceToForce(in) / 1000); break; @@ -1019,7 +1019,7 @@ static uint ConvertIntegerValue(TraceRestrictValueType type, uint in, bool to_di /** * Convert integer values to decimal display units */ -static void ConvertValueToDecimal(TraceRestrictValueType type, uint in, int64 &value, int64 &decimal) +static void ConvertValueToDecimal(TraceRestrictValueType type, uint in, int64_t &value, int64_t &decimal) { switch (type) { case TRVT_POWER_WEIGHT_RATIO: @@ -1027,7 +1027,7 @@ static void ConvertValueToDecimal(TraceRestrictValueType type, uint in, int64 &v break; case TRVT_FORCE_WEIGHT_RATIO: - ConvertForceWeightRatioToDisplay(static_cast(in) * 1000, value, decimal); + ConvertForceWeightRatioToDisplay(static_cast(in) * 1000, value, decimal); break; case TRVT_SPEED: @@ -1075,8 +1075,8 @@ enum CondFlagsDropDownType { CFDDT_ORIF = TRCF_OR, ///< This is an or-if block }; -static const uint32 _condflags_dropdown_else_hide_mask = 1; ///< disable bitmask for CFDDT_ELSE -static const uint32 _condflags_dropdown_else_if_hide_mask = 6; ///< disable bitmask for CFDDT_ELIF and CFDDT_ORIF +static const uint32_t _condflags_dropdown_else_hide_mask = 1; ///< disable bitmask for CFDDT_ELSE +static const uint32_t _condflags_dropdown_else_if_hide_mask = 6; ///< disable bitmask for CFDDT_ELIF and CFDDT_ORIF static const StringID _condflags_dropdown_str[] = { STR_TRACE_RESTRICT_CONDITIONAL_ELSE, @@ -1119,7 +1119,7 @@ static uint GetPathfinderPenaltyDropdownIndex(TraceRestrictItem item) return TRPPPI_END; case TRPPAF_PRESET: { - uint16 index = GetTraceRestrictValue(item); + uint16_t index = GetTraceRestrictValue(item); assert(index < TRPPPI_END); return index; } @@ -1417,7 +1417,7 @@ static void DrawInstructionString(const TraceRestrictProgram *prog, TraceRestric case TRVT_SLOT_INDEX_INT: { assert(prog != nullptr); assert(GetTraceRestrictType(item) == TRIT_COND_SLOT_OCCUPANCY); - uint32 value = *(TraceRestrictProgram::InstructionAt(prog->items, index - 1) + 1); + uint32_t value = *(TraceRestrictProgram::InstructionAt(prog->items, index - 1) + 1); SetDParam(0, _program_cond_type[GetTraceRestrictCondFlags(item)]); SetDParam(1, GetTraceRestrictAuxField(item) ? STR_TRACE_RESTRICT_VARIABLE_SLOT_OCCUPANCY_REMAINING_SHORT : STR_TRACE_RESTRICT_VARIABLE_SLOT_OCCUPANCY_SHORT); if (GetTraceRestrictValue(item) == INVALID_TRACE_RESTRICT_SLOT_ID) { @@ -1446,7 +1446,7 @@ static void DrawInstructionString(const TraceRestrictProgram *prog, TraceRestric case TRVT_COUNTER_INDEX_INT: { assert(prog != nullptr); assert(GetTraceRestrictType(item) == TRIT_COND_COUNTER_VALUE); - uint32 value = *(TraceRestrictProgram::InstructionAt(prog->items, index - 1) + 1); + uint32_t value = *(TraceRestrictProgram::InstructionAt(prog->items, index - 1) + 1); SetDParam(0, _program_cond_type[GetTraceRestrictCondFlags(item)]); if (GetTraceRestrictValue(item) == INVALID_TRACE_RESTRICT_COUNTER_ID) { instruction_string = STR_TRACE_RESTRICT_CONDITIONAL_COUNTER_STR; @@ -1466,7 +1466,7 @@ static void DrawInstructionString(const TraceRestrictProgram *prog, TraceRestric case TRVT_TIME_DATE_INT: { assert(prog != nullptr); assert(GetTraceRestrictType(item) == TRIT_COND_TIME_DATE_VALUE); - uint32 value = *(TraceRestrictProgram::InstructionAt(prog->items, index - 1) + 1); + uint32_t value = *(TraceRestrictProgram::InstructionAt(prog->items, index - 1) + 1); SetDParam(0, _program_cond_type[GetTraceRestrictCondFlags(item)]); instruction_string = GetTraceRestrictValue(item) == TRTDVF_HOUR_MINUTE ? STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_TIME_HHMM : STR_TRACE_RESTRICT_CONDITIONAL_COMPARE_INTEGER; SetDParam(1, STR_TRACE_RESTRICT_TIME_MINUTE_ITEM + GetTraceRestrictValue(item)); @@ -1528,7 +1528,7 @@ static void DrawInstructionString(const TraceRestrictProgram *prog, TraceRestric case TRPPAF_PRESET: { instruction_string = STR_TRACE_RESTRICT_PF_PENALTY_ITEM_PRESET; - uint16 idx = GetTraceRestrictValue(item); + uint16_t idx = GetTraceRestrictValue(item); assert(idx < TRPPPI_END); SetDParam(0, _pf_penalty_dropdown_str[idx]); break; @@ -1676,7 +1676,7 @@ static void DrawInstructionString(const TraceRestrictProgram *prog, TraceRestric break; case TRIT_COUNTER: { - uint32 value = *(TraceRestrictProgram::InstructionAt(prog->items, index - 1) + 1); + uint32_t value = *(TraceRestrictProgram::InstructionAt(prog->items, index - 1) + 1); switch (static_cast(GetTraceRestrictCondOp(item))) { case TRCCOF_INCREASE: instruction_string = STR_TRACE_RESTRICT_COUNTER_INCREASE_ITEM; @@ -1869,8 +1869,8 @@ public: return; } - uint32 disabled = _program_insert_or_if_hide_mask; - uint32 hidden = 0; + uint32_t disabled = _program_insert_or_if_hide_mask; + uint32_t hidden = 0; TraceRestrictItem item = this->GetSelected(); if (GetTraceRestrictType(item) == TRIT_COND_ENDIF || (IsTraceRestrictConditional(item) && GetTraceRestrictCondFlags(item) != 0)) { @@ -1924,11 +1924,11 @@ public: return; } - uint32 p2 = 0; + uint32_t p2 = 0; if (widget == TR_WIDGET_UP_BTN) p2 |= 1; if (_ctrl_pressed) p2 |= 2; - uint32 offset = this->selected_instruction - 1; + uint32_t offset = this->selected_instruction - 1; this->IsUpDownBtnUsable(widget == TR_WIDGET_UP_BTN, true); @@ -1943,7 +1943,7 @@ public: return; } - uint32 offset = this->selected_instruction - 1; + uint32_t offset = this->selected_instruction - 1; this->expecting_inserted_item = item; TraceRestrictDoCommandP(tile, track, TRDCT_DUPLICATE_ITEM, offset, 0, STR_TRACE_RESTRICT_ERROR_CAN_T_MOVE_ITEM); @@ -1966,7 +1966,7 @@ public: return; } - uint32 disabled = 0; + uint32_t disabled = 0; if (!ElseInsertionDryRun(true)) disabled |= _condflags_dropdown_else_hide_mask; if (!ElseIfInsertionDryRun(true)) disabled |= _condflags_dropdown_else_if_hide_mask; @@ -2029,7 +2029,7 @@ public: TraceRestrictItem item = this->GetSelected(); TraceRestrictValueType type = GetTraceRestrictTypeProperties(item).value_type; if (IsDecimalValueType(type)) { - int64 value, decimal; + int64_t value, decimal; ConvertValueToDecimal(type, GetTraceRestrictValue(item), value, decimal); SetDParam(0, value); SetDParam(1, decimal); @@ -2261,7 +2261,7 @@ public: str_replace_wchar(tmp_buffer, lastof(tmp_buffer), GetDecimalSeparatorChar(), '.'); value = ConvertDecimalToValue(type, atof(tmp_buffer)); if (value >= (1 << TRIFA_VALUE_COUNT)) { - int64 value, decimal; + int64_t value, decimal; ConvertValueToDecimal(type, (1 << TRIFA_VALUE_COUNT) - 1, value, decimal); SetDParam(0, value); SetDParam(1, decimal); @@ -2358,7 +2358,7 @@ public: case TR_WIDGET_VALUE_DROPDOWN: { if (GetTraceRestrictTypeProperties(item).value_type == TRVT_PF_PENALTY) { if (value == TRPPPI_END) { - uint16 penalty_value; + uint16_t penalty_value; if (GetTraceRestrictAuxField(item) == TRPPAF_PRESET) { penalty_value = _tracerestrict_pathfinder_penalty_preset_values[GetTraceRestrictValue(item)]; } else { @@ -2682,7 +2682,7 @@ public: TraceRestrictItem item = this->GetSelected(); TraceRestrictValueType type = GetTraceRestrictTypeProperties(item).value_type; if (IsDecimalValueType(type)) { - int64 value, decimal; + int64_t value, decimal; ConvertValueToDecimal(type, GetTraceRestrictValue(item), value, decimal); SetDParam(0, value); SetDParam(1, decimal); @@ -2898,7 +2898,7 @@ private: if (GetTraceRestrictType(item) == TRIT_NULL) return false; std::vector items = prog->items; // copy - uint32 offset = this->selected_instruction - 1; + uint32_t offset = this->selected_instruction - 1; if (TraceRestrictProgramMoveItemAt(items, offset, up, _ctrl_pressed).Succeeded()) { TraceRestrictProgramActionsUsedFlags actions_used_flags; if (TraceRestrictProgram::Validate(items, actions_used_flags).Succeeded()) { @@ -2917,7 +2917,7 @@ private: TraceRestrictItem item = this->GetSelected(); if (GetTraceRestrictType(item) == TRIT_NULL) return false; - uint32 offset = this->selected_instruction - 1; + uint32_t offset = this->selected_instruction - 1; if (TraceRestrictProgramDuplicateItemAtDryRun(prog->items, offset)) { return true; } @@ -3416,7 +3416,7 @@ private: * This asserts if @p value is not in @p list_set, and @p missing_ok is false */ void ShowDropDownListWithValue(const TraceRestrictDropDownListSet *list_set, uint value, bool missing_ok, - int button, uint32 disabled_mask, uint32 hidden_mask) + int button, uint32_t disabled_mask, uint32_t hidden_mask) { this->drop_down_list_mapping[button] = list_set; int selected = GetDropDownListIndexByValue(list_set, value, missing_ok); diff --git a/src/track_type.h b/src/track_type.h index 3b5d395c90..974e95576f 100644 --- a/src/track_type.h +++ b/src/track_type.h @@ -100,7 +100,7 @@ template <> struct EnumPropsT : MakeEnumPropsT { std::unique_ptr lookahead; - uint32 flags; + uint32_t flags; - uint16 crash_anim_pos; ///< Crash animation counter, also used for realistic braking train brake overheating + uint16_t crash_anim_pos; ///< Crash animation counter, also used for realistic braking train brake overheating TrackBits track; TrainForceProceeding force_proceed; @@ -149,12 +149,12 @@ struct Train FINAL : public GroundVehicle { 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; - uint16 reverse_distance; - uint16 tunnel_bridge_signal_num; - uint16 speed_restriction; - uint16 signal_speed_restriction; + uint16_t reverse_distance; + uint16_t tunnel_bridge_signal_num; + uint16_t speed_restriction; + uint16_t signal_speed_restriction; /** We don't want GCC to zero our struct! It already is zeroed and has an index! */ Train() : GroundVehicleBase() {} @@ -217,12 +217,12 @@ public: int GetCurrentMaxSpeed() const override; - uint8 GetZPosCacheUpdateInterval() const + uint8_t GetZPosCacheUpdateInterval() const { - return Clamp(std::min(this->gcache.cached_total_length / 4, this->tcache.cached_centre_mass / 2), 2, 32); + return Clamp(std::min(this->gcache.cached_total_length / 4, this->tcache.cached_centre_mass / 2), 2, 32); } - uint32 CalculateOverallZPos() const; + uint32_t CalculateOverallZPos() const; bool UsingRealisticBraking() const { return this->tcache.cached_tflags & TCF_RL_BRAKING; } @@ -286,7 +286,7 @@ public: return const_cast(const_cast(this)->GetStationLoadingVehicle()); } - uint16 GetCargoWeight(uint cargo_amount) const + uint16_t GetCargoWeight(uint cargo_amount) const { if (cargo_amount > 0) { CargoSpec::Get(this->cargo_type)->WeightOfNUnitsInTrain(cargo_amount); @@ -300,9 +300,9 @@ public: * Allows to know the weight value that this vehicle will use (excluding cargo). * @return Weight value from the engine in tonnes. */ - uint16 GetWeightWithoutCargo() const + uint16_t GetWeightWithoutCargo() const { - uint16 weight = 0; + uint16_t weight = 0; /* Vehicle weight is not added for articulated parts. */ if (!this->IsArticulatedPart()) { @@ -321,7 +321,7 @@ public: * Allows to know the weight value that this vehicle will use (cargo only). * @return Weight value from the engine in tonnes. */ - uint16 GetCargoWeight() const + uint16_t GetCargoWeight() const { return this->GetCargoWeight(this->cargo.StoredCount()); } @@ -342,14 +342,14 @@ protected: // These functions should not be called outside acceleration code. * @param v The front engine of the vehicle. * @return The speed the train is limited to. */ - inline uint16 GetBreakdownSpeed() const + inline uint16_t GetBreakdownSpeed() const { assert(this->IsFrontEngine()); - uint16 speed = UINT16_MAX; + uint16_t speed = UINT16_MAX; for (const Train *w = this; w != nullptr; w = w->Next()) { if (w->breakdown_ctr == 1 && w->breakdown_type == BREAKDOWN_LOW_SPEED) { - speed = std::min(speed, w->breakdown_severity); + speed = std::min(speed, w->breakdown_severity); } } return speed; @@ -359,11 +359,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() && (this->IsVirtual() || HasPowerOnRail(this->railtype, GetRailTypeByTrackBit(this->tile, this->track)))) { - 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; @@ -376,7 +376,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) && (head->IsVirtual() || HasPowerOnRail(head->railtype, GetRailTypeByTrackBit(this->tile, this->track)))) { @@ -390,7 +390,7 @@ 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 { return this->GetWeightWithoutCargo() + this->GetCargoWeight(); } @@ -399,7 +399,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. @@ -442,7 +442,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; } @@ -451,7 +451,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 @@ -463,7 +463,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; } @@ -472,7 +472,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(GetRailTypeByTrackBit(this->tile, this->track))->max_speed; } @@ -516,10 +516,10 @@ struct TrainDecelerationStats { TrainDecelerationStats(const Train *t, int z_pos); }; -CommandCost CmdMoveRailVehicle(TileIndex, DoCommandFlag , uint32, uint32, const char *); -CommandCost CmdMoveVirtualRailVehicle(TileIndex, DoCommandFlag, uint32, uint32, const char*); +CommandCost CmdMoveRailVehicle(TileIndex, DoCommandFlag , uint32_t, uint32_t, const char *); +CommandCost CmdMoveVirtualRailVehicle(TileIndex, DoCommandFlag, uint32_t, uint32_t, const char*); -Train* BuildVirtualRailVehicle(EngineID, StringID &error, uint32 user, bool no_consist_change); +Train* BuildVirtualRailVehicle(EngineID, StringID &error, uint32_t user, bool no_consist_change); int GetTileMarginInFrontOfTrain(const Train *v, int x_pos, int y_pos); @@ -530,7 +530,7 @@ inline int GetTileMarginInFrontOfTrain(const Train *v) int GetTrainStopLocation(StationID station_id, TileIndex tile, Train *v, bool update_train_state, int *station_ahead, int *station_length); -int GetTrainRealisticAccelerationAtSpeed(const int speed, const int mass, const uint32 cached_power, const uint32 max_te, const uint32 air_drag, const RailType railtype); +int GetTrainRealisticAccelerationAtSpeed(const int speed, const int mass, const uint32_t cached_power, const uint32_t max_te, const uint32_t air_drag, const RailType railtype); int GetTrainEstimatedMaxAchievableSpeed(const Train *train, int mass, const int speed_cap); #endif /* TRAIN_H */ diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 4b70599b9e..d54d5621cc 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -67,7 +67,7 @@ enum ChooseTrainTrackLookAheadStateFlags { struct ChooseTrainTrackLookAheadState { uint order_items_start = 0; ///< Order items start for VehicleOrderSaver - uint16 flags = 0; ///< Flags + uint16_t flags = 0; ///< Flags DestinationID reverse_dest = 0; ///< Reverse station ID when CTTLASF_REVERSE_FOUND is set }; @@ -103,13 +103,13 @@ static bool CheckTrainStayInWormHolePathReserve(Train *t, TileIndex tile); * at the current position of the train is going to be invalid */ static DateTicksScaled GetSpeedRestrictionTimeout(const Train *t) { - const int64 velocity = std::max(25, t->cur_speed); - const int64 look_ahead_distance = Clamp(t->cur_speed / 8, 4, 16); // In tiles, varying between 4 and 16 depending on current speed + const int64_t velocity = std::max(25, t->cur_speed); + const int64_t look_ahead_distance = Clamp(t->cur_speed / 8, 4, 16); // In tiles, varying between 4 and 16 depending on current speed // This assumes travel along the X or Y map axis, not diagonally. See GetAdvanceDistance, GetAdvanceSpeed. - const int64 ticks_per_tile = (192 * 16 * 4 / 3) / velocity; + const int64_t ticks_per_tile = (192 * 16 * 4 / 3) / velocity; - const int64 ticks = ticks_per_tile * look_ahead_distance; + const int64_t ticks = ticks_per_tile * look_ahead_distance; return _scaled_date_ticks + ticks; } @@ -148,7 +148,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); } @@ -223,21 +223,21 @@ void CheckBreakdownFlags(Train *v) } } -uint16 GetTrainVehicleMaxSpeed(const Train *u, const RailVehicleInfo *rvi_u, const Train *front) +uint16_t GetTrainVehicleMaxSpeed(const Train *u, const RailVehicleInfo *rvi_u, const Train *front) { - const uint16 base_speed = GetVehicleProperty(u, PROP_TRAIN_SPEED, rvi_u->max_speed); - uint16 speed = base_speed; + const uint16_t base_speed = GetVehicleProperty(u, PROP_TRAIN_SPEED, rvi_u->max_speed); + uint16_t speed = base_speed; if (HasBit(u->flags, VRF_NEED_REPAIR) && front->IsFrontEngine()) { for (uint i = 0; i < u->critical_breakdown_count; i++) { - speed = std::min(speed - (speed / (front->tcache.cached_num_engines + 2)) + 1, speed); + speed = std::min(speed - (speed / (front->tcache.cached_num_engines + 2)) + 1, speed); } } /* clamp speed to be no less than lower of 5mph and 1/8 of base speed */ - speed = std::max(speed, std::min(5, (base_speed + 7) >> 3)); + speed = std::max(speed, std::min(5, (base_speed + 7) >> 3)); if (HasBit(u->flags, VRF_HAS_HIT_RV) && front->IsFrontEngine()) { - speed = std::min(speed, 30); + speed = std::min(speed, 30); } return speed; } @@ -250,7 +250,7 @@ uint16 GetTrainVehicleMaxSpeed(const Train *u, const RailVehicleInfo *rvi_u, con */ void Train::ConsistChanged(ConsistChangeFlags allowed_changes) { - uint16 max_speed = UINT16_MAX; + uint16_t max_speed = UINT16_MAX; dbg_assert(this->IsFrontEngine() || this->IsFreeWagon()); @@ -340,12 +340,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 = GetTrainVehicleMaxSpeed(u, rvi_u, this); + uint16_t speed = GetTrainVehicleMaxSpeed(u, rvi_u, this); 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); @@ -358,7 +358,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); @@ -812,21 +812,21 @@ TrainDecelerationStats::TrainDecelerationStats(const Train *t, int z_pos) this->t = t; } -static int64 GetRealisticBrakingDistanceForSpeed(const TrainDecelerationStats &stats, int start_speed, int end_speed, int z_delta) +static int64_t GetRealisticBrakingDistanceForSpeed(const TrainDecelerationStats &stats, int start_speed, int end_speed, int z_delta) { /* v^2 = u^2 + 2as */ - auto sqr = [](int64 speed) -> int64 { return speed * speed; }; + auto sqr = [](int64_t speed) -> int64_t { return speed * speed; }; - int64 ke_delta = sqr(start_speed) - sqr(end_speed); + int64_t ke_delta = sqr(start_speed) - sqr(end_speed); - int64 dist = ke_delta / stats.deceleration_x2; + int64_t dist = ke_delta / stats.deceleration_x2; if (z_delta < 0 && _settings_game.vehicle.train_acceleration_model != AM_ORIGINAL) { /* descending */ /* (5/18) is due to KE being in km/h derived units instead of m/s */ - int64 slope_dist = (ke_delta - (z_delta * ((400 * 5) / 18) * _settings_game.vehicle.train_slope_steepness)) / stats.uncapped_deceleration_x2; - dist = std::max(dist, slope_dist); + int64_t slope_dist = (ke_delta - (z_delta * ((400 * 5) / 18) * _settings_game.vehicle.train_slope_steepness)) / stats.uncapped_deceleration_x2; + dist = std::max(dist, slope_dist); } return dist; } @@ -835,25 +835,25 @@ static int GetRealisticBrakingSpeedForDistance(const TrainDecelerationStats &sta { /* v^2 = u^2 + 2as */ - auto sqr = [](int64 speed) -> int64 { return speed * speed; }; + auto sqr = [](int64_t speed) -> int64_t { return speed * speed; }; - int64 target_ke = sqr(end_speed); - int64 speed_sqr = target_ke + ((int64)stats.deceleration_x2 * (int64)distance); + int64_t target_ke = sqr(end_speed); + int64_t speed_sqr = target_ke + ((int64_t)stats.deceleration_x2 * (int64_t)distance); if (speed_sqr <= REALISTIC_BRAKING_MIN_SPEED * REALISTIC_BRAKING_MIN_SPEED) return REALISTIC_BRAKING_MIN_SPEED; if (z_delta < 0 && _settings_game.vehicle.train_acceleration_model != AM_ORIGINAL) { /* descending */ /* (5/18) is due to KE being in km/h derived units instead of m/s */ - int64 sloped_ke = target_ke + (z_delta * ((400 * 5) / 18) * _settings_game.vehicle.train_slope_steepness); - int64 slope_speed_sqr = sloped_ke + ((int64)stats.uncapped_deceleration_x2 * (int64)distance); + int64_t sloped_ke = target_ke + (z_delta * ((400 * 5) / 18) * _settings_game.vehicle.train_slope_steepness); + int64_t slope_speed_sqr = sloped_ke + ((int64_t)stats.uncapped_deceleration_x2 * (int64_t)distance); if (slope_speed_sqr < speed_sqr && _settings_game.vehicle.train_acceleration_model == AM_REALISTIC && GetRailTypeInfo(stats.t->railtype)->acceleration_type != 2) { /* calculate speed at which braking would be sufficient */ uint weight = stats.t->gcache.cached_weight; - int64 power_w = (stats.t->gcache.cached_power * 746ll) + (stats.t->tcache.cached_braking_length * (int64)RBC_BRAKE_POWER_PER_LENGTH); - int64 min_braking_force = (stats.t->tcache.cached_braking_length * (int64)RBC_BRAKE_FORCE_PER_LENGTH) + stats.t->gcache.cached_axle_resistance + (weight * 16); + int64_t power_w = (stats.t->gcache.cached_power * 746ll) + (stats.t->tcache.cached_braking_length * (int64_t)RBC_BRAKE_POWER_PER_LENGTH); + int64_t min_braking_force = (stats.t->tcache.cached_braking_length * (int64_t)RBC_BRAKE_FORCE_PER_LENGTH) + stats.t->gcache.cached_axle_resistance + (weight * 16); /* F = (7/8) * (F_min + ((power_w * 18) / (5 * v))) * v^2 = sloped_ke + F * s / (4 * m) @@ -868,25 +868,25 @@ static int GetRealisticBrakingSpeedForDistance(const TrainDecelerationStats &sta * let l = k / 3 * v = cbrt(r + sqrt(r^2 - l^3)) + cbrt(r - sqrt(r^2 - l^3)) */ - int64 l = (sloped_ke + ((7 * min_braking_force * (int64)distance) / (8 * weight))) / 3; - int64 r = (7 * 9 * power_w * (int64)distance) / (160 * weight); - int64 sqrt_factor = (r * r) - (l * l * l); + int64_t l = (sloped_ke + ((7 * min_braking_force * (int64_t)distance) / (8 * weight))) / 3; + int64_t r = (7 * 9 * power_w * (int64_t)distance) / (160 * weight); + int64_t sqrt_factor = (r * r) - (l * l * l); if (sqrt_factor >= 0) { - int64 part = IntSqrt64(sqrt_factor); - int32 v_calc = IntCbrt(r + part); + int64_t part = IntSqrt64(sqrt_factor); + int32_t v_calc = IntCbrt(r + part); int cb2 = r - part; if (cb2 > 0) { v_calc += IntCbrt(cb2); } else if (cb2 < 0) { v_calc -= IntCbrt(-cb2); } - int64 v_calc_sq = sqr(v_calc); + int64_t v_calc_sq = sqr(v_calc); if (v_calc_sq < speed_sqr && v_calc_sq > slope_speed_sqr) { return std::max((int)REALISTIC_BRAKING_MIN_SPEED, v_calc); } } } - speed_sqr = std::min(speed_sqr, slope_speed_sqr); + speed_sqr = std::min(speed_sqr, slope_speed_sqr); } if (speed_sqr <= REALISTIC_BRAKING_MIN_SPEED * REALISTIC_BRAKING_MIN_SPEED) return REALISTIC_BRAKING_MIN_SPEED; if (speed_sqr > UINT_MAX) speed_sqr = UINT_MAX; @@ -899,7 +899,7 @@ void LimitSpeedFromLookAhead(int &max_speed, const TrainDecelerationStats &stats if (position <= current_position) { max_speed = std::min(max_speed, std::max(15, end_speed)); } else if (end_speed < max_speed) { - int64 distance = GetRealisticBrakingDistanceForSpeed(stats, max_speed, end_speed, z_delta); + int64_t distance = GetRealisticBrakingDistanceForSpeed(stats, max_speed, end_speed, z_delta); if (distance + current_position > position) { /* Speed is too fast, we would overshoot */ if (z_delta < 0 && (position - current_position) < stats.t->gcache.cached_total_length) { @@ -938,7 +938,7 @@ static void ApplyLookAheadItem(const Train *v, const TrainReservationLookAheadIt current_order_index++; AdvanceOrderIndex(v, current_order_index); order = v->GetOrder(current_order_index); - uint16 order_max_speed = order->GetMaxSpeed(); + uint16_t order_max_speed = order->GetMaxSpeed(); if (order_max_speed < UINT16_MAX) limit_advisory_speed(item.start, order_max_speed, item.z_pos); } break; @@ -985,7 +985,7 @@ static void AdvanceLookAheadPosition(Train *v) if (unlikely(v->lookahead->current_position >= (1 << 30))) { /* Prevent signed overflow by rebasing all position values */ - const int32 old_position = v->lookahead->current_position; + const int32_t old_position = v->lookahead->current_position; v->lookahead->current_position = 0; v->lookahead->reservation_end_position -= old_position; v->lookahead->lookahead_end_position -= old_position; @@ -1142,12 +1142,12 @@ int Train::GetCurrentMaxSpeed() const return std::min(info.strict_max_speed, info.advisory_max_speed); } -uint32 Train::CalculateOverallZPos() const +uint32_t Train::CalculateOverallZPos() const { if (likely(HasBit(this->vcache.cached_veh_flags, VCF_GV_ZERO_SLOPE_RESIST))) { return this->z_pos; } else { - int64 sum = 0; + int64_t sum = 0; for (const Train *u = this; u != nullptr; u = u->Next()) { sum += ((int)u->z_pos * (int)u->tcache.cached_veh_weight); } @@ -1177,7 +1177,7 @@ void Train::UpdateAcceleration() case AM_REALISTIC: { int acceleration_type = this->GetAccelerationType(); bool maglev = (acceleration_type == 2); - int64 power_w = power * 746ll; + int64_t power_w = power * 746ll; /* Increase the effective length used for brake force/power value when using the freight weight multiplier */ uint length = this->gcache.cached_total_length; @@ -1192,7 +1192,7 @@ void Train::UpdateAcceleration() } this->tcache.cached_braking_length = length; - int64 min_braking_force = (int64)length * (int64)RBC_BRAKE_FORCE_PER_LENGTH; + int64_t min_braking_force = (int64_t)length * (int64_t)RBC_BRAKE_FORCE_PER_LENGTH; if (!maglev) { /* From GroundVehicle::GetAcceleration() * force = power * 18 / (speed * 5); @@ -1211,9 +1211,9 @@ void Train::UpdateAcceleration() */ int evaluation_speed = this->vcache.cached_max_speed; int area = 14; - int64 power_b = power_w + ((int64)length * RBC_BRAKE_POWER_PER_LENGTH); + int64_t power_b = power_w + ((int64_t)length * RBC_BRAKE_POWER_PER_LENGTH); if (this->gcache.cached_air_drag > 0) { - uint64 v_3 = 1800 * (uint64)power_b / (area * this->gcache.cached_air_drag); + uint64_t v_3 = 1800 * (uint64_t)power_b / (area * this->gcache.cached_air_drag); evaluation_speed = std::min(evaluation_speed, IntCbrt(v_3)); } if (evaluation_speed > 0) { @@ -1303,7 +1303,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) { dbg_assert(IsValidImageIndex(spritenum)); return ((direction + _engine_sprite_add[spritenum]) & _engine_sprite_and[spritenum]) + _engine_sprite_base[spritenum]; @@ -1317,7 +1317,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); @@ -1340,7 +1340,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); @@ -1882,7 +1882,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; @@ -2023,7 +2023,7 @@ static void NormaliseTrainHead(Train *head) head->unitnumber = GetFreeUnitNumber(VEH_TRAIN); } -CommandCost CmdMoveVirtualRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdMoveVirtualRailVehicle(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Train *src = Train::GetIfValid(GB(p1, 0, 20)); if (src == nullptr || !src->IsVirtual()) return CMD_ERROR; @@ -2046,7 +2046,7 @@ CommandCost CmdMoveVirtualRailVehicle(TileIndex tile, DoCommandFlag flags, uint3 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID s = GB(p1, 0, 20); VehicleID d = GB(p2, 0, 20); @@ -2293,7 +2293,7 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u * @param user the user for the order backup. * @return the cost of this operation or an error */ -CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, uint16 data, uint32 user) +CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *t, uint16_t data, uint32_t user) { /* Sell a chain of vehicles or not? */ bool sell_chain = HasBit(data, 0); @@ -2481,10 +2481,10 @@ static void MarkTrainAsStuck(Train *v, bool waiting_restriction = false) * @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); @@ -2570,7 +2570,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; } @@ -3076,7 +3076,7 @@ void ReverseTrainDirection(Train *v) * Prevent setting the wrong signals by making wait_counter a non-integer multiple of TILE_SIZE. * Use a huge value so that the train will reverse again if there is another vehicle coming the other way. */ - t->wait_counter = static_cast(-((int)TILE_SIZE / 2)); + t->wait_counter = static_cast(-((int)TILE_SIZE / 2)); t->tunnel_bridge_signal_num = 0; } }; @@ -3138,7 +3138,7 @@ void ReverseTrainDirection(Train *v) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdReverseTrainDirection(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdReverseTrainDirection(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Train *v = Train::GetIfValid(p1); if (v == nullptr) return CMD_ERROR; @@ -3214,7 +3214,7 @@ CommandCost CmdReverseTrainDirection(TileIndex tile, DoCommandFlag flags, uint32 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdForceTrainProceed(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdForceTrainProceed(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Train *t = Train::GetIfValid(p1); if (t == nullptr) return CMD_ERROR; @@ -3501,7 +3501,7 @@ static bool CheckTrainStayInDepot(Train *v) static int GetAndClearLastBridgeEntranceSetSignalIndex(TileIndex bridge_entrance) { - uint16 m = _m[bridge_entrance].m2; + uint16_t m = _m[bridge_entrance].m2; if (m & BRIDGE_M2_SIGNAL_STATE_EXT_FLAG) { auto it = _long_bridge_signal_sim_map.find(bridge_entrance); if (it != _long_bridge_signal_sim_map.end()) { @@ -3509,18 +3509,18 @@ static int GetAndClearLastBridgeEntranceSetSignalIndex(TileIndex bridge_entrance uint slot = (uint)lbss.signal_red_bits.size(); while (slot > 0) { slot--; - uint64 &slot_bits = lbss.signal_red_bits[slot]; + uint64_t &slot_bits = lbss.signal_red_bits[slot]; if (slot_bits) { - uint8 i = FindLastBit(slot_bits); + uint8_t i = FindLastBit(slot_bits); ClrBit(slot_bits, i); return 1 + BRIDGE_M2_SIGNAL_STATE_COUNT + (64 * slot) + i; } } } } - uint16 m_masked = GB(m & (~BRIDGE_M2_SIGNAL_STATE_EXT_FLAG), BRIDGE_M2_SIGNAL_STATE_OFFSET, BRIDGE_M2_SIGNAL_STATE_FIELD_SIZE); + uint16_t m_masked = GB(m & (~BRIDGE_M2_SIGNAL_STATE_EXT_FLAG), BRIDGE_M2_SIGNAL_STATE_OFFSET, BRIDGE_M2_SIGNAL_STATE_FIELD_SIZE); if (m_masked) { - uint8 i = FindLastBit(m_masked); + uint8_t i = FindLastBit(m_masked); ClrBit(_m[bridge_entrance].m2, BRIDGE_M2_SIGNAL_STATE_OFFSET + i); return 1 + i; } @@ -3531,8 +3531,8 @@ static int GetAndClearLastBridgeEntranceSetSignalIndex(TileIndex bridge_entrance static void UpdateTunnelBridgeEntranceSignalAspect(TileIndex tile) { Trackdir trackdir = GetTunnelBridgeEntranceTrackdir(tile); - uint8 aspect = GetForwardAspectFollowingTrackAndIncrement(tile, trackdir); - uint8 old_aspect = GetTunnelBridgeEntranceSignalAspect(tile); + uint8_t aspect = GetForwardAspectFollowingTrackAndIncrement(tile, trackdir); + uint8_t old_aspect = GetTunnelBridgeEntranceSignalAspect(tile); if (aspect != old_aspect) { SetTunnelBridgeEntranceSignalAspect(tile, aspect); MarkTunnelBridgeSignalDirty(tile, false); @@ -4168,7 +4168,7 @@ static bool IsReservationLookAheadLongEnough(const Train *v, const ChooseTrainTr if (found_signal) { int delta_z = v->lookahead->reservation_end_z - signal_z; delta_z += (delta_z >> 2); // Slightly overestimate slope changes to compensate for non-uniform descents - int64 distance = GetRealisticBrakingDistanceForSpeed(stats, signal_speed, 0, delta_z); + int64_t distance = GetRealisticBrakingDistanceForSpeed(stats, signal_speed, 0, delta_z); if (signal_position + distance <= v->lookahead->reservation_end_position) return true; } @@ -4180,7 +4180,7 @@ static bool LookaheadWithinCurrentTunnelBridge(const Train *t) return t->lookahead->current_position >= t->lookahead->reservation_end_position - ((int)TILE_SIZE * t->lookahead->tunnel_bridge_reserved_tiles) && !HasBit(t->lookahead->flags, TRLF_TB_EXIT_FREE); } -static bool HasLongReservePbsSignalOnTrackdir(Train* v, TileIndex tile, Trackdir trackdir, bool default_value, uint16 lookahead_state_flags) +static bool HasLongReservePbsSignalOnTrackdir(Train* v, TileIndex tile, Trackdir trackdir, bool default_value, uint16_t lookahead_state_flags) { if (HasPbsSignalOnTrackdir(tile, trackdir)) { if (IsNoEntrySignal(tile, TrackdirToTrack(trackdir))) return false; @@ -4455,7 +4455,7 @@ static Track ChooseTrainTrack(Train *v, TileIndex tile, DiagDirection enterdir, Track next_track = DoTrainPathfind(v, new_tile, dest_enterdir, tracks, path_found, do_track_reservation, &res_dest, &final_dest); DEBUG_UPDATESTATECHECKSUM("ChooseTrainTrack: v: %u, path_found: %d, next_track: %d", v->index, path_found, next_track); - UpdateStateChecksum((((uint64) v->index) << 32) | (path_found << 16) | next_track); + UpdateStateChecksum((((uint64_t) v->index) << 32) | (path_found << 16) | next_track); if (new_tile == tile) best_track = next_track; v->HandlePathfindingResult(path_found); } @@ -4881,7 +4881,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; } } @@ -5106,8 +5106,8 @@ static Vehicle *CheckTrainAtSignal(Vehicle *v, void *data) } struct FindSpaceBetweenTrainsChecker { - int32 pos; - uint16 distance; + int32_t pos; + uint16_t distance; DiagDirection direction; }; @@ -5123,7 +5123,7 @@ static Vehicle *FindSpaceBetweenTrainsEnum(Vehicle *v, void *data) } const FindSpaceBetweenTrainsChecker *checker = (FindSpaceBetweenTrainsChecker*) data; - int32 a, b = 0; + int32_t a, b = 0; switch (checker->direction) { default: NOT_REACHED(); @@ -5137,7 +5137,7 @@ static Vehicle *FindSpaceBetweenTrainsEnum(Vehicle *v, void *data) return nullptr; } -static bool IsTooCloseBehindTrain(Train *t, TileIndex tile, uint16 distance, bool check_endtile) +static bool IsTooCloseBehindTrain(Train *t, TileIndex tile, uint16_t distance, bool check_endtile) { if (t->force_proceed != 0) return false; @@ -5436,12 +5436,12 @@ void HandleTraceRestrictSpeedRestrictionAction(const TraceRestrictProgramResult if (out.flags & TRPRF_SPEED_RESTRICTION_SET) { SetBit(v->flags, VRF_PENDING_SPEED_RESTRICTION); for (auto it = _pending_speed_restriction_change_map.lower_bound(v->index); it != _pending_speed_restriction_change_map.end() && it->first == v->index; ++it) { - if ((uint16) (out.speed_restriction + 0xFFFF) < (uint16) (it->second.new_speed + 0xFFFF)) it->second.new_speed = out.speed_restriction; + if ((uint16_t) (out.speed_restriction + 0xFFFF) < (uint16_t) (it->second.new_speed + 0xFFFF)) it->second.new_speed = out.speed_restriction; } - uint16 flags = 0; + uint16_t flags = 0; if (IsDiagonalTrack(TrackdirToTrack(signal_td))) SetBit(flags, PSRCF_DIAGONAL); - _pending_speed_restriction_change_map.insert({ v->index, { (uint16) (v->gcache.cached_total_length + (HasBit(flags, PSRCF_DIAGONAL) ? 8 : 4)), out.speed_restriction, v->speed_restriction, flags } }); - if ((uint16) (out.speed_restriction + 0xFFFF) < (uint16) (v->speed_restriction + 0xFFFF)) v->speed_restriction = out.speed_restriction; + _pending_speed_restriction_change_map.insert({ v->index, { (uint16_t) (v->gcache.cached_total_length + (HasBit(flags, PSRCF_DIAGONAL) ? 8 : 4)), out.speed_restriction, v->speed_restriction, flags } }); + if ((uint16_t) (out.speed_restriction + 0xFFFF) < (uint16_t) (v->speed_restriction + 0xFFFF)) v->speed_restriction = out.speed_restriction; } if (out.flags & TRPRF_SPEED_ADAPT_EXEMPT && !HasBit(v->flags, VRF_SPEED_ADAPTATION_EXEMPT)) { SetBit(v->flags, VRF_SPEED_ADAPTATION_EXEMPT); @@ -5469,7 +5469,7 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse) bool update_signal_tunbridge_exit = false; Direction old_direction = INVALID_DIR; TrackBits old_trackbits = INVALID_TRACK_BIT; - uint16 old_gv_flags = 0; + uint16_t old_gv_flags = 0; auto notify_direction_changed = [&](Direction old_direction, Direction new_direction) { if (prev == nullptr && _settings_game.vehicle.train_acceleration_model == AM_ORIGINAL) { @@ -5499,7 +5499,7 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse) IsRailBridgeHeadTile(gp.old_tile) && DiagdirBetweenTiles(gp.old_tile, gp.new_tile) == GetTunnelBridgeDirection(gp.old_tile)) { /* left a bridge headtile into a wormhole */ Direction old_direction = v->direction; - uint32 r = VehicleEnterTile(v, gp.old_tile, gp.x, gp.y); // NB: old tile, the bridge head which the train just left + uint32_t r = VehicleEnterTile(v, gp.old_tile, gp.x, gp.y); // NB: old tile, the bridge head which the train just left if (HasBit(r, VETS_CANNOT_ENTER)) { goto invalid_rail; } @@ -5524,7 +5524,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; } @@ -5701,7 +5701,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 = (v->track & TRACK_BIT_WORMHOLE) ? 0 : VehicleEnterTile(v, gp.new_tile, gp.x, gp.y); + uint32_t r = (v->track & TRACK_BIT_WORMHOLE) ? 0 : VehicleEnterTile(v, gp.new_tile, gp.x, gp.y); if (HasBit(r, VETS_CANNOT_ENTER)) { goto invalid_rail; } @@ -6309,7 +6309,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); @@ -6340,7 +6340,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 }; @@ -6386,7 +6386,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; @@ -6752,7 +6752,7 @@ Money Train::GetRunningCost() const bool Train::Tick() { DEBUG_UPDATESTATECHECKSUM("Train::Tick: v: %u, x: %d, y: %d, track: %d", this->index, this->x_pos, this->y_pos, this->track); - UpdateStateChecksum((((uint64) this->x_pos) << 32) | (this->y_pos << 16) | this->track); + UpdateStateChecksum((((uint64_t) this->x_pos) << 32) | (this->y_pos << 16) | this->track); if (this->IsFrontEngine()) { if (!((this->vehstatus & VS_STOPPED) || this->IsWaitingInDepot()) || this->cur_speed > 0) this->running_ticks++; @@ -6950,7 +6950,7 @@ void DeleteVisibleTrain(Train *v) UpdateSignalsInBuffer(); } -Train* CmdBuildVirtualRailWagon(const Engine *e, uint32 user, bool no_consist_change) +Train* CmdBuildVirtualRailWagon(const Engine *e, uint32_t user, bool no_consist_change) { const RailVehicleInfo *rvi = &e->u.rail; @@ -7008,7 +7008,7 @@ Train* CmdBuildVirtualRailWagon(const Engine *e, uint32 user, bool no_consist_ch return v; } -Train* BuildVirtualRailVehicle(EngineID eid, StringID &error, uint32 user, bool no_consist_change) +Train* BuildVirtualRailVehicle(EngineID eid, StringID &error, uint32_t user, bool no_consist_change) { const Engine *e = Engine::GetIfValid(eid); if (e == nullptr || e->type != VEH_TRAIN) { @@ -7100,7 +7100,7 @@ Train* BuildVirtualRailVehicle(EngineID eid, StringID &error, uint32 user, bool * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildVirtualRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildVirtualRailVehicle(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { EngineID eid = GB(p1, 0, 16); @@ -7168,7 +7168,7 @@ static inline CommandCost CmdStartStopVehicle(const Vehicle *v, bool evaluate_ca * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdTemplateReplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdTemplateReplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Train *incoming = Train::GetIfValid(p1); @@ -7211,7 +7211,7 @@ CommandCost CmdTemplateReplaceVehicle(TileIndex tile, DoCommandFlag flags, uint3 const bool refit_to_template = tv->refit_as_template; CargoID store_refit_ct = CT_INVALID; - uint16 store_refit_csubt = 0; + uint16_t store_refit_csubt = 0; // if a train shall keep its old refit, store the refit setting of its first vehicle if (!refit_to_template) { for (Train *getc = incoming; getc != nullptr; getc = getc->GetNextUnit()) { @@ -7235,7 +7235,7 @@ CommandCost CmdTemplateReplaceVehicle(TileIndex tile, DoCommandFlag flags, uint3 TemplateDepotVehicles depot_vehicles; if (tv->IsSetReuseDepotVehicles()) depot_vehicles.Init(tile); - auto refit_unit = [&](const Train *unit, CargoID cid, uint16 csubt) { + auto refit_unit = [&](const Train *unit, CargoID cid, uint16_t csubt) { CommandCost refit_cost = DoCommand(unit->tile, unit->index, cid | csubt << 8 | (1 << 16), flags, GetCmdRefitVeh(unit)); if (refit_cost.Succeeded()) buy.AddCost(refit_cost); }; @@ -7276,7 +7276,7 @@ CommandCost CmdTemplateReplaceVehicle(TileIndex tile, DoCommandFlag flags, uint3 } CargoID refit_cargo = refit_to_template ? cur_tmpl->cargo_type : store_refit_ct; - uint32 refit_cmd = (refit_cargo != CT_INVALID) ? (refit_cargo << 24) : 0; + uint32_t refit_cmd = (refit_cargo != CT_INVALID) ? (refit_cargo << 24) : 0; buy.AddCost(DoCommand(tile, cur_tmpl->engine_type | (1 << 16) | refit_cmd, 0, flags, CMD_BUILD_VEHICLE)); }; for (const TemplateVehicle *cur_tmpl = tv; cur_tmpl != nullptr; cur_tmpl = cur_tmpl->GetNextUnit()) { @@ -7496,24 +7496,24 @@ void TrainBrakesOverheatedBreakdown(Vehicle *v) t->breakdown_severity = 0; } -int GetTrainRealisticAccelerationAtSpeed(const int speed, const int mass, const uint32 cached_power, const uint32 max_te, const uint32 air_drag, const RailType railtype) +int GetTrainRealisticAccelerationAtSpeed(const int speed, const int mass, const uint32_t cached_power, const uint32_t max_te, const uint32_t air_drag, const RailType railtype) { - const int64 power = cached_power * 746ll; - int64 resistance = 0; + const int64_t power = cached_power * 746ll; + int64_t resistance = 0; const bool maglev = (GetRailTypeInfo(railtype)->acceleration_type == 2); if (!maglev) { /* Static resistance plus rolling friction. */ resistance = 10 * mass; - resistance += (int64)mass * (int64)(15 * (512 + speed) / 512); + resistance += (int64_t)mass * (int64_t)(15 * (512 + speed) / 512); } const int area = 14; resistance += (area * air_drag * speed * speed) / 1000; - int64 force; + int64_t force; if (speed > 0) { if (!maglev) { @@ -7527,14 +7527,14 @@ int GetTrainRealisticAccelerationAtSpeed(const int speed, const int mass, const force = power / 25; } } else { - force = (!maglev) ? std::min(max_te, power) : power; + force = (!maglev) ? std::min(max_te, power) : power; force = std::max(force, (mass * 8) + resistance); } /* Easy way out when there is no acceleration. */ if (force == resistance) return 0; - int acceleration = ClampTo((force - resistance) / (mass * 4)); + int acceleration = ClampTo((force - resistance) / (mass * 4)); acceleration = force < resistance ? std::min(-1, acceleration) : std::max(1, acceleration); return acceleration; @@ -7556,7 +7556,7 @@ int GetTrainEstimatedMaxAchievableSpeed(const Train *train, int mass, const int return max_speed; } -void SetSignalTrainAdaptationSpeed(const Train *v, TileIndex tile, uint16 track) +void SetSignalTrainAdaptationSpeed(const Train *v, TileIndex tile, uint16_t track) { SignalSpeedKey speed_key = {}; speed_key.signal_tile = tile; @@ -7570,7 +7570,7 @@ void SetSignalTrainAdaptationSpeed(const Train *v, TileIndex tile, uint16 track) _signal_speeds[speed_key] = speed_value; } -static uint16 GetTrainAdaptationSpeed(TileIndex tile, uint16 track, Trackdir last_passing_train_dir) +static uint16_t GetTrainAdaptationSpeed(TileIndex tile, uint16_t track, Trackdir last_passing_train_dir) { SignalSpeedKey speed_key = { speed_key.signal_tile = tile, @@ -7584,21 +7584,21 @@ static uint16 GetTrainAdaptationSpeed(TileIndex tile, uint16 track, Trackdir las _signal_speeds.erase(found_speed_restriction); return 0; } else { - return std::max(25, found_speed_restriction->second.train_speed); + return std::max(25, found_speed_restriction->second.train_speed); } } else { return 0; } } -void ApplySignalTrainAdaptationSpeed(Train *v, TileIndex tile, uint16 track) +void ApplySignalTrainAdaptationSpeed(Train *v, TileIndex tile, uint16_t track) { - uint16 speed = GetTrainAdaptationSpeed(tile, track, v->GetVehicleTrackdir()); + uint16_t speed = GetTrainAdaptationSpeed(tile, track, v->GetVehicleTrackdir()); if (speed > 0 && v->lookahead != nullptr) { for (const TrainReservationLookAheadItem &item : v->lookahead->items) { if (item.type == TRLIT_SPEED_ADAPTATION && item.end + 1 < v->lookahead->reservation_end_position) { - uint16 signal_speed = GetLowestSpeedTrainAdaptationSpeedAtSignal(item.data_id, item.data_aux); + uint16_t signal_speed = GetLowestSpeedTrainAdaptationSpeedAtSignal(item.data_id, item.data_aux); if (signal_speed == 0) { /* unrestricted signal ahead, disregard speed adaptation at earlier signal */ @@ -7616,16 +7616,16 @@ void ApplySignalTrainAdaptationSpeed(Train *v, TileIndex tile, uint16 track) v->signal_speed_restriction = speed; } -uint16 GetLowestSpeedTrainAdaptationSpeedAtSignal(TileIndex tile, uint16 track) +uint16_t GetLowestSpeedTrainAdaptationSpeedAtSignal(TileIndex tile, uint16_t track) { - uint16 lowest_speed = 0; + uint16_t lowest_speed = 0; SignalSpeedKey speed_key = { tile, track, (Trackdir)0 }; for (auto iter = _signal_speeds.lower_bound(speed_key); iter != _signal_speeds.end() && iter->first.signal_tile == tile && iter->first.signal_track == track;) { if (iter->second.IsOutOfDate()) { iter = _signal_speeds.erase(iter); } else { - uint16 adapt_speed = std::max(25, iter->second.train_speed); + uint16_t adapt_speed = std::max(25, iter->second.train_speed); if (lowest_speed == 0 || adapt_speed < lowest_speed) lowest_speed = adapt_speed; ++iter; } @@ -7634,9 +7634,9 @@ uint16 GetLowestSpeedTrainAdaptationSpeedAtSignal(TileIndex tile, uint16 track) return lowest_speed; } -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_gui.cpp b/src/train_gui.cpp index 4691f786d4..96deaebd75 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -20,7 +20,7 @@ #include "safeguards.h" -uint16 GetTrainVehicleMaxSpeed(const Train *u, const RailVehicleInfo *rvi_u, const Train *front); +uint16_t GetTrainVehicleMaxSpeed(const Train *u, const RailVehicleInfo *rvi_u, const Train *front); /** * Callback for building wagons. @@ -30,7 +30,7 @@ uint16 GetTrainVehicleMaxSpeed(const Train *u, const RailVehicleInfo *rvi_u, con * @param p2 Additional data for the command (for the #CommandProc) * @param cmd Unused. */ -void CcBuildWagon(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcBuildWagon(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; @@ -232,7 +232,7 @@ static void TrainDetailsInfoTab(const Train *v, int left, int right, int y, byte { const RailVehicleInfo *rvi = RailVehInfo(v->engine_type); bool show_speed = !UsesWagonOverride(v) && (_settings_game.vehicle.wagon_speed_limits || rvi->railveh_type != RAILVEH_WAGON); - uint16 speed; + uint16_t speed; if (rvi->railveh_type == RAILVEH_WAGON) { SetDParam(0, PackEngineNameDParam(v->engine_type, EngineNameContext::VehicleDetails)); @@ -414,7 +414,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/train_speed_adaptation.h b/src/train_speed_adaptation.h index 706140614e..36460f4fa6 100644 --- a/src/train_speed_adaptation.h +++ b/src/train_speed_adaptation.h @@ -18,7 +18,7 @@ struct SignalSpeedKey { TileIndex signal_tile; - uint16 signal_track; + uint16_t signal_track; Trackdir last_passing_train_dir; bool operator==(const SignalSpeedKey& other) const @@ -35,7 +35,7 @@ struct SignalSpeedKey { }; struct SignalSpeedValue { - uint16 train_speed; + uint16_t train_speed; DateTicksScaled time_stamp; /** Checks if the timeout has passed */ @@ -48,8 +48,8 @@ struct SignalSpeedValue { extern btree::btree_map _signal_speeds; struct Train; -void SetSignalTrainAdaptationSpeed(const Train *v, TileIndex tile, uint16 track); -void ApplySignalTrainAdaptationSpeed(Train *v, TileIndex tile, uint16 track); -uint16 GetLowestSpeedTrainAdaptationSpeedAtSignal(TileIndex tile, uint16 track); +void SetSignalTrainAdaptationSpeed(const Train *v, TileIndex tile, uint16_t track); +void ApplySignalTrainAdaptationSpeed(Train *v, TileIndex tile, uint16_t track); +uint16_t GetLowestSpeedTrainAdaptationSpeedAtSignal(TileIndex tile, uint16_t track); #endif /* TRAIN_SPEED_ADAPTATION_H */ diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index 7b3d5b9cfd..13ecc62e66 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -129,7 +129,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 b244e48b31..ffe3f81dff 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 { diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp index d7b5ceb8f5..e248892a19 100644 --- a/src/tree_cmd.cpp +++ b/src/tree_cmd.cpp @@ -53,9 +53,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 @@ -130,13 +130,13 @@ static void PlantTreesOnTile(TileIndex tile, TreeType treetype, uint count, uint * Previous value of _settings_game.construction.trees_around_snow_line_range * used to calculate _arctic_tree_occurance */ -static uint8 _previous_trees_around_snow_line_range = 255; +static uint8_t _previous_trees_around_snow_line_range = 255; /** * Array of probabilities for artic trees to appear, * by normalised distance from snow line */ -static std::vector _arctic_tree_occurance; +static std::vector _arctic_tree_occurance; /** Recalculate _arctic_tree_occurance */ static void RecalculateArcticTreeOccuranceArray() @@ -147,7 +147,7 @@ static void RecalculateArcticTreeOccuranceArray() * 256 * ((1 + (-3 * distance / range) / 6) ** 6) * ((256 - (128 * distance / range)) ** 6) >> (5 * 8); */ - uint8 range = _settings_game.construction.trees_around_snow_line_range; + uint8_t range = _settings_game.construction.trees_around_snow_line_range; _previous_trees_around_snow_line_range = range; _arctic_tree_occurance.clear(); _arctic_tree_occurance.reserve((range * 5) / 4); @@ -155,7 +155,7 @@ static void RecalculateArcticTreeOccuranceArray() if (range == 0) return; for (uint i = 1; i < 256; i++) { uint x = 256 - ((128 * i) / range); - uint32 output = x; + uint32_t output = x; output *= x; output *= x; output *= x; @@ -164,7 +164,7 @@ static void RecalculateArcticTreeOccuranceArray() output *= x; output >>= 24; if (output == 0) break; - _arctic_tree_occurance.push_back(static_cast(output)); + _arctic_tree_occurance.push_back(static_cast(output)); } } @@ -190,7 +190,7 @@ static TreeType GetRandomTreeType(TileIndex tile, uint seed) return (TreeType)(seed * TREE_COUNT_SUB_ARCTIC / 256 + TREE_SUB_ARCTIC); } - uint8 range = _settings_game.construction.trees_around_snow_line_range; + uint8_t range = _settings_game.construction.trees_around_snow_line_range; if (range != _previous_trees_around_snow_line_range) RecalculateArcticTreeOccuranceArray(); int z = GetTileZ(tile); @@ -235,7 +235,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)); @@ -263,7 +263,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); @@ -282,7 +282,7 @@ static void PlaceTreeGroups(uint num_groups) static TileIndex FindTreePositionAtSameHeight(TileIndex tile, int height, uint steps) { for (uint i = 0; i < steps; i++) { - const uint32 r = Random(); + const uint32_t r = Random(); const int x = GB(r, 0, 5) - 16; const int y = GB(r, 8, 5) - 16; const TileIndex cur_tile = TileAddWrap(tile, x, y); @@ -382,7 +382,7 @@ void PlaceTreesRandomly() i = ScaleByMapSize(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); @@ -412,7 +412,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); @@ -464,14 +464,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) { @@ -546,7 +546,7 @@ void GenerateTrees() * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdPlantTree(TileIndex end_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdPlantTree(TileIndex end_tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { StringID msg = INVALID_STRING_ID; CommandCost cost(EXPENSES_OTHER); @@ -831,7 +831,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; @@ -867,7 +867,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); } @@ -910,7 +910,7 @@ static void TileLoop_Trees(TileIndex tile) /* _tick_counter is incremented by 256 between each call, so ignore lower 8 bits. * Also, we add tile % 31 to spread the updates evenly over the map, * where 31 is just some prime number that looks ok. */ - uint32 cycle = (uint32)((tile % 31) + (_tick_counter >> 8)); + uint32_t cycle = (uint32_t)((tile % 31) + (_tick_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) { @@ -929,7 +929,7 @@ static void TileLoop_Trees(TileIndex tile) if (_settings_game.construction.tree_growth_rate == 4) return; /* slow, very slow, extremely slow */ - uint16 grow_slowing_values[4] = { 0x10000 / 5, 0x10000 / 20, 0x10000 / 120, 0 }; + uint16_t grow_slowing_values[4] = { 0x10000 / 5, 0x10000 / 20, 0x10000 / 120, 0 }; if (GB(Random(), 0, 16) >= grow_slowing_values[_settings_game.construction.tree_growth_rate - 1]) { return; @@ -1067,7 +1067,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 b8feda8a05..b7aee55544 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -39,8 +39,8 @@ uint PlaceTreeGroupAroundTile(TileIndex tile, TreeType treetype, uint radius, ui */ 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/tunnel_base.h b/src/tunnel_base.h index faf6b65035..d17232ee69 100644 --- a/src/tunnel_base.h +++ b/src/tunnel_base.h @@ -20,16 +20,16 @@ extern TunnelPool _tunnel_pool; struct Tunnel : TunnelPool::PoolItem<&_tunnel_pool> { - TileIndex tile_n; // North tile of tunnel. - TileIndex tile_s; // South tile of tunnel. - uint8 height; // Tunnel height - bool is_chunnel; // Whether this tunnel is a chunnel - uint8 style; // Style (new signals) of tunnel. + TileIndex tile_n; ///< North tile of tunnel. + TileIndex tile_s; ///< South tile of tunnel. + uint8_t height; ///< Tunnel height + bool is_chunnel; ///< Whether this tunnel is a chunnel + uint8_t style; ///< Style (new signals) of tunnel. Tunnel() {} ~Tunnel(); - Tunnel(TileIndex tile_n, TileIndex tile_s, uint8 height, bool is_chunnel) : tile_n(tile_n), tile_s(tile_s), height(height), is_chunnel(is_chunnel) + Tunnel(TileIndex tile_n, TileIndex tile_s, uint8_t height, bool is_chunnel) : tile_n(tile_n), tile_s(tile_s), height(height), is_chunnel(is_chunnel) { this->UpdateIndexes(); } diff --git a/src/tunnel_map.cpp b/src/tunnel_map.cpp index ce4afa362a..c613d981d3 100644 --- a/src/tunnel_map.cpp +++ b/src/tunnel_map.cpp @@ -21,19 +21,19 @@ TunnelPool _tunnel_pool("Tunnel"); INSTANTIATE_POOL_METHODS(Tunnel) static robin_hood::unordered_map tunnel_tile_index_map; -static btree::btree_multimap tunnel_axis_height_index; +static btree::btree_multimap tunnel_axis_height_index; -static uint64 GetTunnelAxisHeightCacheKey(TileIndex tile, uint8 height, bool y_axis) { +static uint64_t GetTunnelAxisHeightCacheKey(TileIndex tile, uint8_t height, bool y_axis) { if (y_axis) { // tunnel extends along Y axis (DIAGDIR_SE from north end), has same X values - return TileX(tile) | (((uint64) height) << 24) | (((uint64) 1) << 32); + return TileX(tile) | (((uint64_t) height) << 24) | (((uint64_t) 1) << 32); } else { // tunnel extends along X axis (DIAGDIR_SW from north end), has same Y values - return TileY(tile) | (((uint64) height) << 24); + return TileY(tile) | (((uint64_t) height) << 24); } } -static inline uint64 GetTunnelAxisHeightCacheKey(const Tunnel* t) { +static inline uint64_t GetTunnelAxisHeightCacheKey(const Tunnel* t) { return GetTunnelAxisHeightCacheKey(t->tile_n, t->height, t->tile_s - t->tile_n > MapMaxX()); } @@ -135,7 +135,7 @@ bool IsTunnelInWay(TileIndex tile, int z, IsTunnelInWayFlags flags) return IsTunnelInWaySingleAxis(tile, z, flags, false, 1) || IsTunnelInWaySingleAxis(tile, z, flags, true, TileOffsByDiagDir(DIAGDIR_SE)); } -void SetTunnelSignalStyle(TileIndex t, TileIndex end, uint8 style) +void SetTunnelSignalStyle(TileIndex t, TileIndex end, uint8_t style) { if (style == 0) { /* Style already 0 */ @@ -150,7 +150,7 @@ void SetTunnelSignalStyle(TileIndex t, TileIndex end, uint8 style) Tunnel::GetByTile(t)->style = style; } -uint8 GetTunnelSignalStyleExtended(TileIndex t) +uint8_t GetTunnelSignalStyleExtended(TileIndex t) { return Tunnel::GetByTile(t)->style; } diff --git a/src/tunnel_map.h b/src/tunnel_map.h index 871aae88dd..048f924910 100644 --- a/src/tunnel_map.h +++ b/src/tunnel_map.h @@ -12,7 +12,7 @@ #include "road_map.h" -typedef uint32 TunnelID; ///< Type for the unique identifier of tunnels. +typedef uint32_t TunnelID; ///< Type for the unique identifier of tunnels. static const TunnelID TUNNEL_ID_MAP_LOOKUP = 0xFFFF; ///< Sentinel ID value to store in m2 to indiciate that the ID should be looked up instead @@ -111,13 +111,13 @@ inline void SetTunnelIndex(TileIndex t, TunnelID id) _m[t].m2 = (id >= TUNNEL_ID_MAP_LOOKUP) ? TUNNEL_ID_MAP_LOOKUP : id; } -void SetTunnelSignalStyle(TileIndex t, TileIndex end, uint8 style); +void SetTunnelSignalStyle(TileIndex t, TileIndex end, uint8_t style); -inline uint8 GetTunnelSignalStyle(TileIndex t) +inline uint8_t GetTunnelSignalStyle(TileIndex t) { if (likely(!HasBit(_m[t].m3, 7))) return 0; - extern uint8 GetTunnelSignalStyleExtended(TileIndex t); + extern uint8_t GetTunnelSignalStyleExtended(TileIndex t); return GetTunnelSignalStyleExtended(t); } diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 678a134ffe..ed74881fc2 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -365,7 +365,7 @@ static Money TunnelBridgeClearCost(TileIndex tile, Price base_price) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { CompanyID company = _current_company; @@ -829,10 +829,10 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u 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]); } } @@ -951,7 +951,7 @@ static inline CommandCost CanBuildChunnel(TileIndex tile, DiagDirection directio * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { CompanyID company = _current_company; @@ -1735,7 +1735,7 @@ static void DrawTunnelBridgeRampSingleSignal(const TileInfo *ti, bool is_green, bool side = (_settings_game.vehicle.road_side != 0) && _settings_game.construction.train_signal_side; DiagDirection dir = GetTunnelBridgeDirection(ti->tile); - uint8 style = GetTunnelBridgeSignalStyle(ti->tile); + uint8_t style = GetTunnelBridgeSignalStyle(ti->tile); side ^= HasBit(_signal_style_masks.signal_opposite_side, style); static const Point SignalPositions[2][4] = { @@ -1757,7 +1757,7 @@ static void DrawTunnelBridgeRampSingleSignal(const TileInfo *ti, bool is_green, SignalVariant variant = IsTunnelBridgeSemaphore(ti->tile) ? SIG_SEMAPHORE : SIG_ELECTRIC; const RailTypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile)); - uint8 aspect = 0; + uint8_t aspect = 0; if (is_green) { if (_extra_aspects > 0) { aspect = show_exit ? GetTunnelBridgeExitSignalAspect(ti->tile) : GetTunnelBridgeEntranceSignalAspect(ti->tile); @@ -1866,14 +1866,14 @@ static void DrawBridgeSignalOnMiddlePart(const TileInfo *ti, TileIndex bridge_st while (bridge_signal_position <= bridge_section) { bridge_signal_position += simulated_wormhole_signals; if (bridge_signal_position == bridge_section) { - uint8 style = GetBridgeSignalStyle(bridge_start_tile); + uint8_t style = GetBridgeSignalStyle(bridge_start_tile); uint position, x, y; GetBridgeSignalXY(ti->tile, GetTunnelBridgeDirection(bridge_start_tile), HasBit(_signal_style_masks.signal_opposite_side, style), position, x, y); SignalVariant variant = IsTunnelBridgeSemaphore(bridge_start_tile) ? SIG_SEMAPHORE : SIG_ELECTRIC; SignalState state = GetBridgeEntranceSimulatedSignalState(bridge_start_tile, m2_position); - uint8 aspect = 0; + uint8_t aspect = 0; if (state == SIGNAL_STATE_GREEN) { aspect = 1; if (_extra_aspects > 0) { @@ -2618,7 +2618,7 @@ static void GetTileDesc_TunnelBridge(TileIndex tile, TileDesc *td) } if (tt == TRANSPORT_RAIL) { - uint8 style = GetTunnelBridgeSignalStyle(tile); + uint8_t style = GetTunnelBridgeSignalStyle(tile); if (style > 0) { /* Add suffix about signal style */ td->dparam[0] = td->str; @@ -2669,7 +2669,7 @@ static void GetTileDesc_TunnelBridge(TileIndex tile, TileDesc *td) } if (!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; @@ -2690,7 +2690,7 @@ static void GetTileDesc_TunnelBridge(TileIndex tile, TileDesc *td) } 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) { @@ -2733,16 +2733,16 @@ static const RailGroundType _tunnel_bridge_fence_table[4][5] = { RailGroundType GetTunnelBridgeGroundType(TileIndex tile) { - uint8 ground_bits = GetTunnelBridgeGroundBits(tile); + uint8_t ground_bits = GetTunnelBridgeGroundBits(tile); if (ground_bits == 0) return RAIL_GROUND_GRASS; if (ground_bits == 1) return RAIL_GROUND_ICE_DESERT; if (ground_bits == 2) return RAIL_GROUND_BARREN; return _tunnel_bridge_fence_table[GetTunnelBridgeDirection(tile)][ground_bits - 3]; } -static uint8 MapTunnelBridgeGroundTypeBits(TileIndex tile, RailGroundType type) +static uint8_t MapTunnelBridgeGroundTypeBits(TileIndex tile, RailGroundType type) { - uint8 ground_bits; + uint8_t ground_bits; switch (type) { case RAIL_GROUND_BARREN: ground_bits = 2; @@ -2790,7 +2790,7 @@ static uint8 MapTunnelBridgeGroundTypeBits(TileIndex tile, RailGroundType type) static void TileLoop_TunnelBridge(TileIndex tile) { - const uint8 old_ground_bits = GetTunnelBridgeGroundBits(tile); + const uint8_t old_ground_bits = GetTunnelBridgeGroundBits(tile); bool snow_or_desert = false; switch (_settings_game.game_creation.landscape) { case LT_ARCTIC: { @@ -2822,7 +2822,7 @@ static void TileLoop_TunnelBridge(TileIndex tile) new_ground = RailTrackToFence(tile, rail); } } - uint8 ground_bits = MapTunnelBridgeGroundTypeBits(tile, new_ground); + uint8_t ground_bits = MapTunnelBridgeGroundTypeBits(tile, new_ground); if (ground_bits != old_ground_bits) { SetTunnelBridgeGroundBits(tile, ground_bits); MarkTileDirtyByTile(tile); @@ -2972,7 +2972,7 @@ void SubtractRailTunnelBridgeInfrastructure(TileIndex begin, TileIndex end) { UpdateRailTunnelBridgeInfrastructure(Company::GetIfValid(GetTileOwner(begin)), begin, end, false); } -void SetTunnelBridgeSignalStyleExtended(TileIndex t, TileIndex end, uint8 style) +void SetTunnelBridgeSignalStyleExtended(TileIndex t, TileIndex end, uint8_t style) { if (IsTunnel(t)) { SetTunnelSignalStyle(t, end, style); @@ -3170,7 +3170,7 @@ static VehicleEnterTileStatus VehicleEnter_TunnelBridge(Vehicle *v, TileIndex ti if (v->vehstatus & VS_HIDDEN) return VETSB_CONTINUE; // Building bridges between chunnel portals allowed. 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/tunnelbridge_map.h b/src/tunnelbridge_map.h index 8996af5602..aa93a36858 100644 --- a/src/tunnelbridge_map.h +++ b/src/tunnelbridge_map.h @@ -49,7 +49,7 @@ inline TransportType GetTunnelBridgeTransportType(TileIndex t) return (TransportType)GB(_m[t].m5, 2, 2); } -inline uint8 GetTunnelBridgeGroundBits(TileIndex t) +inline uint8_t GetTunnelBridgeGroundBits(TileIndex t) { assert_tile(IsTileType(t, MP_TUNNELBRIDGE), t); return GB(_me[t].m7, 5, 3); @@ -77,7 +77,7 @@ inline bool IsRailTunnelBridgeTile(TileIndex t) return IsTileType(t, MP_TUNNELBRIDGE) && (Extract(_m[t].m5) == TRANSPORT_RAIL); } -inline void SetTunnelBridgeGroundBits(TileIndex t, uint8 bits) +inline void SetTunnelBridgeGroundBits(TileIndex t, uint8_t bits) { assert_tile(IsTileType(t, MP_TUNNELBRIDGE), t); SB(_me[t].m7, 5, 3, bits); @@ -525,25 +525,25 @@ inline void SetTunnelBridgePBS(TileIndex t, bool is_pbs) SB(_me[t].m6, 6, 1, is_pbs ? 1 : 0); } -inline uint8 GetTunnelBridgeEntranceSignalAspect(TileIndex t) +inline uint8_t GetTunnelBridgeEntranceSignalAspect(TileIndex t) { assert_tile(IsTunnelBridgeWithSignalSimulation(t), t); return GB(_m[t].m3, 0, 3); } -inline void SetTunnelBridgeEntranceSignalAspect(TileIndex t, uint8 aspect) +inline void SetTunnelBridgeEntranceSignalAspect(TileIndex t, uint8_t aspect) { assert_tile(IsTunnelBridgeWithSignalSimulation(t), t); SB(_m[t].m3, 0, 3, aspect); } -inline uint8 GetTunnelBridgeExitSignalAspect(TileIndex t) +inline uint8_t GetTunnelBridgeExitSignalAspect(TileIndex t) { assert_tile(IsTunnelBridgeWithSignalSimulation(t), t); return GB(_m[t].m3, 3, 3); } -inline void SetTunnelBridgeExitSignalAspect(TileIndex t, uint8 aspect) +inline void SetTunnelBridgeExitSignalAspect(TileIndex t, uint8_t aspect) { assert_tile(IsTunnelBridgeWithSignalSimulation(t), t); SB(_m[t].m3, 3, 3, aspect); @@ -601,23 +601,23 @@ inline Trackdir GetTunnelBridgeEntranceTrackdir(TileIndex t) return GetTunnelBridgeEntranceTrackdir(t, GetTunnelBridgeDirection(t)); } -inline void SetTunnelBridgeSignalStyle(TileIndex t, TileIndex end, uint8 style) +inline void SetTunnelBridgeSignalStyle(TileIndex t, TileIndex end, uint8_t style) { if (style == 0 && !HasBit(_m[t].m3, 7)) return; - extern void SetTunnelBridgeSignalStyleExtended(TileIndex t, TileIndex end, uint8 style); + extern void SetTunnelBridgeSignalStyleExtended(TileIndex t, TileIndex end, uint8_t style); SetTunnelBridgeSignalStyleExtended(t, end, style); } -inline uint8 GetTunnelBridgeSignalStyle(TileIndex t) +inline uint8_t GetTunnelBridgeSignalStyle(TileIndex t) { if (likely(!HasBit(_m[t].m3, 7))) return 0; if (IsTunnel(t)) { - extern uint8 GetTunnelSignalStyleExtended(TileIndex t); + extern uint8_t GetTunnelSignalStyleExtended(TileIndex t); return GetTunnelSignalStyleExtended(t); } else { - extern uint8 GetBridgeSignalStyleExtended(TileIndex t); + extern uint8_t GetBridgeSignalStyleExtended(TileIndex t); return GetBridgeSignalStyleExtended(t); } } diff --git a/src/unit_conversion.h b/src/unit_conversion.h index d71b149f2d..2a5af08d8d 100644 --- a/src/unit_conversion.h +++ b/src/unit_conversion.h @@ -17,10 +17,10 @@ uint ConvertWeightToDisplayWeight(uint weight); uint ConvertDisplayWeightToWeight(uint weight); uint ConvertPowerToDisplayPower(uint power); uint ConvertDisplayPowerToPower(uint power); -int64 ConvertForceToDisplayForce(int64 force); -int64 ConvertDisplayForceToForce(int64 force); -void ConvertPowerWeightRatioToDisplay(int64 ratio, int64 &value, int64 &decimals); -void ConvertForceWeightRatioToDisplay(int64 ratio, int64 &value, int64 &decimals); +int64_t ConvertForceToDisplayForce(int64_t force); +int64_t ConvertDisplayForceToForce(int64_t force); +void ConvertPowerWeightRatioToDisplay(int64_t ratio, int64_t &value, int64_t &decimals); +void ConvertForceWeightRatioToDisplay(int64_t ratio, int64_t &value, int64_t &decimals); uint ConvertDisplayToPowerWeightRatio(double in); uint ConvertDisplayToForceWeightRatio(double in); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index c390727da8..f4472db895 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -98,7 +98,7 @@ static const uint GEN_HASHY_BUCKET_BITS = 6; VehicleID _new_vehicle_id; uint _returned_refit_capacity; ///< Stores the capacity after a refit operation. -uint16 _returned_mail_refit_capacity; ///< Stores the mail capacity after a refit operation (Aircraft only). +uint16_t _returned_mail_refit_capacity; ///< Stores the mail capacity after a refit operation (Aircraft only). CargoArray _returned_vehicle_capacities; ///< Stores the cargo capacities after a vehicle build operation @@ -448,7 +448,7 @@ void VehicleLengthChanged(const Vehicle *u) } return; } - uint32 grfid = engine->grf_prop.grffile->grfid; + uint32_t grfid = engine->grf_prop.grffile->grfid; GRFConfig *grfconfig = GetGRFConfig(grfid); if (GamelogGRFBugReverse(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); @@ -688,7 +688,7 @@ CommandCost TunnelBridgeIsFree(TileIndex tile, TileIndex endtile, const Vehicle struct FindTrainClosestToTunnelBridgeEndInfo { Train *best; ///< The currently "best" vehicle we have found. - int32 best_pos; + int32_t best_pos; DiagDirection direction; FindTrainClosestToTunnelBridgeEndInfo(DiagDirection direction) : best(nullptr), best_pos(INT32_MIN), direction(direction) {} @@ -711,7 +711,7 @@ static Vehicle *FindClosestTrainToTunnelBridgeEndEnum(Vehicle *v, void *data) if ((GetAcrossTunnelBridgeTrackBits(t->tile) & t->track & TRACK_BIT_ALL) == TRACK_BIT_NONE) return nullptr; } - int32 pos; + int32_t pos; switch (info->direction) { default: NOT_REACHED(); case DIAGDIR_NE: pos = -v->x_pos; break; // X: lower is better @@ -1083,7 +1083,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(); } @@ -1320,7 +1320,7 @@ static void RunVehicleDayProc() /* Call the 32-day callback if needed */ if ((v->day_counter & 0x1F) == 0 && v->HasEngineType() && (Engine::Get(v->engine_type)->callbacks_used & SGCU_VEHICLE_32DAY_CALLBACK) != 0) { - 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 @@ -1809,7 +1809,7 @@ void CallVehicleTicks() _vehicles_to_pay_repair.clear(); } -void RemoveVirtualTrainsOfUser(uint32 user) +void RemoveVirtualTrainsOfUser(uint32_t user) { if (!_tick_caches_valid || HasChickenBit(DCBF_VEH_TICK_CACHE)) RebuildVehicleTickCaches(); @@ -2123,7 +2123,7 @@ static const byte _breakdown_chances[4][4] = { * @param v the vehicle in question. * @param r the random number to use. (Note that bits 0..6 are already used) */ -void DetermineBreakdownType(Vehicle *v, uint32 r) { +void DetermineBreakdownType(Vehicle *v, uint32_t r) { /* if 'improved breakdowns' is off, just do the classic breakdown */ if (!_settings_game.vehicle.improved_breakdowns) { v->breakdown_type = BREAKDOWN_CRITICAL; @@ -2168,8 +2168,8 @@ void DetermineBreakdownType(Vehicle *v, uint32 r) { } else if (rand <= breakdown_type_chance[BREAKDOWN_LOW_SPEED]) { v->breakdown_type = BREAKDOWN_LOW_SPEED; /* average of random and reliability */ - uint16 rand2 = (GB(r, 16, 16) + v->reliability) >> 1; - uint16 max_speed = + uint16_t rand2 = (GB(r, 16, 16) + v->reliability) >> 1; + uint16_t max_speed = (v->type == VEH_TRAIN) ? GetVehicleProperty(v, PROP_TRAIN_SPEED, RailVehInfo(v->engine_type)->max_speed) : (v->type == VEH_ROAD ) ? @@ -2179,7 +2179,7 @@ void DetermineBreakdownType(Vehicle *v, uint32 r) { GetVehicleProperty(v, PROP_AIRCRAFT_SPEED, AircraftVehInfo(v->engine_type)->max_speed); byte min_speed = std::min(41, max_speed >> 2); /* we use the min() function here because we want to use the real value of max_speed for the min_speed calculation */ - max_speed = std::min(max_speed, 255); + max_speed = std::min(max_speed, 255); v->breakdown_severity = Clamp((max_speed * rand2) >> 16, min_speed, max_speed); } else if (rand <= breakdown_type_chance[BREAKDOWN_LOW_POWER]) { v->breakdown_type = BREAKDOWN_LOW_POWER; @@ -2214,12 +2214,12 @@ void CheckVehicleBreakdown(Vehicle *v) return; } - uint32 r = Random(); + uint32_t r = Random(); /* increase chance of failure */ int chance = v->breakdown_chance + 1; if (Chance16I(1, 25, r)) chance += 25; - chance = ClampTo(chance); + chance = ClampTo(chance); v->breakdown_chance = chance; if (_settings_game.vehicle.improved_breakdowns) { @@ -2241,10 +2241,10 @@ void CheckVehicleBreakdown(Vehicle *v) * However, because breakdowns are no longer by definition a complete stop, * their impact will be significantly less. */ - uint32 r1 = Random(); - uint32 breakdown_scaling_x2 = (_settings_game.difficulty.vehicle_breakdowns == 64) ? 1 : (_settings_game.difficulty.vehicle_breakdowns * 2); - if ((uint32) (0xffff - v->reliability) * breakdown_scaling_x2 * chance > GB(r1, 0, 24) * 10 * 2) { - uint32 r2 = Random(); + uint32_t r1 = Random(); + uint32_t breakdown_scaling_x2 = (_settings_game.difficulty.vehicle_breakdowns == 64) ? 1 : (_settings_game.difficulty.vehicle_breakdowns * 2); + if ((uint32_t) (0xffff - v->reliability) * breakdown_scaling_x2 * chance > GB(r1, 0, 24) * 10 * 2) { + uint32_t r2 = Random(); v->breakdown_ctr = GB(r1, 24, 6) + 0xF; if (v->type == VEH_TRAIN) SetBit(Train::From(v)->First()->flags, VRF_CONSIST_BREAKDOWN); v->breakdown_delay = GB(r2, 0, 7) + 0x80; @@ -2477,7 +2477,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; @@ -2532,7 +2532,7 @@ uint8 CalcPercentVehicleFilled(const Vehicle *front, StringID *colour) } } -uint8 CalcPercentVehicleFilledOfCargo(const Vehicle *front, CargoID cargo) +uint8_t CalcPercentVehicleFilledOfCargo(const Vehicle *front, CargoID cargo) { int count = 0; int max = 0; @@ -2797,7 +2797,7 @@ VehicleOrderID Vehicle::GetFirstWaitingLocation(bool require_wait_timetabled) co */ 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 */ }; @@ -3109,7 +3109,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) @@ -3182,7 +3182,7 @@ PaletteID GetUncachedTrainPaletteIgnoringGroup(const Train *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); @@ -3231,7 +3231,7 @@ static void VehicleIncreaseStats(const Vehicle *front) { for (const Vehicle *v = front; v != nullptr; v = v->Next()) { StationID last_loading_station = HasBit(front->vehicle_flags, VF_LAST_LOAD_ST_SEP) ? v->last_loading_station : front->last_loading_station; - uint64 loading_tick = HasBit(front->vehicle_flags, VF_LAST_LOAD_ST_SEP) ? v->last_loading_tick : front->last_loading_tick; + uint64_t loading_tick = HasBit(front->vehicle_flags, VF_LAST_LOAD_ST_SEP) ? v->last_loading_tick : front->last_loading_tick; if (v->refit_cap > 0 && last_loading_station != INVALID_STATION && last_loading_station != front->last_station_visited && @@ -3361,7 +3361,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); } } @@ -3480,10 +3480,10 @@ void Vehicle::LeaveStation() /* NB: this is saved here as we overwrite it on the first iteration of the loop below */ StationID head_last_loading_station = this->last_loading_station; - uint64 head_last_loading_tick = this->last_loading_tick; + uint64_t head_last_loading_tick = this->last_loading_tick; for (Vehicle *u = this; u != nullptr; u = u->Next()) { StationID last_loading_station = HasBit(this->vehicle_flags, VF_LAST_LOAD_ST_SEP) ? u->last_loading_station : head_last_loading_station; - uint64 last_loading_tick = HasBit(this->vehicle_flags, VF_LAST_LOAD_ST_SEP) ? u->last_loading_tick : head_last_loading_tick; + uint64_t last_loading_tick = HasBit(this->vehicle_flags, VF_LAST_LOAD_ST_SEP) ? u->last_loading_tick : head_last_loading_tick; if (u->cargo_type < NUM_CARGO && HasBit(cargoes_can_load_unload, u->cargo_type)) { if (HasBit(cargoes_can_leave_with_cargo, u->cargo_type)) { u->last_loading_station = this->last_station_visited; @@ -3535,7 +3535,7 @@ void Vehicle::LeaveStation() new_occupancy = current_occupancy; } else { Company *owner = Company::GetIfValid(this->owner); - uint8 occupancy_smoothness = owner ? owner->settings.order_occupancy_smoothness : 0; + uint8_t occupancy_smoothness = owner ? owner->settings.order_occupancy_smoothness : 0; // Exponential weighted moving average using occupancy_smoothness new_occupancy = (old_occupancy - 1) * occupancy_smoothness; new_occupancy += current_occupancy * (100 - occupancy_smoothness); @@ -3544,7 +3544,7 @@ void Vehicle::LeaveStation() } if (new_occupancy + 1 != old_occupancy) { this->order_occupancy_average = 0; - real_current_order->SetOccupancy(static_cast(new_occupancy + 1)); + real_current_order->SetOccupancy(static_cast(new_occupancy + 1)); for (const Vehicle *v = this->FirstShared(); v != nullptr; v = v->NextShared()) { SetWindowDirty(WC_VEHICLE_ORDERS, v->index); } @@ -3747,7 +3747,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command, Tile 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); } @@ -3828,7 +3828,7 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command, Tile } if (this->IsGroundVehicle() && this->GetNumManualOrders() > 0) { - uint16 &gv_flags = this->GetGroundVehicleFlags(); + uint16_t &gv_flags = this->GetGroundVehicleFlags(); SetBit(gv_flags, GVF_SUPPRESS_IMPLICIT_ORDERS); } @@ -3882,7 +3882,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); @@ -3926,7 +3926,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 }; @@ -3936,14 +3936,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; @@ -3956,19 +3956,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; } @@ -4286,7 +4286,7 @@ void DumpVehicleFlagsGeneric(const Vehicle *v, T dump, U dump_header) dump('N', "VCF_IMAGE_REFRESH_NEXT", HasBit(v->vcache.cached_veh_flags, VCF_IMAGE_REFRESH_NEXT)); dump('c', "VCF_IMAGE_CURVATURE", HasBit(v->vcache.cached_veh_flags, VCF_IMAGE_CURVATURE)); if (v->IsGroundVehicle()) { - uint16 gv_flags = v->GetGroundVehicleFlags(); + uint16_t gv_flags = v->GetGroundVehicleFlags(); dump_header("gvf:", "GroundVehicleFlags:"); dump('u', "GVF_GOINGUP_BIT", HasBit(gv_flags, GVF_GOINGUP_BIT)); dump('d', "GVF_GOINGDOWN_BIT", HasBit(gv_flags, GVF_GOINGDOWN_BIT)); @@ -4555,7 +4555,7 @@ const GroundVehicleCache *Vehicle::GetGroundVehicleCache() const * @pre The vehicle is a #GroundVehicle. * @return #GroundVehicleFlags of the vehicle. */ -uint16 &Vehicle::GetGroundVehicleFlags() +uint16_t &Vehicle::GetGroundVehicleFlags() { dbg_assert(this->IsGroundVehicle()); if (this->type == VEH_TRAIN) { @@ -4570,7 +4570,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 { dbg_assert(this->IsGroundVehicle()); if (this->type == VEH_TRAIN) { @@ -4588,7 +4588,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); @@ -4684,9 +4684,9 @@ void ShiftVehicleDates(DateDelta interval) * 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(); @@ -4699,9 +4699,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 a973ff4f17..47ce5117da 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -30,7 +30,7 @@ #include #include -CommandCost CmdRefitVehicle(TileIndex, DoCommandFlag, uint32, uint32, const char*); +CommandCost CmdRefitVehicle(TileIndex, DoCommandFlag, uint32_t, uint32_t, const char*); /** Vehicle status bits in #Vehicle::vehstatus. */ enum VehStatus { @@ -81,12 +81,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. */ @@ -150,9 +150,9 @@ enum VehicleCacheFlags { /** 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 cached_image_curvature; ///< Cached neighbour curvature, see: VCF_IMAGE_CURVATURE + 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. + uint16_t cached_image_curvature; ///< Cached neighbour curvature, see: VCF_IMAGE_CURVATURE byte cached_vis_effect; ///< Visual effect to show (see #VisualEffect) byte cached_veh_flags; ///< Vehicle cache flags (see #VehicleCacheFlags) @@ -220,10 +220,10 @@ enum PendingSpeedRestrictionChangeFlags { }; struct PendingSpeedRestrictionChange { - uint16 distance; - uint16 new_speed; - uint16 prev_speed; - uint16 flags; + uint16_t distance; + uint16_t new_speed; + uint16_t prev_speed; + uint16_t flags; }; /** A vehicle pool for a little over 1 million vehicles. */ @@ -274,8 +274,8 @@ private: public: friend SaveLoadTable GetVehicleDescription(VehicleType vt); ///< So we can use private/protected variables in the saveload code friend void FixOldVehicles(); - friend void AfterLoadVehicles(bool part_of_load); ///< So we can set the #previous and #first pointers while loading - friend bool LoadOldVehicle(LoadgameState *ls, int num); ///< So we can set the proper next pointer while loading + friend void AfterLoadVehicles(bool part_of_load); ///< So we can set the #previous and #first pointers while loading + friend bool LoadOldVehicle(LoadgameState *ls, int num); ///< So we can set the proper next pointer while loading friend upstream_sl::SlVehicleCommon; friend upstream_sl::SlVehicleDisaster; @@ -299,7 +299,7 @@ public: CargoPayment *cargo_payment; ///< The cargo payment we're currently in /* Used for timetabling. */ - uint32 current_loading_time; ///< How long loading took. Less than current_order_time if vehicle is early. + uint32_t current_loading_time; ///< How long loading took. Less than current_order_time if vehicle is early. Rect coord; ///< NOSAVE: Graphical bounding box of the vehicle, i.e. what to redraw on moves. @@ -321,16 +321,16 @@ public: DateDelta max_age; ///< Maximum age Date date_of_last_service; ///< Last date the vehicle had a service at a depot. Date date_of_last_service_newgrf; ///< Last date the vehicle had a service at a depot, unchanged by the date cheat to protect against unsafe NewGRF behavior. - 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? @@ -345,43 +345,43 @@ 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. (Also used as virtual train client ID). + uint32_t motion_counter; ///< counter to occasionally play a vehicle sound. (Also used as virtual train client ID). byte progress; ///< The percentage (if divided by 256) this vehicle already crossed the tile unit. - uint16 random_bits; ///< Bits used for randomized variational spritegroups. + uint16_t random_bits; ///< Bits used for randomized variational spritegroups. byte waiting_triggers; ///< Triggers to be yet matched before rerandomizing the random bits. StationID last_station_visited; ///< The last station we stopped at. StationID last_loading_station; ///< Last station the vehicle has stopped at and could possibly leave from with any cargo loaded. (See VF_LAST_LOAD_ST_SEP). - uint64 last_loading_tick; ///< Last time (relative to _scaled_tick_counter) the vehicle has stopped at a station and could possibly leave with any cargo loaded. (See VF_LAST_LOAD_ST_SEP). + uint64_t last_loading_tick; ///< Last time (relative to _scaled_tick_counter) the vehicle has stopped at a station and could possibly leave with any cargo loaded. (See VF_LAST_LOAD_ST_SEP). 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 - uint16 running_ticks; ///< Number of ticks this vehicle was not stopped this day + uint16_t running_ticks; ///< Number of ticks this vehicle was not stopped this day byte vehstatus; ///< Status - uint8 order_occupancy_average; ///< NOSAVE: order occupancy average. 0 = invalid, 1 = n/a, 16-116 = 0-100% + uint8_t order_occupancy_average; ///< NOSAVE: order occupancy average. 0 = invalid, 1 = n/a, 16-116 = 0-100% Order current_order; ///< The current order (+ status, like: loading) union { @@ -389,7 +389,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) Direction cur_image_valid_dir; ///< NOSAVE: direction for which cur_image does not need to be regenerated on the next tick @@ -401,7 +401,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; } @@ -422,8 +422,8 @@ public: GroundVehicleCache *GetGroundVehicleCache(); const GroundVehicleCache *GetGroundVehicleCache() const; - uint16 &GetGroundVehicleFlags(); - const uint16 &GetGroundVehicleFlags() const; + uint16_t &GetGroundVehicleFlags(); + const uint16_t &GetGroundVehicleFlags() const; void DeleteUnreachedImplicitOrders(); @@ -523,7 +523,7 @@ public: Direction GetMapImageDirection() const { return this->direction; } const GRFFile *GetGRF() const; - uint32 GetGRFID() const; + uint32_t GetGRFID() const; /** * Invalidates cached NewGRF variables @@ -852,7 +852,7 @@ public: void RecalculateOrderOccupancyAverage(); - inline uint8 GetOrderOccupancyAverage() const + inline uint8_t GetOrderOccupancyAverage() const { if (order_occupancy_average == 0) const_cast(this)->RecalculateOrderOccupancyAverage(); return this->order_occupancy_average; @@ -934,9 +934,9 @@ public: void UpdatePositionAndViewport(); void 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); } @@ -1234,8 +1234,8 @@ public: */ IterateWrapper Orders() const { return IterateWrapper(this->orders); } - uint32 GetDisplayMaxWeight() const; - uint32 GetDisplayMinPowerToWeight() const; + uint32_t GetDisplayMaxWeight() const; + uint32_t GetDisplayMinPowerToWeight() const; }; inline bool IsPointInViewportVehicleRedrawArea(const std::vector &viewport_redraw_rects, const Point &pt) @@ -1394,9 +1394,9 @@ struct SpecializedVehicle : public Vehicle { } private: - inline uint16 GetVehicleCurvature() const + inline uint16_t GetVehicleCurvature() const { - uint16 curvature = 0; + uint16_t curvature = 0; if (this->Previous() != nullptr) { SB(curvature, 0, 4, this->Previous()->direction); if (this->Previous()->Previous() != nullptr) SB(curvature, 4, 4, this->Previous()->Previous()->direction); @@ -1524,7 +1524,7 @@ struct FreeUnitIDGenerator { }; /** Sentinel for an invalid coordinate. */ -static const int32 INVALID_COORD = 0x7fffffff; +static const int32_t INVALID_COORD = 0x7fffffff; inline void InvalidateVehicleTickCaches() { diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 283b6449cf..65410cde69 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -43,28 +43,28 @@ #include "safeguards.h" /* Tables used in vehicle.h to find the right command for a certain vehicle type */ -const uint32 _veh_build_proc_table[] = { +const uint32_t _veh_build_proc_table[] = { CMD_BUILD_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_TRAIN), CMD_BUILD_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_ROAD_VEHICLE), CMD_BUILD_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_SHIP), CMD_BUILD_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_BUY_AIRCRAFT), }; -const uint32 _veh_sell_proc_table[] = { +const uint32_t _veh_sell_proc_table[] = { CMD_SELL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_SELL_TRAIN), CMD_SELL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_SELL_ROAD_VEHICLE), CMD_SELL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_SELL_SHIP), CMD_SELL_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_SELL_AIRCRAFT), }; -const uint32 _veh_refit_proc_table[] = { +const uint32_t _veh_refit_proc_table[] = { CMD_REFIT_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_REFIT_TRAIN), CMD_REFIT_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_REFIT_ROAD_VEHICLE), CMD_REFIT_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_REFIT_SHIP), CMD_REFIT_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_REFIT_AIRCRAFT), }; -const uint32 _send_to_depot_proc_table[] = { +const uint32_t _send_to_depot_proc_table[] = { CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_TRAIN_TO_DEPOT), CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_ROAD_VEHICLE_TO_DEPOT), CMD_SEND_VEHICLE_TO_DEPOT | CMD_MSG(STR_ERROR_CAN_T_SEND_SHIP_TO_DEPOT), @@ -92,7 +92,7 @@ static CommandCost GetRefitCost(const Vehicle *v, EngineID engine_type, CargoID * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { /* Elementary check for valid location. */ if (!IsDepotTile(tile)) return CMD_ERROR; @@ -219,7 +219,7 @@ CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint return value; } -CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *v, uint16 data, uint32 user); +CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *v, uint16_t data, uint32_t user); /** * Sell a vehicle. @@ -233,7 +233,7 @@ CommandCost CmdSellRailWagon(DoCommandFlag flags, Vehicle *v, uint16 data, uint3 * @param text unused. * @return the cost of this operation or an error. */ -CommandCost CmdSellVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSellVehicle(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Vehicle *v = Vehicle::GetIfValid(GB(p1, 0, 20)); if (v == nullptr) return CMD_ERROR; @@ -274,7 +274,7 @@ CommandCost CmdSellVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 return ret; } -CommandCost CmdSellVirtualVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSellVirtualVehicle(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Train *v = Train::GetIfValid(GB(p1, 0, 20)); if (v == nullptr || !v->IsVirtual()) return CMD_ERROR; @@ -299,9 +299,9 @@ static int GetRefitCostFactor(const Vehicle *v, EngineID engine_type, CargoID ne /* Is this vehicle a NewGRF vehicle? */ if (e->GetGRF() != nullptr && (e->callbacks_used & SGCU_VEHICLE_REFIT_COST) != 0) { 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); @@ -380,7 +380,7 @@ struct RefitResult { * @param auto_refit Refitting is done as automatic refitting outside a depot. * @return Refit cost. */ -static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles, CargoID new_cid, byte new_subtype, DoCommandFlag flags, bool auto_refit) +static CommandCost 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; @@ -430,7 +430,7 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles, 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. */ @@ -479,7 +479,7 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles, /* 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; @@ -487,7 +487,7 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles, 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); } @@ -515,7 +515,7 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Vehicle *v = Vehicle::GetIfValid(p1); if (v == nullptr) return CMD_ERROR; @@ -559,7 +559,7 @@ CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint if (new_cid >= NUM_CARGO) return CMD_ERROR; /* For aircraft there is always only one. */ - uint8 num_vehicles = GB(p2, 16, 8); + uint8_t num_vehicles = GB(p2, 16, 8); bool only_this = HasBit(p2, 25) || front->type == VEH_AIRCRAFT || (front->type == VEH_SHIP && num_vehicles == 1); CommandCost cost = RefitVehicle(v, only_this, num_vehicles, new_cid, new_subtype, flags, auto_refit); @@ -618,7 +618,7 @@ CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { /* Disable the effect of p2 bit 0, when DC_AUTOREPLACE is not set */ if ((flags & DC_AUTOREPLACE) == 0) SetBit(p2, 0); @@ -653,7 +653,7 @@ CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, if (HasBit(p2, 0)) { /* 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) { @@ -715,7 +715,7 @@ CommandCost CmdStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdMassStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdMassStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleList list; bool do_start = HasBit(p1, 0); @@ -756,7 +756,7 @@ CommandCost CmdMassStartStopVehicle(TileIndex tile, DoCommandFlag flags, uint32 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdDepotSellAllVehicles(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdDepotSellAllVehicles(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleList list; @@ -795,7 +795,7 @@ CommandCost CmdDepotSellAllVehicles(TileIndex tile, DoCommandFlag flags, uint32 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdDepotMassAutoReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdDepotMassAutoReplace(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleList list; CommandCost cost = CommandCost(EXPENSES_NEW_VEHICLES); @@ -892,7 +892,7 @@ static void CloneVehicleName(const Vehicle *src, Vehicle *dst) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdToggleReuseDepotVehicles(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdToggleReuseDepotVehicles(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { // Identify template to toggle TemplateVehicle *template_vehicle = TemplateVehicle::GetIfValid(p1); @@ -921,7 +921,7 @@ CommandCost CmdToggleReuseDepotVehicles(TileIndex tile, DoCommandFlag flags, uin * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdToggleKeepRemainingVehicles(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdToggleKeepRemainingVehicles(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { // Identify template to toggle TemplateVehicle *template_vehicle = TemplateVehicle::GetIfValid(p1); @@ -950,7 +950,7 @@ CommandCost CmdToggleKeepRemainingVehicles(TileIndex tile, DoCommandFlag flags, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdSetRefitAsTemplate(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSetRefitAsTemplate(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { // Identify template to toggle TemplateVehicle *template_vehicle = TemplateVehicle::GetIfValid(p1); @@ -980,7 +980,7 @@ CommandCost CmdSetRefitAsTemplate(TileIndex tile, DoCommandFlag flags, uint32 p1 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdToggleTemplateReplaceOldOnly(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdToggleTemplateReplaceOldOnly(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { // Identify template to toggle TemplateVehicle *template_vehicle = TemplateVehicle::GetIfValid(p1); @@ -1010,7 +1010,7 @@ CommandCost CmdToggleTemplateReplaceOldOnly(TileIndex tile, DoCommandFlag flags, * @param text new name * @return the cost of this operation or an error */ -CommandCost CmdRenameTemplateReplace(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRenameTemplateReplace(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { TemplateVehicle *template_vehicle = TemplateVehicle::GetIfValid(p1); @@ -1047,7 +1047,7 @@ CommandCost CmdRenameTemplateReplace(TileIndex tile, DoCommandFlag flags, uint32 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdVirtualTrainFromTemplateVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdVirtualTrainFromTemplateVehicle(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID template_vehicle_id = p1; @@ -1071,7 +1071,7 @@ CommandCost CmdVirtualTrainFromTemplateVehicle(TileIndex tile, DoCommandFlag fla return CommandCost(); } -CommandCost CmdDeleteVirtualTrain(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text); +CommandCost CmdDeleteVirtualTrain(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text); template void UpdateNewVirtualTrainFromSource(Train *v, const T *src) @@ -1113,7 +1113,7 @@ void UpdateNewVirtualTrainFromSource(Train *v, const T *src) InvalidateVehicleTickCaches(); } -Train* VirtualTrainFromTemplateVehicle(const TemplateVehicle* tv, StringID &err, uint32 user) +Train* VirtualTrainFromTemplateVehicle(const TemplateVehicle* tv, StringID &err, uint32_t user) { CommandCost c; Train *tmp, *head, *tail; @@ -1162,7 +1162,7 @@ Train* VirtualTrainFromTemplateVehicle(const TemplateVehicle* tv, StringID &err, * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdVirtualTrainFromTrain(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdVirtualTrainFromTrain(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID vehicle_id = p1; Vehicle* vehicle = Vehicle::GetIfValid(vehicle_id); @@ -1217,7 +1217,7 @@ CommandCost CmdVirtualTrainFromTrain(TileIndex tile, DoCommandFlag flags, uint32 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdDeleteVirtualTrain(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdDeleteVirtualTrain(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID vehicle_id = p1; @@ -1254,7 +1254,7 @@ CommandCost CmdDeleteVirtualTrain(TileIndex tile, DoCommandFlag flags, uint32 p1 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdReplaceTemplateVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdReplaceTemplateVehicle(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { VehicleID template_vehicle_id = p1; VehicleID virtual_train_id = p2; @@ -1348,7 +1348,7 @@ CommandCost CmdReplaceTemplateVehicle(TileIndex tile, DoCommandFlag flags, uint3 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdTemplateVehicleFromTrain(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdTemplateVehicleFromTrain(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { // create a new template from the clicked vehicle TemplateVehicle *tv; @@ -1403,7 +1403,7 @@ CommandCost CmdTemplateVehicleFromTrain(TileIndex tile, DoCommandFlag flags, uin * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdDeleteTemplateVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdDeleteTemplateVehicle(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { // Identify template to delete TemplateVehicle *del = TemplateVehicle::GetIfValid(p1); @@ -1440,7 +1440,7 @@ CommandCost CmdDeleteTemplateVehicle(TileIndex tile, DoCommandFlag flags, uint32 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdIssueTemplateReplacement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdIssueTemplateReplacement(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { bool should_execute = (flags & DC_EXEC) != 0; @@ -1469,7 +1469,7 @@ CommandCost CmdIssueTemplateReplacement(TileIndex tile, DoCommandFlag flags, uin * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdDeleteTemplateReplacement(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdDeleteTemplateReplacement(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { bool should_execute = (flags & DC_EXEC) != 0; @@ -1497,7 +1497,7 @@ CommandCost CmdDeleteTemplateReplacement(TileIndex tile, DoCommandFlag flags, ui * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { CommandCost total_cost(EXPENSES_NEW_VEHICLES); @@ -1685,7 +1685,7 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdCloneVehicleFromTemplate(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdCloneVehicleFromTemplate(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { TemplateVehicle* tv = TemplateVehicle::GetIfValid(p1); @@ -1762,13 +1762,13 @@ static CommandCost SendAllVehiclesToDepot(DoCommandFlag flags, DepotCommand depo * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdSendVehicleToDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSendVehicleToDepot(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (p1 & DEPOT_MASS_SEND) { /* Mass goto depot requested */ VehicleListIdentifier vli; if (!vli.UnpackIfValid(p2)) return CMD_ERROR; - uint32 depot_flags = (p1 & (DEPOT_SERVICE | DEPOT_CANCEL | DEPOT_SELL)); + uint32_t depot_flags = (p1 & (DEPOT_SERVICE | DEPOT_CANCEL | DEPOT_SELL)); if (!(p1 & DEPOT_CANCEL)) depot_flags |= DEPOT_DONT_CANCEL; return SendAllVehiclesToDepot(flags, (DepotCommand) depot_flags, vli, GB(p1, 0, 8)); } @@ -1789,7 +1789,7 @@ CommandCost CmdSendVehicleToDepot(TileIndex tile, DoCommandFlag flags, uint32 p1 * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdSetVehicleUnitNumber(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSetVehicleUnitNumber(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Vehicle *v = Vehicle::GetIfValid(p1); if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR; @@ -1813,7 +1813,7 @@ CommandCost CmdSetVehicleUnitNumber(TileIndex tile, DoCommandFlag flags, uint32 * @param text the new name or an empty string when resetting to the default * @return the cost of this operation or an error */ -CommandCost CmdRenameVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRenameVehicle(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Vehicle *v = Vehicle::GetIfValid(p1); if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR; @@ -1855,7 +1855,7 @@ CommandCost CmdRenameVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uin * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdChangeServiceInt(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdChangeServiceInt(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Vehicle *v = Vehicle::GetIfValid(p1); if (v == nullptr || !v->IsPrimaryVehicle()) return CMD_ERROR; @@ -1867,7 +1867,7 @@ CommandCost CmdChangeServiceInt(TileIndex tile, DoCommandFlag flags, uint32 p1, bool iscustom = HasBit(p2, 16); bool ispercent = iscustom ? HasBit(p2, 17) : company->settings.vehicle.servint_ispercent; - uint16 serv_int; + uint16_t serv_int; if (iscustom) { serv_int = GB(p2, 0, 16); if (serv_int != GetServiceIntervalClamped(serv_int, ispercent)) return CMD_ERROR; diff --git a/src/vehicle_func.h b/src/vehicle_func.h index d002844be4..269829990b 100644 --- a/src/vehicle_func.h +++ b/src/vehicle_func.h @@ -38,7 +38,7 @@ struct Viewport; * @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); @@ -118,8 +118,8 @@ inline bool HasVehicleOnPosXY(int x, int y, VehicleType type, void *data, Vehicl } void CallVehicleTicks(); -uint8 CalcPercentVehicleFilled(const Vehicle *v, StringID *colour); -uint8 CalcPercentVehicleFilledOfCargo(const Vehicle *v, CargoID cargo); +uint8_t CalcPercentVehicleFilled(const Vehicle *v, StringID *colour); +uint8_t CalcPercentVehicleFilledOfCargo(const Vehicle *v, CargoID cargo); void VehicleLengthChanged(const Vehicle *u); @@ -199,48 +199,48 @@ SpriteID GetEnginePalette(EngineID engine_type, CompanyID company); SpriteID GetVehiclePalette(const Vehicle *v); SpriteID GetUncachedTrainPaletteIgnoringGroup(const Train *v); -extern const uint32 _veh_build_proc_table[]; -extern const uint32 _veh_sell_proc_table[]; -extern const uint32 _veh_refit_proc_table[]; -extern const uint32 _send_to_depot_proc_table[]; +extern const uint32_t _veh_build_proc_table[]; +extern const uint32_t _veh_sell_proc_table[]; +extern const uint32_t _veh_refit_proc_table[]; +extern const uint32_t _send_to_depot_proc_table[]; /* Functions to find the right command for certain vehicle type */ -inline uint32 GetCmdBuildVeh(VehicleType type) +inline uint32_t GetCmdBuildVeh(VehicleType type) { return _veh_build_proc_table[type]; } -inline uint32 GetCmdBuildVeh(const BaseVehicle *v) +inline uint32_t GetCmdBuildVeh(const BaseVehicle *v) { return GetCmdBuildVeh(v->type); } -inline uint32 GetCmdSellVeh(VehicleType type) +inline uint32_t GetCmdSellVeh(VehicleType type) { return _veh_sell_proc_table[type]; } -inline uint32 GetCmdSellVeh(const BaseVehicle *v) +inline uint32_t GetCmdSellVeh(const BaseVehicle *v) { return GetCmdSellVeh(v->type); } -inline uint32 GetCmdRefitVeh(VehicleType type) +inline uint32_t GetCmdRefitVeh(VehicleType type) { return _veh_refit_proc_table[type]; } -inline uint32 GetCmdRefitVeh(const BaseVehicle *v) +inline uint32_t GetCmdRefitVeh(const BaseVehicle *v) { return GetCmdRefitVeh(v->type); } -inline uint32 GetCmdSendToDepot(VehicleType type) +inline uint32_t GetCmdSendToDepot(VehicleType type) { return _send_to_depot_proc_table[type]; } -inline uint32 GetCmdSendToDepot(const BaseVehicle *v) +inline uint32_t GetCmdSendToDepot(const BaseVehicle *v) { return GetCmdSendToDepot(v->type); } @@ -251,7 +251,7 @@ CommandCost EnsureNoTrainOnTrackBits(TileIndex tile, TrackBits track_bits); extern VehicleID _new_vehicle_id; extern uint _returned_refit_capacity; -extern uint16 _returned_mail_refit_capacity; +extern uint16_t _returned_mail_refit_capacity; extern CargoArray _returned_vehicle_capacities; bool CanVehicleUseStation(EngineID engine_type, const struct Station *st); @@ -261,7 +261,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 fe910167e3..e46746f3d8 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -699,7 +699,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. bool is_virtual_train; ///< TemplateReplacement, whether the selected vehicle is virtual mutable std::map ship_part_names; ///< Ship part name strings @@ -990,7 +990,7 @@ struct RefitWindow : public Window { const Vehicle *front = v->First(); uint offset = 0; for (const Vehicle *u = front; u != v; u = u->Next()) offset++; - uint16 callback = GetVehicleCallback(XCBID_SHIP_REFIT_PART_NAME, offset, 0, front->engine_type, front); + uint16_t callback = GetVehicleCallback(XCBID_SHIP_REFIT_PART_NAME, offset, 0, front->engine_type, front); if (callback != CALLBACK_FAILED && callback < 0x400) { const GRFFile *grffile = v->GetGRF(); assert(grffile != nullptr); @@ -1465,7 +1465,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; @@ -1551,14 +1551,14 @@ static bool VehicleProfitThisYearSorter(const Vehicle * const &a, const Vehicle /** Sort vehicles by last year profit */ static bool VehicleProfitLastYearSorter(const Vehicle * const &a, const Vehicle * const &b) { - int r = ClampTo(a->GetDisplayProfitLastYear() - b->GetDisplayProfitLastYear()); + int r = ClampTo(a->GetDisplayProfitLastYear() - b->GetDisplayProfitLastYear()); return (r != 0) ? r < 0 : VehicleNumberSorter(a, b); } /** Sort vehicles by lifetime profit */ static bool VehicleProfitLifetimeSorter(const Vehicle * const &a, const Vehicle * const &b) { - int r = ClampTo(a->GetDisplayProfitLifetime() - b->GetDisplayProfitLifetime()); + int r = ClampTo(a->GetDisplayProfitLifetime() - b->GetDisplayProfitLifetime()); return (r != 0) ? r < 0 : VehicleNumberSorter(a, b); } @@ -1973,7 +1973,7 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int } case VST_AVERAGE_ORDER_OCCUPANCY: { - uint8 occupancy_average = v->GetOrderOccupancyAverage(); + uint8_t occupancy_average = v->GetOrderOccupancyAverage(); if (occupancy_average >= 16) { str = STR_VEHICLE_LIST_ORDER_OCCUPANCY_AVERAGE; SetDParam(3, occupancy_average - 16); @@ -2112,7 +2112,7 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int void BaseVehicleListWindow::UpdateSortingInterval() { - uint16 resort_interval = DAY_TICKS * 10; + uint16_t resort_interval = DAY_TICKS * 10; if (this->grouping == GB_NONE && this->vehgroups.SortType() == VST_TIMETABLE_DELAY) resort_interval = DAY_TICKS; this->vehgroups.SetResortInterval(resort_interval); } @@ -2660,7 +2660,7 @@ static WindowDesc _vehicle_list_train_desc(__FILE__, __LINE__, std::begin(_nested_vehicle_list), std::end(_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; @@ -2699,7 +2699,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); @@ -2814,7 +2814,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); @@ -3166,8 +3166,8 @@ struct VehicleDetailsWindow : Window { byte total_engines = 0; if (v->type == VEH_TRAIN) { /* we want to draw the average reliability and total number of breakdowns */ - uint32 total_reliability = 0; - uint16 total_breakdowns = 0; + uint32_t total_reliability = 0; + uint16_t total_breakdowns = 0; for (const Vehicle *w = v; w != nullptr; w = w->Next()) { if (Train::From(w)->IsEngine() || Train::From(w)->IsMultiheaded()) { total_reliability += w->reliability; @@ -3335,7 +3335,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); DoCommandP(v->tile, v->index, interval | (iscustom << 16) | (ispercent << 17), CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_ERROR_CAN_T_CHANGE_SERVICING)); break; } @@ -3469,7 +3469,7 @@ enum VehicleCommandTranslation { }; /** Command codes for the shared buttons indexed by VehicleCommandTranslation and vehicle type. */ -static const uint32 _vehicle_command_translation_table[][4] = { +static const uint32_t _vehicle_command_translation_table[][4] = { { // VCT_CMD_START_STOP CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_TRAIN), CMD_START_STOP_VEHICLE | CMD_MSG(STR_ERROR_CAN_T_STOP_START_ROAD_VEHICLE), @@ -3497,7 +3497,7 @@ static const uint32 _vehicle_command_translation_table[][4] = { * @param p1 vehicle ID * @param p2 unused */ -void CcStartStopVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcStartStopVehicle(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; @@ -3763,7 +3763,7 @@ public: } else if (w->breakdown_type == BREAKDOWN_LOW_POWER) { int percent; if (v->type == VEH_TRAIN) { - uint32 power, te; + uint32_t power, te; Train::From(v)->CalculatePower(power, te, true); percent = (100 * power) / Train::From(v)->gcache.cached_power; } else { @@ -4286,7 +4286,7 @@ void StopGlobalFollowVehicle(const Vehicle *v) * @param p2 unused * @param cmd unused */ -void CcBuildPrimaryVehicle(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint64 p3, uint32 cmd) +void CcBuildPrimaryVehicle(const CommandCost &result, TileIndex tile, uint32_t p1, uint32_t p2, uint64_t p3, uint32_t cmd) { if (result.Failed()) return; diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h index 91082957ba..5207ecef8e 100644 --- a/src/vehicle_gui.h +++ b/src/vehicle_gui.h @@ -39,10 +39,10 @@ enum VehicleInvalidateWindowData { /** Extra information about refitted cargo and capacity */ struct TestedEngineDetails { - Money cost; ///< Refit cost - CargoID cargo; ///< Cargo type - uint capacity; ///< Cargo capacity - uint16 mail_capacity; ///< Mail capacity if available + Money cost; ///< Refit cost + CargoID cargo; ///< Cargo type + uint capacity; ///< Cargo capacity + uint16_t mail_capacity; ///< Mail capacity if available CargoArray all_capacities{}; ///< Capacities for all cargoes void FillDefaultCapacities(const Engine *e); @@ -146,7 +146,7 @@ inline bool HasFocusedVehicleChanged(const VehicleID vid, Window *ref_window) case WC_VEHICLE_VIEW: case WC_VEHICLE_CARGO_TYPE_LOAD_ORDERS: case WC_VEHICLE_CARGO_TYPE_UNLOAD_ORDERS: - return ((uint32) wn != vid); + return ((uint32_t) wn != vid); } } diff --git a/src/vehicle_type.h b/src/vehicle_type.h index 137f8d3996..3e35f579f5 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 @@ -124,6 +124,6 @@ enum EngineImageType { EIT_PREVIEW = 0x21, ///< Vehicle drawn in preview window, news, ... }; -static const uint32 VEHICLE_NAME_NO_GROUP = 0x80000000; ///< String constant to not include the vehicle's group name, if using the long name format +static const uint32_t VEHICLE_NAME_NO_GROUP = 0x80000000; ///< String constant to not include the vehicle's group name, if using the long name format #endif /* VEHICLE_TYPE_H */ diff --git a/src/vehiclelist.cpp b/src/vehiclelist.cpp index cacfcba88b..8256dd6e38 100644 --- a/src/vehiclelist.cpp +++ b/src/vehiclelist.cpp @@ -20,7 +20,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)); @@ -37,7 +37,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; @@ -52,7 +52,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 866f4eb632..8d50ac6b54 100644 --- a/src/vehiclelist.h +++ b/src/vehiclelist.h @@ -33,11 +33,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); /** * Create a simple vehicle list. diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp index ecae4200a7..0e1349ff93 100644 --- a/src/video/allegro_v.cpp +++ b/src/video/allegro_v.cpp @@ -245,7 +245,7 @@ std::vector VideoDriver_Allegro::GetListOfMonitorRefreshRates() } struct AllegroVkMapping { - uint16 vk_from; + uint16_t vk_from; byte vk_count; byte map_to; }; @@ -306,7 +306,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); @@ -406,7 +406,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_v.h b/src/video/cocoa/cocoa_v.h index ca23b6fd6a..2244f99204 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 86d7e4adbf..12cd6299c3 100644 --- a/src/video/cocoa/cocoa_v.mm +++ b/src/video/cocoa/cocoa_v.mm @@ -567,11 +567,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; } } @@ -645,14 +645,14 @@ void VideoDriver_CocoaQuartz::AllocateBackingStore(bool) 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( @@ -700,9 +700,9 @@ void VideoDriver_CocoaQuartz::AllocateBackingStore(bool) */ 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; @@ -719,10 +719,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)_cur_palette.palette[i].r << 16; - clr |= (uint32)_cur_palette.palette[i].g << 8; - clr |= (uint32)_cur_palette.palette[i].b; + uint32_t clr = 0xff000000; + clr |= (uint32_t)_cur_palette.palette[i].r << 16; + clr |= (uint32_t)_cur_palette.palette[i].g << 8; + clr |= (uint32_t)_cur_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 57c7c8bd8c..c1e14b3b79 100644 --- a/src/video/cocoa/cocoa_wnd.mm +++ b/src/video/cocoa/cocoa_wnd.mm @@ -109,7 +109,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; @@ -127,7 +127,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; @@ -141,9 +141,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++) { @@ -164,7 +164,7 @@ static std::vector NSStringToUTF32(NSString *s) #ifdef HAVE_TOUCHBAR_SUPPORT static void CGDataFreeCallback(void *, const void *data, size_t) { - delete[] (const uint32 *)data; + delete[] (const uint32_t *)data; } /** @@ -179,7 +179,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)); @@ -678,7 +678,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; @@ -784,7 +784,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; @@ -817,7 +817,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); @@ -865,7 +865,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()) { @@ -894,7 +894,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 d7c9c8ec3a..13a12a6ce7 100644 --- a/src/video/opengl.cpp +++ b/src/video/opengl.cpp @@ -943,7 +943,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) { @@ -1176,7 +1176,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; @@ -1192,7 +1192,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; } /** @@ -1375,7 +1375,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. */ @@ -1479,7 +1479,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); @@ -1504,7 +1504,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 921247cd30..36e8794f21 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_v.cpp b/src/video/sdl2_v.cpp index 0e5fe930f0..ff7f7ebd12 100644 --- a/src/video/sdl2_v.cpp +++ b/src/video/sdl2_v.cpp @@ -107,7 +107,7 @@ static DBusHandlerResult FcitxDBusMessageFilter(DBusConnection *connection, DBus if (dbus_message_is_signal(message, "org.fcitx.Fcitx.InputContext", "UpdatePreedit")) { const char *text = nullptr; - int32 cursor; + int32_t cursor; if (!dbus_message_get_args(message, nullptr, DBUS_TYPE_STRING, &text, DBUS_TYPE_INT32, &cursor, DBUS_TYPE_INVALID)) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; if (text != nullptr && EditBoxInGlobalFocus()) { @@ -136,7 +136,7 @@ static void FcitxInit() int pid = getpid(); int id = -1; - uint32 enable, hk1sym, hk1state, hk2sym, hk2state; + uint32_t enable, hk1sym, hk1state, hk2sym, hk2state; DBusMessage *msg = dbus_message_new_method_call(_fcitx_service_name, "/inputmethod", "org.fcitx.Fcitx.InputMethod", "CreateICv3"); if (!msg) return; auto guard1 = scope_guard([&]() { @@ -158,7 +158,7 @@ static void FcitxInit() dbus_connection_add_filter(_fcitx_dbus_session_conn, &FcitxDBusMessageFilter, nullptr, nullptr); dbus_connection_flush(_fcitx_dbus_session_conn); - uint32 caps = CAPACITY_PREEDIT; + uint32_t caps = CAPACITY_PREEDIT; DBusMessage *msg2 = dbus_message_new_method_call(_fcitx_service_name, _fcitx_ic_name, "org.fcitx.Fcitx.InputContext", "SetCapacity"); if (!msg2) return; auto guard3 = scope_guard([&]() { @@ -174,12 +174,12 @@ static void FcitxInit() _fcitx_mode = true; } -static uint32 _fcitx_last_keycode = 0; -static uint32 _fcitx_last_keysym = 0; -static uint16 _last_sdl_key_mod; +static uint32_t _fcitx_last_keycode = 0; +static uint32_t _fcitx_last_keysym = 0; +static uint16_t _last_sdl_key_mod; static bool FcitxProcessKey() { - uint32 fcitx_mods = 0; + uint32_t fcitx_mods = 0; if (_last_sdl_key_mod & KMOD_SHIFT) fcitx_mods |= FcitxKeyState_Shift; if (_last_sdl_key_mod & KMOD_CAPS) fcitx_mods |= FcitxKeyState_CapsLock; if (_last_sdl_key_mod & KMOD_CTRL) fcitx_mods |= FcitxKeyState_Ctrl; @@ -189,7 +189,7 @@ static bool FcitxProcessKey() if (_last_sdl_key_mod & KMOD_RGUI) fcitx_mods |= FcitxKeyState_Meta; int type = FCITX_PRESS_KEY; - uint32 event_time = 0; + uint32_t event_time = 0; DBusMessage *msg = dbus_message_new_method_call(_fcitx_service_name, _fcitx_ic_name, "org.fcitx.Fcitx.InputContext", "ProcessKeyEvent"); if (!msg) return false; @@ -203,7 +203,7 @@ static bool FcitxProcessKey() auto guard2 = scope_guard([&]() { dbus_message_unref(reply); }); - uint32 handled = 0; + uint32_t handled = 0; if (!dbus_message_get_args(reply, nullptr, DBUS_TYPE_INT32, &handled, DBUS_TYPE_INVALID)) return false; return handled; } @@ -387,7 +387,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); @@ -581,7 +581,7 @@ static const SDLVkMapping _vk_mapping[] = { AS(SDLK_HASH, WKC_HASH), }; -static uint ConvertSdlKeyIntoMy(SDL_Keysym *sym, WChar *character) +static uint ConvertSdlKeyIntoMy(SDL_Keysym *sym, char32_t *character) { const SDLVkMapping *map; uint key = 0; @@ -736,7 +736,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 @@ -768,7 +768,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 { @@ -913,7 +913,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 878ecc4872..030251348e 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -245,7 +245,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); @@ -378,7 +378,7 @@ bool VideoDriver_SDL::ClaimMousePointer() } struct SDLVkMapping { - uint16 vk_from; + uint16_t vk_from; byte vk_count; byte map_to; }; @@ -439,7 +439,7 @@ static const SDLVkMapping _vk_mapping[] = { AS(SDLK_HASH, WKC_HASH), }; -static uint ConvertSdlKeyIntoMy(SDL_keysym *sym, WChar *character) +static uint ConvertSdlKeyIntoMy(SDL_keysym *sym, char32_t *character) { const SDLVkMapping *map; uint key = 0; @@ -559,7 +559,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); } @@ -633,7 +633,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 b454c54e35..ace8f61b9c 100644 --- a/src/video/video_driver.hpp +++ b/src/video/video_driver.hpp @@ -142,7 +142,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. */ - inline uint8 *GetAnimBuffer() + inline uint8_t *GetAnimBuffer() { return this->anim_buffer; } @@ -361,7 +361,7 @@ protected: std::recursive_mutex game_state_mutex; std::mutex game_thread_wait_mutex; - uint8 *anim_buffer = nullptr; ///< Animation buffer, (not used by all drivers, here because it is accessed very frequently) + uint8_t *anim_buffer = nullptr; ///< Animation buffer, (not used by all drivers, here because it is accessed very frequently) static void GameThreadThunk(VideoDriver *drv); diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 01cf02b3f7..58585860b8 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -124,7 +124,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(); @@ -241,9 +241,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)) { @@ -401,7 +401,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); @@ -473,8 +473,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 @@ -494,8 +494,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); } } @@ -795,7 +795,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 316dc1ea15..d0a70cfd4d 100644 --- a/src/video/win32_v.h +++ b/src/video/win32_v.h @@ -61,7 +61,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. */ @@ -149,7 +149,7 @@ protected: HGLRC gl_rc; ///< OpenGL context. 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 124a020c0a..18a2e37f0c 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -147,26 +147,26 @@ static const int MAX_TILE_EXTENT_BOTTOM = ZOOM_LVL_BASE * (TILE_PIXELS + 2 * TIL struct StringSpriteToDraw { StringID string; Colours colour; - int32 x; - int32 y; - uint64 params[2]; - uint16 width; + int32_t x; + int32_t y; + uint64_t params[2]; + 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; ChildScreenSpritePositionMode position_mode; int next; ///< next child to draw (-1 at the end) }; @@ -205,7 +205,7 @@ enum RailSnapMode { * allowed line directions. */ struct LineSnapPoint : Point { - uint8 dirs; ///< Allowed line directions, set of #Direction bits. + uint8_t dirs; ///< Allowed line directions, set of #Direction bits. }; typedef std::vector LineSnapPoints; ///< Set of snapping points @@ -222,7 +222,7 @@ struct PolylineInfo { struct TunnelToMap { TunnelBridgeToMap tb; int y_intercept; - uint8 tunnel_z; + uint8_t tunnel_z; }; struct TunnelToMapStorage { std::vector tunnels; @@ -282,7 +282,7 @@ struct ViewportDrawerDynamic { btree::btree_map bridge_to_map_x; btree::btree_map bridge_to_map_y; - uint8 display_flags; + uint8_t display_flags; std::atomic draw_jobs_active; @@ -421,7 +421,7 @@ enum ViewportDebugFlags { VDF_DISABLE_LANDSCAPE_CACHE, VDF_DISABLE_THREAD, }; -uint32 _viewport_debug_flags; +uint32_t _viewport_debug_flags; static Point MapXYZToViewport(const Viewport *vp, int x, int y, int z) { @@ -507,7 +507,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); @@ -929,7 +929,7 @@ void HandleZoomMessage(Window *w, const Viewport *vp, WidgetID widget_zoom_in, W * @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) { dbg_assert((image & SPRITE_MASK) < MAX_SPRITES); @@ -983,7 +983,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; @@ -1099,7 +1099,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; dbg_assert((image & SPRITE_MASK) < MAX_SPRITES); @@ -1118,7 +1118,7 @@ void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w, Point pt = RemapCoords(x, y, z); int tmp_left, tmp_top, tmp_x = pt.x, tmp_y = pt.y; - uint16 tmp_width, tmp_height; + uint16_t tmp_width, tmp_height; /* Compute screen extents of sprite */ if (unlikely(image == SPR_EMPTY_BOUNDING_BOX)) { @@ -1313,7 +1313,7 @@ void AddChildSpriteScreen(SpriteID image, PaletteID pal, int x, int y, bool tran _vd.last_child = &cs.next; } -static void AddStringToDraw(ViewportDrawerDynamic *vdd, int x, int y, StringID string, uint64 params_1, uint64 params_2, Colours colour, uint16 width) +static void AddStringToDraw(ViewportDrawerDynamic *vdd, int x, int y, StringID string, uint64_t params_1, uint64_t params_2, Colours colour, uint16_t width) { dbg_assert(width != 0); StringSpriteToDraw &ss = vdd->string_sprites_to_draw.emplace_back(); @@ -1790,7 +1790,7 @@ static void ViewportAddLandscape() * @param string_small_shadow Shadow string for 4x and 8x zoom level; or #STR_NULL if no shadow * @param colour colour of the sign background; or INVALID_COLOUR if transparent */ -void ViewportAddString(ViewportDrawerDynamic *vdd, const DrawPixelInfo *dpi, ZoomLevel small_from, const ViewportSign *sign, StringID string_normal, StringID string_small, StringID string_small_shadow, uint64 params_1, uint64 params_2, Colours colour) +void ViewportAddString(ViewportDrawerDynamic *vdd, const DrawPixelInfo *dpi, ZoomLevel small_from, const ViewportSign *sign, StringID string_normal, StringID string_small, StringID string_small_shadow, uint64_t params_1, uint64_t params_2, Colours colour) { bool small = dpi->zoom >= small_from; @@ -2260,7 +2260,7 @@ void ViewportDrawDirtyBlocks(const DrawPixelInfo *dpi, bool increment_colour) 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); } @@ -2760,13 +2760,13 @@ void ViewportDrawPlans(const Viewport *vp) #define GET_SLOPE_INDEX(slope_index) SLOPIFY_COLOUR(tile, nullptr, 0, 1, 2, 3, 4, slope_index =) #define COL8TO32(x) _cur_palette.palette[x].data -#define COLOUR_FROM_INDEX(x) ((const uint8 *)&(x))[colour_index] +#define COLOUR_FROM_INDEX(x) ((const uint8_t *)&(x))[colour_index] #define IS32(x) (is_32bpp ? COL8TO32(x) : (x)) /* Variables containing Colour if 32bpp or palette index if 8bpp. */ -uint32 _vp_map_vegetation_clear_colours[16][6][8]; ///< [Slope][ClearGround][Multi (see LoadClearGroundMainColours())] -uint32 _vp_map_vegetation_tree_colours[16][5][MAX_TREE_COUNT_BY_LANDSCAPE]; ///< [Slope][TreeGround][max of _tree_count_by_landscape] -uint32 _vp_map_water_colour[5]; ///< [Slope] +uint32_t _vp_map_vegetation_clear_colours[16][6][8]; ///< [Slope][ClearGround][Multi (see LoadClearGroundMainColours())] +uint32_t _vp_map_vegetation_tree_colours[16][5][MAX_TREE_COUNT_BY_LANDSCAPE]; ///< [Slope][TreeGround][max of _tree_count_by_landscape] +uint32_t _vp_map_water_colour[5]; ///< [Slope] static inline uint ViewportMapGetColourIndexMulti(const TileIndex tile, const ClearGround cg) { @@ -2794,12 +2794,12 @@ static const ClearGround _treeground_to_clearground[5] = { }; template -static inline uint32 ViewportMapGetColourVegetationTree(const TileIndex tile, const TreeGround tg, const uint td, const uint tc, const uint colour_index, Slope slope) +static inline uint32_t ViewportMapGetColourVegetationTree(const TileIndex tile, const TreeGround tg, const uint td, const uint tc, const uint colour_index, Slope slope) { if (IsTransparencySet(TO_TREES)) { ClearGround cg = _treeground_to_clearground[tg]; if (cg == CLEAR_SNOW && _settings_game.game_creation.landscape == LT_TROPIC) cg = CLEAR_DESERT; - uint32 ground_colour = _vp_map_vegetation_clear_colours[slope][cg][td]; + uint32_t ground_colour = _vp_map_vegetation_clear_colours[slope][cg][td]; if (IsInvisibilitySet(TO_TREES)) { /* Like ground. */ @@ -2824,7 +2824,7 @@ static inline uint32 ViewportMapGetColourVegetationTree(const TileIndex tile, co } } -static bool ViewportMapGetColourVegetationCustomObject(uint32 &colour, const TileIndex tile, const uint colour_index, bool is_32bpp, bool show_slope) +static bool ViewportMapGetColourVegetationCustomObject(uint32_t &colour, const TileIndex tile, const uint colour_index, bool is_32bpp, bool show_slope) { ObjectViewportMapType vmtype = OVMT_DEFAULT; const ObjectSpec *spec = ObjectSpec::GetByTile(tile); @@ -2921,9 +2921,9 @@ static bool ViewportMapGetColourVegetationCustomObject(uint32 &colour, const Til } template -static inline uint32 ViewportMapGetColourVegetation(const TileIndex tile, TileType t, const uint colour_index) +static inline uint32_t ViewportMapGetColourVegetation(const TileIndex tile, TileType t, const uint colour_index) { - uint32 colour; + uint32_t colour; auto set_default_colour = [&](TileType ttype) { colour = ApplyMask(MKCOLOUR_XXXX(GREY_SCALE(3)), &_smallmap_vehicles_andor[ttype]); @@ -2987,7 +2987,7 @@ static inline uint32 ViewportMapGetColourVegetation(const TileIndex tile, TileTy } template -static inline uint32 ViewportMapGetColourIndustries(const TileIndex tile, const TileType t, const uint colour_index) +static inline uint32_t ViewportMapGetColourIndustries(const TileIndex tile, const TileType t, const uint colour_index) { extern LegendAndColour _legend_from_industries[NUM_INDUSTRYTYPES + 1]; extern uint _industry_to_list_pos[NUM_INDUSTRYTYPES]; @@ -3041,8 +3041,8 @@ static inline uint32 ViewportMapGetColourIndustries(const TileIndex tile, const const int h = TileHeight(tile); const SmallMapColourScheme * const cs = &_heightmap_schemes[_settings_client.gui.smallmap_land_colour]; - const uint32 colours = ApplyMask(_settings_client.gui.show_height_on_viewport_map ? cs->height_colours[h] : cs->default_colour, &_smallmap_vehicles_andor[t2]); - uint32 colour = COLOUR_FROM_INDEX(colours); + const uint32_t colours = ApplyMask(_settings_client.gui.show_height_on_viewport_map ? cs->height_colours[h] : cs->default_colour, &_smallmap_vehicles_andor[t2]); + uint32_t colour = COLOUR_FROM_INDEX(colours); if (show_slope) ASSIGN_SLOPIFIED_COLOUR(tile, nullptr, colour, _lighten_colour[colour], _darken_colour[colour], colour); @@ -3050,7 +3050,7 @@ static inline uint32 ViewportMapGetColourIndustries(const TileIndex tile, const } template -static inline uint32 ViewportMapGetColourOwner(const TileIndex tile, TileType t, const uint colour_index) +static inline uint32_t ViewportMapGetColourOwner(const TileIndex tile, TileType t, const uint colour_index) { extern LegendAndColour _legend_land_owners[NUM_NO_COMPANY_ENTRIES + MAX_COMPANIES + 1]; extern uint _company_to_list_pos[MAX_COMPANIES]; @@ -3076,7 +3076,7 @@ static inline uint32 ViewportMapGetColourOwner(const TileIndex tile, TileType t, } const SmallMapColourScheme * const cs = &_heightmap_schemes[_settings_client.gui.smallmap_land_colour]; - uint32 colour = COLOUR_FROM_INDEX(_settings_client.gui.show_height_on_viewport_map ? cs->height_colours[TileHeight(tile)] : cs->default_colour); + uint32_t colour = COLOUR_FROM_INDEX(_settings_client.gui.show_height_on_viewport_map ? cs->height_colours[TileHeight(tile)] : cs->default_colour); if (show_slope) ASSIGN_SLOPIFIED_COLOUR(tile, nullptr, colour, _lighten_colour[colour], _darken_colour[colour], colour); return IS32(colour); @@ -3086,7 +3086,7 @@ static inline uint32 ViewportMapGetColourOwner(const TileIndex tile, TileType t, /* Train stations are sometimes hard to spot. * So we give the player a hint by mixing his colour with black. */ - uint32 colour = _legend_land_owners[_company_to_list_pos[o]].colour; + uint32_t colour = _legend_land_owners[_company_to_list_pos[o]].colour; if (t != MP_STATION) { if (show_slope) ASSIGN_SLOPIFIED_COLOUR(tile, nullptr, colour, _lighten_colour[colour], _darken_colour[colour], colour); } else { @@ -3097,9 +3097,9 @@ static inline uint32 ViewportMapGetColourOwner(const TileIndex tile, TileType t, } template -static inline uint32 ViewportMapGetColourRoutes(const TileIndex tile, TileType t, const uint colour_index) +static inline uint32_t ViewportMapGetColourRoutes(const TileIndex tile, TileType t, const uint colour_index) { - uint32 colour; + uint32_t colour; switch (t) { case MP_WATER: @@ -3227,7 +3227,7 @@ static inline TileIndex ViewportMapGetMostSignificantTileType(const Viewport * c return from_tile; } - const uint8 length = (vp->zoom - ZOOM_LVL_OUT_128X) * 2; + const uint8_t length = (vp->zoom - ZOOM_LVL_OUT_128X) * 2; TileArea tile_area = TileArea(from_tile, length, length); tile_area.ClampToMap(); @@ -3262,14 +3262,14 @@ static inline TileIndex ViewportMapGetMostSignificantTileType(const Viewport * c return result; } -static uint32 ViewportMapVoidColour() +static uint32_t ViewportMapVoidColour() { return (_settings_game.construction.map_edge_mode == 2) ? _vp_map_water_colour[SLOPE_FLAT] : 0; } /** Get the colour of a tile, can be 32bpp RGB or 8bpp palette index. */ template -uint32 ViewportMapGetColour(const Viewport * const vp, int x, int y, const uint colour_index) +uint32_t ViewportMapGetColour(const Viewport * const vp, int x, int y, const uint colour_index) { if (x >= static_cast(MapMaxX() * TILE_SIZE) || y >= static_cast(MapMaxY() * TILE_SIZE)) return ViewportMapVoidColour(); @@ -3306,25 +3306,25 @@ uint32 ViewportMapGetColour(const Viewport * const vp, int x, int y, const uint } /* Taken from http://stereopsis.com/doubleblend.html, PixelBlend() is faster than ComposeColourRGBANoCheck() */ -static inline void PixelBlend(uint32 * const d, const uint32 s) +static inline void PixelBlend(uint32_t * const d, const uint32_t s) { #if defined(__EMSCRIPTEN__) *d = Blitter_32bppBase::ComposeColourRGBANoCheck(s & 0xFF, (s >> 8) & 0xFF, (s >> 16) & 0xFF, (s >> 24) & 0xFF, Colour(*d)).data; return; #endif - const uint32 a = (s >> 24) + 1; - const uint32 dstrb = *d & 0xFF00FF; - const uint32 dstg = *d & 0xFF00; - const uint32 srcrb = s & 0xFF00FF; - const uint32 srcg = s & 0xFF00; - uint32 drb = srcrb - dstrb; - uint32 dg = srcg - dstg; + const uint32_t a = (s >> 24) + 1; + const uint32_t dstrb = *d & 0xFF00FF; + const uint32_t dstg = *d & 0xFF00; + const uint32_t srcrb = s & 0xFF00FF; + const uint32_t srcg = s & 0xFF00; + uint32_t drb = srcrb - dstrb; + uint32_t dg = srcg - dstg; drb *= a; dg *= a; drb >>= 8; dg >>= 8; - uint32 rb = (drb + dstrb) & 0xFF00FF; - uint32 g = (dg + dstg) & 0xFF00; + uint32_t rb = (drb + dstrb) & 0xFF00FF; + uint32_t g = (dg + dstg) & 0xFF00; *d = rb | g; } @@ -3353,7 +3353,7 @@ static void ViewportMapDrawScrollingViewportBox(const Viewport * const vp) /* If asked, with 32bpp we can do some blending */ if (_settings_client.gui.show_scrolling_viewport_on_map >= 2 && blitter->GetScreenDepth() == 32) { for (int j = t_inter; j < b_inter; j++) { - uint32 *buf = (uint32*) blitter->MoveTo(_vdd->dpi.dst_ptr, 0, j); + uint32_t *buf = (uint32_t*) blitter->MoveTo(_vdd->dpi.dst_ptr, 0, j); for (int i = l_inter; i < r_inter; i++) { PixelBlend(buf + i, 0x40FCFCFC); } @@ -3425,7 +3425,7 @@ static void ViewportMapDrawSelection(const Viewport * const vp) points[2] = end_pt; points[3] = mid2_pt; GfxFillPolygon(points, 0, FILLRECT_FUNCTOR, [](void *dst, int count) { - uint32 *buf = reinterpret_cast(dst); + uint32_t *buf = reinterpret_cast(dst); for (int i = 0; i < count; i++) { PixelBlend(buf + i, 0x40FCFCFC); } @@ -3446,7 +3446,7 @@ static void ViewportMapDrawBridgeTunnel(Viewport * const vp, const TunnelBridgeT const Owner o = GetTileOwner(tile); if (o < MAX_COMPANIES && !_legend_land_owners[_company_to_list_pos[o]].show_on_map) return; - uint8 colour; + uint8_t colour; if (vp->map_type == VPMT_OWNER && _settings_client.gui.use_owner_colour_for_tunnelbridge && o < MAX_COMPANIES) { colour = _legend_land_owners[_company_to_list_pos[o]].colour; colour = is_tunnel ? _darken_colour[colour] : _lighten_colour[colour]; @@ -3494,9 +3494,9 @@ static void ViewportMapDrawBridgeTunnel(Viewport * const vp, const TunnelBridgeT if (IsInsideMM(y, 0, h)) { uint idx = (x + _vdd->offset_x) + ((y + _vdd->offset_y) * vp->width); if (is_32bpp) { - reinterpret_cast(vp->land_pixel_cache.data())[idx] = COL8TO32(colour); + reinterpret_cast(vp->land_pixel_cache.data())[idx] = COL8TO32(colour); } else { - reinterpret_cast(vp->land_pixel_cache.data())[idx] = colour; + reinterpret_cast(vp->land_pixel_cache.data())[idx] = colour; } } } @@ -3533,8 +3533,8 @@ void ViewportMapDraw(Viewport * const vp) int j = 0; const int land_cache_start = _vdd->offset_x + (_vdd->offset_y * vp->width); - uint32 *land_cache_ptr32 = reinterpret_cast(vp->land_pixel_cache.data()) + land_cache_start; - uint8 *land_cache_ptr8 = reinterpret_cast(vp->land_pixel_cache.data()) + land_cache_start; + uint32_t *land_cache_ptr32 = reinterpret_cast(vp->land_pixel_cache.data()) + land_cache_start; + uint8_t *land_cache_ptr8 = reinterpret_cast(vp->land_pixel_cache.data()) + land_cache_start; bool cache_updated = false; @@ -3554,7 +3554,7 @@ void ViewportMapDraw(Viewport * const vp) land_cache_ptr32++; } else { if (*land_cache_ptr8 == 0xD7) { - *land_cache_ptr8 = (uint8) ViewportMapGetColour(vp, c, d, colour_index); + *land_cache_ptr8 = (uint8_t) ViewportMapGetColour(vp, c, d, colour_index); cache_updated = true; } land_cache_ptr8++; @@ -3622,9 +3622,9 @@ void ViewportMapDraw(Viewport * const vp) } if (is_32bpp) { - blitter->SetRect32(_vdd->dpi.dst_ptr, 0, 0, reinterpret_cast(vp->land_pixel_cache.data()) + land_cache_start, h, w, vp->width); + blitter->SetRect32(_vdd->dpi.dst_ptr, 0, 0, reinterpret_cast(vp->land_pixel_cache.data()) + land_cache_start, h, w, vp->width); } else { - blitter->SetRect(_vdd->dpi.dst_ptr, 0, 0, reinterpret_cast(vp->land_pixel_cache.data()) + land_cache_start, h, w, vp->width); + blitter->SetRect(_vdd->dpi.dst_ptr, 0, 0, reinterpret_cast(vp->land_pixel_cache.data()) + land_cache_start, h, w, vp->width); } if (unlikely(HasBit(_viewport_debug_flags, VDF_SHOW_NO_LANDSCAPE_MAP_DRAW)) && !cache_updated) { @@ -3710,7 +3710,7 @@ static void ViewportDoDrawPhase3(Viewport *vp); static void ViewportDoDrawRenderJob(Viewport *vp, ViewportDrawerDynamic *vdd); /* This is run in the main thread */ -void ViewportDoDraw(Viewport *vp, int left, int top, int right, int bottom, uint8 display_flags) +void ViewportDoDraw(Viewport *vp, int left, int top, int right, int bottom, uint8_t display_flags) { if (_spare_viewport_drawers.empty()) { _vdd.reset(new ViewportDrawerDynamic()); @@ -3945,9 +3945,9 @@ static void ViewportDoDrawPhase3(Viewport *vp) * Make sure we don't draw a too big area at a time. * If we do, the sprite sorter will run into major performance problems and the sprite memory may overflow. */ -void ViewportDrawChk(Viewport *vp, int left, int top, int right, int bottom, uint8 display_flags) +void ViewportDrawChk(Viewport *vp, int left, int top, int right, int bottom, uint8_t display_flags) { - if ((vp->zoom < ZOOM_LVL_DRAW_MAP) && ((int64)ScaleByZoom(bottom - top, vp->zoom) * (int64)ScaleByZoom(right - left, vp->zoom) > (int64)(1000000 * ZOOM_LVL_BASE * ZOOM_LVL_BASE))) { + if ((vp->zoom < ZOOM_LVL_DRAW_MAP) && ((int64_t)ScaleByZoom(bottom - top, vp->zoom) * (int64_t)ScaleByZoom(right - left, vp->zoom) > (int64_t)(1000000 * ZOOM_LVL_BASE * ZOOM_LVL_BASE))) { if ((bottom - top) > (right - left)) { int t = (top + bottom) >> 1; ViewportDrawChk(vp, left, top, right, t, display_flags); @@ -3968,7 +3968,7 @@ void ViewportDrawChk(Viewport *vp, int left, int top, int right, int bottom, uin } } -static inline void ViewportDraw(Viewport *vp, int left, int top, int right, int bottom, uint8 display_flags) +static inline void ViewportDraw(Viewport *vp, int left, int top, int right, int bottom, uint8_t display_flags) { if (right <= vp->left || bottom <= vp->top) return; @@ -3990,7 +3990,7 @@ static inline void ViewportDraw(Viewport *vp, int left, int top, int right, int /** * Draw the viewport of this window. */ -void Window::DrawViewport(uint8 display_flags) const +void Window::DrawViewport(uint8_t display_flags) const { PerformanceAccumulator framerate(PFE_DRAWWORLD); @@ -4205,7 +4205,7 @@ void MarkViewportDirty(Viewport * const vp, int left, int top, int right, int bo uint w = UnScaleByZoom(right, vp->zoom) - l; uint h = UnScaleByZoom(bottom, vp->zoom) - t; uint bitdepth = BlitterFactory::GetCurrentBlitter()->GetScreenDepth() / 8; - uint8 *land_cache = vp->land_pixel_cache.data() + ((l + (t * vp->width)) * bitdepth); + uint8_t *land_cache = vp->land_pixel_cache.data() + ((l + (t * vp->width)) * bitdepth); while (--h) { memset(land_cache, 0xD7, (size_t)w * bitdepth); land_cache += vp->width * bitdepth; @@ -5378,7 +5378,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; @@ -6147,7 +6147,7 @@ calc_heightdiff_single_direction:; if (dx != 1 || dy != 1) { heightdiff = CalcHeightdiff(style, 0, t0, t1); SetDParam(0, DistanceManhattan(t0, t1)); - SetDParam(1, IntSqrt64(((uint64)dx * (uint64)dx) + ((uint64)dy * (uint64)dy))); // Avoid overflow in DistanceSquare + SetDParam(1, IntSqrt64(((uint64_t)dx * (uint64_t)dx) + ((uint64_t)dy * (uint64_t)dy))); // Avoid overflow in DistanceSquare } else { SetDParam(0, 0); SetDParam(1, 0); @@ -6430,7 +6430,7 @@ void InitializeSpriteSorter() * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdScrollViewport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdScrollViewport(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (_current_company != OWNER_DEITY) return CMD_ERROR; ViewportScrollTarget target = (ViewportScrollTarget)p1; @@ -6464,7 +6464,7 @@ static LineSnapPoint LineSnapPointAtRailTrackEndpoint(TileIndex tile, DiagDirect SetBit(ret.dirs, DiagDirToDir(exit_dir)); SetBit(ret.dirs, ChangeDir(DiagDirToDir(exit_dir), DIRDIFF_45LEFT)); SetBit(ret.dirs, ChangeDir(DiagDirToDir(exit_dir), DIRDIFF_45RIGHT)); - if (bidirectional) ret.dirs |= ROR(ret.dirs, DIRDIFF_REVERSE); + if (bidirectional) ret.dirs |= ROR(ret.dirs, DIRDIFF_REVERSE); return ret; } @@ -6579,7 +6579,7 @@ static void SetRailSnapTile(TileIndex tile) for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) { _tile_snap_points.push_back(LineSnapPointAtRailTrackEndpoint(tile, dir, false)); LineSnapPoint &point = _tile_snap_points.back(); - point.dirs = ROR(point.dirs, DIRDIFF_REVERSE); + point.dirs = ROR(point.dirs, DIRDIFF_REVERSE); } } diff --git a/src/viewport_func.h b/src/viewport_func.h index 1cfe92d7c6..801ee209c0 100644 --- a/src/viewport_func.h +++ b/src/viewport_func.h @@ -29,7 +29,7 @@ void ClearViewportCache(Viewport *vp); void ClearViewportLandPixelCache(Viewport *vp); void ClearViewportCaches(); 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(); @@ -73,10 +73,10 @@ 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, ChildScreenSpritePositionMode position_mode = ChildScreenSpritePositionMode::Relative); -void ViewportAddString(ViewportDrawerDynamic *vdd, const DrawPixelInfo *dpi, ZoomLevel small_from, const ViewportSign *sign, StringID string_normal, StringID string_small, StringID string_small_shadow, uint64 params_1, uint64 params_2 = 0, Colours colour = INVALID_COLOUR); +void ViewportAddString(ViewportDrawerDynamic *vdd, const DrawPixelInfo *dpi, ZoomLevel small_from, const ViewportSign *sign, StringID string_normal, StringID string_small, StringID string_small_shadow, uint64_t params_1, uint64_t params_2 = 0, Colours colour = INVALID_COLOUR); void StartSpriteCombine(); @@ -94,7 +94,7 @@ void SetRedErrorSquare(TileIndex tile); void SetTileSelectSize(int w, int h); void SetTileSelectBigSize(int ox, int oy, int sx, int sy); -void ViewportDoDraw(Viewport *vp, int left, int top, int right, int bottom, uint8 display_flags); +void ViewportDoDraw(Viewport *vp, int left, int top, int right, int bottom, uint8_t display_flags); void ViewportDoDrawProcessAllPending(); bool ScrollWindowToTile(TileIndex tile, Window *w, bool instant = false); diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp index 43a5869098..7c67ae2291 100644 --- a/src/viewport_gui.cpp +++ b/src/viewport_gui.cpp @@ -220,19 +220,19 @@ void ShowExtraViewportWindowForTileUnderCursor() ShowExtraViewportWindow(pt.x != -1 ? TileVirtXY(pt.x, pt.y) : INVALID_TILE); } -enum TownNameTooltipMode : uint8 { +enum TownNameTooltipMode : uint8_t { TNTM_OFF, TNTM_ON_IF_HIDDEN, TNTM_ALWAYS_ON }; -enum WaypointTooltipNameMode : uint8 { +enum WaypointTooltipNameMode : uint8_t { WTNM_OFF, WTNM_ON_IF_HIDDEN, WTNM_ALWAYS_ON }; -enum StationTooltipNameMode : uint8 { +enum StationTooltipNameMode : uint8_t { STNM_OFF, STNM_ON_IF_HIDDEN, STNM_ALWAYS_ON diff --git a/src/viewport_kdtree.h b/src/viewport_kdtree.h index 56254b4148..104ad80e2c 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; extern bool _viewport_sign_kdtree_valid; diff --git a/src/viewport_sprite_sorter.h b/src/viewport_sprite_sorter.h index a631543d07..011390c2c3 100644 --- a/src/viewport_sprite_sorter.h +++ b/src/viewport_sprite_sorter.h @@ -21,27 +21,27 @@ struct __declspec(align(16)) ParentSpriteToDraw { struct __attribute__ ((aligned (16))) ParentSpriteToDraw { #endif /* 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. - uint16 width; ///< sprite width - uint16 height; ///< sprite height, bit 15: comparison_done: used during sprite sorting: true if sprite has been compared with all other sprites + int32_t first_child; ///< the first child to draw. + uint16_t width; ///< sprite width + uint16_t height; ///< sprite height, bit 15: comparison_done: used during sprite sorting: true if sprite has been compared with all other sprites bool IsComparisonDone() const { return HasBit(this->height, 15); } void SetComparisonDone(bool done) { SB(this->height, 15, 1, done ? 1 : 0); } diff --git a/src/viewport_type.h b/src/viewport_type.h index b824784a45..2da7bd77a6 100644 --- a/src/viewport_type.h +++ b/src/viewport_type.h @@ -31,7 +31,7 @@ enum ViewportMapType { }; struct ViewPortMapDrawVehiclesCache { - uint64 done_hash_bits[64]; + uint64_t done_hash_bits[64]; std::vector vehicle_pixels; }; @@ -57,7 +57,7 @@ struct Viewport { std::vector dirty_blocks; uint dirty_blocks_per_column; uint dirty_blocks_per_row; - uint8 dirty_block_left_margin; + uint8_t dirty_block_left_margin; bool is_dirty = false; bool is_drawn = false; bool update_vehicles = false; @@ -95,10 +95,10 @@ private: /** 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(ZoomLevel maxzoom, int center, int top, StringID str, StringID str_small = STR_NULL); void MarkDirty(ZoomLevel maxzoom) const; @@ -227,7 +227,7 @@ enum ViewportMarkDirtyFlags : byte { }; DECLARE_ENUM_AS_BIT_SET(ViewportMarkDirtyFlags) -enum class ChildScreenSpritePositionMode : uint8 { +enum class ChildScreenSpritePositionMode : uint8_t { Relative, NonRelative, Absolute, diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index b9a03276e5..a2c9041ad6 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -49,7 +49,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 @@ -108,7 +108,7 @@ void ClearNeighbourNonFloodingStates(TileIndex tile) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildShipDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildShipDepot(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Axis axis = Extract(p1); @@ -434,7 +434,7 @@ static CommandCost RemoveLock(TileIndex tile, DoCommandFlag flags) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildLock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildLock(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { DiagDirection dir = GetInclinedSlopeDirection(GetTileSlope(tile)); if (dir == INVALID_DIAGDIR) return_cmd_error(STR_ERROR_LAND_SLOPED_IN_WRONG_DIRECTION); @@ -473,7 +473,7 @@ void MakeRiverAndModifyDesertZoneAround(TileIndex tile) * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildCanal(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { WaterClass wc = Extract(p2); if (p1 >= MapSize() || wc == WATER_CLASS_INVALID) return CMD_ERROR; @@ -886,7 +886,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; } @@ -1216,7 +1216,7 @@ void DoFloodTile(TileIndex target) const ObjectSpec *spec = ObjectSpec::GetByTile(target); if ((spec->ctrl_flags & OBJECT_CTRL_FLAG_USE_LAND_GROUND) && (spec->ctrl_flags & OBJECT_CTRL_FLAG_EDGE_FOUNDATION)) { Object *obj = Object::GetByTile(target); - uint8 flags = spec->edge_foundation[obj->view]; + uint8_t flags = spec->edge_foundation[obj->view]; DiagDirection edge = (DiagDirection)GB(flags, 0, 2); Slope incline = InclinedSlope(edge); if (!(tileh & incline) && !(flags & OBJECT_EF_FLAG_FOUNDATION_LOWER)) { diff --git a/src/water_map.h b/src/water_map.h index 34b885daa6..c3926d6892 100644 --- a/src/water_map.h +++ b/src/water_map.h @@ -393,7 +393,7 @@ inline void MakeShore(TileIndex t) * @param wc The class of water the tile has to be * @param random_bits Eventual random bits to be set for this tile */ -inline void MakeWater(TileIndex t, Owner o, WaterClass wc, uint8 random_bits) +inline void MakeWater(TileIndex t, Owner o, WaterClass wc, uint8_t random_bits) { SetTileType(t, MP_WATER); SetTileOwner(t, o); @@ -421,7 +421,7 @@ inline void MakeSea(TileIndex t) * @param t The tile to change into river * @param random_bits Random bits to be set for this tile */ -inline void MakeRiver(TileIndex t, uint8 random_bits) +inline void MakeRiver(TileIndex t, uint8_t random_bits) { MakeWater(t, OWNER_WATER, WATER_CLASS_RIVER, random_bits); } @@ -432,7 +432,7 @@ inline void MakeRiver(TileIndex t, uint8 random_bits) * @param o The owner of the canal * @param random_bits Random bits to be set for this tile */ -inline void MakeCanal(TileIndex t, Owner o, uint8 random_bits) +inline void MakeCanal(TileIndex t, Owner o, uint8_t random_bits) { dbg_assert(o != OWNER_WATER); MakeWater(t, o, WATER_CLASS_CANAL, random_bits); @@ -530,7 +530,7 @@ inline bool IsNonFloodingWaterTile(TileIndex t) */ inline bool IsFloodingTypeTile(TileIndex t) { - static const uint16 mask = (1 << MP_WATER) | (1 << MP_STATION) | (1 << MP_INDUSTRY) | (1 << MP_RAILWAY) | (1 << MP_TREES) | (1 << MP_OBJECT) | (1 << MP_VOID); + static const uint16_t mask = (1 << MP_WATER) | (1 << MP_STATION) | (1 << MP_INDUSTRY) | (1 << MP_RAILWAY) | (1 << MP_TREES) | (1 << MP_OBJECT) | (1 << MP_VOID); return HasBit(mask, GetTileType(t)); } diff --git a/src/waypoint_base.h b/src/waypoint_base.h index cee2aaf622..95b97366e5 100644 --- a/src/waypoint_base.h +++ b/src/waypoint_base.h @@ -22,8 +22,8 @@ enum WaypointFlags { /** Representation of a waypoint. */ struct Waypoint FINAL : SpecializedStation { - uint16 town_cn; ///< The N-1th waypoint for this town (consecutive number) - uint16 waypoint_flags; ///< Waypoint flags, see WaypointFlags + uint16_t town_cn; ///< The N-1th waypoint for this town (consecutive number) + uint16_t waypoint_flags; ///< Waypoint flags, see WaypointFlags TileArea road_waypoint_area; ///< Tile area the road waypoint part covers @@ -43,7 +43,7 @@ struct Waypoint FINAL : SpecializedStation { return IsRailWaypointTile(tile) && GetStationIndex(tile) == this->index; } - uint32 GetNewGRFVariable(const struct ResolverObject &object, uint16 variable, byte parameter, bool *available) const override; + uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint16_t variable, byte parameter, bool *available) const override; void GetTileArea(TileArea *ta, StationType type) const override; diff --git a/src/waypoint_cmd.cpp b/src/waypoint_cmd.cpp index 0225455e98..bfe9aa5b4e 100644 --- a/src/waypoint_cmd.cpp +++ b/src/waypoint_cmd.cpp @@ -199,7 +199,7 @@ extern CommandCost IsRailStationBridgeAboveOk(TileIndex tile, const StationSpec * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildRailWaypoint(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdBuildRailWaypoint(TileIndex start_tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { /* Unpack parameters */ Axis axis = Extract(p1); @@ -356,7 +356,7 @@ CommandCost CmdBuildRailWaypoint(TileIndex start_tile, DoCommandFlag flags, uint * @param text Unused. * @return The cost of this operation or an error. */ -CommandCost CmdBuildRoadWaypoint(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data) +CommandCost CmdBuildRoadWaypoint(TileIndex start_tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, uint64_t p3, const char *text, const CommandAuxiliaryBase *aux_data) { StationID station_to_join = GB(p2, 16, 16); byte width = GB(p1, 0, 8); @@ -514,7 +514,7 @@ CommandCost CmdBuildRoadWaypoint(TileIndex start_tile, DoCommandFlag flags, uint * @param text unused * @return the cost of this operation or an error */ -CommandCost CmdBuildBuoy(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdBuildBuoy(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { if (tile == 0 || !HasTileWaterGround(tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE); @@ -625,7 +625,7 @@ static bool IsUniqueWaypointName(const char *name) * @param text the new name or an empty string when resetting to the default * @return the cost of this operation or an error */ -CommandCost CmdRenameWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdRenameWaypoint(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Waypoint *wp = Waypoint::GetIfValid(p1); if (wp == nullptr) return CMD_ERROR; @@ -663,7 +663,7 @@ CommandCost CmdRenameWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, ui * @param text the new name or an empty string when resetting to the default * @return the cost of this operation or an error */ -CommandCost CmdSetWaypointLabelHidden(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text) +CommandCost CmdSetWaypointLabelHidden(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint32_t p2, const char *text) { Waypoint *wp = Waypoint::GetIfValid(p1); if (wp == nullptr) return CMD_ERROR; diff --git a/src/widget.cpp b/src/widget.cpp index ae5054a9d9..229d7cca4a 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -173,7 +173,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)}; } /** @@ -540,7 +540,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); @@ -618,8 +618,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); @@ -657,8 +657,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); @@ -1120,7 +1120,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; @@ -1229,7 +1229,7 @@ NWidgetCore::NWidgetCore(WidgetType tp, Colours colour, WidgetID index, uint fil * @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; @@ -1504,7 +1504,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; @@ -2210,7 +2210,7 @@ void NWidgetBackground::Add(std::unique_ptr &&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 = std::make_unique(); @@ -2262,7 +2262,7 @@ void NWidgetBackground::SetupSmallestSize(Window *w) 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 ? GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.frametext.top / 2 : 0); + this->child->padding.top = std::max(WidgetDimensions::scaled.frametext.top, this->widget_data != STR_NULL ? GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.frametext.top / 2 : 0); this->smallest_x += this->child->padding.Horizontal(); this->smallest_y += this->child->padding.Vertical(); @@ -2427,7 +2427,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); w->viewport_widget = this; @@ -2482,7 +2482,7 @@ int Scrollbar::GetScrolledRowFromWidget(int clickpos, const Window * const w, Wi * @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) { diff --git a/src/widget_type.h b/src/widget_type.h index 0ca0678c4e..9c59e444fa 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -49,7 +49,7 @@ enum ResizeWidgetValues { /** * Window widget types, nested widget types, and nested widget part types. */ -enum WidgetType : uint8 { +enum WidgetType : uint8_t { /* Window widget types. */ WWT_EMPTY, ///< Empty widget, place holder to reserve space in widget tree. @@ -120,7 +120,7 @@ enum WidgetType : uint8 { /** * Base widget flags. */ -enum WidgetBaseFlags : uint8 { +enum WidgetBaseFlags : uint8_t { WBF_DIRTY = 1 << 0, ///< Widget is dirty. }; DECLARE_ENUM_AS_BIT_SET(WidgetBaseFlags) @@ -196,7 +196,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; @@ -316,7 +316,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); @@ -333,9 +333,9 @@ 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. - FontSize uz_text_size; ///< 'Unscaled' font size, 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. }; /** Nested widget flags that affect display and interaction with 'real' widgets. */ @@ -694,7 +694,7 @@ public: void SetupSmallestSize(Window *w) 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); }; @@ -704,10 +704,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 */ @@ -725,7 +725,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; } @@ -734,7 +734,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; } @@ -743,7 +743,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; } @@ -753,7 +753,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()); } @@ -785,7 +785,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 */ @@ -799,7 +799,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 */ @@ -815,7 +815,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; } @@ -879,7 +879,7 @@ public: return it; } - EventState UpdateListPositionOnKeyPress(int &list_position, uint16 keycode) const; + EventState UpdateListPositionOnKeyPress(int &list_position, uint16_t keycode) const; }; /** @@ -970,7 +970,7 @@ 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. @@ -1001,7 +1001,7 @@ 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. @@ -1018,7 +1018,7 @@ 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. }; @@ -1043,7 +1043,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. }; /** @@ -1051,9 +1051,9 @@ struct NWidgetPartPIP { * @ingroup NestedWidgetParts */ struct NWidgetPartTextLines { - uint8 lines; ///< Number of text lines. - uint8 spacing; ///< Extra spacing around lines. - FontSize size; ///< Font size of text lines. + uint8_t lines; ///< Number of text lines. + uint8_t spacing; ///< Extra spacing around lines. + FontSize size; ///< Font size of text lines. }; /** @@ -1062,7 +1062,7 @@ struct NWidgetPartTextLines { */ struct NWidgetPartTextStyle { TextColour colour; ///< TextColour for DrawString. - FontSize size; ///< Font size of text. + FontSize size; ///< Font size of text. }; /** @@ -1084,7 +1084,7 @@ typedef std::unique_ptr NWidgetFunctionType(); * @ingroup NestedWidgetParts */ struct NWidgetPart { - WidgetType type; ///< Type of the part. @see NWidgetPartType. + WidgetType type; ///< Type of the part. @see NWidgetPartType. union { Point xy; ///< Part with an x/y size. NWidgetPartDataTip data_tip; ///< Part with a data/tooltip. diff --git a/src/window.cpp b/src/window.cpp index f75627d124..02650e7a0b 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -67,7 +67,7 @@ Window *_first_window = nullptr; /** If false, highlight is white, otherwise the by the widget defined colour. */ bool _window_highlight_colour = false; -uint64 _window_update_number = 1; +uint64_t _window_update_number = 1; /* * Window that currently has focus. - The main purpose is to generate @@ -100,8 +100,8 @@ std::vector *_window_descs = nullptr; std::string _windows_file; /** Window description constructor. */ -WindowDesc::WindowDesc(const char * const file, const int line, WindowPosition def_pos, const char *ini_key, int16 def_width_trad, int16 def_height_trad, - WindowClass window_class, WindowClass parent_class, uint32 flags, +WindowDesc::WindowDesc(const char * const file, const int line, 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_begin, const NWidgetPart *nwid_end, HotkeyList *hotkeys, WindowDesc *ini_parent) : file(file), line(line), @@ -138,7 +138,7 @@ const WindowDescPreferences &WindowDesc::GetPreferences() const * 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 { const WindowDescPreferences &prefs = this->GetPreferences(); return prefs.pref_width != 0 ? prefs.pref_width : ScaleGUITrad(this->default_width_trad); @@ -149,7 +149,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 { const WindowDescPreferences &prefs = this->GetPreferences(); return prefs.pref_height != 0 ? prefs.pref_height : ScaleGUITrad(this->default_height_trad); @@ -699,8 +699,8 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count) w->window_desc->GetPreferences().pref_width = w->width; w->window_desc->GetPreferences().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; @@ -1782,13 +1782,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; @@ -1842,7 +1842,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); } @@ -2747,7 +2747,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. */ @@ -2932,7 +2932,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 9320901cb2..4e08b8d1d0 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -87,15 +87,15 @@ extern Window *_z_back_window; extern Window *_first_window; extern Window *_focused_window; -inline uint64 GetWindowUpdateNumber() +inline uint64_t GetWindowUpdateNumber() { - extern uint64 _window_update_number; + extern uint64_t _window_update_number; return _window_update_number; } inline void IncrementWindowUpdateNumber() { - extern uint64 _window_update_number; + extern uint64_t _window_update_number; _window_update_number++; } @@ -114,8 +114,8 @@ struct HotkeyList; struct WindowDescPreferences { 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. }; /** @@ -123,8 +123,8 @@ struct WindowDescPreferences { */ struct WindowDesc { - WindowDesc(const char * const file, const int line, WindowPosition default_pos, const char *ini_key, int16 def_width_trad, int16 def_height_trad, - WindowClass window_class, WindowClass parent_class, uint32 flags, + WindowDesc(const char * const file, const int line, 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_begin, const NWidgetPart *nwid_end, HotkeyList *hotkeys = nullptr, WindowDesc *ini_parent = nullptr); ~WindowDesc(); @@ -135,9 +135,9 @@ struct WindowDesc { 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_begin; ///< Beginning of nested widget parts describing the window. - const NWidgetPart *nwid_end; ///< Ending of nested widget parts describing the window. + const NWidgetPart *nwid_end; ///< Ending of nested widget parts describing the window. HotkeyList *hotkeys; ///< Hotkeys for the window. WindowDesc *ini_parent; ///< Other window desc to use for WindowDescPreferences. @@ -146,15 +146,15 @@ struct WindowDesc { const WindowDescPreferences &GetPreferences() const; WindowDescPreferences &GetPreferences() { return const_cast(const_cast(this)->GetPreferences()); } - 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 @@ -192,7 +192,7 @@ enum SortButtonState { /** * Window flags. */ -enum WindowFlags : uint16 { +enum WindowFlags : uint16_t { WF_TIMEOUT = 1 << 0, ///< Window timeout counter. WF_DRAGGING = 1 << 3, ///< Window is being dragged. @@ -221,13 +221,13 @@ static const int WHITE_BORDER_DURATION = 3; ///< The initial timeout value for W * @see InitializeViewport(), UpdateNextViewportPosition(), ApplyNextViewportPosition(), UpdateViewportCoordinates(). */ 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 next_scrollpos_x; ///< Next x coordinate to display (virtual screen coordinate of topleft corner of the viewport). - int32 next_scrollpos_y; ///< Next y coordinate to display (virtual screen coordinate of topleft corner of the viewport). + VehicleID follow_vehicle; ///< VehicleID to follow if following a vehicle, #INVALID_VEHICLE otherwise. + 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). + int32_t next_scrollpos_x; ///< Next x coordinate to display (virtual screen coordinate of topleft corner of the viewport). + int32_t next_scrollpos_y; ///< Next y coordinate to display (virtual screen coordinate of topleft corner of the viewport). bool force_update_overlay_pending; ///< Forced overlay update is pending (see SetViewportPosition) }; @@ -530,7 +530,7 @@ public: void SetWidgetDirty(WidgetID widget_index); void DrawWidgets() const; - void DrawViewport(uint8 display_flags) const; + void DrawViewport(uint8_t display_flags) const; void DrawSortButtonState(WidgetID widget, SortButtonState state) const; static int SortButtonWidth(); @@ -569,7 +569,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. @@ -621,7 +621,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 427ca11263..fbe25106b1 100644 --- a/src/window_type.h +++ b/src/window_type.h @@ -820,7 +820,7 @@ struct Window; struct WindowBase; /** Number to differentiate different windows of the same class */ -typedef int32 WindowNumber; +typedef int32_t WindowNumber; /** State of handling an event. */ enum EventState { diff --git a/src/zoning.h b/src/zoning.h index 3401b3548a..f43a975240 100644 --- a/src/zoning.h +++ b/src/zoning.h @@ -16,7 +16,7 @@ /** * Zoning evaluation modes */ -enum ZoningEvaluationMode : uint8 { +enum ZoningEvaluationMode : uint8_t { ZEM_NOTHING = 0, ///< No zoning action selected ZEM_AUTHORITY, ///< Check the local authority's opinion. ZEM_CAN_BUILD, ///< Check wither or not the player can build. diff --git a/src/zoning_cmd.cpp b/src/zoning_cmd.cpp index d627e7b3c8..9dff5ae0d0 100644 --- a/src/zoning_cmd.cpp +++ b/src/zoning_cmd.cpp @@ -33,8 +33,8 @@ Zoning _zoning; static const SpriteID ZONING_INVALID_SPRITE_ID = UINT_MAX; -static btree::btree_set _zoning_cache_inner; -static btree::btree_set _zoning_cache_outer; +static btree::btree_set _zoning_cache_inner; +static btree::btree_set _zoning_cache_outer; /** * Draw the zoning sprites. @@ -377,7 +377,7 @@ inline SpriteID TileZoningSpriteEvaluationCached(TileIndex tile, Owner owner, Zo if (ev_mode == ZEM_IND_UNSER && !IsTileType(tile, MP_INDUSTRY)) return ZONING_INVALID_SPRITE_ID; if (ev_mode >= ZEM_STA_CATCH && ev_mode <= ZEM_IND_UNSER) { // cacheable - btree::btree_set &cache = is_inner ? _zoning_cache_inner : _zoning_cache_outer; + btree::btree_set &cache = is_inner ? _zoning_cache_inner : _zoning_cache_outer; auto iter = cache.lower_bound(tile << 3); if (iter != cache.end() && *iter >> 3 == tile) { switch (*iter & 7) { @@ -488,7 +488,7 @@ void ZoningMarkDirtyStationCoverageArea(const Station *st, ZoningModeMask mask) MarkTileDirtyByTile(TileXY(x, y), VMDF_NOT_MAP_MODE); } } - auto invalidate_cache_rect = [&](btree::btree_set &cache) { + auto invalidate_cache_rect = [&](btree::btree_set &cache) { for (int y = rect.top; y <= rect.bottom; y++) { auto iter = cache.lower_bound(TileXY(rect.left, y) << 3); auto end_iter = iter; @@ -529,7 +529,7 @@ void ClearZoningCaches() void SetZoningMode(bool inner, ZoningEvaluationMode mode) { ZoningEvaluationMode ¤t_mode = inner ? _zoning.inner : _zoning.outer; - btree::btree_set &cache = inner ? _zoning_cache_inner : _zoning_cache_outer; + btree::btree_set &cache = inner ? _zoning_cache_inner : _zoning_cache_outer; if (current_mode == mode) return; diff --git a/src/zoom_type.h b/src/zoom_type.h index eccc6de27f..c69f060168 100644 --- a/src/zoom_type.h +++ b/src/zoom_type.h @@ -54,7 +54,7 @@ enum ZoomLevel : byte { }; DECLARE_POSTFIX_INCREMENT(ZoomLevel) -inline uint8 ZoomMask(ZoomLevel level) +inline uint8_t ZoomMask(ZoomLevel level) { return 1 << level; }