FieldDataInstaller.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #pragma once
  16. #include <vector>
  17. #include <string>
  18. #include <OgreMesh.h>
  19. #include <tinyxml.h>
  20. #include "data/VGearsFLevelFile.h"
  21. #include "DiskImage.h"
  22. #include "ScopedLgp.h"
  23. #include "SpawnPointDb.h"
  24. #include "ModelsAndAnimationsDb.h"
  25. #include "FieldTextWriter.h"
  26. #include "decompiler/field/FieldScriptFormatter.h"
  27. #include "decompiler/field/FieldDecompiler.h"
  28. #include "common/FinalFantasy7/FF7NameLookup.h"
  29. typedef std::vector<std::string> MapList;
  30. typedef std::map<u16, SpawnPointDb> FieldSpawnPointsMap;
  31. typedef std::map<u16, float> FieldScaleFactorMap;
  32. class BaseFF7FieldScriptFormatter : public FieldScriptFormatter{
  33. public:
  34. /**
  35. * Constructor.
  36. *
  37. * @param[in] field_name The field name.
  38. * @param[in] field_id_to_name_lookup Field name lookup table to use.
  39. * @param[in] spawn_points The list of spawn points.
  40. */
  41. BaseFF7FieldScriptFormatter(
  42. const std::string& field_name, const std::vector<std::string>& field_id_to_name_lookup,
  43. FieldSpawnPointsMap& spawn_points
  44. ) : field_name_(field_name), field_id_to_name_lookup_(field_id_to_name_lookup), spawn_points_(spawn_points)
  45. {}
  46. /**
  47. * Composes a spawn point name
  48. *
  49. * The name will have the format
  50. * {FIELD_NAME}_{ENTITY}_{FUNCTION_NAME}_addr_{ADDRESS}
  51. *
  52. * @param[in] map_id Unused.
  53. * @param[in] entity Entity name.
  54. * @param[in] function_name Name of the function.
  55. * @param[in] address @todo Understand and document.
  56. * @return The composed spawn point name.
  57. */
  58. virtual std::string GetSpawnPointName(
  59. unsigned int map_id, const std::string& entity, const std::string& function_name, unsigned int address
  60. ) override{
  61. return field_name_ + "_" + entity + "_" + function_name + "_addr_" + std::to_string(address);
  62. }
  63. /**
  64. * Retrieves a map name from it's ID.
  65. *
  66. * @param[in] map_id The map ID.
  67. * @return The map name.
  68. */
  69. virtual std::string GetMapName(unsigned int map_id) override{return field_id_to_name_lookup_[map_id];}
  70. /**
  71. * Retrieves a user friendly variable name.
  72. *
  73. * @param[in] bank Variable bank.
  74. * @param[in] addr Variable address.
  75. * @return Friendly name for the variable, or an empty string if it
  76. * doesn't have one assigned.
  77. */
  78. virtual std::string GetFriendlyVarName(unsigned int bank, unsigned int addr) override{
  79. return VGears::NameLookup::FieldScriptVarName(bank, addr);
  80. }
  81. /**
  82. * Retrieves a user friendly entity name.
  83. *
  84. * @param[in] entity Entity name.
  85. * @return Friendly name for the entity, or the current name if it
  86. * doesn't have one assigned.
  87. */
  88. virtual std::string GetFriendlyEntityName(const std::string& entity) override{
  89. return VGears::NameLookup::FieldScriptEntityName(entity);
  90. }
  91. /**
  92. * Retrieves a user friendly character name.
  93. *
  94. * @param[in] char_id Character ID.
  95. * @return Friendly name for the entity, or an empty string if it
  96. * doesn't have one assigned.
  97. */
  98. virtual std::string GetFriendlyCharName(int char_id) override{return VGears::NameLookup::CharName(char_id);}
  99. /**
  100. * Retrieves a user friendly function name.
  101. *
  102. * @param[in] entity The name of the entity the function belongs to.
  103. * @param[in] function_name Function name.
  104. * @return Friendly name for the function, or the current name if it
  105. * doesn't have one assigned.
  106. */
  107. virtual std::string GetFriendlyFunctionName(
  108. const std::string& entity, const std::string& function_name
  109. ) override{
  110. return VGears::NameLookup::FieldScriptFunctionName(field_name_, entity, function_name);
  111. }
  112. /**
  113. * Retrieves the header comment for a function in an entity.
  114. *
  115. * @param[in] entity The name of the entity the function belongs to.
  116. * @param[in] function_name Function name.
  117. * @return Friendly comment for the function, or an empty string if it
  118. * doesn't have one assigned.
  119. */
  120. virtual std::string GetFunctionComment(const std::string& entity, const std::string& function_name) override{
  121. return VGears::NameLookup::FieldScriptFunctionComment(field_name_, entity, function_name);
  122. }
  123. protected:
  124. /**
  125. * The field name.
  126. */
  127. std::string field_name_;
  128. /**
  129. * The list of spawn points.
  130. */
  131. FieldSpawnPointsMap& spawn_points_;
  132. /**
  133. * Look up table relatingfield IDs and names.
  134. */
  135. const std::vector<std::string>& field_id_to_name_lookup_;
  136. };
  137. /**
  138. * Handles the script gateway colection.
  139. */
  140. class FF7FieldScriptGatewayCollector : public BaseFF7FieldScriptFormatter{
  141. // TODO: Move declaration to a .h file.
  142. public:
  143. /**
  144. * Cosntructor.
  145. */
  146. FF7FieldScriptGatewayCollector(
  147. const std::string& field_name, const std::vector<std::string>& field_id_to_name_lookup,
  148. FieldSpawnPointsMap& spawn_points, size_t this_field_id
  149. ) : BaseFF7FieldScriptFormatter(field_name,field_id_to_name_lookup, spawn_points), field_id_(this_field_id)
  150. {}
  151. /**
  152. * Adds an spawn point.
  153. *
  154. * If the spawn is new, a new record will be added to the spawn point
  155. * database. If it was already there, update the record to add the
  156. * origin.
  157. *
  158. * @param[in] map_id The target map ID.
  159. * @param[in] entity The entity that acts as the spawn point.
  160. * @param[in] function_name The spawn function name.
  161. * @param[in] address @todo Understand and document.
  162. * @param[in] x X coordinate of the field target at which to spawn.
  163. * @param[in] y Y coordinate of the field target at which to spawn.
  164. * @param[in] z Z coordinate of the field target at which to spawn.
  165. * @param[in] angle Orientation at which to spawn.
  166. */
  167. virtual void AddSpawnPoint(
  168. unsigned int map_id, const std::string& entity, const std::string& function_name,
  169. unsigned int address, int x, int y, int z, int angle
  170. ) override {
  171. auto it = spawn_points_.find(map_id);
  172. VGears::TriggersFile::Gateway gw = {};
  173. gw.destination_field_id = map_id;
  174. gw.destination.x = x;
  175. gw.destination.y = y;
  176. gw.destination.z = z;
  177. gw.dir = angle;
  178. if (it != std::end(spawn_points_)){
  179. // Add to the list of gateways that link to destination_field_id.
  180. SpawnPointDb::Record rec;
  181. rec.from_script = true;
  182. rec.field_id = field_id_;
  183. rec.gateway = gw;
  184. rec.entity_name = entity;
  185. rec.script_function_name = function_name;
  186. rec.gateway_index_or_map_jump_address = address;
  187. it->second.gateways_to_this_field.push_back(rec);
  188. }
  189. else{
  190. // Create a new record for destination_field_id
  191. SpawnPointDb db;
  192. db.target_field_id = map_id;
  193. SpawnPointDb::Record rec;
  194. rec.from_script = true;
  195. rec.field_id = field_id_;
  196. rec.gateway = gw;
  197. rec.entity_name = entity;
  198. rec.script_function_name = function_name;
  199. rec.gateway_index_or_map_jump_address = address;
  200. db.gateways_to_this_field.push_back(rec);
  201. spawn_points_.insert(std::make_pair(db.target_field_id, db));
  202. }
  203. }
  204. private:
  205. /**
  206. * The field map ID.
  207. */
  208. size_t field_id_;
  209. };
  210. /**
  211. * Handles the formatting of field scripts.
  212. */
  213. class FF7FieldScriptFormatter : public BaseFF7FieldScriptFormatter{
  214. public:
  215. /**
  216. * Constructor.
  217. *
  218. * @param[in] field_name The field name.
  219. * @param[in] models The list of field models.
  220. * @param[in] field_id_to_name_lookup Field name lookup table to use.
  221. * @param[in] spawn_points The list of spawn points.
  222. */
  223. FF7FieldScriptFormatter(
  224. const std::string& field_name, const VGears::ModelListFilePtr& models,
  225. const std::vector<std::string>& field_id_to_name_lookup, FieldSpawnPointsMap& spawn_points
  226. ) : BaseFF7FieldScriptFormatter(field_name, field_id_to_name_lookup, spawn_points), model_loader_(models)
  227. {}
  228. // Names an animation, can't return empty
  229. /**
  230. * Retreieves an animation name from iths ID.
  231. *
  232. * @param[in] char_id ID of the character the animation belogs to.
  233. * @param[in] id Animation ID.
  234. * @return The animation name. If there is no name assigned, or it
  235. * can't be found, a string with the animation ID.
  236. */
  237. virtual std::string GetFriendlyAnimationName(int char_id, int id) override{
  238. // Get the animation file name, then look up the friendly name of
  239. // the "raw" animation.
  240. if (static_cast<unsigned int>(char_id) >= model_loader_->GetModels().size()){
  241. std::cerr << "FF7FieldScriptFormatter::AnimationName ERROR:"
  242. << "Char ID " << char_id << " out of bounds" << std::endl;
  243. return std::to_string(id);
  244. }
  245. const auto& model_info = model_loader_->GetModels().at(char_id);
  246. if (static_cast<unsigned int>(id) >= model_info.animations.size()){
  247. std::cerr << "FF7FieldScriptFormatter::AnimationName ERROR:" << "In field " << field_name_
  248. << " the model " << model_info.name << " animation with ID " << id << " is out of bounds ("
  249. << model_info.animations.size() << ")" << std::endl;
  250. return std::to_string(id);
  251. }
  252. const auto raw_name = model_info.animations.at(id).name;
  253. // Trim off ".yos" or whatever extension the model loader adds in.
  254. Ogre::String base_name;
  255. VGears::StringUtil::splitBase(raw_name, base_name);
  256. VGears::StringUtil::toLowerCase(base_name);
  257. return VGears::NameLookup::Animation(base_name);
  258. }
  259. /**
  260. * Retrieves the animation a model must play when its script doesn't set a default one.
  261. *
  262. * In the original game a model without a requested animation plays the first one of its
  263. * list.
  264. *
  265. * @param[in] char_id ID of the model, as given to the CHAR opcode.
  266. * @return Name of the first animation of the model. An empty string if the model already
  267. * has an animation called "Idle", or it has no animations.
  268. */
  269. virtual std::string GetDefaultAnimationName(int char_id) override{
  270. if (static_cast<unsigned int>(char_id) >= model_loader_->GetModels().size()) return "";
  271. const auto& animations = model_loader_->GetModels().at(char_id).animations;
  272. if (animations.empty()) return "";
  273. std::string first;
  274. for (size_t i = 0; i < animations.size(); ++ i){
  275. Ogre::String base_name;
  276. VGears::StringUtil::splitBase(animations[i].name, base_name);
  277. VGears::StringUtil::toLowerCase(base_name);
  278. const std::string friendly = VGears::NameLookup::Animation(base_name);
  279. if (friendly == "Idle") return "";
  280. if (i == 0) first = friendly;
  281. }
  282. return first;
  283. }
  284. /**
  285. * Retrieves the animation a model plays when it walks or runs on its own.
  286. *
  287. * @param[in] char_id ID of the model, as given to the CHAR opcode.
  288. * @param[in] index 1 for the walk animation, 2 for the run animation.
  289. * @return Name of the animation, or an empty string if the model hasn't got it.
  290. */
  291. virtual std::string GetMoveAnimationName(int char_id, int index) override{
  292. if (char_id < 0 || static_cast<unsigned int>(char_id) >= model_loader_->GetModels().size())
  293. return "";
  294. const auto& animations = model_loader_->GetModels().at(char_id).animations;
  295. if (static_cast<unsigned int>(index) >= animations.size()) return "";
  296. Ogre::String base_name;
  297. VGears::StringUtil::splitBase(animations[index].name, base_name);
  298. VGears::StringUtil::toLowerCase(base_name);
  299. return VGears::NameLookup::Animation(base_name);
  300. }
  301. private:
  302. /**
  303. * The field model loader.
  304. */
  305. const VGears::ModelListFilePtr& model_loader_;
  306. };
  307. class FieldDataInstaller{
  308. public:
  309. /**
  310. * Installer constructor
  311. *
  312. * @param[in] disk_image Disk image to extract the data from.
  313. * @param[in] output_dir Path to the directory to write generated data
  314. * to.
  315. */
  316. FieldDataInstaller(
  317. const DiskImage& disk_image, const std::string output_dir,
  318. std::function<void(std::string)> log_output_line
  319. );
  320. /**
  321. * Fills the converted field list with the fields already installed in the data directory.
  322. *
  323. * Used when the fields are not converted in this run but other steps (like the world map scripts) need them.
  324. */
  325. void LoadInstalledFields();
  326. /**
  327. * Installer destructor.
  328. */
  329. ~FieldDataInstaller();
  330. const MapList& GetMapList() const{return map_list_;}
  331. const FieldScaleFactorMap& GetFieldScaleFactors() const{return scale_factors_;}
  332. const MapList& GetConvertedMapList() const{return converted_map_list_;}
  333. /**
  334. * Initializer for {@see CollectionFieldSpawnAndScaleFactors}.
  335. *
  336. * Installation step 1.
  337. *
  338. * @param[in] res_mgr The application resource manager.
  339. * @return The total number of level files to process.
  340. */
  341. int CollectSpawnAndScaleFactorsInit(Ogre::ResourceGroupManager* res_mgr);
  342. /**
  343. * Reads spawn points and scale factors from flevel files.
  344. *
  345. * Installation step 2.
  346. *
  347. * @param[in] field_index Index of the field to collect from. Must be
  348. * less than the value returned by
  349. * {@see CollectSpawnAndScaleFactorsInit}.
  350. */
  351. void CollectSpawnAndScaleFactors(int field_index);
  352. /**
  353. * Writes the coordinates of the exits to the world map (scripts/worldmap/world_arrivals.lua).
  354. */
  355. void WriteWorldArrivals();
  356. /**
  357. * Converts FFVII PC fields to V-Gears format.
  358. *
  359. * @param[in] field_index Index of the field to collect from. Must be
  360. * less than the value returned by
  361. * {@see CollectSpawnAndScaleFactorsInit}.
  362. */
  363. void Convert(int field_index);
  364. /**
  365. * Initializer for {@see WriteMapsXmlIteration}.
  366. *
  367. * Installation step 3.
  368. *
  369. * @return The number of converted maps that need to be written.
  370. */
  371. int WriteInit();
  372. /**
  373. * Saves the game maps to XML files.
  374. *
  375. * Installation step 4.
  376. *
  377. * @param[in] field_index Index of the field to collect from. Must be
  378. * less than the value returned by {@see WriteInit}.
  379. */
  380. void Write(int field_index);
  381. /**
  382. * Cleans up after {@see WriteMapsXmlIteration}.
  383. *
  384. * Installation step 5.
  385. */
  386. void WriteEnd();
  387. /**
  388. * Initializer for {@see ConvertFieldModelsIteration}.
  389. *
  390. * Installation step 6.
  391. *
  392. * @return List of names of models to convert.
  393. */
  394. std::vector<std::string> ConvertModelsInit();
  395. /**
  396. * Converts the field models to V-Gears format.
  397. *
  398. * Installation step 7 and final.
  399. *
  400. * @param[in] model_name Name of the model to convert.
  401. */
  402. void ConvertModels(std::string model_name);
  403. /**
  404. * Memory banks that are temporary: every field starts with them set to zero.
  405. */
  406. static const std::vector<int> TEMPORARY_BANKS;
  407. /**
  408. * Retrieves the Lua code every field script starts with.
  409. *
  410. * It creates the entity container, and sets the temporary memory banks to zero. In the
  411. * original game a field can't see what the previous one left in them, but here the
  412. * banks live as long as the game, so scripts that wait for a bank to change would see
  413. * leftovers.
  414. *
  415. * @return Lua code to put at the beginning of a field script.
  416. */
  417. static std::string FieldScriptHeader();
  418. private:
  419. /**
  420. * Creates a gateway script.
  421. *
  422. * @param[in] gateway_entity_name Name of the gateway entity.
  423. * @param[in] target_map_name Name of the target map.
  424. * @param[in] source_spawn_point_name The spawn point name.
  425. * @return Gateway LUA script.
  426. */
  427. static std::string CreateGateWayScript(
  428. const std::string& gateway_entity_name, const std::string& target_map_name,
  429. const std::string& source_spawn_point_name
  430. );
  431. /**
  432. * Retrieves a field ID from a name.
  433. *
  434. * @param[in] name The name of the field.
  435. * @param[in] field_id_to_name_lookup Lookup table to use.
  436. * @return The field ID for the specified name.
  437. * @throws std::runtime_error If there is no ID for the field name.
  438. */
  439. static size_t GetFieldId(const std::string& name, const std::vector<std::string>& field_id_to_name_lookup);
  440. /**
  441. * Checks if a file is a field file.
  442. *
  443. * To verify it, it just checks that the extension is not '.tex', '.tut'
  444. * or '.siz' and that the name is not 'maplist'.
  445. *
  446. * @param[in] resource_name The name of the file to test.
  447. * @return False if the file is surely not a field file, true otherwise.
  448. */
  449. static bool IsAFieldFile(const Ogre::String& resource_name);
  450. /**
  451. * Checks if a map cause fatal crash bugs.
  452. *
  453. * It uses a hardcoded list of maps that are known to cause errors. This
  454. * can be removed when whatever is causing the crash(s) is fixed.
  455. *
  456. * @note: Even so, conversion of all models will fail with a bone index
  457. * out of bounds.
  458. * @param[in] resource_name The name of the map file to test.
  459. * @return True if the map will crash, false otherwise.
  460. */
  461. static bool WillCrash(const Ogre::String& resource_name);
  462. /**
  463. * Checks if a map is a test field.
  464. *
  465. * It uses a hardcoded list of maps that are known to be test maps.
  466. * Unused maps are considered to be test maps.
  467. *
  468. * @param[in] resource_name The name of the map file to test.
  469. * @return True if the map is a test map, false otherwise.
  470. */
  471. static bool IsTestField(const Ogre::String& resource_name);
  472. /**
  473. * Collects the scale factor from a map.
  474. *
  475. * @param[in] field The field to collect from.
  476. * @param[out] scale_factors The scale factor for the map will be set
  477. * here, in the appropiate map entry.
  478. * @param[in] field_id_to_name_lookup Lookup table to relate field IDs
  479. * and names.
  480. */
  481. static void CollectFieldScaleFactors(
  482. VGears::FLevelFilePtr& field, FieldScaleFactorMap& scale_factors,
  483. const std::vector<std::string>& field_id_to_name_lookup
  484. );
  485. /**
  486. * Collects the spawn point from a field.
  487. *
  488. * If a spawn is new, a new record will be added to the spawn point
  489. * database. If it was already there, update the record to add the
  490. * origin.
  491. *
  492. * @param[in] field The field to collect from.
  493. * @param[in] field_id_to_name_lookup Lookup table to relate field IDs
  494. * and names.
  495. * @param[out] spawn_points Spawn points will be added sequentially to
  496. * the end of this map.
  497. */
  498. static bool CollectSpawnPoints(
  499. VGears::FLevelFilePtr& field, const std::vector<std::string>& field_id_to_name_lookup,
  500. FieldSpawnPointsMap& spawn_points
  501. );
  502. /**
  503. * The scale factor for line point coordinates.
  504. *
  505. * When a LINE opcode is found in the game scripts, the line points X
  506. * and Y coordinates must be scaled down by this factor.
  507. */
  508. static float LINE_SCALE_FACTOR;
  509. /**
  510. * Path to the field models directory.
  511. */
  512. static std::string FIELD_MODELS_DIR;
  513. /**
  514. * Path to the field maps directory.
  515. */
  516. static std::string FIELD_MAPS_DIR;
  517. /**
  518. * Gateways to this map ID are considered to be inactive.
  519. */
  520. static int INACTIVE_GATEWAY_ID;
  521. /**
  522. * Exports a mesh to a file.
  523. *
  524. * The file will have the mesh name.
  525. *
  526. * @param[in] outdir Path to the directory where the file will be saved.
  527. * @param[in] mesh The mesh to export.
  528. */
  529. void ExportMesh(const std::string outdir, const Ogre::MeshPtr &mesh);
  530. /**
  531. * Reads the music track IDs from a specific field.
  532. *
  533. * @param[in] field The field to extract tracks from.
  534. * @return The list of tracks. It can be empty.
  535. */
  536. std::vector<int> ExtractMusicTrackIds(VGears::FLevelFilePtr& field);
  537. /**
  538. * Converts a FFVII PC field to a V-Gears field.
  539. *
  540. * @param[in] field The field map to convert.
  541. */
  542. void PcFieldToVGearsField(VGears::FLevelFilePtr& field);
  543. /**
  544. * Retrieves a field scale factor.
  545. *
  546. * @param[in] field_id The id (name) of the field.
  547. * @return The scale factor for the map.
  548. * @throws std::runtime_error If there is no ID for the field name.
  549. */
  550. float GetFieldScaleFactor(size_t field_id);
  551. /**
  552. * Creates a directory in the outputh path.
  553. *
  554. * @param[in] dir Path of the directory to create, relative to the
  555. * output path..
  556. * @throws std::runtime_error If the directory can't be created.
  557. */
  558. void CreateDir(const std::string& dir);
  559. /**
  560. * The path to the directory from which to read the PC game data.
  561. */
  562. DiskImage disk_image_;
  563. /**
  564. * The path to the directory where to save the V-Gears data.
  565. */
  566. std::string output_dir_;
  567. /**
  568. * Directory where the game data is installed (<install dir>/data/).
  569. */
  570. std::string data_dir_;
  571. /**
  572. * Helper variable to indicate internal progress of installation steps.
  573. */
  574. size_t conversion_step_;
  575. /**
  576. * Helper variable to indicate internal progress of installation steps.
  577. */
  578. size_t progress_step_num_elements_;
  579. /**
  580. * Iterator counter.
  581. */
  582. size_t iterator_counter_;
  583. /**
  584. * LGP archive with field data.
  585. */
  586. std::unique_ptr<ScopedLgp> fields_lgp_;
  587. /**
  588. * LGP archive with texture data.
  589. */
  590. std::unique_ptr<ScopedLgp> textures_lgp_;
  591. /**
  592. * LGP archive with field model data.
  593. */
  594. std::unique_ptr<ScopedLgp> field_models_lgp_;
  595. /**
  596. * List of flevel files.
  597. */
  598. Ogre::StringVectorPtr flevel_file_list_;
  599. /**
  600. * The list of maps.
  601. */
  602. std::vector<std::string> map_list_;
  603. std::vector<std::string> failed_fields_;
  604. /**
  605. * Map of the collected spawn points.
  606. */
  607. FieldSpawnPointsMap spawn_points_;
  608. /**
  609. * Map of th collected scale factors.
  610. */
  611. FieldScaleFactorMap scale_factors_;
  612. /**
  613. * ModelsAndAnimationsUsedByConvertedFields
  614. */
  615. ModelsAndAnimationsDb used_models_and_anims_;
  616. /**
  617. * List of converted maps.
  618. */
  619. MapList converted_map_list_;
  620. /**
  621. * Iterator for {@see converted_map_list}.
  622. */
  623. MapList::iterator converted_map_list_iterator_;
  624. /**
  625. * Field currently being processed.
  626. */
  627. VGears::FLevelFilePtr field_;
  628. /**
  629. * List of model files.
  630. */
  631. Ogre::StringVectorPtr field_model_file_list_;
  632. /**
  633. * An XML document.
  634. *
  635. * Internally used during some installation steps.
  636. */
  637. std::unique_ptr<TiXmlDocument> doc_;
  638. /**
  639. * An XML element.
  640. *
  641. * Internally used during some installation steps.
  642. */
  643. std::unique_ptr<TiXmlElement> element_;
  644. /**
  645. * Iterator for {@see used_models_and_anims_}.
  646. */
  647. ModelAnimationMap::iterator model_animation_map_iterator_;
  648. /**
  649. * Function used to print text to the log output, line by line.
  650. */
  651. std::function<void(std::string)> write_output_line_;
  652. /**
  653. * Function used to print set the current installation progress text.
  654. */
  655. std::function<void(std::string)> set_progress_label_;
  656. /**
  657. * Field text writer.
  658. */
  659. FieldTextWriter field_text_writer_;
  660. /**
  661. * Written materials.
  662. */
  663. std::vector<std::string> materials_;
  664. };