Merge lp:~widelands-dev/widelands/bug-1343299 into lp:widelands
- bug-1343299
- Merge into trunk
Proposed by
GunChleoc
Status: | Merged |
---|---|
Merged at revision: | 7190 |
Proposed branch: | lp:~widelands-dev/widelands/bug-1343299 |
Merge into: | lp:widelands |
Diff against target: |
25952 lines (+4801/-4801) 306 files modified
src/ai/ai_help_structs.cc (+1/-1) src/ai/ai_help_structs.h (+1/-1) src/ai/computer_player.cc (+3/-3) src/ai/computer_player.h (+3/-3) src/ai/defaultai.cc (+15/-15) src/base/md5.h (+6/-6) src/chat/chat.h (+2/-2) src/economy/cmd_call_economy_balance.cc (+16/-16) src/economy/cmd_call_economy_balance.h (+2/-2) src/economy/economy.cc (+7/-7) src/economy/economy_data_packet.cc (+17/-17) src/economy/economy_data_packet.h (+2/-2) src/economy/fleet.cc (+16/-16) src/economy/portdock.cc (+17/-17) src/economy/request.cc (+32/-32) src/economy/request.h (+2/-2) src/economy/road.cc (+2/-2) src/economy/road.h (+1/-1) src/economy/route.cc (+7/-7) src/economy/route.h (+1/-1) src/economy/shippingitem.cc (+4/-4) src/economy/transfer.cc (+5/-5) src/economy/ware_instance.cc (+14/-14) src/economy/wares_queue.cc (+20/-20) src/economy/wares_queue.h (+2/-2) src/editor/editorinteractive.cc (+1/-1) src/editor/map_generator.cc (+40/-40) src/editor/map_generator.h (+5/-5) src/editor/tools/editor_decrease_resources_tool.cc (+1/-1) src/editor/tools/editor_increase_resources_tool.cc (+2/-2) src/editor/tools/editor_increase_resources_tool.h (+1/-1) src/editor/tools/editor_make_infrastructure_tool.cc (+1/-1) src/editor/tools/editor_make_infrastructure_tool.h (+1/-1) src/editor/tools/editor_set_port_space_tool.cc (+3/-3) src/editor/tools/editor_set_port_space_tool.h (+1/-1) src/editor/tools/editor_set_resources_tool.cc (+1/-1) src/editor/tools/editor_set_starting_pos_tool.cc (+2/-2) src/editor/tools/editor_set_starting_pos_tool.h (+1/-1) src/editor/ui_menus/editor_main_menu_load_map.cc (+8/-8) src/editor/ui_menus/editor_main_menu_map_options.cc (+2/-2) src/editor/ui_menus/editor_main_menu_random_map.cc (+6/-6) src/editor/ui_menus/editor_main_menu_save_map.cc (+20/-20) src/editor/ui_menus/editor_main_menu_save_map_make_directory.cc (+1/-1) src/editor/ui_menus/editor_player_menu.cc (+5/-5) src/editor/ui_menus/editor_tool_change_resources_options_menu.cc (+1/-1) src/editor/ui_menus/editor_tool_menu.cc (+1/-1) src/game_io/game_class_packet.cc (+10/-10) src/game_io/game_class_packet.h (+2/-2) src/game_io/game_cmd_queue_packet.cc (+21/-21) src/game_io/game_cmd_queue_packet.h (+2/-2) src/game_io/game_data_packet.h (+2/-2) src/game_io/game_interactive_player_packet.cc (+14/-14) src/game_io/game_interactive_player_packet.h (+2/-2) src/game_io/game_loader.cc (+12/-12) src/game_io/game_map_packet.cc (+6/-6) src/game_io/game_map_packet.h (+5/-5) src/game_io/game_player_economies_packet.cc (+15/-15) src/game_io/game_player_economies_packet.h (+2/-2) src/game_io/game_player_info_packet.cc (+50/-50) src/game_io/game_player_info_packet.h (+2/-2) src/game_io/game_preload_packet.cc (+5/-5) src/game_io/game_preload_packet.h (+2/-2) src/game_io/game_saver.cc (+8/-8) src/graphic/animation.cc (+3/-3) src/graphic/diranimations.h (+1/-1) src/graphic/font.cc (+2/-2) src/graphic/graphic.cc (+3/-3) src/graphic/image_io.cc (+6/-6) src/graphic/render/gamerenderer_gl.cc (+2/-2) src/graphic/render/gl_surface_texture.cc (+2/-2) src/graphic/render/gl_surface_texture.h (+3/-3) src/graphic/text/font_io.cc (+2/-2) src/graphic/text/test/render.cc (+2/-2) src/graphic/text/test/render_richtext.cc (+2/-2) src/graphic/texture.cc (+1/-1) src/graphic/texture.h (+1/-1) src/io/dedicated_log.cc (+19/-19) src/io/dedicated_log.h (+1/-1) src/io/fileread.cc (+20/-20) src/io/fileread.h (+17/-17) src/io/filesystem/disk_filesystem.cc (+60/-60) src/io/filesystem/disk_filesystem.h (+26/-26) src/io/filesystem/filesystem.cc (+27/-27) src/io/filesystem/filesystem.h (+31/-31) src/io/filesystem/layered_filesystem.cc (+72/-71) src/io/filesystem/layered_filesystem.h (+26/-26) src/io/filesystem/test/test_filesystem.cc (+7/-7) src/io/filesystem/zip_exceptions.h (+1/-1) src/io/filesystem/zip_filesystem.cc (+64/-64) src/io/filesystem/zip_filesystem.h (+34/-34) src/io/filewrite.cc (+19/-19) src/io/filewrite.h (+12/-12) src/io/machdep.h (+13/-13) src/io/streamread.cc (+20/-20) src/io/streamread.h (+15/-15) src/io/streamwrite.cc (+4/-4) src/io/streamwrite.h (+29/-29) src/logic/attackable.h (+1/-1) src/logic/battle.cc (+32/-32) src/logic/battle.h (+2/-2) src/logic/bob.cc (+65/-65) src/logic/bob.h (+2/-2) src/logic/buildcost.cc (+6/-6) src/logic/building.cc (+1/-1) src/logic/campaign_visibility.cc (+2/-2) src/logic/carrier.cc (+5/-5) src/logic/checkstep.cc (+9/-9) src/logic/checkstep.h (+11/-11) src/logic/cmd_calculate_statistics.cc (+6/-6) src/logic/cmd_calculate_statistics.h (+2/-2) src/logic/cmd_incorporate.cc (+8/-8) src/logic/cmd_incorporate.h (+2/-2) src/logic/cmd_luacoroutine.cc (+7/-7) src/logic/cmd_luacoroutine.h (+2/-2) src/logic/cmd_luascript.cc (+8/-8) src/logic/cmd_luascript.h (+2/-2) src/logic/cmd_queue.cc (+9/-9) src/logic/cmd_queue.h (+2/-2) src/logic/critter.cc (+7/-7) src/logic/editor_game_base.cc (+1/-1) src/logic/editor_game_base.h (+1/-1) src/logic/expedition_bootstrap.cc (+12/-12) src/logic/findbob.cc (+1/-1) src/logic/findimmovable.cc (+1/-1) src/logic/game.cc (+54/-54) src/logic/game.h (+9/-9) src/logic/game_controller.h (+10/-10) src/logic/game_settings.h (+29/-29) src/logic/immovable.cc (+40/-40) src/logic/instances.cc (+28/-28) src/logic/instances.h (+4/-4) src/logic/map.cc (+4/-4) src/logic/map.h (+4/-4) src/logic/map_info.cc (+8/-8) src/logic/message.h (+2/-2) src/logic/message_id.h (+2/-2) src/logic/message_queue.h (+1/-1) src/logic/militarysite.cc (+48/-48) src/logic/militarysite.h (+14/-14) src/logic/path.cc (+9/-9) src/logic/path.h (+1/-1) src/logic/pathfield.cc (+1/-1) src/logic/pathfield.h (+1/-1) src/logic/player.cc (+48/-48) src/logic/player.h (+7/-7) src/logic/playercommand.cc (+483/-483) src/logic/playercommand.h (+60/-60) src/logic/playersmanager.cc (+3/-3) src/logic/production_program.cc (+4/-4) src/logic/productionsite.h (+1/-1) src/logic/replay.cc (+33/-33) src/logic/replay.h (+4/-4) src/logic/replay_game_controller.cc (+12/-12) src/logic/replay_game_controller.h (+8/-8) src/logic/requirements.cc (+27/-27) src/logic/requirements.h (+4/-4) src/logic/save_handler.cc (+12/-12) src/logic/ship.cc (+31/-31) src/logic/single_player_game_controller.cc (+11/-11) src/logic/single_player_game_controller.h (+8/-8) src/logic/single_player_game_settings_provider.cc (+43/-43) src/logic/single_player_game_settings_provider.h (+23/-23) src/logic/soldier.cc (+54/-54) src/logic/soldier.h (+7/-7) src/logic/soldiercontrol.h (+13/-13) src/logic/trainingsite.cc (+29/-29) src/logic/trainingsite.h (+11/-11) src/logic/tribe.cc (+5/-5) src/logic/warehouse.cc (+14/-14) src/logic/warehouse.h (+16/-16) src/logic/widelands.h (+3/-3) src/logic/widelands_geometry.cc (+2/-2) src/logic/widelands_geometry.h (+1/-1) src/logic/widelands_geometry_io.cc (+28/-28) src/logic/widelands_geometry_io.h (+12/-12) src/logic/worker.cc (+18/-18) src/logic/worker.h (+1/-1) src/logic/worker_descr.cc (+3/-3) src/logic/worker_descr.h (+1/-1) src/logic/worker_program.cc (+3/-3) src/logic/worker_program.h (+1/-1) src/logic/world/editor_category.cc (+1/-1) src/logic/world/map_gen.cc (+32/-32) src/logic/world/map_gen.h (+26/-26) src/logic/world/terrain_description.cc (+2/-2) src/map_io/map_allowed_building_types_packet.cc (+2/-2) src/map_io/map_allowed_worker_types_packet.cc (+2/-2) src/map_io/map_bob_packet.cc (+10/-10) src/map_io/map_bob_packet.h (+2/-2) src/map_io/map_building_packet.cc (+31/-31) src/map_io/map_building_packet.h (+2/-2) src/map_io/map_buildingdata_packet.cc (+261/-261) src/map_io/map_buildingdata_packet.h (+2/-2) src/map_io/map_data_packet.h (+2/-2) src/map_io/map_elemental_packet.cc (+4/-4) src/map_io/map_elemental_packet.h (+3/-3) src/map_io/map_exploration_packet.cc (+12/-12) src/map_io/map_extradata_packet.cc (+13/-13) src/map_io/map_extradata_packet.h (+2/-2) src/map_io/map_flag_packet.cc (+13/-13) src/map_io/map_flagdata_packet.cc (+47/-47) src/map_io/map_heights_packet.cc (+8/-8) src/map_io/map_message_saver.h (+1/-1) src/map_io/map_node_ownership_packet.cc (+9/-9) src/map_io/map_object_packet.cc (+9/-9) src/map_io/map_object_packet.h (+3/-3) src/map_io/map_objective_packet.cc (+2/-2) src/map_io/map_player_names_and_tribes_packet.cc (+4/-4) src/map_io/map_player_names_and_tribes_packet.h (+3/-3) src/map_io/map_player_position_packet.cc (+2/-2) src/map_io/map_players_messages_packet.cc (+5/-5) src/map_io/map_players_view_packet.cc (+131/-131) src/map_io/map_port_spaces_packet.cc (+2/-2) src/map_io/map_port_spaces_packet.h (+3/-3) src/map_io/map_resources_packet.cc (+18/-18) src/map_io/map_resources_packet.h (+2/-2) src/map_io/map_road_packet.cc (+9/-9) src/map_io/map_roaddata_packet.cc (+55/-55) src/map_io/map_saver.cc (+25/-25) src/map_io/map_scripting_packet.cc (+17/-17) src/map_io/map_terrain_packet.cc (+17/-17) src/map_io/map_terrain_packet.h (+2/-2) src/map_io/map_version_packet.cc (+2/-2) src/map_io/s2map.cc (+14/-14) src/map_io/widelands_map_loader.cc (+32/-32) src/network/internet_gaming.cc (+100/-100) src/network/internet_gaming.h (+7/-7) src/network/internet_gaming_protocol.h (+41/-41) src/network/netclient.cc (+206/-206) src/network/netclient.h (+37/-37) src/network/nethost.cc (+477/-477) src/network/nethost.h (+60/-60) src/network/network.cc (+6/-6) src/network/network.h (+5/-5) src/network/network_lan_promotion.cc (+3/-3) src/network/network_lan_promotion.h (+1/-1) src/network/network_player_settings_backend.cc (+7/-7) src/network/network_protocol.h (+50/-50) src/profile/profile.cc (+10/-10) src/profile/profile.h (+2/-2) src/random/random.cc (+8/-8) src/random/random.h (+2/-2) src/scripting/lua_coroutine.cc (+8/-8) src/scripting/lua_game.cc (+8/-8) src/scripting/lua_map.cc (+7/-7) src/scripting/lua_path.cc (+4/-4) src/scripting/lua_root.cc (+2/-2) src/scripting/lua_ui.cc (+2/-2) src/scripting/persistence.cc (+5/-5) src/scripting/scripting.cc (+2/-2) src/scripting/test/test_luna.cc (+9/-9) src/sound/songset.cc (+5/-5) src/sound/sound_handler.cc (+10/-10) src/sound/sound_handler.h (+0/-1) src/ui_basic/editbox.cc (+4/-4) src/ui_basic/editbox.h (+4/-4) src/ui_basic/helpwindow.cc (+3/-3) src/ui_basic/helpwindow.h (+1/-1) src/ui_basic/icon.cc (+3/-3) src/ui_basic/icon.h (+3/-3) src/ui_basic/messagebox.cc (+12/-12) src/ui_basic/messagebox.h (+3/-3) src/ui_basic/panel.cc (+1/-1) src/ui_basic/progresswindow.cc (+1/-1) src/ui_basic/spinbox.cc (+17/-17) src/ui_basic/spinbox.h (+8/-8) src/ui_fsmenu/editor_mapselect.cc (+8/-8) src/ui_fsmenu/internet_lobby.cc (+12/-12) src/ui_fsmenu/internet_lobby.h (+4/-4) src/ui_fsmenu/launch_mpg.cc (+34/-34) src/ui_fsmenu/launch_mpg.h (+1/-1) src/ui_fsmenu/launch_spg.cc (+20/-20) src/ui_fsmenu/loadgame.cc (+11/-11) src/ui_fsmenu/loadreplay.cc (+5/-5) src/ui_fsmenu/mapselect.cc (+5/-5) src/ui_fsmenu/multiplayer.cc (+5/-5) src/ui_fsmenu/multiplayer.h (+2/-2) src/ui_fsmenu/netsetup_lan.cc (+3/-3) src/ui_fsmenu/options.cc (+12/-12) src/wlapplication.cc (+23/-23) src/wui/attack_box.cc (+1/-1) src/wui/chatoverlay.cc (+6/-6) src/wui/chatoverlay.h (+1/-1) src/wui/debugconsole.cc (+2/-2) src/wui/debugconsole.h (+2/-2) src/wui/encyclopedia_window.cc (+6/-6) src/wui/encyclopedia_window.h (+3/-3) src/wui/fieldaction.cc (+13/-13) src/wui/game_chat_menu.cc (+1/-1) src/wui/game_debug_ui.cc (+2/-2) src/wui/game_main_menu_save_game.cc (+14/-14) src/wui/gamechatpanel.cc (+9/-9) src/wui/gamechatpanel.h (+4/-4) src/wui/interactive_base.cc (+19/-19) src/wui/interactive_base.h (+2/-2) src/wui/interactive_gamebase.cc (+1/-1) src/wui/interactive_player.cc (+4/-4) src/wui/itemwaresdisplay.cc (+8/-8) src/wui/itemwaresdisplay.h (+3/-3) src/wui/login_box.cc (+6/-6) src/wui/login_box.h (+2/-2) src/wui/multiplayersetupgroup.cc (+9/-9) src/wui/playerdescrgroup.cc (+10/-10) src/wui/soldiercapacitycontrol.cc (+3/-3) src/wui/soldierlist.cc (+7/-7) src/wui/waresdisplay.cc (+1/-1) |
To merge this branch: | bzr merge lp:~widelands-dev/widelands/bug-1343299 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
SirVer | Approve | ||
Review via email:
|
Commit message
Description of the change
Refactoring: removed CamelCase etc from function names.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/ai/ai_help_structs.cc' | |||
2 | --- src/ai/ai_help_structs.cc 2014-07-20 07:47:15 +0000 | |||
3 | +++ src/ai/ai_help_structs.cc 2014-09-29 14:39:47 +0000 | |||
4 | @@ -60,7 +60,7 @@ | |||
5 | 60 | return true; | 60 | return true; |
6 | 61 | } | 61 | } |
7 | 62 | 62 | ||
9 | 63 | bool CheckStepRoadAI::reachabledest(Map& map, FCoords const dest) const { | 63 | bool CheckStepRoadAI::reachable_dest(Map& map, FCoords const dest) const { |
10 | 64 | NodeCaps const caps = dest.field->nodecaps(); | 64 | NodeCaps const caps = dest.field->nodecaps(); |
11 | 65 | 65 | ||
12 | 66 | if (!(caps & movecaps_)) { | 66 | if (!(caps & movecaps_)) { |
13 | 67 | 67 | ||
14 | === modified file 'src/ai/ai_help_structs.h' | |||
15 | --- src/ai/ai_help_structs.h 2014-09-10 08:55:04 +0000 | |||
16 | +++ src/ai/ai_help_structs.h 2014-09-29 14:39:47 +0000 | |||
17 | @@ -48,7 +48,7 @@ | |||
18 | 48 | } | 48 | } |
19 | 49 | 49 | ||
20 | 50 | bool allowed(Map&, FCoords start, FCoords end, int32_t dir, CheckStep::StepId) const; | 50 | bool allowed(Map&, FCoords start, FCoords end, int32_t dir, CheckStep::StepId) const; |
22 | 51 | bool reachabledest(Map&, FCoords dest) const; | 51 | bool reachable_dest(Map&, FCoords dest) const; |
23 | 52 | 52 | ||
24 | 53 | Player* player_; | 53 | Player* player_; |
25 | 54 | uint8_t movecaps_; | 54 | uint8_t movecaps_; |
26 | 55 | 55 | ||
27 | === modified file 'src/ai/computer_player.cc' | |||
28 | --- src/ai/computer_player.cc 2014-09-10 13:03:40 +0000 | |||
29 | +++ src/ai/computer_player.cc 2014-09-29 14:39:47 +0000 | |||
30 | @@ -50,7 +50,7 @@ | |||
31 | 50 | EmptyAI::EmptyAIImpl EmptyAI::implementation; | 50 | EmptyAI::EmptyAIImpl EmptyAI::implementation; |
32 | 51 | 51 | ||
33 | 52 | const ComputerPlayer::ImplementationVector & | 52 | const ComputerPlayer::ImplementationVector & |
35 | 53 | ComputerPlayer::getImplementations() | 53 | ComputerPlayer::get_implementations() |
36 | 54 | { | 54 | { |
37 | 55 | static std::vector<ComputerPlayer::Implementation const *> impls; | 55 | static std::vector<ComputerPlayer::Implementation const *> impls; |
38 | 56 | 56 | ||
39 | @@ -64,10 +64,10 @@ | |||
40 | 64 | return impls; | 64 | return impls; |
41 | 65 | } | 65 | } |
42 | 66 | 66 | ||
44 | 67 | const ComputerPlayer::Implementation * ComputerPlayer::getImplementation | 67 | const ComputerPlayer::Implementation * ComputerPlayer::get_implementation |
45 | 68 | (const std::string & name) | 68 | (const std::string & name) |
46 | 69 | { | 69 | { |
48 | 70 | const ImplementationVector & vec = getImplementations(); | 70 | const ImplementationVector & vec = get_implementations(); |
49 | 71 | 71 | ||
50 | 72 | for (const ComputerPlayer::Implementation* implementation : vec) { | 72 | for (const ComputerPlayer::Implementation* implementation : vec) { |
51 | 73 | if (implementation->name == name) { | 73 | if (implementation->name == name) { |
52 | 74 | 74 | ||
53 | === modified file 'src/ai/computer_player.h' | |||
54 | --- src/ai/computer_player.h 2014-09-14 11:31:58 +0000 | |||
55 | +++ src/ai/computer_player.h 2014-09-29 14:39:47 +0000 | |||
56 | @@ -48,7 +48,7 @@ | |||
57 | 48 | /** | 48 | /** |
58 | 49 | * Interface to a concrete implementation, used to instantiate AIs. | 49 | * Interface to a concrete implementation, used to instantiate AIs. |
59 | 50 | * | 50 | * |
61 | 51 | * \see getImplementations() | 51 | * \see get_implementations() |
62 | 52 | */ | 52 | */ |
63 | 53 | struct Implementation { | 53 | struct Implementation { |
64 | 54 | std::string name; | 54 | std::string name; |
65 | @@ -61,12 +61,12 @@ | |||
66 | 61 | /** | 61 | /** |
67 | 62 | * Get a list of available AI implementations. | 62 | * Get a list of available AI implementations. |
68 | 63 | */ | 63 | */ |
70 | 64 | static const ImplementationVector & getImplementations(); | 64 | static const ImplementationVector & get_implementations(); |
71 | 65 | 65 | ||
72 | 66 | /** | 66 | /** |
73 | 67 | * Get the best matching implementation for this name. | 67 | * Get the best matching implementation for this name. |
74 | 68 | */ | 68 | */ |
76 | 69 | static const Implementation * getImplementation(const std::string & name); | 69 | static const Implementation * get_implementation(const std::string & name); |
77 | 70 | 70 | ||
78 | 71 | private: | 71 | private: |
79 | 72 | Widelands::Game & m_game; | 72 | Widelands::Game & m_game; |
80 | 73 | 73 | ||
81 | === modified file 'src/ai/defaultai.cc' | |||
82 | --- src/ai/defaultai.cc 2014-09-14 11:31:58 +0000 | |||
83 | +++ src/ai/defaultai.cc 2014-09-29 14:39:47 +0000 | |||
84 | @@ -658,10 +658,10 @@ | |||
85 | 658 | 658 | ||
86 | 659 | if (v > 0 && dist > 0) { | 659 | if (v > 0 && dist > 0) { |
87 | 660 | 660 | ||
90 | 661 | field.military_capacity_ += militarysite->maxSoldierCapacity(); | 661 | field.military_capacity_ += militarysite->max_soldier_capacity(); |
91 | 662 | field.military_presence_ += militarysite->stationedSoldiers().size(); | 662 | field.military_presence_ += militarysite->stationed_soldiers().size(); |
92 | 663 | 663 | ||
94 | 664 | if (!militarysite->stationedSoldiers().empty()) { | 664 | if (!militarysite->stationed_soldiers().empty()) { |
95 | 665 | field.military_stationed_ += 1; | 665 | field.military_stationed_ += 1; |
96 | 666 | } | 666 | } |
97 | 667 | 667 | ||
98 | @@ -2216,7 +2216,7 @@ | |||
99 | 2216 | for (std::list<MilitarySiteObserver>::iterator it = militarysites.begin(); | 2216 | for (std::list<MilitarySiteObserver>::iterator it = militarysites.begin(); |
100 | 2217 | it != militarysites.end(); | 2217 | it != militarysites.end(); |
101 | 2218 | ++it) | 2218 | ++it) |
103 | 2219 | if (it->site->stationedSoldiers().size() == 0) | 2219 | if (it->site->stationed_soldiers().size() == 0) |
104 | 2220 | unstationed_milit_buildings_ += 1; | 2220 | unstationed_milit_buildings_ += 1; |
105 | 2221 | 2221 | ||
106 | 2222 | // count militarysites in construction | 2222 | // count militarysites in construction |
107 | @@ -2250,7 +2250,7 @@ | |||
108 | 2250 | // as long as it is > 1 - BUT take care that there is a warehouse in the | 2250 | // as long as it is > 1 - BUT take care that there is a warehouse in the |
109 | 2251 | // same economy where the thrown out soldiers can go to. | 2251 | // same economy where the thrown out soldiers can go to. |
110 | 2252 | if (ms->economy().warehouses().size()) { | 2252 | if (ms->economy().warehouses().size()) { |
112 | 2253 | uint32_t const j = ms->soldierCapacity(); | 2253 | uint32_t const j = ms->soldier_capacity(); |
113 | 2254 | 2254 | ||
114 | 2255 | if (MilitarySite::kPrefersRookies != ms->get_soldier_preference()) { | 2255 | if (MilitarySite::kPrefersRookies != ms->get_soldier_preference()) { |
115 | 2256 | game().send_player_militarysite_set_soldier_preference( | 2256 | game().send_player_militarysite_set_soldier_preference( |
116 | @@ -2283,8 +2283,8 @@ | |||
117 | 2283 | } else { | 2283 | } else { |
118 | 2284 | // If an enemy is in sight and the number of stationed soldier is not | 2284 | // If an enemy is in sight and the number of stationed soldier is not |
119 | 2285 | // at maximum - set it to maximum. | 2285 | // at maximum - set it to maximum. |
122 | 2286 | uint32_t const j = ms->maxSoldierCapacity(); | 2286 | uint32_t const j = ms->max_soldier_capacity(); |
123 | 2287 | uint32_t const k = ms->soldierCapacity(); | 2287 | uint32_t const k = ms->soldier_capacity(); |
124 | 2288 | 2288 | ||
125 | 2289 | if (j > k) | 2289 | if (j > k) |
126 | 2290 | // game().send_player_change_soldier_capacity(*ms, j - k); | 2290 | // game().send_player_change_soldier_capacity(*ms, j - k); |
127 | @@ -2696,11 +2696,11 @@ | |||
128 | 2696 | continue; | 2696 | continue; |
129 | 2697 | } | 2697 | } |
130 | 2698 | 2698 | ||
132 | 2699 | if (bld->canAttack()) { | 2699 | if (bld->can_attack()) { |
133 | 2700 | 2700 | ||
134 | 2701 | // any_attackable_building=true; | 2701 | // any_attackable_building=true; |
135 | 2702 | 2702 | ||
137 | 2703 | int32_t ta = player_->findAttackSoldiers(bld->base_flag()); | 2703 | int32_t ta = player_->find_attack_soldiers(bld->base_flag()); |
138 | 2704 | 2704 | ||
139 | 2705 | if (type_ == NORMAL) | 2705 | if (type_ == NORMAL) |
140 | 2706 | ta = ta * 2 / 3; | 2706 | ta = ta * 2 / 3; |
141 | @@ -2708,24 +2708,24 @@ | |||
142 | 2708 | if (ta < 1) | 2708 | if (ta < 1) |
143 | 2709 | continue; | 2709 | continue; |
144 | 2710 | 2710 | ||
146 | 2711 | int32_t const tc = ta - bld->presentSoldiers().size(); | 2711 | int32_t const tc = ta - bld->present_soldiers().size(); |
147 | 2712 | 2712 | ||
150 | 2713 | if (bld->presentSoldiers().size() > 1) | 2713 | if (bld->present_soldiers().size() > 1) |
151 | 2714 | defend_ready_enemies += bld->presentSoldiers().size() - 1; | 2714 | defend_ready_enemies += bld->present_soldiers().size() - 1; |
152 | 2715 | 2715 | ||
153 | 2716 | if (tc > chance) { | 2716 | if (tc > chance) { |
154 | 2717 | target = bld; | 2717 | target = bld; |
155 | 2718 | chance = tc; | 2718 | chance = tc; |
156 | 2719 | attackers = ta; | 2719 | attackers = ta; |
158 | 2720 | defenders = bld->presentSoldiers().size(); | 2720 | defenders = bld->present_soldiers().size(); |
159 | 2721 | } | 2721 | } |
160 | 2722 | } | 2722 | } |
161 | 2723 | } else if (upcast(Warehouse, wh, immovables.at(j).object)) { | 2723 | } else if (upcast(Warehouse, wh, immovables.at(j).object)) { |
162 | 2724 | if (!player_->is_hostile(wh->owner())) | 2724 | if (!player_->is_hostile(wh->owner())) |
163 | 2725 | continue; | 2725 | continue; |
164 | 2726 | 2726 | ||
167 | 2727 | if (wh->canAttack()) { | 2727 | if (wh->can_attack()) { |
168 | 2728 | int32_t ta = player_->findAttackSoldiers(wh->base_flag()); | 2728 | int32_t ta = player_->find_attack_soldiers(wh->base_flag()); |
169 | 2729 | 2729 | ||
170 | 2730 | if (ta < 1) | 2730 | if (ta < 1) |
171 | 2731 | continue; | 2731 | continue; |
172 | 2732 | 2732 | ||
173 | === modified file 'src/base/md5.h' | |||
174 | --- src/base/md5.h 2014-09-14 11:31:58 +0000 | |||
175 | +++ src/base/md5.h 2014-09-29 14:39:47 +0000 | |||
176 | @@ -65,8 +65,8 @@ | |||
177 | 65 | /** | 65 | /** |
178 | 66 | * This class is responsible for creating a streaming md5 checksum. | 66 | * This class is responsible for creating a streaming md5 checksum. |
179 | 67 | * You simply pass it the data using stream operations, and if you want | 67 | * You simply pass it the data using stream operations, and if you want |
182 | 68 | * to read the checksum, first call FinishChecksum(), followed by | 68 | * to read the checksum, first call finish_checksum(), followed by |
183 | 69 | * GetChecksum(). | 69 | * get_checksum(). |
184 | 70 | * | 70 | * |
185 | 71 | * Instances of this class can be copied. | 71 | * Instances of this class can be copied. |
186 | 72 | */ | 72 | */ |
187 | @@ -93,24 +93,24 @@ | |||
188 | 93 | /// | 93 | /// |
189 | 94 | /// \param data data to compute chksum for | 94 | /// \param data data to compute chksum for |
190 | 95 | /// \param size size of data | 95 | /// \param size size of data |
192 | 96 | void Data(const void * const newdata, const size_t size) { | 96 | void data(const void * const newdata, const size_t size) { |
193 | 97 | assert(can_handle_data); | 97 | assert(can_handle_data); |
194 | 98 | md5_process_bytes(newdata, size, &ctx); | 98 | md5_process_bytes(newdata, size, &ctx); |
195 | 99 | } | 99 | } |
196 | 100 | 100 | ||
197 | 101 | /// This function finishes the checksum calculation. | 101 | /// This function finishes the checksum calculation. |
198 | 102 | /// After this, no more data may be written to the checksum. | 102 | /// After this, no more data may be written to the checksum. |
200 | 103 | void FinishChecksum() { | 103 | void finish_checksum() { |
201 | 104 | assert(can_handle_data); | 104 | assert(can_handle_data); |
202 | 105 | can_handle_data = 0; | 105 | can_handle_data = 0; |
203 | 106 | md5_finish_ctx(&ctx, sum.data); | 106 | md5_finish_ctx(&ctx, sum.data); |
204 | 107 | } | 107 | } |
205 | 108 | 108 | ||
207 | 109 | /// Retrieve the checksum. Note that \ref FinishChecksum must be called | 109 | /// Retrieve the checksum. Note that \ref finish_checksum must be called |
208 | 110 | /// before this function. | 110 | /// before this function. |
209 | 111 | /// | 111 | /// |
210 | 112 | /// \return a pointer to an array of 16 bytes containing the checksum. | 112 | /// \return a pointer to an array of 16 bytes containing the checksum. |
212 | 113 | const Md5Checksum & GetChecksum() const { | 113 | const Md5Checksum & get_checksum() const { |
213 | 114 | assert(!can_handle_data); | 114 | assert(!can_handle_data); |
214 | 115 | return sum; | 115 | return sum; |
215 | 116 | } | 116 | } |
216 | 117 | 117 | ||
217 | === modified file 'src/chat/chat.h' | |||
218 | --- src/chat/chat.h 2014-07-16 07:44:33 +0000 | |||
219 | +++ src/chat/chat.h 2014-09-29 14:39:47 +0000 | |||
220 | @@ -62,14 +62,14 @@ | |||
221 | 62 | virtual ~ChatProvider(); | 62 | virtual ~ChatProvider(); |
222 | 63 | 63 | ||
223 | 64 | // Send the given chat message. The message may or may not | 64 | // Send the given chat message. The message may or may not |
225 | 65 | // appear in subsequent calls to \ref getMessages. | 65 | // appear in subsequent calls to \ref get_messages. |
226 | 66 | virtual void send(const std::string &) = 0; | 66 | virtual void send(const std::string &) = 0; |
227 | 67 | 67 | ||
228 | 68 | // \return a (chronological) list of received chat messages. | 68 | // \return a (chronological) list of received chat messages. |
229 | 69 | // This list need not be stable or monotonic. In other words, | 69 | // This list need not be stable or monotonic. In other words, |
230 | 70 | // subsequent calls to this functions may return a smaller or | 70 | // subsequent calls to this functions may return a smaller or |
231 | 71 | // greater number of chat messages. | 71 | // greater number of chat messages. |
233 | 72 | virtual const std::vector<ChatMessage>& getMessages() const = 0; | 72 | virtual const std::vector<ChatMessage>& get_messages() const = 0; |
234 | 73 | 73 | ||
235 | 74 | // reimplemented e.g. in internet_gaming to silence the chat if in game. | 74 | // reimplemented e.g. in internet_gaming to silence the chat if in game. |
236 | 75 | // TODO(sirver): this does not belong here. The receiver of the | 75 | // TODO(sirver): this does not belong here. The receiver of the |
237 | 76 | 76 | ||
238 | === modified file 'src/economy/cmd_call_economy_balance.cc' | |||
239 | --- src/economy/cmd_call_economy_balance.cc 2014-09-10 08:55:04 +0000 | |||
240 | +++ src/economy/cmd_call_economy_balance.cc 2014-09-29 14:39:47 +0000 | |||
241 | @@ -53,24 +53,24 @@ | |||
242 | 53 | /** | 53 | /** |
243 | 54 | * Read and write | 54 | * Read and write |
244 | 55 | */ | 55 | */ |
246 | 56 | void CmdCallEconomyBalance::Read | 56 | void CmdCallEconomyBalance::read |
247 | 57 | (FileRead & fr, EditorGameBase & egbase, MapObjectLoader & mol) | 57 | (FileRead & fr, EditorGameBase & egbase, MapObjectLoader & mol) |
248 | 58 | { | 58 | { |
249 | 59 | try { | 59 | try { |
251 | 60 | uint16_t const packet_version = fr.Unsigned16(); | 60 | uint16_t const packet_version = fr.unsigned_16(); |
252 | 61 | if (packet_version == CURRENT_CMD_CALL_ECONOMY_VERSION) { | 61 | if (packet_version == CURRENT_CMD_CALL_ECONOMY_VERSION) { |
255 | 62 | GameLogicCommand::Read(fr, egbase, mol); | 62 | GameLogicCommand::read(fr, egbase, mol); |
256 | 63 | uint32_t serial = fr.Unsigned32(); | 63 | uint32_t serial = fr.unsigned_32(); |
257 | 64 | if (serial) | 64 | if (serial) |
258 | 65 | m_flag = &mol.get<Flag>(serial); | 65 | m_flag = &mol.get<Flag>(serial); |
260 | 66 | m_timerid = fr.Unsigned32(); | 66 | m_timerid = fr.unsigned_32(); |
261 | 67 | } else if (packet_version == 1 || packet_version == 2) { | 67 | } else if (packet_version == 1 || packet_version == 2) { |
264 | 68 | GameLogicCommand::Read(fr, egbase, mol); | 68 | GameLogicCommand::read(fr, egbase, mol); |
265 | 69 | uint8_t const player_number = fr.Unsigned8(); | 69 | uint8_t const player_number = fr.unsigned_8(); |
266 | 70 | if (Player * const player = egbase.get_player(player_number)) { | 70 | if (Player * const player = egbase.get_player(player_number)) { |
268 | 71 | if (!fr.Unsigned8()) | 71 | if (!fr.unsigned_8()) |
269 | 72 | throw wexception("0 is not allowed here"); | 72 | throw wexception("0 is not allowed here"); |
271 | 73 | uint16_t const economy_number = fr.Unsigned16(); | 73 | uint16_t const economy_number = fr.unsigned_16(); |
272 | 74 | if (economy_number < player->get_nr_economies()) | 74 | if (economy_number < player->get_nr_economies()) |
273 | 75 | m_flag = | 75 | m_flag = |
274 | 76 | player->get_economy_by_number(economy_number) | 76 | player->get_economy_by_number(economy_number) |
275 | @@ -80,7 +80,7 @@ | |||
276 | 80 | } else | 80 | } else |
277 | 81 | throw wexception("invalid player number %u", player_number); | 81 | throw wexception("invalid player number %u", player_number); |
278 | 82 | if (packet_version >= 2) | 82 | if (packet_version >= 2) |
280 | 83 | m_timerid = fr.Unsigned32(); | 83 | m_timerid = fr.unsigned_32(); |
281 | 84 | else | 84 | else |
282 | 85 | m_timerid = 0; | 85 | m_timerid = 0; |
283 | 86 | } else | 86 | } else |
284 | @@ -90,18 +90,18 @@ | |||
285 | 90 | throw wexception("call economy balance: %s", e.what()); | 90 | throw wexception("call economy balance: %s", e.what()); |
286 | 91 | } | 91 | } |
287 | 92 | } | 92 | } |
289 | 93 | void CmdCallEconomyBalance::Write | 93 | void CmdCallEconomyBalance::write |
290 | 94 | (FileWrite & fw, EditorGameBase & egbase, MapObjectSaver & mos) | 94 | (FileWrite & fw, EditorGameBase & egbase, MapObjectSaver & mos) |
291 | 95 | { | 95 | { |
293 | 96 | fw.Unsigned16(CURRENT_CMD_CALL_ECONOMY_VERSION); | 96 | fw.unsigned_16(CURRENT_CMD_CALL_ECONOMY_VERSION); |
294 | 97 | 97 | ||
295 | 98 | // Write Base Commands | 98 | // Write Base Commands |
297 | 99 | GameLogicCommand::Write(fw, egbase, mos); | 99 | GameLogicCommand::write(fw, egbase, mos); |
298 | 100 | if (Flag * const flag = m_flag.get(egbase)) | 100 | if (Flag * const flag = m_flag.get(egbase)) |
300 | 101 | fw.Unsigned32(mos.get_object_file_index(*flag)); | 101 | fw.unsigned_32(mos.get_object_file_index(*flag)); |
301 | 102 | else | 102 | else |
304 | 103 | fw.Unsigned32(0); | 103 | fw.unsigned_32(0); |
305 | 104 | fw.Unsigned32(m_timerid); | 104 | fw.unsigned_32(m_timerid); |
306 | 105 | } | 105 | } |
307 | 106 | 106 | ||
308 | 107 | } | 107 | } |
309 | 108 | 108 | ||
310 | === modified file 'src/economy/cmd_call_economy_balance.h' | |||
311 | --- src/economy/cmd_call_economy_balance.h 2014-09-10 08:55:04 +0000 | |||
312 | +++ src/economy/cmd_call_economy_balance.h 2014-09-29 14:39:47 +0000 | |||
313 | @@ -39,8 +39,8 @@ | |||
314 | 39 | 39 | ||
315 | 40 | uint8_t id() const override {return QUEUE_CMD_CALL_ECONOMY_BALANCE;} | 40 | uint8_t id() const override {return QUEUE_CMD_CALL_ECONOMY_BALANCE;} |
316 | 41 | 41 | ||
319 | 42 | void Write(FileWrite &, EditorGameBase &, MapObjectSaver &) override; | 42 | void write(FileWrite &, EditorGameBase &, MapObjectSaver &) override; |
320 | 43 | void Read (FileRead &, EditorGameBase &, MapObjectLoader &) override; | 43 | void read (FileRead &, EditorGameBase &, MapObjectLoader &) override; |
321 | 44 | 44 | ||
322 | 45 | private: | 45 | private: |
323 | 46 | OPtr<Flag> m_flag; | 46 | OPtr<Flag> m_flag; |
324 | 47 | 47 | ||
325 | === modified file 'src/economy/economy.cc' | |||
326 | --- src/economy/economy.cc 2014-09-14 11:31:58 +0000 | |||
327 | +++ src/economy/economy.cc 2014-09-29 14:39:47 +0000 | |||
328 | @@ -718,9 +718,9 @@ | |||
329 | 718 | // alerts, so add info to the sync stream here. | 718 | // alerts, so add info to the sync stream here. |
330 | 719 | { | 719 | { |
331 | 720 | ::StreamWrite & ss = game.syncstream(); | 720 | ::StreamWrite & ss = game.syncstream(); |
335 | 721 | ss.Unsigned8 (req.get_type ()); | 721 | ss.unsigned_8 (req.get_type ()); |
336 | 722 | ss.Unsigned8 (req.get_index ()); | 722 | ss.unsigned_8 (req.get_index ()); |
337 | 723 | ss.Unsigned32(req.target ().serial()); | 723 | ss.unsigned_32(req.target ().serial()); |
338 | 724 | } | 724 | } |
339 | 725 | 725 | ||
340 | 726 | int32_t cost; // estimated time in milliseconds to fulfill Request | 726 | int32_t cost; // estimated time in milliseconds to fulfill Request |
341 | @@ -1017,12 +1017,12 @@ | |||
342 | 1017 | // to avoid potential future problems caused by the m_supplies changing | 1017 | // to avoid potential future problems caused by the m_supplies changing |
343 | 1018 | // under us in some way. | 1018 | // under us in some way. |
344 | 1019 | ::StreamWrite & ss = game.syncstream(); | 1019 | ::StreamWrite & ss = game.syncstream(); |
347 | 1020 | ss.Unsigned32(0x02decafa); // appears as facade02 in sync stream | 1020 | ss.unsigned_32(0x02decafa); // appears as facade02 in sync stream |
348 | 1021 | ss.Unsigned32(assignments.size()); | 1021 | ss.unsigned_32(assignments.size()); |
349 | 1022 | 1022 | ||
350 | 1023 | for (const std::pair<Supply *, Warehouse *>& temp_assignment : assignments) { | 1023 | for (const std::pair<Supply *, Warehouse *>& temp_assignment : assignments) { |
353 | 1024 | ss.Unsigned32(temp_assignment.first->get_position(game)->serial()); | 1024 | ss.unsigned_32(temp_assignment.first->get_position(game)->serial()); |
354 | 1025 | ss.Unsigned32(temp_assignment.second->serial()); | 1025 | ss.unsigned_32(temp_assignment.second->serial()); |
355 | 1026 | 1026 | ||
356 | 1027 | temp_assignment.first->send_to_storage(game, temp_assignment.second); | 1027 | temp_assignment.first->send_to_storage(game, temp_assignment.second); |
357 | 1028 | } | 1028 | } |
358 | 1029 | 1029 | ||
359 | === modified file 'src/economy/economy_data_packet.cc' | |||
360 | --- src/economy/economy_data_packet.cc 2014-09-10 16:57:31 +0000 | |||
361 | +++ src/economy/economy_data_packet.cc 2014-09-29 14:39:47 +0000 | |||
362 | @@ -31,20 +31,20 @@ | |||
363 | 31 | 31 | ||
364 | 32 | namespace Widelands { | 32 | namespace Widelands { |
365 | 33 | 33 | ||
367 | 34 | void EconomyDataPacket::Read(FileRead & fr) | 34 | void EconomyDataPacket::read(FileRead & fr) |
368 | 35 | { | 35 | { |
370 | 36 | uint16_t const version = fr.Unsigned16(); | 36 | uint16_t const version = fr.unsigned_16(); |
371 | 37 | 37 | ||
372 | 38 | try { | 38 | try { |
373 | 39 | if (1 <= version && version <= CURRENT_ECONOMY_VERSION) { | 39 | if (1 <= version && version <= CURRENT_ECONOMY_VERSION) { |
374 | 40 | if (2 <= version) | 40 | if (2 <= version) |
375 | 41 | try { | 41 | try { |
376 | 42 | const TribeDescr & tribe = m_eco->owner().tribe(); | 42 | const TribeDescr & tribe = m_eco->owner().tribe(); |
380 | 43 | while (Time const last_modified = fr.Unsigned32()) { | 43 | while (Time const last_modified = fr.unsigned_32()) { |
381 | 44 | char const * const type_name = fr.CString(); | 44 | char const * const type_name = fr.c_string(); |
382 | 45 | uint32_t const permanent = fr.Unsigned32(); | 45 | uint32_t const permanent = fr.unsigned_32(); |
383 | 46 | if (version <= 2) | 46 | if (version <= 2) |
385 | 47 | fr.Unsigned32(); | 47 | fr.unsigned_32(); |
386 | 48 | WareIndex i = tribe.ware_index(type_name); | 48 | WareIndex i = tribe.ware_index(type_name); |
387 | 49 | if (i != INVALID_INDEX) { | 49 | if (i != INVALID_INDEX) { |
388 | 50 | if (tribe.get_ware_descr(i)->default_target_quantity() == | 50 | if (tribe.get_ware_descr(i)->default_target_quantity() == |
389 | @@ -91,7 +91,7 @@ | |||
390 | 91 | } catch (const WException & e) { | 91 | } catch (const WException & e) { |
391 | 92 | throw GameDataError("target quantities: %s", e.what()); | 92 | throw GameDataError("target quantities: %s", e.what()); |
392 | 93 | } | 93 | } |
394 | 94 | m_eco->m_request_timerid = fr.Unsigned32(); | 94 | m_eco->m_request_timerid = fr.unsigned_32(); |
395 | 95 | } else { | 95 | } else { |
396 | 96 | throw GameDataError("unknown version %u", version); | 96 | throw GameDataError("unknown version %u", version); |
397 | 97 | } | 97 | } |
398 | @@ -100,18 +100,18 @@ | |||
399 | 100 | } | 100 | } |
400 | 101 | } | 101 | } |
401 | 102 | 102 | ||
403 | 103 | void EconomyDataPacket::Write(FileWrite & fw) | 103 | void EconomyDataPacket::write(FileWrite & fw) |
404 | 104 | { | 104 | { |
406 | 105 | fw.Unsigned16(CURRENT_ECONOMY_VERSION); | 105 | fw.unsigned_16(CURRENT_ECONOMY_VERSION); |
407 | 106 | const TribeDescr & tribe = m_eco->owner().tribe(); | 106 | const TribeDescr & tribe = m_eco->owner().tribe(); |
408 | 107 | for (WareIndex i = tribe.get_nrwares(); i;) { | 107 | for (WareIndex i = tribe.get_nrwares(); i;) { |
409 | 108 | --i; | 108 | --i; |
410 | 109 | const Economy::TargetQuantity & tq = | 109 | const Economy::TargetQuantity & tq = |
411 | 110 | m_eco->m_ware_target_quantities[i]; | 110 | m_eco->m_ware_target_quantities[i]; |
412 | 111 | if (Time const last_modified = tq.last_modified) { | 111 | if (Time const last_modified = tq.last_modified) { |
416 | 112 | fw.Unsigned32(last_modified); | 112 | fw.unsigned_32(last_modified); |
417 | 113 | fw.CString(tribe.get_ware_descr(i)->name()); | 113 | fw.c_string(tribe.get_ware_descr(i)->name()); |
418 | 114 | fw.Unsigned32(tq.permanent); | 114 | fw.unsigned_32(tq.permanent); |
419 | 115 | } | 115 | } |
420 | 116 | } | 116 | } |
421 | 117 | for (WareIndex i = tribe.get_nrworkers(); i;) { | 117 | for (WareIndex i = tribe.get_nrworkers(); i;) { |
422 | @@ -119,13 +119,13 @@ | |||
423 | 119 | const Economy::TargetQuantity & tq = | 119 | const Economy::TargetQuantity & tq = |
424 | 120 | m_eco->m_worker_target_quantities[i]; | 120 | m_eco->m_worker_target_quantities[i]; |
425 | 121 | if (Time const last_modified = tq.last_modified) { | 121 | if (Time const last_modified = tq.last_modified) { |
429 | 122 | fw.Unsigned32(last_modified); | 122 | fw.unsigned_32(last_modified); |
430 | 123 | fw.CString(tribe.get_worker_descr(i)->name()); | 123 | fw.c_string(tribe.get_worker_descr(i)->name()); |
431 | 124 | fw.Unsigned32(tq.permanent); | 124 | fw.unsigned_32(tq.permanent); |
432 | 125 | } | 125 | } |
433 | 126 | } | 126 | } |
436 | 127 | fw.Unsigned32(0); // terminator | 127 | fw.unsigned_32(0); // terminator |
437 | 128 | fw.Unsigned32(m_eco->m_request_timerid); | 128 | fw.unsigned_32(m_eco->m_request_timerid); |
438 | 129 | } | 129 | } |
439 | 130 | 130 | ||
440 | 131 | } | 131 | } |
441 | 132 | 132 | ||
442 | === modified file 'src/economy/economy_data_packet.h' | |||
443 | --- src/economy/economy_data_packet.h 2014-09-10 07:57:29 +0000 | |||
444 | +++ src/economy/economy_data_packet.h 2014-09-29 14:39:47 +0000 | |||
445 | @@ -33,8 +33,8 @@ | |||
446 | 33 | public: | 33 | public: |
447 | 34 | EconomyDataPacket(Economy * e) : m_eco(e) {} | 34 | EconomyDataPacket(Economy * e) : m_eco(e) {} |
448 | 35 | 35 | ||
451 | 36 | void Read(FileRead &); | 36 | void read(FileRead &); |
452 | 37 | void Write(FileWrite &); | 37 | void write(FileWrite &); |
453 | 38 | 38 | ||
454 | 39 | private: | 39 | private: |
455 | 40 | Economy * m_eco; | 40 | Economy * m_eco; |
456 | 41 | 41 | ||
457 | === modified file 'src/economy/fleet.cc' | |||
458 | --- src/economy/fleet.cc 2014-09-10 08:55:04 +0000 | |||
459 | +++ src/economy/fleet.cc 2014-09-29 14:39:47 +0000 | |||
460 | @@ -692,22 +692,22 @@ | |||
461 | 692 | 692 | ||
462 | 693 | Fleet & fleet = get<Fleet>(); | 693 | Fleet & fleet = get<Fleet>(); |
463 | 694 | 694 | ||
465 | 695 | uint32_t nrships = fr.Unsigned32(); | 695 | uint32_t nrships = fr.unsigned_32(); |
466 | 696 | m_ships.resize(nrships); | 696 | m_ships.resize(nrships); |
467 | 697 | for (uint32_t i = 0; i < nrships; ++i) | 697 | for (uint32_t i = 0; i < nrships; ++i) |
469 | 698 | m_ships[i] = fr.Unsigned32(); | 698 | m_ships[i] = fr.unsigned_32(); |
470 | 699 | 699 | ||
472 | 700 | uint32_t nrports = fr.Unsigned32(); | 700 | uint32_t nrports = fr.unsigned_32(); |
473 | 701 | m_ports.resize(nrports); | 701 | m_ports.resize(nrports); |
474 | 702 | for (uint32_t i = 0; i < nrports; ++i) | 702 | for (uint32_t i = 0; i < nrports; ++i) |
476 | 703 | m_ports[i] = fr.Unsigned32(); | 703 | m_ports[i] = fr.unsigned_32(); |
477 | 704 | 704 | ||
478 | 705 | if (version >= 2) { | 705 | if (version >= 2) { |
480 | 706 | fleet.m_act_pending = fr.Unsigned8(); | 706 | fleet.m_act_pending = fr.unsigned_8(); |
481 | 707 | if (version < 3) | 707 | if (version < 3) |
482 | 708 | fleet.m_act_pending = false; | 708 | fleet.m_act_pending = false; |
483 | 709 | if (version < 4) | 709 | if (version < 4) |
485 | 710 | fr.Unsigned32(); // m_roundrobin | 710 | fr.unsigned_32(); // m_roundrobin |
486 | 711 | } | 711 | } |
487 | 712 | } | 712 | } |
488 | 713 | 713 | ||
489 | @@ -756,9 +756,9 @@ | |||
490 | 756 | 756 | ||
491 | 757 | try { | 757 | try { |
492 | 758 | // The header has been peeled away by the caller | 758 | // The header has been peeled away by the caller |
494 | 759 | uint8_t const version = fr.Unsigned8(); | 759 | uint8_t const version = fr.unsigned_8(); |
495 | 760 | if (1 <= version && version <= FLEET_SAVEGAME_VERSION) { | 760 | if (1 <= version && version <= FLEET_SAVEGAME_VERSION) { |
497 | 761 | PlayerNumber owner_number = fr.Unsigned8(); | 761 | PlayerNumber owner_number = fr.unsigned_8(); |
498 | 762 | if (!owner_number || owner_number > egbase.map().get_nrplayers()) | 762 | if (!owner_number || owner_number > egbase.map().get_nrplayers()) |
499 | 763 | throw GameDataError | 763 | throw GameDataError |
500 | 764 | ("owner number is %u but there are only %u players", | 764 | ("owner number is %u but there are only %u players", |
501 | @@ -781,23 +781,23 @@ | |||
502 | 781 | 781 | ||
503 | 782 | void Fleet::save(EditorGameBase & egbase, MapObjectSaver & mos, FileWrite & fw) | 782 | void Fleet::save(EditorGameBase & egbase, MapObjectSaver & mos, FileWrite & fw) |
504 | 783 | { | 783 | { |
507 | 784 | fw.Unsigned8(HeaderFleet); | 784 | fw.unsigned_8(HeaderFleet); |
508 | 785 | fw.Unsigned8(FLEET_SAVEGAME_VERSION); | 785 | fw.unsigned_8(FLEET_SAVEGAME_VERSION); |
509 | 786 | 786 | ||
511 | 787 | fw.Unsigned8(m_owner.player_number()); | 787 | fw.unsigned_8(m_owner.player_number()); |
512 | 788 | 788 | ||
513 | 789 | MapObject::save(egbase, mos, fw); | 789 | MapObject::save(egbase, mos, fw); |
514 | 790 | 790 | ||
516 | 791 | fw.Unsigned32(m_ships.size()); | 791 | fw.unsigned_32(m_ships.size()); |
517 | 792 | for (const Ship * temp_ship : m_ships) { | 792 | for (const Ship * temp_ship : m_ships) { |
519 | 793 | fw.Unsigned32(mos.get_object_file_index(*temp_ship)); | 793 | fw.unsigned_32(mos.get_object_file_index(*temp_ship)); |
520 | 794 | } | 794 | } |
522 | 795 | fw.Unsigned32(m_ports.size()); | 795 | fw.unsigned_32(m_ports.size()); |
523 | 796 | for (const PortDock * temp_port : m_ports) { | 796 | for (const PortDock * temp_port : m_ports) { |
525 | 797 | fw.Unsigned32(mos.get_object_file_index(*temp_port)); | 797 | fw.unsigned_32(mos.get_object_file_index(*temp_port)); |
526 | 798 | } | 798 | } |
527 | 799 | 799 | ||
529 | 800 | fw.Unsigned8(m_act_pending); | 800 | fw.unsigned_8(m_act_pending); |
530 | 801 | } | 801 | } |
531 | 802 | 802 | ||
532 | 803 | } // namespace Widelands | 803 | } // namespace Widelands |
533 | 804 | 804 | ||
534 | === modified file 'src/economy/portdock.cc' | |||
535 | --- src/economy/portdock.cc 2014-09-10 10:18:46 +0000 | |||
536 | +++ src/economy/portdock.cc 2014-09-29 14:39:47 +0000 | |||
537 | @@ -478,29 +478,29 @@ | |||
538 | 478 | 478 | ||
539 | 479 | PortDock & pd = get<PortDock>(); | 479 | PortDock & pd = get<PortDock>(); |
540 | 480 | 480 | ||
543 | 481 | m_warehouse = fr.Unsigned32(); | 481 | m_warehouse = fr.unsigned_32(); |
544 | 482 | uint16_t nrdockpoints = fr.Unsigned16(); | 482 | uint16_t nrdockpoints = fr.unsigned_16(); |
545 | 483 | 483 | ||
546 | 484 | pd.m_dockpoints.resize(nrdockpoints); | 484 | pd.m_dockpoints.resize(nrdockpoints); |
547 | 485 | for (uint16_t i = 0; i < nrdockpoints; ++i) { | 485 | for (uint16_t i = 0; i < nrdockpoints; ++i) { |
549 | 486 | pd.m_dockpoints[i] = ReadCoords32(&fr, egbase().map().extent()); | 486 | pd.m_dockpoints[i] = read_coords_32(&fr, egbase().map().extent()); |
550 | 487 | pd.set_position(egbase(), pd.m_dockpoints[i]); | 487 | pd.set_position(egbase(), pd.m_dockpoints[i]); |
551 | 488 | } | 488 | } |
552 | 489 | 489 | ||
553 | 490 | if (version >= 2) { | 490 | if (version >= 2) { |
555 | 491 | pd.m_need_ship = fr.Unsigned8(); | 491 | pd.m_need_ship = fr.unsigned_8(); |
556 | 492 | 492 | ||
558 | 493 | m_waiting.resize(fr.Unsigned32()); | 493 | m_waiting.resize(fr.unsigned_32()); |
559 | 494 | for (ShippingItem::Loader& shipping_loader : m_waiting) { | 494 | for (ShippingItem::Loader& shipping_loader : m_waiting) { |
560 | 495 | shipping_loader.load(fr); | 495 | shipping_loader.load(fr); |
561 | 496 | } | 496 | } |
562 | 497 | 497 | ||
563 | 498 | if (version >= 3) { | 498 | if (version >= 3) { |
564 | 499 | // All the other expedition specific stuff is saved in the warehouse. | 499 | // All the other expedition specific stuff is saved in the warehouse. |
566 | 500 | if (fr.Unsigned8()) { // Do we have an expedition? | 500 | if (fr.unsigned_8()) { // Do we have an expedition? |
567 | 501 | pd.m_expedition_bootstrap.reset(new ExpeditionBootstrap(&pd)); | 501 | pd.m_expedition_bootstrap.reset(new ExpeditionBootstrap(&pd)); |
568 | 502 | } | 502 | } |
570 | 503 | pd.m_expedition_ready = (fr.Unsigned8() == 1) ? true : false; | 503 | pd.m_expedition_ready = (fr.unsigned_8() == 1) ? true : false; |
571 | 504 | } else { | 504 | } else { |
572 | 505 | pd.m_expedition_ready = false; | 505 | pd.m_expedition_ready = false; |
573 | 506 | } | 506 | } |
574 | @@ -545,7 +545,7 @@ | |||
575 | 545 | try { | 545 | try { |
576 | 546 | // The header has been peeled away by the caller | 546 | // The header has been peeled away by the caller |
577 | 547 | 547 | ||
579 | 548 | uint8_t const version = fr.Unsigned8(); | 548 | uint8_t const version = fr.unsigned_8(); |
580 | 549 | if (1 <= version && version <= PORTDOCK_SAVEGAME_VERSION) { | 549 | if (1 <= version && version <= PORTDOCK_SAVEGAME_VERSION) { |
581 | 550 | loader->init(egbase, mol, *new PortDock(nullptr)); | 550 | loader->init(egbase, mol, *new PortDock(nullptr)); |
582 | 551 | loader->load(fr, version); | 551 | loader->load(fr, version); |
583 | @@ -560,27 +560,27 @@ | |||
584 | 560 | 560 | ||
585 | 561 | void PortDock::save(EditorGameBase & egbase, MapObjectSaver & mos, FileWrite & fw) | 561 | void PortDock::save(EditorGameBase & egbase, MapObjectSaver & mos, FileWrite & fw) |
586 | 562 | { | 562 | { |
589 | 563 | fw.Unsigned8(HeaderPortDock); | 563 | fw.unsigned_8(HeaderPortDock); |
590 | 564 | fw.Unsigned8(PORTDOCK_SAVEGAME_VERSION); | 564 | fw.unsigned_8(PORTDOCK_SAVEGAME_VERSION); |
591 | 565 | 565 | ||
592 | 566 | PlayerImmovable::save(egbase, mos, fw); | 566 | PlayerImmovable::save(egbase, mos, fw); |
593 | 567 | 567 | ||
596 | 568 | fw.Unsigned32(mos.get_object_file_index(*m_warehouse)); | 568 | fw.unsigned_32(mos.get_object_file_index(*m_warehouse)); |
597 | 569 | fw.Unsigned16(m_dockpoints.size()); | 569 | fw.unsigned_16(m_dockpoints.size()); |
598 | 570 | for (const Coords& coords: m_dockpoints) { | 570 | for (const Coords& coords: m_dockpoints) { |
600 | 571 | WriteCoords32(&fw, coords); | 571 | write_coords_32(&fw, coords); |
601 | 572 | } | 572 | } |
602 | 573 | 573 | ||
604 | 574 | fw.Unsigned8(m_need_ship); | 574 | fw.unsigned_8(m_need_ship); |
605 | 575 | 575 | ||
607 | 576 | fw.Unsigned32(m_waiting.size()); | 576 | fw.unsigned_32(m_waiting.size()); |
608 | 577 | for (ShippingItem& shipping_item : m_waiting) { | 577 | for (ShippingItem& shipping_item : m_waiting) { |
609 | 578 | shipping_item.save(egbase, mos, fw); | 578 | shipping_item.save(egbase, mos, fw); |
610 | 579 | } | 579 | } |
611 | 580 | 580 | ||
612 | 581 | // Expedition specific stuff | 581 | // Expedition specific stuff |
615 | 582 | fw.Unsigned8(m_expedition_bootstrap.get() != nullptr ? 1 : 0); | 582 | fw.unsigned_8(m_expedition_bootstrap.get() != nullptr ? 1 : 0); |
616 | 583 | fw.Unsigned8(m_expedition_ready ? 1 : 0); | 583 | fw.unsigned_8(m_expedition_ready ? 1 : 0); |
617 | 584 | } | 584 | } |
618 | 585 | 585 | ||
619 | 586 | } // namespace Widelands | 586 | } // namespace Widelands |
620 | 587 | 587 | ||
621 | === modified file 'src/economy/request.cc' | |||
622 | --- src/economy/request.cc 2014-09-14 12:13:35 +0000 | |||
623 | +++ src/economy/request.cc 2014-09-29 14:39:47 +0000 | |||
624 | @@ -105,14 +105,14 @@ | |||
625 | 105 | * might have been initialized. We have to kill them and replace | 105 | * might have been initialized. We have to kill them and replace |
626 | 106 | * them through the data in the file | 106 | * them through the data in the file |
627 | 107 | */ | 107 | */ |
629 | 108 | void Request::Read | 108 | void Request::read |
630 | 109 | (FileRead & fr, Game & game, MapObjectLoader & mol) | 109 | (FileRead & fr, Game & game, MapObjectLoader & mol) |
631 | 110 | { | 110 | { |
632 | 111 | try { | 111 | try { |
634 | 112 | uint16_t const version = fr.Unsigned16(); | 112 | uint16_t const version = fr.unsigned_16(); |
635 | 113 | if (version == 6) { | 113 | if (version == 6) { |
636 | 114 | const TribeDescr& tribe = m_target.owner().tribe(); | 114 | const TribeDescr& tribe = m_target.owner().tribe(); |
638 | 115 | char const* const type_name = fr.CString(); | 115 | char const* const type_name = fr.c_string(); |
639 | 116 | WareIndex const wai = tribe.ware_index(type_name); | 116 | WareIndex const wai = tribe.ware_index(type_name); |
640 | 117 | if (wai != INVALID_INDEX) { | 117 | if (wai != INVALID_INDEX) { |
641 | 118 | m_type = wwWARE; | 118 | m_type = wwWARE; |
642 | @@ -123,32 +123,32 @@ | |||
643 | 123 | m_type = wwWORKER; | 123 | m_type = wwWORKER; |
644 | 124 | m_index = woi; | 124 | m_index = woi; |
645 | 125 | } else { | 125 | } else { |
647 | 126 | throw wexception("Request::Read: unknown type '%s'.\n", type_name); | 126 | throw wexception("Request::read: unknown type '%s'.\n", type_name); |
648 | 127 | } | 127 | } |
649 | 128 | } | 128 | } |
653 | 129 | m_count = fr.Unsigned32(); | 129 | m_count = fr.unsigned_32(); |
654 | 130 | m_required_time = fr.Unsigned32(); | 130 | m_required_time = fr.unsigned_32(); |
655 | 131 | m_required_interval = fr.Unsigned32(); | 131 | m_required_interval = fr.unsigned_32(); |
656 | 132 | 132 | ||
658 | 133 | m_last_request_time = fr.Unsigned32(); | 133 | m_last_request_time = fr.unsigned_32(); |
659 | 134 | 134 | ||
660 | 135 | assert(m_transfers.empty()); | 135 | assert(m_transfers.empty()); |
661 | 136 | 136 | ||
663 | 137 | uint16_t const nr_transfers = fr.Unsigned16(); | 137 | uint16_t const nr_transfers = fr.unsigned_16(); |
664 | 138 | for (uint16_t i = 0; i < nr_transfers; ++i) | 138 | for (uint16_t i = 0; i < nr_transfers; ++i) |
665 | 139 | try { | 139 | try { |
667 | 140 | MapObject* obj = &mol.get<MapObject>(fr.Unsigned32()); | 140 | MapObject* obj = &mol.get<MapObject>(fr.unsigned_32()); |
668 | 141 | Transfer* transfer; | 141 | Transfer* transfer; |
669 | 142 | 142 | ||
670 | 143 | if (upcast(Worker, worker, obj)) { | 143 | if (upcast(Worker, worker, obj)) { |
671 | 144 | transfer = worker->get_transfer(); | 144 | transfer = worker->get_transfer(); |
672 | 145 | if (m_type != wwWORKER || !worker->descr().can_act_as(m_index)) { | 145 | if (m_type != wwWORKER || !worker->descr().can_act_as(m_index)) { |
674 | 146 | throw wexception("Request::Read: incompatible transfer type"); | 146 | throw wexception("Request::read: incompatible transfer type"); |
675 | 147 | } | 147 | } |
676 | 148 | } else if (upcast(WareInstance, ware, obj)) { | 148 | } else if (upcast(WareInstance, ware, obj)) { |
677 | 149 | transfer = ware->get_transfer(); | 149 | transfer = ware->get_transfer(); |
678 | 150 | if (m_type != wwWARE || ware->descr_index() != m_index) { | 150 | if (m_type != wwWARE || ware->descr_index() != m_index) { |
680 | 151 | throw wexception("Request::Read: incompatible transfer type"); | 151 | throw wexception("Request::read: incompatible transfer type"); |
681 | 152 | } | 152 | } |
682 | 153 | } else { | 153 | } else { |
683 | 154 | throw wexception("transfer target %u is neither ware nor worker", obj->serial()); | 154 | throw wexception("transfer target %u is neither ware nor worker", obj->serial()); |
684 | @@ -164,7 +164,7 @@ | |||
685 | 164 | } catch (const WException& e) { | 164 | } catch (const WException& e) { |
686 | 165 | throw wexception("transfer %u: %s", i, e.what()); | 165 | throw wexception("transfer %u: %s", i, e.what()); |
687 | 166 | } | 166 | } |
689 | 167 | m_requirements.Read (fr, game, mol); | 167 | m_requirements.read (fr, game, mol); |
690 | 168 | if (!is_open() && m_economy) | 168 | if (!is_open() && m_economy) |
691 | 169 | m_economy->remove_request(*this); | 169 | m_economy->remove_request(*this); |
692 | 170 | } else | 170 | } else |
693 | @@ -177,10 +177,10 @@ | |||
694 | 177 | /** | 177 | /** |
695 | 178 | * Write this request to a file | 178 | * Write this request to a file |
696 | 179 | */ | 179 | */ |
698 | 180 | void Request::Write | 180 | void Request::write |
699 | 181 | (FileWrite & fw, Game & game, MapObjectSaver & mos) const | 181 | (FileWrite & fw, Game & game, MapObjectSaver & mos) const |
700 | 182 | { | 182 | { |
702 | 183 | fw.Unsigned16(REQUEST_VERSION); | 183 | fw.unsigned_16(REQUEST_VERSION); |
703 | 184 | 184 | ||
704 | 185 | // Target and econmy should be set. Same is true for callback stuff. | 185 | // Target and econmy should be set. Same is true for callback stuff. |
705 | 186 | 186 | ||
706 | @@ -188,30 +188,30 @@ | |||
707 | 188 | const TribeDescr & tribe = m_target.owner().tribe(); | 188 | const TribeDescr & tribe = m_target.owner().tribe(); |
708 | 189 | assert(m_type != wwWARE || m_index < tribe.get_nrwares ()); | 189 | assert(m_type != wwWARE || m_index < tribe.get_nrwares ()); |
709 | 190 | assert(m_type != wwWORKER || m_index < tribe.get_nrworkers()); | 190 | assert(m_type != wwWORKER || m_index < tribe.get_nrworkers()); |
711 | 191 | fw.CString | 191 | fw.c_string |
712 | 192 | (m_type == wwWARE ? | 192 | (m_type == wwWARE ? |
713 | 193 | tribe.get_ware_descr (m_index)->name() : | 193 | tribe.get_ware_descr (m_index)->name() : |
714 | 194 | tribe.get_worker_descr(m_index)->name()); | 194 | tribe.get_worker_descr(m_index)->name()); |
715 | 195 | 195 | ||
724 | 196 | fw.Unsigned32(m_count); | 196 | fw.unsigned_32(m_count); |
725 | 197 | 197 | ||
726 | 198 | fw.Unsigned32(m_required_time); | 198 | fw.unsigned_32(m_required_time); |
727 | 199 | fw.Unsigned32(m_required_interval); | 199 | fw.unsigned_32(m_required_interval); |
728 | 200 | 200 | ||
729 | 201 | fw.Unsigned32(m_last_request_time); | 201 | fw.unsigned_32(m_last_request_time); |
730 | 202 | 202 | ||
731 | 203 | fw.Unsigned16(m_transfers.size()); // Write number of current transfers. | 203 | fw.unsigned_16(m_transfers.size()); // Write number of current transfers. |
732 | 204 | for (uint32_t i = 0; i < m_transfers.size(); ++i) { | 204 | for (uint32_t i = 0; i < m_transfers.size(); ++i) { |
733 | 205 | Transfer & trans = *m_transfers[i]; | 205 | Transfer & trans = *m_transfers[i]; |
734 | 206 | if (trans.m_ware) { // write ware/worker | 206 | if (trans.m_ware) { // write ware/worker |
735 | 207 | assert(mos.is_object_known(*trans.m_ware)); | 207 | assert(mos.is_object_known(*trans.m_ware)); |
737 | 208 | fw.Unsigned32(mos.get_object_file_index(*trans.m_ware)); | 208 | fw.unsigned_32(mos.get_object_file_index(*trans.m_ware)); |
738 | 209 | } else if (trans.m_worker) { | 209 | } else if (trans.m_worker) { |
739 | 210 | assert(mos.is_object_known(*trans.m_worker)); | 210 | assert(mos.is_object_known(*trans.m_worker)); |
741 | 211 | fw.Unsigned32(mos.get_object_file_index(*trans.m_worker)); | 211 | fw.unsigned_32(mos.get_object_file_index(*trans.m_worker)); |
742 | 212 | } | 212 | } |
743 | 213 | } | 213 | } |
745 | 214 | m_requirements.Write (fw, game, mos); | 214 | m_requirements.write (fw, game, mos); |
746 | 215 | } | 215 | } |
747 | 216 | 216 | ||
748 | 217 | /** | 217 | /** |
749 | @@ -407,16 +407,16 @@ | |||
750 | 407 | assert(is_open()); | 407 | assert(is_open()); |
751 | 408 | 408 | ||
752 | 409 | ::StreamWrite & ss = game.syncstream(); | 409 | ::StreamWrite & ss = game.syncstream(); |
756 | 410 | ss.Unsigned32(0x01decafa); // appears as facade01 in sync stream | 410 | ss.unsigned_32(0x01decafa); // appears as facade01 in sync stream |
757 | 411 | ss.Unsigned32(target().serial()); | 411 | ss.unsigned_32(target().serial()); |
758 | 412 | ss.Unsigned32(supp.get_position(game)->serial()); | 412 | ss.unsigned_32(supp.get_position(game)->serial()); |
759 | 413 | 413 | ||
760 | 414 | Transfer * t; | 414 | Transfer * t; |
761 | 415 | if (get_type() == wwWORKER) { | 415 | if (get_type() == wwWORKER) { |
762 | 416 | // Begin the transfer of a soldier or worker. | 416 | // Begin the transfer of a soldier or worker. |
763 | 417 | // launch_worker() creates or starts the worker | 417 | // launch_worker() creates or starts the worker |
764 | 418 | Worker & s = supp.launch_worker(game, *this); | 418 | Worker & s = supp.launch_worker(game, *this); |
766 | 419 | ss.Unsigned32(s.serial()); | 419 | ss.unsigned_32(s.serial()); |
767 | 420 | t = new Transfer(game, *this, s); | 420 | t = new Transfer(game, *this, s); |
768 | 421 | } else { | 421 | } else { |
769 | 422 | // Begin the transfer of an ware. The ware itself is passive. | 422 | // Begin the transfer of an ware. The ware itself is passive. |
770 | @@ -424,7 +424,7 @@ | |||
771 | 424 | // warehouse. Once it's on the flag, the flag code will decide what to | 424 | // warehouse. Once it's on the flag, the flag code will decide what to |
772 | 425 | // do with it. | 425 | // do with it. |
773 | 426 | WareInstance & ware = supp.launch_ware(game, *this); | 426 | WareInstance & ware = supp.launch_ware(game, *this); |
775 | 427 | ss.Unsigned32(ware.serial()); | 427 | ss.unsigned_32(ware.serial()); |
776 | 428 | t = new Transfer(game, *this, ware); | 428 | t = new Transfer(game, *this, ware); |
777 | 429 | } | 429 | } |
778 | 430 | 430 | ||
779 | 431 | 431 | ||
780 | === modified file 'src/economy/request.h' | |||
781 | --- src/economy/request.h 2014-09-14 12:13:35 +0000 | |||
782 | +++ src/economy/request.h 2014-09-29 14:39:47 +0000 | |||
783 | @@ -93,8 +93,8 @@ | |||
784 | 93 | 93 | ||
785 | 94 | void start_transfer(Game &, Supply &); | 94 | void start_transfer(Game &, Supply &); |
786 | 95 | 95 | ||
789 | 96 | void Read (FileRead &, Game &, MapObjectLoader &); | 96 | void read (FileRead &, Game &, MapObjectLoader &); |
790 | 97 | void Write(FileWrite &, Game &, MapObjectSaver &) const; | 97 | void write(FileWrite &, Game &, MapObjectSaver &) const; |
791 | 98 | Worker * get_transfer_worker(); | 98 | Worker * get_transfer_worker(); |
792 | 99 | 99 | ||
793 | 100 | // callbacks for WareInstance/Worker code | 100 | // callbacks for WareInstance/Worker code |
794 | 101 | 101 | ||
795 | === modified file 'src/economy/road.cc' | |||
796 | --- src/economy/road.cc 2014-09-10 13:03:40 +0000 | |||
797 | +++ src/economy/road.cc 2014-09-29 14:39:47 +0000 | |||
798 | @@ -41,7 +41,7 @@ | |||
799 | 41 | return g_road_descr; | 41 | return g_road_descr; |
800 | 42 | } | 42 | } |
801 | 43 | 43 | ||
803 | 44 | bool Road::IsRoadDescr(MapObjectDescr const * const descr) | 44 | bool Road::is_road_descr(MapObjectDescr const * const descr) |
804 | 45 | { | 45 | { |
805 | 46 | return descr == &g_road_descr; | 46 | return descr == &g_road_descr; |
806 | 47 | } | 47 | } |
807 | @@ -480,7 +480,7 @@ | |||
808 | 480 | assert(static_cast<uint32_t>(index) < path.get_nsteps() - 1); | 480 | assert(static_cast<uint32_t>(index) < path.get_nsteps() - 1); |
809 | 481 | 481 | ||
810 | 482 | path.truncate(index); | 482 | path.truncate(index); |
812 | 483 | secondpath.starttrim(index); | 483 | secondpath.trim_start(index); |
813 | 484 | 484 | ||
814 | 485 | molog("splitting road: first part:\n"); | 485 | molog("splitting road: first part:\n"); |
815 | 486 | for (const Coords& coords : path.get_coords()) { | 486 | for (const Coords& coords : path.get_coords()) { |
816 | 487 | 487 | ||
817 | === modified file 'src/economy/road.h' | |||
818 | --- src/economy/road.h 2014-09-14 11:31:58 +0000 | |||
819 | +++ src/economy/road.h 2014-09-29 14:39:47 +0000 | |||
820 | @@ -63,7 +63,7 @@ | |||
821 | 63 | 63 | ||
822 | 64 | const RoadDescr& descr() const; | 64 | const RoadDescr& descr() const; |
823 | 65 | 65 | ||
825 | 66 | static bool IsRoadDescr(MapObjectDescr const *); | 66 | static bool is_road_descr(MapObjectDescr const *); |
826 | 67 | 67 | ||
827 | 68 | enum FlagId { | 68 | enum FlagId { |
828 | 69 | FlagStart = 0, | 69 | FlagStart = 0, |
829 | 70 | 70 | ||
830 | === modified file 'src/economy/route.cc' | |||
831 | --- src/economy/route.cc 2014-09-10 10:18:46 +0000 | |||
832 | +++ src/economy/route.cc 2014-09-29 14:39:47 +0000 | |||
833 | @@ -63,7 +63,7 @@ | |||
834 | 63 | /** | 63 | /** |
835 | 64 | * Remove the first count steps from the route. | 64 | * Remove the first count steps from the route. |
836 | 65 | */ | 65 | */ |
838 | 66 | void Route::starttrim(int32_t count) | 66 | void Route::trim_start(int32_t count) |
839 | 67 | { | 67 | { |
840 | 68 | assert(count < static_cast<int32_t>(m_route.size())); | 68 | assert(count < static_cast<int32_t>(m_route.size())); |
841 | 69 | 69 | ||
842 | @@ -91,10 +91,10 @@ | |||
843 | 91 | { | 91 | { |
844 | 92 | m_route.clear(); | 92 | m_route.clear(); |
845 | 93 | 93 | ||
848 | 94 | m_totalcost = fr.Signed32(); | 94 | m_totalcost = fr.signed_32(); |
849 | 95 | uint32_t nsteps = fr.Unsigned16(); | 95 | uint32_t nsteps = fr.unsigned_16(); |
850 | 96 | for (uint32_t step = 0; step < nsteps; ++step) | 96 | for (uint32_t step = 0; step < nsteps; ++step) |
852 | 97 | data.flags.push_back(fr.Unsigned32()); | 97 | data.flags.push_back(fr.unsigned_32()); |
853 | 98 | } | 98 | } |
854 | 99 | 99 | ||
855 | 100 | 100 | ||
856 | @@ -120,8 +120,8 @@ | |||
857 | 120 | void Route::save | 120 | void Route::save |
858 | 121 | (FileWrite & fw, EditorGameBase & egbase, MapObjectSaver & mos) | 121 | (FileWrite & fw, EditorGameBase & egbase, MapObjectSaver & mos) |
859 | 122 | { | 122 | { |
862 | 123 | fw.Signed32(get_totalcost()); | 123 | fw.signed_32(get_totalcost()); |
863 | 124 | fw.Unsigned16(m_route.size()); | 124 | fw.unsigned_16(m_route.size()); |
864 | 125 | for | 125 | for |
865 | 126 | (std::vector<ObjectPointer>::size_type idx = 0; | 126 | (std::vector<ObjectPointer>::size_type idx = 0; |
866 | 127 | idx < m_route.size(); | 127 | idx < m_route.size(); |
867 | @@ -129,7 +129,7 @@ | |||
868 | 129 | { | 129 | { |
869 | 130 | Flag & flag = get_flag(egbase, idx); | 130 | Flag & flag = get_flag(egbase, idx); |
870 | 131 | assert(mos.is_object_known(flag)); | 131 | assert(mos.is_object_known(flag)); |
872 | 132 | fw.Unsigned32(mos.get_object_file_index(flag)); | 132 | fw.unsigned_32(mos.get_object_file_index(flag)); |
873 | 133 | } | 133 | } |
874 | 134 | } | 134 | } |
875 | 135 | 135 | ||
876 | 136 | 136 | ||
877 | === modified file 'src/economy/route.h' | |||
878 | --- src/economy/route.h 2014-09-10 08:55:04 +0000 | |||
879 | +++ src/economy/route.h 2014-09-29 14:39:47 +0000 | |||
880 | @@ -50,7 +50,7 @@ | |||
881 | 50 | int32_t get_nrsteps() const {return m_route.size() - 1;} | 50 | int32_t get_nrsteps() const {return m_route.size() - 1;} |
882 | 51 | Flag & get_flag(EditorGameBase &, std::vector<Flag *>::size_type); | 51 | Flag & get_flag(EditorGameBase &, std::vector<Flag *>::size_type); |
883 | 52 | 52 | ||
885 | 53 | void starttrim(int32_t count); | 53 | void trim_start(int32_t count); |
886 | 54 | void truncate(int32_t count); | 54 | void truncate(int32_t count); |
887 | 55 | 55 | ||
888 | 56 | struct LoadData { | 56 | struct LoadData { |
889 | 57 | 57 | ||
890 | === modified file 'src/economy/shippingitem.cc' | |||
891 | --- src/economy/shippingitem.cc 2014-09-10 08:55:04 +0000 | |||
892 | +++ src/economy/shippingitem.cc 2014-09-29 14:39:47 +0000 | |||
893 | @@ -167,9 +167,9 @@ | |||
894 | 167 | 167 | ||
895 | 168 | void ShippingItem::Loader::load(FileRead & fr) | 168 | void ShippingItem::Loader::load(FileRead & fr) |
896 | 169 | { | 169 | { |
898 | 170 | uint8_t version = fr.Unsigned8(); | 170 | uint8_t version = fr.unsigned_8(); |
899 | 171 | if (1 <= version && version <= SHIPPINGITEM_SAVEGAME_VERSION) { | 171 | if (1 <= version && version <= SHIPPINGITEM_SAVEGAME_VERSION) { |
901 | 172 | m_serial = fr.Unsigned32(); | 172 | m_serial = fr.unsigned_32(); |
902 | 173 | } else | 173 | } else |
903 | 174 | throw GameDataError("unknown ShippingItem version %u", version); | 174 | throw GameDataError("unknown ShippingItem version %u", version); |
904 | 175 | } | 175 | } |
905 | @@ -184,8 +184,8 @@ | |||
906 | 184 | 184 | ||
907 | 185 | void ShippingItem::save(EditorGameBase & egbase, MapObjectSaver & mos, FileWrite & fw) | 185 | void ShippingItem::save(EditorGameBase & egbase, MapObjectSaver & mos, FileWrite & fw) |
908 | 186 | { | 186 | { |
911 | 187 | fw.Unsigned8(SHIPPINGITEM_SAVEGAME_VERSION); | 187 | fw.unsigned_8(SHIPPINGITEM_SAVEGAME_VERSION); |
912 | 188 | fw.Unsigned32(mos.get_object_file_index_or_zero(m_object.get(egbase))); | 188 | fw.unsigned_32(mos.get_object_file_index_or_zero(m_object.get(egbase))); |
913 | 189 | } | 189 | } |
914 | 190 | 190 | ||
915 | 191 | } // namespace Widelands | 191 | } // namespace Widelands |
916 | 192 | 192 | ||
917 | === modified file 'src/economy/transfer.cc' | |||
918 | --- src/economy/transfer.cc 2014-09-10 07:57:29 +0000 | |||
919 | +++ src/economy/transfer.cc 2014-09-29 14:39:47 +0000 | |||
920 | @@ -178,7 +178,7 @@ | |||
921 | 178 | if (m_route.get_nrsteps() >= 1) | 178 | if (m_route.get_nrsteps() >= 1) |
922 | 179 | if (upcast(Road const, road, location)) | 179 | if (upcast(Road const, road, location)) |
923 | 180 | if (&road->get_flag(Road::FlagEnd) == &m_route.get_flag(m_game, 1)) | 180 | if (&road->get_flag(Road::FlagEnd) == &m_route.get_flag(m_game, 1)) |
925 | 181 | m_route.starttrim(1); | 181 | m_route.trim_start(1); |
926 | 182 | 182 | ||
927 | 183 | if (m_route.get_nrsteps() >= 1) | 183 | if (m_route.get_nrsteps() >= 1) |
928 | 184 | if (upcast(Road const, road, destination)) | 184 | if (upcast(Road const, road, destination)) |
929 | @@ -316,11 +316,11 @@ | |||
930 | 316 | 316 | ||
931 | 317 | void Transfer::read(FileRead & fr, Transfer::ReadData & rd) | 317 | void Transfer::read(FileRead & fr, Transfer::ReadData & rd) |
932 | 318 | { | 318 | { |
934 | 319 | uint8_t version = fr.Unsigned8(); | 319 | uint8_t version = fr.unsigned_8(); |
935 | 320 | if (version != TRANSFER_SAVEGAME_VERSION) | 320 | if (version != TRANSFER_SAVEGAME_VERSION) |
936 | 321 | throw wexception("unhandled/unknown transfer version %u", version); | 321 | throw wexception("unhandled/unknown transfer version %u", version); |
937 | 322 | 322 | ||
939 | 323 | rd.destination = fr.Unsigned32(); | 323 | rd.destination = fr.unsigned_32(); |
940 | 324 | } | 324 | } |
941 | 325 | 325 | ||
942 | 326 | void Transfer::read_pointers | 326 | void Transfer::read_pointers |
943 | @@ -332,8 +332,8 @@ | |||
944 | 332 | 332 | ||
945 | 333 | void Transfer::write(MapObjectSaver & mos, FileWrite & fw) | 333 | void Transfer::write(MapObjectSaver & mos, FileWrite & fw) |
946 | 334 | { | 334 | { |
949 | 335 | fw.Unsigned8(TRANSFER_SAVEGAME_VERSION); | 335 | fw.unsigned_8(TRANSFER_SAVEGAME_VERSION); |
950 | 336 | fw.Unsigned32(mos.get_object_file_index_or_zero(m_destination.get(m_game))); | 336 | fw.unsigned_32(mos.get_object_file_index_or_zero(m_destination.get(m_game))); |
951 | 337 | // not saving route right now, will be recaculated anyway | 337 | // not saving route right now, will be recaculated anyway |
952 | 338 | } | 338 | } |
953 | 339 | 339 | ||
954 | 340 | 340 | ||
955 | === modified file 'src/economy/ware_instance.cc' | |||
956 | --- src/economy/ware_instance.cc 2014-09-10 10:18:46 +0000 | |||
957 | +++ src/economy/ware_instance.cc 2014-09-29 14:39:47 +0000 | |||
958 | @@ -557,9 +557,9 @@ | |||
959 | 557 | MapObject::Loader::load(fr); | 557 | MapObject::Loader::load(fr); |
960 | 558 | 558 | ||
961 | 559 | WareInstance & ware = get<WareInstance>(); | 559 | WareInstance & ware = get<WareInstance>(); |
965 | 560 | m_location = fr.Unsigned32(); | 560 | m_location = fr.unsigned_32(); |
966 | 561 | m_transfer_nextstep = fr.Unsigned32(); | 561 | m_transfer_nextstep = fr.unsigned_32(); |
967 | 562 | if (fr.Unsigned8()) { | 562 | if (fr.unsigned_8()) { |
968 | 563 | ware.m_transfer = | 563 | ware.m_transfer = |
969 | 564 | new Transfer(ref_cast<Game, EditorGameBase>(egbase()), ware); | 564 | new Transfer(ref_cast<Game, EditorGameBase>(egbase()), ware); |
970 | 565 | ware.m_transfer->read(fr, m_transfer); | 565 | ware.m_transfer->read(fr, m_transfer); |
971 | @@ -598,21 +598,21 @@ | |||
972 | 598 | void WareInstance::save | 598 | void WareInstance::save |
973 | 599 | (EditorGameBase & egbase, MapObjectSaver & mos, FileWrite & fw) | 599 | (EditorGameBase & egbase, MapObjectSaver & mos, FileWrite & fw) |
974 | 600 | { | 600 | { |
979 | 601 | fw.Unsigned8(HeaderWareInstance); | 601 | fw.unsigned_8(HeaderWareInstance); |
980 | 602 | fw.Unsigned8(WAREINSTANCE_SAVEGAME_VERSION); | 602 | fw.unsigned_8(WAREINSTANCE_SAVEGAME_VERSION); |
981 | 603 | fw.CString(descr().tribe().name()); | 603 | fw.c_string(descr().tribe().name()); |
982 | 604 | fw.CString(descr().name()); | 604 | fw.c_string(descr().name()); |
983 | 605 | 605 | ||
984 | 606 | MapObject::save(egbase, mos, fw); | 606 | MapObject::save(egbase, mos, fw); |
985 | 607 | 607 | ||
988 | 608 | fw.Unsigned32(mos.get_object_file_index_or_zero(m_location.get(egbase))); | 608 | fw.unsigned_32(mos.get_object_file_index_or_zero(m_location.get(egbase))); |
989 | 609 | fw.Unsigned32 | 609 | fw.unsigned_32 |
990 | 610 | (mos.get_object_file_index_or_zero(m_transfer_nextstep.get(egbase))); | 610 | (mos.get_object_file_index_or_zero(m_transfer_nextstep.get(egbase))); |
991 | 611 | if (m_transfer) { | 611 | if (m_transfer) { |
993 | 612 | fw.Unsigned8(1); | 612 | fw.unsigned_8(1); |
994 | 613 | m_transfer->write(mos, fw); | 613 | m_transfer->write(mos, fw); |
995 | 614 | } else { | 614 | } else { |
997 | 615 | fw.Unsigned8(0); | 615 | fw.unsigned_8(0); |
998 | 616 | } | 616 | } |
999 | 617 | } | 617 | } |
1000 | 618 | 618 | ||
1001 | @@ -620,13 +620,13 @@ | |||
1002 | 620 | (EditorGameBase & egbase, MapObjectLoader & mol, FileRead & fr) | 620 | (EditorGameBase & egbase, MapObjectLoader & mol, FileRead & fr) |
1003 | 621 | { | 621 | { |
1004 | 622 | try { | 622 | try { |
1006 | 623 | uint8_t version = fr.Unsigned8(); | 623 | uint8_t version = fr.unsigned_8(); |
1007 | 624 | 624 | ||
1008 | 625 | if (version != WAREINSTANCE_SAVEGAME_VERSION) | 625 | if (version != WAREINSTANCE_SAVEGAME_VERSION) |
1009 | 626 | throw wexception("unknown/unhandled version %i", version); | 626 | throw wexception("unknown/unhandled version %i", version); |
1010 | 627 | 627 | ||
1013 | 628 | const std::string tribename = fr.CString(); | 628 | const std::string tribename = fr.c_string(); |
1014 | 629 | const std::string warename = fr.CString(); | 629 | const std::string warename = fr.c_string(); |
1015 | 630 | 630 | ||
1016 | 631 | egbase.manually_load_tribe(tribename); | 631 | egbase.manually_load_tribe(tribename); |
1017 | 632 | 632 | ||
1018 | 633 | 633 | ||
1019 | === modified file 'src/economy/wares_queue.cc' | |||
1020 | --- src/economy/wares_queue.cc 2014-09-14 12:13:35 +0000 | |||
1021 | +++ src/economy/wares_queue.cc 2014-09-29 14:39:47 +0000 | |||
1022 | @@ -235,47 +235,47 @@ | |||
1023 | 235 | * Read and write | 235 | * Read and write |
1024 | 236 | */ | 236 | */ |
1025 | 237 | #define WARES_QUEUE_DATA_PACKET_VERSION 2 | 237 | #define WARES_QUEUE_DATA_PACKET_VERSION 2 |
1027 | 238 | void WaresQueue::Write(FileWrite & fw, Game & game, MapObjectSaver & mos) | 238 | void WaresQueue::write(FileWrite & fw, Game & game, MapObjectSaver & mos) |
1028 | 239 | { | 239 | { |
1030 | 240 | fw.Unsigned16(WARES_QUEUE_DATA_PACKET_VERSION); | 240 | fw.unsigned_16(WARES_QUEUE_DATA_PACKET_VERSION); |
1031 | 241 | 241 | ||
1032 | 242 | // Owner and callback is not saved, but this should be obvious on load. | 242 | // Owner and callback is not saved, but this should be obvious on load. |
1034 | 243 | fw.CString | 243 | fw.c_string |
1035 | 244 | (owner().tribe().get_ware_descr(m_ware)->name().c_str()); | 244 | (owner().tribe().get_ware_descr(m_ware)->name().c_str()); |
1040 | 245 | fw.Signed32(m_max_size); | 245 | fw.signed_32(m_max_size); |
1041 | 246 | fw.Signed32(m_max_fill); | 246 | fw.signed_32(m_max_fill); |
1042 | 247 | fw.Signed32(m_filled); | 247 | fw.signed_32(m_filled); |
1043 | 248 | fw.Signed32(m_consume_interval); | 248 | fw.signed_32(m_consume_interval); |
1044 | 249 | if (m_request) { | 249 | if (m_request) { |
1047 | 250 | fw.Unsigned8(1); | 250 | fw.unsigned_8(1); |
1048 | 251 | m_request->Write(fw, game, mos); | 251 | m_request->write(fw, game, mos); |
1049 | 252 | } else | 252 | } else |
1051 | 253 | fw.Unsigned8(0); | 253 | fw.unsigned_8(0); |
1052 | 254 | } | 254 | } |
1053 | 255 | 255 | ||
1054 | 256 | 256 | ||
1056 | 257 | void WaresQueue::Read(FileRead & fr, Game & game, MapObjectLoader & mol) | 257 | void WaresQueue::read(FileRead & fr, Game & game, MapObjectLoader & mol) |
1057 | 258 | { | 258 | { |
1059 | 259 | uint16_t const packet_version = fr.Unsigned16(); | 259 | uint16_t const packet_version = fr.unsigned_16(); |
1060 | 260 | try { | 260 | try { |
1061 | 261 | if (packet_version == WARES_QUEUE_DATA_PACKET_VERSION || packet_version == 1) { | 261 | if (packet_version == WARES_QUEUE_DATA_PACKET_VERSION || packet_version == 1) { |
1062 | 262 | delete m_request; | 262 | delete m_request; |
1065 | 263 | m_ware = owner().tribe().ware_index(fr.CString ()); | 263 | m_ware = owner().tribe().ware_index(fr.c_string ()); |
1066 | 264 | m_max_size = fr.Unsigned32(); | 264 | m_max_size = fr.unsigned_32(); |
1067 | 265 | if (packet_version == 1) | 265 | if (packet_version == 1) |
1068 | 266 | m_max_fill = m_max_size; | 266 | m_max_fill = m_max_size; |
1069 | 267 | else | 267 | else |
1075 | 268 | m_max_fill = fr.Signed32(); | 268 | m_max_fill = fr.signed_32(); |
1076 | 269 | m_filled = fr.Unsigned32(); | 269 | m_filled = fr.unsigned_32(); |
1077 | 270 | m_consume_interval = fr.Unsigned32(); | 270 | m_consume_interval = fr.unsigned_32(); |
1078 | 271 | if (fr.Unsigned8 ()) { | 271 | if (fr.unsigned_8 ()) { |
1079 | 272 | m_request = // TODO(unknown): Change Request::Read | 272 | m_request = // TODO(unknown): Change Request::read |
1080 | 273 | new Request // to a constructor. | 273 | new Request // to a constructor. |
1081 | 274 | (m_owner, | 274 | (m_owner, |
1082 | 275 | 0, | 275 | 0, |
1083 | 276 | WaresQueue::request_callback, | 276 | WaresQueue::request_callback, |
1084 | 277 | wwWORKER); | 277 | wwWORKER); |
1086 | 278 | m_request->Read(fr, game, mol); | 278 | m_request->read(fr, game, mol); |
1087 | 279 | } else | 279 | } else |
1088 | 280 | m_request = nullptr; | 280 | m_request = nullptr; |
1089 | 281 | 281 | ||
1090 | 282 | 282 | ||
1091 | === modified file 'src/economy/wares_queue.h' | |||
1092 | --- src/economy/wares_queue.h 2014-09-14 12:13:35 +0000 | |||
1093 | +++ src/economy/wares_queue.h 2014-09-29 14:39:47 +0000 | |||
1094 | @@ -67,8 +67,8 @@ | |||
1095 | 67 | 67 | ||
1096 | 68 | Player & owner() const {return m_owner.owner();} | 68 | Player & owner() const {return m_owner.owner();} |
1097 | 69 | 69 | ||
1100 | 70 | void Read (FileRead &, Game &, MapObjectLoader &); | 70 | void read (FileRead &, Game &, MapObjectLoader &); |
1101 | 71 | void Write(FileWrite &, Game &, MapObjectSaver &); | 71 | void write(FileWrite &, Game &, MapObjectSaver &); |
1102 | 72 | 72 | ||
1103 | 73 | private: | 73 | private: |
1104 | 74 | static void request_callback | 74 | static void request_callback |
1105 | 75 | 75 | ||
1106 | === modified file 'src/editor/editorinteractive.cc' | |||
1107 | --- src/editor/editorinteractive.cc 2014-09-14 16:08:13 +0000 | |||
1108 | +++ src/editor/editorinteractive.cc 2014-09-29 14:39:47 +0000 | |||
1109 | @@ -244,7 +244,7 @@ | |||
1110 | 244 | m_realtime = WLApplication::get()->get_time(); | 244 | m_realtime = WLApplication::get()->get_time(); |
1111 | 245 | frametime = m_realtime - lasttime; | 245 | frametime = m_realtime - lasttime; |
1112 | 246 | 246 | ||
1114 | 247 | egbase().get_game_time_pointer() += frametime; | 247 | egbase().get_gametime_pointer() += frametime; |
1115 | 248 | 248 | ||
1116 | 249 | g_gr->animate_maptextures(egbase().get_gametime()); | 249 | g_gr->animate_maptextures(egbase().get_gametime()); |
1117 | 250 | } | 250 | } |
1118 | 251 | 251 | ||
1119 | === modified file 'src/editor/map_generator.cc' | |||
1120 | --- src/editor/map_generator.cc 2014-09-14 11:31:58 +0000 | |||
1121 | +++ src/editor/map_generator.cc 2014-09-29 14:39:47 +0000 | |||
1122 | @@ -59,13 +59,13 @@ | |||
1123 | 59 | MapGenAreaInfo::MapGenTerrainType const terrType) | 59 | MapGenAreaInfo::MapGenTerrainType const terrType) |
1124 | 60 | { | 60 | { |
1125 | 61 | // Figure out which bob area is due here... | 61 | // Figure out which bob area is due here... |
1127 | 62 | size_t num = map_gen_info_->getNumLandResources(); | 62 | size_t num = map_gen_info_->get_num_land_resources(); |
1128 | 63 | size_t found = num; | 63 | size_t found = num; |
1130 | 64 | uint32_t sum_weight = map_gen_info_->getSumLandResourceWeight(); | 64 | uint32_t sum_weight = map_gen_info_->get_sum_land_resource_weight(); |
1131 | 65 | uint32_t max_val = 0; | 65 | uint32_t max_val = 0; |
1132 | 66 | for (size_t ix = 0; ix < num; ++ix) { | 66 | for (size_t ix = 0; ix < num; ++ix) { |
1133 | 67 | uint32_t val = random_bobs[ix][fc.x + map_info_.w * fc.y]; | 67 | uint32_t val = random_bobs[ix][fc.x + map_info_.w * fc.y]; |
1135 | 68 | val = (val / sum_weight) * map_gen_info_->getLandResource(ix).getWeight(); | 68 | val = (val / sum_weight) * map_gen_info_->get_land_resource(ix).get_weight(); |
1136 | 69 | if (val >= max_val) { | 69 | if (val >= max_val) { |
1137 | 70 | found = ix; | 70 | found = ix; |
1138 | 71 | max_val = val; | 71 | max_val = val; |
1139 | @@ -76,15 +76,15 @@ | |||
1140 | 76 | 76 | ||
1141 | 77 | // Figure out if we really need to set a bob here... | 77 | // Figure out if we really need to set a bob here... |
1142 | 78 | 78 | ||
1144 | 79 | const MapGenLandResource & landResource = map_gen_info_->getLandResource(found); | 79 | const MapGenLandResource & landResource = map_gen_info_->get_land_resource(found); |
1145 | 80 | 80 | ||
1147 | 81 | const MapGenBobCategory * bobCategory = landResource.getBobCategory(terrType); | 81 | const MapGenBobCategory * bobCategory = landResource.get_bob_category(terrType); |
1148 | 82 | 82 | ||
1149 | 83 | if (!bobCategory) // no bobs defined here... | 83 | if (!bobCategory) // no bobs defined here... |
1150 | 84 | return; | 84 | return; |
1151 | 85 | 85 | ||
1154 | 86 | uint32_t immovDens = landResource.getImmovableDensity(); | 86 | uint32_t immovDens = landResource.get_immovable_density(); |
1155 | 87 | uint32_t movDens = landResource.getMoveableDensity(); | 87 | uint32_t movDens = landResource.get_moveable_density(); |
1156 | 88 | 88 | ||
1157 | 89 | immovDens *= max_val / 100; | 89 | immovDens *= max_val / 100; |
1158 | 90 | movDens *= max_val / 100; | 90 | movDens *= max_val / 100; |
1159 | @@ -136,7 +136,7 @@ | |||
1160 | 136 | uint8_t res_val = static_cast<uint8_t>(random_value / (kMaxElevation / max_amount)); | 136 | uint8_t res_val = static_cast<uint8_t>(random_value / (kMaxElevation / max_amount)); |
1161 | 137 | res_val *= static_cast<uint8_t>(map_info_.resource_amount) + 1; | 137 | res_val *= static_cast<uint8_t>(map_info_.resource_amount) + 1; |
1162 | 138 | res_val /= 3; | 138 | res_val /= 3; |
1164 | 139 | if (Editor_Change_Resource_Tool_Callback(fc, map_, world, res_idx)) { | 139 | if (editor_change_resource_tool_callback(fc, map_, world, res_idx)) { |
1165 | 140 | fc.field->set_resources(res_idx, res_val); | 140 | fc.field->set_resources(res_idx, res_val); |
1166 | 141 | fc.field->set_starting_res_amount(res_val); | 141 | fc.field->set_starting_res_amount(res_val); |
1167 | 142 | } | 142 | } |
1168 | @@ -205,9 +205,9 @@ | |||
1169 | 205 | (double const elevation, | 205 | (double const elevation, |
1170 | 206 | Coords const c) | 206 | Coords const c) |
1171 | 207 | { | 207 | { |
1175 | 208 | int32_t const water_h = map_gen_info_->getWaterShallowHeight(); | 208 | int32_t const water_h = map_gen_info_->get_water_shallow_height(); |
1176 | 209 | int32_t const mount_h = map_gen_info_->getMountainFootHeight(); | 209 | int32_t const mount_h = map_gen_info_->get_mountain_foot_height(); |
1177 | 210 | int32_t const summit_h = map_gen_info_->getSummitHeight (); | 210 | int32_t const summit_h = map_gen_info_->get_summit_height (); |
1178 | 211 | 211 | ||
1179 | 212 | double const water_fac = map_info_.waterRatio; | 212 | double const water_fac = map_info_.waterRatio; |
1180 | 213 | double const land_fac = map_info_.landRatio; | 213 | double const land_fac = map_info_.landRatio; |
1181 | @@ -452,9 +452,9 @@ | |||
1182 | 452 | MapGenAreaInfo::MapGenTerrainType & terrType) | 452 | MapGenAreaInfo::MapGenTerrainType & terrType) |
1183 | 453 | { | 453 | { |
1184 | 454 | uint32_t numLandAreas = | 454 | uint32_t numLandAreas = |
1186 | 455 | map_gen_info_->getNumAreas(MapGenAreaInfo::atLand); | 455 | map_gen_info_->get_num_areas(MapGenAreaInfo::atLand); |
1187 | 456 | uint32_t const numWasteLandAreas = | 456 | uint32_t const numWasteLandAreas = |
1189 | 457 | map_gen_info_->getNumAreas(MapGenAreaInfo::atWasteland); | 457 | map_gen_info_->get_num_areas(MapGenAreaInfo::atWasteland); |
1190 | 458 | 458 | ||
1191 | 459 | bool isDesert = false; | 459 | bool isDesert = false; |
1192 | 460 | bool isDesertOuter = false; | 460 | bool isDesertOuter = false; |
1193 | @@ -516,10 +516,10 @@ | |||
1194 | 516 | landAreaIndex = 0; | 516 | landAreaIndex = 0; |
1195 | 517 | else if (numLandAreas == 2) { | 517 | else if (numLandAreas == 2) { |
1196 | 518 | uint32_t const weight1 = | 518 | uint32_t const weight1 = |
1198 | 519 | map_gen_info_->getArea(MapGenAreaInfo::atLand, 0).getWeight(); | 519 | map_gen_info_->get_area(MapGenAreaInfo::atLand, 0).get_weight(); |
1199 | 520 | uint32_t const weight2 = | 520 | uint32_t const weight2 = |
1202 | 521 | map_gen_info_->getArea(MapGenAreaInfo::atLand, 1).getWeight(); | 521 | map_gen_info_->get_area(MapGenAreaInfo::atLand, 1).get_weight(); |
1203 | 522 | uint32_t const sum = map_gen_info_->getSumLandWeight(); | 522 | uint32_t const sum = map_gen_info_->get_sum_land_weight(); |
1204 | 523 | if | 523 | if |
1205 | 524 | (weight1 * (random2[c0.x + map_info_.w * c0.y] / sum) | 524 | (weight1 * (random2[c0.x + map_info_.w * c0.y] / sum) |
1206 | 525 | >= | 525 | >= |
1207 | @@ -529,12 +529,12 @@ | |||
1208 | 529 | landAreaIndex = 1; | 529 | landAreaIndex = 1; |
1209 | 530 | } else { | 530 | } else { |
1210 | 531 | uint32_t const weight1 = | 531 | uint32_t const weight1 = |
1212 | 532 | map_gen_info_->getArea(MapGenAreaInfo::atLand, 0).getWeight(); | 532 | map_gen_info_->get_area(MapGenAreaInfo::atLand, 0).get_weight(); |
1213 | 533 | uint32_t const weight2 = | 533 | uint32_t const weight2 = |
1215 | 534 | map_gen_info_->getArea(MapGenAreaInfo::atLand, 1).getWeight(); | 534 | map_gen_info_->get_area(MapGenAreaInfo::atLand, 1).get_weight(); |
1216 | 535 | uint32_t const weight3 = | 535 | uint32_t const weight3 = |
1219 | 536 | map_gen_info_->getArea(MapGenAreaInfo::atLand, 2).getWeight(); | 536 | map_gen_info_->get_area(MapGenAreaInfo::atLand, 2).get_weight(); |
1220 | 537 | uint32_t const sum = map_gen_info_->getSumLandWeight(); | 537 | uint32_t const sum = map_gen_info_->get_sum_land_weight(); |
1221 | 538 | uint32_t const randomX = (rand2 + rand3) / 2; | 538 | uint32_t const randomX = (rand2 + rand3) / 2; |
1222 | 539 | if | 539 | if |
1223 | 540 | (weight1 * (rand2 / sum) > weight2 * (rand3 / sum) && | 540 | (weight1 * (rand2 / sum) > weight2 * (rand3 / sum) && |
1224 | @@ -557,14 +557,14 @@ | |||
1225 | 557 | 557 | ||
1226 | 558 | // see whether it is water | 558 | // see whether it is water |
1227 | 559 | 559 | ||
1229 | 560 | uint32_t const coast_h = map_gen_info_->getLandCoastHeight(); | 560 | uint32_t const coast_h = map_gen_info_->get_land_coast_height(); |
1230 | 561 | if (h1 <= coast_h && h2 <= coast_h && h3 <= coast_h) { // water or coast... | 561 | if (h1 <= coast_h && h2 <= coast_h && h3 <= coast_h) { // water or coast... |
1231 | 562 | atp = MapGenAreaInfo::atLand; | 562 | atp = MapGenAreaInfo::atLand; |
1232 | 563 | ttp = MapGenAreaInfo::ttLandCoast; | 563 | ttp = MapGenAreaInfo::ttLandCoast; |
1233 | 564 | 564 | ||
1237 | 565 | uint32_t const ocean_h = map_gen_info_->getWaterOceanHeight(); | 565 | uint32_t const ocean_h = map_gen_info_->get_water_ocean_height(); |
1238 | 566 | uint32_t const shelf_h = map_gen_info_->getWaterShelfHeight(); | 566 | uint32_t const shelf_h = map_gen_info_->get_water_shelf_height(); |
1239 | 567 | uint32_t const shallow_h = map_gen_info_->getWaterShallowHeight(); | 567 | uint32_t const shallow_h = map_gen_info_->get_water_shallow_height(); |
1240 | 568 | 568 | ||
1241 | 569 | // TODO(unknown): The heights can not be lower than water-Shallow -- | 569 | // TODO(unknown): The heights can not be lower than water-Shallow -- |
1242 | 570 | // there will never be an ocean yet | 570 | // there will never be an ocean yet |
1243 | @@ -580,10 +580,10 @@ | |||
1244 | 580 | ttp = MapGenAreaInfo::ttWaterShallow; | 580 | ttp = MapGenAreaInfo::ttWaterShallow; |
1245 | 581 | } | 581 | } |
1246 | 582 | } else { // it is not water | 582 | } else { // it is not water |
1251 | 583 | uint32_t const upper_h = map_gen_info_->getLandUpperHeight (); | 583 | uint32_t const upper_h = map_gen_info_->get_land_upper_height (); |
1252 | 584 | uint32_t const foot_h = map_gen_info_->getMountainFootHeight(); | 584 | uint32_t const foot_h = map_gen_info_->get_mountain_foot_height(); |
1253 | 585 | uint32_t const mount_h = map_gen_info_->getMountainHeight (); | 585 | uint32_t const mount_h = map_gen_info_->get_mountain_height (); |
1254 | 586 | uint32_t const snow_h = map_gen_info_->getSnowHeight (); | 586 | uint32_t const snow_h = map_gen_info_->get_snow_height (); |
1255 | 587 | if (h1 >= snow_h && h2 >= snow_h && h3 >= snow_h) { | 587 | if (h1 >= snow_h && h2 >= snow_h && h3 >= snow_h) { |
1256 | 588 | atp = MapGenAreaInfo::atMountains; | 588 | atp = MapGenAreaInfo::atMountains; |
1257 | 589 | ttp = MapGenAreaInfo::ttMountainsSnow; | 589 | ttp = MapGenAreaInfo::ttMountainsSnow; |
1258 | @@ -616,11 +616,11 @@ | |||
1259 | 616 | 616 | ||
1260 | 617 | // Figure out which terrain to use at this point in the map... | 617 | // Figure out which terrain to use at this point in the map... |
1261 | 618 | return | 618 | return |
1263 | 619 | map_gen_info_->getArea(atp, usedLandIndex).getTerrain | 619 | map_gen_info_->get_area(atp, usedLandIndex).get_terrain |
1264 | 620 | (ttp, | 620 | (ttp, |
1265 | 621 | rng.rand() | 621 | rng.rand() |
1266 | 622 | % | 622 | % |
1268 | 623 | map_gen_info_->getArea(atp, usedLandIndex).getNumTerrains(ttp)); | 623 | map_gen_info_->get_area(atp, usedLandIndex).get_num_terrains(ttp)); |
1269 | 624 | 624 | ||
1270 | 625 | } | 625 | } |
1271 | 626 | 626 | ||
1272 | @@ -663,9 +663,9 @@ | |||
1273 | 663 | 663 | ||
1274 | 664 | // for bobs | 664 | // for bobs |
1275 | 665 | std::unique_ptr<std::unique_ptr<uint32_t[]> []> random_bobs | 665 | std::unique_ptr<std::unique_ptr<uint32_t[]> []> random_bobs |
1277 | 666 | (new std::unique_ptr<uint32_t[]> [map_gen_info_->getNumLandResources()]); | 666 | (new std::unique_ptr<uint32_t[]> [map_gen_info_->get_num_land_resources()]); |
1278 | 667 | 667 | ||
1280 | 668 | for (size_t ix = 0; ix < map_gen_info_->getNumLandResources(); ++ix) | 668 | for (size_t ix = 0; ix < map_gen_info_->get_num_land_resources(); ++ix) |
1281 | 669 | random_bobs[ix].reset | 669 | random_bobs[ix].reset |
1282 | 670 | (generate_random_value_map(map_info_.w, map_info_.h, rng)); | 670 | (generate_random_value_map(map_info_.w, map_info_.h, rng)); |
1283 | 671 | 671 | ||
1284 | @@ -871,7 +871,7 @@ | |||
1285 | 871 | =============== | 871 | =============== |
1286 | 872 | */ | 872 | */ |
1287 | 873 | 873 | ||
1289 | 874 | int UniqueRandomMapInfo::mapIdCharToNumber(char ch) | 874 | int UniqueRandomMapInfo::map_id_char_to_number(char ch) |
1290 | 875 | { | 875 | { |
1291 | 876 | if ((ch == '0') || (ch == 'o') || (ch == 'O')) | 876 | if ((ch == '0') || (ch == 'o') || (ch == 'O')) |
1292 | 877 | return 22; | 877 | return 22; |
1293 | @@ -917,7 +917,7 @@ | |||
1294 | 917 | Return value: The converted value as a character | 917 | Return value: The converted value as a character |
1295 | 918 | =============== | 918 | =============== |
1296 | 919 | */ | 919 | */ |
1298 | 920 | char UniqueRandomMapInfo::mapIdNumberToChar(int32_t const num) | 920 | char UniqueRandomMapInfo::map_id_number_to_char(int32_t const num) |
1299 | 921 | { | 921 | { |
1300 | 922 | if (num == 22) | 922 | if (num == 22) |
1301 | 923 | return '0'; | 923 | return '0'; |
1302 | @@ -950,7 +950,7 @@ | |||
1303 | 950 | =============== | 950 | =============== |
1304 | 951 | */ | 951 | */ |
1305 | 952 | 952 | ||
1307 | 953 | bool UniqueRandomMapInfo::setFromIdString | 953 | bool UniqueRandomMapInfo::set_from_id_string |
1308 | 954 | (UniqueRandomMapInfo & mapInfo_out, const std::string & mapIdString) | 954 | (UniqueRandomMapInfo & mapInfo_out, const std::string & mapIdString) |
1309 | 955 | { | 955 | { |
1310 | 956 | // check string | 956 | // check string |
1311 | @@ -967,7 +967,7 @@ | |||
1312 | 967 | int32_t nums[kMapIdDigits]; | 967 | int32_t nums[kMapIdDigits]; |
1313 | 968 | 968 | ||
1314 | 969 | for (uint32_t ix = 0; ix < kMapIdDigits; ++ix) { | 969 | for (uint32_t ix = 0; ix < kMapIdDigits; ++ix) { |
1316 | 970 | int const num = mapIdCharToNumber(mapIdString[ix + (ix / 4)]); | 970 | int const num = map_id_char_to_number(mapIdString[ix + (ix / 4)]); |
1317 | 971 | if (num < 0) | 971 | if (num < 0) |
1318 | 972 | return false; | 972 | return false; |
1319 | 973 | nums[ix] = num; | 973 | nums[ix] = num; |
1320 | @@ -1050,7 +1050,7 @@ | |||
1321 | 1050 | begin created (map specific info) | 1050 | begin created (map specific info) |
1322 | 1051 | =============== | 1051 | =============== |
1323 | 1052 | */ | 1052 | */ |
1325 | 1053 | void UniqueRandomMapInfo::generateIdString | 1053 | void UniqueRandomMapInfo::generate_id_string |
1326 | 1054 | (std::string & mapIdsString_out, const UniqueRandomMapInfo & mapInfo) | 1054 | (std::string & mapIdsString_out, const UniqueRandomMapInfo & mapInfo) |
1327 | 1055 | { | 1055 | { |
1328 | 1056 | // Init | 1056 | // Init |
1329 | @@ -1070,7 +1070,7 @@ | |||
1330 | 1070 | nums[ix] = 0; | 1070 | nums[ix] = 0; |
1331 | 1071 | 1071 | ||
1332 | 1072 | // Generate world name hash | 1072 | // Generate world name hash |
1334 | 1073 | uint16_t nameHash = generateWorldNameHash(mapInfo.world_name); | 1073 | uint16_t nameHash = generate_world_name_hash(mapInfo.world_name); |
1335 | 1074 | 1074 | ||
1336 | 1075 | // Convert map random number | 1075 | // Convert map random number |
1337 | 1076 | nums [0] = mapInfo.mapNumber & 31; | 1076 | nums [0] = mapInfo.mapNumber & 31; |
1338 | @@ -1134,14 +1134,14 @@ | |||
1339 | 1134 | 1134 | ||
1340 | 1135 | // translate it to ASCII | 1135 | // translate it to ASCII |
1341 | 1136 | for (uint32_t ix = 0; ix < kMapIdDigits; ++ix) { | 1136 | for (uint32_t ix = 0; ix < kMapIdDigits; ++ix) { |
1343 | 1137 | mapIdsString_out += mapIdNumberToChar(nums[ix]); | 1137 | mapIdsString_out += map_id_number_to_char(nums[ix]); |
1344 | 1138 | if (ix % 4 == 3 && ix != kMapIdDigits - 1) | 1138 | if (ix % 4 == 3 && ix != kMapIdDigits - 1) |
1345 | 1139 | mapIdsString_out += "-"; | 1139 | mapIdsString_out += "-"; |
1346 | 1140 | } | 1140 | } |
1347 | 1141 | } | 1141 | } |
1348 | 1142 | 1142 | ||
1349 | 1143 | 1143 | ||
1351 | 1144 | uint16_t Widelands::UniqueRandomMapInfo::generateWorldNameHash | 1144 | uint16_t Widelands::UniqueRandomMapInfo::generate_world_name_hash |
1352 | 1145 | (const std::string & name) | 1145 | (const std::string & name) |
1353 | 1146 | { | 1146 | { |
1354 | 1147 | // This is only a simple digest algorithm. Thats enough for our purposes. | 1147 | // This is only a simple digest algorithm. Thats enough for our purposes. |
1355 | 1148 | 1148 | ||
1356 | === modified file 'src/editor/map_generator.h' | |||
1357 | --- src/editor/map_generator.h 2014-09-10 10:18:46 +0000 | |||
1358 | +++ src/editor/map_generator.h 2014-09-29 14:39:47 +0000 | |||
1359 | @@ -63,15 +63,15 @@ | |||
1360 | 63 | bool islandMode; // whether the world will be an island | 63 | bool islandMode; // whether the world will be an island |
1361 | 64 | 64 | ||
1362 | 65 | // other stuff | 65 | // other stuff |
1364 | 66 | static bool setFromIdString | 66 | static bool set_from_id_string |
1365 | 67 | (UniqueRandomMapInfo & mapInfo_out, const std::string & mapIdString); | 67 | (UniqueRandomMapInfo & mapInfo_out, const std::string & mapIdString); |
1367 | 68 | static void generateIdString | 68 | static void generate_id_string |
1368 | 69 | (std::string & mapIdsString_out, const UniqueRandomMapInfo & mapInfo); | 69 | (std::string & mapIdsString_out, const UniqueRandomMapInfo & mapInfo); |
1369 | 70 | 70 | ||
1370 | 71 | private: | 71 | private: |
1374 | 72 | static int mapIdCharToNumber(char); | 72 | static int map_id_char_to_number(char); |
1375 | 73 | static char mapIdNumberToChar(int32_t); | 73 | static char map_id_number_to_char(int32_t); |
1376 | 74 | static uint16_t generateWorldNameHash(const std::string &); | 74 | static uint16_t generate_world_name_hash(const std::string &); |
1377 | 75 | }; | 75 | }; |
1378 | 76 | 76 | ||
1379 | 77 | 77 | ||
1380 | 78 | 78 | ||
1381 | === modified file 'src/editor/tools/editor_decrease_resources_tool.cc' | |||
1382 | --- src/editor/tools/editor_decrease_resources_tool.cc 2014-09-10 14:08:25 +0000 | |||
1383 | +++ src/editor/tools/editor_decrease_resources_tool.cc 2014-09-29 14:39:47 +0000 | |||
1384 | @@ -57,7 +57,7 @@ | |||
1385 | 57 | args.orgRes.push_back(mr.location().field->get_resources_amount()); | 57 | args.orgRes.push_back(mr.location().field->get_resources_amount()); |
1386 | 58 | 58 | ||
1387 | 59 | if (res == args.cur_res && | 59 | if (res == args.cur_res && |
1389 | 60 | Editor_Change_Resource_Tool_Callback(mr.location(), map, world, args.cur_res)) { | 60 | editor_change_resource_tool_callback(mr.location(), map, world, args.cur_res)) { |
1390 | 61 | // Ok, we're doing something. First remove the current overlays. | 61 | // Ok, we're doing something. First remove the current overlays. |
1391 | 62 | std::string str = | 62 | std::string str = |
1392 | 63 | world.get_resource(res)->get_editor_pic | 63 | world.get_resource(res)->get_editor_pic |
1393 | 64 | 64 | ||
1394 | === modified file 'src/editor/tools/editor_increase_resources_tool.cc' | |||
1395 | --- src/editor/tools/editor_increase_resources_tool.cc 2014-09-10 14:08:25 +0000 | |||
1396 | +++ src/editor/tools/editor_increase_resources_tool.cc 2014-09-29 14:39:47 +0000 | |||
1397 | @@ -46,7 +46,7 @@ | |||
1398 | 46 | } // namespace | 46 | } // namespace |
1399 | 47 | 47 | ||
1400 | 48 | 48 | ||
1402 | 49 | int32_t Editor_Change_Resource_Tool_Callback | 49 | int32_t editor_change_resource_tool_callback |
1403 | 50 | (const TCoords<Widelands::FCoords>& c, Widelands::Map& map, | 50 | (const TCoords<Widelands::FCoords>& c, Widelands::Map& map, |
1404 | 51 | const Widelands::World& world, int32_t const curres) | 51 | const Widelands::World& world, int32_t const curres) |
1405 | 52 | { | 52 | { |
1406 | @@ -110,7 +110,7 @@ | |||
1407 | 110 | if | 110 | if |
1408 | 111 | ((res == args.cur_res || !mr.location().field->get_resources_amount()) | 111 | ((res == args.cur_res || !mr.location().field->get_resources_amount()) |
1409 | 112 | && | 112 | && |
1411 | 113 | Editor_Change_Resource_Tool_Callback(mr.location(), map, world, args.cur_res)) | 113 | editor_change_resource_tool_callback(mr.location(), map, world, args.cur_res)) |
1412 | 114 | { | 114 | { |
1413 | 115 | // Ok, we're doing something. First remove the current overlays. | 115 | // Ok, we're doing something. First remove the current overlays. |
1414 | 116 | const Image* pic = | 116 | const Image* pic = |
1415 | 117 | 117 | ||
1416 | === modified file 'src/editor/tools/editor_increase_resources_tool.h' | |||
1417 | --- src/editor/tools/editor_increase_resources_tool.h 2014-09-10 14:08:25 +0000 | |||
1418 | +++ src/editor/tools/editor_increase_resources_tool.h 2014-09-29 14:39:47 +0000 | |||
1419 | @@ -72,7 +72,7 @@ | |||
1420 | 72 | Widelands::ResourceIndex m_cur_res; | 72 | Widelands::ResourceIndex m_cur_res; |
1421 | 73 | }; | 73 | }; |
1422 | 74 | 74 | ||
1424 | 75 | int32_t Editor_Change_Resource_Tool_Callback | 75 | int32_t editor_change_resource_tool_callback |
1425 | 76 | (const Widelands::TCoords<Widelands::FCoords>& c, Widelands::Map& map, | 76 | (const Widelands::TCoords<Widelands::FCoords>& c, Widelands::Map& map, |
1426 | 77 | const Widelands::World& world, int32_t const curres); | 77 | const Widelands::World& world, int32_t const curres); |
1427 | 78 | 78 | ||
1428 | 79 | 79 | ||
1429 | === modified file 'src/editor/tools/editor_make_infrastructure_tool.cc' | |||
1430 | --- src/editor/tools/editor_make_infrastructure_tool.cc 2014-09-10 14:08:25 +0000 | |||
1431 | +++ src/editor/tools/editor_make_infrastructure_tool.cc 2014-09-29 14:39:47 +0000 | |||
1432 | @@ -31,7 +31,7 @@ | |||
1433 | 31 | * Callback function to calculate correct overlays | 31 | * Callback function to calculate correct overlays |
1434 | 32 | */ | 32 | */ |
1435 | 33 | int32_t | 33 | int32_t |
1437 | 34 | Editor_Make_Infrastructure_Tool_Callback | 34 | editor_make_infrastructure_tool_callback |
1438 | 35 | (const Widelands::TCoords<Widelands::FCoords>& c, | 35 | (const Widelands::TCoords<Widelands::FCoords>& c, |
1439 | 36 | Widelands::EditorGameBase& egbase, | 36 | Widelands::EditorGameBase& egbase, |
1440 | 37 | int32_t const player) | 37 | int32_t const player) |
1441 | 38 | 38 | ||
1442 | === modified file 'src/editor/tools/editor_make_infrastructure_tool.h' | |||
1443 | --- src/editor/tools/editor_make_infrastructure_tool.h 2014-09-10 14:08:25 +0000 | |||
1444 | +++ src/editor/tools/editor_make_infrastructure_tool.h 2014-09-29 14:39:47 +0000 | |||
1445 | @@ -53,7 +53,7 @@ | |||
1446 | 53 | UI::UniqueWindow::Registry m_registry; | 53 | UI::UniqueWindow::Registry m_registry; |
1447 | 54 | }; | 54 | }; |
1448 | 55 | 55 | ||
1450 | 56 | int32_t Editor_Make_Infrastructure_Tool_Callback | 56 | int32_t editor_make_infrastructure_tool_callback |
1451 | 57 | (const Widelands::TCoords<Widelands::FCoords>& c, | 57 | (const Widelands::TCoords<Widelands::FCoords>& c, |
1452 | 58 | Widelands::EditorGameBase& egbase, int32_t const player); | 58 | Widelands::EditorGameBase& egbase, int32_t const player); |
1453 | 59 | 59 | ||
1454 | 60 | 60 | ||
1455 | === modified file 'src/editor/tools/editor_set_port_space_tool.cc' | |||
1456 | --- src/editor/tools/editor_set_port_space_tool.cc 2014-09-10 14:08:25 +0000 | |||
1457 | +++ src/editor/tools/editor_set_port_space_tool.cc 2014-09-29 14:39:47 +0000 | |||
1458 | @@ -30,7 +30,7 @@ | |||
1459 | 30 | using namespace Widelands; | 30 | using namespace Widelands; |
1460 | 31 | 31 | ||
1461 | 32 | /// static callback function for overlay calculation | 32 | /// static callback function for overlay calculation |
1463 | 33 | int32_t Editor_Tool_Set_Port_Space_Callback | 33 | int32_t editor_Tool_set_port_space_callback |
1464 | 34 | (const Widelands::TCoords<Widelands::FCoords>& c, Map& map) | 34 | (const Widelands::TCoords<Widelands::FCoords>& c, Map& map) |
1465 | 35 | { | 35 | { |
1466 | 36 | NodeCaps const caps = c.field->nodecaps(); | 36 | NodeCaps const caps = c.field->nodecaps(); |
1467 | @@ -71,7 +71,7 @@ | |||
1468 | 71 | (map, Widelands::Area<Widelands::FCoords>(map.get_fcoords(center.node), args.sel_radius)); | 71 | (map, Widelands::Area<Widelands::FCoords>(map.get_fcoords(center.node), args.sel_radius)); |
1469 | 72 | do { | 72 | do { |
1470 | 73 | // check if field is valid | 73 | // check if field is valid |
1472 | 74 | if (Editor_Tool_Set_Port_Space_Callback(mr.location(), map)) { | 74 | if (editor_Tool_set_port_space_callback(mr.location(), map)) { |
1473 | 75 | map.set_port_space(mr.location(), true); | 75 | map.set_port_space(mr.location(), true); |
1474 | 76 | Area<FCoords> a(mr.location(), 0); | 76 | Area<FCoords> a(mr.location(), 0); |
1475 | 77 | map.recalc_for_field_area(world, a); | 77 | map.recalc_for_field_area(world, a); |
1476 | @@ -106,7 +106,7 @@ | |||
1477 | 106 | (map, Widelands::Area<Widelands::FCoords>(map.get_fcoords(center.node), args.sel_radius)); | 106 | (map, Widelands::Area<Widelands::FCoords>(map.get_fcoords(center.node), args.sel_radius)); |
1478 | 107 | do { | 107 | do { |
1479 | 108 | // check if field is valid | 108 | // check if field is valid |
1481 | 109 | if (Editor_Tool_Set_Port_Space_Callback(mr.location(), map)) { | 109 | if (editor_Tool_set_port_space_callback(mr.location(), map)) { |
1482 | 110 | map.set_port_space(mr.location(), false); | 110 | map.set_port_space(mr.location(), false); |
1483 | 111 | Area<FCoords> a(mr.location(), 0); | 111 | Area<FCoords> a(mr.location(), 0); |
1484 | 112 | map.recalc_for_field_area(world, a); | 112 | map.recalc_for_field_area(world, a); |
1485 | 113 | 113 | ||
1486 | === modified file 'src/editor/tools/editor_set_port_space_tool.h' | |||
1487 | --- src/editor/tools/editor_set_port_space_tool.h 2014-09-10 14:08:25 +0000 | |||
1488 | +++ src/editor/tools/editor_set_port_space_tool.h 2014-09-29 14:39:47 +0000 | |||
1489 | @@ -67,7 +67,7 @@ | |||
1490 | 67 | char const * get_sel_impl() const override {return FSEL_ESPS_FILENAME;} | 67 | char const * get_sel_impl() const override {return FSEL_ESPS_FILENAME;} |
1491 | 68 | }; | 68 | }; |
1492 | 69 | 69 | ||
1494 | 70 | int32_t Editor_Tool_Set_Port_Space_Callback | 70 | int32_t editor_Tool_set_port_space_callback |
1495 | 71 | (const Widelands::TCoords<Widelands::FCoords>& c, Widelands::Map& map); | 71 | (const Widelands::TCoords<Widelands::FCoords>& c, Widelands::Map& map); |
1496 | 72 | 72 | ||
1497 | 73 | #endif // end of include guard: WL_EDITOR_TOOLS_EDITOR_SET_PORT_SPACE_TOOL_H | 73 | #endif // end of include guard: WL_EDITOR_TOOLS_EDITOR_SET_PORT_SPACE_TOOL_H |
1498 | 74 | 74 | ||
1499 | === modified file 'src/editor/tools/editor_set_resources_tool.cc' | |||
1500 | --- src/editor/tools/editor_set_resources_tool.cc 2014-09-10 14:08:25 +0000 | |||
1501 | +++ src/editor/tools/editor_set_resources_tool.cc 2014-09-29 14:39:47 +0000 | |||
1502 | @@ -55,7 +55,7 @@ | |||
1503 | 55 | args.orgResT.push_back(res); | 55 | args.orgResT.push_back(res); |
1504 | 56 | args.orgRes.push_back(mr.location().field->get_resources_amount()); | 56 | args.orgRes.push_back(mr.location().field->get_resources_amount()); |
1505 | 57 | 57 | ||
1507 | 58 | if (Editor_Change_Resource_Tool_Callback(mr.location(), map, world, args.cur_res)) { | 58 | if (editor_change_resource_tool_callback(mr.location(), map, world, args.cur_res)) { |
1508 | 59 | // Ok, we're doing something. First remove the current overlays. | 59 | // Ok, we're doing something. First remove the current overlays. |
1509 | 60 | const Image* pic = g_gr->images().get | 60 | const Image* pic = g_gr->images().get |
1510 | 61 | (world.get_resource(res)->get_editor_pic (mr.location().field->get_resources_amount())); | 61 | (world.get_resource(res)->get_editor_pic (mr.location().field->get_resources_amount())); |
1511 | 62 | 62 | ||
1512 | === modified file 'src/editor/tools/editor_set_starting_pos_tool.cc' | |||
1513 | --- src/editor/tools/editor_set_starting_pos_tool.cc 2014-09-10 14:08:25 +0000 | |||
1514 | +++ src/editor/tools/editor_set_starting_pos_tool.cc 2014-09-29 14:39:47 +0000 | |||
1515 | @@ -32,7 +32,7 @@ | |||
1516 | 32 | /* | 32 | /* |
1517 | 33 | * static callback function for overlay calculation | 33 | * static callback function for overlay calculation |
1518 | 34 | */ | 34 | */ |
1520 | 35 | int32_t Editor_Tool_Set_Starting_Pos_Callback | 35 | int32_t editor_tool_set_starting_pos_callback |
1521 | 36 | (const Widelands::TCoords<Widelands::FCoords>& c, Widelands::Map& map) | 36 | (const Widelands::TCoords<Widelands::FCoords>& c, Widelands::Map& map) |
1522 | 37 | { | 37 | { |
1523 | 38 | // Area around already placed players | 38 | // Area around already placed players |
1524 | @@ -88,7 +88,7 @@ | |||
1525 | 88 | const Image* pic = g_gr->images().get(picname); | 88 | const Image* pic = g_gr->images().get(picname); |
1526 | 89 | 89 | ||
1527 | 90 | // check if field is valid | 90 | // check if field is valid |
1529 | 91 | if (Editor_Tool_Set_Starting_Pos_Callback(map.get_fcoords(center.node), map)) { | 91 | if (editor_tool_set_starting_pos_callback(map.get_fcoords(center.node), map)) { |
1530 | 92 | OverlayManager & overlay_manager = map.overlay_manager(); | 92 | OverlayManager & overlay_manager = map.overlay_manager(); |
1531 | 93 | // remove old overlay if any | 93 | // remove old overlay if any |
1532 | 94 | overlay_manager.remove_overlay(old_sp, pic); | 94 | overlay_manager.remove_overlay(old_sp, pic); |
1533 | 95 | 95 | ||
1534 | === modified file 'src/editor/tools/editor_set_starting_pos_tool.h' | |||
1535 | --- src/editor/tools/editor_set_starting_pos_tool.h 2014-09-10 14:08:25 +0000 | |||
1536 | +++ src/editor/tools/editor_set_starting_pos_tool.h 2014-09-29 14:39:47 +0000 | |||
1537 | @@ -51,7 +51,7 @@ | |||
1538 | 51 | char const * m_current_sel_pic; | 51 | char const * m_current_sel_pic; |
1539 | 52 | }; | 52 | }; |
1540 | 53 | 53 | ||
1542 | 54 | int32_t Editor_Tool_Set_Starting_Pos_Callback | 54 | int32_t editor_tool_set_starting_pos_callback |
1543 | 55 | (const Widelands::TCoords<Widelands::FCoords>& c, Widelands::Map& map); | 55 | (const Widelands::TCoords<Widelands::FCoords>& c, Widelands::Map& map); |
1544 | 56 | 56 | ||
1545 | 57 | #endif // end of include guard: WL_EDITOR_TOOLS_EDITOR_SET_STARTING_POS_TOOL_H | 57 | #endif // end of include guard: WL_EDITOR_TOOLS_EDITOR_SET_STARTING_POS_TOOL_H |
1546 | 58 | 58 | ||
1547 | === modified file 'src/editor/ui_menus/editor_main_menu_load_map.cc' | |||
1548 | --- src/editor/ui_menus/editor_main_menu_load_map.cc 2014-09-23 09:26:48 +0000 | |||
1549 | +++ src/editor/ui_menus/editor_main_menu_load_map.cc 2014-09-29 14:39:47 +0000 | |||
1550 | @@ -138,7 +138,7 @@ | |||
1551 | 138 | void MainMenuLoadMap::clicked_ok() { | 138 | void MainMenuLoadMap::clicked_ok() { |
1552 | 139 | const char * const filename(m_ls->get_selected()); | 139 | const char * const filename(m_ls->get_selected()); |
1553 | 140 | 140 | ||
1555 | 141 | if (g_fs->IsDirectory(filename) && !WidelandsMapLoader::is_widelands_map(filename)) { | 141 | if (g_fs->is_directory(filename) && !WidelandsMapLoader::is_widelands_map(filename)) { |
1556 | 142 | m_curdir = filename; | 142 | m_curdir = filename; |
1557 | 143 | m_ls->clear(); | 143 | m_ls->clear(); |
1558 | 144 | m_mapfiles.clear(); | 144 | m_mapfiles.clear(); |
1559 | @@ -157,7 +157,7 @@ | |||
1560 | 157 | 157 | ||
1561 | 158 | m_ok_btn->set_enabled(true); | 158 | m_ok_btn->set_enabled(true); |
1562 | 159 | 159 | ||
1564 | 160 | if (!g_fs->IsDirectory(name) || WidelandsMapLoader::is_widelands_map(name)) { | 160 | if (!g_fs->is_directory(name) || WidelandsMapLoader::is_widelands_map(name)) { |
1565 | 161 | Widelands::Map map; | 161 | Widelands::Map map; |
1566 | 162 | { | 162 | { |
1567 | 163 | std::unique_ptr<Widelands::MapLoader> map_loader = map.get_correct_loader(name); | 163 | std::unique_ptr<Widelands::MapLoader> map_loader = map.get_correct_loader(name); |
1568 | @@ -196,7 +196,7 @@ | |||
1569 | 196 | */ | 196 | */ |
1570 | 197 | void MainMenuLoadMap::fill_list() { | 197 | void MainMenuLoadMap::fill_list() { |
1571 | 198 | // Fill it with all files we find. | 198 | // Fill it with all files we find. |
1573 | 199 | m_mapfiles = g_fs->ListDirectory(m_curdir); | 199 | m_mapfiles = g_fs->list_directory(m_curdir); |
1574 | 200 | 200 | ||
1575 | 201 | // First, we add all directories. We manually add the parent directory. | 201 | // First, we add all directories. We manually add the parent directory. |
1576 | 202 | if (m_curdir != m_basedir) { | 202 | if (m_curdir != m_basedir) { |
1577 | @@ -222,13 +222,13 @@ | |||
1578 | 222 | { | 222 | { |
1579 | 223 | const char * const name = pname->c_str(); | 223 | const char * const name = pname->c_str(); |
1580 | 224 | if | 224 | if |
1584 | 225 | (strcmp(FileSystem::FS_Filename(name), ".") && | 225 | (strcmp(FileSystem::fs_filename(name), ".") && |
1585 | 226 | strcmp(FileSystem::FS_Filename(name), "..") && | 226 | strcmp(FileSystem::fs_filename(name), "..") && |
1586 | 227 | g_fs->IsDirectory(name) && | 227 | g_fs->is_directory(name) && |
1587 | 228 | !WidelandsMapLoader::is_widelands_map(name)) | 228 | !WidelandsMapLoader::is_widelands_map(name)) |
1588 | 229 | 229 | ||
1589 | 230 | m_ls->add | 230 | m_ls->add |
1591 | 231 | (FileSystem::FS_Filename(name), | 231 | (FileSystem::fs_filename(name), |
1592 | 232 | name, | 232 | name, |
1593 | 233 | g_gr->images().get("pics/ls_dir.png")); | 233 | g_gr->images().get("pics/ls_dir.png")); |
1594 | 234 | } | 234 | } |
1595 | @@ -246,7 +246,7 @@ | |||
1596 | 246 | try { | 246 | try { |
1597 | 247 | map_loader->preload_map(true); | 247 | map_loader->preload_map(true); |
1598 | 248 | m_ls->add | 248 | m_ls->add |
1600 | 249 | (FileSystem::FS_Filename(name), | 249 | (FileSystem::fs_filename(name), |
1601 | 250 | name, | 250 | name, |
1602 | 251 | g_gr->images().get | 251 | g_gr->images().get |
1603 | 252 | (dynamic_cast<WidelandsMapLoader*>(map_loader.get()) | 252 | (dynamic_cast<WidelandsMapLoader*>(map_loader.get()) |
1604 | 253 | 253 | ||
1605 | === modified file 'src/editor/ui_menus/editor_main_menu_map_options.cc' | |||
1606 | --- src/editor/ui_menus/editor_main_menu_map_options.cc 2014-09-10 14:48:40 +0000 | |||
1607 | +++ src/editor/ui_menus/editor_main_menu_map_options.cc 2014-09-29 14:39:47 +0000 | |||
1608 | @@ -116,8 +116,8 @@ | |||
1609 | 116 | char buf[200]; | 116 | char buf[200]; |
1610 | 117 | sprintf(buf, "%ix%i", map.get_width(), map.get_height()); | 117 | sprintf(buf, "%ix%i", map.get_width(), map.get_height()); |
1611 | 118 | m_size->set_text(buf); | 118 | m_size->set_text(buf); |
1614 | 119 | m_author->setText(map.get_author()); | 119 | m_author->set_text(map.get_author()); |
1615 | 120 | m_name ->setText(map.get_name()); | 120 | m_name ->set_text(map.get_name()); |
1616 | 121 | sprintf(buf, "%i", map.get_nrplayers()); | 121 | sprintf(buf, "%i", map.get_nrplayers()); |
1617 | 122 | m_nrplayers->set_text(buf); | 122 | m_nrplayers->set_text(buf); |
1618 | 123 | m_descr ->set_text(map.get_description()); | 123 | m_descr ->set_text(map.get_description()); |
1619 | 124 | 124 | ||
1620 | === modified file 'src/editor/ui_menus/editor_main_menu_random_map.cc' | |||
1621 | --- src/editor/ui_menus/editor_main_menu_random_map.cc 2014-09-14 12:13:35 +0000 | |||
1622 | +++ src/editor/ui_menus/editor_main_menu_random_map.cc 2014-09-29 14:39:47 +0000 | |||
1623 | @@ -90,7 +90,7 @@ | |||
1624 | 90 | m_mapNumber = rng.rand(); | 90 | m_mapNumber = rng.rand(); |
1625 | 91 | snprintf | 91 | snprintf |
1626 | 92 | (buffer, sizeof(buffer), "%u", static_cast<unsigned int>(m_mapNumber)); | 92 | (buffer, sizeof(buffer), "%u", static_cast<unsigned int>(m_mapNumber)); |
1628 | 93 | m_nrEditbox->setText(buffer); | 93 | m_nrEditbox->set_text(buffer); |
1629 | 94 | posy += height + spacing + spacing + spacing; | 94 | posy += height + spacing + spacing + spacing; |
1630 | 95 | 95 | ||
1631 | 96 | 96 | ||
1632 | @@ -297,7 +297,7 @@ | |||
1633 | 297 | posx, posy, | 297 | posx, posy, |
1634 | 298 | width, 20, | 298 | width, 20, |
1635 | 299 | g_gr->images().get("pics/but1.png")); | 299 | g_gr->images().get("pics/but1.png")); |
1637 | 300 | m_idEditbox->setText("abcd-efgh-ijkl-mnop"); | 300 | m_idEditbox->set_text("abcd-efgh-ijkl-mnop"); |
1638 | 301 | m_idEditbox->changed.connect | 301 | m_idEditbox->changed.connect |
1639 | 302 | (boost::bind(&MainMenuNewRandomMap::id_edit_box_changed, this)); | 302 | (boost::bind(&MainMenuNewRandomMap::id_edit_box_changed, this)); |
1640 | 303 | posy += height + spacing + spacing + spacing; | 303 | posy += height + spacing + spacing + spacing; |
1641 | @@ -499,12 +499,12 @@ | |||
1642 | 499 | 499 | ||
1643 | 500 | std::string str = m_idEditbox->text(); | 500 | std::string str = m_idEditbox->text(); |
1644 | 501 | 501 | ||
1646 | 502 | if (!UniqueRandomMapInfo::setFromIdString(mapInfo, str)) | 502 | if (!UniqueRandomMapInfo::set_from_id_string(mapInfo, str)) |
1647 | 503 | m_goButton->set_enabled(false); | 503 | m_goButton->set_enabled(false); |
1648 | 504 | else { | 504 | else { |
1649 | 505 | std::stringstream sstrm; | 505 | std::stringstream sstrm; |
1650 | 506 | sstrm << mapInfo.mapNumber; | 506 | sstrm << mapInfo.mapNumber; |
1652 | 507 | m_nrEditbox->setText(sstrm.str()); | 507 | m_nrEditbox->set_text(sstrm.str()); |
1653 | 508 | 508 | ||
1654 | 509 | m_h = 0; | 509 | m_h = 0; |
1655 | 510 | for (uint32_t ix = 0; ix < NUMBER_OF_MAP_DIMENSIONS; ++ix) | 510 | for (uint32_t ix = 0; ix < NUMBER_OF_MAP_DIMENSIONS; ++ix) |
1656 | @@ -545,9 +545,9 @@ | |||
1657 | 545 | set_map_info(mapInfo); | 545 | set_map_info(mapInfo); |
1658 | 546 | 546 | ||
1659 | 547 | std::string idStr; | 547 | std::string idStr; |
1661 | 548 | Widelands::UniqueRandomMapInfo::generateIdString(idStr, mapInfo); | 548 | Widelands::UniqueRandomMapInfo::generate_id_string(idStr, mapInfo); |
1662 | 549 | 549 | ||
1664 | 550 | m_idEditbox->setText(idStr); | 550 | m_idEditbox->set_text(idStr); |
1665 | 551 | 551 | ||
1666 | 552 | m_goButton->set_enabled(true); | 552 | m_goButton->set_enabled(true); |
1667 | 553 | } else | 553 | } else |
1668 | 554 | 554 | ||
1669 | === modified file 'src/editor/ui_menus/editor_main_menu_save_map.cc' | |||
1670 | --- src/editor/ui_menus/editor_main_menu_save_map.cc 2014-09-23 09:26:48 +0000 | |||
1671 | +++ src/editor/ui_menus/editor_main_menu_save_map.cc 2014-09-29 14:39:47 +0000 | |||
1672 | @@ -73,7 +73,7 @@ | |||
1673 | 73 | posx, posy + get_inner_h() - spacing - offsy - 60 + 3, | 73 | posx, posy + get_inner_h() - spacing - offsy - 60 + 3, |
1674 | 74 | get_inner_w() / 2 - spacing, 20, | 74 | get_inner_w() / 2 - spacing, 20, |
1675 | 75 | g_gr->images().get("pics/but1.png")); | 75 | g_gr->images().get("pics/but1.png")); |
1677 | 76 | m_editbox->setText(parent.egbase().map().get_name()); | 76 | m_editbox->set_text(parent.egbase().map().get_name()); |
1678 | 77 | m_editbox->changed.connect(boost::bind(&MainMenuSaveMap::edit_box_changed, this)); | 77 | m_editbox->changed.connect(boost::bind(&MainMenuSaveMap::edit_box_changed, this)); |
1679 | 78 | 78 | ||
1680 | 79 | posx = get_inner_w() / 2 + spacing; | 79 | posx = get_inner_w() / 2 + spacing; |
1681 | @@ -164,11 +164,11 @@ | |||
1682 | 164 | filename = m_ls->get_selected(); | 164 | filename = m_ls->get_selected(); |
1683 | 165 | 165 | ||
1684 | 166 | if | 166 | if |
1686 | 167 | (g_fs->IsDirectory(filename.c_str()) | 167 | (g_fs->is_directory(filename.c_str()) |
1687 | 168 | && | 168 | && |
1688 | 169 | !Widelands::WidelandsMapLoader::is_widelands_map(filename)) | 169 | !Widelands::WidelandsMapLoader::is_widelands_map(filename)) |
1689 | 170 | { | 170 | { |
1691 | 171 | m_curdir = g_fs->FS_CanonicalizeName(filename); | 171 | m_curdir = g_fs->canonicalize_name(filename); |
1692 | 172 | m_ls->clear(); | 172 | m_ls->clear(); |
1693 | 173 | m_mapfiles.clear(); | 173 | m_mapfiles.clear(); |
1694 | 174 | fill_list(); | 174 | fill_list(); |
1695 | @@ -200,12 +200,12 @@ | |||
1696 | 200 | void MainMenuSaveMap::clicked_make_directory() { | 200 | void MainMenuSaveMap::clicked_make_directory() { |
1697 | 201 | MainMenuSaveMapMakeDirectory md(this, _("unnamed")); | 201 | MainMenuSaveMapMakeDirectory md(this, _("unnamed")); |
1698 | 202 | if (md.run()) { | 202 | if (md.run()) { |
1700 | 203 | g_fs->EnsureDirectoryExists(m_basedir); | 203 | g_fs->ensure_directory_exists(m_basedir); |
1701 | 204 | // create directory | 204 | // create directory |
1702 | 205 | std::string fullname = m_curdir; | 205 | std::string fullname = m_curdir; |
1703 | 206 | fullname += "/"; | 206 | fullname += "/"; |
1704 | 207 | fullname += md.get_dirname(); | 207 | fullname += md.get_dirname(); |
1706 | 208 | g_fs->MakeDirectory(fullname); | 208 | g_fs->make_directory(fullname); |
1707 | 209 | m_ls->clear(); | 209 | m_ls->clear(); |
1708 | 210 | m_mapfiles.clear(); | 210 | m_mapfiles.clear(); |
1709 | 211 | fill_list(); | 211 | fill_list(); |
1710 | @@ -226,7 +226,7 @@ | |||
1711 | 226 | ml->preload_map(true); // This has worked before, no problem | 226 | ml->preload_map(true); // This has worked before, no problem |
1712 | 227 | } | 227 | } |
1713 | 228 | 228 | ||
1715 | 229 | m_editbox->setText(FileSystem::FS_Filename(name)); | 229 | m_editbox->set_text(FileSystem::fs_filename(name)); |
1716 | 230 | 230 | ||
1717 | 231 | m_name ->set_text(map.get_name ()); | 231 | m_name ->set_text(map.get_name ()); |
1718 | 232 | m_author->set_text(map.get_author ()); | 232 | m_author->set_text(map.get_author ()); |
1719 | @@ -239,11 +239,11 @@ | |||
1720 | 239 | sprintf(buf, "%ix%i", map.get_width(), map.get_height()); | 239 | sprintf(buf, "%ix%i", map.get_width(), map.get_height()); |
1721 | 240 | m_size->set_text(buf); | 240 | m_size->set_text(buf); |
1722 | 241 | } else { | 241 | } else { |
1724 | 242 | m_name ->set_text(FileSystem::FS_Filename(name)); | 242 | m_name ->set_text(FileSystem::fs_filename(name)); |
1725 | 243 | m_author ->set_text(""); | 243 | m_author ->set_text(""); |
1726 | 244 | m_nrplayers->set_text(""); | 244 | m_nrplayers->set_text(""); |
1727 | 245 | m_size ->set_text(""); | 245 | m_size ->set_text(""); |
1729 | 246 | if (g_fs->IsDirectory(name)) { | 246 | if (g_fs->is_directory(name)) { |
1730 | 247 | std::string dir_string = | 247 | std::string dir_string = |
1731 | 248 | (boost::format("\\<%s\\>") % _("directory")).str(); | 248 | (boost::format("\\<%s\\>") % _("directory")).str(); |
1732 | 249 | m_descr ->set_text(dir_string); | 249 | m_descr ->set_text(dir_string); |
1733 | @@ -263,7 +263,7 @@ | |||
1734 | 263 | void MainMenuSaveMap::double_clicked_item(uint32_t) { | 263 | void MainMenuSaveMap::double_clicked_item(uint32_t) { |
1735 | 264 | const char * const name = m_ls->get_selected(); | 264 | const char * const name = m_ls->get_selected(); |
1736 | 265 | 265 | ||
1738 | 266 | if (g_fs->IsDirectory(name) && !Widelands::WidelandsMapLoader::is_widelands_map(name)) { | 266 | if (g_fs->is_directory(name) && !Widelands::WidelandsMapLoader::is_widelands_map(name)) { |
1739 | 267 | m_curdir = name; | 267 | m_curdir = name; |
1740 | 268 | m_ls->clear(); | 268 | m_ls->clear(); |
1741 | 269 | m_mapfiles.clear(); | 269 | m_mapfiles.clear(); |
1742 | @@ -277,7 +277,7 @@ | |||
1743 | 277 | */ | 277 | */ |
1744 | 278 | void MainMenuSaveMap::fill_list() { | 278 | void MainMenuSaveMap::fill_list() { |
1745 | 279 | // Fill it with all files we find. | 279 | // Fill it with all files we find. |
1747 | 280 | m_mapfiles = g_fs->ListDirectory(m_curdir); | 280 | m_mapfiles = g_fs->list_directory(m_curdir); |
1748 | 281 | 281 | ||
1749 | 282 | // First, we add all directories. We manually add the parent directory | 282 | // First, we add all directories. We manually add the parent directory |
1750 | 283 | if (m_curdir != m_basedir) { | 283 | if (m_curdir != m_basedir) { |
1751 | @@ -303,13 +303,13 @@ | |||
1752 | 303 | { | 303 | { |
1753 | 304 | const char * const name = pname->c_str(); | 304 | const char * const name = pname->c_str(); |
1754 | 305 | if | 305 | if |
1758 | 306 | (strcmp(FileSystem::FS_Filename(name), ".") && | 306 | (strcmp(FileSystem::fs_filename(name), ".") && |
1759 | 307 | strcmp(FileSystem::FS_Filename(name), "..") && | 307 | strcmp(FileSystem::fs_filename(name), "..") && |
1760 | 308 | g_fs->IsDirectory(name) && | 308 | g_fs->is_directory(name) && |
1761 | 309 | !Widelands::WidelandsMapLoader::is_widelands_map(name)) | 309 | !Widelands::WidelandsMapLoader::is_widelands_map(name)) |
1762 | 310 | 310 | ||
1763 | 311 | m_ls->add | 311 | m_ls->add |
1765 | 312 | (FileSystem::FS_Filename(name), | 312 | (FileSystem::fs_filename(name), |
1766 | 313 | name, | 313 | name, |
1767 | 314 | g_gr->images().get("pics/ls_dir.png")); | 314 | g_gr->images().get("pics/ls_dir.png")); |
1768 | 315 | } | 315 | } |
1769 | @@ -329,7 +329,7 @@ | |||
1770 | 329 | try { | 329 | try { |
1771 | 330 | wml->preload_map(true); | 330 | wml->preload_map(true); |
1772 | 331 | m_ls->add | 331 | m_ls->add |
1774 | 332 | (FileSystem::FS_Filename(name), | 332 | (FileSystem::fs_filename(name), |
1775 | 333 | name, | 333 | name, |
1776 | 334 | g_gr->images().get("pics/ls_wlmap.png")); | 334 | g_gr->images().get("pics/ls_wlmap.png")); |
1777 | 335 | } catch (const WException &) {} // we simply skip illegal entries | 335 | } catch (const WException &) {} // we simply skip illegal entries |
1778 | @@ -355,7 +355,7 @@ | |||
1779 | 355 | */ | 355 | */ |
1780 | 356 | bool MainMenuSaveMap::save_map(std::string filename, bool binary) { | 356 | bool MainMenuSaveMap::save_map(std::string filename, bool binary) { |
1781 | 357 | // Make sure that the base directory exists. | 357 | // Make sure that the base directory exists. |
1783 | 358 | g_fs->EnsureDirectoryExists(m_basedir); | 358 | g_fs->ensure_directory_exists(m_basedir); |
1784 | 359 | 359 | ||
1785 | 360 | // OK, first check if the extension matches (ignoring case). | 360 | // OK, first check if the extension matches (ignoring case). |
1786 | 361 | bool assign_extension = true; | 361 | bool assign_extension = true; |
1787 | @@ -375,20 +375,20 @@ | |||
1788 | 375 | complete_filename += filename; | 375 | complete_filename += filename; |
1789 | 376 | 376 | ||
1790 | 377 | // Check if file exists. If so, show a warning. | 377 | // Check if file exists. If so, show a warning. |
1792 | 378 | if (g_fs->FileExists(complete_filename)) { | 378 | if (g_fs->file_exists(complete_filename)) { |
1793 | 379 | std::string s = | 379 | std::string s = |
1794 | 380 | (boost::format(_("A file with the name ‘%s’ already exists. Overwrite?")) | 380 | (boost::format(_("A file with the name ‘%s’ already exists. Overwrite?")) |
1796 | 381 | % FileSystem::FS_Filename(filename.c_str())).str(); | 381 | % FileSystem::fs_filename(filename.c_str())).str(); |
1797 | 382 | UI::WLMessageBox mbox | 382 | UI::WLMessageBox mbox |
1798 | 383 | (&eia(), _("Error Saving Map!"), s, UI::WLMessageBox::YESNO); | 383 | (&eia(), _("Error Saving Map!"), s, UI::WLMessageBox::YESNO); |
1799 | 384 | if (!mbox.run()) | 384 | if (!mbox.run()) |
1800 | 385 | return false; | 385 | return false; |
1801 | 386 | 386 | ||
1803 | 387 | g_fs->Unlink(complete_filename); | 387 | g_fs->fs_unlink(complete_filename); |
1804 | 388 | } | 388 | } |
1805 | 389 | 389 | ||
1806 | 390 | std::unique_ptr<FileSystem> fs | 390 | std::unique_ptr<FileSystem> fs |
1808 | 391 | (g_fs->CreateSubFileSystem(complete_filename, binary ? FileSystem::ZIP : FileSystem::DIR)); | 391 | (g_fs->create_sub_file_system(complete_filename, binary ? FileSystem::ZIP : FileSystem::DIR)); |
1809 | 392 | Widelands::MapSaver wms(*fs, eia().egbase()); | 392 | Widelands::MapSaver wms(*fs, eia().egbase()); |
1810 | 393 | try { | 393 | try { |
1811 | 394 | wms.save(); | 394 | wms.save(); |
1812 | 395 | 395 | ||
1813 | === modified file 'src/editor/ui_menus/editor_main_menu_save_map_make_directory.cc' | |||
1814 | --- src/editor/ui_menus/editor_main_menu_save_map_make_directory.cc 2014-09-10 14:08:25 +0000 | |||
1815 | +++ src/editor/ui_menus/editor_main_menu_save_map_make_directory.cc 2014-09-29 14:39:47 +0000 | |||
1816 | @@ -42,7 +42,7 @@ | |||
1817 | 42 | new UI::EditBox | 42 | new UI::EditBox |
1818 | 43 | (this, spacing, posy, get_inner_w() - 2 * spacing, 20, | 43 | (this, spacing, posy, get_inner_w() - 2 * spacing, 20, |
1819 | 44 | g_gr->images().get("pics/but1.png")); | 44 | g_gr->images().get("pics/but1.png")); |
1821 | 45 | m_edit->setText(dirname); | 45 | m_edit->set_text(dirname); |
1822 | 46 | m_dirname = dirname; | 46 | m_dirname = dirname; |
1823 | 47 | m_edit->changed.connect(boost::bind(&MainMenuSaveMapMakeDirectory::edit_changed, this)); | 47 | m_edit->changed.connect(boost::bind(&MainMenuSaveMapMakeDirectory::edit_changed, this)); |
1824 | 48 | 48 | ||
1825 | 49 | 49 | ||
1826 | === modified file 'src/editor/ui_menus/editor_player_menu.cc' | |||
1827 | --- src/editor/ui_menus/editor_player_menu.cc 2014-09-10 14:08:25 +0000 | |||
1828 | +++ src/editor/ui_menus/editor_player_menu.cc 2014-09-29 14:39:47 +0000 | |||
1829 | @@ -147,7 +147,7 @@ | |||
1830 | 147 | m_plr_names[p - 1]->changed.connect | 147 | m_plr_names[p - 1]->changed.connect |
1831 | 148 | (boost::bind(&EditorPlayerMenu::name_changed, this, p - 1)); | 148 | (boost::bind(&EditorPlayerMenu::name_changed, this, p - 1)); |
1832 | 149 | posx += 140 + spacing; | 149 | posx += 140 + spacing; |
1834 | 150 | m_plr_names[p - 1]->setText(map.get_scenario_player_name(p)); | 150 | m_plr_names[p - 1]->set_text(map.get_scenario_player_name(p)); |
1835 | 151 | } | 151 | } |
1836 | 152 | 152 | ||
1837 | 153 | if (!m_plr_set_tribes_buts[p - 1]) { | 153 | if (!m_plr_set_tribes_buts[p - 1]) { |
1838 | @@ -356,7 +356,7 @@ | |||
1839 | 356 | // Register callback function to make sure that only valid locations are | 356 | // Register callback function to make sure that only valid locations are |
1840 | 357 | // selected. | 357 | // selected. |
1841 | 358 | map.overlay_manager().register_overlay_callback_function( | 358 | map.overlay_manager().register_overlay_callback_function( |
1843 | 359 | boost::bind(&Editor_Tool_Set_Starting_Pos_Callback, _1, boost::ref(map))); | 359 | boost::bind(&editor_tool_set_starting_pos_callback, _1, boost::ref(map))); |
1844 | 360 | map.recalc_whole_map(menu.egbase().world()); | 360 | map.recalc_whole_map(menu.egbase().world()); |
1845 | 361 | update(); | 361 | update(); |
1846 | 362 | } | 362 | } |
1847 | @@ -372,10 +372,10 @@ | |||
1848 | 372 | Widelands::Map & map = menu.egbase().map(); | 372 | Widelands::Map & map = menu.egbase().map(); |
1849 | 373 | if (text == "") { | 373 | if (text == "") { |
1850 | 374 | text = map.get_scenario_player_name(m + 1); | 374 | text = map.get_scenario_player_name(m + 1); |
1852 | 375 | m_plr_names[m]->setText(text); | 375 | m_plr_names[m]->set_text(text); |
1853 | 376 | } | 376 | } |
1854 | 377 | map.set_scenario_player_name(m + 1, text); | 377 | map.set_scenario_player_name(m + 1, text); |
1856 | 378 | m_plr_names[m]->setText(map.get_scenario_player_name(m + 1)); | 378 | m_plr_names[m]->set_text(map.get_scenario_player_name(m + 1)); |
1857 | 379 | menu.set_need_save(true); | 379 | menu.set_need_save(true); |
1858 | 380 | } | 380 | } |
1859 | 381 | 381 | ||
1860 | @@ -441,6 +441,6 @@ | |||
1861 | 441 | parent.select_tool(parent.tools.make_infrastructure, EditorTool::First); | 441 | parent.select_tool(parent.tools.make_infrastructure, EditorTool::First); |
1862 | 442 | parent.tools.make_infrastructure.set_player(n); | 442 | parent.tools.make_infrastructure.set_player(n); |
1863 | 443 | overlay_manager.register_overlay_callback_function( | 443 | overlay_manager.register_overlay_callback_function( |
1865 | 444 | boost::bind(&Editor_Make_Infrastructure_Tool_Callback, _1, boost::ref(egbase), n)); | 444 | boost::bind(&editor_make_infrastructure_tool_callback, _1, boost::ref(egbase), n)); |
1866 | 445 | map.recalc_whole_map(egbase.world()); | 445 | map.recalc_whole_map(egbase.world()); |
1867 | 446 | } | 446 | } |
1868 | 447 | 447 | ||
1869 | === modified file 'src/editor/ui_menus/editor_tool_change_resources_options_menu.cc' | |||
1870 | --- src/editor/ui_menus/editor_tool_change_resources_options_menu.cc 2014-09-10 14:08:25 +0000 | |||
1871 | +++ src/editor/ui_menus/editor_tool_change_resources_options_menu.cc 2014-09-29 14:39:47 +0000 | |||
1872 | @@ -215,7 +215,7 @@ | |||
1873 | 215 | Widelands::EditorGameBase& egbase = ref_cast<EditorInteractive, UI::Panel>(*get_parent()).egbase(); | 215 | Widelands::EditorGameBase& egbase = ref_cast<EditorInteractive, UI::Panel>(*get_parent()).egbase(); |
1874 | 216 | Widelands::Map & map = egbase.map(); | 216 | Widelands::Map & map = egbase.map(); |
1875 | 217 | map.overlay_manager().register_overlay_callback_function( | 217 | map.overlay_manager().register_overlay_callback_function( |
1877 | 218 | boost::bind(&Editor_Change_Resource_Tool_Callback, _1, boost::ref(map), boost::ref(egbase.world()), n)); | 218 | boost::bind(&editor_change_resource_tool_callback, _1, boost::ref(map), boost::ref(egbase.world()), n)); |
1878 | 219 | map.recalc_whole_map(egbase.world()); | 219 | map.recalc_whole_map(egbase.world()); |
1879 | 220 | select_correct_tool(); | 220 | select_correct_tool(); |
1880 | 221 | 221 | ||
1881 | 222 | 222 | ||
1882 | === modified file 'src/editor/ui_menus/editor_tool_menu.cc' | |||
1883 | --- src/editor/ui_menus/editor_tool_menu.cc 2014-09-10 14:08:25 +0000 | |||
1884 | +++ src/editor/ui_menus/editor_tool_menu.cc 2014-09-29 14:39:47 +0000 | |||
1885 | @@ -142,7 +142,7 @@ | |||
1886 | 142 | // Set correct overlay | 142 | // Set correct overlay |
1887 | 143 | Widelands::Map & map = parent.egbase().map(); | 143 | Widelands::Map & map = parent.egbase().map(); |
1888 | 144 | map.overlay_manager().register_overlay_callback_function( | 144 | map.overlay_manager().register_overlay_callback_function( |
1890 | 145 | boost::bind(&Editor_Tool_Set_Port_Space_Callback, _1, boost::ref(map))); | 145 | boost::bind(&editor_Tool_set_port_space_callback, _1, boost::ref(map))); |
1891 | 146 | map.recalc_whole_map(parent.egbase().world()); | 146 | map.recalc_whole_map(parent.egbase().world()); |
1892 | 147 | update(); | 147 | update(); |
1893 | 148 | } | 148 | } |
1894 | 149 | 149 | ||
1895 | === modified file 'src/game_io/game_class_packet.cc' | |||
1896 | --- src/game_io/game_class_packet.cc 2014-09-10 08:55:04 +0000 | |||
1897 | +++ src/game_io/game_class_packet.cc 2014-09-29 14:39:47 +0000 | |||
1898 | @@ -29,16 +29,16 @@ | |||
1899 | 29 | #define CURRENT_PACKET_VERSION 2 | 29 | #define CURRENT_PACKET_VERSION 2 |
1900 | 30 | 30 | ||
1901 | 31 | 31 | ||
1903 | 32 | void GameClassPacket::Read | 32 | void GameClassPacket::read |
1904 | 33 | (FileSystem & fs, Game & game, MapObjectLoader *) | 33 | (FileSystem & fs, Game & game, MapObjectLoader *) |
1905 | 34 | { | 34 | { |
1906 | 35 | try { | 35 | try { |
1907 | 36 | FileRead fr; | 36 | FileRead fr; |
1910 | 37 | fr.Open(fs, "binary/game_class"); | 37 | fr.open(fs, "binary/game_class"); |
1911 | 38 | uint16_t const packet_version = fr.Unsigned16(); | 38 | uint16_t const packet_version = fr.unsigned_16(); |
1912 | 39 | if (packet_version <= CURRENT_PACKET_VERSION) { | 39 | if (packet_version <= CURRENT_PACKET_VERSION) { |
1915 | 40 | fr.Signed16(); // This used to be game speed | 40 | fr.signed_16(); // This used to be game speed |
1916 | 41 | game.gametime_ = fr.Unsigned32(); | 41 | game.gametime_ = fr.unsigned_32(); |
1917 | 42 | } else | 42 | } else |
1918 | 43 | throw GameDataError | 43 | throw GameDataError |
1919 | 44 | ("unknown/unhandled version %u", packet_version); | 44 | ("unknown/unhandled version %u", packet_version); |
1920 | @@ -50,17 +50,17 @@ | |||
1921 | 50 | /* | 50 | /* |
1922 | 51 | * Write Function | 51 | * Write Function |
1923 | 52 | */ | 52 | */ |
1925 | 53 | void GameClassPacket::Write | 53 | void GameClassPacket::write |
1926 | 54 | (FileSystem & fs, Game & game, MapObjectSaver * const) | 54 | (FileSystem & fs, Game & game, MapObjectSaver * const) |
1927 | 55 | { | 55 | { |
1928 | 56 | FileWrite fw; | 56 | FileWrite fw; |
1929 | 57 | 57 | ||
1930 | 58 | // Packet version | 58 | // Packet version |
1932 | 59 | fw.Unsigned16(CURRENT_PACKET_VERSION); | 59 | fw.unsigned_16(CURRENT_PACKET_VERSION); |
1933 | 60 | 60 | ||
1934 | 61 | // State is running, we do not need to save this | 61 | // State is running, we do not need to save this |
1935 | 62 | // Save speed | 62 | // Save speed |
1937 | 63 | fw.Signed16(1000); | 63 | fw.signed_16(1000); |
1938 | 64 | 64 | ||
1939 | 65 | // From the interactive player, is saved somewhere else | 65 | // From the interactive player, is saved somewhere else |
1940 | 66 | // Computer players are saved somewhere else | 66 | // Computer players are saved somewhere else |
1941 | @@ -70,7 +70,7 @@ | |||
1942 | 70 | 70 | ||
1943 | 71 | // EDITOR GAME CLASS | 71 | // EDITOR GAME CLASS |
1944 | 72 | // Write gametime | 72 | // Write gametime |
1946 | 73 | fw.Unsigned32(game.gametime_); | 73 | fw.unsigned_32(game.gametime_); |
1947 | 74 | 74 | ||
1948 | 75 | // We do not care for players, since they were set | 75 | // We do not care for players, since they were set |
1949 | 76 | // on game initialization to match Map::scenario_player_[names|tribes] | 76 | // on game initialization to match Map::scenario_player_[names|tribes] |
1950 | @@ -85,7 +85,7 @@ | |||
1951 | 85 | 85 | ||
1952 | 86 | // Track pointers are not saved in save games | 86 | // Track pointers are not saved in save games |
1953 | 87 | 87 | ||
1955 | 88 | fw.Write(fs, "binary/game_class"); | 88 | fw.write(fs, "binary/game_class"); |
1956 | 89 | } | 89 | } |
1957 | 90 | 90 | ||
1958 | 91 | } | 91 | } |
1959 | 92 | 92 | ||
1960 | === modified file 'src/game_io/game_class_packet.h' | |||
1961 | --- src/game_io/game_class_packet.h 2014-09-10 16:57:31 +0000 | |||
1962 | +++ src/game_io/game_class_packet.h 2014-09-29 14:39:47 +0000 | |||
1963 | @@ -29,8 +29,8 @@ | |||
1964 | 29 | * a game for a user (for example in a listbox) | 29 | * a game for a user (for example in a listbox) |
1965 | 30 | */ | 30 | */ |
1966 | 31 | struct GameClassPacket : public GameDataPacket { | 31 | struct GameClassPacket : public GameDataPacket { |
1969 | 32 | void Read (FileSystem &, Game &, MapObjectLoader * = nullptr) override; | 32 | void read (FileSystem &, Game &, MapObjectLoader * = nullptr) override; |
1970 | 33 | void Write(FileSystem &, Game &, MapObjectSaver * = nullptr) override; | 33 | void write(FileSystem &, Game &, MapObjectSaver * = nullptr) override; |
1971 | 34 | }; | 34 | }; |
1972 | 35 | 35 | ||
1973 | 36 | } | 36 | } |
1974 | 37 | 37 | ||
1975 | === modified file 'src/game_io/game_cmd_queue_packet.cc' | |||
1976 | --- src/game_io/game_cmd_queue_packet.cc 2014-09-14 16:08:13 +0000 | |||
1977 | +++ src/game_io/game_cmd_queue_packet.cc 2014-09-29 14:39:47 +0000 | |||
1978 | @@ -32,47 +32,47 @@ | |||
1979 | 32 | #define CURRENT_PACKET_VERSION 2 | 32 | #define CURRENT_PACKET_VERSION 2 |
1980 | 33 | 33 | ||
1981 | 34 | 34 | ||
1983 | 35 | void GameCmdQueuePacket::Read | 35 | void GameCmdQueuePacket::read |
1984 | 36 | (FileSystem & fs, Game & game, MapObjectLoader * const ol) | 36 | (FileSystem & fs, Game & game, MapObjectLoader * const ol) |
1985 | 37 | { | 37 | { |
1986 | 38 | try { | 38 | try { |
1987 | 39 | FileRead fr; | 39 | FileRead fr; |
1990 | 40 | fr.Open(fs, "binary/cmd_queue"); | 40 | fr.open(fs, "binary/cmd_queue"); |
1991 | 41 | uint16_t const packet_version = fr.Unsigned16(); | 41 | uint16_t const packet_version = fr.unsigned_16(); |
1992 | 42 | if (packet_version == CURRENT_PACKET_VERSION) { | 42 | if (packet_version == CURRENT_PACKET_VERSION) { |
1993 | 43 | CmdQueue & cmdq = game.cmdqueue(); | 43 | CmdQueue & cmdq = game.cmdqueue(); |
1994 | 44 | 44 | ||
1995 | 45 | // nothing to be done for m_game | 45 | // nothing to be done for m_game |
1996 | 46 | 46 | ||
1997 | 47 | // Next serial | 47 | // Next serial |
1999 | 48 | cmdq.nextserial = fr.Unsigned32(); | 48 | cmdq.nextserial = fr.unsigned_32(); |
2000 | 49 | 49 | ||
2001 | 50 | // Erase all currently pending commands in the queue | 50 | // Erase all currently pending commands in the queue |
2002 | 51 | cmdq.flush(); | 51 | cmdq.flush(); |
2003 | 52 | 52 | ||
2004 | 53 | for (;;) { | 53 | for (;;) { |
2006 | 54 | uint32_t const packet_id = fr.Unsigned16(); | 54 | uint32_t const packet_id = fr.unsigned_16(); |
2007 | 55 | 55 | ||
2008 | 56 | if (!packet_id) | 56 | if (!packet_id) |
2009 | 57 | break; | 57 | break; |
2010 | 58 | 58 | ||
2011 | 59 | CmdQueue::CmdItem item; | 59 | CmdQueue::CmdItem item; |
2014 | 60 | item.category = fr.Signed32(); | 60 | item.category = fr.signed_32(); |
2015 | 61 | item.serial = fr.Unsigned32(); | 61 | item.serial = fr.unsigned_32(); |
2016 | 62 | 62 | ||
2017 | 63 | if (packet_id == 129) { | 63 | if (packet_id == 129) { |
2018 | 64 | // For backwards compatibility with savegames up to build15: | 64 | // For backwards compatibility with savegames up to build15: |
2019 | 65 | // Discard old CheckEventChain commands | 65 | // Discard old CheckEventChain commands |
2024 | 66 | fr.Unsigned16(); // CheckEventChain version | 66 | fr.unsigned_16(); // CheckEventChain version |
2025 | 67 | fr.Unsigned16(); // GameLogicCommand version | 67 | fr.unsigned_16(); // GameLogicCommand version |
2026 | 68 | fr.Unsigned32(); // GameLogicCommand duetime | 68 | fr.unsigned_32(); // GameLogicCommand duetime |
2027 | 69 | fr.Unsigned16(); // CheckEventChain ID | 69 | fr.unsigned_16(); // CheckEventChain ID |
2028 | 70 | continue; | 70 | continue; |
2029 | 71 | } | 71 | } |
2030 | 72 | 72 | ||
2031 | 73 | GameLogicCommand & cmd = | 73 | GameLogicCommand & cmd = |
2032 | 74 | QueueCmdFactory::create_correct_queue_command(packet_id); | 74 | QueueCmdFactory::create_correct_queue_command(packet_id); |
2034 | 75 | cmd.Read(fr, game, *ol); | 75 | cmd.read(fr, game, *ol); |
2035 | 76 | 76 | ||
2036 | 77 | item.cmd = &cmd; | 77 | item.cmd = &cmd; |
2037 | 78 | 78 | ||
2038 | @@ -88,20 +88,20 @@ | |||
2039 | 88 | } | 88 | } |
2040 | 89 | 89 | ||
2041 | 90 | 90 | ||
2043 | 91 | void GameCmdQueuePacket::Write | 91 | void GameCmdQueuePacket::write |
2044 | 92 | (FileSystem & fs, Game & game, MapObjectSaver * const os) | 92 | (FileSystem & fs, Game & game, MapObjectSaver * const os) |
2045 | 93 | { | 93 | { |
2046 | 94 | FileWrite fw; | 94 | FileWrite fw; |
2047 | 95 | 95 | ||
2048 | 96 | // Now packet version | 96 | // Now packet version |
2050 | 97 | fw.Unsigned16(CURRENT_PACKET_VERSION); | 97 | fw.unsigned_16(CURRENT_PACKET_VERSION); |
2051 | 98 | 98 | ||
2052 | 99 | const CmdQueue & cmdq = game.cmdqueue(); | 99 | const CmdQueue & cmdq = game.cmdqueue(); |
2053 | 100 | 100 | ||
2054 | 101 | // nothing to be done for m_game | 101 | // nothing to be done for m_game |
2055 | 102 | 102 | ||
2056 | 103 | // Next serial | 103 | // Next serial |
2058 | 104 | fw.Unsigned32(cmdq.nextserial); | 104 | fw.unsigned_32(cmdq.nextserial); |
2059 | 105 | 105 | ||
2060 | 106 | // Write all commands | 106 | // Write all commands |
2061 | 107 | 107 | ||
2062 | @@ -118,14 +118,14 @@ | |||
2063 | 118 | if (it.cmd->duetime() == time) { | 118 | if (it.cmd->duetime() == time) { |
2064 | 119 | if (upcast(GameLogicCommand, cmd, it.cmd)) { | 119 | if (upcast(GameLogicCommand, cmd, it.cmd)) { |
2065 | 120 | // The id (aka command type) | 120 | // The id (aka command type) |
2067 | 121 | fw.Unsigned16(cmd->id()); | 121 | fw.unsigned_16(cmd->id()); |
2068 | 122 | 122 | ||
2069 | 123 | // Serial number | 123 | // Serial number |
2072 | 124 | fw.Signed32(it.category); | 124 | fw.signed_32(it.category); |
2073 | 125 | fw.Unsigned32(it.serial); | 125 | fw.unsigned_32(it.serial); |
2074 | 126 | 126 | ||
2075 | 127 | // Now the command itself | 127 | // Now the command itself |
2077 | 128 | cmd->Write(fw, game, *os); | 128 | cmd->write(fw, game, *os); |
2078 | 129 | } | 129 | } |
2079 | 130 | ++ nhandled; | 130 | ++ nhandled; |
2080 | 131 | } | 131 | } |
2081 | @@ -137,9 +137,9 @@ | |||
2082 | 137 | } | 137 | } |
2083 | 138 | 138 | ||
2084 | 139 | 139 | ||
2086 | 140 | fw.Unsigned16(0); // end of command queue | 140 | fw.unsigned_16(0); // end of command queue |
2087 | 141 | 141 | ||
2089 | 142 | fw.Write(fs, "binary/cmd_queue"); | 142 | fw.write(fs, "binary/cmd_queue"); |
2090 | 143 | } | 143 | } |
2091 | 144 | 144 | ||
2092 | 145 | } | 145 | } |
2093 | 146 | 146 | ||
2094 | === modified file 'src/game_io/game_cmd_queue_packet.h' | |||
2095 | --- src/game_io/game_cmd_queue_packet.h 2014-09-10 16:57:31 +0000 | |||
2096 | +++ src/game_io/game_cmd_queue_packet.h 2014-09-29 14:39:47 +0000 | |||
2097 | @@ -31,8 +31,8 @@ | |||
2098 | 31 | * a game for a user (for example in a listbox) | 31 | * a game for a user (for example in a listbox) |
2099 | 32 | */ | 32 | */ |
2100 | 33 | struct GameCmdQueuePacket : public GameDataPacket { | 33 | struct GameCmdQueuePacket : public GameDataPacket { |
2103 | 34 | void Read (FileSystem &, Game &, MapObjectLoader * = nullptr) override; | 34 | void read (FileSystem &, Game &, MapObjectLoader * = nullptr) override; |
2104 | 35 | void Write(FileSystem &, Game &, MapObjectSaver * = nullptr) override; | 35 | void write(FileSystem &, Game &, MapObjectSaver * = nullptr) override; |
2105 | 36 | }; | 36 | }; |
2106 | 37 | 37 | ||
2107 | 38 | } | 38 | } |
2108 | 39 | 39 | ||
2109 | === modified file 'src/game_io/game_data_packet.h' | |||
2110 | --- src/game_io/game_data_packet.h 2014-09-10 07:57:29 +0000 | |||
2111 | +++ src/game_io/game_data_packet.h 2014-09-29 14:39:47 +0000 | |||
2112 | @@ -40,8 +40,8 @@ | |||
2113 | 40 | */ | 40 | */ |
2114 | 41 | struct GameDataPacket { | 41 | struct GameDataPacket { |
2115 | 42 | virtual ~GameDataPacket() {} | 42 | virtual ~GameDataPacket() {} |
2118 | 43 | virtual void Read (FileSystem &, Game &, MapObjectLoader * = nullptr) = 0; | 43 | virtual void read (FileSystem &, Game &, MapObjectLoader * = nullptr) = 0; |
2119 | 44 | virtual void Write(FileSystem &, Game &, MapObjectSaver * = nullptr) = 0; | 44 | virtual void write(FileSystem &, Game &, MapObjectSaver * = nullptr) = 0; |
2120 | 45 | }; | 45 | }; |
2121 | 46 | 46 | ||
2122 | 47 | } | 47 | } |
2123 | 48 | 48 | ||
2124 | === modified file 'src/game_io/game_interactive_player_packet.cc' | |||
2125 | --- src/game_io/game_interactive_player_packet.cc 2014-09-10 13:03:40 +0000 | |||
2126 | +++ src/game_io/game_interactive_player_packet.cc 2014-09-29 14:39:47 +0000 | |||
2127 | @@ -34,15 +34,15 @@ | |||
2128 | 34 | #define CURRENT_PACKET_VERSION 2 | 34 | #define CURRENT_PACKET_VERSION 2 |
2129 | 35 | 35 | ||
2130 | 36 | 36 | ||
2132 | 37 | void GameInteractivePlayerPacket::Read | 37 | void GameInteractivePlayerPacket::read |
2133 | 38 | (FileSystem & fs, Game & game, MapObjectLoader *) | 38 | (FileSystem & fs, Game & game, MapObjectLoader *) |
2134 | 39 | { | 39 | { |
2135 | 40 | try { | 40 | try { |
2136 | 41 | FileRead fr; | 41 | FileRead fr; |
2139 | 42 | fr.Open(fs, "binary/interactive_player"); | 42 | fr.open(fs, "binary/interactive_player"); |
2140 | 43 | uint16_t const packet_version = fr.Unsigned16(); | 43 | uint16_t const packet_version = fr.unsigned_16(); |
2141 | 44 | if (packet_version == CURRENT_PACKET_VERSION) { | 44 | if (packet_version == CURRENT_PACKET_VERSION) { |
2143 | 45 | PlayerNumber player_number = fr.Unsigned8(); | 45 | PlayerNumber player_number = fr.unsigned_8(); |
2144 | 46 | if (!(0 < player_number && player_number <= game.map().get_nrplayers())) { | 46 | if (!(0 < player_number && player_number <= game.map().get_nrplayers())) { |
2145 | 47 | throw GameDataError("Invalid player number: %i.", player_number); | 47 | throw GameDataError("Invalid player number: %i.", player_number); |
2146 | 48 | } | 48 | } |
2147 | @@ -59,9 +59,9 @@ | |||
2148 | 59 | if (player_number > max) | 59 | if (player_number > max) |
2149 | 60 | throw GameDataError("The game has no players!"); | 60 | throw GameDataError("The game has no players!"); |
2150 | 61 | } | 61 | } |
2154 | 62 | int32_t const x = fr.Unsigned16(); | 62 | int32_t const x = fr.unsigned_16(); |
2155 | 63 | int32_t const y = fr.Unsigned16(); | 63 | int32_t const y = fr.unsigned_16(); |
2156 | 64 | uint32_t const display_flags = fr.Unsigned32(); | 64 | uint32_t const display_flags = fr.unsigned_32(); |
2157 | 65 | 65 | ||
2158 | 66 | if (InteractiveBase * const ibase = game.get_ibase()) { | 66 | if (InteractiveBase * const ibase = game.get_ibase()) { |
2159 | 67 | ibase->set_viewpoint(Point(x, y), true); | 67 | ibase->set_viewpoint(Point(x, y), true); |
2160 | @@ -88,32 +88,32 @@ | |||
2161 | 88 | /* | 88 | /* |
2162 | 89 | * Write Function | 89 | * Write Function |
2163 | 90 | */ | 90 | */ |
2165 | 91 | void GameInteractivePlayerPacket::Write | 91 | void GameInteractivePlayerPacket::write |
2166 | 92 | (FileSystem & fs, Game & game, MapObjectSaver * const) | 92 | (FileSystem & fs, Game & game, MapObjectSaver * const) |
2167 | 93 | { | 93 | { |
2168 | 94 | FileWrite fw; | 94 | FileWrite fw; |
2169 | 95 | 95 | ||
2170 | 96 | // Now packet version | 96 | // Now packet version |
2172 | 97 | fw.Unsigned16(CURRENT_PACKET_VERSION); | 97 | fw.unsigned_16(CURRENT_PACKET_VERSION); |
2173 | 98 | 98 | ||
2174 | 99 | InteractiveBase * const ibase = game.get_ibase(); | 99 | InteractiveBase * const ibase = game.get_ibase(); |
2175 | 100 | InteractivePlayer * const iplayer = game.get_ipl(); | 100 | InteractivePlayer * const iplayer = game.get_ipl(); |
2176 | 101 | 101 | ||
2177 | 102 | // Player number | 102 | // Player number |
2179 | 103 | fw.Unsigned8(iplayer ? iplayer->player_number() : 1); | 103 | fw.unsigned_8(iplayer ? iplayer->player_number() : 1); |
2180 | 104 | 104 | ||
2181 | 105 | // Map Position | 105 | // Map Position |
2182 | 106 | if (ibase) { | 106 | if (ibase) { |
2183 | 107 | assert(0 <= ibase->get_viewpoint().x); | 107 | assert(0 <= ibase->get_viewpoint().x); |
2184 | 108 | assert(0 <= ibase->get_viewpoint().y); | 108 | assert(0 <= ibase->get_viewpoint().y); |
2185 | 109 | } | 109 | } |
2188 | 110 | fw.Unsigned16(ibase ? ibase->get_viewpoint().x : 0); | 110 | fw.unsigned_16(ibase ? ibase->get_viewpoint().x : 0); |
2189 | 111 | fw.Unsigned16(ibase ? ibase->get_viewpoint().y : 0); | 111 | fw.unsigned_16(ibase ? ibase->get_viewpoint().y : 0); |
2190 | 112 | 112 | ||
2191 | 113 | // Display flags | 113 | // Display flags |
2193 | 114 | fw.Unsigned32(ibase ? ibase->get_display_flags() : 0); | 114 | fw.unsigned_32(ibase ? ibase->get_display_flags() : 0); |
2194 | 115 | 115 | ||
2196 | 116 | fw.Write(fs, "binary/interactive_player"); | 116 | fw.write(fs, "binary/interactive_player"); |
2197 | 117 | } | 117 | } |
2198 | 118 | 118 | ||
2199 | 119 | } | 119 | } |
2200 | 120 | 120 | ||
2201 | === modified file 'src/game_io/game_interactive_player_packet.h' | |||
2202 | --- src/game_io/game_interactive_player_packet.h 2014-09-10 16:57:31 +0000 | |||
2203 | +++ src/game_io/game_interactive_player_packet.h 2014-09-29 14:39:47 +0000 | |||
2204 | @@ -29,8 +29,8 @@ | |||
2205 | 29 | * player number and so on | 29 | * player number and so on |
2206 | 30 | */ | 30 | */ |
2207 | 31 | struct GameInteractivePlayerPacket : public GameDataPacket { | 31 | struct GameInteractivePlayerPacket : public GameDataPacket { |
2210 | 32 | void Read (FileSystem &, Game &, MapObjectLoader * = nullptr) override; | 32 | void read (FileSystem &, Game &, MapObjectLoader * = nullptr) override; |
2211 | 33 | void Write(FileSystem &, Game &, MapObjectSaver * = nullptr) override; | 33 | void write(FileSystem &, Game &, MapObjectSaver * = nullptr) override; |
2212 | 34 | }; | 34 | }; |
2213 | 35 | 35 | ||
2214 | 36 | } | 36 | } |
2215 | 37 | 37 | ||
2216 | === modified file 'src/game_io/game_loader.cc' | |||
2217 | --- src/game_io/game_loader.cc 2014-09-18 18:56:20 +0000 | |||
2218 | +++ src/game_io/game_loader.cc 2014-09-29 14:39:47 +0000 | |||
2219 | @@ -39,7 +39,7 @@ | |||
2220 | 39 | namespace Widelands { | 39 | namespace Widelands { |
2221 | 40 | 40 | ||
2222 | 41 | GameLoader::GameLoader(const std::string & path, Game & game) : | 41 | GameLoader::GameLoader(const std::string & path, Game & game) : |
2224 | 42 | m_fs(*g_fs->MakeSubFileSystem(path)), m_game(game) | 42 | m_fs(*g_fs->make_sub_file_system(path)), m_game(game) |
2225 | 43 | {} | 43 | {} |
2226 | 44 | 44 | ||
2227 | 45 | 45 | ||
2228 | @@ -52,7 +52,7 @@ | |||
2229 | 52 | */ | 52 | */ |
2230 | 53 | int32_t GameLoader::preload_game(GamePreloadPacket & mp) { | 53 | int32_t GameLoader::preload_game(GamePreloadPacket & mp) { |
2231 | 54 | // Load elemental data block | 54 | // Load elemental data block |
2233 | 55 | mp.Read(m_fs, m_game, nullptr); | 55 | mp.read(m_fs, m_game, nullptr); |
2234 | 56 | 56 | ||
2235 | 57 | return 0; | 57 | return 0; |
2236 | 58 | } | 58 | } |
2237 | @@ -64,33 +64,33 @@ | |||
2238 | 64 | ScopedTimer timer("GameLoader::load() took %ums"); | 64 | ScopedTimer timer("GameLoader::load() took %ums"); |
2239 | 65 | 65 | ||
2240 | 66 | log("Game: Reading Preload Data ... "); | 66 | log("Game: Reading Preload Data ... "); |
2242 | 67 | {GamePreloadPacket p; p.Read(m_fs, m_game);} | 67 | {GamePreloadPacket p; p.read(m_fs, m_game);} |
2243 | 68 | log("took %ums\n", timer.ms_since_last_query()); | 68 | log("took %ums\n", timer.ms_since_last_query()); |
2244 | 69 | 69 | ||
2245 | 70 | log("Game: Reading Game Class Data ... "); | 70 | log("Game: Reading Game Class Data ... "); |
2247 | 71 | {GameClassPacket p; p.Read(m_fs, m_game);} | 71 | {GameClassPacket p; p.read(m_fs, m_game);} |
2248 | 72 | log("took %ums\n", timer.ms_since_last_query()); | 72 | log("took %ums\n", timer.ms_since_last_query()); |
2249 | 73 | 73 | ||
2250 | 74 | log("Game: Reading Map Data ... "); | 74 | log("Game: Reading Map Data ... "); |
2252 | 75 | GameMapPacket M; M.Read(m_fs, m_game); | 75 | GameMapPacket M; M.read(m_fs, m_game); |
2253 | 76 | log("Game: Reading Map Data took %ums\n", timer.ms_since_last_query()); | 76 | log("Game: Reading Map Data took %ums\n", timer.ms_since_last_query()); |
2254 | 77 | 77 | ||
2255 | 78 | log("Game: Reading Player Info ... "); | 78 | log("Game: Reading Player Info ... "); |
2257 | 79 | {GamePlayerInfoPacket p; p.Read(m_fs, m_game);} | 79 | {GamePlayerInfoPacket p; p.read(m_fs, m_game);} |
2258 | 80 | log("Game: Reading Player Info took %ums\n", timer.ms_since_last_query()); | 80 | log("Game: Reading Player Info took %ums\n", timer.ms_since_last_query()); |
2259 | 81 | 81 | ||
2263 | 82 | log("Game: Calling Read_Complete()\n"); | 82 | log("Game: Calling read_complete()\n"); |
2264 | 83 | M.Read_Complete(m_game); | 83 | M.read_complete(m_game); |
2265 | 84 | log("Game: Read_Complete took: %ums\n", timer.ms_since_last_query()); | 84 | log("Game: read_complete took: %ums\n", timer.ms_since_last_query()); |
2266 | 85 | 85 | ||
2267 | 86 | MapObjectLoader * const mol = M.get_map_object_loader(); | 86 | MapObjectLoader * const mol = M.get_map_object_loader(); |
2268 | 87 | 87 | ||
2269 | 88 | log("Game: Reading Player Economies Info ... "); | 88 | log("Game: Reading Player Economies Info ... "); |
2271 | 89 | {GamePlayerEconomiesPacket p; p.Read(m_fs, m_game, mol);} | 89 | {GamePlayerEconomiesPacket p; p.read(m_fs, m_game, mol);} |
2272 | 90 | log("took %ums\n", timer.ms_since_last_query()); | 90 | log("took %ums\n", timer.ms_since_last_query()); |
2273 | 91 | 91 | ||
2274 | 92 | log("Game: Reading Command Queue Data ... "); | 92 | log("Game: Reading Command Queue Data ... "); |
2276 | 93 | {GameCmdQueuePacket p; p.Read(m_fs, m_game, mol);} | 93 | {GameCmdQueuePacket p; p.read(m_fs, m_game, mol);} |
2277 | 94 | log("took %ums\n", timer.ms_since_last_query()); | 94 | log("took %ums\n", timer.ms_since_last_query()); |
2278 | 95 | 95 | ||
2279 | 96 | // This must be after the command queue has been read. | 96 | // This must be after the command queue has been read. |
2280 | @@ -120,7 +120,7 @@ | |||
2281 | 120 | // player. | 120 | // player. |
2282 | 121 | if (!multiplayer) { | 121 | if (!multiplayer) { |
2283 | 122 | log("Game: Reading Interactive Player Data ... "); | 122 | log("Game: Reading Interactive Player Data ... "); |
2285 | 123 | {GameInteractivePlayerPacket p; p.Read(m_fs, m_game, mol);} | 123 | {GameInteractivePlayerPacket p; p.read(m_fs, m_game, mol);} |
2286 | 124 | log("took %ums\n", timer.ms_since_last_query()); | 124 | log("took %ums\n", timer.ms_since_last_query()); |
2287 | 125 | } | 125 | } |
2288 | 126 | 126 | ||
2289 | 127 | 127 | ||
2290 | === modified file 'src/game_io/game_map_packet.cc' | |||
2291 | --- src/game_io/game_map_packet.cc 2014-09-10 07:57:29 +0000 | |||
2292 | +++ src/game_io/game_map_packet.cc 2014-09-29 14:39:47 +0000 | |||
2293 | @@ -34,16 +34,16 @@ | |||
2294 | 34 | delete m_wml; | 34 | delete m_wml; |
2295 | 35 | } | 35 | } |
2296 | 36 | 36 | ||
2298 | 37 | void GameMapPacket::Read | 37 | void GameMapPacket::read |
2299 | 38 | (FileSystem & fs, Game & game, MapObjectLoader * const) | 38 | (FileSystem & fs, Game & game, MapObjectLoader * const) |
2300 | 39 | { | 39 | { |
2302 | 40 | if (!fs.FileExists("map") || !fs.IsDirectory("map")) | 40 | if (!fs.file_exists("map") || !fs.is_directory("map")) |
2303 | 41 | throw GameDataError("no map"); | 41 | throw GameDataError("no map"); |
2304 | 42 | 42 | ||
2305 | 43 | // Now Load the map as it would be a normal map saving. | 43 | // Now Load the map as it would be a normal map saving. |
2306 | 44 | delete m_wml; | 44 | delete m_wml; |
2307 | 45 | 45 | ||
2309 | 46 | m_wml = new WidelandsMapLoader(fs.MakeSubFileSystem("map"), &game.map()); | 46 | m_wml = new WidelandsMapLoader(fs.make_sub_file_system("map"), &game.map()); |
2310 | 47 | 47 | ||
2311 | 48 | m_wml->preload_map(true); | 48 | m_wml->preload_map(true); |
2312 | 49 | 49 | ||
2313 | @@ -53,18 +53,18 @@ | |||
2314 | 53 | } | 53 | } |
2315 | 54 | 54 | ||
2316 | 55 | 55 | ||
2318 | 56 | void GameMapPacket::Read_Complete(Game & game) { | 56 | void GameMapPacket::read_complete(Game & game) { |
2319 | 57 | m_wml->load_map_complete(game, true); | 57 | m_wml->load_map_complete(game, true); |
2320 | 58 | m_mol = m_wml->get_map_object_loader(); | 58 | m_mol = m_wml->get_map_object_loader(); |
2321 | 59 | } | 59 | } |
2322 | 60 | 60 | ||
2323 | 61 | 61 | ||
2325 | 62 | void GameMapPacket::Write | 62 | void GameMapPacket::write |
2326 | 63 | (FileSystem & fs, Game & game, MapObjectSaver * const) | 63 | (FileSystem & fs, Game & game, MapObjectSaver * const) |
2327 | 64 | { | 64 | { |
2328 | 65 | 65 | ||
2329 | 66 | std::unique_ptr<FileSystem> mapfs | 66 | std::unique_ptr<FileSystem> mapfs |
2331 | 67 | (fs.CreateSubFileSystem("map", FileSystem::DIR)); | 67 | (fs.create_sub_file_system("map", FileSystem::DIR)); |
2332 | 68 | 68 | ||
2333 | 69 | // Now Write the map as it would be a normal map saving. | 69 | // Now Write the map as it would be a normal map saving. |
2334 | 70 | delete m_wms; | 70 | delete m_wms; |
2335 | 71 | 71 | ||
2336 | === modified file 'src/game_io/game_map_packet.h' | |||
2337 | --- src/game_io/game_map_packet.h 2014-09-10 16:57:31 +0000 | |||
2338 | +++ src/game_io/game_map_packet.h 2014-09-29 14:39:47 +0000 | |||
2339 | @@ -36,11 +36,11 @@ | |||
2340 | 36 | 36 | ||
2341 | 37 | 37 | ||
2342 | 38 | /// Ensures that the world gets loaded but does not much more. | 38 | /// Ensures that the world gets loaded but does not much more. |
2348 | 39 | void Read (FileSystem &, Game &, MapObjectLoader * = nullptr) override; | 39 | void read (FileSystem &, Game &, MapObjectLoader * = nullptr) override; |
2349 | 40 | 40 | ||
2350 | 41 | void Read_Complete(Game &); /// Loads the rest of the map. | 41 | void read_complete(Game &); /// Loads the rest of the map. |
2351 | 42 | 42 | ||
2352 | 43 | void Write(FileSystem &, Game &, MapObjectSaver * = nullptr) override; | 43 | void write(FileSystem &, Game &, MapObjectSaver * = nullptr) override; |
2353 | 44 | 44 | ||
2354 | 45 | MapObjectSaver * get_map_object_saver () {return m_mos;} | 45 | MapObjectSaver * get_map_object_saver () {return m_mos;} |
2355 | 46 | MapObjectLoader * get_map_object_loader() {return m_mol;} | 46 | MapObjectLoader * get_map_object_loader() {return m_mol;} |
2356 | 47 | 47 | ||
2357 | === modified file 'src/game_io/game_player_economies_packet.cc' | |||
2358 | --- src/game_io/game_player_economies_packet.cc 2014-09-10 08:55:04 +0000 | |||
2359 | +++ src/game_io/game_player_economies_packet.cc 2014-09-29 14:39:47 +0000 | |||
2360 | @@ -35,7 +35,7 @@ | |||
2361 | 35 | #define CURRENT_PACKET_VERSION 3 | 35 | #define CURRENT_PACKET_VERSION 3 |
2362 | 36 | 36 | ||
2363 | 37 | 37 | ||
2365 | 38 | void GamePlayerEconomiesPacket::Read | 38 | void GamePlayerEconomiesPacket::read |
2366 | 39 | (FileSystem & fs, Game & game, MapObjectLoader *) | 39 | (FileSystem & fs, Game & game, MapObjectLoader *) |
2367 | 40 | { | 40 | { |
2368 | 41 | try { | 41 | try { |
2369 | @@ -44,30 +44,30 @@ | |||
2370 | 44 | PlayerNumber const nr_players = map.get_nrplayers(); | 44 | PlayerNumber const nr_players = map.get_nrplayers(); |
2371 | 45 | 45 | ||
2372 | 46 | FileRead fr; | 46 | FileRead fr; |
2375 | 47 | fr.Open(fs, "binary/player_economies"); | 47 | fr.open(fs, "binary/player_economies"); |
2376 | 48 | uint16_t const packet_version = fr.Unsigned16(); | 48 | uint16_t const packet_version = fr.unsigned_16(); |
2377 | 49 | if (3 <= packet_version && packet_version <= CURRENT_PACKET_VERSION) { | 49 | if (3 <= packet_version && packet_version <= CURRENT_PACKET_VERSION) { |
2378 | 50 | iterate_players_existing(p, nr_players, game, player) | 50 | iterate_players_existing(p, nr_players, game, player) |
2379 | 51 | try { | 51 | try { |
2380 | 52 | Player::Economies & economies = player->m_economies; | 52 | Player::Economies & economies = player->m_economies; |
2381 | 53 | for (uint32_t i = 0; i < economies.size(); ++i) { | 53 | for (uint32_t i = 0; i < economies.size(); ++i) { |
2383 | 54 | uint32_t value = fr.Unsigned32(); | 54 | uint32_t value = fr.unsigned_32(); |
2384 | 55 | if (value < 0xffffffff) { | 55 | if (value < 0xffffffff) { |
2385 | 56 | if (upcast(Flag const, flag, map[value].get_immovable())) { | 56 | if (upcast(Flag const, flag, map[value].get_immovable())) { |
2386 | 57 | EconomyDataPacket d(flag->get_economy()); | 57 | EconomyDataPacket d(flag->get_economy()); |
2388 | 58 | d.Read(fr); | 58 | d.read(fr); |
2389 | 59 | } else { | 59 | } else { |
2390 | 60 | throw GameDataError("there is no flag at the specified location"); | 60 | throw GameDataError("there is no flag at the specified location"); |
2391 | 61 | } | 61 | } |
2392 | 62 | } else { | 62 | } else { |
2393 | 63 | bool read_this_economy = false; | 63 | bool read_this_economy = false; |
2394 | 64 | 64 | ||
2396 | 65 | Bob* bob = map[ReadMap_Index32(&fr, max_index)].get_first_bob(); | 65 | Bob* bob = map[read_map_index_32(&fr, max_index)].get_first_bob(); |
2397 | 66 | while (bob) { | 66 | while (bob) { |
2398 | 67 | if (upcast(Ship const, ship, bob)) { | 67 | if (upcast(Ship const, ship, bob)) { |
2399 | 68 | assert(ship->get_economy()); | 68 | assert(ship->get_economy()); |
2400 | 69 | EconomyDataPacket d(ship->get_economy()); | 69 | EconomyDataPacket d(ship->get_economy()); |
2402 | 70 | d.Read(fr); | 70 | d.read(fr); |
2403 | 71 | read_this_economy = true; | 71 | read_this_economy = true; |
2404 | 72 | } | 72 | } |
2405 | 73 | bob = bob->get_next_bob(); | 73 | bob = bob->get_next_bob(); |
2406 | @@ -91,12 +91,12 @@ | |||
2407 | 91 | /* | 91 | /* |
2408 | 92 | * Write Function | 92 | * Write Function |
2409 | 93 | */ | 93 | */ |
2411 | 94 | void GamePlayerEconomiesPacket::Write | 94 | void GamePlayerEconomiesPacket::write |
2412 | 95 | (FileSystem & fs, Game & game, MapObjectSaver * const) | 95 | (FileSystem & fs, Game & game, MapObjectSaver * const) |
2413 | 96 | { | 96 | { |
2414 | 97 | FileWrite fw; | 97 | FileWrite fw; |
2415 | 98 | 98 | ||
2417 | 99 | fw.Unsigned16(CURRENT_PACKET_VERSION); | 99 | fw.unsigned_16(CURRENT_PACKET_VERSION); |
2418 | 100 | 100 | ||
2419 | 101 | const Map & map = game.map(); | 101 | const Map & map = game.map(); |
2420 | 102 | const Field & field_0 = map[0]; | 102 | const Field & field_0 = map[0]; |
2421 | @@ -110,10 +110,10 @@ | |||
2422 | 110 | for (Field const * field = &field_0; field < &map[map.max_index()]; ++field) { | 110 | for (Field const * field = &field_0; field < &map[map.max_index()]; ++field) { |
2423 | 111 | if (upcast(Flag const, flag, field->get_immovable())) { | 111 | if (upcast(Flag const, flag, field->get_immovable())) { |
2424 | 112 | if (flag->get_economy() == temp_economy) { | 112 | if (flag->get_economy() == temp_economy) { |
2426 | 113 | fw.Unsigned32(field - &field_0); | 113 | fw.unsigned_32(field - &field_0); |
2427 | 114 | 114 | ||
2428 | 115 | EconomyDataPacket d(flag->get_economy()); | 115 | EconomyDataPacket d(flag->get_economy()); |
2430 | 116 | d.Write(fw); | 116 | d.write(fw); |
2431 | 117 | wrote_this_economy = true; | 117 | wrote_this_economy = true; |
2432 | 118 | break; | 118 | break; |
2433 | 119 | } | 119 | } |
2434 | @@ -131,11 +131,11 @@ | |||
2435 | 131 | if (upcast(Ship const, ship, bob)) { | 131 | if (upcast(Ship const, ship, bob)) { |
2436 | 132 | if (ship->get_economy() == temp_economy) { | 132 | if (ship->get_economy() == temp_economy) { |
2437 | 133 | // TODO(sirver): the 0xffffffff is ugly and fragile. | 133 | // TODO(sirver): the 0xffffffff is ugly and fragile. |
2440 | 134 | fw.Unsigned32(0xffffffff); // Sentinel value. | 134 | fw.unsigned_32(0xffffffff); // Sentinel value. |
2441 | 135 | fw.Unsigned32(field - &field_0); | 135 | fw.unsigned_32(field - &field_0); |
2442 | 136 | 136 | ||
2443 | 137 | EconomyDataPacket d(ship->get_economy()); | 137 | EconomyDataPacket d(ship->get_economy()); |
2445 | 138 | d.Write(fw); | 138 | d.write(fw); |
2446 | 139 | wrote_this_economy = true; | 139 | wrote_this_economy = true; |
2447 | 140 | } | 140 | } |
2448 | 141 | } | 141 | } |
2449 | @@ -149,7 +149,7 @@ | |||
2450 | 149 | } | 149 | } |
2451 | 150 | } | 150 | } |
2452 | 151 | 151 | ||
2454 | 152 | fw.Write(fs, "binary/player_economies"); | 152 | fw.write(fs, "binary/player_economies"); |
2455 | 153 | } | 153 | } |
2456 | 154 | 154 | ||
2457 | 155 | } | 155 | } |
2458 | 156 | 156 | ||
2459 | === modified file 'src/game_io/game_player_economies_packet.h' | |||
2460 | --- src/game_io/game_player_economies_packet.h 2014-09-10 16:57:31 +0000 | |||
2461 | +++ src/game_io/game_player_economies_packet.h 2014-09-29 14:39:47 +0000 | |||
2462 | @@ -28,8 +28,8 @@ | |||
2463 | 28 | * how many and which economies does a player have? | 28 | * how many and which economies does a player have? |
2464 | 29 | */ | 29 | */ |
2465 | 30 | struct GamePlayerEconomiesPacket : public GameDataPacket { | 30 | struct GamePlayerEconomiesPacket : public GameDataPacket { |
2468 | 31 | void Read (FileSystem &, Game &, MapObjectLoader * = nullptr) override; | 31 | void read (FileSystem &, Game &, MapObjectLoader * = nullptr) override; |
2469 | 32 | void Write(FileSystem &, Game &, MapObjectSaver * = nullptr) override; | 32 | void write(FileSystem &, Game &, MapObjectSaver * = nullptr) override; |
2470 | 33 | }; | 33 | }; |
2471 | 34 | 34 | ||
2472 | 35 | } | 35 | } |
2473 | 36 | 36 | ||
2474 | === modified file 'src/game_io/game_player_info_packet.cc' | |||
2475 | --- src/game_io/game_player_info_packet.cc 2014-09-10 08:55:04 +0000 | |||
2476 | +++ src/game_io/game_player_info_packet.cc 2014-09-29 14:39:47 +0000 | |||
2477 | @@ -33,61 +33,61 @@ | |||
2478 | 33 | #define CURRENT_PACKET_VERSION 15 | 33 | #define CURRENT_PACKET_VERSION 15 |
2479 | 34 | 34 | ||
2480 | 35 | 35 | ||
2482 | 36 | void GamePlayerInfoPacket::Read | 36 | void GamePlayerInfoPacket::read |
2483 | 37 | (FileSystem & fs, Game & game, MapObjectLoader *) | 37 | (FileSystem & fs, Game & game, MapObjectLoader *) |
2484 | 38 | { | 38 | { |
2485 | 39 | try { | 39 | try { |
2486 | 40 | FileRead fr; | 40 | FileRead fr; |
2489 | 41 | fr.Open(fs, "binary/player_info"); | 41 | fr.open(fs, "binary/player_info"); |
2490 | 42 | uint16_t const packet_version = fr.Unsigned16(); | 42 | uint16_t const packet_version = fr.unsigned_16(); |
2491 | 43 | if (5 <= packet_version && packet_version <= CURRENT_PACKET_VERSION) { | 43 | if (5 <= packet_version && packet_version <= CURRENT_PACKET_VERSION) { |
2493 | 44 | uint32_t const max_players = fr.Unsigned16(); | 44 | uint32_t const max_players = fr.unsigned_16(); |
2494 | 45 | for (uint32_t i = 1; i < max_players + 1; ++i) { | 45 | for (uint32_t i = 1; i < max_players + 1; ++i) { |
2495 | 46 | game.remove_player(i); | 46 | game.remove_player(i); |
2498 | 47 | if (fr.Unsigned8()) { | 47 | if (fr.unsigned_8()) { |
2499 | 48 | bool const see_all = fr.Unsigned8(); | 48 | bool const see_all = fr.unsigned_8(); |
2500 | 49 | 49 | ||
2502 | 50 | int32_t const plnum = fr.Unsigned8(); | 50 | int32_t const plnum = fr.unsigned_8(); |
2503 | 51 | if (plnum < 1 || MAX_PLAYERS < plnum) | 51 | if (plnum < 1 || MAX_PLAYERS < plnum) |
2504 | 52 | throw GameDataError | 52 | throw GameDataError |
2505 | 53 | ("player number (%i) is out of range (1 .. %u)", | 53 | ("player number (%i) is out of range (1 .. %u)", |
2506 | 54 | plnum, MAX_PLAYERS); | 54 | plnum, MAX_PLAYERS); |
2507 | 55 | Widelands::TeamNumber team = 0; | 55 | Widelands::TeamNumber team = 0; |
2508 | 56 | if (packet_version >= 9) | 56 | if (packet_version >= 9) |
2514 | 57 | team = fr.Unsigned8(); | 57 | team = fr.unsigned_8(); |
2515 | 58 | 58 | ||
2516 | 59 | char const * const tribe_name = fr.CString(); | 59 | char const * const tribe_name = fr.c_string(); |
2517 | 60 | 60 | ||
2518 | 61 | std::string const name = fr.CString(); | 61 | std::string const name = fr.c_string(); |
2519 | 62 | 62 | ||
2520 | 63 | game.add_player(plnum, 0, tribe_name, name, team); | 63 | game.add_player(plnum, 0, tribe_name, name, team); |
2521 | 64 | Player & player = game.player(plnum); | 64 | Player & player = game.player(plnum); |
2522 | 65 | player.set_see_all(see_all); | 65 | player.set_see_all(see_all); |
2523 | 66 | 66 | ||
2525 | 67 | player.setAI(fr.CString()); | 67 | player.set_ai(fr.c_string()); |
2526 | 68 | 68 | ||
2527 | 69 | if (packet_version >= 15) | 69 | if (packet_version >= 15) |
2529 | 70 | player.ReadStatistics(fr, 3); | 70 | player.read_statistics(fr, 3); |
2530 | 71 | else if (packet_version >= 14) | 71 | else if (packet_version >= 14) |
2532 | 72 | player.ReadStatistics(fr, 2); | 72 | player.read_statistics(fr, 2); |
2533 | 73 | else if (packet_version >= 12) | 73 | else if (packet_version >= 12) |
2535 | 74 | player.ReadStatistics(fr, 1); | 74 | player.read_statistics(fr, 1); |
2536 | 75 | else | 75 | else |
2538 | 76 | player.ReadStatistics(fr, 0); | 76 | player.read_statistics(fr, 0); |
2539 | 77 | 77 | ||
2546 | 78 | player.m_casualties = fr.Unsigned32(); | 78 | player.m_casualties = fr.unsigned_32(); |
2547 | 79 | player.m_kills = fr.Unsigned32(); | 79 | player.m_kills = fr.unsigned_32(); |
2548 | 80 | player.m_msites_lost = fr.Unsigned32(); | 80 | player.m_msites_lost = fr.unsigned_32(); |
2549 | 81 | player.m_msites_defeated = fr.Unsigned32(); | 81 | player.m_msites_defeated = fr.unsigned_32(); |
2550 | 82 | player.m_civil_blds_lost = fr.Unsigned32(); | 82 | player.m_civil_blds_lost = fr.unsigned_32(); |
2551 | 83 | player.m_civil_blds_defeated = fr.Unsigned32(); | 83 | player.m_civil_blds_defeated = fr.unsigned_32(); |
2552 | 84 | } | 84 | } |
2553 | 85 | } | 85 | } |
2554 | 86 | 86 | ||
2555 | 87 | if (packet_version <= 10) | 87 | if (packet_version <= 10) |
2557 | 88 | game.ReadStatistics(fr, 3); | 88 | game.read_statistics(fr, 3); |
2558 | 89 | else | 89 | else |
2560 | 90 | game.ReadStatistics(fr, 4); | 90 | game.read_statistics(fr, 4); |
2561 | 91 | } else | 91 | } else |
2562 | 92 | throw GameDataError | 92 | throw GameDataError |
2563 | 93 | ("unknown/unhandled version %u", packet_version); | 93 | ("unknown/unhandled version %u", packet_version); |
2564 | @@ -97,48 +97,48 @@ | |||
2565 | 97 | } | 97 | } |
2566 | 98 | 98 | ||
2567 | 99 | 99 | ||
2569 | 100 | void GamePlayerInfoPacket::Write | 100 | void GamePlayerInfoPacket::write |
2570 | 101 | (FileSystem & fs, Game & game, MapObjectSaver *) | 101 | (FileSystem & fs, Game & game, MapObjectSaver *) |
2571 | 102 | { | 102 | { |
2572 | 103 | FileWrite fw; | 103 | FileWrite fw; |
2573 | 104 | 104 | ||
2574 | 105 | // Now packet version | 105 | // Now packet version |
2576 | 106 | fw.Unsigned16(CURRENT_PACKET_VERSION); | 106 | fw.unsigned_16(CURRENT_PACKET_VERSION); |
2577 | 107 | 107 | ||
2578 | 108 | // Number of (potential) players | 108 | // Number of (potential) players |
2579 | 109 | PlayerNumber const nr_players = game.map().get_nrplayers(); | 109 | PlayerNumber const nr_players = game.map().get_nrplayers(); |
2581 | 110 | fw.Unsigned16(nr_players); | 110 | fw.unsigned_16(nr_players); |
2582 | 111 | iterate_players_existing_const(p, nr_players, game, plr) { | 111 | iterate_players_existing_const(p, nr_players, game, plr) { |
2591 | 112 | fw.Unsigned8(1); // Player is in game. | 112 | fw.unsigned_8(1); // Player is in game. |
2592 | 113 | 113 | ||
2593 | 114 | fw.Unsigned8(plr->m_see_all); | 114 | fw.unsigned_8(plr->m_see_all); |
2594 | 115 | 115 | ||
2595 | 116 | fw.Unsigned8(plr->m_plnum); | 116 | fw.unsigned_8(plr->m_plnum); |
2596 | 117 | fw.Unsigned8(plr->team_number()); | 117 | fw.unsigned_8(plr->team_number()); |
2597 | 118 | 118 | ||
2598 | 119 | fw.CString(plr->tribe().name().c_str()); | 119 | fw.c_string(plr->tribe().name().c_str()); |
2599 | 120 | 120 | ||
2600 | 121 | // Seen fields is in a map packet | 121 | // Seen fields is in a map packet |
2601 | 122 | // Allowed buildings is in a map packet | 122 | // Allowed buildings is in a map packet |
2602 | 123 | 123 | ||
2603 | 124 | // Economies are in a packet after map loading | 124 | // Economies are in a packet after map loading |
2604 | 125 | 125 | ||
2607 | 126 | fw.CString(plr->m_name.c_str()); | 126 | fw.c_string(plr->m_name.c_str()); |
2608 | 127 | fw.CString(plr->m_ai.c_str()); | 127 | fw.c_string(plr->m_ai.c_str()); |
2609 | 128 | 128 | ||
2617 | 129 | plr->WriteStatistics(fw); | 129 | plr->write_statistics(fw); |
2618 | 130 | fw.Unsigned32(plr->casualties()); | 130 | fw.unsigned_32(plr->casualties()); |
2619 | 131 | fw.Unsigned32(plr->kills ()); | 131 | fw.unsigned_32(plr->kills ()); |
2620 | 132 | fw.Unsigned32(plr->msites_lost ()); | 132 | fw.unsigned_32(plr->msites_lost ()); |
2621 | 133 | fw.Unsigned32(plr->msites_defeated ()); | 133 | fw.unsigned_32(plr->msites_defeated ()); |
2622 | 134 | fw.Unsigned32(plr->civil_blds_lost ()); | 134 | fw.unsigned_32(plr->civil_blds_lost ()); |
2623 | 135 | fw.Unsigned32(plr->civil_blds_defeated()); | 135 | fw.unsigned_32(plr->civil_blds_defeated()); |
2624 | 136 | } else | 136 | } else |
2630 | 137 | fw.Unsigned8(0); // Player is NOT in game. | 137 | fw.unsigned_8(0); // Player is NOT in game. |
2631 | 138 | 138 | ||
2632 | 139 | game.WriteStatistics(fw); | 139 | game.write_statistics(fw); |
2633 | 140 | 140 | ||
2634 | 141 | fw.Write(fs, "binary/player_info"); | 141 | fw.write(fs, "binary/player_info"); |
2635 | 142 | } | 142 | } |
2636 | 143 | 143 | ||
2637 | 144 | } | 144 | } |
2638 | 145 | 145 | ||
2639 | === modified file 'src/game_io/game_player_info_packet.h' | |||
2640 | --- src/game_io/game_player_info_packet.h 2014-09-10 16:57:31 +0000 | |||
2641 | +++ src/game_io/game_player_info_packet.h 2014-09-29 14:39:47 +0000 | |||
2642 | @@ -29,8 +29,8 @@ | |||
2643 | 29 | * a game for a user (for example in a listbox) | 29 | * a game for a user (for example in a listbox) |
2644 | 30 | */ | 30 | */ |
2645 | 31 | struct GamePlayerInfoPacket : public GameDataPacket { | 31 | struct GamePlayerInfoPacket : public GameDataPacket { |
2648 | 32 | void Read (FileSystem &, Game &, MapObjectLoader * = nullptr) override; | 32 | void read (FileSystem &, Game &, MapObjectLoader * = nullptr) override; |
2649 | 33 | void Write(FileSystem &, Game &, MapObjectSaver * = nullptr) override; | 33 | void write(FileSystem &, Game &, MapObjectSaver * = nullptr) override; |
2650 | 34 | }; | 34 | }; |
2651 | 35 | 35 | ||
2652 | 36 | } | 36 | } |
2653 | 37 | 37 | ||
2654 | === modified file 'src/game_io/game_preload_packet.cc' | |||
2655 | --- src/game_io/game_preload_packet.cc 2014-09-10 13:03:40 +0000 | |||
2656 | +++ src/game_io/game_preload_packet.cc 2014-09-29 14:39:47 +0000 | |||
2657 | @@ -45,7 +45,7 @@ | |||
2658 | 45 | #define MINIMAP_FILENAME "minimap.png" | 45 | #define MINIMAP_FILENAME "minimap.png" |
2659 | 46 | 46 | ||
2660 | 47 | 47 | ||
2662 | 48 | void GamePreloadPacket::Read | 48 | void GamePreloadPacket::read |
2663 | 49 | (FileSystem & fs, Game &, MapObjectLoader * const) | 49 | (FileSystem & fs, Game &, MapObjectLoader * const) |
2664 | 50 | { | 50 | { |
2665 | 51 | try { | 51 | try { |
2666 | @@ -62,7 +62,7 @@ | |||
2667 | 62 | m_player_nr = s.get_safe_int("player_nr"); | 62 | m_player_nr = s.get_safe_int("player_nr"); |
2668 | 63 | m_win_condition = s.get_safe_string("win_condition"); | 63 | m_win_condition = s.get_safe_string("win_condition"); |
2669 | 64 | m_number_of_players = s.get_safe_int(PLAYERS_AMOUNT_KEY_V4); | 64 | m_number_of_players = s.get_safe_int(PLAYERS_AMOUNT_KEY_V4); |
2671 | 65 | if (fs.FileExists(MINIMAP_FILENAME)) { | 65 | if (fs.file_exists(MINIMAP_FILENAME)) { |
2672 | 66 | m_minimap_path = MINIMAP_FILENAME; | 66 | m_minimap_path = MINIMAP_FILENAME; |
2673 | 67 | } | 67 | } |
2674 | 68 | } else { | 68 | } else { |
2675 | @@ -75,7 +75,7 @@ | |||
2676 | 75 | } | 75 | } |
2677 | 76 | 76 | ||
2678 | 77 | 77 | ||
2680 | 78 | void GamePreloadPacket::Write | 78 | void GamePreloadPacket::write |
2681 | 79 | (FileSystem & fs, Game & game, MapObjectSaver * const) | 79 | (FileSystem & fs, Game & game, MapObjectSaver * const) |
2682 | 80 | { | 80 | { |
2683 | 81 | 81 | ||
2684 | @@ -116,10 +116,10 @@ | |||
2685 | 116 | if (ipl != nullptr) { | 116 | if (ipl != nullptr) { |
2686 | 117 | const MiniMapLayer flags = MiniMapLayer::Owner | MiniMapLayer::Building | MiniMapLayer::Terrain; | 117 | const MiniMapLayer flags = MiniMapLayer::Owner | MiniMapLayer::Building | MiniMapLayer::Terrain; |
2687 | 118 | const Point& vp = ipl->get_viewpoint(); | 118 | const Point& vp = ipl->get_viewpoint(); |
2689 | 119 | std::unique_ptr< ::StreamWrite> sw(fs.OpenStreamWrite(MINIMAP_FILENAME)); | 119 | std::unique_ptr< ::StreamWrite> sw(fs.open_stream_write(MINIMAP_FILENAME)); |
2690 | 120 | if (sw.get() != nullptr) { | 120 | if (sw.get() != nullptr) { |
2691 | 121 | write_minimap_image(game, &ipl->player(), vp, flags, sw.get()); | 121 | write_minimap_image(game, &ipl->player(), vp, flags, sw.get()); |
2693 | 122 | sw->Flush(); | 122 | sw->flush(); |
2694 | 123 | } | 123 | } |
2695 | 124 | } | 124 | } |
2696 | 125 | } | 125 | } |
2697 | 126 | 126 | ||
2698 | === modified file 'src/game_io/game_preload_packet.h' | |||
2699 | --- src/game_io/game_preload_packet.h 2014-09-10 16:57:31 +0000 | |||
2700 | +++ src/game_io/game_preload_packet.h 2014-09-29 14:39:47 +0000 | |||
2701 | @@ -32,8 +32,8 @@ | |||
2702 | 32 | * a game for a user (for example in a listbox) | 32 | * a game for a user (for example in a listbox) |
2703 | 33 | */ | 33 | */ |
2704 | 34 | struct GamePreloadPacket : public GameDataPacket { | 34 | struct GamePreloadPacket : public GameDataPacket { |
2707 | 35 | void Read (FileSystem &, Game &, MapObjectLoader * = nullptr) override; | 35 | void read (FileSystem &, Game &, MapObjectLoader * = nullptr) override; |
2708 | 36 | void Write(FileSystem &, Game &, MapObjectSaver * = nullptr) override; | 36 | void write(FileSystem &, Game &, MapObjectSaver * = nullptr) override; |
2709 | 37 | 37 | ||
2710 | 38 | char const * get_mapname() {return m_mapname.c_str();} | 38 | char const * get_mapname() {return m_mapname.c_str();} |
2711 | 39 | std::string get_background() {return m_background;} | 39 | std::string get_background() {return m_background;} |
2712 | 40 | 40 | ||
2713 | === modified file 'src/game_io/game_saver.cc' | |||
2714 | --- src/game_io/game_saver.cc 2014-09-10 16:57:31 +0000 | |||
2715 | +++ src/game_io/game_saver.cc 2014-09-29 14:39:47 +0000 | |||
2716 | @@ -43,36 +43,36 @@ | |||
2717 | 43 | void GameSaver::save() { | 43 | void GameSaver::save() { |
2718 | 44 | ScopedTimer timer("GameSaver::save() took %ums"); | 44 | ScopedTimer timer("GameSaver::save() took %ums"); |
2719 | 45 | 45 | ||
2721 | 46 | m_fs.EnsureDirectoryExists("binary"); | 46 | m_fs.ensure_directory_exists("binary"); |
2722 | 47 | 47 | ||
2723 | 48 | log("Game: Writing Preload Data ... "); | 48 | log("Game: Writing Preload Data ... "); |
2725 | 49 | {GamePreloadPacket p; p.Write(m_fs, m_game, nullptr);} | 49 | {GamePreloadPacket p; p.write(m_fs, m_game, nullptr);} |
2726 | 50 | log("took %ums\n", timer.ms_since_last_query()); | 50 | log("took %ums\n", timer.ms_since_last_query()); |
2727 | 51 | 51 | ||
2728 | 52 | log("Game: Writing Game Class Data ... "); | 52 | log("Game: Writing Game Class Data ... "); |
2730 | 53 | {GameClassPacket p; p.Write(m_fs, m_game, nullptr);} | 53 | {GameClassPacket p; p.write(m_fs, m_game, nullptr);} |
2731 | 54 | log("took %ums\n", timer.ms_since_last_query()); | 54 | log("took %ums\n", timer.ms_since_last_query()); |
2732 | 55 | 55 | ||
2733 | 56 | log("Game: Writing Player Info ... "); | 56 | log("Game: Writing Player Info ... "); |
2735 | 57 | {GamePlayerInfoPacket p; p.Write(m_fs, m_game, nullptr);} | 57 | {GamePlayerInfoPacket p; p.write(m_fs, m_game, nullptr);} |
2736 | 58 | log("took %ums\n", timer.ms_since_last_query()); | 58 | log("took %ums\n", timer.ms_since_last_query()); |
2737 | 59 | 59 | ||
2738 | 60 | log("Game: Writing Map Data!\n"); | 60 | log("Game: Writing Map Data!\n"); |
2740 | 61 | GameMapPacket M; M.Write(m_fs, m_game, nullptr); | 61 | GameMapPacket M; M.write(m_fs, m_game, nullptr); |
2741 | 62 | log("Game: Writing Map Data took %ums\n", timer.ms_since_last_query()); | 62 | log("Game: Writing Map Data took %ums\n", timer.ms_since_last_query()); |
2742 | 63 | 63 | ||
2743 | 64 | MapObjectSaver * const mos = M.get_map_object_saver(); | 64 | MapObjectSaver * const mos = M.get_map_object_saver(); |
2744 | 65 | 65 | ||
2745 | 66 | log("Game: Writing Player Economies Info ... "); | 66 | log("Game: Writing Player Economies Info ... "); |
2747 | 67 | {GamePlayerEconomiesPacket p; p.Write(m_fs, m_game, mos);} | 67 | {GamePlayerEconomiesPacket p; p.write(m_fs, m_game, mos);} |
2748 | 68 | log("took %ums\n", timer.ms_since_last_query()); | 68 | log("took %ums\n", timer.ms_since_last_query()); |
2749 | 69 | 69 | ||
2750 | 70 | log("Game: Writing Command Queue Data ... "); | 70 | log("Game: Writing Command Queue Data ... "); |
2752 | 71 | {GameCmdQueuePacket p; p.Write(m_fs, m_game, mos);} | 71 | {GameCmdQueuePacket p; p.write(m_fs, m_game, mos);} |
2753 | 72 | log("took %ums\n", timer.ms_since_last_query()); | 72 | log("took %ums\n", timer.ms_since_last_query()); |
2754 | 73 | 73 | ||
2755 | 74 | log("Game: Writing Interactive Player Data ... "); | 74 | log("Game: Writing Interactive Player Data ... "); |
2757 | 75 | {GameInteractivePlayerPacket p; p.Write(m_fs, m_game, mos);} | 75 | {GameInteractivePlayerPacket p; p.write(m_fs, m_game, mos);} |
2758 | 76 | log("took %ums\n", timer.ms_since_last_query()); | 76 | log("took %ums\n", timer.ms_since_last_query()); |
2759 | 77 | } | 77 | } |
2760 | 78 | 78 | ||
2761 | 79 | 79 | ||
2762 | === modified file 'src/graphic/animation.cc' | |||
2763 | --- src/graphic/animation.cc 2014-09-14 11:31:58 +0000 | |||
2764 | +++ src/graphic/animation.cc 2014-09-29 14:39:47 +0000 | |||
2765 | @@ -173,7 +173,7 @@ | |||
2766 | 173 | if (fps > 0) | 173 | if (fps > 0) |
2767 | 174 | frametime_ = 1000 / fps; | 174 | frametime_ = 1000 / fps; |
2768 | 175 | 175 | ||
2770 | 176 | hotspot_ = section.get_Point("hotspot"); | 176 | hotspot_ = section.get_point("hotspot"); |
2771 | 177 | 177 | ||
2772 | 178 | // In the filename template, the last sequence of '?' characters (if any) | 178 | // In the filename template, the last sequence of '?' characters (if any) |
2773 | 179 | // is replaced with a number, for example the template "idle_??" is | 179 | // is replaced with a number, for example the template "idle_??" is |
2774 | @@ -193,12 +193,12 @@ | |||
2775 | 193 | string filename_wo_ext; | 193 | string filename_wo_ext; |
2776 | 194 | while (glob.next(&filename_wo_ext)) { | 194 | while (glob.next(&filename_wo_ext)) { |
2777 | 195 | const string filename = filename_wo_ext + ".png"; | 195 | const string filename = filename_wo_ext + ".png"; |
2779 | 196 | if (!g_fs->FileExists(filename)) | 196 | if (!g_fs->file_exists(filename)) |
2780 | 197 | break; | 197 | break; |
2781 | 198 | image_files_.push_back(filename); | 198 | image_files_.push_back(filename); |
2782 | 199 | 199 | ||
2783 | 200 | const string pc_filename = filename_wo_ext + "_pc.png"; | 200 | const string pc_filename = filename_wo_ext + "_pc.png"; |
2785 | 201 | if (g_fs->FileExists(pc_filename)) { | 201 | if (g_fs->file_exists(pc_filename)) { |
2786 | 202 | hasplrclrs_ = true; | 202 | hasplrclrs_ = true; |
2787 | 203 | pc_mask_image_files_.push_back(pc_filename); | 203 | pc_mask_image_files_.push_back(pc_filename); |
2788 | 204 | } | 204 | } |
2789 | 205 | 205 | ||
2790 | === modified file 'src/graphic/diranimations.h' | |||
2791 | --- src/graphic/diranimations.h 2014-07-28 14:08:41 +0000 | |||
2792 | +++ src/graphic/diranimations.h 2014-09-29 14:39:47 +0000 | |||
2793 | @@ -52,7 +52,7 @@ | |||
2794 | 52 | m_animations[dir - 1] = anim; | 52 | m_animations[dir - 1] = anim; |
2795 | 53 | } | 53 | } |
2796 | 54 | 54 | ||
2798 | 55 | static DirAnimations Null() { | 55 | static DirAnimations null() { |
2799 | 56 | return DirAnimations(0); // Since real animation IDs are positive, this is safe | 56 | return DirAnimations(0); // Since real animation IDs are positive, this is safe |
2800 | 57 | } | 57 | } |
2801 | 58 | 58 | ||
2802 | 59 | 59 | ||
2803 | === modified file 'src/graphic/font.cc' | |||
2804 | --- src/graphic/font.cc 2014-09-14 11:31:58 +0000 | |||
2805 | +++ src/graphic/font.cc 2014-09-29 14:39:47 +0000 | |||
2806 | @@ -58,9 +58,9 @@ | |||
2807 | 58 | 58 | ||
2808 | 59 | // We must keep this File Read open, otherwise the following calls are | 59 | // We must keep this File Read open, otherwise the following calls are |
2809 | 60 | // crashing. do not know why... | 60 | // crashing. do not know why... |
2811 | 61 | m_fontfile.Open(*g_fs, filename); | 61 | m_fontfile.open(*g_fs, filename); |
2812 | 62 | 62 | ||
2814 | 63 | SDL_RWops * const ops = SDL_RWFromMem(m_fontfile.Data(0), m_fontfile.GetSize()); | 63 | SDL_RWops * const ops = SDL_RWFromMem(m_fontfile.data(0), m_fontfile.get_size()); |
2815 | 64 | if (!ops) | 64 | if (!ops) |
2816 | 65 | throw wexception("could not load font!: RWops Pointer invalid"); | 65 | throw wexception("could not load font!: RWops Pointer invalid"); |
2817 | 66 | 66 | ||
2818 | 67 | 67 | ||
2819 | === modified file 'src/graphic/graphic.cc' | |||
2820 | --- src/graphic/graphic.cc 2014-07-25 13:45:18 +0000 | |||
2821 | +++ src/graphic/graphic.cc 2014-09-29 14:39:47 +0000 | |||
2822 | @@ -309,7 +309,7 @@ | |||
2823 | 309 | SDL_GL_SwapBuffers(); | 309 | SDL_GL_SwapBuffers(); |
2824 | 310 | glEnable(GL_TEXTURE_2D); | 310 | glEnable(GL_TEXTURE_2D); |
2825 | 311 | 311 | ||
2827 | 312 | GLSurfaceTexture::Initialize(use_arb); | 312 | GLSurfaceTexture::initialize(use_arb); |
2828 | 313 | } | 313 | } |
2829 | 314 | 314 | ||
2830 | 315 | if (g_opengl) | 315 | if (g_opengl) |
2831 | @@ -341,7 +341,7 @@ | |||
2832 | 341 | UI::g_fh->flush(); | 341 | UI::g_fh->flush(); |
2833 | 342 | 342 | ||
2834 | 343 | if (g_opengl) | 343 | if (g_opengl) |
2836 | 344 | GLSurfaceTexture::Cleanup(); | 344 | GLSurfaceTexture::cleanup(); |
2837 | 345 | } | 345 | } |
2838 | 346 | 346 | ||
2839 | 347 | Graphic::~Graphic() | 347 | Graphic::~Graphic() |
2840 | @@ -487,7 +487,7 @@ | |||
2841 | 487 | void Graphic::screenshot(const string& fname) const | 487 | void Graphic::screenshot(const string& fname) const |
2842 | 488 | { | 488 | { |
2843 | 489 | log("Save screenshot to %s\n", fname.c_str()); | 489 | log("Save screenshot to %s\n", fname.c_str()); |
2845 | 490 | StreamWrite * sw = g_fs->OpenStreamWrite(fname); | 490 | StreamWrite * sw = g_fs->open_stream_write(fname); |
2846 | 491 | save_surface_to_png(screen_.get(), sw); | 491 | save_surface_to_png(screen_.get(), sw); |
2847 | 492 | delete sw; | 492 | delete sw; |
2848 | 493 | } | 493 | } |
2849 | 494 | 494 | ||
2850 | === modified file 'src/graphic/image_io.cc' | |||
2851 | --- src/graphic/image_io.cc 2014-07-14 10:45:44 +0000 | |||
2852 | +++ src/graphic/image_io.cc 2014-09-29 14:39:47 +0000 | |||
2853 | @@ -35,14 +35,14 @@ | |||
2854 | 35 | 35 | ||
2855 | 36 | // A helper function for save_surface_to_png. Writes the compressed data to | 36 | // A helper function for save_surface_to_png. Writes the compressed data to |
2856 | 37 | // the StreamWrite. | 37 | // the StreamWrite. |
2859 | 38 | void png_write_function(png_structp png_ptr, png_bytep data, png_size_t length) { | 38 | void png_write_function(png_structp png_ptr, png_bytep png_data, png_size_t length) { |
2860 | 39 | static_cast<StreamWrite*>(png_get_io_ptr(png_ptr))->Data(data, length); | 39 | static_cast<StreamWrite*>(png_get_io_ptr(png_ptr))->data(png_data, length); |
2861 | 40 | } | 40 | } |
2862 | 41 | 41 | ||
2863 | 42 | // A helper function for save_surface_to_png. | 42 | // A helper function for save_surface_to_png. |
2864 | 43 | // Flush function to avoid crashes with default libpng flush function | 43 | // Flush function to avoid crashes with default libpng flush function |
2865 | 44 | void png_flush_function(png_structp png_ptr) { | 44 | void png_flush_function(png_structp png_ptr) { |
2867 | 45 | static_cast<StreamWrite*>(png_get_io_ptr(png_ptr))->Flush(); | 45 | static_cast<StreamWrite*>(png_get_io_ptr(png_ptr))->flush(); |
2868 | 46 | } | 46 | } |
2869 | 47 | 47 | ||
2870 | 48 | } // namespace | 48 | } // namespace |
2871 | @@ -55,16 +55,16 @@ | |||
2872 | 55 | FileRead fr; | 55 | FileRead fr; |
2873 | 56 | bool found; | 56 | bool found; |
2874 | 57 | if (fs) { | 57 | if (fs) { |
2876 | 58 | found = fr.TryOpen(*fs, fname); | 58 | found = fr.try_open(*fs, fname); |
2877 | 59 | } else { | 59 | } else { |
2879 | 60 | found = fr.TryOpen(*g_fs, fname); | 60 | found = fr.try_open(*g_fs, fname); |
2880 | 61 | } | 61 | } |
2881 | 62 | 62 | ||
2882 | 63 | if (!found) { | 63 | if (!found) { |
2883 | 64 | throw ImageNotFound(fname); | 64 | throw ImageNotFound(fname); |
2884 | 65 | } | 65 | } |
2885 | 66 | 66 | ||
2887 | 67 | SDL_Surface* sdlsurf = IMG_Load_RW(SDL_RWFromMem(fr.Data(0), fr.GetSize()), 1); | 67 | SDL_Surface* sdlsurf = IMG_Load_RW(SDL_RWFromMem(fr.data(0), fr.get_size()), 1); |
2888 | 68 | if (!sdlsurf) { | 68 | if (!sdlsurf) { |
2889 | 69 | throw ImageLoadingError(fname.c_str(), IMG_GetError()); | 69 | throw ImageLoadingError(fname.c_str(), IMG_GetError()); |
2890 | 70 | } | 70 | } |
2891 | 71 | 71 | ||
2892 | === modified file 'src/graphic/render/gamerenderer_gl.cc' | |||
2893 | --- src/graphic/render/gamerenderer_gl.cc 2014-09-14 16:08:13 +0000 | |||
2894 | +++ src/graphic/render/gamerenderer_gl.cc 2014-09-29 14:39:47 +0000 | |||
2895 | @@ -295,7 +295,7 @@ | |||
2896 | 295 | const Texture & texture = | 295 | const Texture & texture = |
2897 | 296 | *g_gr->get_maptexture_data | 296 | *g_gr->get_maptexture_data |
2898 | 297 | (world.terrain_descr(ter).get_texture()); | 297 | (world.terrain_descr(ter).get_texture()); |
2900 | 298 | glBindTexture(GL_TEXTURE_2D, texture.getTexture()); | 298 | glBindTexture(GL_TEXTURE_2D, texture.get_texture()); |
2901 | 299 | glDrawRangeElements | 299 | glDrawRangeElements |
2902 | 300 | (GL_TRIANGLES, | 300 | (GL_TRIANGLES, |
2903 | 301 | 0, m_patch_size.w * m_patch_size.h - 1, | 301 | 0, m_patch_size.w * m_patch_size.h - 1, |
2904 | @@ -472,7 +472,7 @@ | |||
2905 | 472 | const Texture & texture = | 472 | const Texture & texture = |
2906 | 473 | *g_gr->get_maptexture_data | 473 | *g_gr->get_maptexture_data |
2907 | 474 | (m_egbase->world().terrain_descr(ter).get_texture()); | 474 | (m_egbase->world().terrain_descr(ter).get_texture()); |
2909 | 475 | glBindTexture(GL_TEXTURE_2D, texture.getTexture()); | 475 | glBindTexture(GL_TEXTURE_2D, texture.get_texture()); |
2910 | 476 | glDrawArrays | 476 | glDrawArrays |
2911 | 477 | (GL_TRIANGLES, | 477 | (GL_TRIANGLES, |
2912 | 478 | 3 * m_terrain_edge_freq_cum[ter], 3 * m_terrain_edge_freq[ter]); | 478 | 3 * m_terrain_edge_freq_cum[ter], 3 * m_terrain_edge_freq[ter]); |
2913 | 479 | 479 | ||
2914 | === modified file 'src/graphic/render/gl_surface_texture.cc' | |||
2915 | --- src/graphic/render/gl_surface_texture.cc 2014-07-20 07:44:53 +0000 | |||
2916 | +++ src/graphic/render/gl_surface_texture.cc 2014-09-29 14:39:47 +0000 | |||
2917 | @@ -32,7 +32,7 @@ | |||
2918 | 32 | /** | 32 | /** |
2919 | 33 | * Initial global resources needed for fast offscreen rendering. | 33 | * Initial global resources needed for fast offscreen rendering. |
2920 | 34 | */ | 34 | */ |
2922 | 35 | void GLSurfaceTexture::Initialize(bool use_arb) { | 35 | void GLSurfaceTexture::initialize(bool use_arb) { |
2923 | 36 | use_arb_ = use_arb; | 36 | use_arb_ = use_arb; |
2924 | 37 | 37 | ||
2925 | 38 | // Generate the framebuffer for Offscreen rendering. | 38 | // Generate the framebuffer for Offscreen rendering. |
2926 | @@ -48,7 +48,7 @@ | |||
2927 | 48 | /** | 48 | /** |
2928 | 49 | * Free global resources. | 49 | * Free global resources. |
2929 | 50 | */ | 50 | */ |
2931 | 51 | void GLSurfaceTexture::Cleanup() { | 51 | void GLSurfaceTexture::cleanup() { |
2932 | 52 | if (use_arb_) | 52 | if (use_arb_) |
2933 | 53 | glDeleteFramebuffers(1, &gl_framebuffer_id_); | 53 | glDeleteFramebuffers(1, &gl_framebuffer_id_); |
2934 | 54 | else | 54 | else |
2935 | 55 | 55 | ||
2936 | === modified file 'src/graphic/render/gl_surface_texture.h' | |||
2937 | --- src/graphic/render/gl_surface_texture.h 2014-07-26 10:43:23 +0000 | |||
2938 | +++ src/graphic/render/gl_surface_texture.h 2014-09-29 14:39:47 +0000 | |||
2939 | @@ -25,10 +25,10 @@ | |||
2940 | 25 | 25 | ||
2941 | 26 | class GLSurfaceTexture : public GLSurface { | 26 | class GLSurfaceTexture : public GLSurface { |
2942 | 27 | public: | 27 | public: |
2944 | 28 | // Call this once before using any instance of this class and Cleanup once | 28 | // Call this once before using any instance of this class and cleanup once |
2945 | 29 | // before the program exits. | 29 | // before the program exits. |
2948 | 30 | static void Initialize(bool use_arb); | 30 | static void initialize(bool use_arb); |
2949 | 31 | static void Cleanup(); | 31 | static void cleanup(); |
2950 | 32 | 32 | ||
2951 | 33 | GLSurfaceTexture(SDL_Surface * surface, bool intensity = false); | 33 | GLSurfaceTexture(SDL_Surface * surface, bool intensity = false); |
2952 | 34 | GLSurfaceTexture(int w, int h); | 34 | GLSurfaceTexture(int w, int h); |
2953 | 35 | 35 | ||
2954 | === modified file 'src/graphic/text/font_io.cc' | |||
2955 | --- src/graphic/text/font_io.cc 2014-09-10 16:57:31 +0000 | |||
2956 | +++ src/graphic/text/font_io.cc 2014-09-29 14:39:47 +0000 | |||
2957 | @@ -41,8 +41,8 @@ | |||
2958 | 41 | std::unique_ptr<std::string> memory; | 41 | std::unique_ptr<std::string> memory; |
2959 | 42 | { | 42 | { |
2960 | 43 | FileRead* fr = new FileRead(); | 43 | FileRead* fr = new FileRead(); |
2963 | 44 | fr->Open(*g_fs, filename); | 44 | fr->open(*g_fs, filename); |
2964 | 45 | memory.reset(new std::string(fr->Data(0), fr->GetSize())); | 45 | memory.reset(new std::string(fr->data(0), fr->get_size())); |
2965 | 46 | } | 46 | } |
2966 | 47 | 47 | ||
2967 | 48 | SDL_RWops* ops = SDL_RWFromConstMem(memory->data(), memory->size()); | 48 | SDL_RWops* ops = SDL_RWFromConstMem(memory->data(), memory->size()); |
2968 | 49 | 49 | ||
2969 | === modified file 'src/graphic/text/test/render.cc' | |||
2970 | --- src/graphic/text/test/render.cc 2014-07-14 10:45:44 +0000 | |||
2971 | +++ src/graphic/text/test/render.cc 2014-09-29 14:39:47 +0000 | |||
2972 | @@ -32,8 +32,8 @@ | |||
2973 | 32 | 32 | ||
2974 | 33 | StandaloneRenderer::StandaloneRenderer() { | 33 | StandaloneRenderer::StandaloneRenderer() { |
2975 | 34 | g_fs = new LayeredFileSystem(); | 34 | g_fs = new LayeredFileSystem(); |
2978 | 35 | g_fs->AddFileSystem(&FileSystem::Create(WIDELANDS_DATA_DIR)); | 35 | g_fs->add_file_system(&FileSystem::create(WIDELANDS_DATA_DIR)); |
2979 | 36 | g_fs->AddFileSystem(&FileSystem::Create(RICHTEXT_DATA_DIR)); | 36 | g_fs->add_file_system(&FileSystem::create(RICHTEXT_DATA_DIR)); |
2980 | 37 | 37 | ||
2981 | 38 | surface_cache_.reset(create_surface_cache(500 << 20)); // 500 MB | 38 | surface_cache_.reset(create_surface_cache(500 << 20)); // 500 MB |
2982 | 39 | image_cache_.reset(new ImageCache(surface_cache_.get())); | 39 | image_cache_.reset(new ImageCache(surface_cache_.get())); |
2983 | 40 | 40 | ||
2984 | === modified file 'src/graphic/text/test/render_richtext.cc' | |||
2985 | --- src/graphic/text/test/render_richtext.cc 2014-07-20 07:44:53 +0000 | |||
2986 | +++ src/graphic/text/test/render_richtext.cc 2014-09-29 14:39:47 +0000 | |||
2987 | @@ -123,8 +123,8 @@ | |||
2988 | 123 | std::unique_ptr<SDLSurface> surf( | 123 | std::unique_ptr<SDLSurface> surf( |
2989 | 124 | static_cast<SDLSurface*>(standalone_renderer.renderer()->render(txt, w, allowed_tags))); | 124 | static_cast<SDLSurface*>(standalone_renderer.renderer()->render(txt, w, allowed_tags))); |
2990 | 125 | 125 | ||
2993 | 126 | std::unique_ptr<FileSystem> fs(&FileSystem::Create(".")); | 126 | std::unique_ptr<FileSystem> fs(&FileSystem::create(".")); |
2994 | 127 | std::unique_ptr<StreamWrite> sw(fs->OpenStreamWrite(outname)); | 127 | std::unique_ptr<StreamWrite> sw(fs->open_stream_write(outname)); |
2995 | 128 | if (!save_surface_to_png(surf.get(), sw.get())) { | 128 | if (!save_surface_to_png(surf.get(), sw.get())) { |
2996 | 129 | std::cout << "Could not encode PNG." << std::endl; | 129 | std::cout << "Could not encode PNG." << std::endl; |
2997 | 130 | } | 130 | } |
2998 | 131 | 131 | ||
2999 | === modified file 'src/graphic/texture.cc' | |||
3000 | --- src/graphic/texture.cc 2014-07-17 13:26:23 +0000 | |||
3001 | +++ src/graphic/texture.cc 2014-09-29 14:39:47 +0000 | |||
3002 | @@ -51,7 +51,7 @@ | |||
3003 | 51 | } | 51 | } |
3004 | 52 | 52 | ||
3005 | 53 | for (const std::string& fname : texture_files) { | 53 | for (const std::string& fname : texture_files) { |
3007 | 54 | if (!g_fs->FileExists(fname)) { | 54 | if (!g_fs->file_exists(fname)) { |
3008 | 55 | throw wexception("Could not find %s.", fname.c_str()); | 55 | throw wexception("Could not find %s.", fname.c_str()); |
3009 | 56 | } | 56 | } |
3010 | 57 | 57 | ||
3011 | 58 | 58 | ||
3012 | === modified file 'src/graphic/texture.h' | |||
3013 | --- src/graphic/texture.h 2014-07-12 12:35:05 +0000 | |||
3014 | +++ src/graphic/texture.h 2014-09-29 14:39:47 +0000 | |||
3015 | @@ -59,7 +59,7 @@ | |||
3016 | 59 | RGBColor get_minimap_color(int8_t shade); | 59 | RGBColor get_minimap_color(int8_t shade); |
3017 | 60 | 60 | ||
3018 | 61 | void animate(uint32_t time); | 61 | void animate(uint32_t time); |
3020 | 62 | uint32_t getTexture() const | 62 | uint32_t get_texture() const |
3021 | 63 | {return m_glFrames.at(m_frame_num)->get_gl_texture();} | 63 | {return m_glFrames.at(m_frame_num)->get_gl_texture();} |
3022 | 64 | 64 | ||
3023 | 65 | private: | 65 | private: |
3024 | 66 | 66 | ||
3025 | === modified file 'src/io/dedicated_log.cc' | |||
3026 | --- src/io/dedicated_log.cc 2014-06-08 21:47:45 +0000 | |||
3027 | +++ src/io/dedicated_log.cc 2014-09-29 14:39:47 +0000 | |||
3028 | @@ -97,18 +97,18 @@ | |||
3029 | 97 | temp += c.sender.empty() ? "SYSTEM" : c.sender; | 97 | temp += c.sender.empty() ? "SYSTEM" : c.sender; |
3030 | 98 | temp += "</td><td class=\"recipient\"> ->" + c.recipient + "</td><td class=\"message\">"; | 98 | temp += "</td><td class=\"recipient\"> ->" + c.recipient + "</td><td class=\"message\">"; |
3031 | 99 | temp += c.msg + "</td></tr>\n"; | 99 | temp += c.msg + "</td></tr>\n"; |
3034 | 100 | m_chat.Printf("%s", temp.c_str()); | 100 | m_chat.print_f("%s", temp.c_str()); |
3035 | 101 | m_chat.WriteAppend(*root, m_chat_file_path.c_str()); | 101 | m_chat.write_append(*root, m_chat_file_path.c_str()); |
3036 | 102 | } | 102 | } |
3037 | 103 | 103 | ||
3038 | 104 | /// Add's a spacer to the chat log | 104 | /// Add's a spacer to the chat log |
3040 | 105 | void DedicatedLog::chatAddSpacer() { | 105 | void DedicatedLog::chat_add_spacer() { |
3041 | 106 | if (m_chat_file_path.empty()) | 106 | if (m_chat_file_path.empty()) |
3042 | 107 | return; | 107 | return; |
3043 | 108 | 108 | ||
3047 | 109 | m_chat.Printf("<tr><td class=\"space\"></td><td class=\"space\"></td>"); | 109 | m_chat.print_f("<tr><td class=\"space\"></td><td class=\"space\"></td>"); |
3048 | 110 | m_chat.Printf("<td class=\"space\"></td><td class=\"space\"></td></tr>\n"); | 110 | m_chat.print_f("<td class=\"space\"></td><td class=\"space\"></td></tr>\n"); |
3049 | 111 | m_chat.WriteAppend(*root, m_chat_file_path.c_str()); | 111 | m_chat.write_append(*root, m_chat_file_path.c_str()); |
3050 | 112 | } | 112 | } |
3051 | 113 | 113 | ||
3052 | 114 | 114 | ||
3053 | @@ -206,8 +206,8 @@ | |||
3054 | 206 | } | 206 | } |
3055 | 207 | } | 207 | } |
3056 | 208 | temp += "</table>\n"; | 208 | temp += "</table>\n"; |
3059 | 209 | m_chat.Printf("%s", temp.c_str()); | 209 | m_chat.print_f("%s", temp.c_str()); |
3060 | 210 | m_chat.Write(*root, m_info_file_path.c_str()); | 210 | m_chat.write(*root, m_info_file_path.c_str()); |
3061 | 211 | } | 211 | } |
3062 | 212 | 212 | ||
3063 | 213 | /// Appends the String \arg msg to the log file | 213 | /// Appends the String \arg msg to the log file |
3064 | @@ -224,8 +224,8 @@ | |||
3065 | 224 | temp += "</td><td class=\"log\">"; | 224 | temp += "</td><td class=\"log\">"; |
3066 | 225 | temp += msg; | 225 | temp += msg; |
3067 | 226 | temp += "</td></tr>\n"; | 226 | temp += "</td></tr>\n"; |
3070 | 227 | m_chat.Printf("%s", temp.c_str()); | 227 | m_chat.print_f("%s", temp.c_str()); |
3071 | 228 | m_chat.WriteAppend(*root, m_log_file_path.c_str()); | 228 | m_chat.write_append(*root, m_log_file_path.c_str()); |
3072 | 229 | } | 229 | } |
3073 | 230 | 230 | ||
3074 | 231 | 231 | ||
3075 | @@ -252,8 +252,8 @@ | |||
3076 | 252 | m_chat_file_path = path; | 252 | m_chat_file_path = path; |
3077 | 253 | 253 | ||
3078 | 254 | // Initialize the chat file | 254 | // Initialize the chat file |
3081 | 255 | m_chat.Printf("<tr><th>Time</th><th>Sender</th><th>Recipient</th><th>Message</th></tr>"); | 255 | m_chat.print_f("<tr><th>Time</th><th>Sender</th><th>Recipient</th><th>Message</th></tr>"); |
3082 | 256 | m_chat.Write(*root, m_chat_file_path.c_str()); // Not WriteAppend, to make sure the file is cleared | 256 | m_chat.write(*root, m_chat_file_path.c_str()); // Not write_append, to make sure the file is cleared |
3083 | 257 | return true; | 257 | return true; |
3084 | 258 | } | 258 | } |
3085 | 259 | 259 | ||
3086 | @@ -307,8 +307,8 @@ | |||
3087 | 307 | m_log_file_path = path; | 307 | m_log_file_path = path; |
3088 | 308 | 308 | ||
3089 | 309 | // Initialize the log file | 309 | // Initialize the log file |
3092 | 310 | m_chat.Printf("<tr><th></th><th>Widelands dedicated server log:</th></tr>\n"); | 310 | m_chat.print_f("<tr><th></th><th>Widelands dedicated server log:</th></tr>\n"); |
3093 | 311 | m_chat.Write(*root, m_log_file_path.c_str()); // Not WriteAppend, to make sure the file is cleared | 311 | m_chat.write(*root, m_log_file_path.c_str()); // Not write_append, to make sure the file is cleared |
3094 | 312 | return true; | 312 | return true; |
3095 | 313 | } | 313 | } |
3096 | 314 | 314 | ||
3097 | @@ -323,14 +323,14 @@ | |||
3098 | 323 | * written to does not exist, in all other cases true. | 323 | * written to does not exist, in all other cases true. |
3099 | 324 | */ | 324 | */ |
3100 | 325 | bool DedicatedLog::check_file_writeable(std::string & path) { | 325 | bool DedicatedLog::check_file_writeable(std::string & path) { |
3103 | 326 | bool existing = root->FileExists(path); | 326 | bool existing = root->file_exists(path); |
3104 | 327 | if (existing && root->IsDirectory(path)) | 327 | if (existing && root->is_directory(path)) |
3105 | 328 | return false; | 328 | return false; |
3107 | 329 | if (root->FileIsWriteable(path)) { | 329 | if (root->file_is_writeable(path)) { |
3108 | 330 | if (existing) { | 330 | if (existing) { |
3109 | 331 | std::string rnpath(path + '~'); | 331 | std::string rnpath(path + '~'); |
3112 | 332 | if (root->FileIsWriteable(rnpath)) | 332 | if (root->file_is_writeable(rnpath)) |
3113 | 333 | root->Rename(path, rnpath); | 333 | root->fs_rename(path, rnpath); |
3114 | 334 | else | 334 | else |
3115 | 335 | log("Note: original file %s could not be backuped\n", path.c_str()); | 335 | log("Note: original file %s could not be backuped\n", path.c_str()); |
3116 | 336 | } | 336 | } |
3117 | 337 | 337 | ||
3118 | === modified file 'src/io/dedicated_log.h' | |||
3119 | --- src/io/dedicated_log.h 2014-07-13 18:20:03 +0000 | |||
3120 | +++ src/io/dedicated_log.h 2014-09-29 14:39:47 +0000 | |||
3121 | @@ -33,7 +33,7 @@ | |||
3122 | 33 | static DedicatedLog * get(); | 33 | static DedicatedLog * get(); |
3123 | 34 | 34 | ||
3124 | 35 | // chat logging functions | 35 | // chat logging functions |
3126 | 36 | void chatAddSpacer(); | 36 | void chat_add_spacer(); |
3127 | 37 | void chat(ChatMessage & c); | 37 | void chat(ChatMessage & c); |
3128 | 38 | 38 | ||
3129 | 39 | // info logging functions | 39 | // info logging functions |
3130 | 40 | 40 | ||
3131 | === modified file 'src/io/fileread.cc' | |||
3132 | --- src/io/fileread.cc 2014-09-09 17:15:20 +0000 | |||
3133 | +++ src/io/fileread.cc 2014-09-29 14:39:47 +0000 | |||
3134 | @@ -23,19 +23,19 @@ | |||
3135 | 23 | 23 | ||
3136 | 24 | FileRead::~FileRead() { | 24 | FileRead::~FileRead() { |
3137 | 25 | if (data_) { | 25 | if (data_) { |
3139 | 26 | Close(); | 26 | close(); |
3140 | 27 | } | 27 | } |
3141 | 28 | } | 28 | } |
3142 | 29 | 29 | ||
3144 | 30 | void FileRead::Open(FileSystem& fs, const std::string& filename) { | 30 | void FileRead::open(FileSystem& fs, const std::string& filename) { |
3145 | 31 | assert(!data_); | 31 | assert(!data_); |
3147 | 32 | data_ = static_cast<char*>(fs.Load(filename, length_)); | 32 | data_ = static_cast<char*>(fs.load(filename, length_)); |
3148 | 33 | filepos_ = 0; | 33 | filepos_ = 0; |
3149 | 34 | } | 34 | } |
3150 | 35 | 35 | ||
3152 | 36 | bool FileRead::TryOpen(FileSystem& fs, const std::string& filename) { | 36 | bool FileRead::try_open(FileSystem& fs, const std::string& filename) { |
3153 | 37 | try { | 37 | try { |
3155 | 38 | Open(fs, filename); | 38 | open(fs, filename); |
3156 | 39 | } | 39 | } |
3157 | 40 | catch (const std::exception&) { | 40 | catch (const std::exception&) { |
3158 | 41 | return false; | 41 | return false; |
3159 | @@ -43,32 +43,32 @@ | |||
3160 | 43 | return true; | 43 | return true; |
3161 | 44 | } | 44 | } |
3162 | 45 | 45 | ||
3164 | 46 | void FileRead::Close() { | 46 | void FileRead::close() { |
3165 | 47 | assert(data_); | 47 | assert(data_); |
3166 | 48 | free(data_); | 48 | free(data_); |
3167 | 49 | data_ = nullptr; | 49 | data_ = nullptr; |
3168 | 50 | } | 50 | } |
3169 | 51 | 51 | ||
3171 | 52 | size_t FileRead::GetSize() const { | 52 | size_t FileRead::get_size() const { |
3172 | 53 | return length_; | 53 | return length_; |
3173 | 54 | } | 54 | } |
3174 | 55 | 55 | ||
3176 | 56 | bool FileRead::EndOfFile() const { | 56 | bool FileRead::end_of_file() const { |
3177 | 57 | return length_ <= filepos_; | 57 | return length_ <= filepos_; |
3178 | 58 | } | 58 | } |
3179 | 59 | 59 | ||
3181 | 60 | void FileRead::SetFilePos(Pos const pos) { | 60 | void FileRead::set_file_pos(Pos const pos) { |
3182 | 61 | assert(data_); | 61 | assert(data_); |
3183 | 62 | if (pos >= length_) | 62 | if (pos >= length_) |
3184 | 63 | throw FileBoundaryExceeded(); | 63 | throw FileBoundaryExceeded(); |
3185 | 64 | filepos_ = pos; | 64 | filepos_ = pos; |
3186 | 65 | } | 65 | } |
3187 | 66 | 66 | ||
3189 | 67 | FileRead::Pos FileRead::GetPos() const { | 67 | FileRead::Pos FileRead::get_pos() const { |
3190 | 68 | return filepos_; | 68 | return filepos_; |
3191 | 69 | } | 69 | } |
3192 | 70 | 70 | ||
3194 | 71 | size_t FileRead::Data(void* dst, size_t bufsize) { | 71 | size_t FileRead::data(void* dst, size_t bufsize) { |
3195 | 72 | assert(data_); | 72 | assert(data_); |
3196 | 73 | size_t read = 0; | 73 | size_t read = 0; |
3197 | 74 | for (; read < bufsize && filepos_ < length_; ++read, ++filepos_) { | 74 | for (; read < bufsize && filepos_ < length_; ++read, ++filepos_) { |
3198 | @@ -77,10 +77,10 @@ | |||
3199 | 77 | return read; | 77 | return read; |
3200 | 78 | } | 78 | } |
3201 | 79 | 79 | ||
3203 | 80 | char* FileRead::Data(uint32_t const bytes, const Pos pos) { | 80 | char* FileRead::data(uint32_t const bytes, const Pos pos) { |
3204 | 81 | assert(data_); | 81 | assert(data_); |
3205 | 82 | Pos i = pos; | 82 | Pos i = pos; |
3207 | 83 | if (pos.isNull()) { | 83 | if (pos.is_null()) { |
3208 | 84 | i = filepos_; | 84 | i = filepos_; |
3209 | 85 | filepos_ += bytes; | 85 | filepos_ += bytes; |
3210 | 86 | } | 86 | } |
3211 | @@ -89,10 +89,10 @@ | |||
3212 | 89 | return data_ + i; | 89 | return data_ + i; |
3213 | 90 | } | 90 | } |
3214 | 91 | 91 | ||
3216 | 92 | char* FileRead::CString(Pos const pos) { | 92 | char* FileRead::c_string(Pos const pos) { |
3217 | 93 | assert(data_); | 93 | assert(data_); |
3218 | 94 | 94 | ||
3220 | 95 | Pos i = pos.isNull() ? filepos_ : pos; | 95 | Pos i = pos.is_null() ? filepos_ : pos; |
3221 | 96 | if (i >= length_) | 96 | if (i >= length_) |
3222 | 97 | throw FileBoundaryExceeded(); | 97 | throw FileBoundaryExceeded(); |
3223 | 98 | char* const result = data_ + i; | 98 | char* const result = data_ + i; |
3224 | @@ -101,17 +101,17 @@ | |||
3225 | 101 | ++i; // beyond the null | 101 | ++i; // beyond the null |
3226 | 102 | if (i > (length_ + 1)) // allow EOF as end marker for string | 102 | if (i > (length_ + 1)) // allow EOF as end marker for string |
3227 | 103 | throw FileBoundaryExceeded(); | 103 | throw FileBoundaryExceeded(); |
3229 | 104 | if (pos.isNull()) | 104 | if (pos.is_null()) |
3230 | 105 | filepos_ = i; | 105 | filepos_ = i; |
3231 | 106 | return result; | 106 | return result; |
3232 | 107 | } | 107 | } |
3233 | 108 | 108 | ||
3236 | 109 | char const* FileRead::CString() { | 109 | char const* FileRead::c_string() { |
3237 | 110 | return CString(Pos::Null()); | 110 | return c_string(Pos::null()); |
3238 | 111 | } | 111 | } |
3239 | 112 | 112 | ||
3242 | 113 | char* FileRead::ReadLine() { | 113 | char* FileRead::read_line() { |
3243 | 114 | if (EndOfFile()) | 114 | if (end_of_file()) |
3244 | 115 | return nullptr; | 115 | return nullptr; |
3245 | 116 | char* result = data_ + filepos_; | 116 | char* result = data_ + filepos_; |
3246 | 117 | for (; data_[filepos_] && data_[filepos_] != '\n'; ++filepos_) | 117 | for (; data_[filepos_] && data_[filepos_] != '\n'; ++filepos_) |
3247 | 118 | 118 | ||
3248 | === modified file 'src/io/fileread.h' | |||
3249 | --- src/io/fileread.h 2014-09-09 17:15:20 +0000 | |||
3250 | +++ src/io/fileread.h 2014-09-29 14:39:47 +0000 | |||
3251 | @@ -40,12 +40,12 @@ | |||
3252 | 40 | Pos(size_t const p = 0) : pos(p) { | 40 | Pos(size_t const p = 0) : pos(p) { |
3253 | 41 | } | 41 | } |
3254 | 42 | /// Returns a special value indicating invalidity. | 42 | /// Returns a special value indicating invalidity. |
3256 | 43 | static Pos Null() { | 43 | static Pos null() { |
3257 | 44 | return std::numeric_limits<size_t>::max(); | 44 | return std::numeric_limits<size_t>::max(); |
3258 | 45 | } | 45 | } |
3259 | 46 | 46 | ||
3262 | 47 | bool isNull() const { | 47 | bool is_null() const { |
3263 | 48 | return *this == Null(); | 48 | return *this == null(); |
3264 | 49 | } | 49 | } |
3265 | 50 | operator size_t() const { | 50 | operator size_t() const { |
3266 | 51 | return pos; | 51 | return pos; |
3267 | @@ -72,45 +72,45 @@ | |||
3268 | 72 | ~FileRead() override; | 72 | ~FileRead() override; |
3269 | 73 | 73 | ||
3270 | 74 | // See base class. | 74 | // See base class. |
3274 | 75 | size_t Data(void* dst, size_t bufsize) override; | 75 | size_t data(void* dst, size_t bufsize) override; |
3275 | 76 | bool EndOfFile() const override; | 76 | bool end_of_file() const override; |
3276 | 77 | char const* CString() override; | 77 | char const* c_string() override; |
3277 | 78 | 78 | ||
3278 | 79 | /// Loads a file into memory. Reserves one additional byte which is zeroed, | 79 | /// Loads a file into memory. Reserves one additional byte which is zeroed, |
3279 | 80 | /// so that text files can be handled like a null-terminated string. | 80 | /// so that text files can be handled like a null-terminated string. |
3280 | 81 | /// \throws an exception if the file couldn't be loaded for whatever reason. | 81 | /// \throws an exception if the file couldn't be loaded for whatever reason. |
3281 | 82 | 82 | ||
3282 | 83 | // TODO(unknown): error handling | 83 | // TODO(unknown): error handling |
3284 | 84 | void Open(FileSystem& fs, const std::string& filename); | 84 | void open(FileSystem& fs, const std::string& filename); |
3285 | 85 | 85 | ||
3288 | 86 | /// Works just like Open, but returns false when the load fails. | 86 | /// Works just like open, but returns false when the load fails. |
3289 | 87 | // TODO(sirver): This method can be expressed through Open() and should not | 87 | // TODO(sirver): This method can be expressed through open() and should not |
3290 | 88 | // be part of the public API, rather a stand alone function. | 88 | // be part of the public API, rather a stand alone function. |
3292 | 89 | bool TryOpen(FileSystem& fs, const std::string& filename); | 89 | bool try_open(FileSystem& fs, const std::string& filename); |
3293 | 90 | 90 | ||
3294 | 91 | /// Frees allocated memory. | 91 | /// Frees allocated memory. |
3296 | 92 | void Close(); | 92 | void close(); |
3297 | 93 | 93 | ||
3298 | 94 | // Returns the size of the file in bytes; | 94 | // Returns the size of the file in bytes; |
3300 | 95 | size_t GetSize() const; | 95 | size_t get_size() const; |
3301 | 96 | 96 | ||
3302 | 97 | /// Set the file pointer to the given location. | 97 | /// Set the file pointer to the given location. |
3303 | 98 | /// \throws File_Boundary_Exceeded if the pointer is out of bound. | 98 | /// \throws File_Boundary_Exceeded if the pointer is out of bound. |
3305 | 99 | void SetFilePos(Pos pos); | 99 | void set_file_pos(Pos pos); |
3306 | 100 | 100 | ||
3307 | 101 | /// Get the position that will be read from in the next read operation that | 101 | /// Get the position that will be read from in the next read operation that |
3308 | 102 | /// does not specify a position. | 102 | /// does not specify a position. |
3310 | 103 | Pos GetPos() const; | 103 | Pos get_pos() const; |
3311 | 104 | 104 | ||
3312 | 105 | // Returns the next 'bytes' starting at 'pos' in the file. Can throw | 105 | // Returns the next 'bytes' starting at 'pos' in the file. Can throw |
3313 | 106 | // File_Boundary_Exceeded. | 106 | // File_Boundary_Exceeded. |
3315 | 107 | char* Data(uint32_t bytes, Pos pos = Pos::Null()); | 107 | char* data(uint32_t bytes, Pos pos = Pos::null()); |
3316 | 108 | 108 | ||
3317 | 109 | // Returns the whole file as a string starting from 'pos'. | 109 | // Returns the whole file as a string starting from 'pos'. |
3319 | 110 | char* CString(Pos pos); | 110 | char* c_string(Pos pos); |
3320 | 111 | 111 | ||
3321 | 112 | // Returns the next line. | 112 | // Returns the next line. |
3323 | 113 | char* ReadLine(); | 113 | char* read_line(); |
3324 | 114 | 114 | ||
3325 | 115 | private: | 115 | private: |
3326 | 116 | char* data_; | 116 | char* data_; |
3327 | 117 | 117 | ||
3328 | === modified file 'src/io/filesystem/disk_filesystem.cc' | |||
3329 | --- src/io/filesystem/disk_filesystem.cc 2014-09-14 11:31:58 +0000 | |||
3330 | +++ src/io/filesystem/disk_filesystem.cc 2014-09-29 14:39:47 +0000 | |||
3331 | @@ -71,22 +71,22 @@ | |||
3332 | 71 | : m_directory(Directory) | 71 | : m_directory(Directory) |
3333 | 72 | { | 72 | { |
3334 | 73 | // TODO(unknown): check OS permissions on whether the directory is writable! | 73 | // TODO(unknown): check OS permissions on whether the directory is writable! |
3336 | 74 | m_root = FS_CanonicalizeName(Directory); | 74 | m_root = canonicalize_name(Directory); |
3337 | 75 | } | 75 | } |
3338 | 76 | 76 | ||
3339 | 77 | 77 | ||
3340 | 78 | /** | 78 | /** |
3341 | 79 | * SHOULD return true if this directory is writable. | 79 | * SHOULD return true if this directory is writable. |
3342 | 80 | */ | 80 | */ |
3344 | 81 | bool RealFSImpl::IsWritable() const { | 81 | bool RealFSImpl::is_writable() const { |
3345 | 82 | // Should be checked here (ondisk state can change) | 82 | // Should be checked here (ondisk state can change) |
3346 | 83 | return true; | 83 | return true; |
3347 | 84 | } | 84 | } |
3348 | 85 | 85 | ||
3349 | 86 | /// returns true, if the file is writeable | 86 | /// returns true, if the file is writeable |
3351 | 87 | bool RealFSImpl::FileIsWriteable(const std::string & path) { | 87 | bool RealFSImpl::file_is_writeable(const std::string & path) { |
3352 | 88 | std::string fullname; | 88 | std::string fullname; |
3354 | 89 | fullname = FS_CanonicalizeName(path); | 89 | fullname = canonicalize_name(path); |
3355 | 90 | 90 | ||
3356 | 91 | // we call fopen with "a" == append to be sure nothing gets overwritten | 91 | // we call fopen with "a" == append to be sure nothing gets overwritten |
3357 | 92 | FILE * const f = fopen(fullname.c_str(), "a"); | 92 | FILE * const f = fopen(fullname.c_str(), "a"); |
3358 | @@ -97,7 +97,7 @@ | |||
3359 | 97 | } | 97 | } |
3360 | 98 | 98 | ||
3361 | 99 | 99 | ||
3363 | 100 | std::set<std::string> RealFSImpl::ListDirectory(const std::string & path) | 100 | std::set<std::string> RealFSImpl::list_directory(const std::string & path) |
3364 | 101 | { | 101 | { |
3365 | 102 | #ifdef _WIN32 | 102 | #ifdef _WIN32 |
3366 | 103 | std::string buf; | 103 | std::string buf; |
3367 | @@ -124,7 +124,7 @@ | |||
3368 | 124 | if ((strcmp(c_file.name, ".") == 0) || (strcmp(c_file.name, "..") == 0)) { | 124 | if ((strcmp(c_file.name, ".") == 0) || (strcmp(c_file.name, "..") == 0)) { |
3369 | 125 | continue; | 125 | continue; |
3370 | 126 | } | 126 | } |
3372 | 127 | const std::string filename = FS_CanonicalizeName(realpath + c_file.name); | 127 | const std::string filename = canonicalize_name(realpath + c_file.name); |
3373 | 128 | const std::string result = filename.substr(m_root.size() + 1); | 128 | const std::string result = filename.substr(m_root.size() + 1); |
3374 | 129 | results.insert(result); | 129 | results.insert(result); |
3375 | 130 | } while (_findnext(hFile, &c_file) == 0); | 130 | } while (_findnext(hFile, &c_file) == 0); |
3376 | @@ -138,7 +138,7 @@ | |||
3377 | 138 | int32_t ofs; | 138 | int32_t ofs; |
3378 | 139 | 139 | ||
3379 | 140 | if (path.size()) { | 140 | if (path.size()) { |
3381 | 141 | if (pathIsAbsolute(path)) { | 141 | if (is_path_absolute(path)) { |
3382 | 142 | buf = path + "/*"; | 142 | buf = path + "/*"; |
3383 | 143 | ofs = 0; | 143 | ofs = 0; |
3384 | 144 | } else { | 144 | } else { |
3385 | @@ -155,7 +155,7 @@ | |||
3386 | 155 | return results; | 155 | return results; |
3387 | 156 | 156 | ||
3388 | 157 | for (size_t i = 0; i < gl.gl_pathc; ++i) { | 157 | for (size_t i = 0; i < gl.gl_pathc; ++i) { |
3390 | 158 | const std::string filename(FS_CanonicalizeName(&gl.gl_pathv[i][ofs])); | 158 | const std::string filename(canonicalize_name(&gl.gl_pathv[i][ofs])); |
3391 | 159 | results.insert(filename.substr(m_root.size() + 1)); | 159 | results.insert(filename.substr(m_root.size() + 1)); |
3392 | 160 | } | 160 | } |
3393 | 161 | 161 | ||
3394 | @@ -171,8 +171,8 @@ | |||
3395 | 171 | * \e can't exist then) | 171 | * \e can't exist then) |
3396 | 172 | */ | 172 | */ |
3397 | 173 | // TODO(unknown): Can this be rewritten to just using exceptions? Should it? | 173 | // TODO(unknown): Can this be rewritten to just using exceptions? Should it? |
3400 | 174 | bool RealFSImpl::FileExists(const std::string & path) { | 174 | bool RealFSImpl::file_exists(const std::string & path) { |
3401 | 175 | return FileSystemPath(FS_CanonicalizeName(path)).m_exists; | 175 | return FileSystemPath(canonicalize_name(path)).m_exists; |
3402 | 176 | } | 176 | } |
3403 | 177 | 177 | ||
3404 | 178 | /** | 178 | /** |
3405 | @@ -180,15 +180,15 @@ | |||
3406 | 180 | * Also returns false if the pathname is invalid (obviously, because the file | 180 | * Also returns false if the pathname is invalid (obviously, because the file |
3407 | 181 | * \e can't exist then) | 181 | * \e can't exist then) |
3408 | 182 | */ | 182 | */ |
3411 | 183 | bool RealFSImpl::IsDirectory(const std::string & path) { | 183 | bool RealFSImpl::is_directory(const std::string & path) { |
3412 | 184 | return FileSystemPath(FS_CanonicalizeName(path)).m_isDirectory; | 184 | return FileSystemPath(canonicalize_name(path)).m_isDirectory; |
3413 | 185 | } | 185 | } |
3414 | 186 | 186 | ||
3415 | 187 | /** | 187 | /** |
3416 | 188 | * Create a sub filesystem out of this filesystem | 188 | * Create a sub filesystem out of this filesystem |
3417 | 189 | */ | 189 | */ |
3420 | 190 | FileSystem * RealFSImpl::MakeSubFileSystem(const std::string & path) { | 190 | FileSystem * RealFSImpl::make_sub_file_system(const std::string & path) { |
3421 | 191 | FileSystemPath fspath(FS_CanonicalizeName(path)); | 191 | FileSystemPath fspath(canonicalize_name(path)); |
3422 | 192 | assert(fspath.m_exists); //TODO(unknown): throw an exception instead | 192 | assert(fspath.m_exists); //TODO(unknown): throw an exception instead |
3423 | 193 | 193 | ||
3424 | 194 | if (fspath.m_isDirectory) | 194 | if (fspath.m_isDirectory) |
3425 | @@ -200,16 +200,16 @@ | |||
3426 | 200 | /** | 200 | /** |
3427 | 201 | * Create a sub filesystem out of this filesystem | 201 | * Create a sub filesystem out of this filesystem |
3428 | 202 | */ | 202 | */ |
3430 | 203 | FileSystem * RealFSImpl::CreateSubFileSystem(const std::string & path, Type const fs) | 203 | FileSystem * RealFSImpl::create_sub_file_system(const std::string & path, Type const fs) |
3431 | 204 | { | 204 | { |
3433 | 205 | FileSystemPath fspath(FS_CanonicalizeName(path)); | 205 | FileSystemPath fspath(canonicalize_name(path)); |
3434 | 206 | if (fspath.m_exists) | 206 | if (fspath.m_exists) |
3435 | 207 | throw wexception | 207 | throw wexception |
3436 | 208 | ("path %s already exists, can not create a filesystem from it", | 208 | ("path %s already exists, can not create a filesystem from it", |
3437 | 209 | path.c_str()); | 209 | path.c_str()); |
3438 | 210 | 210 | ||
3439 | 211 | if (fs == FileSystem::DIR) { | 211 | if (fs == FileSystem::DIR) { |
3441 | 212 | EnsureDirectoryExists(path); | 212 | ensure_directory_exists(path); |
3442 | 213 | return new RealFSImpl(fspath); | 213 | return new RealFSImpl(fspath); |
3443 | 214 | } else | 214 | } else |
3444 | 215 | return new ZipFilesystem(fspath); | 215 | return new ZipFilesystem(fspath); |
3445 | @@ -218,8 +218,8 @@ | |||
3446 | 218 | /** | 218 | /** |
3447 | 219 | * Remove a number of files | 219 | * Remove a number of files |
3448 | 220 | */ | 220 | */ |
3451 | 221 | void RealFSImpl::Unlink(const std::string & file) { | 221 | void RealFSImpl::fs_unlink(const std::string & file) { |
3452 | 222 | FileSystemPath fspath(FS_CanonicalizeName(file)); | 222 | FileSystemPath fspath(canonicalize_name(file)); |
3453 | 223 | if (!fspath.m_exists) | 223 | if (!fspath.m_exists) |
3454 | 224 | return; | 224 | return; |
3455 | 225 | 225 | ||
3456 | @@ -233,14 +233,14 @@ | |||
3457 | 233 | * Remove a single directory or file | 233 | * Remove a single directory or file |
3458 | 234 | */ | 234 | */ |
3459 | 235 | void RealFSImpl::m_unlink_file(const std::string & file) { | 235 | void RealFSImpl::m_unlink_file(const std::string & file) { |
3461 | 236 | FileSystemPath fspath(FS_CanonicalizeName(file)); | 236 | FileSystemPath fspath(canonicalize_name(file)); |
3462 | 237 | assert(fspath.m_exists); //TODO(unknown): throw an exception instead | 237 | assert(fspath.m_exists); //TODO(unknown): throw an exception instead |
3463 | 238 | assert(!fspath.m_isDirectory); //TODO(unknown): throw an exception instead | 238 | assert(!fspath.m_isDirectory); //TODO(unknown): throw an exception instead |
3464 | 239 | 239 | ||
3465 | 240 | #ifndef _WIN32 | 240 | #ifndef _WIN32 |
3466 | 241 | unlink(fspath.c_str()); | 241 | unlink(fspath.c_str()); |
3467 | 242 | #else | 242 | #else |
3469 | 243 | DeleteFile(fspath.c_str()); | 243 | delete_file(fspath.c_str()); |
3470 | 244 | #endif | 244 | #endif |
3471 | 245 | } | 245 | } |
3472 | 246 | 246 | ||
3473 | @@ -248,23 +248,23 @@ | |||
3474 | 248 | * Recursively remove a directory | 248 | * Recursively remove a directory |
3475 | 249 | */ | 249 | */ |
3476 | 250 | void RealFSImpl::m_unlink_directory(const std::string & file) { | 250 | void RealFSImpl::m_unlink_directory(const std::string & file) { |
3478 | 251 | FileSystemPath fspath(FS_CanonicalizeName(file)); | 251 | FileSystemPath fspath(canonicalize_name(file)); |
3479 | 252 | assert(fspath.m_exists); //TODO(unknown): throw an exception instead | 252 | assert(fspath.m_exists); //TODO(unknown): throw an exception instead |
3480 | 253 | assert(fspath.m_isDirectory); //TODO(unknown): throw an exception instead | 253 | assert(fspath.m_isDirectory); //TODO(unknown): throw an exception instead |
3481 | 254 | 254 | ||
3483 | 255 | FilenameSet files = ListDirectory(file); | 255 | FilenameSet files = list_directory(file); |
3484 | 256 | for | 256 | for |
3485 | 257 | (FilenameSet::iterator pname = files.begin(); | 257 | (FilenameSet::iterator pname = files.begin(); |
3486 | 258 | pname != files.end(); | 258 | pname != files.end(); |
3487 | 259 | ++pname) | 259 | ++pname) |
3488 | 260 | { | 260 | { |
3490 | 261 | std::string filename = FS_Filename(pname->c_str()); | 261 | std::string filename = fs_filename(pname->c_str()); |
3491 | 262 | if (filename == "..") | 262 | if (filename == "..") |
3492 | 263 | continue; | 263 | continue; |
3493 | 264 | if (filename == ".") | 264 | if (filename == ".") |
3494 | 265 | continue; | 265 | continue; |
3495 | 266 | 266 | ||
3497 | 267 | if (IsDirectory(*pname)) | 267 | if (is_directory(*pname)) |
3498 | 268 | m_unlink_directory(*pname); | 268 | m_unlink_directory(*pname); |
3499 | 269 | else | 269 | else |
3500 | 270 | m_unlink_file(*pname); | 270 | m_unlink_file(*pname); |
3501 | @@ -275,7 +275,7 @@ | |||
3502 | 275 | #ifndef _WIN32 | 275 | #ifndef _WIN32 |
3503 | 276 | rmdir(fspath.c_str()); | 276 | rmdir(fspath.c_str()); |
3504 | 277 | #else | 277 | #else |
3506 | 278 | RemoveDirectory(fspath.c_str()); | 278 | remove_directory(fspath.c_str()); |
3507 | 279 | #endif | 279 | #endif |
3508 | 280 | } | 280 | } |
3509 | 281 | 281 | ||
3510 | @@ -283,20 +283,20 @@ | |||
3511 | 283 | * Create this directory if it doesn't exist, throws an error | 283 | * Create this directory if it doesn't exist, throws an error |
3512 | 284 | * if the dir can't be created or if a file with this name exists | 284 | * if the dir can't be created or if a file with this name exists |
3513 | 285 | */ | 285 | */ |
3515 | 286 | void RealFSImpl::EnsureDirectoryExists(const std::string & dirname) | 286 | void RealFSImpl::ensure_directory_exists(const std::string & dirname) |
3516 | 287 | { | 287 | { |
3517 | 288 | try { | 288 | try { |
3518 | 289 | std::string::size_type it = 0; | 289 | std::string::size_type it = 0; |
3519 | 290 | while (it < dirname.size()) { | 290 | while (it < dirname.size()) { |
3520 | 291 | it = dirname.find(m_filesep, it); | 291 | it = dirname.find(m_filesep, it); |
3521 | 292 | 292 | ||
3523 | 293 | FileSystemPath fspath(FS_CanonicalizeName(dirname.substr(0, it))); | 293 | FileSystemPath fspath(canonicalize_name(dirname.substr(0, it))); |
3524 | 294 | if (fspath.m_exists && !fspath.m_isDirectory) | 294 | if (fspath.m_exists && !fspath.m_isDirectory) |
3525 | 295 | throw wexception | 295 | throw wexception |
3526 | 296 | ("%s exists and is not a directory", | 296 | ("%s exists and is not a directory", |
3527 | 297 | dirname.substr(0, it).c_str()); | 297 | dirname.substr(0, it).c_str()); |
3528 | 298 | if (!fspath.m_exists) | 298 | if (!fspath.m_exists) |
3530 | 299 | MakeDirectory(dirname.substr(0, it)); | 299 | make_directory(dirname.substr(0, it)); |
3531 | 300 | 300 | ||
3532 | 301 | if (it == std::string::npos) | 301 | if (it == std::string::npos) |
3533 | 302 | break; | 302 | break; |
3534 | @@ -304,7 +304,7 @@ | |||
3535 | 304 | } | 304 | } |
3536 | 305 | } catch (const std::exception & e) { | 305 | } catch (const std::exception & e) { |
3537 | 306 | throw wexception | 306 | throw wexception |
3539 | 307 | ("RealFSImpl::EnsureDirectoryExists(%s): %s", | 307 | ("RealFSImpl::ensure_directory_exists(%s): %s", |
3540 | 308 | dirname.c_str(), e.what()); | 308 | dirname.c_str(), e.what()); |
3541 | 309 | } | 309 | } |
3542 | 310 | } | 310 | } |
3543 | @@ -314,11 +314,11 @@ | |||
3544 | 314 | * if a file is in the way or if the creation fails. | 314 | * if a file is in the way or if the creation fails. |
3545 | 315 | * | 315 | * |
3546 | 316 | * Pleas note, this function does not honor parents, | 316 | * Pleas note, this function does not honor parents, |
3548 | 317 | * MakeDirectory("onedir/otherdir/onemoredir") will fail | 317 | * make_directory("onedir/otherdir/onemoredir") will fail |
3549 | 318 | * if either onedir or otherdir is missing | 318 | * if either onedir or otherdir is missing |
3550 | 319 | */ | 319 | */ |
3553 | 320 | void RealFSImpl::MakeDirectory(const std::string & dirname) { | 320 | void RealFSImpl::make_directory(const std::string & dirname) { |
3554 | 321 | FileSystemPath fspath(FS_CanonicalizeName(dirname)); | 321 | FileSystemPath fspath(canonicalize_name(dirname)); |
3555 | 322 | if (fspath.m_exists) | 322 | if (fspath.m_exists) |
3556 | 323 | throw wexception | 323 | throw wexception |
3557 | 324 | ("a file with the name \"%s\" already exists", dirname.c_str()); | 324 | ("a file with the name \"%s\" already exists", dirname.c_str()); |
3558 | @@ -333,19 +333,19 @@ | |||
3559 | 333 | == | 333 | == |
3560 | 334 | -1) | 334 | -1) |
3561 | 335 | throw DirectoryCannotCreateError | 335 | throw DirectoryCannotCreateError |
3563 | 336 | ("RealFSImpl::MakeDirectory", | 336 | ("RealFSImpl::make_directory", |
3564 | 337 | dirname, | 337 | dirname, |
3565 | 338 | strerror(errno)); | 338 | strerror(errno)); |
3566 | 339 | } | 339 | } |
3567 | 340 | 340 | ||
3568 | 341 | /** | 341 | /** |
3570 | 342 | * Read the given file into alloced memory; called by FileRead::Open. | 342 | * Read the given file into alloced memory; called by FileRead::open. |
3571 | 343 | * Throws an exception if the file couldn't be opened. | 343 | * Throws an exception if the file couldn't be opened. |
3572 | 344 | */ | 344 | */ |
3577 | 345 | void * RealFSImpl::Load(const std::string & fname, size_t & length) { | 345 | void * RealFSImpl::load(const std::string & fname, size_t & length) { |
3578 | 346 | const std::string fullname = FS_CanonicalizeName(fname); | 346 | const std::string fullname = canonicalize_name(fname); |
3579 | 347 | if (IsDirectory(fullname)) { | 347 | if (is_directory(fullname)) { |
3580 | 348 | throw FileError("RealFSImpl::Load", fullname.c_str()); | 348 | throw FileError("RealFSImpl::load", fullname.c_str()); |
3581 | 349 | } | 349 | } |
3582 | 350 | 350 | ||
3583 | 351 | FILE * file = nullptr; | 351 | FILE * file = nullptr; |
3584 | @@ -354,7 +354,7 @@ | |||
3585 | 354 | try { | 354 | try { |
3586 | 355 | file = fopen(fullname.c_str(), "rb"); | 355 | file = fopen(fullname.c_str(), "rb"); |
3587 | 356 | if (!file) | 356 | if (!file) |
3589 | 357 | throw FileError("RealFSImpl::Load", fullname.c_str()); | 357 | throw FileError("RealFSImpl::load", fullname.c_str()); |
3590 | 358 | 358 | ||
3591 | 359 | // determine the size of the file (rather quirky, but it doesn't require | 359 | // determine the size of the file (rather quirky, but it doesn't require |
3592 | 360 | // potentially unportable functions) | 360 | // potentially unportable functions) |
3593 | @@ -364,7 +364,7 @@ | |||
3594 | 364 | const int32_t ftell_pos = ftell(file); | 364 | const int32_t ftell_pos = ftell(file); |
3595 | 365 | if (ftell_pos < 0) | 365 | if (ftell_pos < 0) |
3596 | 366 | throw wexception | 366 | throw wexception |
3598 | 367 | ("RealFSImpl::Load: error when loading \"%s\" (\"%s\"): file " | 367 | ("RealFSImpl::load: error when loading \"%s\" (\"%s\"): file " |
3599 | 368 | "size calculation yielded negative value %i", | 368 | "size calculation yielded negative value %i", |
3600 | 369 | fname.c_str(), fullname.c_str(), ftell_pos); | 369 | fname.c_str(), fullname.c_str(), ftell_pos); |
3601 | 370 | size = ftell_pos; | 370 | size = ftell_pos; |
3602 | @@ -376,7 +376,7 @@ | |||
3603 | 376 | int result = fread(data, size, 1, file); | 376 | int result = fread(data, size, 1, file); |
3604 | 377 | if (size && (result != 1)) { | 377 | if (size && (result != 1)) { |
3605 | 378 | throw wexception | 378 | throw wexception |
3607 | 379 | ("RealFSImpl::Load: read failed for %s (%s) with size %" PRIuS "", | 379 | ("RealFSImpl::load: read failed for %s (%s) with size %" PRIuS "", |
3608 | 380 | fname.c_str(), fullname.c_str(), size); | 380 | fname.c_str(), fullname.c_str(), size); |
3609 | 381 | } | 381 | } |
3610 | 382 | static_cast<int8_t *>(data)[size] = 0; | 382 | static_cast<int8_t *>(data)[size] = 0; |
3611 | @@ -402,11 +402,11 @@ | |||
3612 | 402 | * that file. | 402 | * that file. |
3613 | 403 | * Throws an exception if it fails. | 403 | * Throws an exception if it fails. |
3614 | 404 | */ | 404 | */ |
3616 | 405 | void RealFSImpl::Write(const std::string & fname, void const * const data, int32_t const length, bool append) | 405 | void RealFSImpl::write(const std::string & fname, void const * const data, int32_t const length, bool append) |
3617 | 406 | { | 406 | { |
3618 | 407 | std::string fullname; | 407 | std::string fullname; |
3619 | 408 | 408 | ||
3621 | 409 | fullname = FS_CanonicalizeName(fname); | 409 | fullname = canonicalize_name(fname); |
3622 | 410 | 410 | ||
3623 | 411 | FILE * const f = fopen(fullname.c_str(), append ? "a" : "wb"); | 411 | FILE * const f = fopen(fullname.c_str(), append ? "a" : "wb"); |
3624 | 412 | if (!f) | 412 | if (!f) |
3625 | @@ -422,11 +422,11 @@ | |||
3626 | 422 | } | 422 | } |
3627 | 423 | 423 | ||
3628 | 424 | // rename a file or directory | 424 | // rename a file or directory |
3630 | 425 | void RealFSImpl::Rename | 425 | void RealFSImpl::fs_rename |
3631 | 426 | (const std::string & old_name, const std::string & new_name) | 426 | (const std::string & old_name, const std::string & new_name) |
3632 | 427 | { | 427 | { |
3635 | 428 | const std::string fullname1 = FS_CanonicalizeName(old_name); | 428 | const std::string fullname1 = canonicalize_name(old_name); |
3636 | 429 | const std::string fullname2 = FS_CanonicalizeName(new_name); | 429 | const std::string fullname2 = canonicalize_name(new_name); |
3637 | 430 | rename(fullname1.c_str(), fullname2.c_str()); | 430 | rename(fullname1.c_str(), fullname2.c_str()); |
3638 | 431 | } | 431 | } |
3639 | 432 | 432 | ||
3640 | @@ -452,11 +452,11 @@ | |||
3641 | 452 | fclose(m_file); | 452 | fclose(m_file); |
3642 | 453 | } | 453 | } |
3643 | 454 | 454 | ||
3646 | 455 | size_t Data(void * data, size_t const bufsize) override { | 455 | size_t data(void * read_data, size_t const bufsize) override { |
3647 | 456 | return fread(data, 1, bufsize, m_file); | 456 | return fread(read_data, 1, bufsize, m_file); |
3648 | 457 | } | 457 | } |
3649 | 458 | 458 | ||
3651 | 459 | bool EndOfFile() const override | 459 | bool end_of_file() const override |
3652 | 460 | { | 460 | { |
3653 | 461 | return feof(m_file); | 461 | return feof(m_file); |
3654 | 462 | } | 462 | } |
3655 | @@ -467,8 +467,8 @@ | |||
3656 | 467 | 467 | ||
3657 | 468 | } | 468 | } |
3658 | 469 | 469 | ||
3661 | 470 | StreamRead * RealFSImpl::OpenStreamRead(const std::string & fname) { | 470 | StreamRead * RealFSImpl::open_stream_read(const std::string & fname) { |
3662 | 471 | const std::string fullname = FS_CanonicalizeName(fname); | 471 | const std::string fullname = canonicalize_name(fname); |
3663 | 472 | 472 | ||
3664 | 473 | return new RealFSStreamRead(fullname); | 473 | return new RealFSStreamRead(fullname); |
3665 | 474 | } | 474 | } |
3666 | @@ -493,15 +493,15 @@ | |||
3667 | 493 | 493 | ||
3668 | 494 | ~RealFSStreamWrite() {fclose(m_file);} | 494 | ~RealFSStreamWrite() {fclose(m_file);} |
3669 | 495 | 495 | ||
3671 | 496 | void Data(const void * const data, const size_t size) override | 496 | void data(const void * const write_data, const size_t size) override |
3672 | 497 | { | 497 | { |
3674 | 498 | size_t ret = fwrite(data, 1, size, m_file); | 498 | size_t ret = fwrite(write_data, 1, size, m_file); |
3675 | 499 | 499 | ||
3676 | 500 | if (ret != size) | 500 | if (ret != size) |
3677 | 501 | throw wexception("Write to %s failed", m_filename.c_str()); | 501 | throw wexception("Write to %s failed", m_filename.c_str()); |
3678 | 502 | } | 502 | } |
3679 | 503 | 503 | ||
3681 | 504 | void Flush() override | 504 | void flush() override |
3682 | 505 | { | 505 | { |
3683 | 506 | fflush(m_file); | 506 | fflush(m_file); |
3684 | 507 | } | 507 | } |
3685 | @@ -513,25 +513,25 @@ | |||
3686 | 513 | 513 | ||
3687 | 514 | } | 514 | } |
3688 | 515 | 515 | ||
3691 | 516 | StreamWrite * RealFSImpl::OpenStreamWrite(const std::string & fname) { | 516 | StreamWrite * RealFSImpl::open_stream_write(const std::string & fname) { |
3692 | 517 | const std::string fullname = FS_CanonicalizeName(fname); | 517 | const std::string fullname = canonicalize_name(fname); |
3693 | 518 | 518 | ||
3694 | 519 | return new RealFSStreamWrite(fullname); | 519 | return new RealFSStreamWrite(fullname); |
3695 | 520 | } | 520 | } |
3696 | 521 | 521 | ||
3698 | 522 | unsigned long long RealFSImpl::DiskSpace() { | 522 | unsigned long long RealFSImpl::disk_space() { |
3699 | 523 | #ifdef _WIN32 | 523 | #ifdef _WIN32 |
3700 | 524 | ULARGE_INTEGER freeavailable; | 524 | ULARGE_INTEGER freeavailable; |
3701 | 525 | return | 525 | return |
3702 | 526 | GetDiskFreeSpaceEx | 526 | GetDiskFreeSpaceEx |
3704 | 527 | (FS_CanonicalizeName(m_directory).c_str(), &freeavailable, 0, 0) | 527 | (canonicalize_name(m_directory).c_str(), &freeavailable, 0, 0) |
3705 | 528 | ? | 528 | ? |
3706 | 529 | //if more than 2G free space report that much | 529 | //if more than 2G free space report that much |
3707 | 530 | freeavailable.HighPart ? std::numeric_limits<unsigned long>::max() : | 530 | freeavailable.HighPart ? std::numeric_limits<unsigned long>::max() : |
3708 | 531 | freeavailable.LowPart : 0; | 531 | freeavailable.LowPart : 0; |
3709 | 532 | #else | 532 | #else |
3710 | 533 | struct statvfs svfs; | 533 | struct statvfs svfs; |
3712 | 534 | if (statvfs(FS_CanonicalizeName(m_directory).c_str(), &svfs) != -1) { | 534 | if (statvfs(canonicalize_name(m_directory).c_str(), &svfs) != -1) { |
3713 | 535 | return static_cast<unsigned long long>(svfs.f_bsize) * svfs.f_bavail; | 535 | return static_cast<unsigned long long>(svfs.f_bsize) * svfs.f_bavail; |
3714 | 536 | } | 536 | } |
3715 | 537 | #endif | 537 | #endif |
3716 | 538 | 538 | ||
3717 | === modified file 'src/io/filesystem/disk_filesystem.h' | |||
3718 | --- src/io/filesystem/disk_filesystem.h 2014-07-26 10:43:23 +0000 | |||
3719 | +++ src/io/filesystem/disk_filesystem.h 2014-09-29 14:39:47 +0000 | |||
3720 | @@ -30,32 +30,32 @@ | |||
3721 | 30 | public: | 30 | public: |
3722 | 31 | RealFSImpl(const std::string & Directory); | 31 | RealFSImpl(const std::string & Directory); |
3723 | 32 | 32 | ||
3750 | 33 | std::set<std::string> ListDirectory(const std::string& path) override; | 33 | std::set<std::string> list_directory(const std::string& path) override; |
3751 | 34 | 34 | ||
3752 | 35 | bool IsWritable() const override; | 35 | bool is_writable() const override; |
3753 | 36 | bool FileIsWriteable(const std::string & path); | 36 | bool file_is_writeable(const std::string & path); |
3754 | 37 | bool FileExists (const std::string & path) override; | 37 | bool file_exists (const std::string & path) override; |
3755 | 38 | bool IsDirectory(const std::string & path) override; | 38 | bool is_directory(const std::string & path) override; |
3756 | 39 | void EnsureDirectoryExists(const std::string & dirname) override; | 39 | void ensure_directory_exists(const std::string & fs_dirname) override; |
3757 | 40 | void MakeDirectory (const std::string & dirname) override; | 40 | void make_directory (const std::string & fs_dirname) override; |
3758 | 41 | 41 | ||
3759 | 42 | void * Load(const std::string & fname, size_t & length) override; | 42 | void * load(const std::string & fname, size_t & length) override; |
3760 | 43 | 43 | ||
3761 | 44 | 44 | ||
3762 | 45 | void Write(const std::string & fname, void const * data, int32_t length, bool append); | 45 | void write(const std::string & fname, void const * data, int32_t length, bool append); |
3763 | 46 | void Write(const std::string & fname, void const * data, int32_t length) override | 46 | void write(const std::string & fname, void const * data, int32_t length) override |
3764 | 47 | {Write(fname, data, length, false);} | 47 | {write(fname, data, length, false);} |
3765 | 48 | 48 | ||
3766 | 49 | StreamRead * OpenStreamRead (const std::string & fname) override; | 49 | StreamRead * open_stream_read (const std::string & fname) override; |
3767 | 50 | StreamWrite * OpenStreamWrite(const std::string & fname) override; | 50 | StreamWrite * open_stream_write(const std::string & fname) override; |
3768 | 51 | 51 | ||
3769 | 52 | FileSystem * MakeSubFileSystem(const std::string & dirname) override; | 52 | FileSystem * make_sub_file_system(const std::string & fs_dirname) override; |
3770 | 53 | FileSystem * CreateSubFileSystem(const std::string & dirname, Type) override; | 53 | FileSystem * create_sub_file_system(const std::string & fs_dirname, Type) override; |
3771 | 54 | void Unlink(const std::string & file) override; | 54 | void fs_unlink(const std::string & file) override; |
3772 | 55 | void Rename(const std::string & old_name, const std::string & new_name) override; | 55 | void fs_rename(const std::string & old_name, const std::string & new_name) override; |
3773 | 56 | 56 | ||
3774 | 57 | std::string getBasename() override {return m_directory;} | 57 | std::string get_basename() override {return m_directory;} |
3775 | 58 | unsigned long long DiskSpace() override; | 58 | unsigned long long disk_space() override; |
3776 | 59 | 59 | ||
3777 | 60 | private: | 60 | private: |
3778 | 61 | void m_unlink_directory(const std::string & file); | 61 | void m_unlink_directory(const std::string & file); |
3779 | 62 | 62 | ||
3780 | === modified file 'src/io/filesystem/filesystem.cc' | |||
3781 | --- src/io/filesystem/filesystem.cc 2014-09-10 13:03:40 +0000 | |||
3782 | +++ src/io/filesystem/filesystem.cc 2014-09-29 14:39:47 +0000 | |||
3783 | @@ -75,7 +75,7 @@ | |||
3784 | 75 | * \param path A file or directory name | 75 | * \param path A file or directory name |
3785 | 76 | * \return True if ref path is absolute and within this FileSystem, false otherwise | 76 | * \return True if ref path is absolute and within this FileSystem, false otherwise |
3786 | 77 | */ | 77 | */ |
3788 | 78 | bool FileSystem::pathIsAbsolute(const std::string & path) const { | 78 | bool FileSystem::is_path_absolute(const std::string & path) const { |
3789 | 79 | std::string::size_type const path_size = path .size(); | 79 | std::string::size_type const path_size = path .size(); |
3790 | 80 | std::string::size_type const root_size = m_root.size(); | 80 | std::string::size_type const root_size = m_root.size(); |
3791 | 81 | 81 | ||
3792 | @@ -107,7 +107,7 @@ | |||
3793 | 107 | * This function is used to make sure that paths send via network are usable | 107 | * This function is used to make sure that paths send via network are usable |
3794 | 108 | * on locale OS. | 108 | * on locale OS. |
3795 | 109 | */ | 109 | */ |
3797 | 110 | std::string FileSystem::fixCrossFile(const std::string & path) const { | 110 | std::string FileSystem::fix_cross_file(const std::string & path) const { |
3798 | 111 | uint32_t path_size = path.size(); | 111 | uint32_t path_size = path.size(); |
3799 | 112 | std::string fixedPath(path); | 112 | std::string fixedPath(path); |
3800 | 113 | std::string temp; | 113 | std::string temp; |
3801 | @@ -141,18 +141,18 @@ | |||
3802 | 141 | /** | 141 | /** |
3803 | 142 | * \return The process' current working directory | 142 | * \return The process' current working directory |
3804 | 143 | */ | 143 | */ |
3806 | 144 | std::string FileSystem::getWorkingDirectory() const { | 144 | std::string FileSystem::get_working_directory() const { |
3807 | 145 | char cwd[PATH_MAX + 1]; | 145 | char cwd[PATH_MAX + 1]; |
3808 | 146 | char * const result = getcwd(cwd, PATH_MAX); | 146 | char * const result = getcwd(cwd, PATH_MAX); |
3809 | 147 | if (! result) | 147 | if (! result) |
3811 | 148 | throw FileError("FileSystem::getWorkingDirectory()", "widelands", "can not run getcwd"); | 148 | throw FileError("FileSystem::get_working_directory()", "widelands", "can not run getcwd"); |
3812 | 149 | 149 | ||
3813 | 150 | return std::string(cwd); | 150 | return std::string(cwd); |
3814 | 151 | } | 151 | } |
3815 | 152 | 152 | ||
3816 | 153 | 153 | ||
3817 | 154 | // TODO(unknown): Write homedir detection for non-getenv-systems | 154 | // TODO(unknown): Write homedir detection for non-getenv-systems |
3819 | 155 | std::string FileSystem::GetHomedir() | 155 | std::string FileSystem::get_homedir() |
3820 | 156 | { | 156 | { |
3821 | 157 | std::string homedir; | 157 | std::string homedir; |
3822 | 158 | #ifdef _WIN32 | 158 | #ifdef _WIN32 |
3823 | @@ -199,7 +199,7 @@ | |||
3824 | 199 | * \param components The output iterator to place the path nodes into | 199 | * \param components The output iterator to place the path nodes into |
3825 | 200 | */ | 200 | */ |
3826 | 201 | template<typename Inserter> | 201 | template<typename Inserter> |
3828 | 202 | static void FS_Tokenize | 202 | static void fs_tokenize |
3829 | 203 | (const std::string & path, char const filesep, Inserter components) | 203 | (const std::string & path, char const filesep, Inserter components) |
3830 | 204 | { | 204 | { |
3831 | 205 | std::string::size_type pos; // start of token | 205 | std::string::size_type pos; // start of token |
3832 | @@ -234,7 +234,7 @@ | |||
3833 | 234 | * Transform any valid, unique pathname into a well-formed absolute path | 234 | * Transform any valid, unique pathname into a well-formed absolute path |
3834 | 235 | */ | 235 | */ |
3835 | 236 | // TODO(unknown): Enable non-Unix paths | 236 | // TODO(unknown): Enable non-Unix paths |
3837 | 237 | std::string FileSystem::FS_CanonicalizeName(std::string path) const { | 237 | std::string FileSystem::canonicalize_name(std::string path) const { |
3838 | 238 | std::list<std::string> components; | 238 | std::list<std::string> components; |
3839 | 239 | std::list<std::string>::iterator i; | 239 | std::list<std::string>::iterator i; |
3840 | 240 | 240 | ||
3841 | @@ -246,19 +246,19 @@ | |||
3842 | 246 | } | 246 | } |
3843 | 247 | #endif | 247 | #endif |
3844 | 248 | 248 | ||
3846 | 249 | FS_Tokenize(path, m_filesep, std::inserter(components, components.begin())); | 249 | fs_tokenize(path, m_filesep, std::inserter(components, components.begin())); |
3847 | 250 | 250 | ||
3848 | 251 | //tilde expansion | 251 | //tilde expansion |
3849 | 252 | if (!components.empty() && *components.begin() == "~") { | 252 | if (!components.empty() && *components.begin() == "~") { |
3850 | 253 | components.erase(components.begin()); | 253 | components.erase(components.begin()); |
3853 | 254 | FS_Tokenize | 254 | fs_tokenize |
3854 | 255 | (GetHomedir(), | 255 | (get_homedir(), |
3855 | 256 | m_filesep, | 256 | m_filesep, |
3856 | 257 | std::inserter(components, components.begin())); | 257 | std::inserter(components, components.begin())); |
3858 | 258 | } else if (!pathIsAbsolute(path)) | 258 | } else if (!is_path_absolute(path)) |
3859 | 259 | // make relative paths absolute (so that "../../foo" can work) | 259 | // make relative paths absolute (so that "../../foo" can work) |
3862 | 260 | FS_Tokenize | 260 | fs_tokenize |
3863 | 261 | (m_root.empty() ? getWorkingDirectory() : m_root, m_filesep, | 261 | (m_root.empty() ? get_working_directory() : m_root, m_filesep, |
3864 | 262 | std::inserter(components, components.begin())); | 262 | std::inserter(components, components.begin())); |
3865 | 263 | 263 | ||
3866 | 264 | //clean up the path | 264 | //clean up the path |
3867 | @@ -316,7 +316,7 @@ | |||
3868 | 316 | * Returns the filename of this path, everything after the last | 316 | * Returns the filename of this path, everything after the last |
3869 | 317 | * / or \ (or the whole string) | 317 | * / or \ (or the whole string) |
3870 | 318 | */ | 318 | */ |
3872 | 319 | const char * FileSystem::FS_Filename(const char * p) { | 319 | const char * FileSystem::fs_filename(const char * p) { |
3873 | 320 | const char * result = p; | 320 | const char * result = p; |
3874 | 321 | 321 | ||
3875 | 322 | while (*p != '\0') { | 322 | while (*p != '\0') { |
3876 | @@ -328,12 +328,12 @@ | |||
3877 | 328 | return result; | 328 | return result; |
3878 | 329 | } | 329 | } |
3879 | 330 | 330 | ||
3882 | 331 | std::string FileSystem::FS_Dirname(const std::string& full_path) { | 331 | std::string FileSystem::fs_dirname(const std::string& full_path) { |
3883 | 332 | const std::string filename = FS_Filename(full_path.c_str()); | 332 | const std::string filename = fs_filename(full_path.c_str()); |
3884 | 333 | return full_path.substr(0, full_path.size() - filename.size()); | 333 | return full_path.substr(0, full_path.size() - filename.size()); |
3885 | 334 | } | 334 | } |
3886 | 335 | 335 | ||
3888 | 336 | std::string FileSystem::FS_FilenameExt(const std::string & f) | 336 | std::string FileSystem::filename_ext(const std::string & f) |
3889 | 337 | { | 337 | { |
3890 | 338 | // Find last '.' - denotes start of extension | 338 | // Find last '.' - denotes start of extension |
3891 | 339 | size_t ext_start = f.rfind('.'); | 339 | size_t ext_start = f.rfind('.'); |
3892 | @@ -344,10 +344,10 @@ | |||
3893 | 344 | return f.substr(ext_start); | 344 | return f.substr(ext_start); |
3894 | 345 | } | 345 | } |
3895 | 346 | 346 | ||
3897 | 347 | std::string FileSystem::FS_FilenameWoExt(const char * const p) | 347 | std::string FileSystem::filename_without_ext(const char * const p) |
3898 | 348 | { | 348 | { |
3901 | 349 | std::string fname(p ? FileSystem::FS_Filename(p) : ""); | 349 | std::string fname(p ? FileSystem::fs_filename(p) : ""); |
3902 | 350 | std::string ext(FileSystem::FS_FilenameExt(fname)); | 350 | std::string ext(FileSystem::filename_ext(fname)); |
3903 | 351 | return fname.substr(0, fname.length() - ext.length()); | 351 | return fname.substr(0, fname.length() - ext.length()); |
3904 | 352 | } | 352 | } |
3905 | 353 | 353 | ||
3906 | @@ -361,7 +361,7 @@ | |||
3907 | 361 | // TODO(unknown): Catch FileNotFoundError in all users | 361 | // TODO(unknown): Catch FileNotFoundError in all users |
3908 | 362 | // TODO(unknown): throw FileTypeError if root is not a zipfile (exception from | 362 | // TODO(unknown): throw FileTypeError if root is not a zipfile (exception from |
3909 | 363 | // ZipFilesystem) | 363 | // ZipFilesystem) |
3911 | 364 | FileSystem & FileSystem::Create(const std::string & root) | 364 | FileSystem & FileSystem::create(const std::string & root) |
3912 | 365 | { | 365 | { |
3913 | 366 | struct stat statinfo; | 366 | struct stat statinfo; |
3914 | 367 | 367 | ||
3915 | @@ -375,10 +375,10 @@ | |||
3916 | 375 | #endif | 375 | #endif |
3917 | 376 | errno == ENAMETOOLONG) | 376 | errno == ENAMETOOLONG) |
3918 | 377 | { | 377 | { |
3920 | 378 | throw FileNotFoundError("FileSystem::Create", root); | 378 | throw FileNotFoundError("FileSystem::create", root); |
3921 | 379 | } | 379 | } |
3922 | 380 | if (errno == EACCES) | 380 | if (errno == EACCES) |
3924 | 381 | throw FileAccessDeniedError("FileSystem::Create", root); | 381 | throw FileAccessDeniedError("FileSystem::create", root); |
3925 | 382 | } | 382 | } |
3926 | 383 | 383 | ||
3927 | 384 | if (S_ISDIR(statinfo.st_mode)) { | 384 | if (S_ISDIR(statinfo.st_mode)) { |
3928 | @@ -389,7 +389,7 @@ | |||
3929 | 389 | } | 389 | } |
3930 | 390 | 390 | ||
3931 | 391 | throw FileTypeError | 391 | throw FileTypeError |
3933 | 392 | ("FileSystem::Create", root, | 392 | ("FileSystem::create", root, |
3934 | 393 | "cannot create virtual filesystem from file or directory"); | 393 | "cannot create virtual filesystem from file or directory"); |
3935 | 394 | } | 394 | } |
3936 | 395 | 395 | ||
3937 | @@ -400,12 +400,12 @@ | |||
3938 | 400 | { | 400 | { |
3939 | 401 | RealFSImpl fs(path); | 401 | RealFSImpl fs(path); |
3940 | 402 | 402 | ||
3942 | 403 | if (fs.IsDirectory(".widelands")) | 403 | if (fs.is_directory(".widelands")) |
3943 | 404 | return true; | 404 | return true; |
3944 | 405 | try { | 405 | try { |
3945 | 406 | // throws an exception if not writable | 406 | // throws an exception if not writable |
3948 | 407 | fs.EnsureDirectoryExists(".widelands"); | 407 | fs.ensure_directory_exists(".widelands"); |
3949 | 408 | fs.Unlink(".widelands"); | 408 | fs.unlink(".widelands"); |
3950 | 409 | return true; | 409 | return true; |
3951 | 410 | } catch (...) { | 410 | } catch (...) { |
3952 | 411 | log("Directory %s is not writeable - next try\n", path); | 411 | log("Directory %s is not writeable - next try\n", path); |
3953 | 412 | 412 | ||
3954 | === modified file 'src/io/filesystem/filesystem.h' | |||
3955 | --- src/io/filesystem/filesystem.h 2014-09-14 11:31:58 +0000 | |||
3956 | +++ src/io/filesystem/filesystem.h 2014-09-29 14:39:47 +0000 | |||
3957 | @@ -53,20 +53,20 @@ | |||
3958 | 53 | virtual ~FileSystem() {} | 53 | virtual ~FileSystem() {} |
3959 | 54 | 54 | ||
3960 | 55 | // Returns all files and directories (full path) in the given directory 'directory'. | 55 | // Returns all files and directories (full path) in the given directory 'directory'. |
3970 | 56 | virtual std::set<std::string> ListDirectory(const std::string& directory) = 0; | 56 | virtual std::set<std::string> list_directory(const std::string& directory) = 0; |
3971 | 57 | 57 | ||
3972 | 58 | virtual bool IsWritable() const = 0; | 58 | virtual bool is_writable() const = 0; |
3973 | 59 | virtual bool IsDirectory(const std::string & path) = 0; | 59 | virtual bool is_directory(const std::string & path) = 0; |
3974 | 60 | virtual bool FileExists (const std::string & path) = 0; | 60 | virtual bool file_exists (const std::string & path) = 0; |
3975 | 61 | 61 | ||
3976 | 62 | virtual void * Load(const std::string & fname, size_t & length) = 0; | 62 | virtual void * load(const std::string & fname, size_t & length) = 0; |
3977 | 63 | 63 | ||
3978 | 64 | virtual void Write | 64 | virtual void write |
3979 | 65 | (const std::string & fname, void const * data, int32_t length) | 65 | (const std::string & fname, void const * data, int32_t length) |
3980 | 66 | = 0; | 66 | = 0; |
3984 | 67 | virtual void EnsureDirectoryExists(const std::string & dirname) = 0; | 67 | virtual void ensure_directory_exists(const std::string & fs_dirname) = 0; |
3985 | 68 | //TODO(unknown): use this only from inside EnsureDirectoryExists() | 68 | //TODO(unknown): use this only from inside ensure_directory_exists() |
3986 | 69 | virtual void MakeDirectory(const std::string & dirname) = 0; | 69 | virtual void make_directory(const std::string & fs_dirname) = 0; |
3987 | 70 | 70 | ||
3988 | 71 | /** | 71 | /** |
3989 | 72 | * Opens the given file for reading as a stream. | 72 | * Opens the given file for reading as a stream. |
3990 | @@ -75,7 +75,7 @@ | |||
3991 | 75 | * \return a \ref StreamRead object for the file. The caller must delete this | 75 | * \return a \ref StreamRead object for the file. The caller must delete this |
3992 | 76 | * object when done to close the file. | 76 | * object when done to close the file. |
3993 | 77 | */ | 77 | */ |
3995 | 78 | virtual StreamRead * OpenStreamRead(const std::string & fname) = 0; | 78 | virtual StreamRead * open_stream_read(const std::string & fname) = 0; |
3996 | 79 | 79 | ||
3997 | 80 | /** | 80 | /** |
3998 | 81 | * Opens the given file for writing as a stream. | 81 | * Opens the given file for writing as a stream. |
3999 | @@ -87,47 +87,47 @@ | |||
4000 | 87 | * delete this object when done to close the file (which will implicitly | 87 | * delete this object when done to close the file (which will implicitly |
4001 | 88 | * flush unwritten data). | 88 | * flush unwritten data). |
4002 | 89 | */ | 89 | */ |
4004 | 90 | virtual StreamWrite * OpenStreamWrite(const std::string & fname) = 0; | 90 | virtual StreamWrite * open_stream_write(const std::string & fname) = 0; |
4005 | 91 | 91 | ||
4006 | 92 | /** | 92 | /** |
4007 | 93 | * Creates a subfilesystem from an existing file/directory. | 93 | * Creates a subfilesystem from an existing file/directory. |
4008 | 94 | * Passes ownership to caller. | 94 | * Passes ownership to caller. |
4009 | 95 | */ | 95 | */ |
4011 | 96 | virtual FileSystem * MakeSubFileSystem(const std::string & dirname) = 0; | 96 | virtual FileSystem * make_sub_file_system(const std::string & fs_dirname) = 0; |
4012 | 97 | /** | 97 | /** |
4013 | 98 | * Creates a subfilesystem from a new file/directory. | 98 | * Creates a subfilesystem from a new file/directory. |
4014 | 99 | * Passes ownership to caller. | 99 | * Passes ownership to caller. |
4015 | 100 | */ | 100 | */ |
4019 | 101 | virtual FileSystem * CreateSubFileSystem(const std::string & dirname, Type) = 0; | 101 | virtual FileSystem * create_sub_file_system(const std::string & fs_dirname, Type) = 0; |
4020 | 102 | virtual void Unlink(const std::string &) = 0; | 102 | virtual void fs_unlink(const std::string &) = 0; |
4021 | 103 | virtual void Rename(const std::string &, const std::string &) = 0; | 103 | virtual void fs_rename(const std::string &, const std::string &) = 0; |
4022 | 104 | 104 | ||
4024 | 105 | static FileSystem & Create(const std::string & root) | 105 | static FileSystem & create(const std::string & root) |
4025 | 106 | ; | 106 | ; |
4026 | 107 | 107 | ||
4027 | 108 | ///Retrieve the filesystem root's name == the mountpoint inside a | 108 | ///Retrieve the filesystem root's name == the mountpoint inside a |
4028 | 109 | ///LayeredFileSystem | 109 | ///LayeredFileSystem |
4030 | 110 | virtual std::string getBasename() = 0; | 110 | virtual std::string get_basename() = 0; |
4031 | 111 | 111 | ||
4032 | 112 | // basic path/filename manipulation | 112 | // basic path/filename manipulation |
4038 | 113 | std::string fixCrossFile(const std::string &) const; | 113 | std::string fix_cross_file(const std::string &) const; |
4039 | 114 | char fileSeparator() {return m_filesep;} | 114 | char file_separator() {return m_filesep;} |
4040 | 115 | std::string getWorkingDirectory() const; | 115 | std::string get_working_directory() const; |
4041 | 116 | std::string FS_CanonicalizeName(std::string path) const; | 116 | std::string canonicalize_name(std::string path) const; |
4042 | 117 | bool pathIsAbsolute(const std::string & path) const; | 117 | bool is_path_absolute(const std::string & path) const; |
4043 | 118 | 118 | ||
4044 | 119 | ///Given a filename, return the name with any path stripped off. | 119 | ///Given a filename, return the name with any path stripped off. |
4047 | 120 | static const char * FS_Filename(const char * n); | 120 | static const char * fs_filename(const char * n); |
4048 | 121 | static std::string FS_Dirname(const std::string& full_path); | 121 | static std::string fs_dirname(const std::string& full_path); |
4049 | 122 | 122 | ||
4050 | 123 | ///Given a filename (without any path), return the extension, if any. | 123 | ///Given a filename (without any path), return the extension, if any. |
4052 | 124 | static std::string FS_FilenameExt(const std::string & f); | 124 | static std::string filename_ext(const std::string & f); |
4053 | 125 | 125 | ||
4054 | 126 | ///Given a filename, return the name with any path or extension stripped off. | 126 | ///Given a filename, return the name with any path or extension stripped off. |
4057 | 127 | static std::string FS_FilenameWoExt(const char * n); | 127 | static std::string filename_without_ext(const char * n); |
4058 | 128 | static std::string GetHomedir(); | 128 | static std::string get_homedir(); |
4059 | 129 | 129 | ||
4061 | 130 | virtual unsigned long long DiskSpace() = 0; | 130 | virtual unsigned long long disk_space() = 0; |
4062 | 131 | 131 | ||
4063 | 132 | protected: | 132 | protected: |
4064 | 133 | ///To get a filesystem, use the Create methods | 133 | ///To get a filesystem, use the Create methods |
4065 | 134 | 134 | ||
4066 | === modified file 'src/io/filesystem/layered_filesystem.cc' | |||
4067 | --- src/io/filesystem/layered_filesystem.cc 2014-09-14 11:31:58 +0000 | |||
4068 | +++ src/io/filesystem/layered_filesystem.cc 2014-09-29 14:39:47 +0000 | |||
4069 | @@ -43,15 +43,15 @@ | |||
4070 | 43 | * Just assume that at least one of our child FSs is writable | 43 | * Just assume that at least one of our child FSs is writable |
4071 | 44 | */ | 44 | */ |
4072 | 45 | // TODO(unknown): Implement me | 45 | // TODO(unknown): Implement me |
4074 | 46 | bool LayeredFileSystem::IsWritable() const { | 46 | bool LayeredFileSystem::is_writable() const { |
4075 | 47 | return true; | 47 | return true; |
4076 | 48 | } | 48 | } |
4077 | 49 | 49 | ||
4079 | 50 | void LayeredFileSystem::AddFileSystem(FileSystem* fs) { | 50 | void LayeredFileSystem::add_file_system(FileSystem* fs) { |
4080 | 51 | m_filesystems.emplace_back(fs); | 51 | m_filesystems.emplace_back(fs); |
4081 | 52 | } | 52 | } |
4082 | 53 | 53 | ||
4084 | 54 | void LayeredFileSystem::SetHomeFileSystem(FileSystem * fs) | 54 | void LayeredFileSystem::set_home_file_system(FileSystem * fs) |
4085 | 55 | { | 55 | { |
4086 | 56 | m_home.reset(fs); | 56 | m_home.reset(fs); |
4087 | 57 | } | 57 | } |
4088 | @@ -60,11 +60,11 @@ | |||
4089 | 60 | * Remove a filesystem from the stack | 60 | * Remove a filesystem from the stack |
4090 | 61 | * \param fs The filesystem to be removed | 61 | * \param fs The filesystem to be removed |
4091 | 62 | */ | 62 | */ |
4093 | 63 | void LayeredFileSystem::RemoveFileSystem(const FileSystem & fs) | 63 | void LayeredFileSystem::remove_file_system(const FileSystem & fs) |
4094 | 64 | { | 64 | { |
4095 | 65 | if (m_filesystems.back().get() != &fs) | 65 | if (m_filesystems.back().get() != &fs) |
4096 | 66 | throw std::logic_error | 66 | throw std::logic_error |
4098 | 67 | ("LayeredFileSystem::RemoveFileSystem: interspersed add/remove " | 67 | ("LayeredFileSystem::remove_file_system: interspersed add/remove " |
4099 | 68 | "detected!"); | 68 | "detected!"); |
4100 | 69 | m_filesystems.pop_back(); | 69 | m_filesystems.pop_back(); |
4101 | 70 | } | 70 | } |
4102 | @@ -77,12 +77,12 @@ | |||
4103 | 77 | * | 77 | * |
4104 | 78 | * Returns the number of files found. | 78 | * Returns the number of files found. |
4105 | 79 | */ | 79 | */ |
4107 | 80 | std::set<std::string> LayeredFileSystem::ListDirectory(const std::string& path) { | 80 | std::set<std::string> LayeredFileSystem::list_directory(const std::string& path) { |
4108 | 81 | std::set<std::string> results; | 81 | std::set<std::string> results; |
4109 | 82 | FilenameSet files; | 82 | FilenameSet files; |
4110 | 83 | //check home system first | 83 | //check home system first |
4111 | 84 | if (m_home) { | 84 | if (m_home) { |
4113 | 85 | files = m_home->ListDirectory(path); | 85 | files = m_home->list_directory(path); |
4114 | 86 | for | 86 | for |
4115 | 87 | (FilenameSet::iterator fnit = files.begin(); | 87 | (FilenameSet::iterator fnit = files.begin(); |
4116 | 88 | fnit != files.end(); | 88 | fnit != files.end(); |
4117 | @@ -91,7 +91,7 @@ | |||
4118 | 91 | } | 91 | } |
4119 | 92 | 92 | ||
4120 | 93 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) { | 93 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) { |
4122 | 94 | files = (*it)->ListDirectory(path); | 94 | files = (*it)->list_directory(path); |
4123 | 95 | 95 | ||
4124 | 96 | for (FilenameSet::iterator fnit = files.begin(); fnit != files.end(); ++fnit) | 96 | for (FilenameSet::iterator fnit = files.begin(); fnit != files.end(); ++fnit) |
4125 | 97 | results.insert(*fnit); | 97 | results.insert(*fnit); |
4126 | @@ -102,11 +102,11 @@ | |||
4127 | 102 | /** | 102 | /** |
4128 | 103 | * Returns true if the file can be found in at least one of the sub-filesystems | 103 | * Returns true if the file can be found in at least one of the sub-filesystems |
4129 | 104 | */ | 104 | */ |
4132 | 105 | bool LayeredFileSystem::FileExists(const std::string & path) { | 105 | bool LayeredFileSystem::file_exists(const std::string & path) { |
4133 | 106 | if (m_home && m_home->FileExists(path)) | 106 | if (m_home && m_home->file_exists(path)) |
4134 | 107 | return true; | 107 | return true; |
4135 | 108 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) | 108 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) |
4137 | 109 | if ((*it)->FileExists(path)) | 109 | if ((*it)->file_exists(path)) |
4138 | 110 | return true; | 110 | return true; |
4139 | 111 | 111 | ||
4140 | 112 | return false; | 112 | return false; |
4141 | @@ -116,32 +116,32 @@ | |||
4142 | 116 | * Returns true if path is a directory in at least one of the directories | 116 | * Returns true if path is a directory in at least one of the directories |
4143 | 117 | */ | 117 | */ |
4144 | 118 | // TODO(unknown): What if it's a file in some and a dir in others????? | 118 | // TODO(unknown): What if it's a file in some and a dir in others????? |
4147 | 119 | bool LayeredFileSystem::IsDirectory(const std::string & path) { | 119 | bool LayeredFileSystem::is_directory(const std::string & path) { |
4148 | 120 | if (m_home && m_home->IsDirectory(path)) | 120 | if (m_home && m_home->is_directory(path)) |
4149 | 121 | return true; | 121 | return true; |
4150 | 122 | 122 | ||
4151 | 123 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) | 123 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) |
4153 | 124 | if ((*it)->IsDirectory(path)) | 124 | if ((*it)->is_directory(path)) |
4154 | 125 | return true; | 125 | return true; |
4155 | 126 | 126 | ||
4156 | 127 | return false; | 127 | return false; |
4157 | 128 | } | 128 | } |
4158 | 129 | 129 | ||
4159 | 130 | /** | 130 | /** |
4161 | 131 | * Read the given file into alloced memory; called by FileRead::Open. | 131 | * Read the given file into alloced memory; called by FileRead::open. |
4162 | 132 | * Throws an exception if the file couldn't be opened. | 132 | * Throws an exception if the file couldn't be opened. |
4163 | 133 | * | 133 | * |
4164 | 134 | * Note: We first query the sub-filesystem whether the file exists. Otherwise, | 134 | * Note: We first query the sub-filesystem whether the file exists. Otherwise, |
4165 | 135 | * we'd have problems differentiating the errors returned by the sub-FS. | 135 | * we'd have problems differentiating the errors returned by the sub-FS. |
4166 | 136 | * Let's just avoid any possible hassles with that. | 136 | * Let's just avoid any possible hassles with that. |
4167 | 137 | */ | 137 | */ |
4171 | 138 | void * LayeredFileSystem::Load(const std::string & fname, size_t & length) { | 138 | void * LayeredFileSystem::load(const std::string & fname, size_t & length) { |
4172 | 139 | if (m_home && m_home->FileExists(fname)) | 139 | if (m_home && m_home->file_exists(fname)) |
4173 | 140 | return m_home->Load(fname, length); | 140 | return m_home->load(fname, length); |
4174 | 141 | 141 | ||
4175 | 142 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) | 142 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) |
4178 | 143 | if ((*it)->FileExists(fname)) | 143 | if ((*it)->file_exists(fname)) |
4179 | 144 | return (*it)->Load(fname, length); | 144 | return (*it)->load(fname, length); |
4180 | 145 | 145 | ||
4181 | 146 | throw FileNotFoundError("Could not find file", fname); | 146 | throw FileNotFoundError("Could not find file", fname); |
4182 | 147 | } | 147 | } |
4183 | @@ -150,15 +150,15 @@ | |||
4184 | 150 | * Write the given block of memory out as a file to the first writable sub-FS. | 150 | * Write the given block of memory out as a file to the first writable sub-FS. |
4185 | 151 | * Throws an exception if it fails. | 151 | * Throws an exception if it fails. |
4186 | 152 | */ | 152 | */ |
4188 | 153 | void LayeredFileSystem::Write | 153 | void LayeredFileSystem::write |
4189 | 154 | (const std::string & fname, void const * const data, int32_t const length) | 154 | (const std::string & fname, void const * const data, int32_t const length) |
4190 | 155 | { | 155 | { |
4193 | 156 | if (m_home && m_home->IsWritable()) | 156 | if (m_home && m_home->is_writable()) |
4194 | 157 | return m_home->Write(fname, data, length); | 157 | return m_home->write(fname, data, length); |
4195 | 158 | 158 | ||
4196 | 159 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) | 159 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) |
4199 | 160 | if ((*it)->IsWritable()) | 160 | if ((*it)->is_writable()) |
4200 | 161 | return (*it)->Write(fname, data, length); | 161 | return (*it)->write(fname, data, length); |
4201 | 162 | 162 | ||
4202 | 163 | throw wexception("LayeredFileSystem: No writable filesystem!"); | 163 | throw wexception("LayeredFileSystem: No writable filesystem!"); |
4203 | 164 | } | 164 | } |
4204 | @@ -167,13 +167,13 @@ | |||
4205 | 167 | * Analogously to Read, open the file from the first sub-filesystem where | 167 | * Analogously to Read, open the file from the first sub-filesystem where |
4206 | 168 | * it exists. | 168 | * it exists. |
4207 | 169 | */ | 169 | */ |
4211 | 170 | StreamRead * LayeredFileSystem::OpenStreamRead (const std::string & fname) { | 170 | StreamRead * LayeredFileSystem::open_stream_read (const std::string & fname) { |
4212 | 171 | if (m_home && m_home->FileExists(fname)) | 171 | if (m_home && m_home->file_exists(fname)) |
4213 | 172 | return m_home->OpenStreamRead(fname); | 172 | return m_home->open_stream_read(fname); |
4214 | 173 | 173 | ||
4215 | 174 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) | 174 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) |
4218 | 175 | if ((*it)->FileExists(fname)) | 175 | if ((*it)->file_exists(fname)) |
4219 | 176 | return (*it)->OpenStreamRead(fname); | 176 | return (*it)->open_stream_read(fname); |
4220 | 177 | 177 | ||
4221 | 178 | throw FileNotFoundError("Could not find file", fname); | 178 | throw FileNotFoundError("Could not find file", fname); |
4222 | 179 | } | 179 | } |
4223 | @@ -181,13 +181,13 @@ | |||
4224 | 181 | /** | 181 | /** |
4225 | 182 | * Analogously to Write, create the file in the first writable sub-FS. | 182 | * Analogously to Write, create the file in the first writable sub-FS. |
4226 | 183 | */ | 183 | */ |
4230 | 184 | StreamWrite * LayeredFileSystem::OpenStreamWrite(const std::string & fname) { | 184 | StreamWrite * LayeredFileSystem::open_stream_write(const std::string & fname) { |
4231 | 185 | if (m_home && m_home->IsWritable()) | 185 | if (m_home && m_home->is_writable()) |
4232 | 186 | return m_home->OpenStreamWrite(fname); | 186 | return m_home->open_stream_write(fname); |
4233 | 187 | 187 | ||
4234 | 188 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) | 188 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) |
4237 | 189 | if ((*it)->IsWritable()) | 189 | if ((*it)->is_writable()) |
4238 | 190 | return (*it)->OpenStreamWrite(fname); | 190 | return (*it)->open_stream_write(fname); |
4239 | 191 | 191 | ||
4240 | 192 | throw wexception("LayeredFileSystem: No writable filesystem!"); | 192 | throw wexception("LayeredFileSystem: No writable filesystem!"); |
4241 | 193 | } | 193 | } |
4242 | @@ -195,27 +195,27 @@ | |||
4243 | 195 | /** | 195 | /** |
4244 | 196 | * MakeDir in first writable directory | 196 | * MakeDir in first writable directory |
4245 | 197 | */ | 197 | */ |
4249 | 198 | void LayeredFileSystem::MakeDirectory(const std::string & dirname) { | 198 | void LayeredFileSystem::make_directory(const std::string & dirname) { |
4250 | 199 | if (m_home && m_home->IsWritable()) | 199 | if (m_home && m_home->is_writable()) |
4251 | 200 | return m_home->MakeDirectory(dirname); | 200 | return m_home->make_directory(dirname); |
4252 | 201 | 201 | ||
4253 | 202 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) | 202 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) |
4256 | 203 | if ((*it)->IsWritable()) | 203 | if ((*it)->is_writable()) |
4257 | 204 | return (*it)->MakeDirectory(dirname); | 204 | return (*it)->make_directory(dirname); |
4258 | 205 | 205 | ||
4259 | 206 | throw wexception("LayeredFileSystem: No writable filesystem!"); | 206 | throw wexception("LayeredFileSystem: No writable filesystem!"); |
4260 | 207 | } | 207 | } |
4261 | 208 | 208 | ||
4262 | 209 | /** | 209 | /** |
4264 | 210 | * EnsureDirectoryExists in first writable directory | 210 | * ensure_directory_exists in first writable directory |
4265 | 211 | */ | 211 | */ |
4269 | 212 | void LayeredFileSystem::EnsureDirectoryExists(const std::string & dirname) { | 212 | void LayeredFileSystem::ensure_directory_exists(const std::string & dirname) { |
4270 | 213 | if (m_home && m_home->IsWritable()) | 213 | if (m_home && m_home->is_writable()) |
4271 | 214 | return m_home->EnsureDirectoryExists(dirname); | 214 | return m_home->ensure_directory_exists(dirname); |
4272 | 215 | 215 | ||
4273 | 216 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) | 216 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) |
4276 | 217 | if ((*it)->IsWritable()) | 217 | if ((*it)->is_writable()) |
4277 | 218 | return (*it)->EnsureDirectoryExists(dirname); | 218 | return (*it)->ensure_directory_exists(dirname); |
4278 | 219 | 219 | ||
4279 | 220 | throw wexception("LayeredFileSystem: No writable filesystem!"); | 220 | throw wexception("LayeredFileSystem: No writable filesystem!"); |
4280 | 221 | } | 221 | } |
4281 | @@ -223,14 +223,14 @@ | |||
4282 | 223 | /** | 223 | /** |
4283 | 224 | * Create a subfilesystem from an existing file/directory | 224 | * Create a subfilesystem from an existing file/directory |
4284 | 225 | */ | 225 | */ |
4286 | 226 | FileSystem * LayeredFileSystem::MakeSubFileSystem(const std::string & dirname) | 226 | FileSystem * LayeredFileSystem::make_sub_file_system(const std::string & dirname) |
4287 | 227 | { | 227 | { |
4290 | 228 | if (m_home && m_home->IsWritable() && m_home->FileExists(dirname)) | 228 | if (m_home && m_home->is_writable() && m_home->file_exists(dirname)) |
4291 | 229 | return m_home->MakeSubFileSystem(dirname); | 229 | return m_home->make_sub_file_system(dirname); |
4292 | 230 | 230 | ||
4293 | 231 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) | 231 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) |
4296 | 232 | if ((*it)->IsWritable() && (*it)->FileExists(dirname)) | 232 | if ((*it)->is_writable() && (*it)->file_exists(dirname)) |
4297 | 233 | return (*it)->MakeSubFileSystem(dirname); | 233 | return (*it)->make_sub_file_system(dirname); |
4298 | 234 | 234 | ||
4299 | 235 | throw wexception("LayeredFileSystem: unable to create sub filesystem"); | 235 | throw wexception("LayeredFileSystem: unable to create sub filesystem"); |
4300 | 236 | } | 236 | } |
4301 | @@ -238,14 +238,14 @@ | |||
4302 | 238 | /** | 238 | /** |
4303 | 239 | * Create a subfilesystem from a new file/directory | 239 | * Create a subfilesystem from a new file/directory |
4304 | 240 | */ | 240 | */ |
4306 | 241 | FileSystem * LayeredFileSystem::CreateSubFileSystem(const std::string & dirname, Type const type) | 241 | FileSystem * LayeredFileSystem::create_sub_file_system(const std::string & dirname, Type const type) |
4307 | 242 | { | 242 | { |
4310 | 243 | if (m_home && m_home->IsWritable() && !m_home->FileExists(dirname)) | 243 | if (m_home && m_home->is_writable() && !m_home->file_exists(dirname)) |
4311 | 244 | return m_home->CreateSubFileSystem(dirname, type); | 244 | return m_home->create_sub_file_system(dirname, type); |
4312 | 245 | 245 | ||
4313 | 246 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) | 246 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) |
4316 | 247 | if ((*it)->IsWritable() && !(*it)->FileExists(dirname)) | 247 | if ((*it)->is_writable() && !(*it)->file_exists(dirname)) |
4317 | 248 | return (*it)->CreateSubFileSystem(dirname, type); | 248 | return (*it)->create_sub_file_system(dirname, type); |
4318 | 249 | 249 | ||
4319 | 250 | throw wexception("LayeredFileSystem: unable to create sub filesystem"); | 250 | throw wexception("LayeredFileSystem: unable to create sub filesystem"); |
4320 | 251 | } | 251 | } |
4321 | @@ -253,33 +253,34 @@ | |||
4322 | 253 | /** | 253 | /** |
4323 | 254 | * Remove this file or directory. If it is a directory, remove it recursively | 254 | * Remove this file or directory. If it is a directory, remove it recursively |
4324 | 255 | */ | 255 | */ |
4327 | 256 | void LayeredFileSystem::Unlink(const std::string & file) { | 256 | void LayeredFileSystem::fs_unlink(const std::string & file) { |
4328 | 257 | if (!FileExists(file)) | 257 | if (!file_exists(file)) |
4329 | 258 | return; | 258 | return; |
4330 | 259 | 259 | ||
4333 | 260 | if (m_home && m_home->IsWritable() && m_home->FileExists(file)) { | 260 | if (m_home && m_home->is_writable() && m_home->file_exists(file)) { |
4334 | 261 | m_home->Unlink(file); | 261 | m_home->fs_unlink(file); |
4335 | 262 | return; | 262 | return; |
4336 | 263 | } | 263 | } |
4337 | 264 | |||
4338 | 264 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) | 265 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) |
4341 | 265 | if ((*it)->IsWritable() && (*it)->FileExists(file)) { | 266 | if ((*it)->is_writable() && (*it)->file_exists(file)) { |
4342 | 266 | (*it)->Unlink(file); | 267 | (*it)->fs_unlink(file); |
4343 | 267 | return; | 268 | return; |
4344 | 268 | } | 269 | } |
4345 | 269 | } | 270 | } |
4346 | 270 | 271 | ||
4348 | 271 | void LayeredFileSystem::Rename | 272 | void LayeredFileSystem::fs_rename |
4349 | 272 | (const std::string & old_name, const std::string & new_name) | 273 | (const std::string & old_name, const std::string & new_name) |
4350 | 273 | { | 274 | { |
4352 | 274 | if (!FileExists(old_name)) | 275 | if (!file_exists(old_name)) |
4353 | 275 | return; | 276 | return; |
4356 | 276 | if (m_home && m_home->IsWritable() && m_home->FileExists(old_name)) { | 277 | if (m_home && m_home->is_writable() && m_home->file_exists(old_name)) { |
4357 | 277 | m_home->Rename(old_name, new_name); | 278 | m_home->fs_rename(old_name, new_name); |
4358 | 278 | return; | 279 | return; |
4359 | 279 | } | 280 | } |
4360 | 280 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) | 281 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) |
4363 | 281 | if ((*it)->IsWritable() && (*it)->FileExists(old_name)) { | 282 | if ((*it)->is_writable() && (*it)->file_exists(old_name)) { |
4364 | 282 | (*it)->Rename(old_name, new_name); | 283 | (*it)->fs_rename(old_name, new_name); |
4365 | 283 | return; | 284 | return; |
4366 | 284 | } | 285 | } |
4367 | 285 | } | 286 | } |
4368 | @@ -288,12 +289,12 @@ | |||
4369 | 288 | // or the first directory on the stack we can find. | 289 | // or the first directory on the stack we can find. |
4370 | 289 | // This heuristic is justified by the fact that ths is | 290 | // This heuristic is justified by the fact that ths is |
4371 | 290 | // where we will create new files. | 291 | // where we will create new files. |
4373 | 291 | unsigned long long LayeredFileSystem::DiskSpace() { | 292 | unsigned long long LayeredFileSystem::disk_space() { |
4374 | 292 | if (m_home) { | 293 | if (m_home) { |
4376 | 293 | return m_home->DiskSpace(); | 294 | return m_home->disk_space(); |
4377 | 294 | } | 295 | } |
4378 | 295 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) | 296 | for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) |
4379 | 296 | if (*it) | 297 | if (*it) |
4381 | 297 | return (*it)->DiskSpace(); | 298 | return (*it)->disk_space(); |
4382 | 298 | return 0; | 299 | return 0; |
4383 | 299 | } | 300 | } |
4384 | 300 | 301 | ||
4385 | === modified file 'src/io/filesystem/layered_filesystem.h' | |||
4386 | --- src/io/filesystem/layered_filesystem.h 2014-07-26 10:43:23 +0000 | |||
4387 | +++ src/io/filesystem/layered_filesystem.h 2014-09-29 14:39:47 +0000 | |||
4388 | @@ -50,37 +50,37 @@ | |||
4389 | 50 | 50 | ||
4390 | 51 | // Add a new filesystem to the top of the stack. Take ownership of the given | 51 | // Add a new filesystem to the top of the stack. Take ownership of the given |
4391 | 52 | // filesystem. | 52 | // filesystem. |
4393 | 53 | void AddFileSystem(FileSystem*); | 53 | void add_file_system(FileSystem*); |
4394 | 54 | 54 | ||
4395 | 55 | // Set the home filesystem (which is the preferred filesystem for writing | 55 | // Set the home filesystem (which is the preferred filesystem for writing |
4396 | 56 | // files). Take ownership of the given filesystem. | 56 | // files). Take ownership of the given filesystem. |
4411 | 57 | void SetHomeFileSystem(FileSystem*); | 57 | void set_home_file_system(FileSystem*); |
4412 | 58 | 58 | ||
4413 | 59 | virtual void RemoveFileSystem(const FileSystem &); | 59 | virtual void remove_file_system(const FileSystem &); |
4414 | 60 | 60 | ||
4415 | 61 | std::set<std::string> ListDirectory(const std::string& path) override; | 61 | std::set<std::string> list_directory(const std::string& path) override; |
4416 | 62 | 62 | ||
4417 | 63 | bool IsWritable() const override; | 63 | bool is_writable () const override; |
4418 | 64 | bool FileExists(const std::string & path) override; | 64 | bool file_exists (const std::string & path) override; |
4419 | 65 | bool IsDirectory (const std::string & path) override; | 65 | bool is_directory (const std::string & path) override; |
4420 | 66 | void EnsureDirectoryExists(const std::string & dirname) override; | 66 | void ensure_directory_exists(const std::string & fs_dirname) override; |
4421 | 67 | void MakeDirectory (const std::string & dirname) override; | 67 | void make_directory (const std::string & fs_dirname) override; |
4422 | 68 | 68 | ||
4423 | 69 | void * Load(const std::string & fname, size_t & length) override; | 69 | void * load(const std::string & fname, size_t & length) override; |
4424 | 70 | virtual void Write | 70 | virtual void write |
4425 | 71 | (const std::string & fname, void const * data, int32_t length) override; | 71 | (const std::string & fname, void const * data, int32_t length) override; |
4426 | 72 | 72 | ||
4438 | 73 | StreamRead * OpenStreamRead (const std::string & fname) override; | 73 | StreamRead * open_stream_read (const std::string & fname) override; |
4439 | 74 | StreamWrite * OpenStreamWrite(const std::string & fname) override; | 74 | StreamWrite * open_stream_write(const std::string & fname) override; |
4440 | 75 | 75 | ||
4441 | 76 | FileSystem * MakeSubFileSystem(const std::string & dirname) override; | 76 | FileSystem * make_sub_file_system(const std::string & fs_dirname) override; |
4442 | 77 | FileSystem * CreateSubFileSystem(const std::string & dirname, Type) override; | 77 | FileSystem * create_sub_file_system(const std::string & fs_dirname, Type) override; |
4443 | 78 | void Unlink(const std::string & file) override; | 78 | void fs_unlink(const std::string & file) override; |
4444 | 79 | void Rename(const std::string &, const std::string &) override; | 79 | void fs_rename(const std::string &, const std::string &) override; |
4445 | 80 | 80 | ||
4446 | 81 | std::string getBasename() override {return std::string();} | 81 | std::string get_basename() override {return std::string();} |
4447 | 82 | 82 | ||
4448 | 83 | unsigned long long DiskSpace() override; | 83 | unsigned long long disk_space() override; |
4449 | 84 | 84 | ||
4450 | 85 | private: | 85 | private: |
4451 | 86 | std::vector<std::unique_ptr<FileSystem>> m_filesystems; | 86 | std::vector<std::unique_ptr<FileSystem>> m_filesystems; |
4452 | 87 | 87 | ||
4453 | === modified file 'src/io/filesystem/test/test_filesystem.cc' | |||
4454 | --- src/io/filesystem/test/test_filesystem.cc 2014-07-14 10:45:44 +0000 | |||
4455 | +++ src/io/filesystem/test/test_filesystem.cc 2014-09-29 14:39:47 +0000 | |||
4456 | @@ -34,7 +34,7 @@ | |||
4457 | 34 | if (!s.empty() && s[0] == '\\') | 34 | if (!s.empty() && s[0] == '\\') |
4458 | 35 | { | 35 | { |
4459 | 36 | // Insert drive letter part from current working directory | 36 | // Insert drive letter part from current working directory |
4461 | 37 | std::string cwd = RealFSImpl("").getWorkingDirectory(); | 37 | std::string cwd = RealFSImpl("").get_working_directory(); |
4462 | 38 | s.insert(0, cwd.substr(0, 2)); | 38 | s.insert(0, cwd.substr(0, 2)); |
4463 | 39 | } | 39 | } |
4464 | 40 | return s; | 40 | return s; |
4465 | @@ -53,15 +53,15 @@ | |||
4466 | 53 | BOOST_AUTO_TEST_SUITE(FileSystemTests) | 53 | BOOST_AUTO_TEST_SUITE(FileSystemTests) |
4467 | 54 | #ifndef _WIN32 | 54 | #ifndef _WIN32 |
4468 | 55 | #define TEST_CANONICALIZE_NAME(root, path, expected) \ | 55 | #define TEST_CANONICALIZE_NAME(root, path, expected) \ |
4470 | 56 | BOOST_CHECK_EQUAL(RealFSImpl(root).FS_CanonicalizeName(path), expected); | 56 | BOOST_CHECK_EQUAL(RealFSImpl(root).canonicalize_name(path), expected); |
4471 | 57 | #else | 57 | #else |
4472 | 58 | #define TEST_CANONICALIZE_NAME(root, path, expected) \ | 58 | #define TEST_CANONICALIZE_NAME(root, path, expected) \ |
4474 | 59 | BOOST_CHECK_EQUAL(RealFSImpl(Win32Path(root)).FS_CanonicalizeName(path), Win32Path(expected)); | 59 | BOOST_CHECK_EQUAL(RealFSImpl(Win32Path(root)).canonicalize_name(path), Win32Path(expected)); |
4475 | 60 | #endif | 60 | #endif |
4476 | 61 | 61 | ||
4477 | 62 | BOOST_AUTO_TEST_CASE(test_canonicalize_name) { | 62 | BOOST_AUTO_TEST_CASE(test_canonicalize_name) { |
4478 | 63 | setenv("HOME", "/home/test", 1); | 63 | setenv("HOME", "/home/test", 1); |
4480 | 64 | std::string cwd = RealFSImpl("").getWorkingDirectory(); | 64 | std::string cwd = RealFSImpl("").get_working_directory(); |
4481 | 65 | 65 | ||
4482 | 66 | // RealFSImpl is constructed with a root directory... | 66 | // RealFSImpl is constructed with a root directory... |
4483 | 67 | 67 | ||
4484 | @@ -128,8 +128,8 @@ | |||
4485 | 128 | 128 | ||
4486 | 129 | #ifdef _WIN32 | 129 | #ifdef _WIN32 |
4487 | 130 | // Check drive letter handling. | 130 | // Check drive letter handling. |
4490 | 131 | BOOST_CHECK_EQUAL(RealFSImpl("C:\\").FS_CanonicalizeName("C:\\"), "C:"); | 131 | BOOST_CHECK_EQUAL(RealFSImpl("C:\\").canonicalize_name("C:\\"), "C:"); |
4491 | 132 | BOOST_CHECK_EQUAL(RealFSImpl("C:\\").FS_CanonicalizeName("D:\\"), "C:\\D:"); | 132 | BOOST_CHECK_EQUAL(RealFSImpl("C:\\").canonicalize_name("D:\\"), "C:\\D:"); |
4492 | 133 | #endif | 133 | #endif |
4493 | 134 | } | 134 | } |
4494 | 135 | 135 | ||
4495 | @@ -138,7 +138,7 @@ | |||
4496 | 138 | // ~ gets expanded to $HOME | 138 | // ~ gets expanded to $HOME |
4497 | 139 | BOOST_AUTO_TEST_CASE(test_canonicalize_name_home_expansion) { | 139 | BOOST_AUTO_TEST_CASE(test_canonicalize_name_home_expansion) { |
4498 | 140 | setenv("HOME", "/my/home", 1); | 140 | setenv("HOME", "/my/home", 1); |
4500 | 141 | std::string cwd = RealFSImpl("").getWorkingDirectory(); | 141 | std::string cwd = RealFSImpl("").get_working_directory(); |
4501 | 142 | 142 | ||
4502 | 143 | TEST_CANONICALIZE_NAME("~", "path", "/my/home/path"); | 143 | TEST_CANONICALIZE_NAME("~", "path", "/my/home/path"); |
4503 | 144 | TEST_CANONICALIZE_NAME("~/test", "path", "/my/home/test/path"); | 144 | TEST_CANONICALIZE_NAME("~/test", "path", "/my/home/test/path"); |
4504 | 145 | 145 | ||
4505 | === modified file 'src/io/filesystem/zip_exceptions.h' | |||
4506 | --- src/io/filesystem/zip_exceptions.h 2014-09-10 13:03:40 +0000 | |||
4507 | +++ src/io/filesystem/zip_exceptions.h 2014-09-29 14:39:47 +0000 | |||
4508 | @@ -27,7 +27,7 @@ | |||
4509 | 27 | * | 27 | * |
4510 | 28 | * Problems with the zipfile itself or normal file operations should throw | 28 | * Problems with the zipfile itself or normal file operations should throw |
4511 | 29 | * FileError or one of it's descendants with an appropriate message. E.g.: | 29 | * FileError or one of it's descendants with an appropriate message. E.g.: |
4513 | 30 | * throw FileNotFoundError("ZipFilesystem::Load", fname, | 30 | * throw FileNotFoundError("ZipFilesystem::load", fname, |
4514 | 31 | * "couldn't open file (from zipfile "+m_zipfilename+")"); | 31 | * "couldn't open file (from zipfile "+m_zipfilename+")"); |
4515 | 32 | */ | 32 | */ |
4516 | 33 | struct ZipOperationError : public std::logic_error { | 33 | struct ZipOperationError : public std::logic_error { |
4517 | 34 | 34 | ||
4518 | === modified file 'src/io/filesystem/zip_filesystem.cc' | |||
4519 | --- src/io/filesystem/zip_filesystem.cc 2014-09-10 13:03:40 +0000 | |||
4520 | +++ src/io/filesystem/zip_filesystem.cc 2014-09-29 14:39:47 +0000 | |||
4521 | @@ -43,7 +43,7 @@ | |||
4522 | 43 | m_unzipfile (nullptr), | 43 | m_unzipfile (nullptr), |
4523 | 44 | m_oldzip (false), | 44 | m_oldzip (false), |
4524 | 45 | m_zipfilename(zipfile), | 45 | m_zipfilename(zipfile), |
4526 | 46 | m_basenamezip(FS_Filename(zipfile.c_str())), | 46 | m_basenamezip(fs_filename(zipfile.c_str())), |
4527 | 47 | m_basename () | 47 | m_basename () |
4528 | 48 | { | 48 | { |
4529 | 49 | // TODO(unknown): check OS permissions on whether the file is writable | 49 | // TODO(unknown): check OS permissions on whether the file is writable |
4530 | @@ -54,13 +54,13 @@ | |||
4531 | 54 | */ | 54 | */ |
4532 | 55 | ZipFilesystem::~ZipFilesystem() | 55 | ZipFilesystem::~ZipFilesystem() |
4533 | 56 | { | 56 | { |
4535 | 57 | m_Close(); | 57 | m_close(); |
4536 | 58 | } | 58 | } |
4537 | 59 | 59 | ||
4538 | 60 | /** | 60 | /** |
4539 | 61 | * Return true if this directory is writable. | 61 | * Return true if this directory is writable. |
4540 | 62 | */ | 62 | */ |
4542 | 63 | bool ZipFilesystem::IsWritable() const { | 63 | bool ZipFilesystem::is_writable() const { |
4543 | 64 | return true; // should be checked in constructor | 64 | return true; // should be checked in constructor |
4544 | 65 | } | 65 | } |
4545 | 66 | 66 | ||
4546 | @@ -69,8 +69,8 @@ | |||
4547 | 69 | * pathname) in the results. There doesn't seem to be an even remotely | 69 | * pathname) in the results. There doesn't seem to be an even remotely |
4548 | 70 | * cross-platform way of doing this | 70 | * cross-platform way of doing this |
4549 | 71 | */ | 71 | */ |
4552 | 72 | std::set<std::string> ZipFilesystem::ListDirectory(const std::string& path_in) { | 72 | std::set<std::string> ZipFilesystem::list_directory(const std::string& path_in) { |
4553 | 73 | m_OpenUnzip(); | 73 | m_open_unzip(); |
4554 | 74 | 74 | ||
4555 | 75 | assert(path_in.size()); // prevent invalid read below | 75 | assert(path_in.size()); // prevent invalid read below |
4556 | 76 | 76 | ||
4557 | @@ -95,7 +95,7 @@ | |||
4558 | 95 | nullptr, 0, nullptr, 0); | 95 | nullptr, 0, nullptr, 0); |
4559 | 96 | 96 | ||
4560 | 97 | std::string complete_filename = strip_basename(filename_inzip); | 97 | std::string complete_filename = strip_basename(filename_inzip); |
4562 | 98 | std::string filename = FS_Filename(complete_filename.c_str()); | 98 | std::string filename = fs_filename(complete_filename.c_str()); |
4563 | 99 | std::string filepath = | 99 | std::string filepath = |
4564 | 100 | complete_filename.substr | 100 | complete_filename.substr |
4565 | 101 | (0, complete_filename.size() - filename.size()); | 101 | (0, complete_filename.size() - filename.size()); |
4566 | @@ -118,9 +118,9 @@ | |||
4567 | 118 | * Returns true if the given file exists, and false if it doesn't. | 118 | * Returns true if the given file exists, and false if it doesn't. |
4568 | 119 | * Also returns false if the pathname is invalid | 119 | * Also returns false if the pathname is invalid |
4569 | 120 | */ | 120 | */ |
4571 | 121 | bool ZipFilesystem::FileExists(const std::string & path) { | 121 | bool ZipFilesystem::file_exists(const std::string & path) { |
4572 | 122 | try { | 122 | try { |
4574 | 123 | m_OpenUnzip(); // TODO(unknown): check return value | 123 | m_open_unzip(); // TODO(unknown): check return value |
4575 | 124 | } catch (...) { | 124 | } catch (...) { |
4576 | 125 | return false; | 125 | return false; |
4577 | 126 | } | 126 | } |
4578 | @@ -159,9 +159,9 @@ | |||
4579 | 159 | * Returns true if the given file is a directory, and false if it doesn't. | 159 | * Returns true if the given file is a directory, and false if it doesn't. |
4580 | 160 | * Also returns false if the pathname is invalid | 160 | * Also returns false if the pathname is invalid |
4581 | 161 | */ | 161 | */ |
4583 | 162 | bool ZipFilesystem::IsDirectory(const std::string & path) { | 162 | bool ZipFilesystem::is_directory(const std::string & path) { |
4584 | 163 | 163 | ||
4586 | 164 | if (!FileExists(path)) | 164 | if (!file_exists(path)) |
4587 | 165 | return false; | 165 | return false; |
4588 | 166 | 166 | ||
4589 | 167 | unz_file_info file_info; | 167 | unz_file_info file_info; |
4590 | @@ -177,13 +177,13 @@ | |||
4591 | 177 | /** | 177 | /** |
4592 | 178 | * Create a sub filesystem out of this filesystem | 178 | * Create a sub filesystem out of this filesystem |
4593 | 179 | */ | 179 | */ |
4601 | 180 | FileSystem * ZipFilesystem::MakeSubFileSystem(const std::string & path) { | 180 | FileSystem * ZipFilesystem::make_sub_file_system(const std::string & path) { |
4602 | 181 | m_OpenUnzip(); | 181 | m_open_unzip(); |
4603 | 182 | 182 | ||
4604 | 183 | assert(FileExists(path)); | 183 | assert(file_exists(path)); |
4605 | 184 | assert(IsDirectory(path)); | 184 | assert(is_directory(path)); |
4606 | 185 | 185 | ||
4607 | 186 | m_Close(); | 186 | m_close(); |
4608 | 187 | 187 | ||
4609 | 188 | std::string localpath = path; | 188 | std::string localpath = path; |
4610 | 189 | 189 | ||
4611 | @@ -201,20 +201,20 @@ | |||
4612 | 201 | * \throw ZipOperationError | 201 | * \throw ZipOperationError |
4613 | 202 | */ | 202 | */ |
4614 | 203 | // TODO(unknown): type should be recognized automatically, | 203 | // TODO(unknown): type should be recognized automatically, |
4617 | 204 | // see Filesystem::Create | 204 | // see Filesystem::create |
4618 | 205 | FileSystem * ZipFilesystem::CreateSubFileSystem(const std::string & path, Type const type) | 205 | FileSystem * ZipFilesystem::create_sub_file_system(const std::string & path, Type const type) |
4619 | 206 | { | 206 | { |
4621 | 207 | assert(!FileExists(path)); | 207 | assert(!file_exists(path)); |
4622 | 208 | 208 | ||
4623 | 209 | if (type != FileSystem::DIR) | 209 | if (type != FileSystem::DIR) |
4624 | 210 | throw ZipOperationError | 210 | throw ZipOperationError |
4626 | 211 | ("ZipFilesystem::CreateSubFileSystem", | 211 | ("ZipFilesystem::create_sub_file_system", |
4627 | 212 | path, m_zipfilename, | 212 | path, m_zipfilename, |
4628 | 213 | "can not create ZipFilesystem inside another ZipFilesystem"); | 213 | "can not create ZipFilesystem inside another ZipFilesystem"); |
4629 | 214 | 214 | ||
4631 | 215 | EnsureDirectoryExists(path); | 215 | ensure_directory_exists(path); |
4632 | 216 | 216 | ||
4634 | 217 | m_Close(); | 217 | m_close(); |
4635 | 218 | 218 | ||
4636 | 219 | std::string localpath = path; | 219 | std::string localpath = path; |
4637 | 220 | 220 | ||
4638 | @@ -231,9 +231,9 @@ | |||
4639 | 231 | * Remove a number of files | 231 | * Remove a number of files |
4640 | 232 | * \throw ZipOperationError | 232 | * \throw ZipOperationError |
4641 | 233 | */ | 233 | */ |
4643 | 234 | void ZipFilesystem::Unlink(const std::string & filename) { | 234 | void ZipFilesystem::fs_unlink(const std::string & filename) { |
4644 | 235 | throw ZipOperationError | 235 | throw ZipOperationError |
4646 | 236 | ("ZipFilesystem::Unlink", | 236 | ("ZipFilesystem::unlink", |
4647 | 237 | filename, | 237 | filename, |
4648 | 238 | m_zipfilename, | 238 | m_zipfilename, |
4649 | 239 | "unlinking is not supported inside zipfiles"); | 239 | "unlinking is not supported inside zipfiles"); |
4650 | @@ -243,11 +243,11 @@ | |||
4651 | 243 | * Create this directory if it doesn't exist, throws an error | 243 | * Create this directory if it doesn't exist, throws an error |
4652 | 244 | * if the dir can't be created or if a file with this name exists | 244 | * if the dir can't be created or if a file with this name exists |
4653 | 245 | */ | 245 | */ |
4656 | 246 | void ZipFilesystem::EnsureDirectoryExists(const std::string & dirname) { | 246 | void ZipFilesystem::ensure_directory_exists(const std::string & dirname) { |
4657 | 247 | if (FileExists(dirname) && IsDirectory(dirname)) | 247 | if (file_exists(dirname) && is_directory(dirname)) |
4658 | 248 | return; | 248 | return; |
4659 | 249 | 249 | ||
4661 | 250 | MakeDirectory(dirname); | 250 | make_directory(dirname); |
4662 | 251 | } | 251 | } |
4663 | 252 | 252 | ||
4664 | 253 | /** | 253 | /** |
4665 | @@ -255,11 +255,11 @@ | |||
4666 | 255 | * if a file is in the way or if the creation fails. | 255 | * if a file is in the way or if the creation fails. |
4667 | 256 | * | 256 | * |
4668 | 257 | * Pleas note, this function does not honor parents, | 257 | * Pleas note, this function does not honor parents, |
4670 | 258 | * MakeDirectory("onedir/otherdir/onemoredir") will fail | 258 | * make_directory("onedir/otherdir/onemoredir") will fail |
4671 | 259 | * if either ondir or otherdir is missing | 259 | * if either ondir or otherdir is missing |
4672 | 260 | */ | 260 | */ |
4675 | 261 | void ZipFilesystem::MakeDirectory(const std::string & dirname) { | 261 | void ZipFilesystem::make_directory(const std::string & dirname) { |
4676 | 262 | m_OpenZip(); | 262 | m_open_zip(); |
4677 | 263 | 263 | ||
4678 | 264 | zip_fileinfo zi; | 264 | zip_fileinfo zi; |
4679 | 265 | 265 | ||
4680 | @@ -296,23 +296,23 @@ | |||
4681 | 296 | break; | 296 | break; |
4682 | 297 | case ZIP_ERRNO: | 297 | case ZIP_ERRNO: |
4683 | 298 | throw FileError | 298 | throw FileError |
4685 | 299 | ("ZipFilesystem::MakeDirectory", complete_filename, strerror(errno)); | 299 | ("ZipFilesystem::make_directory", complete_filename, strerror(errno)); |
4686 | 300 | default: | 300 | default: |
4687 | 301 | throw FileError | 301 | throw FileError |
4689 | 302 | ("ZipFilesystem::MakeDirectory", complete_filename); | 302 | ("ZipFilesystem::make_directory", complete_filename); |
4690 | 303 | } | 303 | } |
4691 | 304 | 304 | ||
4692 | 305 | zipCloseFileInZip(m_zipfile); | 305 | zipCloseFileInZip(m_zipfile); |
4693 | 306 | } | 306 | } |
4694 | 307 | 307 | ||
4695 | 308 | /** | 308 | /** |
4697 | 309 | * Read the given file into alloced memory; called by FileRead::Open. | 309 | * Read the given file into alloced memory; called by FileRead::open. |
4698 | 310 | * \throw FileNotFoundError if the file couldn't be opened. | 310 | * \throw FileNotFoundError if the file couldn't be opened. |
4699 | 311 | */ | 311 | */ |
4702 | 312 | void * ZipFilesystem::Load(const std::string & fname, size_t & length) { | 312 | void * ZipFilesystem::load(const std::string & fname, size_t & length) { |
4703 | 313 | if (!FileExists(fname.c_str()) || IsDirectory(fname.c_str())) | 313 | if (!file_exists(fname.c_str()) || is_directory(fname.c_str())) |
4704 | 314 | throw ZipOperationError | 314 | throw ZipOperationError |
4706 | 315 | ("ZipFilesystem::Load", | 315 | ("ZipFilesystem::load", |
4707 | 316 | fname, | 316 | fname, |
4708 | 317 | m_zipfilename, | 317 | m_zipfilename, |
4709 | 318 | "could not open file from zipfile"); | 318 | "could not open file from zipfile"); |
4710 | @@ -330,7 +330,7 @@ | |||
4711 | 330 | char buf[200]; | 330 | char buf[200]; |
4712 | 331 | snprintf(buf, sizeof(buf), "read error %i", len); | 331 | snprintf(buf, sizeof(buf), "read error %i", len); |
4713 | 332 | throw ZipOperationError | 332 | throw ZipOperationError |
4715 | 333 | ("ZipFilesystem::Load", | 333 | ("ZipFilesystem::load", |
4716 | 334 | fname, | 334 | fname, |
4717 | 335 | m_zipfilename, | 335 | m_zipfilename, |
4718 | 336 | buf); | 336 | buf); |
4719 | @@ -357,13 +357,13 @@ | |||
4720 | 357 | * Write the given block of memory to the repository. | 357 | * Write the given block of memory to the repository. |
4721 | 358 | * Throws an exception if it fails. | 358 | * Throws an exception if it fails. |
4722 | 359 | */ | 359 | */ |
4724 | 360 | void ZipFilesystem::Write | 360 | void ZipFilesystem::write |
4725 | 361 | (const std::string & fname, void const * const data, int32_t const length) | 361 | (const std::string & fname, void const * const data, int32_t const length) |
4726 | 362 | { | 362 | { |
4727 | 363 | std::string filename = fname; | 363 | std::string filename = fname; |
4728 | 364 | std::replace(filename.begin(), filename.end(), '\\', '/'); | 364 | std::replace(filename.begin(), filename.end(), '\\', '/'); |
4729 | 365 | 365 | ||
4731 | 366 | m_OpenZip(); | 366 | m_open_zip(); |
4732 | 367 | 367 | ||
4733 | 368 | zip_fileinfo zi; | 368 | zip_fileinfo zi; |
4734 | 369 | 369 | ||
4735 | @@ -389,7 +389,7 @@ | |||
4736 | 389 | break; | 389 | break; |
4737 | 390 | default: | 390 | default: |
4738 | 391 | throw ZipOperationError | 391 | throw ZipOperationError |
4740 | 392 | ("ZipFilesystem::Write", complete_filename, m_zipfilename); | 392 | ("ZipFilesystem::write", complete_filename, m_zipfilename); |
4741 | 393 | } | 393 | } |
4742 | 394 | 394 | ||
4743 | 395 | switch (zipWriteInFileInZip (m_zipfile, data, length)) { | 395 | switch (zipWriteInFileInZip (m_zipfile, data, length)) { |
4744 | @@ -397,10 +397,10 @@ | |||
4745 | 397 | break; | 397 | break; |
4746 | 398 | case ZIP_ERRNO: | 398 | case ZIP_ERRNO: |
4747 | 399 | throw FileError | 399 | throw FileError |
4749 | 400 | ("ZipFilesystem::Write", complete_filename, strerror(errno)); | 400 | ("ZipFilesystem::write", complete_filename, strerror(errno)); |
4750 | 401 | default: | 401 | default: |
4751 | 402 | throw FileError | 402 | throw FileError |
4753 | 403 | ("ZipFilesystem::Write", complete_filename); | 403 | ("ZipFilesystem::write", complete_filename); |
4754 | 404 | } | 404 | } |
4755 | 405 | 405 | ||
4756 | 406 | zipCloseFileInZip(m_zipfile); | 406 | zipCloseFileInZip(m_zipfile); |
4757 | @@ -413,12 +413,12 @@ | |||
4758 | 413 | ZipFilesystem::ZipStreamRead::ZipStreamRead(zipFile file, ZipFilesystem* zipfs) | 413 | ZipFilesystem::ZipStreamRead::ZipStreamRead(zipFile file, ZipFilesystem* zipfs) |
4759 | 414 | : m_unzipfile(file), m_zipfs(zipfs) {} | 414 | : m_unzipfile(file), m_zipfs(zipfs) {} |
4760 | 415 | ZipFilesystem::ZipStreamRead::~ZipStreamRead() { | 415 | ZipFilesystem::ZipStreamRead::~ZipStreamRead() { |
4762 | 416 | m_zipfs->m_Close(); | 416 | m_zipfs->m_close(); |
4763 | 417 | } | 417 | } |
4764 | 418 | 418 | ||
4766 | 419 | size_t ZipFilesystem::ZipStreamRead::Data(void* data, size_t bufsize) | 419 | size_t ZipFilesystem::ZipStreamRead::data(void* read_data, size_t bufsize) |
4767 | 420 | { | 420 | { |
4769 | 421 | int copied = unzReadCurrentFile(m_unzipfile, data, bufsize); | 421 | int copied = unzReadCurrentFile(m_unzipfile, read_data, bufsize); |
4770 | 422 | if (copied < 0) { | 422 | if (copied < 0) { |
4771 | 423 | throw new DataError("Failed to read from zip file"); | 423 | throw new DataError("Failed to read from zip file"); |
4772 | 424 | } | 424 | } |
4773 | @@ -427,21 +427,21 @@ | |||
4774 | 427 | } | 427 | } |
4775 | 428 | return copied; | 428 | return copied; |
4776 | 429 | } | 429 | } |
4778 | 430 | bool ZipFilesystem::ZipStreamRead::EndOfFile() const | 430 | bool ZipFilesystem::ZipStreamRead::end_of_file() const |
4779 | 431 | { | 431 | { |
4780 | 432 | return unzReadCurrentFile(m_unzipfile, nullptr, 1) == 0; | 432 | return unzReadCurrentFile(m_unzipfile, nullptr, 1) == 0; |
4781 | 433 | } | 433 | } |
4782 | 434 | 434 | ||
4785 | 435 | StreamRead* ZipFilesystem::OpenStreamRead(const std::string& fname) { | 435 | StreamRead* ZipFilesystem::open_stream_read(const std::string& fname) { |
4786 | 436 | if (!FileExists(fname.c_str()) || IsDirectory(fname.c_str())) | 436 | if (!file_exists(fname.c_str()) || is_directory(fname.c_str())) |
4787 | 437 | throw ZipOperationError | 437 | throw ZipOperationError |
4789 | 438 | ("ZipFilesystem::Load", | 438 | ("ZipFilesystem::load", |
4790 | 439 | fname, | 439 | fname, |
4791 | 440 | m_zipfilename, | 440 | m_zipfilename, |
4792 | 441 | "could not open file from zipfile"); | 441 | "could not open file from zipfile"); |
4793 | 442 | 442 | ||
4794 | 443 | int32_t method; | 443 | int32_t method; |
4796 | 444 | m_OpenUnzip(); | 444 | m_open_unzip(); |
4797 | 445 | int result = unzOpenCurrentFile3(m_unzipfile, &method, nullptr, 1, nullptr); | 445 | int result = unzOpenCurrentFile3(m_unzipfile, &method, nullptr, 1, nullptr); |
4798 | 446 | switch (result) { | 446 | switch (result) { |
4799 | 447 | case ZIP_OK: | 447 | case ZIP_OK: |
4800 | @@ -461,12 +461,12 @@ | |||
4801 | 461 | : m_zipfile(file), m_zipfs(zipfs) {} | 461 | : m_zipfile(file), m_zipfs(zipfs) {} |
4802 | 462 | ZipFilesystem::ZipStreamWrite::~ZipStreamWrite() | 462 | ZipFilesystem::ZipStreamWrite::~ZipStreamWrite() |
4803 | 463 | { | 463 | { |
4805 | 464 | m_zipfs->m_Close(); | 464 | m_zipfs->m_close(); |
4806 | 465 | } | 465 | } |
4807 | 466 | 466 | ||
4809 | 467 | void ZipFilesystem::ZipStreamWrite::Data(const void* const data, const size_t size) | 467 | void ZipFilesystem::ZipStreamWrite::data(const void* const write_data, const size_t size) |
4810 | 468 | { | 468 | { |
4812 | 469 | int result = zipWriteInFileInZip(m_zipfile, data, size); | 469 | int result = zipWriteInFileInZip(m_zipfile, write_data, size); |
4813 | 470 | switch (result) { | 470 | switch (result) { |
4814 | 471 | case ZIP_OK: | 471 | case ZIP_OK: |
4815 | 472 | break; | 472 | break; |
4816 | @@ -475,8 +475,8 @@ | |||
4817 | 475 | } | 475 | } |
4818 | 476 | } | 476 | } |
4819 | 477 | 477 | ||
4822 | 478 | StreamWrite * ZipFilesystem::OpenStreamWrite(const std::string & fname) { | 478 | StreamWrite * ZipFilesystem::open_stream_write(const std::string & fname) { |
4823 | 479 | m_OpenZip(); | 479 | m_open_zip(); |
4824 | 480 | 480 | ||
4825 | 481 | zip_fileinfo zi; | 481 | zip_fileinfo zi; |
4826 | 482 | 482 | ||
4827 | @@ -510,7 +510,7 @@ | |||
4828 | 510 | /** | 510 | /** |
4829 | 511 | * Private Functions below | 511 | * Private Functions below |
4830 | 512 | */ | 512 | */ |
4832 | 513 | void ZipFilesystem::m_Close() { | 513 | void ZipFilesystem::m_close() { |
4833 | 514 | if (m_state == STATE_ZIPPING) | 514 | if (m_state == STATE_ZIPPING) |
4834 | 515 | zipClose(m_zipfile, nullptr); | 515 | zipClose(m_zipfile, nullptr); |
4835 | 516 | else if (m_state == STATE_UNZIPPPING) | 516 | else if (m_state == STATE_UNZIPPPING) |
4836 | @@ -522,11 +522,11 @@ | |||
4837 | 522 | /** | 522 | /** |
4838 | 523 | * Open a zipfile for compressing | 523 | * Open a zipfile for compressing |
4839 | 524 | */ | 524 | */ |
4841 | 525 | void ZipFilesystem::m_OpenZip() { | 525 | void ZipFilesystem::m_open_zip() { |
4842 | 526 | if (m_state == STATE_ZIPPING) | 526 | if (m_state == STATE_ZIPPING) |
4843 | 527 | return; | 527 | return; |
4844 | 528 | 528 | ||
4846 | 529 | m_Close(); | 529 | m_close(); |
4847 | 530 | 530 | ||
4848 | 531 | m_zipfile = zipOpen(m_zipfilename.c_str(), APPEND_STATUS_ADDINZIP); | 531 | m_zipfile = zipOpen(m_zipfilename.c_str(), APPEND_STATUS_ADDINZIP); |
4849 | 532 | if (!m_zipfile) { | 532 | if (!m_zipfile) { |
4850 | @@ -541,25 +541,25 @@ | |||
4851 | 541 | * Open a zipfile for extraction | 541 | * Open a zipfile for extraction |
4852 | 542 | * \throw FileTypeError | 542 | * \throw FileTypeError |
4853 | 543 | */ | 543 | */ |
4855 | 544 | void ZipFilesystem::m_OpenUnzip() { | 544 | void ZipFilesystem::m_open_unzip() { |
4856 | 545 | if (m_state == STATE_UNZIPPPING) | 545 | if (m_state == STATE_UNZIPPPING) |
4857 | 546 | return; | 546 | return; |
4858 | 547 | 547 | ||
4860 | 548 | m_Close(); | 548 | m_close(); |
4861 | 549 | 549 | ||
4862 | 550 | m_unzipfile = unzOpen(m_zipfilename.c_str()); | 550 | m_unzipfile = unzOpen(m_zipfilename.c_str()); |
4863 | 551 | if (!m_unzipfile) | 551 | if (!m_unzipfile) |
4864 | 552 | throw FileTypeError | 552 | throw FileTypeError |
4866 | 553 | ("ZipFilesystem::m_OpenUnzip", m_zipfilename, "not a .zip file"); | 553 | ("ZipFilesystem::m_open_unzip", m_zipfilename, "not a .zip file"); |
4867 | 554 | 554 | ||
4868 | 555 | m_state = STATE_UNZIPPPING; | 555 | m_state = STATE_UNZIPPPING; |
4869 | 556 | } | 556 | } |
4870 | 557 | 557 | ||
4872 | 558 | void ZipFilesystem::Rename(const std::string &, const std::string &) { | 558 | void ZipFilesystem::fs_rename(const std::string &, const std::string &) { |
4873 | 559 | throw wexception("rename inside zip FS is not implemented yet"); | 559 | throw wexception("rename inside zip FS is not implemented yet"); |
4874 | 560 | } | 560 | } |
4875 | 561 | 561 | ||
4877 | 562 | unsigned long long ZipFilesystem::DiskSpace() { | 562 | unsigned long long ZipFilesystem::disk_space() { |
4878 | 563 | return 0; | 563 | return 0; |
4879 | 564 | } | 564 | } |
4880 | 565 | 565 | ||
4881 | 566 | 566 | ||
4882 | === modified file 'src/io/filesystem/zip_filesystem.h' | |||
4883 | --- src/io/filesystem/zip_filesystem.h 2014-07-26 10:43:23 +0000 | |||
4884 | +++ src/io/filesystem/zip_filesystem.h 2014-09-29 14:39:47 +0000 | |||
4885 | @@ -35,40 +35,40 @@ | |||
4886 | 35 | explicit ZipFilesystem(const std::string &); | 35 | explicit ZipFilesystem(const std::string &); |
4887 | 36 | virtual ~ZipFilesystem(); | 36 | virtual ~ZipFilesystem(); |
4888 | 37 | 37 | ||
4899 | 38 | bool IsWritable() const override; | 38 | bool is_writable() const override; |
4900 | 39 | 39 | ||
4901 | 40 | std::set<std::string> ListDirectory(const std::string& path) override; | 40 | std::set<std::string> list_directory(const std::string& path) override; |
4902 | 41 | 41 | ||
4903 | 42 | bool IsDirectory(const std::string & path) override; | 42 | bool is_directory(const std::string & path) override; |
4904 | 43 | bool FileExists (const std::string & path) override; | 43 | bool file_exists (const std::string & path) override; |
4905 | 44 | 44 | ||
4906 | 45 | void * Load(const std::string & fname, size_t & length) override; | 45 | void * load(const std::string & fname, size_t & length) override; |
4907 | 46 | 46 | ||
4908 | 47 | virtual void Write | 47 | virtual void write |
4909 | 48 | (const std::string & fname, void const * data, int32_t length) override; | 48 | (const std::string & fname, void const * data, int32_t length) override; |
4928 | 49 | void EnsureDirectoryExists(const std::string & dirname) override; | 49 | void ensure_directory_exists(const std::string & fs_dirname) override; |
4929 | 50 | void MakeDirectory (const std::string & dirname) override; | 50 | void make_directory (const std::string & fs_dirname) override; |
4930 | 51 | 51 | ||
4931 | 52 | virtual StreamRead * OpenStreamRead | 52 | virtual StreamRead * open_stream_read |
4932 | 53 | (const std::string & fname) override; | 53 | (const std::string & fname) override; |
4933 | 54 | virtual StreamWrite * OpenStreamWrite | 54 | virtual StreamWrite * open_stream_write |
4934 | 55 | (const std::string & fname) override; | 55 | (const std::string & fname) override; |
4935 | 56 | 56 | ||
4936 | 57 | FileSystem * MakeSubFileSystem(const std::string & dirname) override; | 57 | FileSystem * make_sub_file_system(const std::string & fs_dirname) override; |
4937 | 58 | FileSystem * CreateSubFileSystem(const std::string & dirname, Type) override; | 58 | FileSystem * create_sub_file_system(const std::string & fs_dirname, Type) override; |
4938 | 59 | void Unlink(const std::string & filename) override; | 59 | void fs_unlink(const std::string & fs_filename) override; |
4939 | 60 | void Rename(const std::string &, const std::string &) override; | 60 | void fs_rename(const std::string &, const std::string &) override; |
4940 | 61 | 61 | ||
4941 | 62 | unsigned long long DiskSpace() override; | 62 | unsigned long long disk_space() override; |
4942 | 63 | 63 | ||
4943 | 64 | static FileSystem * CreateFromDirectory(const std::string & directory); | 64 | static FileSystem * create_from_directory(const std::string & directory); |
4944 | 65 | 65 | ||
4945 | 66 | std::string getBasename() override {return m_zipfilename;} | 66 | std::string get_basename() override {return m_zipfilename;} |
4946 | 67 | 67 | ||
4947 | 68 | protected: | 68 | protected: |
4951 | 69 | void m_OpenUnzip(); | 69 | void m_open_unzip(); |
4952 | 70 | void m_OpenZip(); | 70 | void m_open_zip(); |
4953 | 71 | void m_Close(); | 71 | void m_close(); |
4954 | 72 | std::string strip_basename(std::string); | 72 | std::string strip_basename(std::string); |
4955 | 73 | 73 | ||
4956 | 74 | enum State { | 74 | enum State { |
4957 | @@ -90,8 +90,8 @@ | |||
4958 | 90 | struct ZipStreamRead : StreamRead { | 90 | struct ZipStreamRead : StreamRead { |
4959 | 91 | explicit ZipStreamRead(zipFile file, ZipFilesystem* zipfs); | 91 | explicit ZipStreamRead(zipFile file, ZipFilesystem* zipfs); |
4960 | 92 | virtual ~ZipStreamRead(); | 92 | virtual ~ZipStreamRead(); |
4963 | 93 | size_t Data(void* data, size_t bufsize) override; | 93 | size_t data(void* data, size_t bufsize) override; |
4964 | 94 | bool EndOfFile() const override; | 94 | bool end_of_file() const override; |
4965 | 95 | private: | 95 | private: |
4966 | 96 | zipFile m_unzipfile; | 96 | zipFile m_unzipfile; |
4967 | 97 | ZipFilesystem* m_zipfs; | 97 | ZipFilesystem* m_zipfs; |
4968 | @@ -99,7 +99,7 @@ | |||
4969 | 99 | struct ZipStreamWrite : StreamWrite { | 99 | struct ZipStreamWrite : StreamWrite { |
4970 | 100 | explicit ZipStreamWrite(zipFile file, ZipFilesystem* zipfs); | 100 | explicit ZipStreamWrite(zipFile file, ZipFilesystem* zipfs); |
4971 | 101 | virtual ~ZipStreamWrite(); | 101 | virtual ~ZipStreamWrite(); |
4973 | 102 | void Data(const void* const data, size_t size) override; | 102 | void data(const void* const data, size_t size) override; |
4974 | 103 | private: | 103 | private: |
4975 | 104 | zipFile m_zipfile; | 104 | zipFile m_zipfile; |
4976 | 105 | ZipFilesystem* m_zipfs; | 105 | ZipFilesystem* m_zipfs; |
4977 | 106 | 106 | ||
4978 | === modified file 'src/io/filewrite.cc' | |||
4979 | --- src/io/filewrite.cc 2014-07-20 07:44:22 +0000 | |||
4980 | +++ src/io/filewrite.cc 2014-09-29 14:39:47 +0000 | |||
4981 | @@ -26,39 +26,39 @@ | |||
4982 | 26 | } | 26 | } |
4983 | 27 | 27 | ||
4984 | 28 | FileWrite::~FileWrite() { | 28 | FileWrite::~FileWrite() { |
4986 | 29 | Clear(); | 29 | clear(); |
4987 | 30 | } | 30 | } |
4988 | 31 | 31 | ||
4990 | 32 | void FileWrite::Clear() { | 32 | void FileWrite::clear() { |
4991 | 33 | free(data_); | 33 | free(data_); |
4992 | 34 | data_ = nullptr; | 34 | data_ = nullptr; |
4993 | 35 | length_ = max_size_ = 0; | 35 | length_ = max_size_ = 0; |
4994 | 36 | filepos_ = 0; | 36 | filepos_ = 0; |
4995 | 37 | } | 37 | } |
4996 | 38 | 38 | ||
4997 | 39 | void FileWrite::Write(FileSystem& fs, char const* const filename) { | ||
4998 | 40 | fs.Write(filename, data_, length_); | ||
4999 | 41 | Clear(); | ||
5000 | 42 | } |
The diff has been truncated for viewing.
Awesome! Code base is getting in ever better shape. Now formatting is the biggest remaining issue that needs solving.