Merge lp:~widelands-dev/widelands/bug-1343299 into lp:widelands

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
Reviewer Review Type Date Requested Status
SirVer Approve
Review via email: mp+236329@code.launchpad.net

Description of the change

Refactoring: removed CamelCase etc from function names.

To post a comment you must log in.
Revision history for this message
SirVer (sirver) wrote :

Awesome! Code base is getting in ever better shape. Now formatting is the biggest remaining issue that needs solving.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/ai/ai_help_structs.cc'
--- src/ai/ai_help_structs.cc 2014-07-20 07:47:15 +0000
+++ src/ai/ai_help_structs.cc 2014-09-29 14:39:47 +0000
@@ -60,7 +60,7 @@
60 return true;60 return true;
61}61}
6262
63bool CheckStepRoadAI::reachabledest(Map& map, FCoords const dest) const {63bool CheckStepRoadAI::reachable_dest(Map& map, FCoords const dest) const {
64 NodeCaps const caps = dest.field->nodecaps();64 NodeCaps const caps = dest.field->nodecaps();
6565
66 if (!(caps & movecaps_)) {66 if (!(caps & movecaps_)) {
6767
=== modified file 'src/ai/ai_help_structs.h'
--- src/ai/ai_help_structs.h 2014-09-10 08:55:04 +0000
+++ src/ai/ai_help_structs.h 2014-09-29 14:39:47 +0000
@@ -48,7 +48,7 @@
48 }48 }
4949
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;
51 bool reachabledest(Map&, FCoords dest) const;51 bool reachable_dest(Map&, FCoords dest) const;
5252
53 Player* player_;53 Player* player_;
54 uint8_t movecaps_;54 uint8_t movecaps_;
5555
=== modified file 'src/ai/computer_player.cc'
--- src/ai/computer_player.cc 2014-09-10 13:03:40 +0000
+++ src/ai/computer_player.cc 2014-09-29 14:39:47 +0000
@@ -50,7 +50,7 @@
50EmptyAI::EmptyAIImpl EmptyAI::implementation;50EmptyAI::EmptyAIImpl EmptyAI::implementation;
5151
52const ComputerPlayer::ImplementationVector &52const ComputerPlayer::ImplementationVector &
53ComputerPlayer::getImplementations()53ComputerPlayer::get_implementations()
54{54{
55 static std::vector<ComputerPlayer::Implementation const *> impls;55 static std::vector<ComputerPlayer::Implementation const *> impls;
5656
@@ -64,10 +64,10 @@
64 return impls;64 return impls;
65}65}
6666
67const ComputerPlayer::Implementation * ComputerPlayer::getImplementation67const ComputerPlayer::Implementation * ComputerPlayer::get_implementation
68 (const std::string & name)68 (const std::string & name)
69{69{
70 const ImplementationVector & vec = getImplementations();70 const ImplementationVector & vec = get_implementations();
7171
72 for (const ComputerPlayer::Implementation* implementation : vec) {72 for (const ComputerPlayer::Implementation* implementation : vec) {
73 if (implementation->name == name) {73 if (implementation->name == name) {
7474
=== modified file 'src/ai/computer_player.h'
--- src/ai/computer_player.h 2014-09-14 11:31:58 +0000
+++ src/ai/computer_player.h 2014-09-29 14:39:47 +0000
@@ -48,7 +48,7 @@
48 /**48 /**
49 * Interface to a concrete implementation, used to instantiate AIs.49 * Interface to a concrete implementation, used to instantiate AIs.
50 *50 *
51 * \see getImplementations()51 * \see get_implementations()
52 */52 */
53 struct Implementation {53 struct Implementation {
54 std::string name;54 std::string name;
@@ -61,12 +61,12 @@
61 /**61 /**
62 * Get a list of available AI implementations.62 * Get a list of available AI implementations.
63 */63 */
64 static const ImplementationVector & getImplementations();64 static const ImplementationVector & get_implementations();
6565
66 /**66 /**
67 * Get the best matching implementation for this name.67 * Get the best matching implementation for this name.
68 */68 */
69 static const Implementation * getImplementation(const std::string & name);69 static const Implementation * get_implementation(const std::string & name);
7070
71private:71private:
72 Widelands::Game & m_game;72 Widelands::Game & m_game;
7373
=== modified file 'src/ai/defaultai.cc'
--- src/ai/defaultai.cc 2014-09-14 11:31:58 +0000
+++ src/ai/defaultai.cc 2014-09-29 14:39:47 +0000
@@ -658,10 +658,10 @@
658658
659 if (v > 0 && dist > 0) {659 if (v > 0 && dist > 0) {
660660
661 field.military_capacity_ += militarysite->maxSoldierCapacity();661 field.military_capacity_ += militarysite->max_soldier_capacity();
662 field.military_presence_ += militarysite->stationedSoldiers().size();662 field.military_presence_ += militarysite->stationed_soldiers().size();
663663
664 if (!militarysite->stationedSoldiers().empty()) {664 if (!militarysite->stationed_soldiers().empty()) {
665 field.military_stationed_ += 1;665 field.military_stationed_ += 1;
666 }666 }
667667
@@ -2216,7 +2216,7 @@
2216 for (std::list<MilitarySiteObserver>::iterator it = militarysites.begin();2216 for (std::list<MilitarySiteObserver>::iterator it = militarysites.begin();
2217 it != militarysites.end();2217 it != militarysites.end();
2218 ++it)2218 ++it)
2219 if (it->site->stationedSoldiers().size() == 0)2219 if (it->site->stationed_soldiers().size() == 0)
2220 unstationed_milit_buildings_ += 1;2220 unstationed_milit_buildings_ += 1;
22212221
2222 // count militarysites in construction2222 // count militarysites in construction
@@ -2250,7 +2250,7 @@
2250 // as long as it is > 1 - BUT take care that there is a warehouse in the2250 // as long as it is > 1 - BUT take care that there is a warehouse in the
2251 // same economy where the thrown out soldiers can go to.2251 // same economy where the thrown out soldiers can go to.
2252 if (ms->economy().warehouses().size()) {2252 if (ms->economy().warehouses().size()) {
2253 uint32_t const j = ms->soldierCapacity();2253 uint32_t const j = ms->soldier_capacity();
22542254
2255 if (MilitarySite::kPrefersRookies != ms->get_soldier_preference()) {2255 if (MilitarySite::kPrefersRookies != ms->get_soldier_preference()) {
2256 game().send_player_militarysite_set_soldier_preference(2256 game().send_player_militarysite_set_soldier_preference(
@@ -2283,8 +2283,8 @@
2283 } else {2283 } else {
2284 // If an enemy is in sight and the number of stationed soldier is not2284 // If an enemy is in sight and the number of stationed soldier is not
2285 // at maximum - set it to maximum.2285 // at maximum - set it to maximum.
2286 uint32_t const j = ms->maxSoldierCapacity();2286 uint32_t const j = ms->max_soldier_capacity();
2287 uint32_t const k = ms->soldierCapacity();2287 uint32_t const k = ms->soldier_capacity();
22882288
2289 if (j > k)2289 if (j > k)
2290 // game().send_player_change_soldier_capacity(*ms, j - k);2290 // game().send_player_change_soldier_capacity(*ms, j - k);
@@ -2696,11 +2696,11 @@
2696 continue;2696 continue;
2697 }2697 }
26982698
2699 if (bld->canAttack()) {2699 if (bld->can_attack()) {
27002700
2701 // any_attackable_building=true;2701 // any_attackable_building=true;
27022702
2703 int32_t ta = player_->findAttackSoldiers(bld->base_flag());2703 int32_t ta = player_->find_attack_soldiers(bld->base_flag());
27042704
2705 if (type_ == NORMAL)2705 if (type_ == NORMAL)
2706 ta = ta * 2 / 3;2706 ta = ta * 2 / 3;
@@ -2708,24 +2708,24 @@
2708 if (ta < 1)2708 if (ta < 1)
2709 continue;2709 continue;
27102710
2711 int32_t const tc = ta - bld->presentSoldiers().size();2711 int32_t const tc = ta - bld->present_soldiers().size();
27122712
2713 if (bld->presentSoldiers().size() > 1)2713 if (bld->present_soldiers().size() > 1)
2714 defend_ready_enemies += bld->presentSoldiers().size() - 1;2714 defend_ready_enemies += bld->present_soldiers().size() - 1;
27152715
2716 if (tc > chance) {2716 if (tc > chance) {
2717 target = bld;2717 target = bld;
2718 chance = tc;2718 chance = tc;
2719 attackers = ta;2719 attackers = ta;
2720 defenders = bld->presentSoldiers().size();2720 defenders = bld->present_soldiers().size();
2721 }2721 }
2722 }2722 }
2723 } else if (upcast(Warehouse, wh, immovables.at(j).object)) {2723 } else if (upcast(Warehouse, wh, immovables.at(j).object)) {
2724 if (!player_->is_hostile(wh->owner()))2724 if (!player_->is_hostile(wh->owner()))
2725 continue;2725 continue;
27262726
2727 if (wh->canAttack()) {2727 if (wh->can_attack()) {
2728 int32_t ta = player_->findAttackSoldiers(wh->base_flag());2728 int32_t ta = player_->find_attack_soldiers(wh->base_flag());
27292729
2730 if (ta < 1)2730 if (ta < 1)
2731 continue;2731 continue;
27322732
=== modified file 'src/base/md5.h'
--- src/base/md5.h 2014-09-14 11:31:58 +0000
+++ src/base/md5.h 2014-09-29 14:39:47 +0000
@@ -65,8 +65,8 @@
65/**65/**
66 * This class is responsible for creating a streaming md5 checksum.66 * This class is responsible for creating a streaming md5 checksum.
67 * You simply pass it the data using stream operations, and if you want67 * You simply pass it the data using stream operations, and if you want
68 * to read the checksum, first call FinishChecksum(), followed by68 * to read the checksum, first call finish_checksum(), followed by
69 * GetChecksum().69 * get_checksum().
70 *70 *
71 * Instances of this class can be copied.71 * Instances of this class can be copied.
72 */72 */
@@ -93,24 +93,24 @@
93 ///93 ///
94 /// \param data data to compute chksum for94 /// \param data data to compute chksum for
95 /// \param size size of data95 /// \param size size of data
96 void Data(const void * const newdata, const size_t size) {96 void data(const void * const newdata, const size_t size) {
97 assert(can_handle_data);97 assert(can_handle_data);
98 md5_process_bytes(newdata, size, &ctx);98 md5_process_bytes(newdata, size, &ctx);
99 }99 }
100100
101 /// This function finishes the checksum calculation.101 /// This function finishes the checksum calculation.
102 /// After this, no more data may be written to the checksum.102 /// After this, no more data may be written to the checksum.
103 void FinishChecksum() {103 void finish_checksum() {
104 assert(can_handle_data);104 assert(can_handle_data);
105 can_handle_data = 0;105 can_handle_data = 0;
106 md5_finish_ctx(&ctx, sum.data);106 md5_finish_ctx(&ctx, sum.data);
107 }107 }
108108
109 /// Retrieve the checksum. Note that \ref FinishChecksum must be called109 /// Retrieve the checksum. Note that \ref finish_checksum must be called
110 /// before this function.110 /// before this function.
111 ///111 ///
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.
113 const Md5Checksum & GetChecksum() const {113 const Md5Checksum & get_checksum() const {
114 assert(!can_handle_data);114 assert(!can_handle_data);
115 return sum;115 return sum;
116 }116 }
117117
=== modified file 'src/chat/chat.h'
--- src/chat/chat.h 2014-07-16 07:44:33 +0000
+++ src/chat/chat.h 2014-09-29 14:39:47 +0000
@@ -62,14 +62,14 @@
62 virtual ~ChatProvider();62 virtual ~ChatProvider();
6363
64 // Send the given chat message. The message may or may not64 // Send the given chat message. The message may or may not
65 // appear in subsequent calls to \ref getMessages.65 // appear in subsequent calls to \ref get_messages.
66 virtual void send(const std::string &) = 0;66 virtual void send(const std::string &) = 0;
6767
68 // \return a (chronological) list of received chat messages.68 // \return a (chronological) list of received chat messages.
69 // This list need not be stable or monotonic. In other words,69 // This list need not be stable or monotonic. In other words,
70 // subsequent calls to this functions may return a smaller or70 // subsequent calls to this functions may return a smaller or
71 // greater number of chat messages.71 // greater number of chat messages.
72 virtual const std::vector<ChatMessage>& getMessages() const = 0;72 virtual const std::vector<ChatMessage>& get_messages() const = 0;
7373
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.
75 // TODO(sirver): this does not belong here. The receiver of the75 // TODO(sirver): this does not belong here. The receiver of the
7676
=== modified file 'src/economy/cmd_call_economy_balance.cc'
--- src/economy/cmd_call_economy_balance.cc 2014-09-10 08:55:04 +0000
+++ src/economy/cmd_call_economy_balance.cc 2014-09-29 14:39:47 +0000
@@ -53,24 +53,24 @@
53/**53/**
54 * Read and write54 * Read and write
55 */55 */
56void CmdCallEconomyBalance::Read56void CmdCallEconomyBalance::read
57 (FileRead & fr, EditorGameBase & egbase, MapObjectLoader & mol)57 (FileRead & fr, EditorGameBase & egbase, MapObjectLoader & mol)
58{58{
59 try {59 try {
60 uint16_t const packet_version = fr.Unsigned16();60 uint16_t const packet_version = fr.unsigned_16();
61 if (packet_version == CURRENT_CMD_CALL_ECONOMY_VERSION) {61 if (packet_version == CURRENT_CMD_CALL_ECONOMY_VERSION) {
62 GameLogicCommand::Read(fr, egbase, mol);62 GameLogicCommand::read(fr, egbase, mol);
63 uint32_t serial = fr.Unsigned32();63 uint32_t serial = fr.unsigned_32();
64 if (serial)64 if (serial)
65 m_flag = &mol.get<Flag>(serial);65 m_flag = &mol.get<Flag>(serial);
66 m_timerid = fr.Unsigned32();66 m_timerid = fr.unsigned_32();
67 } else if (packet_version == 1 || packet_version == 2) {67 } else if (packet_version == 1 || packet_version == 2) {
68 GameLogicCommand::Read(fr, egbase, mol);68 GameLogicCommand::read(fr, egbase, mol);
69 uint8_t const player_number = fr.Unsigned8();69 uint8_t const player_number = fr.unsigned_8();
70 if (Player * const player = egbase.get_player(player_number)) {70 if (Player * const player = egbase.get_player(player_number)) {
71 if (!fr.Unsigned8())71 if (!fr.unsigned_8())
72 throw wexception("0 is not allowed here");72 throw wexception("0 is not allowed here");
73 uint16_t const economy_number = fr.Unsigned16();73 uint16_t const economy_number = fr.unsigned_16();
74 if (economy_number < player->get_nr_economies())74 if (economy_number < player->get_nr_economies())
75 m_flag =75 m_flag =
76 player->get_economy_by_number(economy_number)76 player->get_economy_by_number(economy_number)
@@ -80,7 +80,7 @@
80 } else80 } else
81 throw wexception("invalid player number %u", player_number);81 throw wexception("invalid player number %u", player_number);
82 if (packet_version >= 2)82 if (packet_version >= 2)
83 m_timerid = fr.Unsigned32();83 m_timerid = fr.unsigned_32();
84 else84 else
85 m_timerid = 0;85 m_timerid = 0;
86 } else86 } else
@@ -90,18 +90,18 @@
90 throw wexception("call economy balance: %s", e.what());90 throw wexception("call economy balance: %s", e.what());
91 }91 }
92}92}
93void CmdCallEconomyBalance::Write93void CmdCallEconomyBalance::write
94 (FileWrite & fw, EditorGameBase & egbase, MapObjectSaver & mos)94 (FileWrite & fw, EditorGameBase & egbase, MapObjectSaver & mos)
95{95{
96 fw.Unsigned16(CURRENT_CMD_CALL_ECONOMY_VERSION);96 fw.unsigned_16(CURRENT_CMD_CALL_ECONOMY_VERSION);
9797
98 // Write Base Commands98 // Write Base Commands
99 GameLogicCommand::Write(fw, egbase, mos);99 GameLogicCommand::write(fw, egbase, mos);
100 if (Flag * const flag = m_flag.get(egbase))100 if (Flag * const flag = m_flag.get(egbase))
101 fw.Unsigned32(mos.get_object_file_index(*flag));101 fw.unsigned_32(mos.get_object_file_index(*flag));
102 else102 else
103 fw.Unsigned32(0);103 fw.unsigned_32(0);
104 fw.Unsigned32(m_timerid);104 fw.unsigned_32(m_timerid);
105}105}
106106
107}107}
108108
=== modified file 'src/economy/cmd_call_economy_balance.h'
--- src/economy/cmd_call_economy_balance.h 2014-09-10 08:55:04 +0000
+++ src/economy/cmd_call_economy_balance.h 2014-09-29 14:39:47 +0000
@@ -39,8 +39,8 @@
3939
40 uint8_t id() const override {return QUEUE_CMD_CALL_ECONOMY_BALANCE;}40 uint8_t id() const override {return QUEUE_CMD_CALL_ECONOMY_BALANCE;}
4141
42 void Write(FileWrite &, EditorGameBase &, MapObjectSaver &) override;42 void write(FileWrite &, EditorGameBase &, MapObjectSaver &) override;
43 void Read (FileRead &, EditorGameBase &, MapObjectLoader &) override;43 void read (FileRead &, EditorGameBase &, MapObjectLoader &) override;
4444
45private:45private:
46 OPtr<Flag> m_flag;46 OPtr<Flag> m_flag;
4747
=== modified file 'src/economy/economy.cc'
--- src/economy/economy.cc 2014-09-14 11:31:58 +0000
+++ src/economy/economy.cc 2014-09-29 14:39:47 +0000
@@ -718,9 +718,9 @@
718 // alerts, so add info to the sync stream here.718 // alerts, so add info to the sync stream here.
719 {719 {
720 ::StreamWrite & ss = game.syncstream();720 ::StreamWrite & ss = game.syncstream();
721 ss.Unsigned8 (req.get_type ());721 ss.unsigned_8 (req.get_type ());
722 ss.Unsigned8 (req.get_index ());722 ss.unsigned_8 (req.get_index ());
723 ss.Unsigned32(req.target ().serial());723 ss.unsigned_32(req.target ().serial());
724 }724 }
725725
726 int32_t cost; // estimated time in milliseconds to fulfill Request726 int32_t cost; // estimated time in milliseconds to fulfill Request
@@ -1017,12 +1017,12 @@
1017 // to avoid potential future problems caused by the m_supplies changing1017 // to avoid potential future problems caused by the m_supplies changing
1018 // under us in some way.1018 // under us in some way.
1019 ::StreamWrite & ss = game.syncstream();1019 ::StreamWrite & ss = game.syncstream();
1020 ss.Unsigned32(0x02decafa); // appears as facade02 in sync stream1020 ss.unsigned_32(0x02decafa); // appears as facade02 in sync stream
1021 ss.Unsigned32(assignments.size());1021 ss.unsigned_32(assignments.size());
10221022
1023 for (const std::pair<Supply *, Warehouse *>& temp_assignment : assignments) {1023 for (const std::pair<Supply *, Warehouse *>& temp_assignment : assignments) {
1024 ss.Unsigned32(temp_assignment.first->get_position(game)->serial());1024 ss.unsigned_32(temp_assignment.first->get_position(game)->serial());
1025 ss.Unsigned32(temp_assignment.second->serial());1025 ss.unsigned_32(temp_assignment.second->serial());
10261026
1027 temp_assignment.first->send_to_storage(game, temp_assignment.second);1027 temp_assignment.first->send_to_storage(game, temp_assignment.second);
1028 }1028 }
10291029
=== modified file 'src/economy/economy_data_packet.cc'
--- src/economy/economy_data_packet.cc 2014-09-10 16:57:31 +0000
+++ src/economy/economy_data_packet.cc 2014-09-29 14:39:47 +0000
@@ -31,20 +31,20 @@
3131
32namespace Widelands {32namespace Widelands {
3333
34void EconomyDataPacket::Read(FileRead & fr)34void EconomyDataPacket::read(FileRead & fr)
35{35{
36 uint16_t const version = fr.Unsigned16();36 uint16_t const version = fr.unsigned_16();
3737
38 try {38 try {
39 if (1 <= version && version <= CURRENT_ECONOMY_VERSION) {39 if (1 <= version && version <= CURRENT_ECONOMY_VERSION) {
40 if (2 <= version)40 if (2 <= version)
41 try {41 try {
42 const TribeDescr & tribe = m_eco->owner().tribe();42 const TribeDescr & tribe = m_eco->owner().tribe();
43 while (Time const last_modified = fr.Unsigned32()) {43 while (Time const last_modified = fr.unsigned_32()) {
44 char const * const type_name = fr.CString();44 char const * const type_name = fr.c_string();
45 uint32_t const permanent = fr.Unsigned32();45 uint32_t const permanent = fr.unsigned_32();
46 if (version <= 2)46 if (version <= 2)
47 fr.Unsigned32();47 fr.unsigned_32();
48 WareIndex i = tribe.ware_index(type_name);48 WareIndex i = tribe.ware_index(type_name);
49 if (i != INVALID_INDEX) {49 if (i != INVALID_INDEX) {
50 if (tribe.get_ware_descr(i)->default_target_quantity() ==50 if (tribe.get_ware_descr(i)->default_target_quantity() ==
@@ -91,7 +91,7 @@
91 } catch (const WException & e) {91 } catch (const WException & e) {
92 throw GameDataError("target quantities: %s", e.what());92 throw GameDataError("target quantities: %s", e.what());
93 }93 }
94 m_eco->m_request_timerid = fr.Unsigned32();94 m_eco->m_request_timerid = fr.unsigned_32();
95 } else {95 } else {
96 throw GameDataError("unknown version %u", version);96 throw GameDataError("unknown version %u", version);
97 }97 }
@@ -100,18 +100,18 @@
100 }100 }
101}101}
102102
103void EconomyDataPacket::Write(FileWrite & fw)103void EconomyDataPacket::write(FileWrite & fw)
104{104{
105 fw.Unsigned16(CURRENT_ECONOMY_VERSION);105 fw.unsigned_16(CURRENT_ECONOMY_VERSION);
106 const TribeDescr & tribe = m_eco->owner().tribe();106 const TribeDescr & tribe = m_eco->owner().tribe();
107 for (WareIndex i = tribe.get_nrwares(); i;) {107 for (WareIndex i = tribe.get_nrwares(); i;) {
108 --i;108 --i;
109 const Economy::TargetQuantity & tq =109 const Economy::TargetQuantity & tq =
110 m_eco->m_ware_target_quantities[i];110 m_eco->m_ware_target_quantities[i];
111 if (Time const last_modified = tq.last_modified) {111 if (Time const last_modified = tq.last_modified) {
112 fw.Unsigned32(last_modified);112 fw.unsigned_32(last_modified);
113 fw.CString(tribe.get_ware_descr(i)->name());113 fw.c_string(tribe.get_ware_descr(i)->name());
114 fw.Unsigned32(tq.permanent);114 fw.unsigned_32(tq.permanent);
115 }115 }
116 }116 }
117 for (WareIndex i = tribe.get_nrworkers(); i;) {117 for (WareIndex i = tribe.get_nrworkers(); i;) {
@@ -119,13 +119,13 @@
119 const Economy::TargetQuantity & tq =119 const Economy::TargetQuantity & tq =
120 m_eco->m_worker_target_quantities[i];120 m_eco->m_worker_target_quantities[i];
121 if (Time const last_modified = tq.last_modified) {121 if (Time const last_modified = tq.last_modified) {
122 fw.Unsigned32(last_modified);122 fw.unsigned_32(last_modified);
123 fw.CString(tribe.get_worker_descr(i)->name());123 fw.c_string(tribe.get_worker_descr(i)->name());
124 fw.Unsigned32(tq.permanent);124 fw.unsigned_32(tq.permanent);
125 }125 }
126 }126 }
127 fw.Unsigned32(0); // terminator127 fw.unsigned_32(0); // terminator
128 fw.Unsigned32(m_eco->m_request_timerid);128 fw.unsigned_32(m_eco->m_request_timerid);
129}129}
130130
131}131}
132132
=== modified file 'src/economy/economy_data_packet.h'
--- src/economy/economy_data_packet.h 2014-09-10 07:57:29 +0000
+++ src/economy/economy_data_packet.h 2014-09-29 14:39:47 +0000
@@ -33,8 +33,8 @@
33 public:33 public:
34 EconomyDataPacket(Economy * e) : m_eco(e) {}34 EconomyDataPacket(Economy * e) : m_eco(e) {}
3535
36 void Read(FileRead &);36 void read(FileRead &);
37 void Write(FileWrite &);37 void write(FileWrite &);
3838
39 private:39 private:
40 Economy * m_eco;40 Economy * m_eco;
4141
=== modified file 'src/economy/fleet.cc'
--- src/economy/fleet.cc 2014-09-10 08:55:04 +0000
+++ src/economy/fleet.cc 2014-09-29 14:39:47 +0000
@@ -692,22 +692,22 @@
692692
693 Fleet & fleet = get<Fleet>();693 Fleet & fleet = get<Fleet>();
694694
695 uint32_t nrships = fr.Unsigned32();695 uint32_t nrships = fr.unsigned_32();
696 m_ships.resize(nrships);696 m_ships.resize(nrships);
697 for (uint32_t i = 0; i < nrships; ++i)697 for (uint32_t i = 0; i < nrships; ++i)
698 m_ships[i] = fr.Unsigned32();698 m_ships[i] = fr.unsigned_32();
699699
700 uint32_t nrports = fr.Unsigned32();700 uint32_t nrports = fr.unsigned_32();
701 m_ports.resize(nrports);701 m_ports.resize(nrports);
702 for (uint32_t i = 0; i < nrports; ++i)702 for (uint32_t i = 0; i < nrports; ++i)
703 m_ports[i] = fr.Unsigned32();703 m_ports[i] = fr.unsigned_32();
704704
705 if (version >= 2) {705 if (version >= 2) {
706 fleet.m_act_pending = fr.Unsigned8();706 fleet.m_act_pending = fr.unsigned_8();
707 if (version < 3)707 if (version < 3)
708 fleet.m_act_pending = false;708 fleet.m_act_pending = false;
709 if (version < 4)709 if (version < 4)
710 fr.Unsigned32(); // m_roundrobin710 fr.unsigned_32(); // m_roundrobin
711 }711 }
712}712}
713713
@@ -756,9 +756,9 @@
756756
757 try {757 try {
758 // The header has been peeled away by the caller758 // The header has been peeled away by the caller
759 uint8_t const version = fr.Unsigned8();759 uint8_t const version = fr.unsigned_8();
760 if (1 <= version && version <= FLEET_SAVEGAME_VERSION) {760 if (1 <= version && version <= FLEET_SAVEGAME_VERSION) {
761 PlayerNumber owner_number = fr.Unsigned8();761 PlayerNumber owner_number = fr.unsigned_8();
762 if (!owner_number || owner_number > egbase.map().get_nrplayers())762 if (!owner_number || owner_number > egbase.map().get_nrplayers())
763 throw GameDataError763 throw GameDataError
764 ("owner number is %u but there are only %u players",764 ("owner number is %u but there are only %u players",
@@ -781,23 +781,23 @@
781781
782void Fleet::save(EditorGameBase & egbase, MapObjectSaver & mos, FileWrite & fw)782void Fleet::save(EditorGameBase & egbase, MapObjectSaver & mos, FileWrite & fw)
783{783{
784 fw.Unsigned8(HeaderFleet);784 fw.unsigned_8(HeaderFleet);
785 fw.Unsigned8(FLEET_SAVEGAME_VERSION);785 fw.unsigned_8(FLEET_SAVEGAME_VERSION);
786786
787 fw.Unsigned8(m_owner.player_number());787 fw.unsigned_8(m_owner.player_number());
788788
789 MapObject::save(egbase, mos, fw);789 MapObject::save(egbase, mos, fw);
790790
791 fw.Unsigned32(m_ships.size());791 fw.unsigned_32(m_ships.size());
792 for (const Ship * temp_ship : m_ships) {792 for (const Ship * temp_ship : m_ships) {
793 fw.Unsigned32(mos.get_object_file_index(*temp_ship));793 fw.unsigned_32(mos.get_object_file_index(*temp_ship));
794 }794 }
795 fw.Unsigned32(m_ports.size());795 fw.unsigned_32(m_ports.size());
796 for (const PortDock * temp_port : m_ports) {796 for (const PortDock * temp_port : m_ports) {
797 fw.Unsigned32(mos.get_object_file_index(*temp_port));797 fw.unsigned_32(mos.get_object_file_index(*temp_port));
798 }798 }
799799
800 fw.Unsigned8(m_act_pending);800 fw.unsigned_8(m_act_pending);
801}801}
802802
803} // namespace Widelands803} // namespace Widelands
804804
=== modified file 'src/economy/portdock.cc'
--- src/economy/portdock.cc 2014-09-10 10:18:46 +0000
+++ src/economy/portdock.cc 2014-09-29 14:39:47 +0000
@@ -478,29 +478,29 @@
478478
479 PortDock & pd = get<PortDock>();479 PortDock & pd = get<PortDock>();
480480
481 m_warehouse = fr.Unsigned32();481 m_warehouse = fr.unsigned_32();
482 uint16_t nrdockpoints = fr.Unsigned16();482 uint16_t nrdockpoints = fr.unsigned_16();
483483
484 pd.m_dockpoints.resize(nrdockpoints);484 pd.m_dockpoints.resize(nrdockpoints);
485 for (uint16_t i = 0; i < nrdockpoints; ++i) {485 for (uint16_t i = 0; i < nrdockpoints; ++i) {
486 pd.m_dockpoints[i] = ReadCoords32(&fr, egbase().map().extent());486 pd.m_dockpoints[i] = read_coords_32(&fr, egbase().map().extent());
487 pd.set_position(egbase(), pd.m_dockpoints[i]);487 pd.set_position(egbase(), pd.m_dockpoints[i]);
488 }488 }
489489
490 if (version >= 2) {490 if (version >= 2) {
491 pd.m_need_ship = fr.Unsigned8();491 pd.m_need_ship = fr.unsigned_8();
492492
493 m_waiting.resize(fr.Unsigned32());493 m_waiting.resize(fr.unsigned_32());
494 for (ShippingItem::Loader& shipping_loader : m_waiting) {494 for (ShippingItem::Loader& shipping_loader : m_waiting) {
495 shipping_loader.load(fr);495 shipping_loader.load(fr);
496 }496 }
497497
498 if (version >= 3) {498 if (version >= 3) {
499 // All the other expedition specific stuff is saved in the warehouse.499 // All the other expedition specific stuff is saved in the warehouse.
500 if (fr.Unsigned8()) { // Do we have an expedition?500 if (fr.unsigned_8()) { // Do we have an expedition?
501 pd.m_expedition_bootstrap.reset(new ExpeditionBootstrap(&pd));501 pd.m_expedition_bootstrap.reset(new ExpeditionBootstrap(&pd));
502 }502 }
503 pd.m_expedition_ready = (fr.Unsigned8() == 1) ? true : false;503 pd.m_expedition_ready = (fr.unsigned_8() == 1) ? true : false;
504 } else {504 } else {
505 pd.m_expedition_ready = false;505 pd.m_expedition_ready = false;
506 }506 }
@@ -545,7 +545,7 @@
545 try {545 try {
546 // The header has been peeled away by the caller546 // The header has been peeled away by the caller
547547
548 uint8_t const version = fr.Unsigned8();548 uint8_t const version = fr.unsigned_8();
549 if (1 <= version && version <= PORTDOCK_SAVEGAME_VERSION) {549 if (1 <= version && version <= PORTDOCK_SAVEGAME_VERSION) {
550 loader->init(egbase, mol, *new PortDock(nullptr));550 loader->init(egbase, mol, *new PortDock(nullptr));
551 loader->load(fr, version);551 loader->load(fr, version);
@@ -560,27 +560,27 @@
560560
561void PortDock::save(EditorGameBase & egbase, MapObjectSaver & mos, FileWrite & fw)561void PortDock::save(EditorGameBase & egbase, MapObjectSaver & mos, FileWrite & fw)
562{562{
563 fw.Unsigned8(HeaderPortDock);563 fw.unsigned_8(HeaderPortDock);
564 fw.Unsigned8(PORTDOCK_SAVEGAME_VERSION);564 fw.unsigned_8(PORTDOCK_SAVEGAME_VERSION);
565565
566 PlayerImmovable::save(egbase, mos, fw);566 PlayerImmovable::save(egbase, mos, fw);
567567
568 fw.Unsigned32(mos.get_object_file_index(*m_warehouse));568 fw.unsigned_32(mos.get_object_file_index(*m_warehouse));
569 fw.Unsigned16(m_dockpoints.size());569 fw.unsigned_16(m_dockpoints.size());
570 for (const Coords& coords: m_dockpoints) {570 for (const Coords& coords: m_dockpoints) {
571 WriteCoords32(&fw, coords);571 write_coords_32(&fw, coords);
572 }572 }
573573
574 fw.Unsigned8(m_need_ship);574 fw.unsigned_8(m_need_ship);
575575
576 fw.Unsigned32(m_waiting.size());576 fw.unsigned_32(m_waiting.size());
577 for (ShippingItem& shipping_item : m_waiting) {577 for (ShippingItem& shipping_item : m_waiting) {
578 shipping_item.save(egbase, mos, fw);578 shipping_item.save(egbase, mos, fw);
579 }579 }
580580
581 // Expedition specific stuff581 // Expedition specific stuff
582 fw.Unsigned8(m_expedition_bootstrap.get() != nullptr ? 1 : 0);582 fw.unsigned_8(m_expedition_bootstrap.get() != nullptr ? 1 : 0);
583 fw.Unsigned8(m_expedition_ready ? 1 : 0);583 fw.unsigned_8(m_expedition_ready ? 1 : 0);
584}584}
585585
586} // namespace Widelands586} // namespace Widelands
587587
=== modified file 'src/economy/request.cc'
--- src/economy/request.cc 2014-09-14 12:13:35 +0000
+++ src/economy/request.cc 2014-09-29 14:39:47 +0000
@@ -105,14 +105,14 @@
105 * might have been initialized. We have to kill them and replace105 * might have been initialized. We have to kill them and replace
106 * them through the data in the file106 * them through the data in the file
107 */107 */
108void Request::Read108void Request::read
109 (FileRead & fr, Game & game, MapObjectLoader & mol)109 (FileRead & fr, Game & game, MapObjectLoader & mol)
110{110{
111 try {111 try {
112 uint16_t const version = fr.Unsigned16();112 uint16_t const version = fr.unsigned_16();
113 if (version == 6) {113 if (version == 6) {
114 const TribeDescr& tribe = m_target.owner().tribe();114 const TribeDescr& tribe = m_target.owner().tribe();
115 char const* const type_name = fr.CString();115 char const* const type_name = fr.c_string();
116 WareIndex const wai = tribe.ware_index(type_name);116 WareIndex const wai = tribe.ware_index(type_name);
117 if (wai != INVALID_INDEX) {117 if (wai != INVALID_INDEX) {
118 m_type = wwWARE;118 m_type = wwWARE;
@@ -123,32 +123,32 @@
123 m_type = wwWORKER;123 m_type = wwWORKER;
124 m_index = woi;124 m_index = woi;
125 } else {125 } else {
126 throw wexception("Request::Read: unknown type '%s'.\n", type_name);126 throw wexception("Request::read: unknown type '%s'.\n", type_name);
127 }127 }
128 }128 }
129 m_count = fr.Unsigned32();129 m_count = fr.unsigned_32();
130 m_required_time = fr.Unsigned32();130 m_required_time = fr.unsigned_32();
131 m_required_interval = fr.Unsigned32();131 m_required_interval = fr.unsigned_32();
132132
133 m_last_request_time = fr.Unsigned32();133 m_last_request_time = fr.unsigned_32();
134134
135 assert(m_transfers.empty());135 assert(m_transfers.empty());
136136
137 uint16_t const nr_transfers = fr.Unsigned16();137 uint16_t const nr_transfers = fr.unsigned_16();
138 for (uint16_t i = 0; i < nr_transfers; ++i)138 for (uint16_t i = 0; i < nr_transfers; ++i)
139 try {139 try {
140 MapObject* obj = &mol.get<MapObject>(fr.Unsigned32());140 MapObject* obj = &mol.get<MapObject>(fr.unsigned_32());
141 Transfer* transfer;141 Transfer* transfer;
142142
143 if (upcast(Worker, worker, obj)) {143 if (upcast(Worker, worker, obj)) {
144 transfer = worker->get_transfer();144 transfer = worker->get_transfer();
145 if (m_type != wwWORKER || !worker->descr().can_act_as(m_index)) {145 if (m_type != wwWORKER || !worker->descr().can_act_as(m_index)) {
146 throw wexception("Request::Read: incompatible transfer type");146 throw wexception("Request::read: incompatible transfer type");
147 }147 }
148 } else if (upcast(WareInstance, ware, obj)) {148 } else if (upcast(WareInstance, ware, obj)) {
149 transfer = ware->get_transfer();149 transfer = ware->get_transfer();
150 if (m_type != wwWARE || ware->descr_index() != m_index) {150 if (m_type != wwWARE || ware->descr_index() != m_index) {
151 throw wexception("Request::Read: incompatible transfer type");151 throw wexception("Request::read: incompatible transfer type");
152 }152 }
153 } else {153 } else {
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());
@@ -164,7 +164,7 @@
164 } catch (const WException& e) {164 } catch (const WException& e) {
165 throw wexception("transfer %u: %s", i, e.what());165 throw wexception("transfer %u: %s", i, e.what());
166 }166 }
167 m_requirements.Read (fr, game, mol);167 m_requirements.read (fr, game, mol);
168 if (!is_open() && m_economy)168 if (!is_open() && m_economy)
169 m_economy->remove_request(*this);169 m_economy->remove_request(*this);
170 } else170 } else
@@ -177,10 +177,10 @@
177/**177/**
178 * Write this request to a file178 * Write this request to a file
179 */179 */
180void Request::Write180void Request::write
181 (FileWrite & fw, Game & game, MapObjectSaver & mos) const181 (FileWrite & fw, Game & game, MapObjectSaver & mos) const
182{182{
183 fw.Unsigned16(REQUEST_VERSION);183 fw.unsigned_16(REQUEST_VERSION);
184184
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.
186186
@@ -188,30 +188,30 @@
188 const TribeDescr & tribe = m_target.owner().tribe();188 const TribeDescr & tribe = m_target.owner().tribe();
189 assert(m_type != wwWARE || m_index < tribe.get_nrwares ());189 assert(m_type != wwWARE || m_index < tribe.get_nrwares ());
190 assert(m_type != wwWORKER || m_index < tribe.get_nrworkers());190 assert(m_type != wwWORKER || m_index < tribe.get_nrworkers());
191 fw.CString191 fw.c_string
192 (m_type == wwWARE ?192 (m_type == wwWARE ?
193 tribe.get_ware_descr (m_index)->name() :193 tribe.get_ware_descr (m_index)->name() :
194 tribe.get_worker_descr(m_index)->name());194 tribe.get_worker_descr(m_index)->name());
195195
196 fw.Unsigned32(m_count);196 fw.unsigned_32(m_count);
197197
198 fw.Unsigned32(m_required_time);198 fw.unsigned_32(m_required_time);
199 fw.Unsigned32(m_required_interval);199 fw.unsigned_32(m_required_interval);
200200
201 fw.Unsigned32(m_last_request_time);201 fw.unsigned_32(m_last_request_time);
202202
203 fw.Unsigned16(m_transfers.size()); // Write number of current transfers.203 fw.unsigned_16(m_transfers.size()); // Write number of current transfers.
204 for (uint32_t i = 0; i < m_transfers.size(); ++i) {204 for (uint32_t i = 0; i < m_transfers.size(); ++i) {
205 Transfer & trans = *m_transfers[i];205 Transfer & trans = *m_transfers[i];
206 if (trans.m_ware) { // write ware/worker206 if (trans.m_ware) { // write ware/worker
207 assert(mos.is_object_known(*trans.m_ware));207 assert(mos.is_object_known(*trans.m_ware));
208 fw.Unsigned32(mos.get_object_file_index(*trans.m_ware));208 fw.unsigned_32(mos.get_object_file_index(*trans.m_ware));
209 } else if (trans.m_worker) {209 } else if (trans.m_worker) {
210 assert(mos.is_object_known(*trans.m_worker));210 assert(mos.is_object_known(*trans.m_worker));
211 fw.Unsigned32(mos.get_object_file_index(*trans.m_worker));211 fw.unsigned_32(mos.get_object_file_index(*trans.m_worker));
212 }212 }
213 }213 }
214 m_requirements.Write (fw, game, mos);214 m_requirements.write (fw, game, mos);
215}215}
216216
217/**217/**
@@ -407,16 +407,16 @@
407 assert(is_open());407 assert(is_open());
408408
409 ::StreamWrite & ss = game.syncstream();409 ::StreamWrite & ss = game.syncstream();
410 ss.Unsigned32(0x01decafa); // appears as facade01 in sync stream410 ss.unsigned_32(0x01decafa); // appears as facade01 in sync stream
411 ss.Unsigned32(target().serial());411 ss.unsigned_32(target().serial());
412 ss.Unsigned32(supp.get_position(game)->serial());412 ss.unsigned_32(supp.get_position(game)->serial());
413413
414 Transfer * t;414 Transfer * t;
415 if (get_type() == wwWORKER) {415 if (get_type() == wwWORKER) {
416 // Begin the transfer of a soldier or worker.416 // Begin the transfer of a soldier or worker.
417 // launch_worker() creates or starts the worker417 // launch_worker() creates or starts the worker
418 Worker & s = supp.launch_worker(game, *this);418 Worker & s = supp.launch_worker(game, *this);
419 ss.Unsigned32(s.serial());419 ss.unsigned_32(s.serial());
420 t = new Transfer(game, *this, s);420 t = new Transfer(game, *this, s);
421 } else {421 } else {
422 // Begin the transfer of an ware. The ware itself is passive.422 // Begin the transfer of an ware. The ware itself is passive.
@@ -424,7 +424,7 @@
424 // warehouse. Once it's on the flag, the flag code will decide what to424 // warehouse. Once it's on the flag, the flag code will decide what to
425 // do with it.425 // do with it.
426 WareInstance & ware = supp.launch_ware(game, *this);426 WareInstance & ware = supp.launch_ware(game, *this);
427 ss.Unsigned32(ware.serial());427 ss.unsigned_32(ware.serial());
428 t = new Transfer(game, *this, ware);428 t = new Transfer(game, *this, ware);
429 }429 }
430430
431431
=== modified file 'src/economy/request.h'
--- src/economy/request.h 2014-09-14 12:13:35 +0000
+++ src/economy/request.h 2014-09-29 14:39:47 +0000
@@ -93,8 +93,8 @@
9393
94 void start_transfer(Game &, Supply &);94 void start_transfer(Game &, Supply &);
9595
96 void Read (FileRead &, Game &, MapObjectLoader &);96 void read (FileRead &, Game &, MapObjectLoader &);
97 void Write(FileWrite &, Game &, MapObjectSaver &) const;97 void write(FileWrite &, Game &, MapObjectSaver &) const;
98 Worker * get_transfer_worker();98 Worker * get_transfer_worker();
9999
100 // callbacks for WareInstance/Worker code100 // callbacks for WareInstance/Worker code
101101
=== modified file 'src/economy/road.cc'
--- src/economy/road.cc 2014-09-10 13:03:40 +0000
+++ src/economy/road.cc 2014-09-29 14:39:47 +0000
@@ -41,7 +41,7 @@
41 return g_road_descr;41 return g_road_descr;
42}42}
4343
44bool Road::IsRoadDescr(MapObjectDescr const * const descr)44bool Road::is_road_descr(MapObjectDescr const * const descr)
45{45{
46 return descr == &g_road_descr;46 return descr == &g_road_descr;
47}47}
@@ -480,7 +480,7 @@
480 assert(static_cast<uint32_t>(index) < path.get_nsteps() - 1);480 assert(static_cast<uint32_t>(index) < path.get_nsteps() - 1);
481481
482 path.truncate(index);482 path.truncate(index);
483 secondpath.starttrim(index);483 secondpath.trim_start(index);
484484
485 molog("splitting road: first part:\n");485 molog("splitting road: first part:\n");
486 for (const Coords& coords : path.get_coords()) {486 for (const Coords& coords : path.get_coords()) {
487487
=== modified file 'src/economy/road.h'
--- src/economy/road.h 2014-09-14 11:31:58 +0000
+++ src/economy/road.h 2014-09-29 14:39:47 +0000
@@ -63,7 +63,7 @@
6363
64 const RoadDescr& descr() const;64 const RoadDescr& descr() const;
6565
66 static bool IsRoadDescr(MapObjectDescr const *);66 static bool is_road_descr(MapObjectDescr const *);
6767
68 enum FlagId {68 enum FlagId {
69 FlagStart = 0,69 FlagStart = 0,
7070
=== modified file 'src/economy/route.cc'
--- src/economy/route.cc 2014-09-10 10:18:46 +0000
+++ src/economy/route.cc 2014-09-29 14:39:47 +0000
@@ -63,7 +63,7 @@
63/**63/**
64 * Remove the first count steps from the route.64 * Remove the first count steps from the route.
65*/65*/
66void Route::starttrim(int32_t count)66void Route::trim_start(int32_t count)
67{67{
68 assert(count < static_cast<int32_t>(m_route.size()));68 assert(count < static_cast<int32_t>(m_route.size()));
6969
@@ -91,10 +91,10 @@
91{91{
92 m_route.clear();92 m_route.clear();
9393
94 m_totalcost = fr.Signed32();94 m_totalcost = fr.signed_32();
95 uint32_t nsteps = fr.Unsigned16();95 uint32_t nsteps = fr.unsigned_16();
96 for (uint32_t step = 0; step < nsteps; ++step)96 for (uint32_t step = 0; step < nsteps; ++step)
97 data.flags.push_back(fr.Unsigned32());97 data.flags.push_back(fr.unsigned_32());
98}98}
9999
100100
@@ -120,8 +120,8 @@
120void Route::save120void Route::save
121 (FileWrite & fw, EditorGameBase & egbase, MapObjectSaver & mos)121 (FileWrite & fw, EditorGameBase & egbase, MapObjectSaver & mos)
122{122{
123 fw.Signed32(get_totalcost());123 fw.signed_32(get_totalcost());
124 fw.Unsigned16(m_route.size());124 fw.unsigned_16(m_route.size());
125 for125 for
126 (std::vector<ObjectPointer>::size_type idx = 0;126 (std::vector<ObjectPointer>::size_type idx = 0;
127 idx < m_route.size();127 idx < m_route.size();
@@ -129,7 +129,7 @@
129 {129 {
130 Flag & flag = get_flag(egbase, idx);130 Flag & flag = get_flag(egbase, idx);
131 assert(mos.is_object_known(flag));131 assert(mos.is_object_known(flag));
132 fw.Unsigned32(mos.get_object_file_index(flag));132 fw.unsigned_32(mos.get_object_file_index(flag));
133 }133 }
134}134}
135135
136136
=== modified file 'src/economy/route.h'
--- src/economy/route.h 2014-09-10 08:55:04 +0000
+++ src/economy/route.h 2014-09-29 14:39:47 +0000
@@ -50,7 +50,7 @@
50 int32_t get_nrsteps() const {return m_route.size() - 1;}50 int32_t get_nrsteps() const {return m_route.size() - 1;}
51 Flag & get_flag(EditorGameBase &, std::vector<Flag *>::size_type);51 Flag & get_flag(EditorGameBase &, std::vector<Flag *>::size_type);
5252
53 void starttrim(int32_t count);53 void trim_start(int32_t count);
54 void truncate(int32_t count);54 void truncate(int32_t count);
5555
56 struct LoadData {56 struct LoadData {
5757
=== modified file 'src/economy/shippingitem.cc'
--- src/economy/shippingitem.cc 2014-09-10 08:55:04 +0000
+++ src/economy/shippingitem.cc 2014-09-29 14:39:47 +0000
@@ -167,9 +167,9 @@
167167
168void ShippingItem::Loader::load(FileRead & fr)168void ShippingItem::Loader::load(FileRead & fr)
169{169{
170 uint8_t version = fr.Unsigned8();170 uint8_t version = fr.unsigned_8();
171 if (1 <= version && version <= SHIPPINGITEM_SAVEGAME_VERSION) {171 if (1 <= version && version <= SHIPPINGITEM_SAVEGAME_VERSION) {
172 m_serial = fr.Unsigned32();172 m_serial = fr.unsigned_32();
173 } else173 } else
174 throw GameDataError("unknown ShippingItem version %u", version);174 throw GameDataError("unknown ShippingItem version %u", version);
175}175}
@@ -184,8 +184,8 @@
184184
185void ShippingItem::save(EditorGameBase & egbase, MapObjectSaver & mos, FileWrite & fw)185void ShippingItem::save(EditorGameBase & egbase, MapObjectSaver & mos, FileWrite & fw)
186{186{
187 fw.Unsigned8(SHIPPINGITEM_SAVEGAME_VERSION);187 fw.unsigned_8(SHIPPINGITEM_SAVEGAME_VERSION);
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)));
189}189}
190190
191} // namespace Widelands191} // namespace Widelands
192192
=== modified file 'src/economy/transfer.cc'
--- src/economy/transfer.cc 2014-09-10 07:57:29 +0000
+++ src/economy/transfer.cc 2014-09-29 14:39:47 +0000
@@ -178,7 +178,7 @@
178 if (m_route.get_nrsteps() >= 1)178 if (m_route.get_nrsteps() >= 1)
179 if (upcast(Road const, road, location))179 if (upcast(Road const, road, location))
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))
181 m_route.starttrim(1);181 m_route.trim_start(1);
182182
183 if (m_route.get_nrsteps() >= 1)183 if (m_route.get_nrsteps() >= 1)
184 if (upcast(Road const, road, destination))184 if (upcast(Road const, road, destination))
@@ -316,11 +316,11 @@
316316
317void Transfer::read(FileRead & fr, Transfer::ReadData & rd)317void Transfer::read(FileRead & fr, Transfer::ReadData & rd)
318{318{
319 uint8_t version = fr.Unsigned8();319 uint8_t version = fr.unsigned_8();
320 if (version != TRANSFER_SAVEGAME_VERSION)320 if (version != TRANSFER_SAVEGAME_VERSION)
321 throw wexception("unhandled/unknown transfer version %u", version);321 throw wexception("unhandled/unknown transfer version %u", version);
322322
323 rd.destination = fr.Unsigned32();323 rd.destination = fr.unsigned_32();
324}324}
325325
326void Transfer::read_pointers326void Transfer::read_pointers
@@ -332,8 +332,8 @@
332332
333void Transfer::write(MapObjectSaver & mos, FileWrite & fw)333void Transfer::write(MapObjectSaver & mos, FileWrite & fw)
334{334{
335 fw.Unsigned8(TRANSFER_SAVEGAME_VERSION);335 fw.unsigned_8(TRANSFER_SAVEGAME_VERSION);
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)));
337 // not saving route right now, will be recaculated anyway337 // not saving route right now, will be recaculated anyway
338}338}
339339
340340
=== modified file 'src/economy/ware_instance.cc'
--- src/economy/ware_instance.cc 2014-09-10 10:18:46 +0000
+++ src/economy/ware_instance.cc 2014-09-29 14:39:47 +0000
@@ -557,9 +557,9 @@
557 MapObject::Loader::load(fr);557 MapObject::Loader::load(fr);
558558
559 WareInstance & ware = get<WareInstance>();559 WareInstance & ware = get<WareInstance>();
560 m_location = fr.Unsigned32();560 m_location = fr.unsigned_32();
561 m_transfer_nextstep = fr.Unsigned32();561 m_transfer_nextstep = fr.unsigned_32();
562 if (fr.Unsigned8()) {562 if (fr.unsigned_8()) {
563 ware.m_transfer =563 ware.m_transfer =
564 new Transfer(ref_cast<Game, EditorGameBase>(egbase()), ware);564 new Transfer(ref_cast<Game, EditorGameBase>(egbase()), ware);
565 ware.m_transfer->read(fr, m_transfer);565 ware.m_transfer->read(fr, m_transfer);
@@ -598,21 +598,21 @@
598void WareInstance::save598void WareInstance::save
599 (EditorGameBase & egbase, MapObjectSaver & mos, FileWrite & fw)599 (EditorGameBase & egbase, MapObjectSaver & mos, FileWrite & fw)
600{600{
601 fw.Unsigned8(HeaderWareInstance);601 fw.unsigned_8(HeaderWareInstance);
602 fw.Unsigned8(WAREINSTANCE_SAVEGAME_VERSION);602 fw.unsigned_8(WAREINSTANCE_SAVEGAME_VERSION);
603 fw.CString(descr().tribe().name());603 fw.c_string(descr().tribe().name());
604 fw.CString(descr().name());604 fw.c_string(descr().name());
605605
606 MapObject::save(egbase, mos, fw);606 MapObject::save(egbase, mos, fw);
607607
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)));
609 fw.Unsigned32609 fw.unsigned_32
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)));
611 if (m_transfer) {611 if (m_transfer) {
612 fw.Unsigned8(1);612 fw.unsigned_8(1);
613 m_transfer->write(mos, fw);613 m_transfer->write(mos, fw);
614 } else {614 } else {
615 fw.Unsigned8(0);615 fw.unsigned_8(0);
616 }616 }
617}617}
618618
@@ -620,13 +620,13 @@
620 (EditorGameBase & egbase, MapObjectLoader & mol, FileRead & fr)620 (EditorGameBase & egbase, MapObjectLoader & mol, FileRead & fr)
621{621{
622 try {622 try {
623 uint8_t version = fr.Unsigned8();623 uint8_t version = fr.unsigned_8();
624624
625 if (version != WAREINSTANCE_SAVEGAME_VERSION)625 if (version != WAREINSTANCE_SAVEGAME_VERSION)
626 throw wexception("unknown/unhandled version %i", version);626 throw wexception("unknown/unhandled version %i", version);
627627
628 const std::string tribename = fr.CString();628 const std::string tribename = fr.c_string();
629 const std::string warename = fr.CString();629 const std::string warename = fr.c_string();
630630
631 egbase.manually_load_tribe(tribename);631 egbase.manually_load_tribe(tribename);
632632
633633
=== modified file 'src/economy/wares_queue.cc'
--- src/economy/wares_queue.cc 2014-09-14 12:13:35 +0000
+++ src/economy/wares_queue.cc 2014-09-29 14:39:47 +0000
@@ -235,47 +235,47 @@
235 * Read and write235 * Read and write
236 */236 */
237#define WARES_QUEUE_DATA_PACKET_VERSION 2237#define WARES_QUEUE_DATA_PACKET_VERSION 2
238void WaresQueue::Write(FileWrite & fw, Game & game, MapObjectSaver & mos)238void WaresQueue::write(FileWrite & fw, Game & game, MapObjectSaver & mos)
239{239{
240 fw.Unsigned16(WARES_QUEUE_DATA_PACKET_VERSION);240 fw.unsigned_16(WARES_QUEUE_DATA_PACKET_VERSION);
241241
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.
243 fw.CString243 fw.c_string
244 (owner().tribe().get_ware_descr(m_ware)->name().c_str());244 (owner().tribe().get_ware_descr(m_ware)->name().c_str());
245 fw.Signed32(m_max_size);245 fw.signed_32(m_max_size);
246 fw.Signed32(m_max_fill);246 fw.signed_32(m_max_fill);
247 fw.Signed32(m_filled);247 fw.signed_32(m_filled);
248 fw.Signed32(m_consume_interval);248 fw.signed_32(m_consume_interval);
249 if (m_request) {249 if (m_request) {
250 fw.Unsigned8(1);250 fw.unsigned_8(1);
251 m_request->Write(fw, game, mos);251 m_request->write(fw, game, mos);
252 } else252 } else
253 fw.Unsigned8(0);253 fw.unsigned_8(0);
254}254}
255255
256256
257void WaresQueue::Read(FileRead & fr, Game & game, MapObjectLoader & mol)257void WaresQueue::read(FileRead & fr, Game & game, MapObjectLoader & mol)
258{258{
259 uint16_t const packet_version = fr.Unsigned16();259 uint16_t const packet_version = fr.unsigned_16();
260 try {260 try {
261 if (packet_version == WARES_QUEUE_DATA_PACKET_VERSION || packet_version == 1) {261 if (packet_version == WARES_QUEUE_DATA_PACKET_VERSION || packet_version == 1) {
262 delete m_request;262 delete m_request;
263 m_ware = owner().tribe().ware_index(fr.CString ());263 m_ware = owner().tribe().ware_index(fr.c_string ());
264 m_max_size = fr.Unsigned32();264 m_max_size = fr.unsigned_32();
265 if (packet_version == 1)265 if (packet_version == 1)
266 m_max_fill = m_max_size;266 m_max_fill = m_max_size;
267 else267 else
268 m_max_fill = fr.Signed32();268 m_max_fill = fr.signed_32();
269 m_filled = fr.Unsigned32();269 m_filled = fr.unsigned_32();
270 m_consume_interval = fr.Unsigned32();270 m_consume_interval = fr.unsigned_32();
271 if (fr.Unsigned8 ()) {271 if (fr.unsigned_8 ()) {
272 m_request = // TODO(unknown): Change Request::Read272 m_request = // TODO(unknown): Change Request::read
273 new Request // to a constructor.273 new Request // to a constructor.
274 (m_owner,274 (m_owner,
275 0,275 0,
276 WaresQueue::request_callback,276 WaresQueue::request_callback,
277 wwWORKER);277 wwWORKER);
278 m_request->Read(fr, game, mol);278 m_request->read(fr, game, mol);
279 } else279 } else
280 m_request = nullptr;280 m_request = nullptr;
281281
282282
=== modified file 'src/economy/wares_queue.h'
--- src/economy/wares_queue.h 2014-09-14 12:13:35 +0000
+++ src/economy/wares_queue.h 2014-09-29 14:39:47 +0000
@@ -67,8 +67,8 @@
6767
68 Player & owner() const {return m_owner.owner();}68 Player & owner() const {return m_owner.owner();}
6969
70 void Read (FileRead &, Game &, MapObjectLoader &);70 void read (FileRead &, Game &, MapObjectLoader &);
71 void Write(FileWrite &, Game &, MapObjectSaver &);71 void write(FileWrite &, Game &, MapObjectSaver &);
7272
73private:73private:
74 static void request_callback74 static void request_callback
7575
=== modified file 'src/editor/editorinteractive.cc'
--- src/editor/editorinteractive.cc 2014-09-14 16:08:13 +0000
+++ src/editor/editorinteractive.cc 2014-09-29 14:39:47 +0000
@@ -244,7 +244,7 @@
244 m_realtime = WLApplication::get()->get_time();244 m_realtime = WLApplication::get()->get_time();
245 frametime = m_realtime - lasttime;245 frametime = m_realtime - lasttime;
246246
247 egbase().get_game_time_pointer() += frametime;247 egbase().get_gametime_pointer() += frametime;
248248
249 g_gr->animate_maptextures(egbase().get_gametime());249 g_gr->animate_maptextures(egbase().get_gametime());
250}250}
251251
=== modified file 'src/editor/map_generator.cc'
--- src/editor/map_generator.cc 2014-09-14 11:31:58 +0000
+++ src/editor/map_generator.cc 2014-09-29 14:39:47 +0000
@@ -59,13 +59,13 @@
59 MapGenAreaInfo::MapGenTerrainType const terrType)59 MapGenAreaInfo::MapGenTerrainType const terrType)
60{60{
61 // Figure out which bob area is due here...61 // Figure out which bob area is due here...
62 size_t num = map_gen_info_->getNumLandResources();62 size_t num = map_gen_info_->get_num_land_resources();
63 size_t found = num;63 size_t found = num;
64 uint32_t sum_weight = map_gen_info_->getSumLandResourceWeight();64 uint32_t sum_weight = map_gen_info_->get_sum_land_resource_weight();
65 uint32_t max_val = 0;65 uint32_t max_val = 0;
66 for (size_t ix = 0; ix < num; ++ix) {66 for (size_t ix = 0; ix < num; ++ix) {
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];
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();
69 if (val >= max_val) {69 if (val >= max_val) {
70 found = ix;70 found = ix;
71 max_val = val;71 max_val = val;
@@ -76,15 +76,15 @@
7676
77 // Figure out if we really need to set a bob here...77 // Figure out if we really need to set a bob here...
7878
79 const MapGenLandResource & landResource = map_gen_info_->getLandResource(found);79 const MapGenLandResource & landResource = map_gen_info_->get_land_resource(found);
8080
81 const MapGenBobCategory * bobCategory = landResource.getBobCategory(terrType);81 const MapGenBobCategory * bobCategory = landResource.get_bob_category(terrType);
8282
83 if (!bobCategory) // no bobs defined here...83 if (!bobCategory) // no bobs defined here...
84 return;84 return;
8585
86 uint32_t immovDens = landResource.getImmovableDensity();86 uint32_t immovDens = landResource.get_immovable_density();
87 uint32_t movDens = landResource.getMoveableDensity();87 uint32_t movDens = landResource.get_moveable_density();
8888
89 immovDens *= max_val / 100;89 immovDens *= max_val / 100;
90 movDens *= max_val / 100;90 movDens *= max_val / 100;
@@ -136,7 +136,7 @@
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));
137 res_val *= static_cast<uint8_t>(map_info_.resource_amount) + 1;137 res_val *= static_cast<uint8_t>(map_info_.resource_amount) + 1;
138 res_val /= 3;138 res_val /= 3;
139 if (Editor_Change_Resource_Tool_Callback(fc, map_, world, res_idx)) {139 if (editor_change_resource_tool_callback(fc, map_, world, res_idx)) {
140 fc.field->set_resources(res_idx, res_val);140 fc.field->set_resources(res_idx, res_val);
141 fc.field->set_starting_res_amount(res_val);141 fc.field->set_starting_res_amount(res_val);
142 }142 }
@@ -205,9 +205,9 @@
205 (double const elevation,205 (double const elevation,
206 Coords const c)206 Coords const c)
207{207{
208 int32_t const water_h = map_gen_info_->getWaterShallowHeight();208 int32_t const water_h = map_gen_info_->get_water_shallow_height();
209 int32_t const mount_h = map_gen_info_->getMountainFootHeight();209 int32_t const mount_h = map_gen_info_->get_mountain_foot_height();
210 int32_t const summit_h = map_gen_info_->getSummitHeight ();210 int32_t const summit_h = map_gen_info_->get_summit_height ();
211211
212 double const water_fac = map_info_.waterRatio;212 double const water_fac = map_info_.waterRatio;
213 double const land_fac = map_info_.landRatio;213 double const land_fac = map_info_.landRatio;
@@ -452,9 +452,9 @@
452 MapGenAreaInfo::MapGenTerrainType & terrType)452 MapGenAreaInfo::MapGenTerrainType & terrType)
453{453{
454 uint32_t numLandAreas =454 uint32_t numLandAreas =
455 map_gen_info_->getNumAreas(MapGenAreaInfo::atLand);455 map_gen_info_->get_num_areas(MapGenAreaInfo::atLand);
456 uint32_t const numWasteLandAreas =456 uint32_t const numWasteLandAreas =
457 map_gen_info_->getNumAreas(MapGenAreaInfo::atWasteland);457 map_gen_info_->get_num_areas(MapGenAreaInfo::atWasteland);
458458
459 bool isDesert = false;459 bool isDesert = false;
460 bool isDesertOuter = false;460 bool isDesertOuter = false;
@@ -516,10 +516,10 @@
516 landAreaIndex = 0;516 landAreaIndex = 0;
517 else if (numLandAreas == 2) {517 else if (numLandAreas == 2) {
518 uint32_t const weight1 =518 uint32_t const weight1 =
519 map_gen_info_->getArea(MapGenAreaInfo::atLand, 0).getWeight();519 map_gen_info_->get_area(MapGenAreaInfo::atLand, 0).get_weight();
520 uint32_t const weight2 =520 uint32_t const weight2 =
521 map_gen_info_->getArea(MapGenAreaInfo::atLand, 1).getWeight();521 map_gen_info_->get_area(MapGenAreaInfo::atLand, 1).get_weight();
522 uint32_t const sum = map_gen_info_->getSumLandWeight();522 uint32_t const sum = map_gen_info_->get_sum_land_weight();
523 if523 if
524 (weight1 * (random2[c0.x + map_info_.w * c0.y] / sum)524 (weight1 * (random2[c0.x + map_info_.w * c0.y] / sum)
525 >=525 >=
@@ -529,12 +529,12 @@
529 landAreaIndex = 1;529 landAreaIndex = 1;
530 } else {530 } else {
531 uint32_t const weight1 =531 uint32_t const weight1 =
532 map_gen_info_->getArea(MapGenAreaInfo::atLand, 0).getWeight();532 map_gen_info_->get_area(MapGenAreaInfo::atLand, 0).get_weight();
533 uint32_t const weight2 =533 uint32_t const weight2 =
534 map_gen_info_->getArea(MapGenAreaInfo::atLand, 1).getWeight();534 map_gen_info_->get_area(MapGenAreaInfo::atLand, 1).get_weight();
535 uint32_t const weight3 =535 uint32_t const weight3 =
536 map_gen_info_->getArea(MapGenAreaInfo::atLand, 2).getWeight();536 map_gen_info_->get_area(MapGenAreaInfo::atLand, 2).get_weight();
537 uint32_t const sum = map_gen_info_->getSumLandWeight();537 uint32_t const sum = map_gen_info_->get_sum_land_weight();
538 uint32_t const randomX = (rand2 + rand3) / 2;538 uint32_t const randomX = (rand2 + rand3) / 2;
539 if539 if
540 (weight1 * (rand2 / sum) > weight2 * (rand3 / sum) &&540 (weight1 * (rand2 / sum) > weight2 * (rand3 / sum) &&
@@ -557,14 +557,14 @@
557557
558 // see whether it is water558 // see whether it is water
559559
560 uint32_t const coast_h = map_gen_info_->getLandCoastHeight();560 uint32_t const coast_h = map_gen_info_->get_land_coast_height();
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...
562 atp = MapGenAreaInfo::atLand;562 atp = MapGenAreaInfo::atLand;
563 ttp = MapGenAreaInfo::ttLandCoast;563 ttp = MapGenAreaInfo::ttLandCoast;
564564
565 uint32_t const ocean_h = map_gen_info_->getWaterOceanHeight();565 uint32_t const ocean_h = map_gen_info_->get_water_ocean_height();
566 uint32_t const shelf_h = map_gen_info_->getWaterShelfHeight();566 uint32_t const shelf_h = map_gen_info_->get_water_shelf_height();
567 uint32_t const shallow_h = map_gen_info_->getWaterShallowHeight();567 uint32_t const shallow_h = map_gen_info_->get_water_shallow_height();
568568
569 // TODO(unknown): The heights can not be lower than water-Shallow --569 // TODO(unknown): The heights can not be lower than water-Shallow --
570 // there will never be an ocean yet570 // there will never be an ocean yet
@@ -580,10 +580,10 @@
580 ttp = MapGenAreaInfo::ttWaterShallow;580 ttp = MapGenAreaInfo::ttWaterShallow;
581 }581 }
582 } else { // it is not water582 } else { // it is not water
583 uint32_t const upper_h = map_gen_info_->getLandUpperHeight ();583 uint32_t const upper_h = map_gen_info_->get_land_upper_height ();
584 uint32_t const foot_h = map_gen_info_->getMountainFootHeight();584 uint32_t const foot_h = map_gen_info_->get_mountain_foot_height();
585 uint32_t const mount_h = map_gen_info_->getMountainHeight ();585 uint32_t const mount_h = map_gen_info_->get_mountain_height ();
586 uint32_t const snow_h = map_gen_info_->getSnowHeight ();586 uint32_t const snow_h = map_gen_info_->get_snow_height ();
587 if (h1 >= snow_h && h2 >= snow_h && h3 >= snow_h) {587 if (h1 >= snow_h && h2 >= snow_h && h3 >= snow_h) {
588 atp = MapGenAreaInfo::atMountains;588 atp = MapGenAreaInfo::atMountains;
589 ttp = MapGenAreaInfo::ttMountainsSnow;589 ttp = MapGenAreaInfo::ttMountainsSnow;
@@ -616,11 +616,11 @@
616616
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...
618 return618 return
619 map_gen_info_->getArea(atp, usedLandIndex).getTerrain619 map_gen_info_->get_area(atp, usedLandIndex).get_terrain
620 (ttp,620 (ttp,
621 rng.rand()621 rng.rand()
622 %622 %
623 map_gen_info_->getArea(atp, usedLandIndex).getNumTerrains(ttp));623 map_gen_info_->get_area(atp, usedLandIndex).get_num_terrains(ttp));
624624
625}625}
626626
@@ -663,9 +663,9 @@
663663
664 // for bobs664 // for bobs
665 std::unique_ptr<std::unique_ptr<uint32_t[]> []> random_bobs665 std::unique_ptr<std::unique_ptr<uint32_t[]> []> random_bobs
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()]);
667667
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)
669 random_bobs[ix].reset669 random_bobs[ix].reset
670 (generate_random_value_map(map_info_.w, map_info_.h, rng));670 (generate_random_value_map(map_info_.w, map_info_.h, rng));
671671
@@ -871,7 +871,7 @@
871===============871===============
872*/872*/
873873
874int UniqueRandomMapInfo::mapIdCharToNumber(char ch)874int UniqueRandomMapInfo::map_id_char_to_number(char ch)
875{875{
876 if ((ch == '0') || (ch == 'o') || (ch == 'O'))876 if ((ch == '0') || (ch == 'o') || (ch == 'O'))
877 return 22;877 return 22;
@@ -917,7 +917,7 @@
917Return value: The converted value as a character917Return value: The converted value as a character
918===============918===============
919*/919*/
920char UniqueRandomMapInfo::mapIdNumberToChar(int32_t const num)920char UniqueRandomMapInfo::map_id_number_to_char(int32_t const num)
921{921{
922 if (num == 22)922 if (num == 22)
923 return '0';923 return '0';
@@ -950,7 +950,7 @@
950===============950===============
951*/951*/
952952
953bool UniqueRandomMapInfo::setFromIdString953bool UniqueRandomMapInfo::set_from_id_string
954 (UniqueRandomMapInfo & mapInfo_out, const std::string & mapIdString)954 (UniqueRandomMapInfo & mapInfo_out, const std::string & mapIdString)
955{955{
956 // check string956 // check string
@@ -967,7 +967,7 @@
967 int32_t nums[kMapIdDigits];967 int32_t nums[kMapIdDigits];
968968
969 for (uint32_t ix = 0; ix < kMapIdDigits; ++ix) {969 for (uint32_t ix = 0; ix < kMapIdDigits; ++ix) {
970 int const num = mapIdCharToNumber(mapIdString[ix + (ix / 4)]);970 int const num = map_id_char_to_number(mapIdString[ix + (ix / 4)]);
971 if (num < 0)971 if (num < 0)
972 return false;972 return false;
973 nums[ix] = num;973 nums[ix] = num;
@@ -1050,7 +1050,7 @@
1050 begin created (map specific info)1050 begin created (map specific info)
1051===============1051===============
1052*/1052*/
1053void UniqueRandomMapInfo::generateIdString1053void UniqueRandomMapInfo::generate_id_string
1054 (std::string & mapIdsString_out, const UniqueRandomMapInfo & mapInfo)1054 (std::string & mapIdsString_out, const UniqueRandomMapInfo & mapInfo)
1055{1055{
1056 // Init1056 // Init
@@ -1070,7 +1070,7 @@
1070 nums[ix] = 0;1070 nums[ix] = 0;
10711071
1072 // Generate world name hash1072 // Generate world name hash
1073 uint16_t nameHash = generateWorldNameHash(mapInfo.world_name);1073 uint16_t nameHash = generate_world_name_hash(mapInfo.world_name);
10741074
1075 // Convert map random number1075 // Convert map random number
1076 nums [0] = mapInfo.mapNumber & 31;1076 nums [0] = mapInfo.mapNumber & 31;
@@ -1134,14 +1134,14 @@
11341134
1135 // translate it to ASCII1135 // translate it to ASCII
1136 for (uint32_t ix = 0; ix < kMapIdDigits; ++ix) {1136 for (uint32_t ix = 0; ix < kMapIdDigits; ++ix) {
1137 mapIdsString_out += mapIdNumberToChar(nums[ix]);1137 mapIdsString_out += map_id_number_to_char(nums[ix]);
1138 if (ix % 4 == 3 && ix != kMapIdDigits - 1)1138 if (ix % 4 == 3 && ix != kMapIdDigits - 1)
1139 mapIdsString_out += "-";1139 mapIdsString_out += "-";
1140 }1140 }
1141}1141}
11421142
11431143
1144uint16_t Widelands::UniqueRandomMapInfo::generateWorldNameHash1144uint16_t Widelands::UniqueRandomMapInfo::generate_world_name_hash
1145 (const std::string & name)1145 (const std::string & name)
1146{1146{
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.
11481148
=== modified file 'src/editor/map_generator.h'
--- src/editor/map_generator.h 2014-09-10 10:18:46 +0000
+++ src/editor/map_generator.h 2014-09-29 14:39:47 +0000
@@ -63,15 +63,15 @@
63 bool islandMode; // whether the world will be an island63 bool islandMode; // whether the world will be an island
6464
65 // other stuff65 // other stuff
66 static bool setFromIdString66 static bool set_from_id_string
67 (UniqueRandomMapInfo & mapInfo_out, const std::string & mapIdString);67 (UniqueRandomMapInfo & mapInfo_out, const std::string & mapIdString);
68 static void generateIdString68 static void generate_id_string
69 (std::string & mapIdsString_out, const UniqueRandomMapInfo & mapInfo);69 (std::string & mapIdsString_out, const UniqueRandomMapInfo & mapInfo);
7070
71private:71private:
72 static int mapIdCharToNumber(char);72 static int map_id_char_to_number(char);
73 static char mapIdNumberToChar(int32_t);73 static char map_id_number_to_char(int32_t);
74 static uint16_t generateWorldNameHash(const std::string &);74 static uint16_t generate_world_name_hash(const std::string &);
75};75};
7676
7777
7878
=== modified file 'src/editor/tools/editor_decrease_resources_tool.cc'
--- src/editor/tools/editor_decrease_resources_tool.cc 2014-09-10 14:08:25 +0000
+++ src/editor/tools/editor_decrease_resources_tool.cc 2014-09-29 14:39:47 +0000
@@ -57,7 +57,7 @@
57 args.orgRes.push_back(mr.location().field->get_resources_amount());57 args.orgRes.push_back(mr.location().field->get_resources_amount());
5858
59 if (res == args.cur_res &&59 if (res == args.cur_res &&
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)) {
61 // Ok, we're doing something. First remove the current overlays.61 // Ok, we're doing something. First remove the current overlays.
62 std::string str =62 std::string str =
63 world.get_resource(res)->get_editor_pic63 world.get_resource(res)->get_editor_pic
6464
=== modified file 'src/editor/tools/editor_increase_resources_tool.cc'
--- src/editor/tools/editor_increase_resources_tool.cc 2014-09-10 14:08:25 +0000
+++ src/editor/tools/editor_increase_resources_tool.cc 2014-09-29 14:39:47 +0000
@@ -46,7 +46,7 @@
46} // namespace46} // namespace
4747
4848
49int32_t Editor_Change_Resource_Tool_Callback49int32_t editor_change_resource_tool_callback
50 (const TCoords<Widelands::FCoords>& c, Widelands::Map& map,50 (const TCoords<Widelands::FCoords>& c, Widelands::Map& map,
51 const Widelands::World& world, int32_t const curres)51 const Widelands::World& world, int32_t const curres)
52{52{
@@ -110,7 +110,7 @@
110 if110 if
111 ((res == args.cur_res || !mr.location().field->get_resources_amount())111 ((res == args.cur_res || !mr.location().field->get_resources_amount())
112 &&112 &&
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))
114 {114 {
115 // Ok, we're doing something. First remove the current overlays.115 // Ok, we're doing something. First remove the current overlays.
116 const Image* pic =116 const Image* pic =
117117
=== modified file 'src/editor/tools/editor_increase_resources_tool.h'
--- src/editor/tools/editor_increase_resources_tool.h 2014-09-10 14:08:25 +0000
+++ src/editor/tools/editor_increase_resources_tool.h 2014-09-29 14:39:47 +0000
@@ -72,7 +72,7 @@
72 Widelands::ResourceIndex m_cur_res;72 Widelands::ResourceIndex m_cur_res;
73};73};
7474
75int32_t Editor_Change_Resource_Tool_Callback75int32_t editor_change_resource_tool_callback
76 (const Widelands::TCoords<Widelands::FCoords>& c, Widelands::Map& map,76 (const Widelands::TCoords<Widelands::FCoords>& c, Widelands::Map& map,
77 const Widelands::World& world, int32_t const curres);77 const Widelands::World& world, int32_t const curres);
7878
7979
=== modified file 'src/editor/tools/editor_make_infrastructure_tool.cc'
--- src/editor/tools/editor_make_infrastructure_tool.cc 2014-09-10 14:08:25 +0000
+++ src/editor/tools/editor_make_infrastructure_tool.cc 2014-09-29 14:39:47 +0000
@@ -31,7 +31,7 @@
31 * Callback function to calculate correct overlays31 * Callback function to calculate correct overlays
32 */32 */
33int32_t33int32_t
34Editor_Make_Infrastructure_Tool_Callback34editor_make_infrastructure_tool_callback
35 (const Widelands::TCoords<Widelands::FCoords>& c,35 (const Widelands::TCoords<Widelands::FCoords>& c,
36 Widelands::EditorGameBase& egbase,36 Widelands::EditorGameBase& egbase,
37 int32_t const player)37 int32_t const player)
3838
=== modified file 'src/editor/tools/editor_make_infrastructure_tool.h'
--- src/editor/tools/editor_make_infrastructure_tool.h 2014-09-10 14:08:25 +0000
+++ src/editor/tools/editor_make_infrastructure_tool.h 2014-09-29 14:39:47 +0000
@@ -53,7 +53,7 @@
53 UI::UniqueWindow::Registry m_registry;53 UI::UniqueWindow::Registry m_registry;
54};54};
5555
56int32_t Editor_Make_Infrastructure_Tool_Callback56int32_t editor_make_infrastructure_tool_callback
57 (const Widelands::TCoords<Widelands::FCoords>& c,57 (const Widelands::TCoords<Widelands::FCoords>& c,
58 Widelands::EditorGameBase& egbase, int32_t const player);58 Widelands::EditorGameBase& egbase, int32_t const player);
5959
6060
=== modified file 'src/editor/tools/editor_set_port_space_tool.cc'
--- src/editor/tools/editor_set_port_space_tool.cc 2014-09-10 14:08:25 +0000
+++ src/editor/tools/editor_set_port_space_tool.cc 2014-09-29 14:39:47 +0000
@@ -30,7 +30,7 @@
30using namespace Widelands;30using namespace Widelands;
3131
32/// static callback function for overlay calculation32/// static callback function for overlay calculation
33int32_t Editor_Tool_Set_Port_Space_Callback33int32_t editor_Tool_set_port_space_callback
34 (const Widelands::TCoords<Widelands::FCoords>& c, Map& map)34 (const Widelands::TCoords<Widelands::FCoords>& c, Map& map)
35{35{
36 NodeCaps const caps = c.field->nodecaps();36 NodeCaps const caps = c.field->nodecaps();
@@ -71,7 +71,7 @@
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));
72 do {72 do {
73 // check if field is valid73 // check if field is valid
74 if (Editor_Tool_Set_Port_Space_Callback(mr.location(), map)) {74 if (editor_Tool_set_port_space_callback(mr.location(), map)) {
75 map.set_port_space(mr.location(), true);75 map.set_port_space(mr.location(), true);
76 Area<FCoords> a(mr.location(), 0);76 Area<FCoords> a(mr.location(), 0);
77 map.recalc_for_field_area(world, a);77 map.recalc_for_field_area(world, a);
@@ -106,7 +106,7 @@
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));
107 do {107 do {
108 // check if field is valid108 // check if field is valid
109 if (Editor_Tool_Set_Port_Space_Callback(mr.location(), map)) {109 if (editor_Tool_set_port_space_callback(mr.location(), map)) {
110 map.set_port_space(mr.location(), false);110 map.set_port_space(mr.location(), false);
111 Area<FCoords> a(mr.location(), 0);111 Area<FCoords> a(mr.location(), 0);
112 map.recalc_for_field_area(world, a);112 map.recalc_for_field_area(world, a);
113113
=== modified file 'src/editor/tools/editor_set_port_space_tool.h'
--- src/editor/tools/editor_set_port_space_tool.h 2014-09-10 14:08:25 +0000
+++ src/editor/tools/editor_set_port_space_tool.h 2014-09-29 14:39:47 +0000
@@ -67,7 +67,7 @@
67 char const * get_sel_impl() const override {return FSEL_ESPS_FILENAME;}67 char const * get_sel_impl() const override {return FSEL_ESPS_FILENAME;}
68};68};
6969
70int32_t Editor_Tool_Set_Port_Space_Callback70int32_t editor_Tool_set_port_space_callback
71 (const Widelands::TCoords<Widelands::FCoords>& c, Widelands::Map& map);71 (const Widelands::TCoords<Widelands::FCoords>& c, Widelands::Map& map);
7272
73#endif // end of include guard: WL_EDITOR_TOOLS_EDITOR_SET_PORT_SPACE_TOOL_H73#endif // end of include guard: WL_EDITOR_TOOLS_EDITOR_SET_PORT_SPACE_TOOL_H
7474
=== modified file 'src/editor/tools/editor_set_resources_tool.cc'
--- src/editor/tools/editor_set_resources_tool.cc 2014-09-10 14:08:25 +0000
+++ src/editor/tools/editor_set_resources_tool.cc 2014-09-29 14:39:47 +0000
@@ -55,7 +55,7 @@
55 args.orgResT.push_back(res);55 args.orgResT.push_back(res);
56 args.orgRes.push_back(mr.location().field->get_resources_amount());56 args.orgRes.push_back(mr.location().field->get_resources_amount());
5757
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)) {
59 // Ok, we're doing something. First remove the current overlays.59 // Ok, we're doing something. First remove the current overlays.
60 const Image* pic = g_gr->images().get60 const Image* pic = g_gr->images().get
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()));
6262
=== modified file 'src/editor/tools/editor_set_starting_pos_tool.cc'
--- src/editor/tools/editor_set_starting_pos_tool.cc 2014-09-10 14:08:25 +0000
+++ src/editor/tools/editor_set_starting_pos_tool.cc 2014-09-29 14:39:47 +0000
@@ -32,7 +32,7 @@
32/*32/*
33 * static callback function for overlay calculation33 * static callback function for overlay calculation
34 */34 */
35int32_t Editor_Tool_Set_Starting_Pos_Callback35int32_t editor_tool_set_starting_pos_callback
36 (const Widelands::TCoords<Widelands::FCoords>& c, Widelands::Map& map)36 (const Widelands::TCoords<Widelands::FCoords>& c, Widelands::Map& map)
37{37{
38 // Area around already placed players38 // Area around already placed players
@@ -88,7 +88,7 @@
88 const Image* pic = g_gr->images().get(picname);88 const Image* pic = g_gr->images().get(picname);
8989
90 // check if field is valid90 // check if field is valid
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)) {
92 OverlayManager & overlay_manager = map.overlay_manager();92 OverlayManager & overlay_manager = map.overlay_manager();
93 // remove old overlay if any93 // remove old overlay if any
94 overlay_manager.remove_overlay(old_sp, pic);94 overlay_manager.remove_overlay(old_sp, pic);
9595
=== modified file 'src/editor/tools/editor_set_starting_pos_tool.h'
--- src/editor/tools/editor_set_starting_pos_tool.h 2014-09-10 14:08:25 +0000
+++ src/editor/tools/editor_set_starting_pos_tool.h 2014-09-29 14:39:47 +0000
@@ -51,7 +51,7 @@
51 char const * m_current_sel_pic;51 char const * m_current_sel_pic;
52};52};
5353
54int32_t Editor_Tool_Set_Starting_Pos_Callback54int32_t editor_tool_set_starting_pos_callback
55 (const Widelands::TCoords<Widelands::FCoords>& c, Widelands::Map& map);55 (const Widelands::TCoords<Widelands::FCoords>& c, Widelands::Map& map);
5656
57#endif // end of include guard: WL_EDITOR_TOOLS_EDITOR_SET_STARTING_POS_TOOL_H57#endif // end of include guard: WL_EDITOR_TOOLS_EDITOR_SET_STARTING_POS_TOOL_H
5858
=== modified file 'src/editor/ui_menus/editor_main_menu_load_map.cc'
--- src/editor/ui_menus/editor_main_menu_load_map.cc 2014-09-23 09:26:48 +0000
+++ src/editor/ui_menus/editor_main_menu_load_map.cc 2014-09-29 14:39:47 +0000
@@ -138,7 +138,7 @@
138void MainMenuLoadMap::clicked_ok() {138void MainMenuLoadMap::clicked_ok() {
139 const char * const filename(m_ls->get_selected());139 const char * const filename(m_ls->get_selected());
140140
141 if (g_fs->IsDirectory(filename) && !WidelandsMapLoader::is_widelands_map(filename)) {141 if (g_fs->is_directory(filename) && !WidelandsMapLoader::is_widelands_map(filename)) {
142 m_curdir = filename;142 m_curdir = filename;
143 m_ls->clear();143 m_ls->clear();
144 m_mapfiles.clear();144 m_mapfiles.clear();
@@ -157,7 +157,7 @@
157157
158 m_ok_btn->set_enabled(true);158 m_ok_btn->set_enabled(true);
159159
160 if (!g_fs->IsDirectory(name) || WidelandsMapLoader::is_widelands_map(name)) {160 if (!g_fs->is_directory(name) || WidelandsMapLoader::is_widelands_map(name)) {
161 Widelands::Map map;161 Widelands::Map map;
162 {162 {
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);
@@ -196,7 +196,7 @@
196 */196 */
197void MainMenuLoadMap::fill_list() {197void MainMenuLoadMap::fill_list() {
198 // Fill it with all files we find.198 // Fill it with all files we find.
199 m_mapfiles = g_fs->ListDirectory(m_curdir);199 m_mapfiles = g_fs->list_directory(m_curdir);
200200
201 // First, we add all directories. We manually add the parent directory.201 // First, we add all directories. We manually add the parent directory.
202 if (m_curdir != m_basedir) {202 if (m_curdir != m_basedir) {
@@ -222,13 +222,13 @@
222 {222 {
223 const char * const name = pname->c_str();223 const char * const name = pname->c_str();
224 if224 if
225 (strcmp(FileSystem::FS_Filename(name), ".") &&225 (strcmp(FileSystem::fs_filename(name), ".") &&
226 strcmp(FileSystem::FS_Filename(name), "..") &&226 strcmp(FileSystem::fs_filename(name), "..") &&
227 g_fs->IsDirectory(name) &&227 g_fs->is_directory(name) &&
228 !WidelandsMapLoader::is_widelands_map(name))228 !WidelandsMapLoader::is_widelands_map(name))
229229
230 m_ls->add230 m_ls->add
231 (FileSystem::FS_Filename(name),231 (FileSystem::fs_filename(name),
232 name,232 name,
233 g_gr->images().get("pics/ls_dir.png"));233 g_gr->images().get("pics/ls_dir.png"));
234 }234 }
@@ -246,7 +246,7 @@
246 try {246 try {
247 map_loader->preload_map(true);247 map_loader->preload_map(true);
248 m_ls->add248 m_ls->add
249 (FileSystem::FS_Filename(name),249 (FileSystem::fs_filename(name),
250 name,250 name,
251 g_gr->images().get251 g_gr->images().get
252 (dynamic_cast<WidelandsMapLoader*>(map_loader.get())252 (dynamic_cast<WidelandsMapLoader*>(map_loader.get())
253253
=== modified file 'src/editor/ui_menus/editor_main_menu_map_options.cc'
--- src/editor/ui_menus/editor_main_menu_map_options.cc 2014-09-10 14:48:40 +0000
+++ src/editor/ui_menus/editor_main_menu_map_options.cc 2014-09-29 14:39:47 +0000
@@ -116,8 +116,8 @@
116 char buf[200];116 char buf[200];
117 sprintf(buf, "%ix%i", map.get_width(), map.get_height());117 sprintf(buf, "%ix%i", map.get_width(), map.get_height());
118 m_size->set_text(buf);118 m_size->set_text(buf);
119 m_author->setText(map.get_author());119 m_author->set_text(map.get_author());
120 m_name ->setText(map.get_name());120 m_name ->set_text(map.get_name());
121 sprintf(buf, "%i", map.get_nrplayers());121 sprintf(buf, "%i", map.get_nrplayers());
122 m_nrplayers->set_text(buf);122 m_nrplayers->set_text(buf);
123 m_descr ->set_text(map.get_description());123 m_descr ->set_text(map.get_description());
124124
=== modified file 'src/editor/ui_menus/editor_main_menu_random_map.cc'
--- src/editor/ui_menus/editor_main_menu_random_map.cc 2014-09-14 12:13:35 +0000
+++ src/editor/ui_menus/editor_main_menu_random_map.cc 2014-09-29 14:39:47 +0000
@@ -90,7 +90,7 @@
90 m_mapNumber = rng.rand();90 m_mapNumber = rng.rand();
91 snprintf91 snprintf
92 (buffer, sizeof(buffer), "%u", static_cast<unsigned int>(m_mapNumber));92 (buffer, sizeof(buffer), "%u", static_cast<unsigned int>(m_mapNumber));
93 m_nrEditbox->setText(buffer);93 m_nrEditbox->set_text(buffer);
94 posy += height + spacing + spacing + spacing;94 posy += height + spacing + spacing + spacing;
9595
9696
@@ -297,7 +297,7 @@
297 posx, posy,297 posx, posy,
298 width, 20,298 width, 20,
299 g_gr->images().get("pics/but1.png"));299 g_gr->images().get("pics/but1.png"));
300 m_idEditbox->setText("abcd-efgh-ijkl-mnop");300 m_idEditbox->set_text("abcd-efgh-ijkl-mnop");
301 m_idEditbox->changed.connect301 m_idEditbox->changed.connect
302 (boost::bind(&MainMenuNewRandomMap::id_edit_box_changed, this));302 (boost::bind(&MainMenuNewRandomMap::id_edit_box_changed, this));
303 posy += height + spacing + spacing + spacing;303 posy += height + spacing + spacing + spacing;
@@ -499,12 +499,12 @@
499499
500 std::string str = m_idEditbox->text();500 std::string str = m_idEditbox->text();
501501
502 if (!UniqueRandomMapInfo::setFromIdString(mapInfo, str))502 if (!UniqueRandomMapInfo::set_from_id_string(mapInfo, str))
503 m_goButton->set_enabled(false);503 m_goButton->set_enabled(false);
504 else {504 else {
505 std::stringstream sstrm;505 std::stringstream sstrm;
506 sstrm << mapInfo.mapNumber;506 sstrm << mapInfo.mapNumber;
507 m_nrEditbox->setText(sstrm.str());507 m_nrEditbox->set_text(sstrm.str());
508508
509 m_h = 0;509 m_h = 0;
510 for (uint32_t ix = 0; ix < NUMBER_OF_MAP_DIMENSIONS; ++ix)510 for (uint32_t ix = 0; ix < NUMBER_OF_MAP_DIMENSIONS; ++ix)
@@ -545,9 +545,9 @@
545 set_map_info(mapInfo);545 set_map_info(mapInfo);
546546
547 std::string idStr;547 std::string idStr;
548 Widelands::UniqueRandomMapInfo::generateIdString(idStr, mapInfo);548 Widelands::UniqueRandomMapInfo::generate_id_string(idStr, mapInfo);
549549
550 m_idEditbox->setText(idStr);550 m_idEditbox->set_text(idStr);
551551
552 m_goButton->set_enabled(true);552 m_goButton->set_enabled(true);
553 } else553 } else
554554
=== modified file 'src/editor/ui_menus/editor_main_menu_save_map.cc'
--- src/editor/ui_menus/editor_main_menu_save_map.cc 2014-09-23 09:26:48 +0000
+++ src/editor/ui_menus/editor_main_menu_save_map.cc 2014-09-29 14:39:47 +0000
@@ -73,7 +73,7 @@
73 posx, posy + get_inner_h() - spacing - offsy - 60 + 3,73 posx, posy + get_inner_h() - spacing - offsy - 60 + 3,
74 get_inner_w() / 2 - spacing, 20,74 get_inner_w() / 2 - spacing, 20,
75 g_gr->images().get("pics/but1.png"));75 g_gr->images().get("pics/but1.png"));
76 m_editbox->setText(parent.egbase().map().get_name());76 m_editbox->set_text(parent.egbase().map().get_name());
77 m_editbox->changed.connect(boost::bind(&MainMenuSaveMap::edit_box_changed, this));77 m_editbox->changed.connect(boost::bind(&MainMenuSaveMap::edit_box_changed, this));
7878
79 posx = get_inner_w() / 2 + spacing;79 posx = get_inner_w() / 2 + spacing;
@@ -164,11 +164,11 @@
164 filename = m_ls->get_selected();164 filename = m_ls->get_selected();
165165
166 if166 if
167 (g_fs->IsDirectory(filename.c_str())167 (g_fs->is_directory(filename.c_str())
168 &&168 &&
169 !Widelands::WidelandsMapLoader::is_widelands_map(filename))169 !Widelands::WidelandsMapLoader::is_widelands_map(filename))
170 {170 {
171 m_curdir = g_fs->FS_CanonicalizeName(filename);171 m_curdir = g_fs->canonicalize_name(filename);
172 m_ls->clear();172 m_ls->clear();
173 m_mapfiles.clear();173 m_mapfiles.clear();
174 fill_list();174 fill_list();
@@ -200,12 +200,12 @@
200void MainMenuSaveMap::clicked_make_directory() {200void MainMenuSaveMap::clicked_make_directory() {
201 MainMenuSaveMapMakeDirectory md(this, _("unnamed"));201 MainMenuSaveMapMakeDirectory md(this, _("unnamed"));
202 if (md.run()) {202 if (md.run()) {
203 g_fs->EnsureDirectoryExists(m_basedir);203 g_fs->ensure_directory_exists(m_basedir);
204 // create directory204 // create directory
205 std::string fullname = m_curdir;205 std::string fullname = m_curdir;
206 fullname += "/";206 fullname += "/";
207 fullname += md.get_dirname();207 fullname += md.get_dirname();
208 g_fs->MakeDirectory(fullname);208 g_fs->make_directory(fullname);
209 m_ls->clear();209 m_ls->clear();
210 m_mapfiles.clear();210 m_mapfiles.clear();
211 fill_list();211 fill_list();
@@ -226,7 +226,7 @@
226 ml->preload_map(true); // This has worked before, no problem226 ml->preload_map(true); // This has worked before, no problem
227 }227 }
228228
229 m_editbox->setText(FileSystem::FS_Filename(name));229 m_editbox->set_text(FileSystem::fs_filename(name));
230230
231 m_name ->set_text(map.get_name ());231 m_name ->set_text(map.get_name ());
232 m_author->set_text(map.get_author ());232 m_author->set_text(map.get_author ());
@@ -239,11 +239,11 @@
239 sprintf(buf, "%ix%i", map.get_width(), map.get_height());239 sprintf(buf, "%ix%i", map.get_width(), map.get_height());
240 m_size->set_text(buf);240 m_size->set_text(buf);
241 } else {241 } else {
242 m_name ->set_text(FileSystem::FS_Filename(name));242 m_name ->set_text(FileSystem::fs_filename(name));
243 m_author ->set_text("");243 m_author ->set_text("");
244 m_nrplayers->set_text("");244 m_nrplayers->set_text("");
245 m_size ->set_text("");245 m_size ->set_text("");
246 if (g_fs->IsDirectory(name)) {246 if (g_fs->is_directory(name)) {
247 std::string dir_string =247 std::string dir_string =
248 (boost::format("\\<%s\\>") % _("directory")).str();248 (boost::format("\\<%s\\>") % _("directory")).str();
249 m_descr ->set_text(dir_string);249 m_descr ->set_text(dir_string);
@@ -263,7 +263,7 @@
263void MainMenuSaveMap::double_clicked_item(uint32_t) {263void MainMenuSaveMap::double_clicked_item(uint32_t) {
264 const char * const name = m_ls->get_selected();264 const char * const name = m_ls->get_selected();
265265
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)) {
267 m_curdir = name;267 m_curdir = name;
268 m_ls->clear();268 m_ls->clear();
269 m_mapfiles.clear();269 m_mapfiles.clear();
@@ -277,7 +277,7 @@
277 */277 */
278void MainMenuSaveMap::fill_list() {278void MainMenuSaveMap::fill_list() {
279 // Fill it with all files we find.279 // Fill it with all files we find.
280 m_mapfiles = g_fs->ListDirectory(m_curdir);280 m_mapfiles = g_fs->list_directory(m_curdir);
281281
282 // First, we add all directories. We manually add the parent directory282 // First, we add all directories. We manually add the parent directory
283 if (m_curdir != m_basedir) {283 if (m_curdir != m_basedir) {
@@ -303,13 +303,13 @@
303 {303 {
304 const char * const name = pname->c_str();304 const char * const name = pname->c_str();
305 if305 if
306 (strcmp(FileSystem::FS_Filename(name), ".") &&306 (strcmp(FileSystem::fs_filename(name), ".") &&
307 strcmp(FileSystem::FS_Filename(name), "..") &&307 strcmp(FileSystem::fs_filename(name), "..") &&
308 g_fs->IsDirectory(name) &&308 g_fs->is_directory(name) &&
309 !Widelands::WidelandsMapLoader::is_widelands_map(name))309 !Widelands::WidelandsMapLoader::is_widelands_map(name))
310310
311 m_ls->add311 m_ls->add
312 (FileSystem::FS_Filename(name),312 (FileSystem::fs_filename(name),
313 name,313 name,
314 g_gr->images().get("pics/ls_dir.png"));314 g_gr->images().get("pics/ls_dir.png"));
315 }315 }
@@ -329,7 +329,7 @@
329 try {329 try {
330 wml->preload_map(true);330 wml->preload_map(true);
331 m_ls->add331 m_ls->add
332 (FileSystem::FS_Filename(name),332 (FileSystem::fs_filename(name),
333 name,333 name,
334 g_gr->images().get("pics/ls_wlmap.png"));334 g_gr->images().get("pics/ls_wlmap.png"));
335 } catch (const WException &) {} // we simply skip illegal entries335 } catch (const WException &) {} // we simply skip illegal entries
@@ -355,7 +355,7 @@
355 */355 */
356bool MainMenuSaveMap::save_map(std::string filename, bool binary) {356bool MainMenuSaveMap::save_map(std::string filename, bool binary) {
357 // Make sure that the base directory exists.357 // Make sure that the base directory exists.
358 g_fs->EnsureDirectoryExists(m_basedir);358 g_fs->ensure_directory_exists(m_basedir);
359359
360 // OK, first check if the extension matches (ignoring case).360 // OK, first check if the extension matches (ignoring case).
361 bool assign_extension = true;361 bool assign_extension = true;
@@ -375,20 +375,20 @@
375 complete_filename += filename;375 complete_filename += filename;
376376
377 // Check if file exists. If so, show a warning.377 // Check if file exists. If so, show a warning.
378 if (g_fs->FileExists(complete_filename)) {378 if (g_fs->file_exists(complete_filename)) {
379 std::string s =379 std::string s =
380 (boost::format(_("A file with the name ‘%s’ already exists. Overwrite?"))380 (boost::format(_("A file with the name ‘%s’ already exists. Overwrite?"))
381 % FileSystem::FS_Filename(filename.c_str())).str();381 % FileSystem::fs_filename(filename.c_str())).str();
382 UI::WLMessageBox mbox382 UI::WLMessageBox mbox
383 (&eia(), _("Error Saving Map!"), s, UI::WLMessageBox::YESNO);383 (&eia(), _("Error Saving Map!"), s, UI::WLMessageBox::YESNO);
384 if (!mbox.run())384 if (!mbox.run())
385 return false;385 return false;
386386
387 g_fs->Unlink(complete_filename);387 g_fs->fs_unlink(complete_filename);
388 }388 }
389389
390 std::unique_ptr<FileSystem> fs390 std::unique_ptr<FileSystem> fs
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));
392 Widelands::MapSaver wms(*fs, eia().egbase());392 Widelands::MapSaver wms(*fs, eia().egbase());
393 try {393 try {
394 wms.save();394 wms.save();
395395
=== modified file 'src/editor/ui_menus/editor_main_menu_save_map_make_directory.cc'
--- src/editor/ui_menus/editor_main_menu_save_map_make_directory.cc 2014-09-10 14:08:25 +0000
+++ src/editor/ui_menus/editor_main_menu_save_map_make_directory.cc 2014-09-29 14:39:47 +0000
@@ -42,7 +42,7 @@
42 new UI::EditBox42 new UI::EditBox
43 (this, spacing, posy, get_inner_w() - 2 * spacing, 20,43 (this, spacing, posy, get_inner_w() - 2 * spacing, 20,
44 g_gr->images().get("pics/but1.png"));44 g_gr->images().get("pics/but1.png"));
45 m_edit->setText(dirname);45 m_edit->set_text(dirname);
46 m_dirname = dirname;46 m_dirname = dirname;
47 m_edit->changed.connect(boost::bind(&MainMenuSaveMapMakeDirectory::edit_changed, this));47 m_edit->changed.connect(boost::bind(&MainMenuSaveMapMakeDirectory::edit_changed, this));
4848
4949
=== modified file 'src/editor/ui_menus/editor_player_menu.cc'
--- src/editor/ui_menus/editor_player_menu.cc 2014-09-10 14:08:25 +0000
+++ src/editor/ui_menus/editor_player_menu.cc 2014-09-29 14:39:47 +0000
@@ -147,7 +147,7 @@
147 m_plr_names[p - 1]->changed.connect147 m_plr_names[p - 1]->changed.connect
148 (boost::bind(&EditorPlayerMenu::name_changed, this, p - 1));148 (boost::bind(&EditorPlayerMenu::name_changed, this, p - 1));
149 posx += 140 + spacing;149 posx += 140 + spacing;
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));
151 }151 }
152152
153 if (!m_plr_set_tribes_buts[p - 1]) {153 if (!m_plr_set_tribes_buts[p - 1]) {
@@ -356,7 +356,7 @@
356 // Register callback function to make sure that only valid locations are356 // Register callback function to make sure that only valid locations are
357 // selected.357 // selected.
358 map.overlay_manager().register_overlay_callback_function(358 map.overlay_manager().register_overlay_callback_function(
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)));
360 map.recalc_whole_map(menu.egbase().world());360 map.recalc_whole_map(menu.egbase().world());
361 update();361 update();
362}362}
@@ -372,10 +372,10 @@
372 Widelands::Map & map = menu.egbase().map();372 Widelands::Map & map = menu.egbase().map();
373 if (text == "") {373 if (text == "") {
374 text = map.get_scenario_player_name(m + 1);374 text = map.get_scenario_player_name(m + 1);
375 m_plr_names[m]->setText(text);375 m_plr_names[m]->set_text(text);
376 }376 }
377 map.set_scenario_player_name(m + 1, text);377 map.set_scenario_player_name(m + 1, text);
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));
379 menu.set_need_save(true);379 menu.set_need_save(true);
380}380}
381381
@@ -441,6 +441,6 @@
441 parent.select_tool(parent.tools.make_infrastructure, EditorTool::First);441 parent.select_tool(parent.tools.make_infrastructure, EditorTool::First);
442 parent.tools.make_infrastructure.set_player(n);442 parent.tools.make_infrastructure.set_player(n);
443 overlay_manager.register_overlay_callback_function(443 overlay_manager.register_overlay_callback_function(
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));
445 map.recalc_whole_map(egbase.world());445 map.recalc_whole_map(egbase.world());
446}446}
447447
=== modified file 'src/editor/ui_menus/editor_tool_change_resources_options_menu.cc'
--- src/editor/ui_menus/editor_tool_change_resources_options_menu.cc 2014-09-10 14:08:25 +0000
+++ src/editor/ui_menus/editor_tool_change_resources_options_menu.cc 2014-09-29 14:39:47 +0000
@@ -215,7 +215,7 @@
215 Widelands::EditorGameBase& egbase = ref_cast<EditorInteractive, UI::Panel>(*get_parent()).egbase();215 Widelands::EditorGameBase& egbase = ref_cast<EditorInteractive, UI::Panel>(*get_parent()).egbase();
216 Widelands::Map & map = egbase.map();216 Widelands::Map & map = egbase.map();
217 map.overlay_manager().register_overlay_callback_function(217 map.overlay_manager().register_overlay_callback_function(
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));
219 map.recalc_whole_map(egbase.world());219 map.recalc_whole_map(egbase.world());
220 select_correct_tool();220 select_correct_tool();
221221
222222
=== modified file 'src/editor/ui_menus/editor_tool_menu.cc'
--- src/editor/ui_menus/editor_tool_menu.cc 2014-09-10 14:08:25 +0000
+++ src/editor/ui_menus/editor_tool_menu.cc 2014-09-29 14:39:47 +0000
@@ -142,7 +142,7 @@
142 // Set correct overlay142 // Set correct overlay
143 Widelands::Map & map = parent.egbase().map();143 Widelands::Map & map = parent.egbase().map();
144 map.overlay_manager().register_overlay_callback_function(144 map.overlay_manager().register_overlay_callback_function(
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)));
146 map.recalc_whole_map(parent.egbase().world());146 map.recalc_whole_map(parent.egbase().world());
147 update();147 update();
148 }148 }
149149
=== modified file 'src/game_io/game_class_packet.cc'
--- src/game_io/game_class_packet.cc 2014-09-10 08:55:04 +0000
+++ src/game_io/game_class_packet.cc 2014-09-29 14:39:47 +0000
@@ -29,16 +29,16 @@
29#define CURRENT_PACKET_VERSION 229#define CURRENT_PACKET_VERSION 2
3030
3131
32void GameClassPacket::Read32void GameClassPacket::read
33 (FileSystem & fs, Game & game, MapObjectLoader *)33 (FileSystem & fs, Game & game, MapObjectLoader *)
34{34{
35 try {35 try {
36 FileRead fr;36 FileRead fr;
37 fr.Open(fs, "binary/game_class");37 fr.open(fs, "binary/game_class");
38 uint16_t const packet_version = fr.Unsigned16();38 uint16_t const packet_version = fr.unsigned_16();
39 if (packet_version <= CURRENT_PACKET_VERSION) {39 if (packet_version <= CURRENT_PACKET_VERSION) {
40 fr.Signed16(); // This used to be game speed40 fr.signed_16(); // This used to be game speed
41 game.gametime_ = fr.Unsigned32();41 game.gametime_ = fr.unsigned_32();
42 } else42 } else
43 throw GameDataError43 throw GameDataError
44 ("unknown/unhandled version %u", packet_version);44 ("unknown/unhandled version %u", packet_version);
@@ -50,17 +50,17 @@
50/*50/*
51 * Write Function51 * Write Function
52 */52 */
53void GameClassPacket::Write53void GameClassPacket::write
54 (FileSystem & fs, Game & game, MapObjectSaver * const)54 (FileSystem & fs, Game & game, MapObjectSaver * const)
55{55{
56 FileWrite fw;56 FileWrite fw;
5757
58 // Packet version58 // Packet version
59 fw.Unsigned16(CURRENT_PACKET_VERSION);59 fw.unsigned_16(CURRENT_PACKET_VERSION);
6060
61 // State is running, we do not need to save this61 // State is running, we do not need to save this
62 // Save speed62 // Save speed
63 fw.Signed16(1000);63 fw.signed_16(1000);
6464
65 // From the interactive player, is saved somewhere else65 // From the interactive player, is saved somewhere else
66 // Computer players are saved somewhere else66 // Computer players are saved somewhere else
@@ -70,7 +70,7 @@
7070
71 // EDITOR GAME CLASS71 // EDITOR GAME CLASS
72 // Write gametime72 // Write gametime
73 fw.Unsigned32(game.gametime_);73 fw.unsigned_32(game.gametime_);
7474
75 // We do not care for players, since they were set75 // We do not care for players, since they were set
76 // on game initialization to match Map::scenario_player_[names|tribes]76 // on game initialization to match Map::scenario_player_[names|tribes]
@@ -85,7 +85,7 @@
8585
86 // Track pointers are not saved in save games86 // Track pointers are not saved in save games
8787
88 fw.Write(fs, "binary/game_class");88 fw.write(fs, "binary/game_class");
89}89}
9090
91}91}
9292
=== modified file 'src/game_io/game_class_packet.h'
--- src/game_io/game_class_packet.h 2014-09-10 16:57:31 +0000
+++ src/game_io/game_class_packet.h 2014-09-29 14:39:47 +0000
@@ -29,8 +29,8 @@
29 * a game for a user (for example in a listbox)29 * a game for a user (for example in a listbox)
30 */30 */
31struct GameClassPacket : public GameDataPacket {31struct GameClassPacket : public GameDataPacket {
32 void Read (FileSystem &, Game &, MapObjectLoader * = nullptr) override;32 void read (FileSystem &, Game &, MapObjectLoader * = nullptr) override;
33 void Write(FileSystem &, Game &, MapObjectSaver * = nullptr) override;33 void write(FileSystem &, Game &, MapObjectSaver * = nullptr) override;
34};34};
3535
36}36}
3737
=== modified file 'src/game_io/game_cmd_queue_packet.cc'
--- src/game_io/game_cmd_queue_packet.cc 2014-09-14 16:08:13 +0000
+++ src/game_io/game_cmd_queue_packet.cc 2014-09-29 14:39:47 +0000
@@ -32,47 +32,47 @@
32#define CURRENT_PACKET_VERSION 232#define CURRENT_PACKET_VERSION 2
3333
3434
35void GameCmdQueuePacket::Read35void GameCmdQueuePacket::read
36 (FileSystem & fs, Game & game, MapObjectLoader * const ol)36 (FileSystem & fs, Game & game, MapObjectLoader * const ol)
37{37{
38 try {38 try {
39 FileRead fr;39 FileRead fr;
40 fr.Open(fs, "binary/cmd_queue");40 fr.open(fs, "binary/cmd_queue");
41 uint16_t const packet_version = fr.Unsigned16();41 uint16_t const packet_version = fr.unsigned_16();
42 if (packet_version == CURRENT_PACKET_VERSION) {42 if (packet_version == CURRENT_PACKET_VERSION) {
43 CmdQueue & cmdq = game.cmdqueue();43 CmdQueue & cmdq = game.cmdqueue();
4444
45 // nothing to be done for m_game45 // nothing to be done for m_game
4646
47 // Next serial47 // Next serial
48 cmdq.nextserial = fr.Unsigned32();48 cmdq.nextserial = fr.unsigned_32();
4949
50 // Erase all currently pending commands in the queue50 // Erase all currently pending commands in the queue
51 cmdq.flush();51 cmdq.flush();
5252
53 for (;;) {53 for (;;) {
54 uint32_t const packet_id = fr.Unsigned16();54 uint32_t const packet_id = fr.unsigned_16();
5555
56 if (!packet_id)56 if (!packet_id)
57 break;57 break;
5858
59 CmdQueue::CmdItem item;59 CmdQueue::CmdItem item;
60 item.category = fr.Signed32();60 item.category = fr.signed_32();
61 item.serial = fr.Unsigned32();61 item.serial = fr.unsigned_32();
6262
63 if (packet_id == 129) {63 if (packet_id == 129) {
64 // For backwards compatibility with savegames up to build15:64 // For backwards compatibility with savegames up to build15:
65 // Discard old CheckEventChain commands65 // Discard old CheckEventChain commands
66 fr.Unsigned16(); // CheckEventChain version66 fr.unsigned_16(); // CheckEventChain version
67 fr.Unsigned16(); // GameLogicCommand version67 fr.unsigned_16(); // GameLogicCommand version
68 fr.Unsigned32(); // GameLogicCommand duetime68 fr.unsigned_32(); // GameLogicCommand duetime
69 fr.Unsigned16(); // CheckEventChain ID69 fr.unsigned_16(); // CheckEventChain ID
70 continue;70 continue;
71 }71 }
7272
73 GameLogicCommand & cmd =73 GameLogicCommand & cmd =
74 QueueCmdFactory::create_correct_queue_command(packet_id);74 QueueCmdFactory::create_correct_queue_command(packet_id);
75 cmd.Read(fr, game, *ol);75 cmd.read(fr, game, *ol);
7676
77 item.cmd = &cmd;77 item.cmd = &cmd;
7878
@@ -88,20 +88,20 @@
88}88}
8989
9090
91void GameCmdQueuePacket::Write91void GameCmdQueuePacket::write
92 (FileSystem & fs, Game & game, MapObjectSaver * const os)92 (FileSystem & fs, Game & game, MapObjectSaver * const os)
93{93{
94 FileWrite fw;94 FileWrite fw;
9595
96 // Now packet version96 // Now packet version
97 fw.Unsigned16(CURRENT_PACKET_VERSION);97 fw.unsigned_16(CURRENT_PACKET_VERSION);
9898
99 const CmdQueue & cmdq = game.cmdqueue();99 const CmdQueue & cmdq = game.cmdqueue();
100100
101 // nothing to be done for m_game101 // nothing to be done for m_game
102102
103 // Next serial103 // Next serial
104 fw.Unsigned32(cmdq.nextserial);104 fw.unsigned_32(cmdq.nextserial);
105105
106 // Write all commands106 // Write all commands
107107
@@ -118,14 +118,14 @@
118 if (it.cmd->duetime() == time) {118 if (it.cmd->duetime() == time) {
119 if (upcast(GameLogicCommand, cmd, it.cmd)) {119 if (upcast(GameLogicCommand, cmd, it.cmd)) {
120 // The id (aka command type)120 // The id (aka command type)
121 fw.Unsigned16(cmd->id());121 fw.unsigned_16(cmd->id());
122122
123 // Serial number123 // Serial number
124 fw.Signed32(it.category);124 fw.signed_32(it.category);
125 fw.Unsigned32(it.serial);125 fw.unsigned_32(it.serial);
126126
127 // Now the command itself127 // Now the command itself
128 cmd->Write(fw, game, *os);128 cmd->write(fw, game, *os);
129 }129 }
130 ++ nhandled;130 ++ nhandled;
131 }131 }
@@ -137,9 +137,9 @@
137 }137 }
138138
139139
140 fw.Unsigned16(0); // end of command queue140 fw.unsigned_16(0); // end of command queue
141141
142 fw.Write(fs, "binary/cmd_queue");142 fw.write(fs, "binary/cmd_queue");
143}143}
144144
145}145}
146146
=== modified file 'src/game_io/game_cmd_queue_packet.h'
--- src/game_io/game_cmd_queue_packet.h 2014-09-10 16:57:31 +0000
+++ src/game_io/game_cmd_queue_packet.h 2014-09-29 14:39:47 +0000
@@ -31,8 +31,8 @@
31 * a game for a user (for example in a listbox)31 * a game for a user (for example in a listbox)
32 */32 */
33struct GameCmdQueuePacket : public GameDataPacket {33struct GameCmdQueuePacket : public GameDataPacket {
34 void Read (FileSystem &, Game &, MapObjectLoader * = nullptr) override;34 void read (FileSystem &, Game &, MapObjectLoader * = nullptr) override;
35 void Write(FileSystem &, Game &, MapObjectSaver * = nullptr) override;35 void write(FileSystem &, Game &, MapObjectSaver * = nullptr) override;
36};36};
3737
38}38}
3939
=== modified file 'src/game_io/game_data_packet.h'
--- src/game_io/game_data_packet.h 2014-09-10 07:57:29 +0000
+++ src/game_io/game_data_packet.h 2014-09-29 14:39:47 +0000
@@ -40,8 +40,8 @@
40*/40*/
41struct GameDataPacket {41struct GameDataPacket {
42 virtual ~GameDataPacket() {}42 virtual ~GameDataPacket() {}
43 virtual void Read (FileSystem &, Game &, MapObjectLoader * = nullptr) = 0;43 virtual void read (FileSystem &, Game &, MapObjectLoader * = nullptr) = 0;
44 virtual void Write(FileSystem &, Game &, MapObjectSaver * = nullptr) = 0;44 virtual void write(FileSystem &, Game &, MapObjectSaver * = nullptr) = 0;
45};45};
4646
47}47}
4848
=== modified file 'src/game_io/game_interactive_player_packet.cc'
--- src/game_io/game_interactive_player_packet.cc 2014-09-10 13:03:40 +0000
+++ src/game_io/game_interactive_player_packet.cc 2014-09-29 14:39:47 +0000
@@ -34,15 +34,15 @@
34#define CURRENT_PACKET_VERSION 234#define CURRENT_PACKET_VERSION 2
3535
3636
37void GameInteractivePlayerPacket::Read37void GameInteractivePlayerPacket::read
38 (FileSystem & fs, Game & game, MapObjectLoader *)38 (FileSystem & fs, Game & game, MapObjectLoader *)
39{39{
40 try {40 try {
41 FileRead fr;41 FileRead fr;
42 fr.Open(fs, "binary/interactive_player");42 fr.open(fs, "binary/interactive_player");
43 uint16_t const packet_version = fr.Unsigned16();43 uint16_t const packet_version = fr.unsigned_16();
44 if (packet_version == CURRENT_PACKET_VERSION) {44 if (packet_version == CURRENT_PACKET_VERSION) {
45 PlayerNumber player_number = fr.Unsigned8();45 PlayerNumber player_number = fr.unsigned_8();
46 if (!(0 < player_number && player_number <= game.map().get_nrplayers())) {46 if (!(0 < player_number && player_number <= game.map().get_nrplayers())) {
47 throw GameDataError("Invalid player number: %i.", player_number);47 throw GameDataError("Invalid player number: %i.", player_number);
48 }48 }
@@ -59,9 +59,9 @@
59 if (player_number > max)59 if (player_number > max)
60 throw GameDataError("The game has no players!");60 throw GameDataError("The game has no players!");
61 }61 }
62 int32_t const x = fr.Unsigned16();62 int32_t const x = fr.unsigned_16();
63 int32_t const y = fr.Unsigned16();63 int32_t const y = fr.unsigned_16();
64 uint32_t const display_flags = fr.Unsigned32();64 uint32_t const display_flags = fr.unsigned_32();
6565
66 if (InteractiveBase * const ibase = game.get_ibase()) {66 if (InteractiveBase * const ibase = game.get_ibase()) {
67 ibase->set_viewpoint(Point(x, y), true);67 ibase->set_viewpoint(Point(x, y), true);
@@ -88,32 +88,32 @@
88/*88/*
89 * Write Function89 * Write Function
90 */90 */
91void GameInteractivePlayerPacket::Write91void GameInteractivePlayerPacket::write
92 (FileSystem & fs, Game & game, MapObjectSaver * const)92 (FileSystem & fs, Game & game, MapObjectSaver * const)
93{93{
94 FileWrite fw;94 FileWrite fw;
9595
96 // Now packet version96 // Now packet version
97 fw.Unsigned16(CURRENT_PACKET_VERSION);97 fw.unsigned_16(CURRENT_PACKET_VERSION);
9898
99 InteractiveBase * const ibase = game.get_ibase();99 InteractiveBase * const ibase = game.get_ibase();
100 InteractivePlayer * const iplayer = game.get_ipl();100 InteractivePlayer * const iplayer = game.get_ipl();
101101
102 // Player number102 // Player number
103 fw.Unsigned8(iplayer ? iplayer->player_number() : 1);103 fw.unsigned_8(iplayer ? iplayer->player_number() : 1);
104104
105 // Map Position105 // Map Position
106 if (ibase) {106 if (ibase) {
107 assert(0 <= ibase->get_viewpoint().x);107 assert(0 <= ibase->get_viewpoint().x);
108 assert(0 <= ibase->get_viewpoint().y);108 assert(0 <= ibase->get_viewpoint().y);
109 }109 }
110 fw.Unsigned16(ibase ? ibase->get_viewpoint().x : 0);110 fw.unsigned_16(ibase ? ibase->get_viewpoint().x : 0);
111 fw.Unsigned16(ibase ? ibase->get_viewpoint().y : 0);111 fw.unsigned_16(ibase ? ibase->get_viewpoint().y : 0);
112112
113 // Display flags113 // Display flags
114 fw.Unsigned32(ibase ? ibase->get_display_flags() : 0);114 fw.unsigned_32(ibase ? ibase->get_display_flags() : 0);
115115
116 fw.Write(fs, "binary/interactive_player");116 fw.write(fs, "binary/interactive_player");
117}117}
118118
119}119}
120120
=== modified file 'src/game_io/game_interactive_player_packet.h'
--- src/game_io/game_interactive_player_packet.h 2014-09-10 16:57:31 +0000
+++ src/game_io/game_interactive_player_packet.h 2014-09-29 14:39:47 +0000
@@ -29,8 +29,8 @@
29 * player number and so on29 * player number and so on
30 */30 */
31struct GameInteractivePlayerPacket : public GameDataPacket {31struct GameInteractivePlayerPacket : public GameDataPacket {
32 void Read (FileSystem &, Game &, MapObjectLoader * = nullptr) override;32 void read (FileSystem &, Game &, MapObjectLoader * = nullptr) override;
33 void Write(FileSystem &, Game &, MapObjectSaver * = nullptr) override;33 void write(FileSystem &, Game &, MapObjectSaver * = nullptr) override;
34};34};
3535
36}36}
3737
=== modified file 'src/game_io/game_loader.cc'
--- src/game_io/game_loader.cc 2014-09-18 18:56:20 +0000
+++ src/game_io/game_loader.cc 2014-09-29 14:39:47 +0000
@@ -39,7 +39,7 @@
39namespace Widelands {39namespace Widelands {
4040
41GameLoader::GameLoader(const std::string & path, Game & game) :41GameLoader::GameLoader(const std::string & path, Game & game) :
42 m_fs(*g_fs->MakeSubFileSystem(path)), m_game(game)42 m_fs(*g_fs->make_sub_file_system(path)), m_game(game)
43{}43{}
4444
4545
@@ -52,7 +52,7 @@
52 */52 */
53int32_t GameLoader::preload_game(GamePreloadPacket & mp) {53int32_t GameLoader::preload_game(GamePreloadPacket & mp) {
54 // Load elemental data block54 // Load elemental data block
55 mp.Read(m_fs, m_game, nullptr);55 mp.read(m_fs, m_game, nullptr);
5656
57 return 0;57 return 0;
58}58}
@@ -64,33 +64,33 @@
64 ScopedTimer timer("GameLoader::load() took %ums");64 ScopedTimer timer("GameLoader::load() took %ums");
6565
66 log("Game: Reading Preload Data ... ");66 log("Game: Reading Preload Data ... ");
67 {GamePreloadPacket p; p.Read(m_fs, m_game);}67 {GamePreloadPacket p; p.read(m_fs, m_game);}
68 log("took %ums\n", timer.ms_since_last_query());68 log("took %ums\n", timer.ms_since_last_query());
6969
70 log("Game: Reading Game Class Data ... ");70 log("Game: Reading Game Class Data ... ");
71 {GameClassPacket p; p.Read(m_fs, m_game);}71 {GameClassPacket p; p.read(m_fs, m_game);}
72 log("took %ums\n", timer.ms_since_last_query());72 log("took %ums\n", timer.ms_since_last_query());
7373
74 log("Game: Reading Map Data ... ");74 log("Game: Reading Map Data ... ");
75 GameMapPacket M; M.Read(m_fs, m_game);75 GameMapPacket M; M.read(m_fs, m_game);
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());
7777
78 log("Game: Reading Player Info ... ");78 log("Game: Reading Player Info ... ");
79 {GamePlayerInfoPacket p; p.Read(m_fs, m_game);}79 {GamePlayerInfoPacket p; p.read(m_fs, m_game);}
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());
8181
82 log("Game: Calling Read_Complete()\n");82 log("Game: Calling read_complete()\n");
83 M.Read_Complete(m_game);83 M.read_complete(m_game);
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());
8585
86 MapObjectLoader * const mol = M.get_map_object_loader();86 MapObjectLoader * const mol = M.get_map_object_loader();
8787
88 log("Game: Reading Player Economies Info ... ");88 log("Game: Reading Player Economies Info ... ");
89 {GamePlayerEconomiesPacket p; p.Read(m_fs, m_game, mol);}89 {GamePlayerEconomiesPacket p; p.read(m_fs, m_game, mol);}
90 log("took %ums\n", timer.ms_since_last_query());90 log("took %ums\n", timer.ms_since_last_query());
9191
92 log("Game: Reading Command Queue Data ... ");92 log("Game: Reading Command Queue Data ... ");
93 {GameCmdQueuePacket p; p.Read(m_fs, m_game, mol);}93 {GameCmdQueuePacket p; p.read(m_fs, m_game, mol);}
94 log("took %ums\n", timer.ms_since_last_query());94 log("took %ums\n", timer.ms_since_last_query());
9595
96 // This must be after the command queue has been read.96 // This must be after the command queue has been read.
@@ -120,7 +120,7 @@
120 // player.120 // player.
121 if (!multiplayer) {121 if (!multiplayer) {
122 log("Game: Reading Interactive Player Data ... ");122 log("Game: Reading Interactive Player Data ... ");
123 {GameInteractivePlayerPacket p; p.Read(m_fs, m_game, mol);}123 {GameInteractivePlayerPacket p; p.read(m_fs, m_game, mol);}
124 log("took %ums\n", timer.ms_since_last_query());124 log("took %ums\n", timer.ms_since_last_query());
125 }125 }
126126
127127
=== modified file 'src/game_io/game_map_packet.cc'
--- src/game_io/game_map_packet.cc 2014-09-10 07:57:29 +0000
+++ src/game_io/game_map_packet.cc 2014-09-29 14:39:47 +0000
@@ -34,16 +34,16 @@
34 delete m_wml;34 delete m_wml;
35}35}
3636
37void GameMapPacket::Read37void GameMapPacket::read
38 (FileSystem & fs, Game & game, MapObjectLoader * const)38 (FileSystem & fs, Game & game, MapObjectLoader * const)
39{39{
40 if (!fs.FileExists("map") || !fs.IsDirectory("map"))40 if (!fs.file_exists("map") || !fs.is_directory("map"))
41 throw GameDataError("no map");41 throw GameDataError("no map");
4242
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.
44 delete m_wml;44 delete m_wml;
4545
46 m_wml = new WidelandsMapLoader(fs.MakeSubFileSystem("map"), &game.map());46 m_wml = new WidelandsMapLoader(fs.make_sub_file_system("map"), &game.map());
4747
48 m_wml->preload_map(true);48 m_wml->preload_map(true);
4949
@@ -53,18 +53,18 @@
53}53}
5454
5555
56void GameMapPacket::Read_Complete(Game & game) {56void GameMapPacket::read_complete(Game & game) {
57 m_wml->load_map_complete(game, true);57 m_wml->load_map_complete(game, true);
58 m_mol = m_wml->get_map_object_loader();58 m_mol = m_wml->get_map_object_loader();
59}59}
6060
6161
62void GameMapPacket::Write62void GameMapPacket::write
63 (FileSystem & fs, Game & game, MapObjectSaver * const)63 (FileSystem & fs, Game & game, MapObjectSaver * const)
64{64{
6565
66 std::unique_ptr<FileSystem> mapfs66 std::unique_ptr<FileSystem> mapfs
67 (fs.CreateSubFileSystem("map", FileSystem::DIR));67 (fs.create_sub_file_system("map", FileSystem::DIR));
6868
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.
70 delete m_wms;70 delete m_wms;
7171
=== modified file 'src/game_io/game_map_packet.h'
--- src/game_io/game_map_packet.h 2014-09-10 16:57:31 +0000
+++ src/game_io/game_map_packet.h 2014-09-29 14:39:47 +0000
@@ -36,11 +36,11 @@
3636
3737
38 /// Ensures that the world gets loaded but does not much more.38 /// Ensures that the world gets loaded but does not much more.
39 void Read (FileSystem &, Game &, MapObjectLoader * = nullptr) override;39 void read (FileSystem &, Game &, MapObjectLoader * = nullptr) override;
4040
41 void Read_Complete(Game &); /// Loads the rest of the map.41 void read_complete(Game &); /// Loads the rest of the map.
4242
43 void Write(FileSystem &, Game &, MapObjectSaver * = nullptr) override;43 void write(FileSystem &, Game &, MapObjectSaver * = nullptr) override;
4444
45 MapObjectSaver * get_map_object_saver () {return m_mos;}45 MapObjectSaver * get_map_object_saver () {return m_mos;}
46 MapObjectLoader * get_map_object_loader() {return m_mol;}46 MapObjectLoader * get_map_object_loader() {return m_mol;}
4747
=== modified file 'src/game_io/game_player_economies_packet.cc'
--- src/game_io/game_player_economies_packet.cc 2014-09-10 08:55:04 +0000
+++ src/game_io/game_player_economies_packet.cc 2014-09-29 14:39:47 +0000
@@ -35,7 +35,7 @@
35#define CURRENT_PACKET_VERSION 335#define CURRENT_PACKET_VERSION 3
3636
3737
38void GamePlayerEconomiesPacket::Read38void GamePlayerEconomiesPacket::read
39 (FileSystem & fs, Game & game, MapObjectLoader *)39 (FileSystem & fs, Game & game, MapObjectLoader *)
40{40{
41 try {41 try {
@@ -44,30 +44,30 @@
44 PlayerNumber const nr_players = map.get_nrplayers();44 PlayerNumber const nr_players = map.get_nrplayers();
4545
46 FileRead fr;46 FileRead fr;
47 fr.Open(fs, "binary/player_economies");47 fr.open(fs, "binary/player_economies");
48 uint16_t const packet_version = fr.Unsigned16();48 uint16_t const packet_version = fr.unsigned_16();
49 if (3 <= packet_version && packet_version <= CURRENT_PACKET_VERSION) {49 if (3 <= packet_version && packet_version <= CURRENT_PACKET_VERSION) {
50 iterate_players_existing(p, nr_players, game, player)50 iterate_players_existing(p, nr_players, game, player)
51 try {51 try {
52 Player::Economies & economies = player->m_economies;52 Player::Economies & economies = player->m_economies;
53 for (uint32_t i = 0; i < economies.size(); ++i) {53 for (uint32_t i = 0; i < economies.size(); ++i) {
54 uint32_t value = fr.Unsigned32();54 uint32_t value = fr.unsigned_32();
55 if (value < 0xffffffff) {55 if (value < 0xffffffff) {
56 if (upcast(Flag const, flag, map[value].get_immovable())) {56 if (upcast(Flag const, flag, map[value].get_immovable())) {
57 EconomyDataPacket d(flag->get_economy());57 EconomyDataPacket d(flag->get_economy());
58 d.Read(fr);58 d.read(fr);
59 } else {59 } else {
60 throw GameDataError("there is no flag at the specified location");60 throw GameDataError("there is no flag at the specified location");
61 }61 }
62 } else {62 } else {
63 bool read_this_economy = false;63 bool read_this_economy = false;
6464
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();
66 while (bob) {66 while (bob) {
67 if (upcast(Ship const, ship, bob)) {67 if (upcast(Ship const, ship, bob)) {
68 assert(ship->get_economy());68 assert(ship->get_economy());
69 EconomyDataPacket d(ship->get_economy());69 EconomyDataPacket d(ship->get_economy());
70 d.Read(fr);70 d.read(fr);
71 read_this_economy = true;71 read_this_economy = true;
72 }72 }
73 bob = bob->get_next_bob();73 bob = bob->get_next_bob();
@@ -91,12 +91,12 @@
91/*91/*
92 * Write Function92 * Write Function
93 */93 */
94void GamePlayerEconomiesPacket::Write94void GamePlayerEconomiesPacket::write
95 (FileSystem & fs, Game & game, MapObjectSaver * const)95 (FileSystem & fs, Game & game, MapObjectSaver * const)
96{96{
97 FileWrite fw;97 FileWrite fw;
9898
99 fw.Unsigned16(CURRENT_PACKET_VERSION);99 fw.unsigned_16(CURRENT_PACKET_VERSION);
100100
101 const Map & map = game.map();101 const Map & map = game.map();
102 const Field & field_0 = map[0];102 const Field & field_0 = map[0];
@@ -110,10 +110,10 @@
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) {
111 if (upcast(Flag const, flag, field->get_immovable())) {111 if (upcast(Flag const, flag, field->get_immovable())) {
112 if (flag->get_economy() == temp_economy) {112 if (flag->get_economy() == temp_economy) {
113 fw.Unsigned32(field - &field_0);113 fw.unsigned_32(field - &field_0);
114114
115 EconomyDataPacket d(flag->get_economy());115 EconomyDataPacket d(flag->get_economy());
116 d.Write(fw);116 d.write(fw);
117 wrote_this_economy = true;117 wrote_this_economy = true;
118 break;118 break;
119 }119 }
@@ -131,11 +131,11 @@
131 if (upcast(Ship const, ship, bob)) {131 if (upcast(Ship const, ship, bob)) {
132 if (ship->get_economy() == temp_economy) {132 if (ship->get_economy() == temp_economy) {
133 // TODO(sirver): the 0xffffffff is ugly and fragile.133 // TODO(sirver): the 0xffffffff is ugly and fragile.
134 fw.Unsigned32(0xffffffff); // Sentinel value.134 fw.unsigned_32(0xffffffff); // Sentinel value.
135 fw.Unsigned32(field - &field_0);135 fw.unsigned_32(field - &field_0);
136136
137 EconomyDataPacket d(ship->get_economy());137 EconomyDataPacket d(ship->get_economy());
138 d.Write(fw);138 d.write(fw);
139 wrote_this_economy = true;139 wrote_this_economy = true;
140 }140 }
141 }141 }
@@ -149,7 +149,7 @@
149 }149 }
150 }150 }
151151
152 fw.Write(fs, "binary/player_economies");152 fw.write(fs, "binary/player_economies");
153}153}
154154
155}155}
156156
=== modified file 'src/game_io/game_player_economies_packet.h'
--- src/game_io/game_player_economies_packet.h 2014-09-10 16:57:31 +0000
+++ src/game_io/game_player_economies_packet.h 2014-09-29 14:39:47 +0000
@@ -28,8 +28,8 @@
28 * how many and which economies does a player have?28 * how many and which economies does a player have?
29 */29 */
30struct GamePlayerEconomiesPacket : public GameDataPacket {30struct GamePlayerEconomiesPacket : public GameDataPacket {
31 void Read (FileSystem &, Game &, MapObjectLoader * = nullptr) override;31 void read (FileSystem &, Game &, MapObjectLoader * = nullptr) override;
32 void Write(FileSystem &, Game &, MapObjectSaver * = nullptr) override;32 void write(FileSystem &, Game &, MapObjectSaver * = nullptr) override;
33};33};
3434
35}35}
3636
=== modified file 'src/game_io/game_player_info_packet.cc'
--- src/game_io/game_player_info_packet.cc 2014-09-10 08:55:04 +0000
+++ src/game_io/game_player_info_packet.cc 2014-09-29 14:39:47 +0000
@@ -33,61 +33,61 @@
33#define CURRENT_PACKET_VERSION 1533#define CURRENT_PACKET_VERSION 15
3434
3535
36void GamePlayerInfoPacket::Read36void GamePlayerInfoPacket::read
37 (FileSystem & fs, Game & game, MapObjectLoader *)37 (FileSystem & fs, Game & game, MapObjectLoader *)
38{38{
39 try {39 try {
40 FileRead fr;40 FileRead fr;
41 fr.Open(fs, "binary/player_info");41 fr.open(fs, "binary/player_info");
42 uint16_t const packet_version = fr.Unsigned16();42 uint16_t const packet_version = fr.unsigned_16();
43 if (5 <= packet_version && packet_version <= CURRENT_PACKET_VERSION) {43 if (5 <= packet_version && packet_version <= CURRENT_PACKET_VERSION) {
44 uint32_t const max_players = fr.Unsigned16();44 uint32_t const max_players = fr.unsigned_16();
45 for (uint32_t i = 1; i < max_players + 1; ++i) {45 for (uint32_t i = 1; i < max_players + 1; ++i) {
46 game.remove_player(i);46 game.remove_player(i);
47 if (fr.Unsigned8()) {47 if (fr.unsigned_8()) {
48 bool const see_all = fr.Unsigned8();48 bool const see_all = fr.unsigned_8();
4949
50 int32_t const plnum = fr.Unsigned8();50 int32_t const plnum = fr.unsigned_8();
51 if (plnum < 1 || MAX_PLAYERS < plnum)51 if (plnum < 1 || MAX_PLAYERS < plnum)
52 throw GameDataError52 throw GameDataError
53 ("player number (%i) is out of range (1 .. %u)",53 ("player number (%i) is out of range (1 .. %u)",
54 plnum, MAX_PLAYERS);54 plnum, MAX_PLAYERS);
55 Widelands::TeamNumber team = 0;55 Widelands::TeamNumber team = 0;
56 if (packet_version >= 9)56 if (packet_version >= 9)
57 team = fr.Unsigned8();57 team = fr.unsigned_8();
5858
59 char const * const tribe_name = fr.CString();59 char const * const tribe_name = fr.c_string();
6060
61 std::string const name = fr.CString();61 std::string const name = fr.c_string();
6262
63 game.add_player(plnum, 0, tribe_name, name, team);63 game.add_player(plnum, 0, tribe_name, name, team);
64 Player & player = game.player(plnum);64 Player & player = game.player(plnum);
65 player.set_see_all(see_all);65 player.set_see_all(see_all);
6666
67 player.setAI(fr.CString());67 player.set_ai(fr.c_string());
6868
69 if (packet_version >= 15)69 if (packet_version >= 15)
70 player.ReadStatistics(fr, 3);70 player.read_statistics(fr, 3);
71 else if (packet_version >= 14)71 else if (packet_version >= 14)
72 player.ReadStatistics(fr, 2);72 player.read_statistics(fr, 2);
73 else if (packet_version >= 12)73 else if (packet_version >= 12)
74 player.ReadStatistics(fr, 1);74 player.read_statistics(fr, 1);
75 else75 else
76 player.ReadStatistics(fr, 0);76 player.read_statistics(fr, 0);
7777
78 player.m_casualties = fr.Unsigned32();78 player.m_casualties = fr.unsigned_32();
79 player.m_kills = fr.Unsigned32();79 player.m_kills = fr.unsigned_32();
80 player.m_msites_lost = fr.Unsigned32();80 player.m_msites_lost = fr.unsigned_32();
81 player.m_msites_defeated = fr.Unsigned32();81 player.m_msites_defeated = fr.unsigned_32();
82 player.m_civil_blds_lost = fr.Unsigned32();82 player.m_civil_blds_lost = fr.unsigned_32();
83 player.m_civil_blds_defeated = fr.Unsigned32();83 player.m_civil_blds_defeated = fr.unsigned_32();
84 }84 }
85 }85 }
8686
87 if (packet_version <= 10)87 if (packet_version <= 10)
88 game.ReadStatistics(fr, 3);88 game.read_statistics(fr, 3);
89 else89 else
90 game.ReadStatistics(fr, 4);90 game.read_statistics(fr, 4);
91 } else91 } else
92 throw GameDataError92 throw GameDataError
93 ("unknown/unhandled version %u", packet_version);93 ("unknown/unhandled version %u", packet_version);
@@ -97,48 +97,48 @@
97}97}
9898
9999
100void GamePlayerInfoPacket::Write100void GamePlayerInfoPacket::write
101 (FileSystem & fs, Game & game, MapObjectSaver *)101 (FileSystem & fs, Game & game, MapObjectSaver *)
102{102{
103 FileWrite fw;103 FileWrite fw;
104104
105 // Now packet version105 // Now packet version
106 fw.Unsigned16(CURRENT_PACKET_VERSION);106 fw.unsigned_16(CURRENT_PACKET_VERSION);
107107
108 // Number of (potential) players108 // Number of (potential) players
109 PlayerNumber const nr_players = game.map().get_nrplayers();109 PlayerNumber const nr_players = game.map().get_nrplayers();
110 fw.Unsigned16(nr_players);110 fw.unsigned_16(nr_players);
111 iterate_players_existing_const(p, nr_players, game, plr) {111 iterate_players_existing_const(p, nr_players, game, plr) {
112 fw.Unsigned8(1); // Player is in game.112 fw.unsigned_8(1); // Player is in game.
113113
114 fw.Unsigned8(plr->m_see_all);114 fw.unsigned_8(plr->m_see_all);
115115
116 fw.Unsigned8(plr->m_plnum);116 fw.unsigned_8(plr->m_plnum);
117 fw.Unsigned8(plr->team_number());117 fw.unsigned_8(plr->team_number());
118118
119 fw.CString(plr->tribe().name().c_str());119 fw.c_string(plr->tribe().name().c_str());
120120
121 // Seen fields is in a map packet121 // Seen fields is in a map packet
122 // Allowed buildings is in a map packet122 // Allowed buildings is in a map packet
123123
124 // Economies are in a packet after map loading124 // Economies are in a packet after map loading
125125
126 fw.CString(plr->m_name.c_str());126 fw.c_string(plr->m_name.c_str());
127 fw.CString(plr->m_ai.c_str());127 fw.c_string(plr->m_ai.c_str());
128128
129 plr->WriteStatistics(fw);129 plr->write_statistics(fw);
130 fw.Unsigned32(plr->casualties());130 fw.unsigned_32(plr->casualties());
131 fw.Unsigned32(plr->kills ());131 fw.unsigned_32(plr->kills ());
132 fw.Unsigned32(plr->msites_lost ());132 fw.unsigned_32(plr->msites_lost ());
133 fw.Unsigned32(plr->msites_defeated ());133 fw.unsigned_32(plr->msites_defeated ());
134 fw.Unsigned32(plr->civil_blds_lost ());134 fw.unsigned_32(plr->civil_blds_lost ());
135 fw.Unsigned32(plr->civil_blds_defeated());135 fw.unsigned_32(plr->civil_blds_defeated());
136 } else136 } else
137 fw.Unsigned8(0); // Player is NOT in game.137 fw.unsigned_8(0); // Player is NOT in game.
138138
139 game.WriteStatistics(fw);139 game.write_statistics(fw);
140140
141 fw.Write(fs, "binary/player_info");141 fw.write(fs, "binary/player_info");
142}142}
143143
144}144}
145145
=== modified file 'src/game_io/game_player_info_packet.h'
--- src/game_io/game_player_info_packet.h 2014-09-10 16:57:31 +0000
+++ src/game_io/game_player_info_packet.h 2014-09-29 14:39:47 +0000
@@ -29,8 +29,8 @@
29 * a game for a user (for example in a listbox)29 * a game for a user (for example in a listbox)
30 */30 */
31struct GamePlayerInfoPacket : public GameDataPacket {31struct GamePlayerInfoPacket : public GameDataPacket {
32 void Read (FileSystem &, Game &, MapObjectLoader * = nullptr) override;32 void read (FileSystem &, Game &, MapObjectLoader * = nullptr) override;
33 void Write(FileSystem &, Game &, MapObjectSaver * = nullptr) override;33 void write(FileSystem &, Game &, MapObjectSaver * = nullptr) override;
34};34};
3535
36}36}
3737
=== modified file 'src/game_io/game_preload_packet.cc'
--- src/game_io/game_preload_packet.cc 2014-09-10 13:03:40 +0000
+++ src/game_io/game_preload_packet.cc 2014-09-29 14:39:47 +0000
@@ -45,7 +45,7 @@
45#define MINIMAP_FILENAME "minimap.png"45#define MINIMAP_FILENAME "minimap.png"
4646
4747
48void GamePreloadPacket::Read48void GamePreloadPacket::read
49 (FileSystem & fs, Game &, MapObjectLoader * const)49 (FileSystem & fs, Game &, MapObjectLoader * const)
50{50{
51 try {51 try {
@@ -62,7 +62,7 @@
62 m_player_nr = s.get_safe_int("player_nr");62 m_player_nr = s.get_safe_int("player_nr");
63 m_win_condition = s.get_safe_string("win_condition");63 m_win_condition = s.get_safe_string("win_condition");
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);
65 if (fs.FileExists(MINIMAP_FILENAME)) {65 if (fs.file_exists(MINIMAP_FILENAME)) {
66 m_minimap_path = MINIMAP_FILENAME;66 m_minimap_path = MINIMAP_FILENAME;
67 }67 }
68 } else {68 } else {
@@ -75,7 +75,7 @@
75}75}
7676
7777
78void GamePreloadPacket::Write78void GamePreloadPacket::write
79 (FileSystem & fs, Game & game, MapObjectSaver * const)79 (FileSystem & fs, Game & game, MapObjectSaver * const)
80{80{
8181
@@ -116,10 +116,10 @@
116 if (ipl != nullptr) {116 if (ipl != nullptr) {
117 const MiniMapLayer flags = MiniMapLayer::Owner | MiniMapLayer::Building | MiniMapLayer::Terrain;117 const MiniMapLayer flags = MiniMapLayer::Owner | MiniMapLayer::Building | MiniMapLayer::Terrain;
118 const Point& vp = ipl->get_viewpoint();118 const Point& vp = ipl->get_viewpoint();
119 std::unique_ptr< ::StreamWrite> sw(fs.OpenStreamWrite(MINIMAP_FILENAME));119 std::unique_ptr< ::StreamWrite> sw(fs.open_stream_write(MINIMAP_FILENAME));
120 if (sw.get() != nullptr) {120 if (sw.get() != nullptr) {
121 write_minimap_image(game, &ipl->player(), vp, flags, sw.get());121 write_minimap_image(game, &ipl->player(), vp, flags, sw.get());
122 sw->Flush();122 sw->flush();
123 }123 }
124 }124 }
125}125}
126126
=== modified file 'src/game_io/game_preload_packet.h'
--- src/game_io/game_preload_packet.h 2014-09-10 16:57:31 +0000
+++ src/game_io/game_preload_packet.h 2014-09-29 14:39:47 +0000
@@ -32,8 +32,8 @@
32 * a game for a user (for example in a listbox)32 * a game for a user (for example in a listbox)
33 */33 */
34struct GamePreloadPacket : public GameDataPacket {34struct GamePreloadPacket : public GameDataPacket {
35 void Read (FileSystem &, Game &, MapObjectLoader * = nullptr) override;35 void read (FileSystem &, Game &, MapObjectLoader * = nullptr) override;
36 void Write(FileSystem &, Game &, MapObjectSaver * = nullptr) override;36 void write(FileSystem &, Game &, MapObjectSaver * = nullptr) override;
3737
38 char const * get_mapname() {return m_mapname.c_str();}38 char const * get_mapname() {return m_mapname.c_str();}
39 std::string get_background() {return m_background;}39 std::string get_background() {return m_background;}
4040
=== modified file 'src/game_io/game_saver.cc'
--- src/game_io/game_saver.cc 2014-09-10 16:57:31 +0000
+++ src/game_io/game_saver.cc 2014-09-29 14:39:47 +0000
@@ -43,36 +43,36 @@
43void GameSaver::save() {43void GameSaver::save() {
44 ScopedTimer timer("GameSaver::save() took %ums");44 ScopedTimer timer("GameSaver::save() took %ums");
4545
46 m_fs.EnsureDirectoryExists("binary");46 m_fs.ensure_directory_exists("binary");
4747
48 log("Game: Writing Preload Data ... ");48 log("Game: Writing Preload Data ... ");
49 {GamePreloadPacket p; p.Write(m_fs, m_game, nullptr);}49 {GamePreloadPacket p; p.write(m_fs, m_game, nullptr);}
50 log("took %ums\n", timer.ms_since_last_query());50 log("took %ums\n", timer.ms_since_last_query());
5151
52 log("Game: Writing Game Class Data ... ");52 log("Game: Writing Game Class Data ... ");
53 {GameClassPacket p; p.Write(m_fs, m_game, nullptr);}53 {GameClassPacket p; p.write(m_fs, m_game, nullptr);}
54 log("took %ums\n", timer.ms_since_last_query());54 log("took %ums\n", timer.ms_since_last_query());
5555
56 log("Game: Writing Player Info ... ");56 log("Game: Writing Player Info ... ");
57 {GamePlayerInfoPacket p; p.Write(m_fs, m_game, nullptr);}57 {GamePlayerInfoPacket p; p.write(m_fs, m_game, nullptr);}
58 log("took %ums\n", timer.ms_since_last_query());58 log("took %ums\n", timer.ms_since_last_query());
5959
60 log("Game: Writing Map Data!\n");60 log("Game: Writing Map Data!\n");
61 GameMapPacket M; M.Write(m_fs, m_game, nullptr);61 GameMapPacket M; M.write(m_fs, m_game, nullptr);
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());
6363
64 MapObjectSaver * const mos = M.get_map_object_saver();64 MapObjectSaver * const mos = M.get_map_object_saver();
6565
66 log("Game: Writing Player Economies Info ... ");66 log("Game: Writing Player Economies Info ... ");
67 {GamePlayerEconomiesPacket p; p.Write(m_fs, m_game, mos);}67 {GamePlayerEconomiesPacket p; p.write(m_fs, m_game, mos);}
68 log("took %ums\n", timer.ms_since_last_query());68 log("took %ums\n", timer.ms_since_last_query());
6969
70 log("Game: Writing Command Queue Data ... ");70 log("Game: Writing Command Queue Data ... ");
71 {GameCmdQueuePacket p; p.Write(m_fs, m_game, mos);}71 {GameCmdQueuePacket p; p.write(m_fs, m_game, mos);}
72 log("took %ums\n", timer.ms_since_last_query());72 log("took %ums\n", timer.ms_since_last_query());
7373
74 log("Game: Writing Interactive Player Data ... ");74 log("Game: Writing Interactive Player Data ... ");
75 {GameInteractivePlayerPacket p; p.Write(m_fs, m_game, mos);}75 {GameInteractivePlayerPacket p; p.write(m_fs, m_game, mos);}
76 log("took %ums\n", timer.ms_since_last_query());76 log("took %ums\n", timer.ms_since_last_query());
77}77}
7878
7979
=== modified file 'src/graphic/animation.cc'
--- src/graphic/animation.cc 2014-09-14 11:31:58 +0000
+++ src/graphic/animation.cc 2014-09-29 14:39:47 +0000
@@ -173,7 +173,7 @@
173 if (fps > 0)173 if (fps > 0)
174 frametime_ = 1000 / fps;174 frametime_ = 1000 / fps;
175175
176 hotspot_ = section.get_Point("hotspot");176 hotspot_ = section.get_point("hotspot");
177177
178 // In the filename template, the last sequence of '?' characters (if any)178 // In the filename template, the last sequence of '?' characters (if any)
179 // is replaced with a number, for example the template "idle_??" is179 // is replaced with a number, for example the template "idle_??" is
@@ -193,12 +193,12 @@
193 string filename_wo_ext;193 string filename_wo_ext;
194 while (glob.next(&filename_wo_ext)) {194 while (glob.next(&filename_wo_ext)) {
195 const string filename = filename_wo_ext + ".png";195 const string filename = filename_wo_ext + ".png";
196 if (!g_fs->FileExists(filename))196 if (!g_fs->file_exists(filename))
197 break;197 break;
198 image_files_.push_back(filename);198 image_files_.push_back(filename);
199199
200 const string pc_filename = filename_wo_ext + "_pc.png";200 const string pc_filename = filename_wo_ext + "_pc.png";
201 if (g_fs->FileExists(pc_filename)) {201 if (g_fs->file_exists(pc_filename)) {
202 hasplrclrs_ = true;202 hasplrclrs_ = true;
203 pc_mask_image_files_.push_back(pc_filename);203 pc_mask_image_files_.push_back(pc_filename);
204 }204 }
205205
=== modified file 'src/graphic/diranimations.h'
--- src/graphic/diranimations.h 2014-07-28 14:08:41 +0000
+++ src/graphic/diranimations.h 2014-09-29 14:39:47 +0000
@@ -52,7 +52,7 @@
52 m_animations[dir - 1] = anim;52 m_animations[dir - 1] = anim;
53 }53 }
5454
55 static DirAnimations Null() {55 static DirAnimations null() {
56 return DirAnimations(0); // Since real animation IDs are positive, this is safe56 return DirAnimations(0); // Since real animation IDs are positive, this is safe
57 }57 }
5858
5959
=== modified file 'src/graphic/font.cc'
--- src/graphic/font.cc 2014-09-14 11:31:58 +0000
+++ src/graphic/font.cc 2014-09-29 14:39:47 +0000
@@ -58,9 +58,9 @@
5858
59 // We must keep this File Read open, otherwise the following calls are59 // We must keep this File Read open, otherwise the following calls are
60 // crashing. do not know why...60 // crashing. do not know why...
61 m_fontfile.Open(*g_fs, filename);61 m_fontfile.open(*g_fs, filename);
6262
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());
64 if (!ops)64 if (!ops)
65 throw wexception("could not load font!: RWops Pointer invalid");65 throw wexception("could not load font!: RWops Pointer invalid");
6666
6767
=== modified file 'src/graphic/graphic.cc'
--- src/graphic/graphic.cc 2014-07-25 13:45:18 +0000
+++ src/graphic/graphic.cc 2014-09-29 14:39:47 +0000
@@ -309,7 +309,7 @@
309 SDL_GL_SwapBuffers();309 SDL_GL_SwapBuffers();
310 glEnable(GL_TEXTURE_2D);310 glEnable(GL_TEXTURE_2D);
311311
312 GLSurfaceTexture::Initialize(use_arb);312 GLSurfaceTexture::initialize(use_arb);
313 }313 }
314314
315 if (g_opengl)315 if (g_opengl)
@@ -341,7 +341,7 @@
341 UI::g_fh->flush();341 UI::g_fh->flush();
342342
343 if (g_opengl)343 if (g_opengl)
344 GLSurfaceTexture::Cleanup();344 GLSurfaceTexture::cleanup();
345}345}
346346
347Graphic::~Graphic()347Graphic::~Graphic()
@@ -487,7 +487,7 @@
487void Graphic::screenshot(const string& fname) const487void Graphic::screenshot(const string& fname) const
488{488{
489 log("Save screenshot to %s\n", fname.c_str());489 log("Save screenshot to %s\n", fname.c_str());
490 StreamWrite * sw = g_fs->OpenStreamWrite(fname);490 StreamWrite * sw = g_fs->open_stream_write(fname);
491 save_surface_to_png(screen_.get(), sw);491 save_surface_to_png(screen_.get(), sw);
492 delete sw;492 delete sw;
493}493}
494494
=== modified file 'src/graphic/image_io.cc'
--- src/graphic/image_io.cc 2014-07-14 10:45:44 +0000
+++ src/graphic/image_io.cc 2014-09-29 14:39:47 +0000
@@ -35,14 +35,14 @@
3535
36// A helper function for save_surface_to_png. Writes the compressed data to36// A helper function for save_surface_to_png. Writes the compressed data to
37// the StreamWrite.37// the StreamWrite.
38void png_write_function(png_structp png_ptr, png_bytep data, png_size_t length) {38void png_write_function(png_structp png_ptr, png_bytep png_data, png_size_t length) {
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);
40}40}
4141
42// A helper function for save_surface_to_png.42// A helper function for save_surface_to_png.
43// Flush function to avoid crashes with default libpng flush function43// Flush function to avoid crashes with default libpng flush function
44void png_flush_function(png_structp png_ptr) {44void png_flush_function(png_structp png_ptr) {
45 static_cast<StreamWrite*>(png_get_io_ptr(png_ptr))->Flush();45 static_cast<StreamWrite*>(png_get_io_ptr(png_ptr))->flush();
46}46}
4747
48} // namespace48} // namespace
@@ -55,16 +55,16 @@
55 FileRead fr;55 FileRead fr;
56 bool found;56 bool found;
57 if (fs) {57 if (fs) {
58 found = fr.TryOpen(*fs, fname);58 found = fr.try_open(*fs, fname);
59 } else {59 } else {
60 found = fr.TryOpen(*g_fs, fname);60 found = fr.try_open(*g_fs, fname);
61 }61 }
6262
63 if (!found) {63 if (!found) {
64 throw ImageNotFound(fname);64 throw ImageNotFound(fname);
65 }65 }
6666
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);
68 if (!sdlsurf) {68 if (!sdlsurf) {
69 throw ImageLoadingError(fname.c_str(), IMG_GetError());69 throw ImageLoadingError(fname.c_str(), IMG_GetError());
70 }70 }
7171
=== modified file 'src/graphic/render/gamerenderer_gl.cc'
--- src/graphic/render/gamerenderer_gl.cc 2014-09-14 16:08:13 +0000
+++ src/graphic/render/gamerenderer_gl.cc 2014-09-29 14:39:47 +0000
@@ -295,7 +295,7 @@
295 const Texture & texture =295 const Texture & texture =
296 *g_gr->get_maptexture_data296 *g_gr->get_maptexture_data
297 (world.terrain_descr(ter).get_texture());297 (world.terrain_descr(ter).get_texture());
298 glBindTexture(GL_TEXTURE_2D, texture.getTexture());298 glBindTexture(GL_TEXTURE_2D, texture.get_texture());
299 glDrawRangeElements299 glDrawRangeElements
300 (GL_TRIANGLES,300 (GL_TRIANGLES,
301 0, m_patch_size.w * m_patch_size.h - 1,301 0, m_patch_size.w * m_patch_size.h - 1,
@@ -472,7 +472,7 @@
472 const Texture & texture =472 const Texture & texture =
473 *g_gr->get_maptexture_data473 *g_gr->get_maptexture_data
474 (m_egbase->world().terrain_descr(ter).get_texture());474 (m_egbase->world().terrain_descr(ter).get_texture());
475 glBindTexture(GL_TEXTURE_2D, texture.getTexture());475 glBindTexture(GL_TEXTURE_2D, texture.get_texture());
476 glDrawArrays476 glDrawArrays
477 (GL_TRIANGLES,477 (GL_TRIANGLES,
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]);
479479
=== modified file 'src/graphic/render/gl_surface_texture.cc'
--- src/graphic/render/gl_surface_texture.cc 2014-07-20 07:44:53 +0000
+++ src/graphic/render/gl_surface_texture.cc 2014-09-29 14:39:47 +0000
@@ -32,7 +32,7 @@
32/**32/**
33 * Initial global resources needed for fast offscreen rendering.33 * Initial global resources needed for fast offscreen rendering.
34 */34 */
35void GLSurfaceTexture::Initialize(bool use_arb) {35void GLSurfaceTexture::initialize(bool use_arb) {
36 use_arb_ = use_arb;36 use_arb_ = use_arb;
3737
38 // Generate the framebuffer for Offscreen rendering.38 // Generate the framebuffer for Offscreen rendering.
@@ -48,7 +48,7 @@
48/**48/**
49 * Free global resources.49 * Free global resources.
50 */50 */
51void GLSurfaceTexture::Cleanup() {51void GLSurfaceTexture::cleanup() {
52 if (use_arb_)52 if (use_arb_)
53 glDeleteFramebuffers(1, &gl_framebuffer_id_);53 glDeleteFramebuffers(1, &gl_framebuffer_id_);
54 else54 else
5555
=== modified file 'src/graphic/render/gl_surface_texture.h'
--- src/graphic/render/gl_surface_texture.h 2014-07-26 10:43:23 +0000
+++ src/graphic/render/gl_surface_texture.h 2014-09-29 14:39:47 +0000
@@ -25,10 +25,10 @@
2525
26class GLSurfaceTexture : public GLSurface {26class GLSurfaceTexture : public GLSurface {
27public:27public:
28 // Call this once before using any instance of this class and Cleanup once28 // Call this once before using any instance of this class and cleanup once
29 // before the program exits.29 // before the program exits.
30 static void Initialize(bool use_arb);30 static void initialize(bool use_arb);
31 static void Cleanup();31 static void cleanup();
3232
33 GLSurfaceTexture(SDL_Surface * surface, bool intensity = false);33 GLSurfaceTexture(SDL_Surface * surface, bool intensity = false);
34 GLSurfaceTexture(int w, int h);34 GLSurfaceTexture(int w, int h);
3535
=== modified file 'src/graphic/text/font_io.cc'
--- src/graphic/text/font_io.cc 2014-09-10 16:57:31 +0000
+++ src/graphic/text/font_io.cc 2014-09-29 14:39:47 +0000
@@ -41,8 +41,8 @@
41 std::unique_ptr<std::string> memory;41 std::unique_ptr<std::string> memory;
42 {42 {
43 FileRead* fr = new FileRead();43 FileRead* fr = new FileRead();
44 fr->Open(*g_fs, filename);44 fr->open(*g_fs, filename);
45 memory.reset(new std::string(fr->Data(0), fr->GetSize()));45 memory.reset(new std::string(fr->data(0), fr->get_size()));
46 }46 }
4747
48 SDL_RWops* ops = SDL_RWFromConstMem(memory->data(), memory->size());48 SDL_RWops* ops = SDL_RWFromConstMem(memory->data(), memory->size());
4949
=== modified file 'src/graphic/text/test/render.cc'
--- src/graphic/text/test/render.cc 2014-07-14 10:45:44 +0000
+++ src/graphic/text/test/render.cc 2014-09-29 14:39:47 +0000
@@ -32,8 +32,8 @@
3232
33StandaloneRenderer::StandaloneRenderer() {33StandaloneRenderer::StandaloneRenderer() {
34 g_fs = new LayeredFileSystem();34 g_fs = new LayeredFileSystem();
35 g_fs->AddFileSystem(&FileSystem::Create(WIDELANDS_DATA_DIR));35 g_fs->add_file_system(&FileSystem::create(WIDELANDS_DATA_DIR));
36 g_fs->AddFileSystem(&FileSystem::Create(RICHTEXT_DATA_DIR));36 g_fs->add_file_system(&FileSystem::create(RICHTEXT_DATA_DIR));
3737
38 surface_cache_.reset(create_surface_cache(500 << 20)); // 500 MB38 surface_cache_.reset(create_surface_cache(500 << 20)); // 500 MB
39 image_cache_.reset(new ImageCache(surface_cache_.get()));39 image_cache_.reset(new ImageCache(surface_cache_.get()));
4040
=== modified file 'src/graphic/text/test/render_richtext.cc'
--- src/graphic/text/test/render_richtext.cc 2014-07-20 07:44:53 +0000
+++ src/graphic/text/test/render_richtext.cc 2014-09-29 14:39:47 +0000
@@ -123,8 +123,8 @@
123 std::unique_ptr<SDLSurface> surf(123 std::unique_ptr<SDLSurface> surf(
124 static_cast<SDLSurface*>(standalone_renderer.renderer()->render(txt, w, allowed_tags)));124 static_cast<SDLSurface*>(standalone_renderer.renderer()->render(txt, w, allowed_tags)));
125125
126 std::unique_ptr<FileSystem> fs(&FileSystem::Create("."));126 std::unique_ptr<FileSystem> fs(&FileSystem::create("."));
127 std::unique_ptr<StreamWrite> sw(fs->OpenStreamWrite(outname));127 std::unique_ptr<StreamWrite> sw(fs->open_stream_write(outname));
128 if (!save_surface_to_png(surf.get(), sw.get())) {128 if (!save_surface_to_png(surf.get(), sw.get())) {
129 std::cout << "Could not encode PNG." << std::endl;129 std::cout << "Could not encode PNG." << std::endl;
130 }130 }
131131
=== modified file 'src/graphic/texture.cc'
--- src/graphic/texture.cc 2014-07-17 13:26:23 +0000
+++ src/graphic/texture.cc 2014-09-29 14:39:47 +0000
@@ -51,7 +51,7 @@
51 }51 }
5252
53 for (const std::string& fname : texture_files) {53 for (const std::string& fname : texture_files) {
54 if (!g_fs->FileExists(fname)) {54 if (!g_fs->file_exists(fname)) {
55 throw wexception("Could not find %s.", fname.c_str());55 throw wexception("Could not find %s.", fname.c_str());
56 }56 }
5757
5858
=== modified file 'src/graphic/texture.h'
--- src/graphic/texture.h 2014-07-12 12:35:05 +0000
+++ src/graphic/texture.h 2014-09-29 14:39:47 +0000
@@ -59,7 +59,7 @@
59 RGBColor get_minimap_color(int8_t shade);59 RGBColor get_minimap_color(int8_t shade);
6060
61 void animate(uint32_t time);61 void animate(uint32_t time);
62 uint32_t getTexture() const62 uint32_t get_texture() const
63 {return m_glFrames.at(m_frame_num)->get_gl_texture();}63 {return m_glFrames.at(m_frame_num)->get_gl_texture();}
6464
65private:65private:
6666
=== modified file 'src/io/dedicated_log.cc'
--- src/io/dedicated_log.cc 2014-06-08 21:47:45 +0000
+++ src/io/dedicated_log.cc 2014-09-29 14:39:47 +0000
@@ -97,18 +97,18 @@
97 temp += c.sender.empty() ? "SYSTEM" : c.sender;97 temp += c.sender.empty() ? "SYSTEM" : c.sender;
98 temp += "</td><td class=\"recipient\"> ->" + c.recipient + "</td><td class=\"message\">";98 temp += "</td><td class=\"recipient\"> ->" + c.recipient + "</td><td class=\"message\">";
99 temp += c.msg + "</td></tr>\n";99 temp += c.msg + "</td></tr>\n";
100 m_chat.Printf("%s", temp.c_str());100 m_chat.print_f("%s", temp.c_str());
101 m_chat.WriteAppend(*root, m_chat_file_path.c_str());101 m_chat.write_append(*root, m_chat_file_path.c_str());
102}102}
103103
104/// Add's a spacer to the chat log104/// Add's a spacer to the chat log
105void DedicatedLog::chatAddSpacer() {105void DedicatedLog::chat_add_spacer() {
106 if (m_chat_file_path.empty())106 if (m_chat_file_path.empty())
107 return;107 return;
108108
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>");
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");
111 m_chat.WriteAppend(*root, m_chat_file_path.c_str());111 m_chat.write_append(*root, m_chat_file_path.c_str());
112}112}
113113
114114
@@ -206,8 +206,8 @@
206 }206 }
207 }207 }
208 temp += "</table>\n";208 temp += "</table>\n";
209 m_chat.Printf("%s", temp.c_str());209 m_chat.print_f("%s", temp.c_str());
210 m_chat.Write(*root, m_info_file_path.c_str());210 m_chat.write(*root, m_info_file_path.c_str());
211}211}
212212
213/// Appends the String \arg msg to the log file213/// Appends the String \arg msg to the log file
@@ -224,8 +224,8 @@
224 temp += "</td><td class=\"log\">";224 temp += "</td><td class=\"log\">";
225 temp += msg;225 temp += msg;
226 temp += "</td></tr>\n";226 temp += "</td></tr>\n";
227 m_chat.Printf("%s", temp.c_str());227 m_chat.print_f("%s", temp.c_str());
228 m_chat.WriteAppend(*root, m_log_file_path.c_str());228 m_chat.write_append(*root, m_log_file_path.c_str());
229}229}
230230
231231
@@ -252,8 +252,8 @@
252 m_chat_file_path = path;252 m_chat_file_path = path;
253253
254 // Initialize the chat file254 // Initialize the chat file
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>");
256 m_chat.Write(*root, m_chat_file_path.c_str()); // Not WriteAppend, to make sure the file is cleared256 m_chat.write(*root, m_chat_file_path.c_str()); // Not write_append, to make sure the file is cleared
257 return true;257 return true;
258}258}
259259
@@ -307,8 +307,8 @@
307 m_log_file_path = path;307 m_log_file_path = path;
308308
309 // Initialize the log file309 // Initialize the log file
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");
311 m_chat.Write(*root, m_log_file_path.c_str()); // Not WriteAppend, to make sure the file is cleared311 m_chat.write(*root, m_log_file_path.c_str()); // Not write_append, to make sure the file is cleared
312 return true;312 return true;
313}313}
314314
@@ -323,14 +323,14 @@
323 * written to does not exist, in all other cases true.323 * written to does not exist, in all other cases true.
324 */324 */
325bool DedicatedLog::check_file_writeable(std::string & path) {325bool DedicatedLog::check_file_writeable(std::string & path) {
326 bool existing = root->FileExists(path);326 bool existing = root->file_exists(path);
327 if (existing && root->IsDirectory(path))327 if (existing && root->is_directory(path))
328 return false;328 return false;
329 if (root->FileIsWriteable(path)) {329 if (root->file_is_writeable(path)) {
330 if (existing) {330 if (existing) {
331 std::string rnpath(path + '~');331 std::string rnpath(path + '~');
332 if (root->FileIsWriteable(rnpath))332 if (root->file_is_writeable(rnpath))
333 root->Rename(path, rnpath);333 root->fs_rename(path, rnpath);
334 else334 else
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());
336 }336 }
337337
=== modified file 'src/io/dedicated_log.h'
--- src/io/dedicated_log.h 2014-07-13 18:20:03 +0000
+++ src/io/dedicated_log.h 2014-09-29 14:39:47 +0000
@@ -33,7 +33,7 @@
33 static DedicatedLog * get();33 static DedicatedLog * get();
3434
35 // chat logging functions35 // chat logging functions
36 void chatAddSpacer();36 void chat_add_spacer();
37 void chat(ChatMessage & c);37 void chat(ChatMessage & c);
3838
39 // info logging functions39 // info logging functions
4040
=== modified file 'src/io/fileread.cc'
--- src/io/fileread.cc 2014-09-09 17:15:20 +0000
+++ src/io/fileread.cc 2014-09-29 14:39:47 +0000
@@ -23,19 +23,19 @@
2323
24FileRead::~FileRead() {24FileRead::~FileRead() {
25 if (data_) {25 if (data_) {
26 Close();26 close();
27 }27 }
28}28}
2929
30void FileRead::Open(FileSystem& fs, const std::string& filename) {30void FileRead::open(FileSystem& fs, const std::string& filename) {
31 assert(!data_);31 assert(!data_);
32 data_ = static_cast<char*>(fs.Load(filename, length_));32 data_ = static_cast<char*>(fs.load(filename, length_));
33 filepos_ = 0;33 filepos_ = 0;
34}34}
3535
36bool FileRead::TryOpen(FileSystem& fs, const std::string& filename) {36bool FileRead::try_open(FileSystem& fs, const std::string& filename) {
37 try {37 try {
38 Open(fs, filename);38 open(fs, filename);
39 }39 }
40 catch (const std::exception&) {40 catch (const std::exception&) {
41 return false;41 return false;
@@ -43,32 +43,32 @@
43 return true;43 return true;
44}44}
4545
46void FileRead::Close() {46void FileRead::close() {
47 assert(data_);47 assert(data_);
48 free(data_);48 free(data_);
49 data_ = nullptr;49 data_ = nullptr;
50}50}
5151
52size_t FileRead::GetSize() const {52size_t FileRead::get_size() const {
53 return length_;53 return length_;
54}54}
5555
56bool FileRead::EndOfFile() const {56bool FileRead::end_of_file() const {
57 return length_ <= filepos_;57 return length_ <= filepos_;
58}58}
5959
60void FileRead::SetFilePos(Pos const pos) {60void FileRead::set_file_pos(Pos const pos) {
61 assert(data_);61 assert(data_);
62 if (pos >= length_)62 if (pos >= length_)
63 throw FileBoundaryExceeded();63 throw FileBoundaryExceeded();
64 filepos_ = pos;64 filepos_ = pos;
65}65}
6666
67FileRead::Pos FileRead::GetPos() const {67FileRead::Pos FileRead::get_pos() const {
68 return filepos_;68 return filepos_;
69}69}
7070
71size_t FileRead::Data(void* dst, size_t bufsize) {71size_t FileRead::data(void* dst, size_t bufsize) {
72 assert(data_);72 assert(data_);
73 size_t read = 0;73 size_t read = 0;
74 for (; read < bufsize && filepos_ < length_; ++read, ++filepos_) {74 for (; read < bufsize && filepos_ < length_; ++read, ++filepos_) {
@@ -77,10 +77,10 @@
77 return read;77 return read;
78}78}
7979
80char* FileRead::Data(uint32_t const bytes, const Pos pos) {80char* FileRead::data(uint32_t const bytes, const Pos pos) {
81 assert(data_);81 assert(data_);
82 Pos i = pos;82 Pos i = pos;
83 if (pos.isNull()) {83 if (pos.is_null()) {
84 i = filepos_;84 i = filepos_;
85 filepos_ += bytes;85 filepos_ += bytes;
86 }86 }
@@ -89,10 +89,10 @@
89 return data_ + i;89 return data_ + i;
90}90}
9191
92char* FileRead::CString(Pos const pos) {92char* FileRead::c_string(Pos const pos) {
93 assert(data_);93 assert(data_);
9494
95 Pos i = pos.isNull() ? filepos_ : pos;95 Pos i = pos.is_null() ? filepos_ : pos;
96 if (i >= length_)96 if (i >= length_)
97 throw FileBoundaryExceeded();97 throw FileBoundaryExceeded();
98 char* const result = data_ + i;98 char* const result = data_ + i;
@@ -101,17 +101,17 @@
101 ++i; // beyond the null101 ++i; // beyond the null
102 if (i > (length_ + 1)) // allow EOF as end marker for string102 if (i > (length_ + 1)) // allow EOF as end marker for string
103 throw FileBoundaryExceeded();103 throw FileBoundaryExceeded();
104 if (pos.isNull())104 if (pos.is_null())
105 filepos_ = i;105 filepos_ = i;
106 return result;106 return result;
107}107}
108108
109char const* FileRead::CString() {109char const* FileRead::c_string() {
110 return CString(Pos::Null());110 return c_string(Pos::null());
111}111}
112112
113char* FileRead::ReadLine() {113char* FileRead::read_line() {
114 if (EndOfFile())114 if (end_of_file())
115 return nullptr;115 return nullptr;
116 char* result = data_ + filepos_;116 char* result = data_ + filepos_;
117 for (; data_[filepos_] && data_[filepos_] != '\n'; ++filepos_)117 for (; data_[filepos_] && data_[filepos_] != '\n'; ++filepos_)
118118
=== modified file 'src/io/fileread.h'
--- src/io/fileread.h 2014-09-09 17:15:20 +0000
+++ src/io/fileread.h 2014-09-29 14:39:47 +0000
@@ -40,12 +40,12 @@
40 Pos(size_t const p = 0) : pos(p) {40 Pos(size_t const p = 0) : pos(p) {
41 }41 }
42 /// Returns a special value indicating invalidity.42 /// Returns a special value indicating invalidity.
43 static Pos Null() {43 static Pos null() {
44 return std::numeric_limits<size_t>::max();44 return std::numeric_limits<size_t>::max();
45 }45 }
4646
47 bool isNull() const {47 bool is_null() const {
48 return *this == Null();48 return *this == null();
49 }49 }
50 operator size_t() const {50 operator size_t() const {
51 return pos;51 return pos;
@@ -72,45 +72,45 @@
72 ~FileRead() override;72 ~FileRead() override;
7373
74 // See base class.74 // See base class.
75 size_t Data(void* dst, size_t bufsize) override;75 size_t data(void* dst, size_t bufsize) override;
76 bool EndOfFile() const override;76 bool end_of_file() const override;
77 char const* CString() override;77 char const* c_string() override;
7878
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,
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.
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.
8282
83 // TODO(unknown): error handling83 // TODO(unknown): error handling
84 void Open(FileSystem& fs, const std::string& filename);84 void open(FileSystem& fs, const std::string& filename);
8585
86 /// Works just like Open, but returns false when the load fails.86 /// Works just like open, but returns false when the load fails.
87 // TODO(sirver): This method can be expressed through Open() and should not87 // TODO(sirver): This method can be expressed through open() and should not
88 // be part of the public API, rather a stand alone function.88 // be part of the public API, rather a stand alone function.
89 bool TryOpen(FileSystem& fs, const std::string& filename);89 bool try_open(FileSystem& fs, const std::string& filename);
9090
91 /// Frees allocated memory.91 /// Frees allocated memory.
92 void Close();92 void close();
9393
94 // Returns the size of the file in bytes;94 // Returns the size of the file in bytes;
95 size_t GetSize() const;95 size_t get_size() const;
9696
97 /// Set the file pointer to the given location.97 /// Set the file pointer to the given location.
98 /// \throws File_Boundary_Exceeded if the pointer is out of bound.98 /// \throws File_Boundary_Exceeded if the pointer is out of bound.
99 void SetFilePos(Pos pos);99 void set_file_pos(Pos pos);
100100
101 /// Get the position that will be read from in the next read operation that101 /// Get the position that will be read from in the next read operation that
102 /// does not specify a position.102 /// does not specify a position.
103 Pos GetPos() const;103 Pos get_pos() const;
104104
105 // Returns the next 'bytes' starting at 'pos' in the file. Can throw105 // Returns the next 'bytes' starting at 'pos' in the file. Can throw
106 // File_Boundary_Exceeded.106 // File_Boundary_Exceeded.
107 char* Data(uint32_t bytes, Pos pos = Pos::Null());107 char* data(uint32_t bytes, Pos pos = Pos::null());
108108
109 // Returns the whole file as a string starting from 'pos'.109 // Returns the whole file as a string starting from 'pos'.
110 char* CString(Pos pos);110 char* c_string(Pos pos);
111111
112 // Returns the next line.112 // Returns the next line.
113 char* ReadLine();113 char* read_line();
114114
115private:115private:
116 char* data_;116 char* data_;
117117
=== modified file 'src/io/filesystem/disk_filesystem.cc'
--- src/io/filesystem/disk_filesystem.cc 2014-09-14 11:31:58 +0000
+++ src/io/filesystem/disk_filesystem.cc 2014-09-29 14:39:47 +0000
@@ -71,22 +71,22 @@
71: m_directory(Directory)71: m_directory(Directory)
72{72{
73 // TODO(unknown): check OS permissions on whether the directory is writable!73 // TODO(unknown): check OS permissions on whether the directory is writable!
74 m_root = FS_CanonicalizeName(Directory);74 m_root = canonicalize_name(Directory);
75}75}
7676
7777
78/**78/**
79 * SHOULD return true if this directory is writable.79 * SHOULD return true if this directory is writable.
80 */80 */
81bool RealFSImpl::IsWritable() const {81bool RealFSImpl::is_writable() const {
82 // Should be checked here (ondisk state can change)82 // Should be checked here (ondisk state can change)
83 return true;83 return true;
84}84}
8585
86/// returns true, if the file is writeable86/// returns true, if the file is writeable
87bool RealFSImpl::FileIsWriteable(const std::string & path) {87bool RealFSImpl::file_is_writeable(const std::string & path) {
88 std::string fullname;88 std::string fullname;
89 fullname = FS_CanonicalizeName(path);89 fullname = canonicalize_name(path);
9090
91 // we call fopen with "a" == append to be sure nothing gets overwritten91 // we call fopen with "a" == append to be sure nothing gets overwritten
92 FILE * const f = fopen(fullname.c_str(), "a");92 FILE * const f = fopen(fullname.c_str(), "a");
@@ -97,7 +97,7 @@
97}97}
9898
9999
100std::set<std::string> RealFSImpl::ListDirectory(const std::string & path)100std::set<std::string> RealFSImpl::list_directory(const std::string & path)
101{101{
102#ifdef _WIN32102#ifdef _WIN32
103 std::string buf;103 std::string buf;
@@ -124,7 +124,7 @@
124 if ((strcmp(c_file.name, ".") == 0) || (strcmp(c_file.name, "..") == 0)) {124 if ((strcmp(c_file.name, ".") == 0) || (strcmp(c_file.name, "..") == 0)) {
125 continue;125 continue;
126 }126 }
127 const std::string filename = FS_CanonicalizeName(realpath + c_file.name);127 const std::string filename = canonicalize_name(realpath + c_file.name);
128 const std::string result = filename.substr(m_root.size() + 1);128 const std::string result = filename.substr(m_root.size() + 1);
129 results.insert(result);129 results.insert(result);
130 } while (_findnext(hFile, &c_file) == 0);130 } while (_findnext(hFile, &c_file) == 0);
@@ -138,7 +138,7 @@
138 int32_t ofs;138 int32_t ofs;
139139
140 if (path.size()) {140 if (path.size()) {
141 if (pathIsAbsolute(path)) {141 if (is_path_absolute(path)) {
142 buf = path + "/*";142 buf = path + "/*";
143 ofs = 0;143 ofs = 0;
144 } else {144 } else {
@@ -155,7 +155,7 @@
155 return results;155 return results;
156156
157 for (size_t i = 0; i < gl.gl_pathc; ++i) {157 for (size_t i = 0; i < gl.gl_pathc; ++i) {
158 const std::string filename(FS_CanonicalizeName(&gl.gl_pathv[i][ofs]));158 const std::string filename(canonicalize_name(&gl.gl_pathv[i][ofs]));
159 results.insert(filename.substr(m_root.size() + 1));159 results.insert(filename.substr(m_root.size() + 1));
160 }160 }
161161
@@ -171,8 +171,8 @@
171 * \e can't exist then)171 * \e can't exist then)
172 */172 */
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?
174bool RealFSImpl::FileExists(const std::string & path) {174bool RealFSImpl::file_exists(const std::string & path) {
175 return FileSystemPath(FS_CanonicalizeName(path)).m_exists;175 return FileSystemPath(canonicalize_name(path)).m_exists;
176}176}
177177
178/**178/**
@@ -180,15 +180,15 @@
180 * Also returns false if the pathname is invalid (obviously, because the file180 * Also returns false if the pathname is invalid (obviously, because the file
181 * \e can't exist then)181 * \e can't exist then)
182 */182 */
183bool RealFSImpl::IsDirectory(const std::string & path) {183bool RealFSImpl::is_directory(const std::string & path) {
184 return FileSystemPath(FS_CanonicalizeName(path)).m_isDirectory;184 return FileSystemPath(canonicalize_name(path)).m_isDirectory;
185}185}
186186
187/**187/**
188 * Create a sub filesystem out of this filesystem188 * Create a sub filesystem out of this filesystem
189 */189 */
190FileSystem * RealFSImpl::MakeSubFileSystem(const std::string & path) {190FileSystem * RealFSImpl::make_sub_file_system(const std::string & path) {
191 FileSystemPath fspath(FS_CanonicalizeName(path));191 FileSystemPath fspath(canonicalize_name(path));
192 assert(fspath.m_exists); //TODO(unknown): throw an exception instead192 assert(fspath.m_exists); //TODO(unknown): throw an exception instead
193193
194 if (fspath.m_isDirectory)194 if (fspath.m_isDirectory)
@@ -200,16 +200,16 @@
200/**200/**
201 * Create a sub filesystem out of this filesystem201 * Create a sub filesystem out of this filesystem
202 */202 */
203FileSystem * RealFSImpl::CreateSubFileSystem(const std::string & path, Type const fs)203FileSystem * RealFSImpl::create_sub_file_system(const std::string & path, Type const fs)
204{204{
205 FileSystemPath fspath(FS_CanonicalizeName(path));205 FileSystemPath fspath(canonicalize_name(path));
206 if (fspath.m_exists)206 if (fspath.m_exists)
207 throw wexception207 throw wexception
208 ("path %s already exists, can not create a filesystem from it",208 ("path %s already exists, can not create a filesystem from it",
209 path.c_str());209 path.c_str());
210210
211 if (fs == FileSystem::DIR) {211 if (fs == FileSystem::DIR) {
212 EnsureDirectoryExists(path);212 ensure_directory_exists(path);
213 return new RealFSImpl(fspath);213 return new RealFSImpl(fspath);
214 } else214 } else
215 return new ZipFilesystem(fspath);215 return new ZipFilesystem(fspath);
@@ -218,8 +218,8 @@
218/**218/**
219 * Remove a number of files219 * Remove a number of files
220 */220 */
221void RealFSImpl::Unlink(const std::string & file) {221void RealFSImpl::fs_unlink(const std::string & file) {
222 FileSystemPath fspath(FS_CanonicalizeName(file));222 FileSystemPath fspath(canonicalize_name(file));
223 if (!fspath.m_exists)223 if (!fspath.m_exists)
224 return;224 return;
225225
@@ -233,14 +233,14 @@
233 * Remove a single directory or file233 * Remove a single directory or file
234 */234 */
235void RealFSImpl::m_unlink_file(const std::string & file) {235void RealFSImpl::m_unlink_file(const std::string & file) {
236 FileSystemPath fspath(FS_CanonicalizeName(file));236 FileSystemPath fspath(canonicalize_name(file));
237 assert(fspath.m_exists); //TODO(unknown): throw an exception instead237 assert(fspath.m_exists); //TODO(unknown): throw an exception instead
238 assert(!fspath.m_isDirectory); //TODO(unknown): throw an exception instead238 assert(!fspath.m_isDirectory); //TODO(unknown): throw an exception instead
239239
240#ifndef _WIN32240#ifndef _WIN32
241 unlink(fspath.c_str());241 unlink(fspath.c_str());
242#else242#else
243 DeleteFile(fspath.c_str());243 delete_file(fspath.c_str());
244#endif244#endif
245}245}
246246
@@ -248,23 +248,23 @@
248 * Recursively remove a directory248 * Recursively remove a directory
249 */249 */
250void RealFSImpl::m_unlink_directory(const std::string & file) {250void RealFSImpl::m_unlink_directory(const std::string & file) {
251 FileSystemPath fspath(FS_CanonicalizeName(file));251 FileSystemPath fspath(canonicalize_name(file));
252 assert(fspath.m_exists); //TODO(unknown): throw an exception instead252 assert(fspath.m_exists); //TODO(unknown): throw an exception instead
253 assert(fspath.m_isDirectory); //TODO(unknown): throw an exception instead253 assert(fspath.m_isDirectory); //TODO(unknown): throw an exception instead
254254
255 FilenameSet files = ListDirectory(file);255 FilenameSet files = list_directory(file);
256 for256 for
257 (FilenameSet::iterator pname = files.begin();257 (FilenameSet::iterator pname = files.begin();
258 pname != files.end();258 pname != files.end();
259 ++pname)259 ++pname)
260 {260 {
261 std::string filename = FS_Filename(pname->c_str());261 std::string filename = fs_filename(pname->c_str());
262 if (filename == "..")262 if (filename == "..")
263 continue;263 continue;
264 if (filename == ".")264 if (filename == ".")
265 continue;265 continue;
266266
267 if (IsDirectory(*pname))267 if (is_directory(*pname))
268 m_unlink_directory(*pname);268 m_unlink_directory(*pname);
269 else269 else
270 m_unlink_file(*pname);270 m_unlink_file(*pname);
@@ -275,7 +275,7 @@
275#ifndef _WIN32275#ifndef _WIN32
276 rmdir(fspath.c_str());276 rmdir(fspath.c_str());
277#else277#else
278 RemoveDirectory(fspath.c_str());278 remove_directory(fspath.c_str());
279#endif279#endif
280}280}
281281
@@ -283,20 +283,20 @@
283 * Create this directory if it doesn't exist, throws an error283 * Create this directory if it doesn't exist, throws an error
284 * if the dir can't be created or if a file with this name exists284 * if the dir can't be created or if a file with this name exists
285 */285 */
286void RealFSImpl::EnsureDirectoryExists(const std::string & dirname)286void RealFSImpl::ensure_directory_exists(const std::string & dirname)
287{287{
288 try {288 try {
289 std::string::size_type it = 0;289 std::string::size_type it = 0;
290 while (it < dirname.size()) {290 while (it < dirname.size()) {
291 it = dirname.find(m_filesep, it);291 it = dirname.find(m_filesep, it);
292292
293 FileSystemPath fspath(FS_CanonicalizeName(dirname.substr(0, it)));293 FileSystemPath fspath(canonicalize_name(dirname.substr(0, it)));
294 if (fspath.m_exists && !fspath.m_isDirectory)294 if (fspath.m_exists && !fspath.m_isDirectory)
295 throw wexception295 throw wexception
296 ("%s exists and is not a directory",296 ("%s exists and is not a directory",
297 dirname.substr(0, it).c_str());297 dirname.substr(0, it).c_str());
298 if (!fspath.m_exists)298 if (!fspath.m_exists)
299 MakeDirectory(dirname.substr(0, it));299 make_directory(dirname.substr(0, it));
300300
301 if (it == std::string::npos)301 if (it == std::string::npos)
302 break;302 break;
@@ -304,7 +304,7 @@
304 }304 }
305 } catch (const std::exception & e) {305 } catch (const std::exception & e) {
306 throw wexception306 throw wexception
307 ("RealFSImpl::EnsureDirectoryExists(%s): %s",307 ("RealFSImpl::ensure_directory_exists(%s): %s",
308 dirname.c_str(), e.what());308 dirname.c_str(), e.what());
309 }309 }
310}310}
@@ -314,11 +314,11 @@
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.
315 *315 *
316 * Pleas note, this function does not honor parents,316 * Pleas note, this function does not honor parents,
317 * MakeDirectory("onedir/otherdir/onemoredir") will fail317 * make_directory("onedir/otherdir/onemoredir") will fail
318 * if either onedir or otherdir is missing318 * if either onedir or otherdir is missing
319 */319 */
320void RealFSImpl::MakeDirectory(const std::string & dirname) {320void RealFSImpl::make_directory(const std::string & dirname) {
321 FileSystemPath fspath(FS_CanonicalizeName(dirname));321 FileSystemPath fspath(canonicalize_name(dirname));
322 if (fspath.m_exists)322 if (fspath.m_exists)
323 throw wexception323 throw wexception
324 ("a file with the name \"%s\" already exists", dirname.c_str());324 ("a file with the name \"%s\" already exists", dirname.c_str());
@@ -333,19 +333,19 @@
333 ==333 ==
334 -1)334 -1)
335 throw DirectoryCannotCreateError335 throw DirectoryCannotCreateError
336 ("RealFSImpl::MakeDirectory",336 ("RealFSImpl::make_directory",
337 dirname,337 dirname,
338 strerror(errno));338 strerror(errno));
339}339}
340340
341/**341/**
342 * Read the given file into alloced memory; called by FileRead::Open.342 * Read the given file into alloced memory; called by FileRead::open.
343 * Throws an exception if the file couldn't be opened.343 * Throws an exception if the file couldn't be opened.
344 */344 */
345void * RealFSImpl::Load(const std::string & fname, size_t & length) {345void * RealFSImpl::load(const std::string & fname, size_t & length) {
346 const std::string fullname = FS_CanonicalizeName(fname);346 const std::string fullname = canonicalize_name(fname);
347 if (IsDirectory(fullname)) {347 if (is_directory(fullname)) {
348 throw FileError("RealFSImpl::Load", fullname.c_str());348 throw FileError("RealFSImpl::load", fullname.c_str());
349 }349 }
350350
351 FILE * file = nullptr;351 FILE * file = nullptr;
@@ -354,7 +354,7 @@
354 try {354 try {
355 file = fopen(fullname.c_str(), "rb");355 file = fopen(fullname.c_str(), "rb");
356 if (!file)356 if (!file)
357 throw FileError("RealFSImpl::Load", fullname.c_str());357 throw FileError("RealFSImpl::load", fullname.c_str());
358358
359 // determine the size of the file (rather quirky, but it doesn't require359 // determine the size of the file (rather quirky, but it doesn't require
360 // potentially unportable functions)360 // potentially unportable functions)
@@ -364,7 +364,7 @@
364 const int32_t ftell_pos = ftell(file);364 const int32_t ftell_pos = ftell(file);
365 if (ftell_pos < 0)365 if (ftell_pos < 0)
366 throw wexception366 throw wexception
367 ("RealFSImpl::Load: error when loading \"%s\" (\"%s\"): file "367 ("RealFSImpl::load: error when loading \"%s\" (\"%s\"): file "
368 "size calculation yielded negative value %i",368 "size calculation yielded negative value %i",
369 fname.c_str(), fullname.c_str(), ftell_pos);369 fname.c_str(), fullname.c_str(), ftell_pos);
370 size = ftell_pos;370 size = ftell_pos;
@@ -376,7 +376,7 @@
376 int result = fread(data, size, 1, file);376 int result = fread(data, size, 1, file);
377 if (size && (result != 1)) {377 if (size && (result != 1)) {
378 throw wexception378 throw wexception
379 ("RealFSImpl::Load: read failed for %s (%s) with size %" PRIuS "",379 ("RealFSImpl::load: read failed for %s (%s) with size %" PRIuS "",
380 fname.c_str(), fullname.c_str(), size);380 fname.c_str(), fullname.c_str(), size);
381 }381 }
382 static_cast<int8_t *>(data)[size] = 0;382 static_cast<int8_t *>(data)[size] = 0;
@@ -402,11 +402,11 @@
402 * that file.402 * that file.
403 * Throws an exception if it fails.403 * Throws an exception if it fails.
404 */404 */
405void RealFSImpl::Write(const std::string & fname, void const * const data, int32_t const length, bool append)405void RealFSImpl::write(const std::string & fname, void const * const data, int32_t const length, bool append)
406{406{
407 std::string fullname;407 std::string fullname;
408408
409 fullname = FS_CanonicalizeName(fname);409 fullname = canonicalize_name(fname);
410410
411 FILE * const f = fopen(fullname.c_str(), append ? "a" : "wb");411 FILE * const f = fopen(fullname.c_str(), append ? "a" : "wb");
412 if (!f)412 if (!f)
@@ -422,11 +422,11 @@
422}422}
423423
424// rename a file or directory424// rename a file or directory
425void RealFSImpl::Rename425void RealFSImpl::fs_rename
426 (const std::string & old_name, const std::string & new_name)426 (const std::string & old_name, const std::string & new_name)
427{427{
428 const std::string fullname1 = FS_CanonicalizeName(old_name);428 const std::string fullname1 = canonicalize_name(old_name);
429 const std::string fullname2 = FS_CanonicalizeName(new_name);429 const std::string fullname2 = canonicalize_name(new_name);
430 rename(fullname1.c_str(), fullname2.c_str());430 rename(fullname1.c_str(), fullname2.c_str());
431}431}
432432
@@ -452,11 +452,11 @@
452 fclose(m_file);452 fclose(m_file);
453 }453 }
454454
455 size_t Data(void * data, size_t const bufsize) override {455 size_t data(void * read_data, size_t const bufsize) override {
456 return fread(data, 1, bufsize, m_file);456 return fread(read_data, 1, bufsize, m_file);
457 }457 }
458458
459 bool EndOfFile() const override459 bool end_of_file() const override
460 {460 {
461 return feof(m_file);461 return feof(m_file);
462 }462 }
@@ -467,8 +467,8 @@
467467
468}468}
469469
470StreamRead * RealFSImpl::OpenStreamRead(const std::string & fname) {470StreamRead * RealFSImpl::open_stream_read(const std::string & fname) {
471 const std::string fullname = FS_CanonicalizeName(fname);471 const std::string fullname = canonicalize_name(fname);
472472
473 return new RealFSStreamRead(fullname);473 return new RealFSStreamRead(fullname);
474}474}
@@ -493,15 +493,15 @@
493493
494 ~RealFSStreamWrite() {fclose(m_file);}494 ~RealFSStreamWrite() {fclose(m_file);}
495495
496 void Data(const void * const data, const size_t size) override496 void data(const void * const write_data, const size_t size) override
497 {497 {
498 size_t ret = fwrite(data, 1, size, m_file);498 size_t ret = fwrite(write_data, 1, size, m_file);
499499
500 if (ret != size)500 if (ret != size)
501 throw wexception("Write to %s failed", m_filename.c_str());501 throw wexception("Write to %s failed", m_filename.c_str());
502 }502 }
503503
504 void Flush() override504 void flush() override
505 {505 {
506 fflush(m_file);506 fflush(m_file);
507 }507 }
@@ -513,25 +513,25 @@
513513
514}514}
515515
516StreamWrite * RealFSImpl::OpenStreamWrite(const std::string & fname) {516StreamWrite * RealFSImpl::open_stream_write(const std::string & fname) {
517 const std::string fullname = FS_CanonicalizeName(fname);517 const std::string fullname = canonicalize_name(fname);
518518
519 return new RealFSStreamWrite(fullname);519 return new RealFSStreamWrite(fullname);
520}520}
521521
522unsigned long long RealFSImpl::DiskSpace() {522unsigned long long RealFSImpl::disk_space() {
523#ifdef _WIN32523#ifdef _WIN32
524 ULARGE_INTEGER freeavailable;524 ULARGE_INTEGER freeavailable;
525 return525 return
526 GetDiskFreeSpaceEx526 GetDiskFreeSpaceEx
527 (FS_CanonicalizeName(m_directory).c_str(), &freeavailable, 0, 0)527 (canonicalize_name(m_directory).c_str(), &freeavailable, 0, 0)
528 ?528 ?
529 //if more than 2G free space report that much529 //if more than 2G free space report that much
530 freeavailable.HighPart ? std::numeric_limits<unsigned long>::max() :530 freeavailable.HighPart ? std::numeric_limits<unsigned long>::max() :
531 freeavailable.LowPart : 0;531 freeavailable.LowPart : 0;
532#else532#else
533 struct statvfs svfs;533 struct statvfs svfs;
534 if (statvfs(FS_CanonicalizeName(m_directory).c_str(), &svfs) != -1) {534 if (statvfs(canonicalize_name(m_directory).c_str(), &svfs) != -1) {
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;
536 }536 }
537#endif537#endif
538538
=== modified file 'src/io/filesystem/disk_filesystem.h'
--- src/io/filesystem/disk_filesystem.h 2014-07-26 10:43:23 +0000
+++ src/io/filesystem/disk_filesystem.h 2014-09-29 14:39:47 +0000
@@ -30,32 +30,32 @@
30public:30public:
31 RealFSImpl(const std::string & Directory);31 RealFSImpl(const std::string & Directory);
3232
33 std::set<std::string> ListDirectory(const std::string& path) override;33 std::set<std::string> list_directory(const std::string& path) override;
3434
35 bool IsWritable() const override;35 bool is_writable() const override;
36 bool FileIsWriteable(const std::string & path);36 bool file_is_writeable(const std::string & path);
37 bool FileExists (const std::string & path) override;37 bool file_exists (const std::string & path) override;
38 bool IsDirectory(const std::string & path) override;38 bool is_directory(const std::string & path) override;
39 void EnsureDirectoryExists(const std::string & dirname) override;39 void ensure_directory_exists(const std::string & fs_dirname) override;
40 void MakeDirectory (const std::string & dirname) override;40 void make_directory (const std::string & fs_dirname) override;
4141
42 void * Load(const std::string & fname, size_t & length) override;42 void * load(const std::string & fname, size_t & length) override;
4343
4444
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);
46 void Write(const std::string & fname, void const * data, int32_t length) override46 void write(const std::string & fname, void const * data, int32_t length) override
47 {Write(fname, data, length, false);}47 {write(fname, data, length, false);}
4848
49 StreamRead * OpenStreamRead (const std::string & fname) override;49 StreamRead * open_stream_read (const std::string & fname) override;
50 StreamWrite * OpenStreamWrite(const std::string & fname) override;50 StreamWrite * open_stream_write(const std::string & fname) override;
5151
52 FileSystem * MakeSubFileSystem(const std::string & dirname) override;52 FileSystem * make_sub_file_system(const std::string & fs_dirname) override;
53 FileSystem * CreateSubFileSystem(const std::string & dirname, Type) override;53 FileSystem * create_sub_file_system(const std::string & fs_dirname, Type) override;
54 void Unlink(const std::string & file) override;54 void fs_unlink(const std::string & file) override;
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;
5656
57 std::string getBasename() override {return m_directory;}57 std::string get_basename() override {return m_directory;}
58 unsigned long long DiskSpace() override;58 unsigned long long disk_space() override;
5959
60private:60private:
61 void m_unlink_directory(const std::string & file);61 void m_unlink_directory(const std::string & file);
6262
=== modified file 'src/io/filesystem/filesystem.cc'
--- src/io/filesystem/filesystem.cc 2014-09-10 13:03:40 +0000
+++ src/io/filesystem/filesystem.cc 2014-09-29 14:39:47 +0000
@@ -75,7 +75,7 @@
75 * \param path A file or directory name75 * \param path A file or directory name
76 * \return True if ref path is absolute and within this FileSystem, false otherwise76 * \return True if ref path is absolute and within this FileSystem, false otherwise
77 */77 */
78bool FileSystem::pathIsAbsolute(const std::string & path) const {78bool FileSystem::is_path_absolute(const std::string & path) const {
79 std::string::size_type const path_size = path .size();79 std::string::size_type const path_size = path .size();
80 std::string::size_type const root_size = m_root.size();80 std::string::size_type const root_size = m_root.size();
8181
@@ -107,7 +107,7 @@
107 * This function is used to make sure that paths send via network are usable107 * This function is used to make sure that paths send via network are usable
108 * on locale OS.108 * on locale OS.
109 */109 */
110std::string FileSystem::fixCrossFile(const std::string & path) const {110std::string FileSystem::fix_cross_file(const std::string & path) const {
111 uint32_t path_size = path.size();111 uint32_t path_size = path.size();
112 std::string fixedPath(path);112 std::string fixedPath(path);
113 std::string temp;113 std::string temp;
@@ -141,18 +141,18 @@
141/**141/**
142 * \return The process' current working directory142 * \return The process' current working directory
143 */143 */
144std::string FileSystem::getWorkingDirectory() const {144std::string FileSystem::get_working_directory() const {
145 char cwd[PATH_MAX + 1];145 char cwd[PATH_MAX + 1];
146 char * const result = getcwd(cwd, PATH_MAX);146 char * const result = getcwd(cwd, PATH_MAX);
147 if (! result)147 if (! result)
148 throw FileError("FileSystem::getWorkingDirectory()", "widelands", "can not run getcwd");148 throw FileError("FileSystem::get_working_directory()", "widelands", "can not run getcwd");
149149
150 return std::string(cwd);150 return std::string(cwd);
151}151}
152152
153153
154// TODO(unknown): Write homedir detection for non-getenv-systems154// TODO(unknown): Write homedir detection for non-getenv-systems
155std::string FileSystem::GetHomedir()155std::string FileSystem::get_homedir()
156{156{
157 std::string homedir;157 std::string homedir;
158#ifdef _WIN32158#ifdef _WIN32
@@ -199,7 +199,7 @@
199 * \param components The output iterator to place the path nodes into199 * \param components The output iterator to place the path nodes into
200 */200 */
201template<typename Inserter>201template<typename Inserter>
202static void FS_Tokenize202static void fs_tokenize
203 (const std::string & path, char const filesep, Inserter components)203 (const std::string & path, char const filesep, Inserter components)
204{204{
205 std::string::size_type pos; // start of token205 std::string::size_type pos; // start of token
@@ -234,7 +234,7 @@
234 * Transform any valid, unique pathname into a well-formed absolute path234 * Transform any valid, unique pathname into a well-formed absolute path
235 */235 */
236// TODO(unknown): Enable non-Unix paths236// TODO(unknown): Enable non-Unix paths
237std::string FileSystem::FS_CanonicalizeName(std::string path) const {237std::string FileSystem::canonicalize_name(std::string path) const {
238 std::list<std::string> components;238 std::list<std::string> components;
239 std::list<std::string>::iterator i;239 std::list<std::string>::iterator i;
240240
@@ -246,19 +246,19 @@
246 }246 }
247#endif247#endif
248248
249 FS_Tokenize(path, m_filesep, std::inserter(components, components.begin()));249 fs_tokenize(path, m_filesep, std::inserter(components, components.begin()));
250250
251 //tilde expansion251 //tilde expansion
252 if (!components.empty() && *components.begin() == "~") {252 if (!components.empty() && *components.begin() == "~") {
253 components.erase(components.begin());253 components.erase(components.begin());
254 FS_Tokenize254 fs_tokenize
255 (GetHomedir(),255 (get_homedir(),
256 m_filesep,256 m_filesep,
257 std::inserter(components, components.begin()));257 std::inserter(components, components.begin()));
258 } else if (!pathIsAbsolute(path))258 } else if (!is_path_absolute(path))
259 // make relative paths absolute (so that "../../foo" can work)259 // make relative paths absolute (so that "../../foo" can work)
260 FS_Tokenize260 fs_tokenize
261 (m_root.empty() ? getWorkingDirectory() : m_root, m_filesep,261 (m_root.empty() ? get_working_directory() : m_root, m_filesep,
262 std::inserter(components, components.begin()));262 std::inserter(components, components.begin()));
263263
264 //clean up the path264 //clean up the path
@@ -316,7 +316,7 @@
316 * Returns the filename of this path, everything after the last316 * Returns the filename of this path, everything after the last
317 * / or \ (or the whole string)317 * / or \ (or the whole string)
318 */318 */
319const char * FileSystem::FS_Filename(const char * p) {319const char * FileSystem::fs_filename(const char * p) {
320 const char * result = p;320 const char * result = p;
321321
322 while (*p != '\0') {322 while (*p != '\0') {
@@ -328,12 +328,12 @@
328 return result;328 return result;
329}329}
330330
331std::string FileSystem::FS_Dirname(const std::string& full_path) {331std::string FileSystem::fs_dirname(const std::string& full_path) {
332 const std::string filename = FS_Filename(full_path.c_str());332 const std::string filename = fs_filename(full_path.c_str());
333 return full_path.substr(0, full_path.size() - filename.size());333 return full_path.substr(0, full_path.size() - filename.size());
334}334}
335335
336std::string FileSystem::FS_FilenameExt(const std::string & f)336std::string FileSystem::filename_ext(const std::string & f)
337{337{
338 // Find last '.' - denotes start of extension338 // Find last '.' - denotes start of extension
339 size_t ext_start = f.rfind('.');339 size_t ext_start = f.rfind('.');
@@ -344,10 +344,10 @@
344 return f.substr(ext_start);344 return f.substr(ext_start);
345}345}
346346
347std::string FileSystem::FS_FilenameWoExt(const char * const p)347std::string FileSystem::filename_without_ext(const char * const p)
348{348{
349 std::string fname(p ? FileSystem::FS_Filename(p) : "");349 std::string fname(p ? FileSystem::fs_filename(p) : "");
350 std::string ext(FileSystem::FS_FilenameExt(fname));350 std::string ext(FileSystem::filename_ext(fname));
351 return fname.substr(0, fname.length() - ext.length());351 return fname.substr(0, fname.length() - ext.length());
352}352}
353353
@@ -361,7 +361,7 @@
361// TODO(unknown): Catch FileNotFoundError in all users361// TODO(unknown): Catch FileNotFoundError in all users
362// TODO(unknown): throw FileTypeError if root is not a zipfile (exception from362// TODO(unknown): throw FileTypeError if root is not a zipfile (exception from
363// ZipFilesystem)363// ZipFilesystem)
364FileSystem & FileSystem::Create(const std::string & root)364FileSystem & FileSystem::create(const std::string & root)
365{365{
366 struct stat statinfo;366 struct stat statinfo;
367367
@@ -375,10 +375,10 @@
375#endif375#endif
376 errno == ENAMETOOLONG)376 errno == ENAMETOOLONG)
377 {377 {
378 throw FileNotFoundError("FileSystem::Create", root);378 throw FileNotFoundError("FileSystem::create", root);
379 }379 }
380 if (errno == EACCES)380 if (errno == EACCES)
381 throw FileAccessDeniedError("FileSystem::Create", root);381 throw FileAccessDeniedError("FileSystem::create", root);
382 }382 }
383383
384 if (S_ISDIR(statinfo.st_mode)) {384 if (S_ISDIR(statinfo.st_mode)) {
@@ -389,7 +389,7 @@
389 }389 }
390390
391 throw FileTypeError391 throw FileTypeError
392 ("FileSystem::Create", root,392 ("FileSystem::create", root,
393 "cannot create virtual filesystem from file or directory");393 "cannot create virtual filesystem from file or directory");
394}394}
395395
@@ -400,12 +400,12 @@
400{400{
401 RealFSImpl fs(path);401 RealFSImpl fs(path);
402402
403 if (fs.IsDirectory(".widelands"))403 if (fs.is_directory(".widelands"))
404 return true;404 return true;
405 try {405 try {
406 // throws an exception if not writable406 // throws an exception if not writable
407 fs.EnsureDirectoryExists(".widelands");407 fs.ensure_directory_exists(".widelands");
408 fs.Unlink(".widelands");408 fs.unlink(".widelands");
409 return true;409 return true;
410 } catch (...) {410 } catch (...) {
411 log("Directory %s is not writeable - next try\n", path);411 log("Directory %s is not writeable - next try\n", path);
412412
=== modified file 'src/io/filesystem/filesystem.h'
--- src/io/filesystem/filesystem.h 2014-09-14 11:31:58 +0000
+++ src/io/filesystem/filesystem.h 2014-09-29 14:39:47 +0000
@@ -53,20 +53,20 @@
53 virtual ~FileSystem() {}53 virtual ~FileSystem() {}
5454
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'.
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;
5757
58 virtual bool IsWritable() const = 0;58 virtual bool is_writable() const = 0;
59 virtual bool IsDirectory(const std::string & path) = 0;59 virtual bool is_directory(const std::string & path) = 0;
60 virtual bool FileExists (const std::string & path) = 0;60 virtual bool file_exists (const std::string & path) = 0;
6161
62 virtual void * Load(const std::string & fname, size_t & length) = 0;62 virtual void * load(const std::string & fname, size_t & length) = 0;
6363
64 virtual void Write64 virtual void write
65 (const std::string & fname, void const * data, int32_t length)65 (const std::string & fname, void const * data, int32_t length)
66 = 0;66 = 0;
67 virtual void EnsureDirectoryExists(const std::string & dirname) = 0;67 virtual void ensure_directory_exists(const std::string & fs_dirname) = 0;
68 //TODO(unknown): use this only from inside EnsureDirectoryExists()68 //TODO(unknown): use this only from inside ensure_directory_exists()
69 virtual void MakeDirectory(const std::string & dirname) = 0;69 virtual void make_directory(const std::string & fs_dirname) = 0;
7070
71 /**71 /**
72 * Opens the given file for reading as a stream.72 * Opens the given file for reading as a stream.
@@ -75,7 +75,7 @@
75 * \return a \ref StreamRead object for the file. The caller must delete this75 * \return a \ref StreamRead object for the file. The caller must delete this
76 * object when done to close the file.76 * object when done to close the file.
77 */77 */
78 virtual StreamRead * OpenStreamRead(const std::string & fname) = 0;78 virtual StreamRead * open_stream_read(const std::string & fname) = 0;
7979
80 /**80 /**
81 * Opens the given file for writing as a stream.81 * Opens the given file for writing as a stream.
@@ -87,47 +87,47 @@
87 * delete this object when done to close the file (which will implicitly87 * delete this object when done to close the file (which will implicitly
88 * flush unwritten data).88 * flush unwritten data).
89 */89 */
90 virtual StreamWrite * OpenStreamWrite(const std::string & fname) = 0;90 virtual StreamWrite * open_stream_write(const std::string & fname) = 0;
9191
92 /**92 /**
93 * Creates a subfilesystem from an existing file/directory.93 * Creates a subfilesystem from an existing file/directory.
94 * Passes ownership to caller.94 * Passes ownership to caller.
95 */95 */
96 virtual FileSystem * MakeSubFileSystem(const std::string & dirname) = 0;96 virtual FileSystem * make_sub_file_system(const std::string & fs_dirname) = 0;
97 /**97 /**
98 * Creates a subfilesystem from a new file/directory.98 * Creates a subfilesystem from a new file/directory.
99 * Passes ownership to caller.99 * Passes ownership to caller.
100 */100 */
101 virtual FileSystem * CreateSubFileSystem(const std::string & dirname, Type) = 0;101 virtual FileSystem * create_sub_file_system(const std::string & fs_dirname, Type) = 0;
102 virtual void Unlink(const std::string &) = 0;102 virtual void fs_unlink(const std::string &) = 0;
103 virtual void Rename(const std::string &, const std::string &) = 0;103 virtual void fs_rename(const std::string &, const std::string &) = 0;
104104
105 static FileSystem & Create(const std::string & root)105 static FileSystem & create(const std::string & root)
106;106;
107107
108 ///Retrieve the filesystem root's name == the mountpoint inside a108 ///Retrieve the filesystem root's name == the mountpoint inside a
109 ///LayeredFileSystem109 ///LayeredFileSystem
110 virtual std::string getBasename() = 0;110 virtual std::string get_basename() = 0;
111111
112 // basic path/filename manipulation112 // basic path/filename manipulation
113 std::string fixCrossFile(const std::string &) const;113 std::string fix_cross_file(const std::string &) const;
114 char fileSeparator() {return m_filesep;}114 char file_separator() {return m_filesep;}
115 std::string getWorkingDirectory() const;115 std::string get_working_directory() const;
116 std::string FS_CanonicalizeName(std::string path) const;116 std::string canonicalize_name(std::string path) const;
117 bool pathIsAbsolute(const std::string & path) const;117 bool is_path_absolute(const std::string & path) const;
118118
119 ///Given a filename, return the name with any path stripped off.119 ///Given a filename, return the name with any path stripped off.
120 static const char * FS_Filename(const char * n);120 static const char * fs_filename(const char * n);
121 static std::string FS_Dirname(const std::string& full_path);121 static std::string fs_dirname(const std::string& full_path);
122122
123 ///Given a filename (without any path), return the extension, if any.123 ///Given a filename (without any path), return the extension, if any.
124 static std::string FS_FilenameExt(const std::string & f);124 static std::string filename_ext(const std::string & f);
125125
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.
127 static std::string FS_FilenameWoExt(const char * n);127 static std::string filename_without_ext(const char * n);
128 static std::string GetHomedir();128 static std::string get_homedir();
129129
130 virtual unsigned long long DiskSpace() = 0;130 virtual unsigned long long disk_space() = 0;
131131
132protected:132protected:
133 ///To get a filesystem, use the Create methods133 ///To get a filesystem, use the Create methods
134134
=== modified file 'src/io/filesystem/layered_filesystem.cc'
--- src/io/filesystem/layered_filesystem.cc 2014-09-14 11:31:58 +0000
+++ src/io/filesystem/layered_filesystem.cc 2014-09-29 14:39:47 +0000
@@ -43,15 +43,15 @@
43 * Just assume that at least one of our child FSs is writable43 * Just assume that at least one of our child FSs is writable
44 */44 */
45// TODO(unknown): Implement me45// TODO(unknown): Implement me
46bool LayeredFileSystem::IsWritable() const {46bool LayeredFileSystem::is_writable() const {
47 return true;47 return true;
48}48}
4949
50void LayeredFileSystem::AddFileSystem(FileSystem* fs) {50void LayeredFileSystem::add_file_system(FileSystem* fs) {
51 m_filesystems.emplace_back(fs);51 m_filesystems.emplace_back(fs);
52}52}
5353
54void LayeredFileSystem::SetHomeFileSystem(FileSystem * fs)54void LayeredFileSystem::set_home_file_system(FileSystem * fs)
55{55{
56 m_home.reset(fs);56 m_home.reset(fs);
57}57}
@@ -60,11 +60,11 @@
60 * Remove a filesystem from the stack60 * Remove a filesystem from the stack
61 * \param fs The filesystem to be removed61 * \param fs The filesystem to be removed
62 */62 */
63void LayeredFileSystem::RemoveFileSystem(const FileSystem & fs)63void LayeredFileSystem::remove_file_system(const FileSystem & fs)
64{64{
65 if (m_filesystems.back().get() != &fs)65 if (m_filesystems.back().get() != &fs)
66 throw std::logic_error66 throw std::logic_error
67 ("LayeredFileSystem::RemoveFileSystem: interspersed add/remove "67 ("LayeredFileSystem::remove_file_system: interspersed add/remove "
68 "detected!");68 "detected!");
69 m_filesystems.pop_back();69 m_filesystems.pop_back();
70}70}
@@ -77,12 +77,12 @@
77 *77 *
78 * Returns the number of files found.78 * Returns the number of files found.
79 */79 */
80std::set<std::string> LayeredFileSystem::ListDirectory(const std::string& path) {80std::set<std::string> LayeredFileSystem::list_directory(const std::string& path) {
81 std::set<std::string> results;81 std::set<std::string> results;
82 FilenameSet files;82 FilenameSet files;
83 //check home system first83 //check home system first
84 if (m_home) {84 if (m_home) {
85 files = m_home->ListDirectory(path);85 files = m_home->list_directory(path);
86 for86 for
87 (FilenameSet::iterator fnit = files.begin();87 (FilenameSet::iterator fnit = files.begin();
88 fnit != files.end();88 fnit != files.end();
@@ -91,7 +91,7 @@
91 }91 }
9292
93 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) {93 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it) {
94 files = (*it)->ListDirectory(path);94 files = (*it)->list_directory(path);
9595
96 for (FilenameSet::iterator fnit = files.begin(); fnit != files.end(); ++fnit)96 for (FilenameSet::iterator fnit = files.begin(); fnit != files.end(); ++fnit)
97 results.insert(*fnit);97 results.insert(*fnit);
@@ -102,11 +102,11 @@
102/**102/**
103 * Returns true if the file can be found in at least one of the sub-filesystems103 * Returns true if the file can be found in at least one of the sub-filesystems
104 */104 */
105bool LayeredFileSystem::FileExists(const std::string & path) {105bool LayeredFileSystem::file_exists(const std::string & path) {
106 if (m_home && m_home->FileExists(path))106 if (m_home && m_home->file_exists(path))
107 return true;107 return true;
108 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)108 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
109 if ((*it)->FileExists(path))109 if ((*it)->file_exists(path))
110 return true;110 return true;
111111
112 return false;112 return false;
@@ -116,32 +116,32 @@
116 * Returns true if path is a directory in at least one of the directories116 * Returns true if path is a directory in at least one of the directories
117 */117 */
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?????
119bool LayeredFileSystem::IsDirectory(const std::string & path) {119bool LayeredFileSystem::is_directory(const std::string & path) {
120 if (m_home && m_home->IsDirectory(path))120 if (m_home && m_home->is_directory(path))
121 return true;121 return true;
122122
123 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)123 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
124 if ((*it)->IsDirectory(path))124 if ((*it)->is_directory(path))
125 return true;125 return true;
126126
127 return false;127 return false;
128}128}
129129
130/**130/**
131 * Read the given file into alloced memory; called by FileRead::Open.131 * Read the given file into alloced memory; called by FileRead::open.
132 * Throws an exception if the file couldn't be opened.132 * Throws an exception if the file couldn't be opened.
133 *133 *
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,
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.
136 * Let's just avoid any possible hassles with that.136 * Let's just avoid any possible hassles with that.
137 */137 */
138void * LayeredFileSystem::Load(const std::string & fname, size_t & length) {138void * LayeredFileSystem::load(const std::string & fname, size_t & length) {
139 if (m_home && m_home->FileExists(fname))139 if (m_home && m_home->file_exists(fname))
140 return m_home->Load(fname, length);140 return m_home->load(fname, length);
141141
142 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)142 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
143 if ((*it)->FileExists(fname))143 if ((*it)->file_exists(fname))
144 return (*it)->Load(fname, length);144 return (*it)->load(fname, length);
145145
146 throw FileNotFoundError("Could not find file", fname);146 throw FileNotFoundError("Could not find file", fname);
147}147}
@@ -150,15 +150,15 @@
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.
151 * Throws an exception if it fails.151 * Throws an exception if it fails.
152 */152 */
153void LayeredFileSystem::Write153void LayeredFileSystem::write
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)
155{155{
156 if (m_home && m_home->IsWritable())156 if (m_home && m_home->is_writable())
157 return m_home->Write(fname, data, length);157 return m_home->write(fname, data, length);
158158
159 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)159 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
160 if ((*it)->IsWritable())160 if ((*it)->is_writable())
161 return (*it)->Write(fname, data, length);161 return (*it)->write(fname, data, length);
162162
163 throw wexception("LayeredFileSystem: No writable filesystem!");163 throw wexception("LayeredFileSystem: No writable filesystem!");
164}164}
@@ -167,13 +167,13 @@
167 * Analogously to Read, open the file from the first sub-filesystem where167 * Analogously to Read, open the file from the first sub-filesystem where
168 * it exists.168 * it exists.
169 */169 */
170StreamRead * LayeredFileSystem::OpenStreamRead (const std::string & fname) {170StreamRead * LayeredFileSystem::open_stream_read (const std::string & fname) {
171 if (m_home && m_home->FileExists(fname))171 if (m_home && m_home->file_exists(fname))
172 return m_home->OpenStreamRead(fname);172 return m_home->open_stream_read(fname);
173173
174 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)174 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
175 if ((*it)->FileExists(fname))175 if ((*it)->file_exists(fname))
176 return (*it)->OpenStreamRead(fname);176 return (*it)->open_stream_read(fname);
177177
178 throw FileNotFoundError("Could not find file", fname);178 throw FileNotFoundError("Could not find file", fname);
179}179}
@@ -181,13 +181,13 @@
181/**181/**
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.
183 */183 */
184StreamWrite * LayeredFileSystem::OpenStreamWrite(const std::string & fname) {184StreamWrite * LayeredFileSystem::open_stream_write(const std::string & fname) {
185 if (m_home && m_home->IsWritable())185 if (m_home && m_home->is_writable())
186 return m_home->OpenStreamWrite(fname);186 return m_home->open_stream_write(fname);
187187
188 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)188 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
189 if ((*it)->IsWritable())189 if ((*it)->is_writable())
190 return (*it)->OpenStreamWrite(fname);190 return (*it)->open_stream_write(fname);
191191
192 throw wexception("LayeredFileSystem: No writable filesystem!");192 throw wexception("LayeredFileSystem: No writable filesystem!");
193}193}
@@ -195,27 +195,27 @@
195/**195/**
196 * MakeDir in first writable directory196 * MakeDir in first writable directory
197 */197 */
198void LayeredFileSystem::MakeDirectory(const std::string & dirname) {198void LayeredFileSystem::make_directory(const std::string & dirname) {
199 if (m_home && m_home->IsWritable())199 if (m_home && m_home->is_writable())
200 return m_home->MakeDirectory(dirname);200 return m_home->make_directory(dirname);
201201
202 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)202 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
203 if ((*it)->IsWritable())203 if ((*it)->is_writable())
204 return (*it)->MakeDirectory(dirname);204 return (*it)->make_directory(dirname);
205205
206 throw wexception("LayeredFileSystem: No writable filesystem!");206 throw wexception("LayeredFileSystem: No writable filesystem!");
207}207}
208208
209/**209/**
210 * EnsureDirectoryExists in first writable directory210 * ensure_directory_exists in first writable directory
211 */211 */
212void LayeredFileSystem::EnsureDirectoryExists(const std::string & dirname) {212void LayeredFileSystem::ensure_directory_exists(const std::string & dirname) {
213 if (m_home && m_home->IsWritable())213 if (m_home && m_home->is_writable())
214 return m_home->EnsureDirectoryExists(dirname);214 return m_home->ensure_directory_exists(dirname);
215215
216 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)216 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
217 if ((*it)->IsWritable())217 if ((*it)->is_writable())
218 return (*it)->EnsureDirectoryExists(dirname);218 return (*it)->ensure_directory_exists(dirname);
219219
220 throw wexception("LayeredFileSystem: No writable filesystem!");220 throw wexception("LayeredFileSystem: No writable filesystem!");
221}221}
@@ -223,14 +223,14 @@
223/**223/**
224 * Create a subfilesystem from an existing file/directory224 * Create a subfilesystem from an existing file/directory
225 */225 */
226FileSystem * LayeredFileSystem::MakeSubFileSystem(const std::string & dirname)226FileSystem * LayeredFileSystem::make_sub_file_system(const std::string & dirname)
227{227{
228 if (m_home && m_home->IsWritable() && m_home->FileExists(dirname))228 if (m_home && m_home->is_writable() && m_home->file_exists(dirname))
229 return m_home->MakeSubFileSystem(dirname);229 return m_home->make_sub_file_system(dirname);
230230
231 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)231 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
232 if ((*it)->IsWritable() && (*it)->FileExists(dirname))232 if ((*it)->is_writable() && (*it)->file_exists(dirname))
233 return (*it)->MakeSubFileSystem(dirname);233 return (*it)->make_sub_file_system(dirname);
234234
235 throw wexception("LayeredFileSystem: unable to create sub filesystem");235 throw wexception("LayeredFileSystem: unable to create sub filesystem");
236}236}
@@ -238,14 +238,14 @@
238/**238/**
239 * Create a subfilesystem from a new file/directory239 * Create a subfilesystem from a new file/directory
240 */240 */
241FileSystem * LayeredFileSystem::CreateSubFileSystem(const std::string & dirname, Type const type)241FileSystem * LayeredFileSystem::create_sub_file_system(const std::string & dirname, Type const type)
242{242{
243 if (m_home && m_home->IsWritable() && !m_home->FileExists(dirname))243 if (m_home && m_home->is_writable() && !m_home->file_exists(dirname))
244 return m_home->CreateSubFileSystem(dirname, type);244 return m_home->create_sub_file_system(dirname, type);
245245
246 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)246 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
247 if ((*it)->IsWritable() && !(*it)->FileExists(dirname))247 if ((*it)->is_writable() && !(*it)->file_exists(dirname))
248 return (*it)->CreateSubFileSystem(dirname, type);248 return (*it)->create_sub_file_system(dirname, type);
249249
250 throw wexception("LayeredFileSystem: unable to create sub filesystem");250 throw wexception("LayeredFileSystem: unable to create sub filesystem");
251}251}
@@ -253,33 +253,34 @@
253/**253/**
254 * Remove this file or directory. If it is a directory, remove it recursively254 * Remove this file or directory. If it is a directory, remove it recursively
255 */255 */
256void LayeredFileSystem::Unlink(const std::string & file) {256void LayeredFileSystem::fs_unlink(const std::string & file) {
257 if (!FileExists(file))257 if (!file_exists(file))
258 return;258 return;
259259
260 if (m_home && m_home->IsWritable() && m_home->FileExists(file)) {260 if (m_home && m_home->is_writable() && m_home->file_exists(file)) {
261 m_home->Unlink(file);261 m_home->fs_unlink(file);
262 return;262 return;
263 }263 }
264
264 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)265 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
265 if ((*it)->IsWritable() && (*it)->FileExists(file)) {266 if ((*it)->is_writable() && (*it)->file_exists(file)) {
266 (*it)->Unlink(file);267 (*it)->fs_unlink(file);
267 return;268 return;
268 }269 }
269}270}
270271
271void LayeredFileSystem::Rename272void LayeredFileSystem::fs_rename
272 (const std::string & old_name, const std::string & new_name)273 (const std::string & old_name, const std::string & new_name)
273{274{
274 if (!FileExists(old_name))275 if (!file_exists(old_name))
275 return;276 return;
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)) {
277 m_home->Rename(old_name, new_name);278 m_home->fs_rename(old_name, new_name);
278 return;279 return;
279 }280 }
280 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)281 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
281 if ((*it)->IsWritable() && (*it)->FileExists(old_name)) {282 if ((*it)->is_writable() && (*it)->file_exists(old_name)) {
282 (*it)->Rename(old_name, new_name);283 (*it)->fs_rename(old_name, new_name);
283 return;284 return;
284 }285 }
285}286}
@@ -288,12 +289,12 @@
288// or the first directory on the stack we can find.289// or the first directory on the stack we can find.
289// This heuristic is justified by the fact that ths is290// This heuristic is justified by the fact that ths is
290// where we will create new files.291// where we will create new files.
291unsigned long long LayeredFileSystem::DiskSpace() {292unsigned long long LayeredFileSystem::disk_space() {
292 if (m_home) {293 if (m_home) {
293 return m_home->DiskSpace();294 return m_home->disk_space();
294 }295 }
295 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)296 for (auto it = m_filesystems.rbegin(); it != m_filesystems.rend(); ++it)
296 if (*it)297 if (*it)
297 return (*it)->DiskSpace();298 return (*it)->disk_space();
298 return 0;299 return 0;
299}300}
300301
=== modified file 'src/io/filesystem/layered_filesystem.h'
--- src/io/filesystem/layered_filesystem.h 2014-07-26 10:43:23 +0000
+++ src/io/filesystem/layered_filesystem.h 2014-09-29 14:39:47 +0000
@@ -50,37 +50,37 @@
5050
51 // Add a new filesystem to the top of the stack. Take ownership of the given51 // Add a new filesystem to the top of the stack. Take ownership of the given
52 // filesystem.52 // filesystem.
53 void AddFileSystem(FileSystem*);53 void add_file_system(FileSystem*);
5454
55 // Set the home filesystem (which is the preferred filesystem for writing55 // Set the home filesystem (which is the preferred filesystem for writing
56 // files). Take ownership of the given filesystem.56 // files). Take ownership of the given filesystem.
57 void SetHomeFileSystem(FileSystem*);57 void set_home_file_system(FileSystem*);
5858
59 virtual void RemoveFileSystem(const FileSystem &);59 virtual void remove_file_system(const FileSystem &);
6060
61 std::set<std::string> ListDirectory(const std::string& path) override;61 std::set<std::string> list_directory(const std::string& path) override;
6262
63 bool IsWritable() const override;63 bool is_writable () const override;
64 bool FileExists(const std::string & path) override;64 bool file_exists (const std::string & path) override;
65 bool IsDirectory (const std::string & path) override;65 bool is_directory (const std::string & path) override;
66 void EnsureDirectoryExists(const std::string & dirname) override;66 void ensure_directory_exists(const std::string & fs_dirname) override;
67 void MakeDirectory (const std::string & dirname) override;67 void make_directory (const std::string & fs_dirname) override;
6868
69 void * Load(const std::string & fname, size_t & length) override;69 void * load(const std::string & fname, size_t & length) override;
70 virtual void Write70 virtual void write
71 (const std::string & fname, void const * data, int32_t length) override;71 (const std::string & fname, void const * data, int32_t length) override;
7272
73 StreamRead * OpenStreamRead (const std::string & fname) override;73 StreamRead * open_stream_read (const std::string & fname) override;
74 StreamWrite * OpenStreamWrite(const std::string & fname) override;74 StreamWrite * open_stream_write(const std::string & fname) override;
7575
76 FileSystem * MakeSubFileSystem(const std::string & dirname) override;76 FileSystem * make_sub_file_system(const std::string & fs_dirname) override;
77 FileSystem * CreateSubFileSystem(const std::string & dirname, Type) override;77 FileSystem * create_sub_file_system(const std::string & fs_dirname, Type) override;
78 void Unlink(const std::string & file) override;78 void fs_unlink(const std::string & file) override;
79 void Rename(const std::string &, const std::string &) override;79 void fs_rename(const std::string &, const std::string &) override;
8080
81 std::string getBasename() override {return std::string();}81 std::string get_basename() override {return std::string();}
8282
83 unsigned long long DiskSpace() override;83 unsigned long long disk_space() override;
8484
85private:85private:
86 std::vector<std::unique_ptr<FileSystem>> m_filesystems;86 std::vector<std::unique_ptr<FileSystem>> m_filesystems;
8787
=== modified file 'src/io/filesystem/test/test_filesystem.cc'
--- src/io/filesystem/test/test_filesystem.cc 2014-07-14 10:45:44 +0000
+++ src/io/filesystem/test/test_filesystem.cc 2014-09-29 14:39:47 +0000
@@ -34,7 +34,7 @@
34 if (!s.empty() && s[0] == '\\')34 if (!s.empty() && s[0] == '\\')
35 {35 {
36 // Insert drive letter part from current working directory36 // Insert drive letter part from current working directory
37 std::string cwd = RealFSImpl("").getWorkingDirectory();37 std::string cwd = RealFSImpl("").get_working_directory();
38 s.insert(0, cwd.substr(0, 2));38 s.insert(0, cwd.substr(0, 2));
39 }39 }
40 return s;40 return s;
@@ -53,15 +53,15 @@
53BOOST_AUTO_TEST_SUITE(FileSystemTests)53BOOST_AUTO_TEST_SUITE(FileSystemTests)
54#ifndef _WIN3254#ifndef _WIN32
55#define TEST_CANONICALIZE_NAME(root, path, expected) \55#define TEST_CANONICALIZE_NAME(root, path, expected) \
56 BOOST_CHECK_EQUAL(RealFSImpl(root).FS_CanonicalizeName(path), expected);56 BOOST_CHECK_EQUAL(RealFSImpl(root).canonicalize_name(path), expected);
57#else57#else
58#define TEST_CANONICALIZE_NAME(root, path, expected) \58#define TEST_CANONICALIZE_NAME(root, path, expected) \
59 BOOST_CHECK_EQUAL(RealFSImpl(Win32Path(root)).FS_CanonicalizeName(path), Win32Path(expected));59 BOOST_CHECK_EQUAL(RealFSImpl(Win32Path(root)).canonicalize_name(path), Win32Path(expected));
60#endif60#endif
6161
62BOOST_AUTO_TEST_CASE(test_canonicalize_name) {62BOOST_AUTO_TEST_CASE(test_canonicalize_name) {
63 setenv("HOME", "/home/test", 1);63 setenv("HOME", "/home/test", 1);
64 std::string cwd = RealFSImpl("").getWorkingDirectory();64 std::string cwd = RealFSImpl("").get_working_directory();
6565
66 // RealFSImpl is constructed with a root directory...66 // RealFSImpl is constructed with a root directory...
6767
@@ -128,8 +128,8 @@
128128
129#ifdef _WIN32129#ifdef _WIN32
130 // Check drive letter handling.130 // Check drive letter handling.
131 BOOST_CHECK_EQUAL(RealFSImpl("C:\\").FS_CanonicalizeName("C:\\"), "C:");131 BOOST_CHECK_EQUAL(RealFSImpl("C:\\").canonicalize_name("C:\\"), "C:");
132 BOOST_CHECK_EQUAL(RealFSImpl("C:\\").FS_CanonicalizeName("D:\\"), "C:\\D:");132 BOOST_CHECK_EQUAL(RealFSImpl("C:\\").canonicalize_name("D:\\"), "C:\\D:");
133#endif133#endif
134}134}
135135
@@ -138,7 +138,7 @@
138// ~ gets expanded to $HOME138// ~ gets expanded to $HOME
139BOOST_AUTO_TEST_CASE(test_canonicalize_name_home_expansion) {139BOOST_AUTO_TEST_CASE(test_canonicalize_name_home_expansion) {
140 setenv("HOME", "/my/home", 1);140 setenv("HOME", "/my/home", 1);
141 std::string cwd = RealFSImpl("").getWorkingDirectory();141 std::string cwd = RealFSImpl("").get_working_directory();
142142
143 TEST_CANONICALIZE_NAME("~", "path", "/my/home/path");143 TEST_CANONICALIZE_NAME("~", "path", "/my/home/path");
144 TEST_CANONICALIZE_NAME("~/test", "path", "/my/home/test/path");144 TEST_CANONICALIZE_NAME("~/test", "path", "/my/home/test/path");
145145
=== modified file 'src/io/filesystem/zip_exceptions.h'
--- src/io/filesystem/zip_exceptions.h 2014-09-10 13:03:40 +0000
+++ src/io/filesystem/zip_exceptions.h 2014-09-29 14:39:47 +0000
@@ -27,7 +27,7 @@
27 *27 *
28 * Problems with the zipfile itself or normal file operations should throw28 * Problems with the zipfile itself or normal file operations should throw
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.:
30 * throw FileNotFoundError("ZipFilesystem::Load", fname,30 * throw FileNotFoundError("ZipFilesystem::load", fname,
31 * "couldn't open file (from zipfile "+m_zipfilename+")");31 * "couldn't open file (from zipfile "+m_zipfilename+")");
32 */32 */
33struct ZipOperationError : public std::logic_error {33struct ZipOperationError : public std::logic_error {
3434
=== modified file 'src/io/filesystem/zip_filesystem.cc'
--- src/io/filesystem/zip_filesystem.cc 2014-09-10 13:03:40 +0000
+++ src/io/filesystem/zip_filesystem.cc 2014-09-29 14:39:47 +0000
@@ -43,7 +43,7 @@
43m_unzipfile (nullptr),43m_unzipfile (nullptr),
44m_oldzip (false),44m_oldzip (false),
45m_zipfilename(zipfile),45m_zipfilename(zipfile),
46m_basenamezip(FS_Filename(zipfile.c_str())),46m_basenamezip(fs_filename(zipfile.c_str())),
47m_basename ()47m_basename ()
48{48{
49 // TODO(unknown): check OS permissions on whether the file is writable49 // TODO(unknown): check OS permissions on whether the file is writable
@@ -54,13 +54,13 @@
54 */54 */
55ZipFilesystem::~ZipFilesystem()55ZipFilesystem::~ZipFilesystem()
56{56{
57 m_Close();57 m_close();
58}58}
5959
60/**60/**
61 * Return true if this directory is writable.61 * Return true if this directory is writable.
62 */62 */
63bool ZipFilesystem::IsWritable() const {63bool ZipFilesystem::is_writable() const {
64 return true; // should be checked in constructor64 return true; // should be checked in constructor
65}65}
6666
@@ -69,8 +69,8 @@
69 * pathname) in the results. There doesn't seem to be an even remotely69 * pathname) in the results. There doesn't seem to be an even remotely
70 * cross-platform way of doing this70 * cross-platform way of doing this
71 */71 */
72std::set<std::string> ZipFilesystem::ListDirectory(const std::string& path_in) {72std::set<std::string> ZipFilesystem::list_directory(const std::string& path_in) {
73 m_OpenUnzip();73 m_open_unzip();
7474
75 assert(path_in.size()); // prevent invalid read below75 assert(path_in.size()); // prevent invalid read below
7676
@@ -95,7 +95,7 @@
95 nullptr, 0, nullptr, 0);95 nullptr, 0, nullptr, 0);
9696
97 std::string complete_filename = strip_basename(filename_inzip);97 std::string complete_filename = strip_basename(filename_inzip);
98 std::string filename = FS_Filename(complete_filename.c_str());98 std::string filename = fs_filename(complete_filename.c_str());
99 std::string filepath =99 std::string filepath =
100 complete_filename.substr100 complete_filename.substr
101 (0, complete_filename.size() - filename.size());101 (0, complete_filename.size() - filename.size());
@@ -118,9 +118,9 @@
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.
119 * Also returns false if the pathname is invalid119 * Also returns false if the pathname is invalid
120 */120 */
121bool ZipFilesystem::FileExists(const std::string & path) {121bool ZipFilesystem::file_exists(const std::string & path) {
122 try {122 try {
123 m_OpenUnzip(); // TODO(unknown): check return value123 m_open_unzip(); // TODO(unknown): check return value
124 } catch (...) {124 } catch (...) {
125 return false;125 return false;
126 }126 }
@@ -159,9 +159,9 @@
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.
160 * Also returns false if the pathname is invalid160 * Also returns false if the pathname is invalid
161 */161 */
162bool ZipFilesystem::IsDirectory(const std::string & path) {162bool ZipFilesystem::is_directory(const std::string & path) {
163163
164 if (!FileExists(path))164 if (!file_exists(path))
165 return false;165 return false;
166166
167 unz_file_info file_info;167 unz_file_info file_info;
@@ -177,13 +177,13 @@
177/**177/**
178 * Create a sub filesystem out of this filesystem178 * Create a sub filesystem out of this filesystem
179 */179 */
180FileSystem * ZipFilesystem::MakeSubFileSystem(const std::string & path) {180FileSystem * ZipFilesystem::make_sub_file_system(const std::string & path) {
181 m_OpenUnzip();181 m_open_unzip();
182182
183 assert(FileExists(path));183 assert(file_exists(path));
184 assert(IsDirectory(path));184 assert(is_directory(path));
185185
186 m_Close();186 m_close();
187187
188 std::string localpath = path;188 std::string localpath = path;
189189
@@ -201,20 +201,20 @@
201 * \throw ZipOperationError201 * \throw ZipOperationError
202 */202 */
203// TODO(unknown): type should be recognized automatically,203// TODO(unknown): type should be recognized automatically,
204// see Filesystem::Create204// see Filesystem::create
205FileSystem * ZipFilesystem::CreateSubFileSystem(const std::string & path, Type const type)205FileSystem * ZipFilesystem::create_sub_file_system(const std::string & path, Type const type)
206{206{
207 assert(!FileExists(path));207 assert(!file_exists(path));
208208
209 if (type != FileSystem::DIR)209 if (type != FileSystem::DIR)
210 throw ZipOperationError210 throw ZipOperationError
211 ("ZipFilesystem::CreateSubFileSystem",211 ("ZipFilesystem::create_sub_file_system",
212 path, m_zipfilename,212 path, m_zipfilename,
213 "can not create ZipFilesystem inside another ZipFilesystem");213 "can not create ZipFilesystem inside another ZipFilesystem");
214214
215 EnsureDirectoryExists(path);215 ensure_directory_exists(path);
216216
217 m_Close();217 m_close();
218218
219 std::string localpath = path;219 std::string localpath = path;
220220
@@ -231,9 +231,9 @@
231 * Remove a number of files231 * Remove a number of files
232 * \throw ZipOperationError232 * \throw ZipOperationError
233 */233 */
234void ZipFilesystem::Unlink(const std::string & filename) {234void ZipFilesystem::fs_unlink(const std::string & filename) {
235 throw ZipOperationError235 throw ZipOperationError
236 ("ZipFilesystem::Unlink",236 ("ZipFilesystem::unlink",
237 filename,237 filename,
238 m_zipfilename,238 m_zipfilename,
239 "unlinking is not supported inside zipfiles");239 "unlinking is not supported inside zipfiles");
@@ -243,11 +243,11 @@
243 * Create this directory if it doesn't exist, throws an error243 * Create this directory if it doesn't exist, throws an error
244 * if the dir can't be created or if a file with this name exists244 * if the dir can't be created or if a file with this name exists
245 */245 */
246void ZipFilesystem::EnsureDirectoryExists(const std::string & dirname) {246void ZipFilesystem::ensure_directory_exists(const std::string & dirname) {
247 if (FileExists(dirname) && IsDirectory(dirname))247 if (file_exists(dirname) && is_directory(dirname))
248 return;248 return;
249249
250 MakeDirectory(dirname);250 make_directory(dirname);
251}251}
252252
253/**253/**
@@ -255,11 +255,11 @@
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.
256 *256 *
257 * Pleas note, this function does not honor parents,257 * Pleas note, this function does not honor parents,
258 * MakeDirectory("onedir/otherdir/onemoredir") will fail258 * make_directory("onedir/otherdir/onemoredir") will fail
259 * if either ondir or otherdir is missing259 * if either ondir or otherdir is missing
260 */260 */
261void ZipFilesystem::MakeDirectory(const std::string & dirname) {261void ZipFilesystem::make_directory(const std::string & dirname) {
262 m_OpenZip();262 m_open_zip();
263263
264 zip_fileinfo zi;264 zip_fileinfo zi;
265265
@@ -296,23 +296,23 @@
296 break;296 break;
297 case ZIP_ERRNO:297 case ZIP_ERRNO:
298 throw FileError298 throw FileError
299 ("ZipFilesystem::MakeDirectory", complete_filename, strerror(errno));299 ("ZipFilesystem::make_directory", complete_filename, strerror(errno));
300 default:300 default:
301 throw FileError301 throw FileError
302 ("ZipFilesystem::MakeDirectory", complete_filename);302 ("ZipFilesystem::make_directory", complete_filename);
303 }303 }
304304
305 zipCloseFileInZip(m_zipfile);305 zipCloseFileInZip(m_zipfile);
306}306}
307307
308/**308/**
309 * Read the given file into alloced memory; called by FileRead::Open.309 * Read the given file into alloced memory; called by FileRead::open.
310 * \throw FileNotFoundError if the file couldn't be opened.310 * \throw FileNotFoundError if the file couldn't be opened.
311 */311 */
312void * ZipFilesystem::Load(const std::string & fname, size_t & length) {312void * ZipFilesystem::load(const std::string & fname, size_t & length) {
313 if (!FileExists(fname.c_str()) || IsDirectory(fname.c_str()))313 if (!file_exists(fname.c_str()) || is_directory(fname.c_str()))
314 throw ZipOperationError314 throw ZipOperationError
315 ("ZipFilesystem::Load",315 ("ZipFilesystem::load",
316 fname,316 fname,
317 m_zipfilename,317 m_zipfilename,
318 "could not open file from zipfile");318 "could not open file from zipfile");
@@ -330,7 +330,7 @@
330 char buf[200];330 char buf[200];
331 snprintf(buf, sizeof(buf), "read error %i", len);331 snprintf(buf, sizeof(buf), "read error %i", len);
332 throw ZipOperationError332 throw ZipOperationError
333 ("ZipFilesystem::Load",333 ("ZipFilesystem::load",
334 fname,334 fname,
335 m_zipfilename,335 m_zipfilename,
336 buf);336 buf);
@@ -357,13 +357,13 @@
357 * Write the given block of memory to the repository.357 * Write the given block of memory to the repository.
358 * Throws an exception if it fails.358 * Throws an exception if it fails.
359 */359 */
360void ZipFilesystem::Write360void ZipFilesystem::write
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)
362{362{
363 std::string filename = fname;363 std::string filename = fname;
364 std::replace(filename.begin(), filename.end(), '\\', '/');364 std::replace(filename.begin(), filename.end(), '\\', '/');
365365
366 m_OpenZip();366 m_open_zip();
367367
368 zip_fileinfo zi;368 zip_fileinfo zi;
369369
@@ -389,7 +389,7 @@
389 break;389 break;
390 default:390 default:
391 throw ZipOperationError391 throw ZipOperationError
392 ("ZipFilesystem::Write", complete_filename, m_zipfilename);392 ("ZipFilesystem::write", complete_filename, m_zipfilename);
393 }393 }
394394
395 switch (zipWriteInFileInZip (m_zipfile, data, length)) {395 switch (zipWriteInFileInZip (m_zipfile, data, length)) {
@@ -397,10 +397,10 @@
397 break;397 break;
398 case ZIP_ERRNO:398 case ZIP_ERRNO:
399 throw FileError399 throw FileError
400 ("ZipFilesystem::Write", complete_filename, strerror(errno));400 ("ZipFilesystem::write", complete_filename, strerror(errno));
401 default:401 default:
402 throw FileError402 throw FileError
403 ("ZipFilesystem::Write", complete_filename);403 ("ZipFilesystem::write", complete_filename);
404 }404 }
405405
406 zipCloseFileInZip(m_zipfile);406 zipCloseFileInZip(m_zipfile);
@@ -413,12 +413,12 @@
413ZipFilesystem::ZipStreamRead::ZipStreamRead(zipFile file, ZipFilesystem* zipfs)413ZipFilesystem::ZipStreamRead::ZipStreamRead(zipFile file, ZipFilesystem* zipfs)
414: m_unzipfile(file), m_zipfs(zipfs) {}414: m_unzipfile(file), m_zipfs(zipfs) {}
415ZipFilesystem::ZipStreamRead::~ZipStreamRead() {415ZipFilesystem::ZipStreamRead::~ZipStreamRead() {
416 m_zipfs->m_Close();416 m_zipfs->m_close();
417}417}
418418
419size_t ZipFilesystem::ZipStreamRead::Data(void* data, size_t bufsize)419size_t ZipFilesystem::ZipStreamRead::data(void* read_data, size_t bufsize)
420{420{
421 int copied = unzReadCurrentFile(m_unzipfile, data, bufsize);421 int copied = unzReadCurrentFile(m_unzipfile, read_data, bufsize);
422 if (copied < 0) {422 if (copied < 0) {
423 throw new DataError("Failed to read from zip file");423 throw new DataError("Failed to read from zip file");
424 }424 }
@@ -427,21 +427,21 @@
427 }427 }
428 return copied;428 return copied;
429}429}
430bool ZipFilesystem::ZipStreamRead::EndOfFile() const430bool ZipFilesystem::ZipStreamRead::end_of_file() const
431{431{
432 return unzReadCurrentFile(m_unzipfile, nullptr, 1) == 0;432 return unzReadCurrentFile(m_unzipfile, nullptr, 1) == 0;
433}433}
434434
435StreamRead* ZipFilesystem::OpenStreamRead(const std::string& fname) {435StreamRead* ZipFilesystem::open_stream_read(const std::string& fname) {
436 if (!FileExists(fname.c_str()) || IsDirectory(fname.c_str()))436 if (!file_exists(fname.c_str()) || is_directory(fname.c_str()))
437 throw ZipOperationError437 throw ZipOperationError
438 ("ZipFilesystem::Load",438 ("ZipFilesystem::load",
439 fname,439 fname,
440 m_zipfilename,440 m_zipfilename,
441 "could not open file from zipfile");441 "could not open file from zipfile");
442442
443 int32_t method;443 int32_t method;
444 m_OpenUnzip();444 m_open_unzip();
445 int result = unzOpenCurrentFile3(m_unzipfile, &method, nullptr, 1, nullptr);445 int result = unzOpenCurrentFile3(m_unzipfile, &method, nullptr, 1, nullptr);
446 switch (result) {446 switch (result) {
447 case ZIP_OK:447 case ZIP_OK:
@@ -461,12 +461,12 @@
461: m_zipfile(file), m_zipfs(zipfs) {}461: m_zipfile(file), m_zipfs(zipfs) {}
462ZipFilesystem::ZipStreamWrite::~ZipStreamWrite()462ZipFilesystem::ZipStreamWrite::~ZipStreamWrite()
463{463{
464 m_zipfs->m_Close();464 m_zipfs->m_close();
465}465}
466466
467void ZipFilesystem::ZipStreamWrite::Data(const void* const data, const size_t size)467void ZipFilesystem::ZipStreamWrite::data(const void* const write_data, const size_t size)
468{468{
469 int result = zipWriteInFileInZip(m_zipfile, data, size);469 int result = zipWriteInFileInZip(m_zipfile, write_data, size);
470 switch (result) {470 switch (result) {
471 case ZIP_OK:471 case ZIP_OK:
472 break;472 break;
@@ -475,8 +475,8 @@
475 }475 }
476}476}
477477
478StreamWrite * ZipFilesystem::OpenStreamWrite(const std::string & fname) {478StreamWrite * ZipFilesystem::open_stream_write(const std::string & fname) {
479 m_OpenZip();479 m_open_zip();
480480
481 zip_fileinfo zi;481 zip_fileinfo zi;
482482
@@ -510,7 +510,7 @@
510/**510/**
511 * Private Functions below511 * Private Functions below
512 */512 */
513void ZipFilesystem::m_Close() {513void ZipFilesystem::m_close() {
514 if (m_state == STATE_ZIPPING)514 if (m_state == STATE_ZIPPING)
515 zipClose(m_zipfile, nullptr);515 zipClose(m_zipfile, nullptr);
516 else if (m_state == STATE_UNZIPPPING)516 else if (m_state == STATE_UNZIPPPING)
@@ -522,11 +522,11 @@
522/**522/**
523 * Open a zipfile for compressing523 * Open a zipfile for compressing
524 */524 */
525void ZipFilesystem::m_OpenZip() {525void ZipFilesystem::m_open_zip() {
526 if (m_state == STATE_ZIPPING)526 if (m_state == STATE_ZIPPING)
527 return;527 return;
528528
529 m_Close();529 m_close();
530530
531 m_zipfile = zipOpen(m_zipfilename.c_str(), APPEND_STATUS_ADDINZIP);531 m_zipfile = zipOpen(m_zipfilename.c_str(), APPEND_STATUS_ADDINZIP);
532 if (!m_zipfile) {532 if (!m_zipfile) {
@@ -541,25 +541,25 @@
541 * Open a zipfile for extraction541 * Open a zipfile for extraction
542 * \throw FileTypeError542 * \throw FileTypeError
543 */543 */
544void ZipFilesystem::m_OpenUnzip() {544void ZipFilesystem::m_open_unzip() {
545 if (m_state == STATE_UNZIPPPING)545 if (m_state == STATE_UNZIPPPING)
546 return;546 return;
547547
548 m_Close();548 m_close();
549549
550 m_unzipfile = unzOpen(m_zipfilename.c_str());550 m_unzipfile = unzOpen(m_zipfilename.c_str());
551 if (!m_unzipfile)551 if (!m_unzipfile)
552 throw FileTypeError552 throw FileTypeError
553 ("ZipFilesystem::m_OpenUnzip", m_zipfilename, "not a .zip file");553 ("ZipFilesystem::m_open_unzip", m_zipfilename, "not a .zip file");
554554
555 m_state = STATE_UNZIPPPING;555 m_state = STATE_UNZIPPPING;
556}556}
557557
558void ZipFilesystem::Rename(const std::string &, const std::string &) {558void ZipFilesystem::fs_rename(const std::string &, const std::string &) {
559 throw wexception("rename inside zip FS is not implemented yet");559 throw wexception("rename inside zip FS is not implemented yet");
560}560}
561561
562unsigned long long ZipFilesystem::DiskSpace() {562unsigned long long ZipFilesystem::disk_space() {
563 return 0;563 return 0;
564}564}
565565
566566
=== modified file 'src/io/filesystem/zip_filesystem.h'
--- src/io/filesystem/zip_filesystem.h 2014-07-26 10:43:23 +0000
+++ src/io/filesystem/zip_filesystem.h 2014-09-29 14:39:47 +0000
@@ -35,40 +35,40 @@
35 explicit ZipFilesystem(const std::string &);35 explicit ZipFilesystem(const std::string &);
36 virtual ~ZipFilesystem();36 virtual ~ZipFilesystem();
3737
38 bool IsWritable() const override;38 bool is_writable() const override;
3939
40 std::set<std::string> ListDirectory(const std::string& path) override;40 std::set<std::string> list_directory(const std::string& path) override;
4141
42 bool IsDirectory(const std::string & path) override;42 bool is_directory(const std::string & path) override;
43 bool FileExists (const std::string & path) override;43 bool file_exists (const std::string & path) override;
4444
45 void * Load(const std::string & fname, size_t & length) override;45 void * load(const std::string & fname, size_t & length) override;
4646
47 virtual void Write47 virtual void write
48 (const std::string & fname, void const * data, int32_t length) override;48 (const std::string & fname, void const * data, int32_t length) override;
49 void EnsureDirectoryExists(const std::string & dirname) override;49 void ensure_directory_exists(const std::string & fs_dirname) override;
50 void MakeDirectory (const std::string & dirname) override;50 void make_directory (const std::string & fs_dirname) override;
5151
52 virtual StreamRead * OpenStreamRead52 virtual StreamRead * open_stream_read
53 (const std::string & fname) override;53 (const std::string & fname) override;
54 virtual StreamWrite * OpenStreamWrite54 virtual StreamWrite * open_stream_write
55 (const std::string & fname) override;55 (const std::string & fname) override;
5656
57 FileSystem * MakeSubFileSystem(const std::string & dirname) override;57 FileSystem * make_sub_file_system(const std::string & fs_dirname) override;
58 FileSystem * CreateSubFileSystem(const std::string & dirname, Type) override;58 FileSystem * create_sub_file_system(const std::string & fs_dirname, Type) override;
59 void Unlink(const std::string & filename) override;59 void fs_unlink(const std::string & fs_filename) override;
60 void Rename(const std::string &, const std::string &) override;60 void fs_rename(const std::string &, const std::string &) override;
6161
62 unsigned long long DiskSpace() override;62 unsigned long long disk_space() override;
6363
64 static FileSystem * CreateFromDirectory(const std::string & directory);64 static FileSystem * create_from_directory(const std::string & directory);
6565
66 std::string getBasename() override {return m_zipfilename;}66 std::string get_basename() override {return m_zipfilename;}
6767
68protected:68protected:
69 void m_OpenUnzip();69 void m_open_unzip();
70 void m_OpenZip();70 void m_open_zip();
71 void m_Close();71 void m_close();
72 std::string strip_basename(std::string);72 std::string strip_basename(std::string);
7373
74 enum State {74 enum State {
@@ -90,8 +90,8 @@
90 struct ZipStreamRead : StreamRead {90 struct ZipStreamRead : StreamRead {
91 explicit ZipStreamRead(zipFile file, ZipFilesystem* zipfs);91 explicit ZipStreamRead(zipFile file, ZipFilesystem* zipfs);
92 virtual ~ZipStreamRead();92 virtual ~ZipStreamRead();
93 size_t Data(void* data, size_t bufsize) override;93 size_t data(void* data, size_t bufsize) override;
94 bool EndOfFile() const override;94 bool end_of_file() const override;
95 private:95 private:
96 zipFile m_unzipfile;96 zipFile m_unzipfile;
97 ZipFilesystem* m_zipfs;97 ZipFilesystem* m_zipfs;
@@ -99,7 +99,7 @@
99 struct ZipStreamWrite : StreamWrite {99 struct ZipStreamWrite : StreamWrite {
100 explicit ZipStreamWrite(zipFile file, ZipFilesystem* zipfs);100 explicit ZipStreamWrite(zipFile file, ZipFilesystem* zipfs);
101 virtual ~ZipStreamWrite();101 virtual ~ZipStreamWrite();
102 void Data(const void* const data, size_t size) override;102 void data(const void* const data, size_t size) override;
103 private:103 private:
104 zipFile m_zipfile;104 zipFile m_zipfile;
105 ZipFilesystem* m_zipfs;105 ZipFilesystem* m_zipfs;
106106
=== modified file 'src/io/filewrite.cc'
--- src/io/filewrite.cc 2014-07-20 07:44:22 +0000
+++ src/io/filewrite.cc 2014-09-29 14:39:47 +0000
@@ -26,39 +26,39 @@
26}26}
2727
28FileWrite::~FileWrite() {28FileWrite::~FileWrite() {
29 Clear();29 clear();
30}30}
3131
32void FileWrite::Clear() {32void FileWrite::clear() {
33 free(data_);33 free(data_);
34 data_ = nullptr;34 data_ = nullptr;
35 length_ = max_size_ = 0;35 length_ = max_size_ = 0;
36 filepos_ = 0;36 filepos_ = 0;
37}37}
3838
39void FileWrite::Write(FileSystem& fs, char const* const filename) {
40 fs.Write(filename, data_, length_);
41 Clear();
42}
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to status/vote changes: