SavemapManager.h 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  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 <OgreSingleton.h>
  18. #include <OgreColourValue.h>
  19. #include "core/Savemap.h"
  20. class SavemapManager : public Ogre::Singleton<SavemapManager>{
  21. public:
  22. /**
  23. * The maximum number of save slots.
  24. */
  25. static int MAX_SAVE_SLOTS;
  26. /**
  27. * Constructor.
  28. */
  29. SavemapManager();
  30. /**
  31. * Destructor.
  32. */
  33. virtual ~SavemapManager();
  34. /**
  35. * Retrieves the current savemap.
  36. *
  37. * @return The current Savemap.
  38. */
  39. Savemap GetCurrentSavemap();
  40. /**
  41. * Retrieves a savemap saved in a slot.
  42. *
  43. * @param[in] slot Slot of the savemap to retrieve.
  44. * @return The savemap in the slot. NULL if there is no such savemap or an invalid slot is
  45. * supplied.
  46. */
  47. Savemap* GetSavemap(unsigned int slot);
  48. /**
  49. * Retrieves a list of the saved maps.
  50. */
  51. std::vector<Savemap*> GetSavemaps();
  52. /**
  53. * Copies the current savemap to a slot and writes the file.
  54. *
  55. * @param slot[in] Slot at which to save.
  56. * @param force[in] If false, it will check if the control data is the save (i.e. if its
  57. * trying to overwrite a savemap of the same playthrought), and if they do not match, it
  58. * will do nothing and return false. If true, it will not be checked.
  59. * @return True if the data was saved, false ifforce was false and control data strings did
  60. * not match, or if there was an I/O error (which will be logged).
  61. */
  62. bool Save(unsigned int slot, bool force);
  63. /**
  64. * Saves a savemap to a slot and writes the file.
  65. *
  66. * @param slot[in] Slot at which to save.
  67. * @param force[in] If false, it will check if the control data is the save (i.e. if its
  68. * trying to overwrite a savemap of the same playthrought), and if they do not match, it
  69. * will do nothing and return false. If true, it will not be checked.
  70. * @return True if the data was saved, false ifforce was false and control data strings did
  71. * not match, or if there was an I/O error (which will be logged).
  72. */
  73. bool Save(Savemap savemap, unsigned int slot, bool force);
  74. /**
  75. * Releases savemaps from memory.
  76. *
  77. * The content of the current savemap which are not yet saved to a slot will be lost.
  78. */
  79. void Release();
  80. /**
  81. * Pushes data to the current savemap memory banks.
  82. *
  83. * @param[in] bank The memory bank.
  84. * @param[in] address The address in the bank.
  85. * @param[in] value The value to save.
  86. */
  87. void SetData(const unsigned int bank, const unsigned int address, const int value);
  88. /**
  89. * Sets the control string of the current savemap.
  90. *
  91. * @param[in] control The control string.
  92. */
  93. void SetControlKey(const char* control);
  94. /**
  95. * Sets the window colours in the current savemap.
  96. *
  97. * @param[in] t_l_r Top-left corner, red component.
  98. * @param[in] t_l_r Top-left corner, green component.
  99. * @param[in] t_l_r Top-left corner, blue component.
  100. * @param[in] t_r_r Top-right corner, red component.
  101. * @param[in] t_r_r Top-right corner, green component.
  102. * @param[in] t_r_r Top-right corner, blue component.
  103. * @param[in] b_r_r Bottom-right corner, red component.
  104. * @param[in] b_r_r Bottom-right corner, green component.
  105. * @param[in] b_r_r Bottom-right corner, blue component.
  106. * @param[in] b_l_r Bottom-left corner, red component.
  107. * @param[in] b_l_r Bottom-left corner, green component.
  108. * @param[in] b_l_r Bottom-left corner, blue component.
  109. */
  110. void SetWindowColours(
  111. const unsigned int t_l_r, const unsigned int t_l_g, const unsigned int t_l_b,
  112. const unsigned int t_r_r, const unsigned int t_r_g, const unsigned int t_r_b,
  113. const unsigned int b_r_r, const unsigned int b_r_g, const unsigned int b_r_b,
  114. const unsigned int b_l_r, const unsigned int b_l_g, const unsigned int b_l_b
  115. );
  116. /**
  117. * Sets the money of the current savemap.
  118. *
  119. * @param[in] money The current money.
  120. */
  121. void SetMoney(const unsigned int money);
  122. /**
  123. * Sets the total playtime of the current savemap.
  124. *
  125. * @param[in] seconds The total playtime, in seconds.
  126. */
  127. void SetGameTime(const unsigned int seconds);
  128. /**
  129. * Sets the time of the curent timer in the default savemap.
  130. *
  131. * @param[in] seconds The current countdown timer time, in seconds.
  132. */
  133. void SetCountdownTime(const unsigned int seconds);
  134. /**
  135. * Marks a key item as owned or non-owned in the current savemap.
  136. *
  137. * @param[in] item Key item id.
  138. * @param[in] owned True to mark it as owned, false to mark is as non-owned.
  139. */
  140. void SetKeyItem(const unsigned int item, const bool owned);
  141. /**
  142. * Sets the current party in the current savemap.
  143. *
  144. * @param[in] member_1 The first party member ID. -1 to leave empty.
  145. * @param[in] member_2 The second party member ID. -1 to leave empty.
  146. * @param[in] member_3 The third party member ID. -1 to leave empty.
  147. */
  148. void SetParty(const int member_1, const int member_2, const int member_3);
  149. /**
  150. * Sets an item in a inventory slot in the current savemap.
  151. *
  152. * @param[in] slot Inventory slot.
  153. * @param[in] id Item ID.
  154. * @param[in] quantity Item quantity. Set to 0 to mark as no item in the specified slot.
  155. */
  156. void SetItem(const unsigned int slot, const unsigned int id, const unsigned int quantity);
  157. /**
  158. * Sets a materia in a materia inventory slot in the current savemap.
  159. *
  160. * For Enemy Skill materia, don't use this, use {@see SetESkillMateria}.
  161. *
  162. * @param[in] slot Materia inventory slot.
  163. * @param[in] id Materia ID. Set to -1 to mark it as an empty slot.
  164. * @param[in] ap Total AP of the materia.
  165. */
  166. void SetMateria(const unsigned int slot, const int id, const unsigned int ap);
  167. /**
  168. * Sets a skill as learned in an Enemy Skill materia inventory slot in the current savemap.
  169. *
  170. * Calling this will make the materia in the slot to be an Enemy Skill materia and set the
  171. * AP to 0. To delete it, call {@see SetMateria} with the same slot and id -1.
  172. *
  173. * @param[in] slot Materia inventory slot.
  174. * @param[in] skill Enemy Skill ID (sequential, from 0).
  175. * @param[in] learned TRue to mark as learned, false to mark as not learned.
  176. */
  177. void SetESkillMateria(const unsigned slot, const unsigned int skill, const bool learned);
  178. /**
  179. * Sets a materia in a materia inventory slot in the current savemap.
  180. *
  181. * For Enemy Skill materia, don't use this, use {@see SetEnemySkillMateriaStash}.
  182. *
  183. * @param[in] slot Materia inventory slot.
  184. * @param[in] id Materia ID. Set to -1 to mark it as an empty slot.
  185. * @param[in] ap Total AP of the materia.
  186. */
  187. void SetMateriaStash(const unsigned int slot, const int id, const unsigned int ap);
  188. /**
  189. * Sets a skill as learned in an Enemy Skill materia stash slot in the current savemap.
  190. *
  191. * Calling this will make the materia in the slot to be an Enemy Skill materia and set the
  192. * AP to 0. To delete it, call {@see SetMateriaStash} with the same slot and id -1.
  193. *
  194. * @param[in] slot Materia inventory slot.
  195. * @param[in] skill Enemy Skill ID (sequential, from 0)
  196. * @param[in] learned TRue to mark as learned, false to mark as not learned.
  197. */
  198. void SetESkillMateriaStash(
  199. const unsigned slot, const unsigned int skill, const bool learned
  200. );
  201. /**
  202. * Sets the current location in the current savemap.
  203. *
  204. * @param[in] x X coordinate.
  205. * @param[in] y Y coordinate.
  206. * @param[in] z Z coordinate. It's optional, set it to lower than 0 to ignore it.
  207. * @param[in] triangle Walkmesh triangle ID.
  208. * @param[in] angle Facing direction.
  209. * @param[in] field Field map ID, or empty for the world map.
  210. * @param[in] Name of the location to show in the save slot.
  211. */
  212. void SetLocation(
  213. const float x, const float y, const float z,
  214. const unsigned int triangle, const int angle, const char* field, const char* name
  215. );
  216. /**
  217. * Sets a setting value in the current savemap.
  218. *
  219. * @param[in] key Setting key.
  220. * @param[in] value Setting value.
  221. * @todo Does nothing, implement when settings are working.
  222. */
  223. void SetSetting(const unsigned int key, const unsigned int value);
  224. /**
  225. * Sets a character basic information in the current savemap.
  226. *
  227. * @param[in] id Character ID.
  228. * @param[in] char_id Character identifier.
  229. * @param[in] name Character name.
  230. * @param[in] enabled If enabled in the PHS.
  231. * @param[in] locked If locked in or out the current party.
  232. * @param[in] level Character level.
  233. * @param[in] kills Total kills.
  234. * @param[in] back_row If the character is in the back row.
  235. * @param[in] exp Total experience.
  236. * @param[in] exp_to_next Experience to reach next level.
  237. * @param[in] limit_level Currently selected limit level.
  238. * @param[in] limit_bar Current limit bar fill status
  239. * @param[in] weapon Equipped weapon ID.
  240. * @param[in] armor Equipped armor ID.
  241. * @param[in] accessory Equipped accessory ID. -1 if none equipped.
  242. */
  243. void SetCharacterInfo(
  244. const unsigned int id, const int char_id, const char* name,
  245. const bool enabled, const bool locked,
  246. const unsigned int level, const unsigned int kills,
  247. const bool back_row, const unsigned int exp, const unsigned int exp_to_next,
  248. const unsigned int limit_level, const unsigned int limit_bar,
  249. const unsigned int weapon, const unsigned int armor, const int accessory
  250. );
  251. /**
  252. * Sets a character stat values in the current savemap.
  253. *
  254. * @param[in] id Character ID.
  255. * @param[in] stat Stat ID. See {@see STAT}.
  256. * @param[in] base Base value of the stat.
  257. * @param[in] extra Extra value of the stat. For STR, VIT, MAG, SPR, DEX and LCK, it means
  258. * the increment by means of sources. For HP and MP, the current value.
  259. */
  260. void SetCharacterStat(
  261. const unsigned int id, const unsigned int stat,
  262. const unsigned int base, const unsigned int extra
  263. );
  264. /**
  265. * Sets a character limit learned status in the current savemap.
  266. *
  267. * @param[in] id Character ID.
  268. * @param[in] level Limit level.
  269. * @param[in] technique Limit level technique ID.
  270. * @param[in] learned TRue to mark as learned, false to mark as non-learned.
  271. * @param[in] uses Times the technique has been used.
  272. */
  273. void SetCharacterLimitLearned(
  274. const unsigned int id, const unsigned int level,
  275. const unsigned int technique, const bool learned, const unsigned int uses
  276. );
  277. /**
  278. * Sets a materia in a character weapon or armor slot in the current savemap.
  279. *
  280. * For Enemy Skill materia, don't use this, use {@see SetCharacterESkillMateria}.
  281. *
  282. * @param[in] id Character ID.
  283. * @param[in] weapon True to set the materia in the weapon, false to set it in the armor.
  284. * @param[in] slot Weapon or armor slot.
  285. * @param[in] materia Materia ID. Set to -1 to mark it as an empty slot.
  286. * @param[in] ap Total AP of the materia.
  287. */
  288. void SetCharacterMateria(
  289. const unsigned int id, const bool weapon, const unsigned int slot,
  290. const int materia, const unsigned int ap
  291. );
  292. /**
  293. * Sets a skill as learned in a character's Enemy Skill materia in the current savemap.
  294. *
  295. * Calling this will make the materia to be an Enemy Skill materia and set the AP to 0. To
  296. * delete it, call {@see SetCharacterMateria} with the same character ID, weapon/armor and
  297. * slot and id -1.
  298. *
  299. * @param[in] id Character ID.
  300. * @param[in] weapon True to set the materia in the weapon, false to set it in the armor.
  301. * @param[in] slot Weapon or armor slot.
  302. * @param[in] skill Enemy Skill ID (sequential, from 0).
  303. * @param[in] learned TRue to mark as learned, false to mark as not learned.
  304. */
  305. void SetCharacterESkillMateria(
  306. const unsigned int id, const bool weapon, const unsigned int slot,
  307. const unsigned int skill, const bool learned
  308. );
  309. /**
  310. * Adds or removes a status to a character in the current savemap.
  311. *
  312. * @param[in] id Character ID.
  313. * @param[in] status ID of the status.
  314. * @param[in] inflicted True to add the status, false to remove it.
  315. */
  316. void SetCharacterStatus(
  317. const unsigned int id, const unsigned int status, const bool inflicted
  318. );
  319. /**
  320. * Checks if a slot is empty.
  321. *
  322. * @return True if the slot is empty, or false if a game is saved there. If an invalid slot
  323. * is queried, it will always return true.
  324. */
  325. bool IsSlotEmpty(const unsigned int slot);
  326. /**
  327. * Retrieves the control key from a saved savemap.
  328. *
  329. * @param[in] slot The slot to read from.
  330. * @return The control key of the slot. If an invalid slot is specified, or if the slot is
  331. * empty, an empty string.
  332. */
  333. std::string GetSlotControlKey(const unsigned int slot);
  334. /**
  335. * Retrieves a colour component from a window corner from a saved savemap.
  336. *
  337. * @param[in] slot The slot to read from.
  338. * @param[in] corner The window corner. See {@see Savemap::Corner}.
  339. * @param[in] corner The color component to get. See {@see Savemap::Colour}.
  340. * @return The color component of the specified corner of windows. If an invalid slot is
  341. * specified, or if the slot is empty, or if an invalid corner or color are requested, 0.
  342. */
  343. unsigned int GetSlotWindowCornerColourComponent(
  344. const unsigned int slot, const unsigned int corner, const unsigned int comp
  345. );
  346. /**
  347. * Retrieves the money from a saved savemap.
  348. *
  349. * @param[in] slot The slot to read from.
  350. * @return The money of the slot. If an invalid slot is specified, or if the slot is
  351. * empty, 0.
  352. */
  353. unsigned int GetSlotMoney(const unsigned int slot);
  354. /**
  355. * Retrieves the total playtime from a saved savemap.
  356. *
  357. * @param[in] slot The slot to read from.
  358. * @return The total playtime, in seconds. If an invalid slot is specified, or if the slot
  359. * is empty, 0.
  360. */
  361. unsigned int GetSlotGameTime(const unsigned int slot);
  362. /**
  363. * Retrieves the time in the timer from a saved savemap.
  364. *
  365. * @param[in] slot The slot to read from.
  366. * @return The timer time, in seconds. If an invalid slot is specified, or if the slot
  367. * is empty, or if there is no timer saved, 0.
  368. */
  369. unsigned int GetSlotCountdownTime(const unsigned int slot);
  370. /**
  371. * Retrieves the ID of a party member from a saved savemap.
  372. *
  373. * @param[in] slot The slot to read from.
  374. * @param[in] pos Position in the party.
  375. * @return The ID of the character at the requested position. If an invalid slot is
  376. * specified, or if the slot is empty, or if an invalid position is passed, or if there is
  377. * no character at the requested position, -1.
  378. */
  379. int GetSlotPartyMember(const unsigned int slot, const unsigned int pos);
  380. /**
  381. * Retrieves the ID of an item in the inventory from a saved savemap.
  382. *
  383. * @param[in] slot The slot to read from.
  384. * @param[in] pos Position in the inventory.
  385. * @return The ID of the item at the requested inventory position. If an invalid slot is
  386. * specified, or if the slot is empty, or if an invalid position is passed, or if there is
  387. * no item at the requested position, 0.
  388. */
  389. unsigned int GetSlotItemAtPosId(const unsigned int slot, const unsigned int pos);
  390. /**
  391. * Retrieves the quantity of an item in the inventory from a saved savemap.
  392. *
  393. * @param[in] slot The slot to read from.
  394. * @param[in] pos Position in the inventory.
  395. * @return The quantity of the item at the requested inventory position. If an invalid slot
  396. * is specified, or if the slot is empty, or if an invalid position is passed, or if there
  397. * is no item at the requested position, 0.
  398. */
  399. unsigned int GetSlotItemAtPosQty(const unsigned int slot, const unsigned int pos);
  400. /**
  401. * Checks the status of a key item from a saved savemap.
  402. *
  403. * @param[in] slot The slot to read from.
  404. * @param[in] id Key item ID.
  405. * @return True if the key item is owned, false if not. If an invalid slot is specified,
  406. * or if the slot is empty, or if an invalid id is passed, false.
  407. */
  408. bool GetSlotKeyItem(const unsigned int slot, const unsigned int id);
  409. /**
  410. * Retrieves the ID of a materia in the inventory from a saved savemap.
  411. *
  412. * @param[in] slot The slot to read from.
  413. * @param[in] pos Position in the materia inventory.
  414. * @return The ID of the materia at the requested inventory position. If an invalid slot is
  415. * specified, or if the slot is empty, or if an invalid position is passed, or if there is
  416. * no materia at the requested position, -1.
  417. */
  418. int GetSlotMateriaAtPosId(const unsigned int slot, const unsigned int pos);
  419. /**
  420. * Retrieves the AP of a materia in the inventory from a saved savemap.
  421. *
  422. * @param[in] slot The slot to read from.
  423. * @param[in] pos Position in the materia inventory.
  424. * @return The AP of the materia at the requested inventory position. If an invalid slot
  425. * is specified, or if the slot is empty, or if an invalid position is passed, or if there
  426. * is no materia at the requested position, 0.
  427. */
  428. unsigned int GetSlotMateriaAtPosAp(const unsigned int slot, const unsigned int pos);
  429. /**
  430. * Checks if there is an Enemy Skill materia at a inventory position from a saved savemap.
  431. *
  432. * @param[in] slot The slot to read from.
  433. * @param[in] pos Position in the materia inventory.
  434. * @return True if the materia in the specified position is an Enemy Skill materia, false
  435. * if not. If an invalid slot is specified, or if the slot is empty, or if an invalid
  436. * position is passed, or if there is no materia at that position, false.
  437. */
  438. bool IsSlotMateriaAtPosESkill(const unsigned int slot, const unsigned int pos);
  439. /**
  440. * Checks if a a enemy skill is learned by a materia at a position from a saved savemap.
  441. *
  442. * @param[in] slot The slot to read from.
  443. * @param[in] pos Position in the materia inventory.
  444. * @param[in] skill Skill ID, starting from 0.
  445. * @return True if the materia in the specified position exists, is an Enemy Skill materia
  446. * and has learned the specified skill. False in any other case.
  447. */
  448. bool IsSlotMateriaAtPosESkillLearned(
  449. const unsigned int slot, const unsigned int pos, const unsigned int skill
  450. );
  451. /**
  452. * Retrieves the ID of a materia in the stash from a saved savemap.
  453. *
  454. * @param[in] slot The slot to read from.
  455. * @param[in] pos Position in the materia stash.
  456. * @return The ID of the materia at the requested stash position. If an invalid slot is
  457. * specified, or if the slot is empty, or if an invalid position is passed, or if there is
  458. * no materia at the requested position, -1.
  459. */
  460. int GetSlotStashAtPosId(const unsigned int slot, const unsigned int pos);
  461. /**
  462. * Retrieves the AP of a materia in the stash from a saved savemap.
  463. *
  464. * @param[in] slot The slot to read from.
  465. * @param[in] pos Position in the materia stash.
  466. * @return The AP of the materia at the requested stash position. If an invalid slot
  467. * is specified, or if the slot is empty, or if an invalid position is passed, or if there
  468. * is no materia at the requested position, 0.
  469. */
  470. unsigned int GetSlotStashAtPosAp(const unsigned int slot, const unsigned int pos);
  471. /**
  472. * Checks if there is an Enemy Skill materia at a stash position from a saved savemap.
  473. *
  474. * @param[in] slot The slot to read from.
  475. * @param[in] pos Position in the materia stash.
  476. * @return True if the materia in the specified position is an Enemy Skill materia, false
  477. * if not. If an invalid slot is specified, or if the slot is empty, or if an invalid
  478. * position is passed, or if there is no materia at that position, false.
  479. */
  480. bool IsSlotStashAtPosESkill(const unsigned int slot, const unsigned int pos);
  481. /**
  482. * Checks if a a enemy skill is learned by a mat. at a stash position from a saved savemap.
  483. *
  484. * @param[in] slot The slot to read from.
  485. * @param[in] pos Position in the materia stash.
  486. * @param[in] skill Skill ID, starting from 0.
  487. * @return True if the materia in the specified position exists, is an Enemy Skill materia
  488. * and has learned the specified skill. False in any other case.
  489. */
  490. bool IsSlotStashAtPosESkillLearned(
  491. const unsigned int slot, const unsigned int pos, const unsigned int skill
  492. );
  493. /**
  494. * Retrieves the X coordinate of the player from a saved savemap.
  495. *
  496. * @param[in] slot The slot to read from.
  497. * @return The X coordinate. If an invalid slot is specified, or if the slot is empty, 0.0.
  498. */
  499. float GetSlotLocationX(const unsigned int slot);
  500. /**
  501. * Retrieves the Y coordinate of the player from a saved savemap.
  502. *
  503. * @param[in] slot The slot to read from.
  504. * @return The Y coordinate. If an invalid slot is specified, or if the slot is empty, 0.0.
  505. */
  506. float GetSlotLocationY(const unsigned int slot);
  507. /**
  508. * Retrieves the Z coordinate of the player from a saved savemap.
  509. *
  510. * @param[in] slot The slot to read from.
  511. * @return The Z coordinate. If an invalid slot is specified, or if the slot is empty, or
  512. * if the coordinate can be ignored, lower than 0.
  513. */
  514. float GetSlotLocationZ(const unsigned int slot);
  515. /**
  516. * Retrieves the walkmesh triangle of the player from a saved savemap.
  517. *
  518. * @param[in] slot The slot to read from.
  519. * @return The triangle ID. If an invalid slot is specified, or if the slot is empty, 0.
  520. */
  521. unsigned int GetSlotLocationTriangle(const unsigned int slot);
  522. /**
  523. * Retrieves the facing angle of the player from a saved savemap.
  524. *
  525. * @param[in] slot The slot to read from.
  526. * @return The angle. If an invalid slot is specified, or if the slot is empty, 0.
  527. */
  528. int GetSlotLocationAngle(const unsigned int slot);
  529. /**
  530. * Retrieves the field ID from a saved savemap.
  531. *
  532. * @param[in] slot The slot to read from.
  533. * @return The field ID. If an invalid slot is specified, or if the slot is empty, or if the
  534. * savemap is saved in the worldmap, an empty string.
  535. */
  536. std::string GetSlotLocationField(const unsigned int slot);
  537. /**
  538. * Retrieves the location name from a saved savemap.
  539. *
  540. * @param[in] slot The slot to read from.
  541. * @return The location name to be displayed in the save slot. If an invalid slot is
  542. * specified, or if the slot is empty, or if the location name has not been saved, an empty
  543. * string.
  544. */
  545. std::string GetSlotLocationName(const unsigned int slot);
  546. /**
  547. * Retrieves a setting from a saved savemap.
  548. *
  549. * @param[in] slot The slot to read from.
  550. * @param[in] key Setting key.
  551. * @return The setting value.
  552. * @todo Implement and document properly.
  553. */
  554. int GetSlotSetting(const unsigned int slot, const unsigned int key);
  555. /**
  556. * Retrieves the char ID of a character from a saved savemap.
  557. *
  558. * @param[in] slot The slot to read from.
  559. * @param[in] id The character ID.
  560. * @return The char ID of the character. If an invalid slot is specified, or if the slot is
  561. * empty, or if an invalid id is passed, or if the character doesn't have a char ID, -1.
  562. */
  563. int GetSlotCharacterCharId(const unsigned int slot, const unsigned int id);
  564. /**
  565. * Retrieves the name of a character from a saved savemap.
  566. *
  567. * @param[in] slot The slot to read from.
  568. * @param[in] id The character ID.
  569. * @return The name of the character. If an invalid slot is specified, or if the slot is
  570. * empty, or if an invalid id is passed, an empty string.
  571. */
  572. std::string GetSlotCharacterName(const unsigned int slot, const unsigned int id);
  573. /**
  574. * Retrieves the level of a character from a saved savemap.
  575. *
  576. * @param[in] slot The slot to read from.
  577. * @param[in] id The character ID.
  578. * @return The level of the character. If an invalid slot is specified, or if the slot is
  579. * empty, or if an invalid id is passed, 1.
  580. */
  581. unsigned int GetSlotCharacterLevel(const unsigned int slot, const unsigned int id);
  582. /**
  583. * Retrieves the total kills of a character from a saved savemap.
  584. *
  585. * @param[in] slot The slot to read from.
  586. * @param[in] id The character ID.
  587. * @return The kills of the character. If an invalid slot is specified, or if the slot is
  588. * empty, or if an invalid id is passed, 0.
  589. */
  590. unsigned int GetSlotCharacterKills(const unsigned int slot, const unsigned int id);
  591. /**
  592. * Checks the enabled status of a character from a saved savemap.
  593. *
  594. * @param[in] slot The slot to read from.
  595. * @param[in] id The character ID.
  596. * @return True if the character is enabled, false if not. If an invalid slot is specified,
  597. * or if the slot is empty, or if an invalid id is passed, false.
  598. */
  599. bool IsSlotCharacterEnabled(const unsigned int slot, const unsigned int id);
  600. /**
  601. * Checks the lock status of a character from a saved savemap.
  602. *
  603. * @param[in] slot The slot to read from.
  604. * @param[in] id The character ID.
  605. * @return True if the character is enabled, false if not. If an invalid slot is specified,
  606. * or if the slot is empty, or if an invalid id is passed, false.
  607. */
  608. bool IsSlotCharacterLocked(const unsigned int slot, const unsigned int id);
  609. /**
  610. * Checks the row of a character from a saved savemap.
  611. *
  612. * @param[in] slot The slot to read from.
  613. * @param[in] id The character ID.
  614. * @return True if the character is in the back row, false if not. If an invalid slot is
  615. * specified, or if the slot is empty, or if an invalid id is passed, false.
  616. */
  617. bool IsSlotCharacterBackRow(const unsigned int slot, const unsigned int id);
  618. /**
  619. * Retrieves the total experience of a character from a saved savemap.
  620. *
  621. * @param[in] slot The slot to read from.
  622. * @param[in] id The character ID.
  623. * @return The experience of the character. If an invalid slot is specified, or if the slot
  624. * is empty, or if an invalid id is passed, 0.
  625. */
  626. unsigned int GetSlotCharacterExp(const unsigned int slot, const unsigned int id);
  627. /**
  628. * Retrieves the experience for next level of a character from a saved savemap.
  629. *
  630. * @param[in] slot The slot to read from.
  631. * @param[in] id The character ID.
  632. * @return The experience of the character. If an invalid slot is specified, or if the slot
  633. * is empty, or if an invalid id is passed, 0.
  634. */
  635. unsigned int GetSlotCharacterExpToNext(const unsigned int slot, const unsigned int id);
  636. /**
  637. * Retrieves the current limit level of a character from a saved savemap.
  638. *
  639. * @param[in] slot The slot to read from.
  640. * @param[in] id The character ID.
  641. * @return The limit level of the character. If an invalid slot is specified, or if the
  642. * slot is empty, or if an invalid id is passed, 0.
  643. */
  644. unsigned int GetSlotCharacterLimitLevel(const unsigned int slot, const unsigned int id);
  645. /**
  646. * Retrieves the current limit bar status level of a character from a saved savemap.
  647. *
  648. * @param[in] slot The slot to read from.
  649. * @param[in] id The character ID.
  650. * @return The limit bar status of the character. If an invalid slot is specified, or if
  651. * the slot is empty, or if an invalid id is passed, 0.
  652. */
  653. unsigned int GetSlotCharacterLimitBar(const unsigned int slot, const unsigned int id);
  654. /**
  655. * Retrieves the ID of the weapon of a character from a saved savemap.
  656. *
  657. * @param[in] slot The slot to read from.
  658. * @param[in] id The character ID.
  659. * @return The character's weapon ID. If an invalid slot is specified, or if the slot is
  660. * empty, or if an invalid id is passed, 0.
  661. */
  662. unsigned int GetSlotCharacterWeaponId(const unsigned int slot, const unsigned int id);
  663. /**
  664. * Retrieves the ID of the armor of a character from a saved savemap.
  665. *
  666. * @param[in] slot The slot to read from.
  667. * @param[in] id The character ID.
  668. * @return The character's armor ID. If an invalid slot is specified, or if the slot is
  669. * empty, or if an invalid id is passed, 0.
  670. */
  671. unsigned int GetSlotCharacterArmorId(const unsigned int slot, const unsigned int id);
  672. /**
  673. * Retrieves the ID of the accessory of a character from a saved savemap.
  674. *
  675. * @param[in] slot The slot to read from.
  676. * @param[in] id The character ID.
  677. * @return The character's accessory ID. If an invalid slot is specified, or if the slot is
  678. * empty, or if an invalid id is passed, or if the character has no accessory equipped, -1.
  679. */
  680. int GetSlotCharacterAccessoryId(const unsigned int slot, const unsigned int id);
  681. /**
  682. * Retrieves the base value of a stat of a character from a saved savemap.
  683. *
  684. * @param[in] slot The slot to read from.
  685. * @param[in] id The character ID.
  686. * @param[in] stat The stat ID (see {@see Savemap::STAT}).
  687. * @return The base value of the specified stat. If an invalid slot is specified, or if the
  688. * slot is empty, or if an invalid id or stat is passed, 0.
  689. */
  690. unsigned int GetSlotCharacterStatBase(
  691. const unsigned int slot, const unsigned int id, const unsigned int stat
  692. );
  693. /**
  694. * Retrieves the extra value of a stat of a character from a saved savemap.
  695. *
  696. * For HP and MP, the extra value means the current value. For any other stat, the bonus
  697. * gained by using sources.
  698. *
  699. * @param[in] slot The slot to read from.
  700. * @param[in] id The character ID.
  701. * @param[in] stat The stat ID (see {@see Savemap::STAT}).
  702. * @return The extra value of the specified stat. If an invalid slot is specified, or if
  703. * the slot is empty, or if an invalid id or stat is passed, 0.
  704. */
  705. unsigned int GetSlotCharacterStatExtra(
  706. const unsigned int slot, const unsigned int id, const unsigned int stat
  707. );
  708. /**
  709. * Retrieves the uses of a character's limit level from a saved savemap.
  710. *
  711. * @param[in] slot The slot to read from.
  712. * @param[in] id The character ID.
  713. * @param[in] level The limit level.
  714. * @return Number of uses of the techniques in the specified limit level. If an invalid
  715. * slot is specified, or if the slot is empty, or if an invalid id or limit level is
  716. * passed, 0.
  717. */
  718. unsigned int GetSlotCharacterLimitUses(
  719. const unsigned int slot, const unsigned int id, const unsigned int level
  720. );
  721. /**
  722. * Checks if a limit technique is learned by a character from a savemap.
  723. *
  724. * @param[in] slot The slot to read from.
  725. * @param[in] id The character ID.
  726. * @param[in] level The limit level.
  727. * @param[in] tech The technique position in the level.
  728. * @return True if the technique has been learned, false if not. If an invalid slot is
  729. * specified, or if the slot is empty, or if an invalid id, limit level or technique is
  730. * passed, false.
  731. */
  732. bool IsSlotCharacterLimitLearned(
  733. const unsigned int slot, const unsigned int id,
  734. const unsigned int level, const unsigned int tech
  735. );
  736. /**
  737. * Retrieves the ID of an equipped materia from a saved savemap.
  738. *
  739. * @param[in] slot The slot to read from.
  740. * @param[in] id The character ID.
  741. * @param[in] weapon If false, check materia equipped in the weapon. If false, check
  742. * materia equiped in the armor.
  743. * @param[in] pos Position in the equipment slots.
  744. * @return The ID of the equipped materia. If an invalid slot is specified, or if the slot
  745. * is empty, or if an invalid id or position is passed, or if there is no materia at the
  746. * requested position, -1.
  747. */
  748. int GetSlotCharacterMateriaId(
  749. const unsigned int slot, const unsigned int id, const bool weapon, const unsigned int pos
  750. );
  751. /**
  752. * Retrieves the AP of an equipped materia from a saved savemap.
  753. *
  754. * @param[in] slot The slot to read from.
  755. * @param[in] id The character ID.
  756. * @param[in] weapon If false, check materia equipped in the weapon. If false, check
  757. * materia equiped in the armor.
  758. * @param[in] pos Position in the equipment slots.
  759. * @return The AP of the equipped materia. If an invalid slot is specified, or if the slot
  760. * is empty, or if an invalid id or position is passed, or if there is no materia at the
  761. * requested position, 0.
  762. */
  763. unsigned int GetSlotCharacterMateriaAp(
  764. const unsigned int slot, const unsigned int id, const bool weapon, const unsigned int pos
  765. );
  766. /**
  767. * Checks if an equipped materia is Enemy Skill from a saved savemap.
  768. *
  769. * @param[in] slot The slot to read from.
  770. * @param[in] id The character ID.
  771. * @param[in] weapon If false, check materia equipped in the weapon. If false, check
  772. * materia equiped in the armor.
  773. * @param[in] pos Position in the equipment slots.
  774. * @return True if the materia in the specified position is an Enemy Skill materia, false
  775. * if not. If an invalid id or slot is specified, or if the slot is empty, or if an invalid
  776. * position is passed, or if there is no materia at that position, false.
  777. */
  778. bool IsSlotCharacterMateriaESkill(
  779. const unsigned int slot, const unsigned int id, const bool weapon, const unsigned int pos
  780. );
  781. /**
  782. * Checks if a a enemy skill is learned by a equipped materia from a saved savemap.
  783. *
  784. * @param[in] slot The slot to read from.
  785. * @param[in] id The character ID.
  786. * @param[in] weapon If false, check materia equipped in the weapon. If false, check
  787. * materia equiped in the armor.
  788. * @param[in] pos Position in the equipment slots.
  789. * @param[in] skill Skill ID, starting from 0.
  790. * @return True if the materia in the specified position exists, is an Enemy Skill materia
  791. * and has learned the specified skill. False in any other case.
  792. */
  793. bool IsSlotCharacterMateriaESkillLearned(
  794. const unsigned int slot, const unsigned int id, const bool weapon,
  795. const unsigned int pos, const unsigned int skill
  796. );
  797. /**
  798. * Retrieves the value of a bank address from a saved savemap.
  799. *
  800. * @param[in] slot The slot to read from.
  801. * @param[in] bank The bank ID.
  802. * @param[in] address The address in the bank.
  803. * @return The value. If an invalid slot is specified, or if the slot is empty, or if an
  804. * invalid bank or address level is passed, 0.
  805. */
  806. int GetSlotData(
  807. const unsigned int slot, const unsigned int bank, const unsigned int address
  808. );
  809. private:
  810. /**
  811. * Path for the save files.
  812. */
  813. static std::string SAVE_PATH;
  814. /**
  815. * Reads every saved savemap from it's file.
  816. */
  817. void ReadSavemaps();
  818. /**
  819. * The current savemap.
  820. */
  821. Savemap* current_savemap_;
  822. /**
  823. * List of saved savemaps.
  824. */
  825. std::vector<Savemap*> saved_savemaps_;
  826. /**
  827. * Indicates if the saved savemaps have been read from files.
  828. */
  829. bool savemaps_read_;
  830. };