← Back to team overview

widelands-dev team mailing list archive

Re: [Merge] lp:~widelands-dev/widelands/economy_save_load_debug into lp:widelands

 


Diff comments:

> === modified file 'src/game_io/game_player_economies_packet.cc'
> --- src/game_io/game_player_economies_packet.cc	2016-08-04 15:49:05 +0000
> +++ src/game_io/game_player_economies_packet.cc	2017-01-10 18:04:24 +0000
> @@ -31,8 +32,31 @@
>  #include "logic/widelands_geometry_io.h"
>  
>  namespace Widelands {
> -
> -constexpr uint16_t kCurrentPacketVersion = 3;
> +namespace {
> +
> +constexpr uint16_t kCurrentPacketVersion = 4;
> +
> +bool write_expedition_ship_economy(Economy* economy, const Map& map, FileWrite* fw) {
> +	for (Field const* field = &map[0]; field < &map[map.max_index()]; ++field) {
> +		Bob* bob = field->get_first_bob();
> +		while (bob) {
> +			if (upcast(Ship const, ship, bob)) {
> +				if (ship->get_economy() == economy) {
> +					// TODO(sirver): the 0xffffffff is ugly and fragile.
> +					fw->unsigned_32(0xffffffff);  // Sentinel value.

Yes, I am aware of that. I still find it awkward - I have no plans of changing it right now.

I mostly moved this code out into a function, so I could do an early return instead of keeping the 'wrote_this_economy' variable which seemed rather fragile to me.

> +					fw->unsigned_32(field - &map[0]);
> +					EconomyDataPacket d(economy);
> +					d.write(*fw);
> +					return true;
> +				}
> +			}
> +			bob = bob->get_next_bob();
> +		}
> +	}
> +	return false;
> +}
> +
> +}  // namespace
>  
>  void GamePlayerEconomiesPacket::read(FileSystem& fs, Game& game, MapObjectLoader*) {
>  	try {


-- 
https://code.launchpad.net/~widelands-dev/widelands/economy_save_load_debug/+merge/314453
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/economy_save_load_debug into lp:widelands.


References