SavemapHandler.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  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. #include <iostream>
  16. #include <string>
  17. #include <vector>
  18. #include "core/SavemapHandler.h"
  19. #include "core/Logger.h"
  20. /**
  21. * Savemap handler singleton.
  22. */
  23. template<>SavemapHandler *Ogre::Singleton<SavemapHandler>::msSingleton = nullptr;
  24. int SavemapHandler::MAX_SAVE_SLOTS(15);
  25. std::string SavemapHandler::SAVE_PATH("save/");
  26. SavemapHandler::SavemapHandler(): current_savemap_(nullptr), savemaps_read_(false){}
  27. SavemapHandler::~SavemapHandler(){
  28. //TODO
  29. LOG_TRIVIAL("SavemapHandler destroyed.");
  30. }
  31. Savemap SavemapHandler::GetCurrentSavemap(){return *current_savemap_;}
  32. Savemap* SavemapHandler::GetSavemap(unsigned int slot){
  33. if (slot >= MAX_SAVE_SLOTS) return nullptr;
  34. if (!savemaps_read_) ReadSavemaps();
  35. return saved_savemaps_[slot];
  36. }
  37. bool SavemapHandler::Save(unsigned int slot, const bool force){
  38. if (current_savemap_ == nullptr) return false;
  39. if (slot >= MAX_SAVE_SLOTS) return false;
  40. if (!savemaps_read_) ReadSavemaps();
  41. if (
  42. force == false && saved_savemaps_[slot]->IsEmpty() == false
  43. && current_savemap_->GetControlKey() != saved_savemaps_[slot]->GetControlKey()
  44. ) return false;
  45. else{
  46. saved_savemaps_[slot] = current_savemap_;
  47. saved_savemaps_[slot]->Write(slot, SAVE_PATH + std::to_string(slot) + ".xml");
  48. return true;
  49. }
  50. }
  51. bool SavemapHandler::Save(Savemap savemap, unsigned int slot, bool force){
  52. if (slot >= MAX_SAVE_SLOTS) return false;
  53. if (!savemaps_read_) ReadSavemaps();
  54. if (
  55. force == false && saved_savemaps_[slot]->IsEmpty() == false
  56. && savemap.GetControlKey() != saved_savemaps_[slot]->GetControlKey()
  57. ) return false;
  58. else{
  59. *current_savemap_ = savemap;
  60. saved_savemaps_[slot] = current_savemap_;
  61. saved_savemaps_[slot]->Write(slot, SAVE_PATH + std::to_string(slot) + ".xml");
  62. return true;
  63. }
  64. }
  65. void SavemapHandler::Release(){
  66. current_savemap_ = nullptr;
  67. saved_savemaps_.clear();
  68. savemaps_read_ = false;
  69. }
  70. void SavemapHandler::ReadSavemaps(){
  71. saved_savemaps_.clear();
  72. for (int i = 0; i < MAX_SAVE_SLOTS; i ++){
  73. Savemap* savemap = new Savemap();
  74. savemap->Read(SAVE_PATH + std::to_string(i) + ".xml");
  75. saved_savemaps_.push_back(savemap);
  76. }
  77. savemaps_read_ = true;
  78. }
  79. void SavemapHandler::SetData(const unsigned int bank, const unsigned int address, const int value){
  80. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  81. current_savemap_->SetData(bank, address, value);
  82. }
  83. void SavemapHandler::SetControlKey(const char* control){
  84. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  85. current_savemap_->SetControlKey(std::string(control));
  86. }
  87. void SavemapHandler::SetWindowColours(
  88. const unsigned int t_l_r, const unsigned int t_l_g, const unsigned int t_l_b,
  89. const unsigned int t_r_r, const unsigned int t_r_g, const unsigned int t_r_b,
  90. const unsigned int b_r_r, const unsigned int b_r_g, const unsigned int b_r_b,
  91. const unsigned int b_l_r, const unsigned int b_l_g, const unsigned int b_l_b
  92. ){
  93. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  94. current_savemap_->SetWindowColours(
  95. t_l_r, t_l_g, t_l_b, t_r_r, t_r_g, t_r_b, b_r_r, b_r_g, b_r_b, b_l_r, b_l_g, b_l_b
  96. );
  97. }
  98. void SavemapHandler::SetMoney(const unsigned int money){
  99. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  100. current_savemap_->SetMoney(money);
  101. }
  102. void SavemapHandler::SetGameTime(const unsigned int seconds){
  103. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  104. current_savemap_->SetGameTime(seconds);
  105. }
  106. void SavemapHandler::SetCountdownTime(const unsigned int seconds){
  107. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  108. current_savemap_->SetCountdownTime(seconds);
  109. }
  110. void SavemapHandler::SetKeyItem(const unsigned int item, const bool owned){
  111. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  112. current_savemap_->SetKeyItem(item, owned);
  113. }
  114. void SavemapHandler::SetParty(const int member_1, const int member_2, const int member_3){
  115. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  116. current_savemap_->SetParty(member_1, member_2, member_3);
  117. }
  118. void SavemapHandler::SetItem(
  119. const unsigned int slot, const unsigned int id, const unsigned int quantity
  120. ){
  121. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  122. current_savemap_->SetItem(slot, id, quantity);
  123. }
  124. void SavemapHandler::SetMateria(const unsigned int slot, const int id, const unsigned int ap){
  125. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  126. current_savemap_->SetMateria(slot, id, ap);
  127. }
  128. void SavemapHandler::SetESkillMateria(
  129. const unsigned slot, const unsigned int skill, const bool learned
  130. ){
  131. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  132. current_savemap_->SetESkillMateria(slot, skill, learned);
  133. }
  134. void SavemapHandler::SetMateriaStash(const unsigned int slot, const int id, const unsigned int ap){
  135. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  136. current_savemap_->SetMateriaStash(slot, id, ap);
  137. }
  138. void SavemapHandler::SetESkillMateriaStash(
  139. const unsigned slot, const unsigned int skill, const bool learned
  140. ){
  141. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  142. current_savemap_->SetESkillMateriaStash(slot, skill, learned);
  143. }
  144. void SavemapHandler::SetLocation(
  145. const float x, const float y, const float z,
  146. const unsigned int triangle, const int angle, const char* field, const char* name
  147. ){
  148. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  149. current_savemap_->SetLocation(x, y, z, triangle, angle, std::string(field), std::string(name));
  150. }
  151. void SavemapHandler::SetSetting(const char* key, const int value){
  152. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  153. current_savemap_->SetSetting(std::string(key), value);
  154. }
  155. bool SavemapHandler::IsSlotSettingSet(const unsigned int slot, const char* key){
  156. if (slot >= MAX_SAVE_SLOTS) return false;
  157. if (savemaps_read_ == false) ReadSavemaps();
  158. return saved_savemaps_[slot]->HasSetting(std::string(key));
  159. }
  160. int SavemapHandler::GetSlotSetting(const unsigned int slot, const char* key){
  161. if (slot >= MAX_SAVE_SLOTS) return 0;
  162. if (savemaps_read_ == false) ReadSavemaps();
  163. return saved_savemaps_[slot]->GetSetting(std::string(key));
  164. }
  165. void SavemapHandler::SetCharacterInfo(
  166. const unsigned int id, const int char_id, const char* name,
  167. const bool enabled, const bool locked,
  168. const unsigned int level, const unsigned int kills,
  169. const bool back_row, const unsigned int exp, const unsigned int exp_to_next,
  170. const unsigned int limit_level, const unsigned int limit_bar,
  171. const unsigned int weapon, const unsigned int armor, const int accessory
  172. ){
  173. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  174. current_savemap_->SetCharacterInfo(
  175. id, char_id, std::string(name), enabled, locked, level, kills, back_row, exp, exp_to_next,
  176. limit_level, limit_bar, weapon, armor, accessory
  177. );
  178. }
  179. void SavemapHandler::SetCharacterStat(
  180. const unsigned int id, const unsigned int stat, const unsigned int base, const unsigned int extra
  181. ){
  182. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  183. current_savemap_->SetCharacterStat(id, stat, base, extra);
  184. }
  185. void SavemapHandler::SetCharacterLimitLearned(
  186. const unsigned int id, const unsigned int level,
  187. const unsigned int technique, const bool learned, const unsigned int uses
  188. ){
  189. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  190. current_savemap_->SetCharacterLimitLearned(id, level, technique, learned, uses);
  191. }
  192. void SavemapHandler::SetCharacterMateria(
  193. const unsigned int id, const bool weapon, const unsigned int slot,
  194. const int materia, const unsigned int ap
  195. ){
  196. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  197. current_savemap_->SetCharacterMateria(id, weapon, slot, materia, ap);
  198. }
  199. void SavemapHandler::SetCharacterESkillMateria(
  200. const unsigned int id, const bool weapon, const unsigned int slot,
  201. const unsigned int skill, const bool learned
  202. ){
  203. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  204. current_savemap_->SetCharacterESkillMateria(id, weapon, slot, skill, learned);
  205. }
  206. void SavemapHandler::SetCharacterStatus(
  207. const unsigned int id, const unsigned int status, const bool inflicted
  208. ){
  209. if (current_savemap_ == nullptr) current_savemap_ = new Savemap();
  210. current_savemap_->SetCharacterStatus(id, status, inflicted);
  211. }
  212. bool SavemapHandler::IsSlotEmpty(const unsigned int slot){
  213. if (slot >= MAX_SAVE_SLOTS) return true;
  214. if (savemaps_read_ == false) ReadSavemaps();
  215. return saved_savemaps_[slot]->IsEmpty();
  216. }
  217. std::string SavemapHandler::GetSlotControlKey(const unsigned int slot){
  218. if (slot >= MAX_SAVE_SLOTS) return std::string("");
  219. if (savemaps_read_ == false) ReadSavemaps();
  220. return saved_savemaps_[slot]->GetControlKey();
  221. }
  222. unsigned int SavemapHandler::GetSlotWindowCornerColourComponent(
  223. const unsigned int slot, const unsigned int corner, const unsigned int comp
  224. ){
  225. if (slot >= MAX_SAVE_SLOTS) return 0;
  226. if (savemaps_read_ == false) ReadSavemaps();
  227. return saved_savemaps_[slot]->GetWindowCornerColourComponent(corner, comp);
  228. }
  229. unsigned int SavemapHandler::GetSlotMoney(const unsigned int slot){
  230. if (slot >= MAX_SAVE_SLOTS) return 0;
  231. if (savemaps_read_ == false) ReadSavemaps();
  232. return saved_savemaps_[slot]->GetMoney();
  233. }
  234. unsigned int SavemapHandler::GetSlotGameTime(const unsigned int slot){
  235. if (slot >= MAX_SAVE_SLOTS) return 0;
  236. if (savemaps_read_ == false) ReadSavemaps();
  237. return saved_savemaps_[slot]->GetGameTime();
  238. }
  239. unsigned int SavemapHandler::GetSlotCountdownTime(const unsigned int slot){
  240. if (slot >= MAX_SAVE_SLOTS) return 0;
  241. if (savemaps_read_ == false) ReadSavemaps();
  242. return saved_savemaps_[slot]->GetCountdownTime();
  243. }
  244. int SavemapHandler::GetSlotPartyMember(const unsigned int slot, const unsigned int pos){
  245. if (slot >= MAX_SAVE_SLOTS) return -1;
  246. if (savemaps_read_ == false) ReadSavemaps();
  247. return saved_savemaps_[slot]->GetPartyMember(pos);
  248. }
  249. unsigned int SavemapHandler::GetSlotItemAtPosId(const unsigned int slot, const unsigned int pos){
  250. if (slot >= MAX_SAVE_SLOTS) return 0;
  251. if (savemaps_read_ == false) ReadSavemaps();
  252. return saved_savemaps_[slot]->GetItemAtPosId(pos);
  253. }
  254. unsigned int SavemapHandler::GetSlotItemAtPosQty(const unsigned int slot, const unsigned int pos){
  255. if (slot >= MAX_SAVE_SLOTS) return 0;
  256. if (savemaps_read_ == false) ReadSavemaps();
  257. return saved_savemaps_[slot]->GetItemAtPosQty(pos);
  258. }
  259. bool SavemapHandler::GetSlotKeyItem(const unsigned int slot, const unsigned int id){
  260. if (slot >= MAX_SAVE_SLOTS) return false;
  261. if (savemaps_read_ == false) ReadSavemaps();
  262. return saved_savemaps_[slot]->GetKeyItem(id);
  263. }
  264. int SavemapHandler::GetSlotMateriaAtPosId(const unsigned int slot, const unsigned int pos){
  265. if (slot >= MAX_SAVE_SLOTS) return -1;
  266. if (savemaps_read_ == false) ReadSavemaps();
  267. return saved_savemaps_[slot]->GetMateriaAtPosId(pos);
  268. }
  269. unsigned int SavemapHandler::GetSlotMateriaAtPosAp(const unsigned int slot, const unsigned int pos){
  270. if (slot >= MAX_SAVE_SLOTS) return 0;
  271. if (savemaps_read_ == false) ReadSavemaps();
  272. return saved_savemaps_[slot]->GetMateriaAtPosAp(pos);
  273. }
  274. bool SavemapHandler::IsSlotMateriaAtPosESkill(const unsigned int slot, const unsigned int pos){
  275. if (slot >= MAX_SAVE_SLOTS) return 0;
  276. if (savemaps_read_ == false) ReadSavemaps();
  277. return saved_savemaps_[slot]->IsMateriaAtPosESkill(pos);
  278. }
  279. bool SavemapHandler::IsSlotMateriaAtPosESkillLearned(
  280. const unsigned int slot, const unsigned int pos, const unsigned int skill
  281. ){
  282. if (slot >= MAX_SAVE_SLOTS) return false;
  283. if (savemaps_read_ == false) ReadSavemaps();
  284. return saved_savemaps_[slot]->IsMateriaAtPosESkillLearned(pos, skill);
  285. }
  286. int SavemapHandler::GetSlotStashAtPosId(const unsigned int slot, const unsigned int pos){
  287. if (slot >= MAX_SAVE_SLOTS) return -1;
  288. if (savemaps_read_ == false) ReadSavemaps();
  289. return saved_savemaps_[slot]->GetStashAtPosId(pos);
  290. }
  291. unsigned int SavemapHandler::GetSlotStashAtPosAp(const unsigned int slot, const unsigned int pos){
  292. if (slot >= MAX_SAVE_SLOTS) return 0;
  293. if (savemaps_read_ == false) ReadSavemaps();
  294. return saved_savemaps_[slot]->GetStashAtPosAp(pos);
  295. }
  296. bool SavemapHandler::IsSlotStashAtPosESkill(const unsigned int slot, const unsigned int pos){
  297. if (slot >= MAX_SAVE_SLOTS) return false;
  298. if (savemaps_read_ == false) ReadSavemaps();
  299. return saved_savemaps_[slot]->IsStashAtPosESkill(pos);
  300. }
  301. bool SavemapHandler::IsSlotStashAtPosESkillLearned(
  302. const unsigned int slot, const unsigned int pos, const unsigned int skill
  303. ){
  304. if (slot >= MAX_SAVE_SLOTS) return false;
  305. if (savemaps_read_ == false) ReadSavemaps();
  306. return saved_savemaps_[slot]->IsStashAtPosESkillLearned(pos, skill);
  307. }
  308. float SavemapHandler::GetSlotLocationX(const unsigned int slot){
  309. if (slot >= MAX_SAVE_SLOTS) return 0.0f;
  310. if (savemaps_read_ == false) ReadSavemaps();
  311. return saved_savemaps_[slot]->GetLocationX();
  312. }
  313. float SavemapHandler::GetSlotLocationY(const unsigned int slot){
  314. if (slot >= MAX_SAVE_SLOTS) return 0.0f;
  315. if (savemaps_read_ == false) ReadSavemaps();
  316. return saved_savemaps_[slot]->GetLocationY();
  317. }
  318. float SavemapHandler::GetSlotLocationZ(const unsigned int slot){
  319. if (slot >= MAX_SAVE_SLOTS) return -1.0f;
  320. if (savemaps_read_ == false) ReadSavemaps();
  321. return saved_savemaps_[slot]->GetLocationZ();
  322. }
  323. unsigned int SavemapHandler::GetSlotLocationTriangle(const unsigned int slot){
  324. if (slot >= MAX_SAVE_SLOTS) return 0;
  325. if (savemaps_read_ == false) ReadSavemaps();
  326. return saved_savemaps_[slot]->GetLocationTriangle();
  327. }
  328. int SavemapHandler::GetSlotLocationAngle(const unsigned int slot){
  329. if (slot >= MAX_SAVE_SLOTS) return 0;
  330. if (savemaps_read_ == false) ReadSavemaps();
  331. return saved_savemaps_[slot]->GetLocationAngle();
  332. }
  333. std::string SavemapHandler::GetSlotLocationField(const unsigned int slot){
  334. if (slot >= MAX_SAVE_SLOTS) return "";
  335. if (savemaps_read_ == false) ReadSavemaps();
  336. return saved_savemaps_[slot]->GetLocationField();
  337. }
  338. std::string SavemapHandler::GetSlotLocationName(const unsigned int slot){
  339. if (slot >= MAX_SAVE_SLOTS) return "";
  340. if (savemaps_read_ == false) ReadSavemaps();
  341. return saved_savemaps_[slot]->GetLocationName();
  342. }
  343. int SavemapHandler::GetSlotCharacterCharId(const unsigned int slot, const unsigned int id){
  344. if (slot >= MAX_SAVE_SLOTS) return 0;
  345. if (savemaps_read_ == false) ReadSavemaps();
  346. return saved_savemaps_[slot]->GetCharacterCharId(id);
  347. }
  348. std::string SavemapHandler::GetSlotCharacterName(const unsigned int slot, const unsigned int id){
  349. if (slot >= MAX_SAVE_SLOTS) return "";
  350. if (savemaps_read_ == false) ReadSavemaps();
  351. return saved_savemaps_[slot]->GetCharacterName(id);
  352. }
  353. unsigned int SavemapHandler::GetSlotCharacterLevel(const unsigned int slot, const unsigned int id){
  354. if (slot >= MAX_SAVE_SLOTS) return 1;
  355. if (savemaps_read_ == false) ReadSavemaps();
  356. return saved_savemaps_[slot]->GetCharacterLevel(id);
  357. }
  358. unsigned int SavemapHandler::GetSlotCharacterKills(const unsigned int slot, const unsigned int id){
  359. if (slot >= MAX_SAVE_SLOTS) return 0;
  360. if (savemaps_read_ == false) ReadSavemaps();
  361. return saved_savemaps_[slot]->GetCharacterKills(id);
  362. }
  363. bool SavemapHandler::IsSlotCharacterEnabled(const unsigned int slot, const unsigned int id){
  364. if (slot >= MAX_SAVE_SLOTS) return false;
  365. if (savemaps_read_ == false) ReadSavemaps();
  366. return saved_savemaps_[slot]->IsCharacterEnabled(id);
  367. }
  368. bool SavemapHandler::IsSlotCharacterLocked(const unsigned int slot, const unsigned int id){
  369. if (slot >= MAX_SAVE_SLOTS) return false;
  370. if (savemaps_read_ == false) ReadSavemaps();
  371. return saved_savemaps_[slot]->IsCharacterLocked(id);
  372. }
  373. bool SavemapHandler::IsSlotCharacterBackRow(const unsigned int slot, const unsigned int id){
  374. if (slot >= MAX_SAVE_SLOTS) return false;
  375. if (savemaps_read_ == false) ReadSavemaps();
  376. return saved_savemaps_[slot]->IsCharacterBackRow(id);
  377. }
  378. unsigned int SavemapHandler::GetSlotCharacterExp(const unsigned int slot, const unsigned int id){
  379. if (slot >= MAX_SAVE_SLOTS) return 0;
  380. if (savemaps_read_ == false) ReadSavemaps();
  381. return saved_savemaps_[slot]->GetCharacterExp(id);
  382. }
  383. unsigned int SavemapHandler::GetSlotCharacterExpToNext(
  384. const unsigned int slot, const unsigned int id
  385. ){
  386. if (slot >= MAX_SAVE_SLOTS) return 0;
  387. if (savemaps_read_ == false) ReadSavemaps();
  388. return saved_savemaps_[slot]->GetCharacterExpToNext(id);
  389. }
  390. unsigned int SavemapHandler::GetSlotCharacterLimitLevel(
  391. const unsigned int slot, const unsigned int id
  392. ){
  393. if (slot >= MAX_SAVE_SLOTS) return 0;
  394. if (savemaps_read_ == false) ReadSavemaps();
  395. return saved_savemaps_[slot]->GetCharacterLimitLevel(id);
  396. }
  397. unsigned int SavemapHandler::GetSlotCharacterLimitBar(
  398. const unsigned int slot, const unsigned int id
  399. ){
  400. if (slot >= MAX_SAVE_SLOTS) return 0;
  401. if (savemaps_read_ == false) ReadSavemaps();
  402. return saved_savemaps_[slot]->GetCharacterLimitBar(id);
  403. }
  404. unsigned int SavemapHandler::GetSlotCharacterWeaponId(
  405. const unsigned int slot, const unsigned int id
  406. ){
  407. if (slot >= MAX_SAVE_SLOTS) return 0;
  408. if (savemaps_read_ == false) ReadSavemaps();
  409. return saved_savemaps_[slot]->GetCharacterWeaponId(id);
  410. }
  411. unsigned int SavemapHandler::GetSlotCharacterArmorId(
  412. const unsigned int slot, const unsigned int id
  413. ){
  414. if (slot >= MAX_SAVE_SLOTS) return 0;
  415. if (savemaps_read_ == false) ReadSavemaps();
  416. return saved_savemaps_[slot]->GetCharacterArmorId(id);
  417. }
  418. int SavemapHandler::GetSlotCharacterAccessoryId(const unsigned int slot, const unsigned int id){
  419. if (slot >= MAX_SAVE_SLOTS) return -1;
  420. if (savemaps_read_ == false) ReadSavemaps();
  421. return saved_savemaps_[slot]->GetCharacterAccessoryId(id);
  422. }
  423. unsigned int SavemapHandler::GetSlotCharacterStatBase(
  424. const unsigned int slot, const unsigned int id, const unsigned int stat
  425. ){
  426. if (slot >= MAX_SAVE_SLOTS) return 0;
  427. if (savemaps_read_ == false) ReadSavemaps();
  428. return saved_savemaps_[slot]->GetCharacterStatBase(id, stat);
  429. }
  430. unsigned int SavemapHandler::GetSlotCharacterStatExtra(
  431. const unsigned int slot, const unsigned int id, const unsigned int stat
  432. ){
  433. if (slot >= MAX_SAVE_SLOTS) return 0;
  434. if (savemaps_read_ == false) ReadSavemaps();
  435. return saved_savemaps_[slot]->GetCharacterStatExtra(id, stat);
  436. }
  437. unsigned int SavemapHandler::GetSlotCharacterLimitUses(
  438. const unsigned int slot, const unsigned int id, const unsigned int level
  439. ){
  440. if (slot >= MAX_SAVE_SLOTS) return 0;
  441. if (savemaps_read_ == false) ReadSavemaps();
  442. return saved_savemaps_[slot]->GetCharacterLimitUses(id, level);
  443. }
  444. bool SavemapHandler::IsSlotCharacterLimitLearned(
  445. const unsigned int slot, const unsigned int id, const unsigned int level, const unsigned int tech
  446. ){
  447. if (slot >= MAX_SAVE_SLOTS) return false;
  448. if (savemaps_read_ == false) ReadSavemaps();
  449. return saved_savemaps_[slot]->IsCharacterLimitLearned(id, level, tech);
  450. }
  451. int SavemapHandler::GetSlotCharacterMateriaId(
  452. const unsigned int slot, const unsigned int id, const bool weapon, const unsigned int pos
  453. ){
  454. if (slot >= MAX_SAVE_SLOTS) return -1;
  455. if (savemaps_read_ == false) ReadSavemaps();
  456. return saved_savemaps_[slot]->GetCharacterMateriaId(id, weapon, pos);
  457. }
  458. unsigned int SavemapHandler::GetSlotCharacterMateriaAp(
  459. const unsigned int slot, const unsigned int id, const bool weapon, const unsigned int pos
  460. ){
  461. if (slot >= MAX_SAVE_SLOTS) return 0;
  462. if (savemaps_read_ == false) ReadSavemaps();
  463. return saved_savemaps_[slot]->GetCharacterMateriaAp(id, weapon, pos);
  464. }
  465. bool SavemapHandler::IsSlotCharacterMateriaESkill(
  466. const unsigned int slot, const unsigned int id, const bool weapon, const unsigned int pos
  467. ){
  468. if (slot >= MAX_SAVE_SLOTS) return false;
  469. if (savemaps_read_ == false) ReadSavemaps();
  470. return saved_savemaps_[slot]->IsCharacterMateriaESkill(id, weapon, pos);
  471. }
  472. bool SavemapHandler::IsSlotCharacterMateriaESkillLearned(
  473. const unsigned int slot, const unsigned int id, const bool weapon,
  474. const unsigned int pos, const unsigned int skill
  475. ){
  476. if (slot >= MAX_SAVE_SLOTS) return false;
  477. if (savemaps_read_ == false) ReadSavemaps();
  478. return saved_savemaps_[slot]->IsCharacterMateriaESkillLearned(id, weapon, pos, skill);
  479. }
  480. int SavemapHandler::GetSlotData(
  481. const unsigned int slot, const unsigned int bank, const unsigned int address
  482. ){
  483. if (slot >= MAX_SAVE_SLOTS) return false;
  484. if (savemaps_read_ == false) ReadSavemaps();
  485. return saved_savemaps_[slot]->GetData(bank, address);
  486. }