mmo.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
  2. // For more information, see LICENCE in the main folder
  3. #ifndef _MMO_H_
  4. #define _MMO_H_
  5. #include <time.h>
  6. #include "utils.h" // _WIN32
  7. #if ! defined(Assert)
  8. #if defined(RELEASE)
  9. #define Assert(EX)
  10. #else
  11. // extern "C" {
  12. #include <assert.h>
  13. // }
  14. #ifndef DEFCPP
  15. #if defined(_WIN32) && !defined(MINGW)
  16. #include <crtdbg.h>
  17. #endif
  18. #endif
  19. #define Assert(EX) assert(EX)
  20. #endif
  21. #endif /* ! defined(Assert) */
  22. #ifdef CYGWIN
  23. // txtやlogなどの書き出すファイルの改行コード
  24. #define RETCODE "\r\n" // (CR/LF:Windows系)
  25. #else
  26. #define RETCODE "\n" // (LF:Unix系)
  27. #endif
  28. #define RET RETCODE
  29. #define FIFOSIZE_SERVERLINK 256*1024
  30. // set to 0 to not check IP of player between each server.
  31. // set to another value if you want to check (1)
  32. #define CMP_AUTHFIFO_IP 1
  33. #define CMP_AUTHFIFO_LOGIN2 1
  34. //Remove/Comment this line to disable sc_data saving. [Skotlex]
  35. #define ENABLE_SC_SAVING
  36. #define MAX_MAP_PER_SERVER 1024
  37. #define MAX_INVENTORY 100
  38. //Number of slots carded equipment can have. Never set to less than 4 as they are also used to keep the data of forged items/equipment. [Skotlex]
  39. //Note: The client seems unable to receive data for more than 4 slots due to all related packets having a fixed size.
  40. #define MAX_SLOTS 4
  41. #define MAX_AMOUNT 30000
  42. #define MAX_ZENY 1000000000
  43. #define MAX_FAME 1000000000
  44. #define MAX_CART 100
  45. #define MAX_SKILL 1100 // Bumped to 1100 for new quest skills, will need to further increase one day... [DracoRPG]
  46. #define GLOBAL_REG_NUM 96
  47. #define ACCOUNT_REG_NUM 64
  48. #define ACCOUNT_REG2_NUM 16
  49. //Should hold the max of GLOBAL/ACCOUNT/ACCOUNT2 (needed for some arrays that hold all three)
  50. #define MAX_REG_NUM 96
  51. #define DEFAULT_WALK_SPEED 150
  52. #define MIN_WALK_SPEED 0
  53. #define MAX_WALK_SPEED 1000
  54. #define MAX_STORAGE 300
  55. #define MAX_GUILD_STORAGE 1000
  56. #define MAX_PARTY 12
  57. #define MAX_GUILD 16+10*6 // increased max guild members +6 per 1 extension levels [Lupus]
  58. #define MAX_GUILDPOSITION 20 // increased max guild positions to accomodate for all members [Valaris] (removed) [PoW]
  59. #define MAX_GUILDEXPLUSION 32
  60. #define MAX_GUILDALLIANCE 16
  61. #define MAX_GUILDSKILL 15 // increased max guild skills because of new skills [Sara-chan]
  62. #define MAX_GUILDCASTLE 24 // increased to include novice castles [Valaris]
  63. #define MAX_GUILDLEVEL 50
  64. #define MAX_GUARDIANS 8 //Local max per castle. [Skotlex]
  65. #define MIN_HAIR_STYLE battle_config.min_hair_style
  66. #define MAX_HAIR_STYLE battle_config.max_hair_style
  67. #define MIN_HAIR_COLOR battle_config.min_hair_color
  68. #define MAX_HAIR_COLOR battle_config.max_hair_color
  69. #define MIN_CLOTH_COLOR battle_config.min_cloth_color
  70. #define MAX_CLOTH_COLOR battle_config.max_cloth_color
  71. // for produce
  72. #define MIN_ATTRIBUTE 0
  73. #define MAX_ATTRIBUTE 4
  74. #define ATTRIBUTE_NORMAL 0
  75. #define MIN_STAR 0
  76. #define MAX_STAR 3
  77. #define MIN_PORTAL_MEMO 0
  78. #define MAX_PORTAL_MEMO 2
  79. #define MAX_STATUS_TYPE 5
  80. #define WEDDING_RING_M 2634
  81. #define WEDDING_RING_F 2635
  82. //For character names, title names, guilds, maps, etc.
  83. //Includes null-terminator as it is the length of the array.
  84. #define NAME_LENGTH 24
  85. //For item names, which tend to have much longer names.
  86. #define ITEM_NAME_LENGTH 50
  87. //For Map Names, which the client considers to be 16 in length
  88. #define MAP_NAME_LENGTH 16
  89. #define MAX_FRIENDS 40
  90. #define MAX_MEMOPOINTS 10
  91. //Size of the fame list arrays.
  92. #define MAX_FAME_LIST 10
  93. //These max values can be exceeded and the char/map servers will update them with no problems
  94. //These are just meant to minimize the updating needed between char/map servers as players login.
  95. //Room for initial 10K accounts
  96. #define DEFAULT_MAX_ACCOUNT_ID 2010000
  97. //Room for initial 100k characters
  98. #define DEFAULT_MAX_CHAR_ID 250000
  99. #define CHAR_CONF_NAME "conf/char_athena.conf"
  100. struct item {
  101. int id;
  102. short nameid;
  103. short amount;
  104. unsigned short equip;
  105. char identify;
  106. char refine;
  107. char attribute;
  108. short card[MAX_SLOTS];
  109. };
  110. struct point{
  111. unsigned short map;
  112. short x,y;
  113. };
  114. struct skill {
  115. unsigned short id,lv,flag;
  116. };
  117. struct global_reg {
  118. char str[32];
  119. char value[256]; // [zBuffer]
  120. };
  121. //For saving status changes across sessions. [Skotlex]
  122. struct status_change_data {
  123. unsigned short type; //SC_type
  124. int val1, val2, val3, val4, tick; //Remaining duration.
  125. };
  126. struct s_pet {
  127. int account_id;
  128. int char_id;
  129. int pet_id;
  130. short class_;
  131. short level;
  132. short egg_id;//pet egg id
  133. short equip;//pet equip name_id
  134. short intimate;//pet friendly
  135. short hungry;//pet hungry
  136. char name[NAME_LENGTH];
  137. char rename_flag;
  138. char incuvate;
  139. };
  140. struct friend {
  141. int account_id;
  142. int char_id;
  143. char name[NAME_LENGTH];
  144. };
  145. struct mmo_charstatus {
  146. int char_id;
  147. int account_id;
  148. int partner_id;
  149. int father;
  150. int mother;
  151. int child;
  152. unsigned int base_exp,job_exp;
  153. int zeny;
  154. short class_;
  155. unsigned short status_point,skill_point;
  156. int hp,max_hp,sp,max_sp;
  157. unsigned short option;
  158. short manner;
  159. unsigned char karma;
  160. short hair,hair_color,clothes_color;
  161. int party_id,guild_id,pet_id;
  162. int fame;
  163. short weapon,shield;
  164. short head_top,head_mid,head_bottom;
  165. char name[NAME_LENGTH];
  166. unsigned int base_level,job_level;
  167. short str,agi,vit,int_,dex,luk;
  168. unsigned char char_num,sex;
  169. unsigned long mapip;
  170. unsigned int mapport;
  171. struct point last_point,save_point,memo_point[MAX_MEMOPOINTS];
  172. struct item inventory[MAX_INVENTORY],cart[MAX_CART];
  173. struct skill skill[MAX_SKILL];
  174. struct friend friends[MAX_FRIENDS]; //New friend system [Skotlex]
  175. };
  176. struct registry {
  177. int global_num;
  178. struct global_reg global[GLOBAL_REG_NUM];
  179. int account_num;
  180. struct global_reg account[ACCOUNT_REG_NUM];
  181. int account2_num;
  182. struct global_reg account2[ACCOUNT_REG2_NUM];
  183. };
  184. struct storage {
  185. int dirty;
  186. int account_id;
  187. short storage_status;
  188. short storage_amount;
  189. struct item storage_[MAX_STORAGE];
  190. };
  191. struct guild_storage {
  192. int dirty;
  193. int guild_id;
  194. short storage_status;
  195. short storage_amount;
  196. struct item storage_[MAX_GUILD_STORAGE];
  197. };
  198. struct map_session_data;
  199. struct gm_account {
  200. int account_id;
  201. int level;
  202. };
  203. struct party_member {
  204. int account_id;
  205. int char_id;
  206. char name[NAME_LENGTH];
  207. unsigned short map;
  208. unsigned short lv;
  209. unsigned leader : 1,
  210. online : 1;
  211. };
  212. struct party {
  213. int party_id;
  214. char name[NAME_LENGTH];
  215. unsigned exp : 1,
  216. item : 2; //&1: Party-Share (round-robin), &2: pickup style: shared.
  217. struct party_member member[MAX_PARTY];
  218. };
  219. struct guild_member {
  220. int account_id, char_id;
  221. short hair,hair_color,gender,class_,lv;
  222. int exp,exp_payper;
  223. short online,position;
  224. int rsv1,rsv2;
  225. char name[NAME_LENGTH];
  226. struct map_session_data *sd;
  227. };
  228. struct guild_position {
  229. char name[NAME_LENGTH];
  230. int mode;
  231. int exp_mode;
  232. };
  233. struct guild_alliance {
  234. int opposition;
  235. int guild_id;
  236. char name[NAME_LENGTH];
  237. };
  238. struct guild_explusion {
  239. char name[NAME_LENGTH];
  240. char mes[40];
  241. char acc[40];
  242. int account_id;
  243. int rsv1,rsv2,rsv3;
  244. };
  245. struct guild_skill {
  246. int id,lv;
  247. };
  248. struct guild {
  249. int guild_id;
  250. short guild_lv, connect_member, max_member, average_lv;
  251. unsigned int exp,next_exp;
  252. int skill_point;
  253. #ifdef TXT_ONLY
  254. //FIXME: Gotta remove this variable completely, but doing so screws up the format of the txt save file...
  255. int castle_id;
  256. #endif
  257. char name[NAME_LENGTH],master[NAME_LENGTH];
  258. struct guild_member member[MAX_GUILD];
  259. struct guild_position position[MAX_GUILDPOSITION];
  260. char mes1[60],mes2[120];
  261. int emblem_len,emblem_id;
  262. char emblem_data[2048];
  263. struct guild_alliance alliance[MAX_GUILDALLIANCE];
  264. struct guild_explusion explusion[MAX_GUILDEXPLUSION];
  265. struct guild_skill skill[MAX_GUILDSKILL];
  266. #ifndef TXT_ONLY
  267. unsigned char save_flag;
  268. #endif
  269. };
  270. struct guild_castle {
  271. int castle_id;
  272. char map_name[MAP_NAME_LENGTH];
  273. char castle_name[NAME_LENGTH];
  274. char castle_event[NAME_LENGTH];
  275. int guild_id;
  276. int economy;
  277. int defense;
  278. int triggerE;
  279. int triggerD;
  280. int nextTime;
  281. int payTime;
  282. int createTime;
  283. int visibleC;
  284. struct {
  285. unsigned visible : 1;
  286. int hp;
  287. int id;
  288. } guardian[MAX_GUARDIANS]; //New simplified structure. [Skotlex]
  289. };
  290. struct square {
  291. int val1[5];
  292. int val2[5];
  293. };
  294. struct fame_list {
  295. int id;
  296. int fame;
  297. char name[NAME_LENGTH];
  298. };
  299. enum {
  300. GBI_EXP =1, // ギルドのEXP
  301. GBI_GUILDLV, // ギルドのLv
  302. GBI_SKILLPOINT, // ギルドのスキルポイント
  303. GBI_SKILLLV, // ギルドスキルLv
  304. };
  305. enum {
  306. GMI_POSITION =0, // メンバーの役職変更
  307. GMI_EXP,
  308. GMI_HAIR,
  309. GMI_HAIR_COLOR,
  310. GMI_GENDER,
  311. GMI_CLASS,
  312. GMI_LEVEL,
  313. };
  314. enum {
  315. GD_SKILLBASE=10000,
  316. GD_APPROVAL=10000,
  317. GD_KAFRACONTRACT=10001,
  318. GD_GUARDIANRESEARCH=10002,
  319. GD_GUARDUP=10003,
  320. GD_EXTENSION=10004,
  321. GD_GLORYGUILD=10005,
  322. GD_LEADERSHIP=10006,
  323. GD_GLORYWOUNDS=10007,
  324. GD_SOULCOLD=10008,
  325. GD_HAWKEYES=10009,
  326. GD_BATTLEORDER=10010,
  327. GD_REGENERATION=10011,
  328. GD_RESTORE=10012,
  329. GD_EMERGENCYCALL=10013,
  330. GD_DEVELOPMENT=10014,
  331. };
  332. //These mark the ID of the jobs, as expected by the client. [Skotlex]
  333. enum {
  334. JOB_NOVICE,
  335. JOB_SWORDMAN,
  336. JOB_MAGE,
  337. JOB_ARCHER,
  338. JOB_ACOLYTE,
  339. JOB_MERCHANT,
  340. JOB_THIEF,
  341. JOB_KNIGHT,
  342. JOB_PRIEST,
  343. JOB_WIZARD,
  344. JOB_BLACKSMITH,
  345. JOB_HUNTER,
  346. JOB_ASSASSIN,
  347. JOB_KNIGHT2,
  348. JOB_CRUSADER,
  349. JOB_MONK,
  350. JOB_SAGE,
  351. JOB_ROGUE,
  352. JOB_ALCHEMIST,
  353. JOB_BARD,
  354. JOB_DANCER,
  355. JOB_CRUSADER2,
  356. JOB_WEDDING,
  357. JOB_SUPER_NOVICE,
  358. JOB_GUNSLINGER,
  359. JOB_NINJA,
  360. JOB_XMAS,
  361. JOB_NOVICE_HIGH = 4001,
  362. JOB_SWORDMAN_HIGH,
  363. JOB_MAGE_HIGH,
  364. JOB_ARCHER_HIGH,
  365. JOB_ACOLYTE_HIGH,
  366. JOB_MERCHANT_HIGH,
  367. JOB_THIEF_HIGH,
  368. JOB_LORD_KNIGHT,
  369. JOB_HIGH_PRIEST,
  370. JOB_HIGH_WIZARD,
  371. JOB_WHITESMITH,
  372. JOB_SNIPER,
  373. JOB_ASSASSIN_CROSS,
  374. JOB_LORD_KNIGHT2,
  375. JOB_PALADIN,
  376. JOB_CHAMPION,
  377. JOB_PROFESSOR,
  378. JOB_STALKER,
  379. JOB_CREATOR,
  380. JOB_CLOWN,
  381. JOB_GYPSY,
  382. JOB_PALADIN2,
  383. JOB_BABY,
  384. JOB_BABY_SWORDMAN,
  385. JOB_BABY_MAGE,
  386. JOB_BABY_ARCHER,
  387. JOB_BABY_ACOLYTE,
  388. JOB_BABY_MERCHANT,
  389. JOB_BABY_THIEF,
  390. JOB_BABY_KNIGHT,
  391. JOB_BABY_PRIEST,
  392. JOB_BABY_WIZARD,
  393. JOB_BABY_BLACKSMITH,
  394. JOB_BABY_HUNTER,
  395. JOB_BABY_ASSASSIN,
  396. JOB_BABY_KNIGHT2,
  397. JOB_BABY_CRUSADER,
  398. JOB_BABY_MONK,
  399. JOB_BABY_SAGE,
  400. JOB_BABY_ROGUE,
  401. JOB_BABY_ALCHEMIST,
  402. JOB_BABY_BARD,
  403. JOB_BABY_DANCER,
  404. JOB_BABY_CRUSADER2,
  405. JOB_SUPER_BABY,
  406. JOB_TAEKWON,
  407. JOB_STAR_GLADIATOR,
  408. JOB_STAR_GLADIATOR2,
  409. JOB_SOUL_LINKER,
  410. };
  411. #ifndef __WIN32
  412. #ifndef strcmpi
  413. #define strcmpi strcasecmp
  414. #endif
  415. #ifndef stricmp
  416. #define stricmp strcasecmp
  417. #endif
  418. #ifndef strncmpi
  419. #define strncmpi strncasecmp
  420. #endif
  421. #ifndef strnicmp
  422. #define strnicmp strncasecmp
  423. #endif
  424. #else
  425. #define snprintf _snprintf
  426. #define vsnprintf _vsnprintf
  427. #ifndef strncmpi
  428. #define strncmpi strnicmp
  429. #endif
  430. #endif
  431. #endif // _MMO_H_