Merge lp:~widelands-dev/widelands/remove-compatibility-wares into lp:widelands
- remove-compatibility-wares
- Merge into trunk
Proposed by
Hans Joachim Desserud
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 6874 | ||||
Proposed branch: | lp:~widelands-dev/widelands/remove-compatibility-wares | ||||
Merge into: | lp:widelands | ||||
Diff against target: |
680 lines (+12/-327) 20 files modified
src/economy/ware_instance.cc (+0/-19) src/logic/immovable.cc (+11/-29) src/logic/instances.cc (+1/-20) src/logic/instances.h (+0/-7) src/logic/productionsite.cc (+0/-36) src/logic/productionsite.h (+0/-13) src/logic/tribe.cc (+0/-46) src/logic/tribe.h (+0/-11) src/logic/widelands_streamread.cc (+0/-3) src/logic/worker.cc (+0/-21) src/logic/worker.h (+0/-2) src/logic/worker_descr.cc (+0/-20) src/logic/worker_descr.h (+0/-10) src/map_io/widelands_map_buildingdata_data_packet.cc (+0/-57) tribes/barbarians/battlearena/conf (+0/-3) tribes/barbarians/conf (+0/-11) tribes/barbarians/ferner/conf (+0/-5) tribes/barbarians/fernery/conf (+0/-8) tribes/barbarians/metalworks/conf (+0/-3) tribes/empire/sawmill/conf (+0/-3) |
||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands/remove-compatibility-wares | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
SirVer | Approve | ||
Review via email: mp+210885@code.launchpad.net |
Commit message
Description of the change
Remove the compatibility-
Also, I've removed what I could find on the code side responsible for reading/using these. I haven't done any thorough checks after these changes, but it compiles ;)
As before, I've included a couple of FIXMEs for specific issues.
To post a comment you must log in.
Revision history for this message
Hans Joachim Desserud (hjd) wrote : | # |
I'm not expert on c++, but it looks ok to me at least.
Btw, I noticed Map_Object:
Revision history for this message
SirVer (sirver) wrote : | # |
load_finish() seems to be still needed - some derived classes override it.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/economy/ware_instance.cc' |
2 | --- src/economy/ware_instance.cc 2014-02-22 18:04:02 +0000 |
3 | +++ src/economy/ware_instance.cc 2014-03-13 21:39:01 +0000 |
4 | @@ -636,32 +636,13 @@ |
5 | if (!tribe) |
6 | throw wexception("unknown tribe '%s'", tribename.c_str()); |
7 | |
8 | - bool kill = false; |
9 | Ware_Index wareindex = tribe->ware_index(warename); |
10 | - if (!wareindex) { |
11 | - // Old savegame, using a ware that no longer exists |
12 | - // We need to do the loading anyway to ensure that the |
13 | - // correct number of bytes is read, but we will mark |
14 | - // the object for immediate removal. |
15 | - log("WARNING: Tribe %s has no ware %s\n", tribename.c_str(), warename.c_str()); |
16 | - wareindex = Ware_Index::First(); |
17 | - kill = true; |
18 | - } |
19 | const WareDescr * descr = tribe->get_ware_descr(wareindex); |
20 | |
21 | std::unique_ptr<Loader> loader(new Loader); |
22 | loader->init(egbase, mol, *new WareInstance(wareindex, descr)); |
23 | loader->load(fr); |
24 | |
25 | - if (kill) { |
26 | - if (upcast(Game, game, &egbase)) |
27 | - loader->add_finish |
28 | - (boost::bind |
29 | - (&Map_Object::schedule_destroy, |
30 | - loader->get_object(), |
31 | - boost::ref(*game))); |
32 | - } |
33 | - |
34 | return loader.release(); |
35 | } catch (const std::exception & e) { |
36 | throw wexception("WareInstance: %s", e.what()); |
37 | |
38 | === modified file 'src/logic/immovable.cc' |
39 | --- src/logic/immovable.cc 2014-03-09 18:29:48 +0000 |
40 | +++ src/logic/immovable.cc 2014-03-13 21:39:01 +0000 |
41 | @@ -742,47 +742,29 @@ |
42 | uint8_t const version = fr.Unsigned8(); |
43 | if (1 <= version and version <= IMMOVABLE_SAVEGAME_VERSION) { |
44 | |
45 | - char const * const owner = fr.CString (); |
46 | - char const * const name = fr.CString (); |
47 | + const std::string owner_name = fr.CString(); |
48 | + const std::string name = fr.CString(); |
49 | Immovable * imm = nullptr; |
50 | |
51 | - if (strcmp(owner, "world")) { // It is a tribe immovable. |
52 | - egbase.manually_load_tribe(owner); |
53 | - |
54 | - if (Tribe_Descr const * const tribe = egbase.get_tribe(owner)) { |
55 | - std::string effective_name = name; |
56 | - const std::vector<std::string> & compat = |
57 | - tribe->compatibility_immovable(name); |
58 | - |
59 | - if (compat.size() >= 1) { |
60 | - if (compat[0] == "replace") { |
61 | - if (compat.size() != 2) |
62 | - throw game_data_error |
63 | - ("incomplete compatibility_immovable replace for %s", |
64 | - name); |
65 | - |
66 | - effective_name = compat[1]; |
67 | - } else |
68 | - throw game_data_error |
69 | - ("bad compatibility_immovable code %s for %s", |
70 | - compat[0].c_str(), name); |
71 | - } |
72 | - |
73 | - int32_t const idx = tribe->get_immovable_index(effective_name); |
74 | + if (owner_name != "world") { // It is a tribe immovable. |
75 | + egbase.manually_load_tribe(owner_name); |
76 | + |
77 | + if (Tribe_Descr const * const tribe = egbase.get_tribe(owner_name)) { |
78 | + int32_t const idx = tribe->get_immovable_index(name); |
79 | if (idx != -1) |
80 | imm = new Immovable(*tribe->get_immovable_descr(idx)); |
81 | else |
82 | throw game_data_error |
83 | ("tribe %s does not define immovable type \"%s\"", |
84 | - owner, effective_name.c_str()); |
85 | + owner_name.c_str(), name.c_str()); |
86 | } else |
87 | - throw wexception("unknown tribe %s", owner); |
88 | + throw wexception("unknown tribe %s", owner_name.c_str()); |
89 | } else { // world immovable |
90 | const World & world = egbase.map().world(); |
91 | - int32_t const idx = world.get_immovable_index(name); |
92 | + int32_t const idx = world.get_immovable_index(name.c_str()); |
93 | if (idx == -1) |
94 | throw wexception |
95 | - ("world does not define immovable type \"%s\"", name); |
96 | + ("world does not define immovable type \"%s\"", name.c_str()); |
97 | |
98 | imm = new Immovable(*world.get_immovable_descr(idx)); |
99 | } |
100 | |
101 | === modified file 'src/logic/instances.cc' |
102 | --- src/logic/instances.cc 2014-03-04 13:24:58 +0000 |
103 | +++ src/logic/instances.cc 2014-03-13 21:39:01 +0000 |
104 | @@ -518,26 +518,7 @@ |
105 | */ |
106 | void Map_Object::Loader::load_finish() |
107 | { |
108 | - while (!m_finish.empty()) { |
109 | - m_finish.back()(); |
110 | - m_finish.pop_back(); |
111 | - } |
112 | -} |
113 | - |
114 | -/** |
115 | - * Register a callback function that will automatically be run at |
116 | - * \ref load_finish time. |
117 | - * |
118 | - * This is useful for registering save game compatibility fixups that need |
119 | - * to be run after everything else has loaded. |
120 | - * |
121 | - * Callbacks are run in LIFO order. |
122 | - */ |
123 | -void Map_Object::Loader::add_finish(const FinishFn & fini) |
124 | -{ |
125 | - m_finish.push_back(fini); |
126 | -} |
127 | - |
128 | +} |
129 | |
130 | /** |
131 | * Save the Map_Object to the given file. |
132 | |
133 | === modified file 'src/logic/instances.h' |
134 | --- src/logic/instances.h 2014-02-22 18:04:02 +0000 |
135 | +++ src/logic/instances.h 2014-03-13 21:39:01 +0000 |
136 | @@ -279,8 +279,6 @@ |
137 | Loader() : m_egbase(nullptr), m_mol(nullptr), m_object(nullptr) {} |
138 | |
139 | public: |
140 | - typedef boost::function<void ()> FinishFn; |
141 | - |
142 | virtual ~Loader() {} |
143 | |
144 | void init |
145 | @@ -298,17 +296,12 @@ |
146 | return ref_cast<T, Map_Object>(*m_object); |
147 | } |
148 | |
149 | - void add_finish(const FinishFn & fini); |
150 | - |
151 | protected: |
152 | void load(FileRead &); |
153 | |
154 | public: |
155 | virtual void load_pointers(); |
156 | virtual void load_finish(); |
157 | - |
158 | - private: |
159 | - std::vector<FinishFn> m_finish; |
160 | }; |
161 | |
162 | /// This is just a fail-safe guard for the time until we fully transition |
163 | |
164 | === modified file 'src/logic/productionsite.cc' |
165 | --- src/logic/productionsite.cc 2014-03-04 13:24:58 +0000 |
166 | +++ src/logic/productionsite.cc 2014-03-13 21:39:01 +0000 |
167 | @@ -133,16 +133,6 @@ |
168 | throw wexception("program %s: %s", program_name.c_str(), e.what()); |
169 | } |
170 | } |
171 | - |
172 | - if (Section * compat_s = prof.get_section("compatibility_programs")) { |
173 | - while (const Section::Value * v = compat_s->get_next_val()) |
174 | - m_compatibility_programs[v->get_name()] = split_string(v->get_string(), " "); |
175 | - } |
176 | - |
177 | - if (Section * compat_s = prof.get_section("compatibility working positions")) { |
178 | - while (const Section::Value * v = compat_s->get_next_val()) |
179 | - m_compatibility_working_positions[v->get_name()] = split_string(v->get_string(), " "); |
180 | - } |
181 | } |
182 | |
183 | ProductionSite_Descr::~ProductionSite_Descr() |
184 | @@ -168,32 +158,6 @@ |
185 | } |
186 | |
187 | /** |
188 | - * If there is a compatibility action for the given program, return it. |
189 | - * |
190 | - * Otherwise, return an empty vector. |
191 | - */ |
192 | -const std::vector<std::string> & ProductionSite_Descr::compatibility_program |
193 | - (const std::string & progname) const |
194 | -{ |
195 | - static const std::vector<std::string> empty; |
196 | - Compatibility::const_iterator it = m_compatibility_programs.find(progname); |
197 | - if (it != m_compatibility_programs.end()) |
198 | - return it->second; |
199 | - return empty; |
200 | -} |
201 | - |
202 | -const std::vector<std::string> & ProductionSite_Descr::compatibility_working_positions |
203 | - (const std::string & workername) const |
204 | -{ |
205 | - static const std::vector<std::string> empty; |
206 | - Compatibility::const_iterator it = m_compatibility_working_positions.find(workername); |
207 | - if (it != m_compatibility_working_positions.end()) |
208 | - return it->second; |
209 | - return empty; |
210 | -} |
211 | - |
212 | - |
213 | -/** |
214 | * Create a new building of this type |
215 | */ |
216 | Building & ProductionSite_Descr::create_object() const { |
217 | |
218 | === modified file 'src/logic/productionsite.h' |
219 | --- src/logic/productionsite.h 2014-02-22 18:04:02 +0000 |
220 | +++ src/logic/productionsite.h 2014-03-13 21:39:01 +0000 |
221 | @@ -85,25 +85,12 @@ |
222 | typedef std::map<std::string, ProductionProgram *> Programs; |
223 | const Programs & programs() const {return m_programs;} |
224 | |
225 | - const std::vector<std::string> & compatibility_program(const std::string & progname) const; |
226 | - const std::vector<std::string> & compatibility_working_positions(const std::string & workername) const; |
227 | - |
228 | private: |
229 | BillOfMaterials m_working_positions; |
230 | BillOfMaterials m_inputs; |
231 | Output m_output_ware_types; |
232 | Output m_output_worker_types; |
233 | Programs m_programs; |
234 | - |
235 | - typedef std::map<std::string, std::vector<std::string> > Compatibility; |
236 | - |
237 | - /** |
238 | - * For savegame compatibility purposes, associate with old program |
239 | - * names a string describing actions that should be taken to preserve |
240 | - * compatibility. |
241 | - */ |
242 | - Compatibility m_compatibility_programs; |
243 | - Compatibility m_compatibility_working_positions; |
244 | }; |
245 | |
246 | class ProductionSite : public Building { |
247 | |
248 | === modified file 'src/logic/tribe.cc' |
249 | --- src/logic/tribe.cc 2014-03-04 13:24:58 +0000 |
250 | +++ src/logic/tribe.cc 2014-03-13 21:39:01 +0000 |
251 | @@ -93,14 +93,6 @@ |
252 | (*this, _name, _descname, path, prof, global_s)); |
253 | PARSE_MAP_OBJECT_TYPES_END; |
254 | |
255 | - // Read compatibility wares (removed wares existing in saved games from older builds |
256 | - if (Section * const section = root_conf.get_section("compatibility_wares")) { |
257 | - while (Section::Value const * const v = section->get_next_val()) { |
258 | - log("Compatibility ware \"%s\"=\"%s\" loaded.\n", v->get_name(), v->get_string()); |
259 | - m_compatibility_wares[v->get_name()] = v->get_string(); |
260 | - } |
261 | - } |
262 | - |
263 | PARSE_MAP_OBJECT_TYPES_BEGIN("immovable") |
264 | m_immovables.add |
265 | (new Immovable_Descr |
266 | @@ -325,11 +317,6 @@ |
267 | } catch (const std::exception & e) { |
268 | throw game_data_error("root conf: %s", e.what()); |
269 | } |
270 | - |
271 | - if (Section * compatibility_s = root_conf.get_section("compatibility_immovable")) { |
272 | - while (const Section::Value * v = compatibility_s->get_next_val()) |
273 | - m_compatibility_immovable[v->get_name()] = split_string(v->get_string(), " "); |
274 | - } |
275 | } catch (const _wexception & e) { |
276 | throw game_data_error("tribe %s: %s", tribename.c_str(), e.what()); |
277 | } |
278 | @@ -530,41 +517,21 @@ |
279 | if (Ware_Index const result = ware_index(warename)) |
280 | return result; |
281 | else |
282 | - // If this point is reached, the defined ware is neither defined as normal ware nor as a compatibility. |
283 | throw game_data_error("tribe %s does not define ware type \"%s\"", name().c_str(), warename.c_str()); |
284 | } |
285 | Ware_Index Tribe_Descr::safe_ware_index(const char * const warename) const { |
286 | if (Ware_Index const result = ware_index(warename)) |
287 | return result; |
288 | else |
289 | - // If this point is reached, the defined ware is neither defined as normal ware nor as a compatibility. |
290 | throw game_data_error("tribe %s does not define ware type \"%s\"", name().c_str(), warename); |
291 | } |
292 | |
293 | Ware_Index Tribe_Descr::ware_index(const std::string & warename) const { |
294 | Ware_Index const wi = m_wares.get_index(warename); |
295 | - if (!wi) { |
296 | - // try to find the ware in compatibility wares std::map |
297 | - std::map<std::string, std::string>::const_iterator it = m_compatibility_wares.find(warename); |
298 | - if (m_compatibility_wares.find(warename) != m_compatibility_wares.end()) { |
299 | - log ("ware %s found in compatibility map: %s!\n", warename.c_str(), it->second.c_str()); |
300 | - if (Ware_Index const result = m_wares.get_index(it->second)) |
301 | - return result; |
302 | - } |
303 | - } |
304 | return wi; |
305 | } |
306 | Ware_Index Tribe_Descr::ware_index(char const * const warename) const { |
307 | Ware_Index const wi = m_wares.get_index(warename); |
308 | - if (!wi) { |
309 | - // try to find the ware in compatibility wares std::map |
310 | - std::map<std::string, std::string>::const_iterator it = m_compatibility_wares.find(warename); |
311 | - if (m_compatibility_wares.find(warename) != m_compatibility_wares.end()) { |
312 | - log ("ware %s found in compatibility map: %s!\n", warename, it->second.c_str()); |
313 | - if (Ware_Index const result = m_wares.get_index(it->second)) |
314 | - return result; |
315 | - } |
316 | - } |
317 | return wi; |
318 | } |
319 | |
320 | @@ -605,19 +572,6 @@ |
321 | return result; |
322 | } |
323 | |
324 | -/** |
325 | - * If there is a savegame compatibility information string concerning the |
326 | - * given immovable name, return it. Otherwise, return an empty string. |
327 | - */ |
328 | -const std::vector<std::string> & Tribe_Descr::compatibility_immovable(const std::string & imm_name) const |
329 | -{ |
330 | - static const std::vector<std::string> empty; |
331 | - Compatibility::const_iterator it = m_compatibility_immovable.find(imm_name); |
332 | - if (it != m_compatibility_immovable.end()) |
333 | - return it->second; |
334 | - return empty; |
335 | -} |
336 | - |
337 | void Tribe_Descr::resize_ware_orders(size_t maxLength) { |
338 | bool need_resize = false; |
339 | |
340 | |
341 | === modified file 'src/logic/tribe.h' |
342 | --- src/logic/tribe.h 2014-02-22 18:04:02 +0000 |
343 | +++ src/logic/tribe.h 2014-03-13 21:39:01 +0000 |
344 | @@ -234,8 +234,6 @@ |
345 | |
346 | void resize_ware_orders(size_t maxLength); |
347 | |
348 | - const std::vector<std::string> & compatibility_immovable(const std::string & name) const; |
349 | - |
350 | private: |
351 | const std::string m_name; |
352 | const World & m_world; |
353 | @@ -260,15 +258,6 @@ |
354 | Initializations m_initializations; |
355 | |
356 | Military_Data m_military_data; |
357 | - |
358 | - typedef std::map<std::string, std::vector<std::string> > Compatibility; |
359 | - /** |
360 | - * For savegame compatibility, this maps immovable names to strings |
361 | - * describing the appropriate compatibility preserving action. |
362 | - */ |
363 | - Compatibility m_compatibility_immovable; |
364 | - std::map<std::string, std::string> m_compatibility_wares; |
365 | - |
366 | }; |
367 | |
368 | } |
369 | |
370 | === modified file 'src/logic/widelands_streamread.cc' |
371 | --- src/logic/widelands_streamread.cc 2013-07-26 20:19:36 +0000 |
372 | +++ src/logic/widelands_streamread.cc 2014-03-13 21:39:01 +0000 |
373 | @@ -27,9 +27,6 @@ |
374 | (const Tribe_Descr & tribe) |
375 | { |
376 | std::string name = CString(); |
377 | - const std::vector<std::string> & compat = tribe.compatibility_immovable(name); |
378 | - if (compat.size() == 2 && compat[0] == "replace") |
379 | - name = compat[1]; |
380 | int32_t const index = tribe.get_immovable_index(name); |
381 | if (index == -1) |
382 | throw tribe_immovable_nonexistent(tribe.name(), name); |
383 | |
384 | === modified file 'src/logic/worker.cc' |
385 | --- src/logic/worker.cc 2014-03-10 09:53:33 +0000 |
386 | +++ src/logic/worker.cc 2014-03-13 21:39:01 +0000 |
387 | @@ -1336,19 +1336,6 @@ |
388 | } |
389 | |
390 | /** |
391 | - * Change this worker into a different type. |
392 | - * |
393 | - * \warning Using this function is very dangerous. The only reason it exists |
394 | - * is to fix certain savegame compatibility issues. |
395 | - */ |
396 | -void Worker::flash(const std::string & newname) |
397 | -{ |
398 | - log("WARNING: Flashing worker of type %s to %s\n", name().c_str(), newname.c_str()); |
399 | - |
400 | - m_descr = tribe().get_worker_descr(tribe().safe_worker_index(newname)); |
401 | -} |
402 | - |
403 | -/** |
404 | * Set a fallback task. |
405 | */ |
406 | void Worker::init_auto_task(Game & game) { |
407 | @@ -3046,14 +3033,6 @@ |
408 | const BobProgramBase * Worker::Loader::get_program(const std::string & name) |
409 | { |
410 | Worker & worker = get<Worker>(); |
411 | - const std::string & compatibility = worker.descr().compatibility_program(name); |
412 | - |
413 | - if (compatibility == "fail") { |
414 | - if (upcast(Game, game, &egbase())) |
415 | - add_finish(boost::bind(&Worker::send_signal, &worker, boost::ref(*game), "fail")); |
416 | - return nullptr; |
417 | - } |
418 | - |
419 | return worker.descr().get_program(name); |
420 | } |
421 | |
422 | |
423 | === modified file 'src/logic/worker.h' |
424 | --- src/logic/worker.h 2014-02-22 18:04:02 +0000 |
425 | +++ src/logic/worker.h 2014-03-13 21:39:01 +0000 |
426 | @@ -146,8 +146,6 @@ |
427 | void create_needed_experience(Game &); |
428 | Ware_Index level (Game &); |
429 | |
430 | - void flash(const std::string & newname); |
431 | - |
432 | int32_t get_needed_experience() const { |
433 | return descr().get_level_experience(); |
434 | } |
435 | |
436 | === modified file 'src/logic/worker_descr.cc' |
437 | --- src/logic/worker_descr.cc 2014-02-22 18:04:02 +0000 |
438 | +++ src/logic/worker_descr.cc 2014-03-13 21:39:01 +0000 |
439 | @@ -131,12 +131,6 @@ |
440 | throw wexception("program %s: %s", program_name.c_str(), e.what()); |
441 | } |
442 | } |
443 | - |
444 | - // Read compatibility information |
445 | - if (Section * compat_s = prof.get_section("compatibility_program")) { |
446 | - while (const Section::Value * v = compat_s->get_next_val()) |
447 | - m_compatibility_programs[v->get_name()] = v->get_string(); |
448 | - } |
449 | } |
450 | |
451 | |
452 | @@ -174,20 +168,6 @@ |
453 | } |
454 | |
455 | /** |
456 | - * Get the compatibility information for the given program name. |
457 | - * |
458 | - * Returns an empty string if no compatibility information for this program is found. |
459 | - */ |
460 | -const std::string & Worker_Descr::compatibility_program(const std::string & programname) const |
461 | -{ |
462 | - static const std::string empty; |
463 | - std::map<std::string, std::string>::const_iterator it = m_compatibility_programs.find(programname); |
464 | - if (it != m_compatibility_programs.end()) |
465 | - return it->second; |
466 | - return empty; |
467 | -} |
468 | - |
469 | -/** |
470 | * Custom creation routing that accounts for the location. |
471 | */ |
472 | Worker & Worker_Descr::create |
473 | |
474 | === modified file 'src/logic/worker_descr.h' |
475 | --- src/logic/worker_descr.h 2014-02-22 18:04:02 +0000 |
476 | +++ src/logic/worker_descr.h 2014-03-13 21:39:01 +0000 |
477 | @@ -114,8 +114,6 @@ |
478 | typedef std::map<std::string, WorkerProgram *> Programs; |
479 | const Programs & programs() const {return m_programs;} |
480 | |
481 | - const std::string & compatibility_program(const std::string & programname) const; |
482 | - |
483 | protected: |
484 | |
485 | std::string m_helptext; ///< Short (tooltip-like) help text |
486 | @@ -139,14 +137,6 @@ |
487 | */ |
488 | Ware_Index m_becomes; |
489 | Programs m_programs; |
490 | - |
491 | - /** |
492 | - * Compatibility hints for loading save games of older versions. |
493 | - * |
494 | - * Maps program name to a string that is to be interpreted by the |
495 | - * game loading logic. |
496 | - */ |
497 | - std::map<std::string, std::string> m_compatibility_programs; |
498 | }; |
499 | |
500 | } |
501 | |
502 | === modified file 'src/map_io/widelands_map_buildingdata_data_packet.cc' |
503 | --- src/map_io/widelands_map_buildingdata_data_packet.cc 2014-03-05 20:20:37 +0000 |
504 | +++ src/map_io/widelands_map_buildingdata_data_packet.cc 2014-03-13 21:39:01 +0000 |
505 | @@ -926,49 +926,6 @@ |
506 | for (uint16_t i = nr_workers; i; --i) { |
507 | Worker * worker = &mol.get<Worker>(fr.Unsigned32()); |
508 | |
509 | - const std::vector<std::string> & compat = |
510 | - pr_descr.compatibility_working_positions(worker->descr().name()); |
511 | - if (!compat.empty()) { |
512 | - if (compat[0] == "flash") { |
513 | - if (compat.size() != 2) |
514 | - throw game_data_error |
515 | - ("working position '%s' compat usage: flash other-name", |
516 | - worker->descr().name().c_str()); |
517 | - |
518 | - worker->flash(compat[1]); |
519 | - } else if (compat[0] == "replace") { |
520 | - if (compat.size() != 2) |
521 | - throw game_data_error |
522 | - ("working position '%s' compat usage: replace other-name", |
523 | - worker->descr().name().c_str()); |
524 | - |
525 | - const Tribe_Descr & tribe = worker->tribe(); |
526 | - |
527 | - log |
528 | - ("COMPAT(%s): replace '%s' (%u) by '%s' in '%s' (%u)\n", |
529 | - tribe.name().c_str(), |
530 | - worker->descr().name().c_str(), worker->serial(), |
531 | - compat[1].c_str(), |
532 | - pr_descr.name().c_str(), productionsite.serial()); |
533 | - |
534 | - mol.schedule_destroy(*worker); |
535 | - |
536 | - const Worker_Descr & worker_descr = |
537 | - *tribe.get_worker_descr |
538 | - (tribe.safe_worker_index(compat[1])); |
539 | - worker = &worker_descr.create |
540 | - (game, |
541 | - productionsite.owner(), |
542 | - &productionsite, |
543 | - worker->get_position()); |
544 | - worker->start_task_buildingwork(game); |
545 | - mol.schedule_act(*worker); |
546 | - } else |
547 | - throw game_data_error |
548 | - ("unknown compat '%s' for working position '%s'", |
549 | - compat[0].c_str(), worker->descr().name().c_str()); |
550 | - } |
551 | - |
552 | // Find a working position that matches this worker. |
553 | const Worker_Descr & worker_descr = worker->descr(); |
554 | ProductionSite::Working_Position * wp = &wp_begin; |
555 | @@ -1035,20 +992,6 @@ |
556 | std::transform |
557 | (program_name.begin(), program_name.end(), program_name.begin(), |
558 | tolower); |
559 | - const std::vector<std::string> & compat = pr_descr.compatibility_program(program_name); |
560 | - if (!compat.empty()) { |
561 | - if (compat[0] == "replace") { |
562 | - if (compat.size() != 2) |
563 | - throw game_data_error |
564 | - ("Program '%s' compatibility: usage: replace other-name", |
565 | - program_name.c_str()); |
566 | - |
567 | - program_name = compat[1]; |
568 | - } else |
569 | - throw game_data_error |
570 | - ("Unknown compatibility code '%s' for program '%s'", |
571 | - compat[0].c_str(), program_name.c_str()); |
572 | - } |
573 | |
574 | productionsite.m_stack[i].program = |
575 | productionsite.descr().get_program(program_name); |
576 | |
577 | === modified file 'tribes/barbarians/battlearena/conf' |
578 | --- tribes/barbarians/battlearena/conf 2014-03-10 10:45:21 +0000 |
579 | +++ tribes/barbarians/battlearena/conf 2014-03-13 21:39:01 +0000 |
580 | @@ -19,9 +19,6 @@ |
581 | [working positions] |
582 | trainer=1 |
583 | |
584 | -[compatibility working positions] |
585 | -carrier=replace trainer |
586 | - |
587 | [inputs] |
588 | pittabread=10 |
589 | fish=6 |
590 | |
591 | === modified file 'tribes/barbarians/conf' |
592 | --- tribes/barbarians/conf 2014-03-10 09:15:02 +0000 |
593 | +++ tribes/barbarians/conf 2014-03-13 21:39:01 +0000 |
594 | @@ -29,13 +29,6 @@ |
595 | fps=5 |
596 | playercolor=true |
597 | |
598 | -[compatibility_immovable] |
599 | -# For compatibility with build15 and earlier |
600 | -flax0s=replace reed0s |
601 | -flax0t=replace reed0t |
602 | -flax0=replace reed0 |
603 | -flax1=replace reed1 |
604 | - |
605 | [immovable types] |
606 | ashes=_Ashes |
607 | destroyed_building=_Destroyed building |
608 | @@ -64,10 +57,6 @@ |
609 | deer=_Deer |
610 | wildboar=_Wild Boar |
611 | |
612 | -[compatibility_wares] |
613 | -# for compatibility with build15 and earlier |
614 | -flax=thatchreed |
615 | - |
616 | [ware types] |
617 | axe=_Ax |
618 | bakingtray=_Bread Paddle |
619 | |
620 | === modified file 'tribes/barbarians/ferner/conf' |
621 | --- tribes/barbarians/ferner/conf 2014-02-22 16:49:17 +0000 |
622 | +++ tribes/barbarians/ferner/conf 2014-03-13 21:39:01 +0000 |
623 | @@ -2,11 +2,6 @@ |
624 | program=plantreed |
625 | program=harvestreed |
626 | |
627 | -[compatibility_program] |
628 | -# For compatibility with build15 and earlier |
629 | -plantflax=fail |
630 | -harvestflax=fail |
631 | - |
632 | [buildcost] |
633 | carrier=1 |
634 | shovel=1 |
635 | |
636 | === modified file 'tribes/barbarians/fernery/conf' |
637 | --- tribes/barbarians/fernery/conf 2014-03-10 10:45:21 +0000 |
638 | +++ tribes/barbarians/fernery/conf 2014-03-13 21:39:01 +0000 |
639 | @@ -20,14 +20,6 @@ |
640 | harvest_reed=_Harvest reed |
641 | work=_Work |
642 | |
643 | -[compatibility_programs] |
644 | -# For compatibility with savegames from build15 and older |
645 | -plant_flax=replace plant_reed |
646 | -harvest_flax=replace harvest_reed |
647 | -# For compatibility with savegames from build13 and older |
648 | -plantflax=replace plant_reed |
649 | -harvestflax=replace harvest_reed |
650 | - |
651 | [plant_reed] |
652 | sleep=18000 #orig sleep=20000 but ferner animation was increased by 2sec |
653 | worker=plantreed |
654 | |
655 | === modified file 'tribes/barbarians/metalworks/conf' |
656 | --- tribes/barbarians/metalworks/conf 2014-03-03 20:59:04 +0000 |
657 | +++ tribes/barbarians/metalworks/conf 2014-03-13 21:39:01 +0000 |
658 | @@ -47,9 +47,6 @@ |
659 | produce_hunting_spear=_Produce hunting spear |
660 | work=_Work |
661 | |
662 | -[compatibility_programs] |
663 | -produce_axe=replace produce_felling_axe |
664 | - |
665 | [produce_felling_axe] |
666 | return=skipped unless economy needs felling_axe |
667 | consume=iron trunk |
668 | |
669 | === modified file 'tribes/empire/sawmill/conf' |
670 | --- tribes/empire/sawmill/conf 2013-07-23 13:40:00 +0000 |
671 | +++ tribes/empire/sawmill/conf 2014-03-13 21:39:01 +0000 |
672 | @@ -16,9 +16,6 @@ |
673 | [working positions] |
674 | carpenter=1 |
675 | |
676 | -[compatibility working positions] |
677 | -toolsmith=flash carpenter |
678 | - |
679 | [inputs] |
680 | trunk=8 |
681 |
Looked over the FIXMEs and the merge request in general. LGTM. Some comments on the FIXMEs
The first was the problem that name was a plain old c string (i.e. a pointer to an array of characters). Constructing a c++ std::string out of it gives you access to more utility methods. Generally speaking, const char* should not show up in our code - they are pretty legacy. I refactored the area around that code to use std::string, instead of const char *.
The second FIXME was a dirty hack that would fail a workers program if it was currently running a program that was removed from the engine. It did this to check for program_name=fail in the conf file, if this was found, a function was queued that would be executed as soon as loading was done and that would send the worker a fail signal. The worker would then go to its 'default action' which is usually running to a warehouse. This code is no longer necessary and it made a bunch of other methods unnecessary too. I removed them.
If you think the changes are fine, feel free to merge.