SavemapHandler.h 39 KB

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