Assigned value is never read in game_io /game_player_economies_data_packet.cc (and general strangeness)

Bug #1350476 reported by Hans Joachim Desserud
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Low
Hans Joachim Desserud

Bug Description

I ran scan-build on r7157 and it found two issue in this file. At first I thought they were simply variations over a common issue, but it turns out that's not the case. Furthermore, it just seems strange.

In line 55, we loop through all the economies via a foreach, which is fair enough. Though, in some cases we reassign the value of the looping variable (line 59). I'm not really sure whether it should actually be reassigned or treated as a separate value. Though in either case, the value of the variable is never read anywhere so it's pretty harmless. Though still rather strange. Could someone please take a look at this?

Related branches

Revision history for this message
Hans Joachim Desserud (hjd) wrote :
Revision history for this message
Hans Joachim Desserud (hjd) wrote :
Revision history for this message
SirVer (sirver) wrote :

That should just be for (int i = 0; i < nr_economies; ++i).

Basically the write code iterates through all economy and for each one searches a map object that is part of this economy. The objects id is then written to the file. On load, the map object is found and it's economy loads the data that was saved. Rather convoluted, but necessary as we can not guarantee that economies are created in the same order as in the original game on load.

Changed in widelands:
status: New → Triaged
milestone: none → build19-rc1
Revision history for this message
SirVer (sirver) wrote :

The reassigned value is also not needed.

Revision history for this message
Hans Joachim Desserud (hjd) wrote :

> That should just be for (int i = 0; i < nr_economies; ++i).

Ok, that's what I thought.

Changed in widelands:
status: Triaged → In Progress
assignee: nobody → Hans Joachim Desserud (hjd)
Changed in widelands:
status: In Progress → Fix Committed
GunChleoc (gunchleoc)
Changed in widelands:
status: Fix Committed → Fix Released
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build19-rc1.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.