~qcumber-some/widelands/spice-up-cmake

« back to all changes in this revision

Viewing changes to src/map_io/widelands_map_bob_data_packet.cc

  • Committer: Jens Beyer (Qcumber-some)
  • Date: 2010-05-28 14:51:37 UTC
  • mfrom: (5149.1.226 trunk)
  • Revision ID: qcumber-some@buerotiger.de-20100528145137-0pyil9qw7szyztsw
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
128
128
                                for (uint16_t x = 0; x < map.get_width(); ++x) {
129
129
                                        uint32_t const nr_bobs = fr.Unsigned32();
130
130
 
131
 
                                        assert(!map[Coords(x, y)].get_first_bob());
132
 
 
133
131
                                        for (uint32_t i = 0; i < nr_bobs; ++i)
134
132
                                                ReadBob(fr, egbase, skip, mol, Coords(x, y));
135
133
                                }
147
145
        (FileSystem & fs, Editor_Game_Base & egbase, Map_Map_Object_Saver & mos)
148
146
throw (_wexception)
149
147
{
150
 
        FileWrite fw;
151
 
 
152
 
        // now packet version
153
 
        fw.Unsigned16(CURRENT_PACKET_VERSION);
154
 
 
155
 
        // Now, all bob id and registerd it
156
 
        // A Field can have more
157
 
        // than one bob, we have to take this into account
158
 
        //  uint8_t   numbers of bob for field
159
 
        //      bob1
160
 
        //      bob2
161
 
        //      ...
162
 
        //      bobn
163
 
        Map & map = egbase.map();
164
 
        for (uint16_t y = 0; y < map.get_height(); ++y) {
165
 
                for (uint16_t x = 0; x < map.get_width(); ++x) {
166
 
                        std::vector<Bob *> bobarr;
167
 
 
168
 
                        map.find_bobs //  FIXME clean up this mess!
169
 
                                (Area<FCoords>(map.get_fcoords(Coords(x, y)), 0), &bobarr);
170
 
                        fw.Unsigned32(bobarr.size());
171
 
 
172
 
                        for (uint32_t i = 0; i < bobarr.size(); ++i) {
173
 
                                // write serial number
174
 
 
175
 
                                //  a bob can not be owned by two nodes
176
 
                                assert(not mos.is_object_known(*bobarr[i]));
177
 
 
178
 
                                Serial const reg = mos.register_object(*bobarr[i]);
179
 
 
180
 
                                // Write its owner
181
 
                                std::string owner_tribe =
182
 
                                        bobarr[i]->descr().get_owner_tribe() ?
183
 
                                        bobarr[i]->descr().get_owner_tribe()->name() : "world";
184
 
                                fw.String(owner_tribe);
185
 
                                // Write it's name
186
 
                                fw.String(bobarr[i]->name());
187
 
                                // Write it's subtype
188
 
                                fw.Unsigned8(bobarr[i]->get_bob_type());
189
 
                                // And it's file register index
190
 
                                fw.Unsigned32(reg);
191
 
                        }
192
 
                }
193
 
        }
194
 
 
195
 
        fw.Write(fs, "binary/bob");
 
148
        throw wexception("bob packet is deprecated");
196
149
}
197
150
 
198
151
}