SavemapHandler.cpp 21 KB

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