searchstore.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. // Copyright (c) rAthena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #ifndef SEARCHSTORE_HPP
  4. #define SEARCHSTORE_HPP
  5. #include <memory>
  6. #include <vector>
  7. #include <common/cbasetypes.hpp>
  8. #include <common/mmo.hpp>
  9. #include "clif.hpp"
  10. #include "map.hpp"
  11. #define SEARCHSTORE_RESULTS_PER_PAGE 10
  12. /// Failure constants for clif functions
  13. enum e_searchstore_failure : uint16
  14. {
  15. // "No matching stores were found." (1803)
  16. SSI_FAILED_NOTHING_SEARCH_ITEM = 0,
  17. // "There are too many results. Please enter more detailed search term." (1784)
  18. SSI_FAILED_OVER_MAXCOUNT,
  19. // "You cannot search anymore." (1798)
  20. SSI_FAILED_SEARCH_CNT,
  21. // "You cannot search yet." (1800)
  22. SSI_FAILED_LIMIT_SEARCH_TIME,
  23. // "No sale (purchase) information available." (1797)
  24. SSI_FAILED_SSILIST_CLICK_TO_OPEN_STORE,
  25. };
  26. /// Search type constants
  27. enum e_searchstore_searchtype : uint16
  28. {
  29. // Search for vending stores
  30. SEARCHTYPE_VENDING = 0,
  31. // Search for buying stores
  32. SEARCHTYPE_BUYING_STORE,
  33. };
  34. /// Search effect constants
  35. enum e_searchstore_effecttype : uint16
  36. {
  37. // Displays the coordinates of the store
  38. SEARCHSTORE_EFFECT_NORMAL = 0,
  39. // Opens the store remotely
  40. SEARCHSTORE_EFFECT_REMOTE,
  41. SEARCHSTORE_EFFECT_MAX
  42. };
  43. /// information about the search being performed
  44. struct s_search_store_search {
  45. map_session_data* search_sd; // sd of the searching player
  46. const struct PACKET_CZ_SEARCH_STORE_INFO_item* itemlist;
  47. const struct PACKET_CZ_SEARCH_STORE_INFO_item* cardlist;
  48. uint32 item_count;
  49. uint32 card_count;
  50. uint32 min_price;
  51. uint32 max_price;
  52. };
  53. struct s_search_store_info_item {
  54. int store_id;
  55. uint32 account_id;
  56. char store_name[MESSAGE_SIZE];
  57. t_itemid nameid;
  58. unsigned short amount;
  59. uint32 price;
  60. t_itemid card[MAX_SLOTS];
  61. unsigned char refine;
  62. uint8 enchantgrade;
  63. };
  64. struct s_search_store_info {
  65. std::vector<std::shared_ptr<s_search_store_info_item>> items;
  66. uint32 pages; // amount of pages already sent to client
  67. uint16 uses;
  68. int remote_id;
  69. time_t nextquerytime;
  70. e_searchstore_effecttype effect;
  71. e_searchstore_searchtype type;
  72. int16 mapid;
  73. bool open;
  74. };
  75. bool searchstore_open(map_session_data& sd, uint16 uses, e_searchstore_effecttype effect, int16 mapid);
  76. void searchstore_query(map_session_data& sd, e_searchstore_searchtype type, uint32 min_price, uint32 max_price, const struct PACKET_CZ_SEARCH_STORE_INFO_item* itemlist, uint32 item_count, const struct PACKET_CZ_SEARCH_STORE_INFO_item* cardlist, uint32 card_count);
  77. bool searchstore_querynext(map_session_data& sd);
  78. void searchstore_next(map_session_data& sd);
  79. void searchstore_clear(map_session_data& sd);
  80. void searchstore_close(map_session_data& sd);
  81. void searchstore_click(map_session_data& sd, uint32 account_id, int store_id, t_itemid nameid);
  82. bool searchstore_queryremote(map_session_data& sd, uint32 account_id);
  83. void searchstore_clearremote(map_session_data& sd);
  84. #endif /* SEARCHSTORE_HPP */