mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-23 00:42:27 +00:00
Compare commits
2148 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ad3d065225 | |||
| 66cfb2e32b | |||
| 3e1c917f11 | |||
| ea4c23efcf | |||
| c328829610 | |||
| 28ac586ed8 | |||
| ee71fa0d56 | |||
| f3e04bfe4c | |||
| a8c23d25f3 | |||
| 41f2d71c7c | |||
| e338f801ea | |||
| 6221c1f8ab | |||
| 5dac9a944b | |||
| 97c1c479f9 | |||
| 21d6865e8c | |||
| e2894ef2aa | |||
| 7656b9b928 | |||
| 0fde0fbd23 | |||
| d5955da08c | |||
| e2333e671b | |||
| 1da70ee6ed | |||
| 0d8cbca016 | |||
| 1a4b794ce4 | |||
| fca359bf51 | |||
| 5f11e91da2 | |||
| 2c275f603a | |||
| ad921d01d8 | |||
| e3e2b266f2 | |||
| e2d52ec3e5 | |||
| a325380884 | |||
| b6294a28cb | |||
| 69336d1e53 | |||
| 2df5506d82 | |||
| 2dacb523fc | |||
| 6474e1353f | |||
| 45ef740244 | |||
| 48299b6024 | |||
| be7d2e9457 | |||
| a90babbae1 | |||
| 4b1d3592d4 | |||
| 77cfd116e0 | |||
| 67c8949cd4 | |||
| b66b7a5fd2 | |||
| b0d358cda8 | |||
| 8553278759 | |||
| 7a3f7602a5 | |||
| 11e08c9b67 | |||
| dfcddac2ef | |||
| 73b2987700 | |||
| 5781821ab3 | |||
| 9183541825 | |||
| 7870081716 | |||
| 2bee906784 | |||
| cab41487d5 | |||
| 66448feece | |||
| 65127ad756 | |||
| 1261c228a3 | |||
| 5be8e710a9 | |||
| 3ad7ab625d | |||
| b6be6c3709 | |||
| 8ff4e59d20 | |||
| ad116af59d | |||
| fa1fe55e01 | |||
| 4f2dbb37d2 | |||
| 7dc1da21f0 | |||
| 806a9fbb99 | |||
| e753685ceb | |||
| e0e3059498 | |||
| 61545beff2 | |||
| 16c5ead887 | |||
| 3a270dd96a | |||
| bb2bed7b00 | |||
| 0438dee22e | |||
| b3d8e22539 | |||
| 968127c414 | |||
| 272180ff0f | |||
| 03fed0f42d | |||
| fab091da2d | |||
| c7417d4b54 | |||
| d8c6c69450 | |||
| 1024e327b5 | |||
| e38268230f | |||
| c7760d8dae | |||
| 8d050b8f3f | |||
| 7800cbbe96 | |||
| 50233b9a8c | |||
| a722e3f112 | |||
| be52d413db | |||
| 1dfd3349b7 | |||
| cf8363f62e | |||
| 7326a3ea7a | |||
| cb49bae53c | |||
| 31f891dda5 | |||
| 38572fe393 | |||
| 83367ee806 | |||
| f117aafc45 | |||
| 3e0c1bc02e | |||
| f13a1d6351 | |||
| fdde64dcc3 | |||
| f5fa07c8db | |||
| 5ffb6bdee7 | |||
| 8035c6c558 | |||
| fc1eca0f31 | |||
| 28e49801b7 | |||
| 66c171b61b | |||
| 3be7d45d36 | |||
| e5822a0c4a | |||
| b05dd45d62 | |||
| 9f64092606 | |||
| d2acd0505c | |||
| 05ed577e23 | |||
| 7831162235 | |||
| 8567fd928a | |||
| 73a23e9f9d | |||
| f232bf1ccd | |||
| acc6926448 | |||
| 837ce8ab4a | |||
| 2497c719ee | |||
| 31b46efcac | |||
| 9f3a0a3f95 | |||
| 179400c777 | |||
| 0f12a74074 | |||
| 61b784e96e | |||
| 723e5d536a | |||
| 225929d937 | |||
| 763ed7f7a3 | |||
| ea6ef4c283 | |||
| e5a0cc9ef7 | |||
| a79ea9b850 | |||
| 039e321dde | |||
| c57292a9dd | |||
| 9561a3fd3e | |||
| aa021addc1 | |||
| c0cbbf3a65 | |||
| a73ac9cfe8 | |||
| ec8c46abfe | |||
| b9b92762b5 | |||
| 7feb531ff7 | |||
| e67423bba7 | |||
| 531e4b0207 | |||
| 34496c49b4 | |||
| a445d7e39f | |||
| 0d12715d77 | |||
| 9878459049 | |||
| 9be0d3b090 | |||
| 16ba3eb11e | |||
| 973aa94cb5 | |||
| 4cbccfdce2 | |||
| a5e6fa3479 | |||
| 3712d36867 | |||
| 17291e9977 | |||
| 15f57e4a4c | |||
| e58d63bf35 | |||
| f89add9f64 | |||
| e039f6d2c6 | |||
| 7cef4d8fe9 | |||
| 7b85b09f24 | |||
| 413538f1b5 | |||
| c03a70651c | |||
| ec01e6c69b | |||
| 11773208df | |||
| 1f155690d8 | |||
| 36a29dbb9f | |||
| c160b8716f | |||
| 7ffce01260 | |||
| 1170b57fd5 | |||
| fee8a1214a | |||
| c26a6959e4 | |||
| 837b9b7ec7 | |||
| a5a8bfb0f4 | |||
| 69bddef5a0 | |||
| 7d242045ec | |||
| c3035fdf41 | |||
| e34c47414f | |||
| 909dda7c09 | |||
| 22ab145f19 | |||
| cd8e30a2ec | |||
| 03be6b2b6b | |||
| cda2217634 | |||
| 4525b512ac | |||
| db0d1116f8 | |||
| 3ef5d8ef0a | |||
| 4ed88e348e | |||
| ad29fa9cfa | |||
| 388c4bc574 | |||
| b4f3993616 | |||
| f9366553a3 | |||
| 9733f04c9c | |||
| 7140a2054f | |||
| 1049e48aca | |||
| 33b79a3588 | |||
| f82699c39b | |||
| 15eaf4e6d1 | |||
| 7621882b4e | |||
| 9b70b73759 | |||
| 8e43134bda | |||
| 52608d9b2d | |||
| d26782b093 | |||
| a2368b4ea7 | |||
| 3d6bb964df | |||
| 347ae1bc34 | |||
| 64f5bfd5ce | |||
| 3cb02e3b86 | |||
| 34c3b8628e | |||
| 8f921ce919 | |||
| 6754dfdf6d | |||
| 81722962cf | |||
| d169d95ab0 | |||
| 63ca4cac5e | |||
| f30ae9dd5a | |||
| eb49707779 | |||
| 86c1420f6e | |||
| 364ed921ce | |||
| 85e1518856 | |||
| 87bb5deb5c | |||
| 11ce399e0d | |||
| ec0989454d | |||
| e9f6031936 | |||
| 03485ef1e0 | |||
| e256175ce6 | |||
| 0f662bf70c | |||
| 4c959159c2 | |||
| d51241720a | |||
| 873d343529 | |||
| 95969ce67b | |||
| bd5cdf502e | |||
| c6a7d5a96c | |||
| 6bc4ecf390 | |||
| c94ceb5b1d | |||
| e390531dcd | |||
| bb702335e8 | |||
| 863c0c5b58 | |||
| 76e280da4e | |||
| bcca35b7b7 | |||
| 65abaade88 | |||
| 8020e921aa | |||
| f2f5b4c1ad | |||
| 5c6f9fcdc4 | |||
| d7dc733480 | |||
| 9e243a2426 | |||
| 9a889802d3 | |||
| 1420987c4c | |||
| ed4d954ba8 | |||
| 881f937a35 | |||
| ed4e762f03 | |||
| fa1e33783a | |||
| 0c38b46bf1 | |||
| 899cf32e6b | |||
| 2fa31799f6 | |||
| 6c3d5c713c | |||
| f16beddf6e | |||
| 506b3ca4a0 | |||
| 80242bd250 | |||
| 7f7f99cbe3 | |||
| 579294fbf0 | |||
| a3b54e5cae | |||
| b392d16808 | |||
| 1f9597a9e2 | |||
| 54c89d69f6 | |||
| a14371ba5c | |||
| 616e13acac | |||
| b50f660339 | |||
| 4c12d31e4a | |||
| e50cf5c4be | |||
| 84310ec8f0 | |||
| ffed5a9e22 | |||
| 92c9ff6e53 | |||
| 986a424322 | |||
| c3e7c48939 | |||
| b2aa3262a9 | |||
| b1587f0326 | |||
| ca7dd7d741 | |||
| 281b321237 | |||
| ba0e4bfc1d | |||
| 3cda62acf4 | |||
| 2ef43212e1 | |||
| f69eccc42b | |||
| a1e425f936 | |||
| 59618e0038 | |||
| ef1f1562f0 | |||
| 31177b7dc7 | |||
| 5b7aaff150 | |||
| b525a32b6e | |||
| 99fe610f72 | |||
| b5ec35e672 | |||
| 6186c3d866 | |||
| 1d0a6bdc71 | |||
| 15fa2b371c | |||
| da121137e5 | |||
| c953f1dee1 | |||
| 32b595afb4 | |||
| 0799b47c9c | |||
| a216672443 | |||
| d755aa48bc | |||
| f7ecfe7257 | |||
| 89a0bbb8bf | |||
| 822c8425bd | |||
| a6b57a3423 | |||
| 6d4f7413a5 | |||
| 3e041052ee | |||
| 444174ef57 | |||
| 970f7e01a9 | |||
| 4432c07081 | |||
| 221c667a23 | |||
| b710c41c34 | |||
| 8825218361 | |||
| 1bb5c4e0d8 | |||
| 58343480ff | |||
| 399bf96a0c | |||
| b7c409e11b | |||
| fd08e9f2ad | |||
| 37d3daaf9a | |||
| 9a4d01da8f | |||
| 81cf748b2b | |||
| 22742b6a25 | |||
| 7d8d96c049 | |||
| 081905dbc3 | |||
| a8b8f71092 | |||
| 36c1d88eac | |||
| 6eba672013 | |||
| 091c8ea5f1 | |||
| f5e49441b6 | |||
| 610f3ed37f | |||
| f215874486 | |||
| 8e529105cf | |||
| 95dc0c5fc8 | |||
| 73c8d3d09d | |||
| 049a0bf787 | |||
| 2095380ba4 | |||
| 081192d29e | |||
| 2429980fd5 | |||
| 0ac238d762 | |||
| 45320fd8ec | |||
| 6d33a13e23 | |||
| 52d64d03a6 | |||
| fe6e289606 | |||
| 26569ac51d | |||
| 38d04931ba | |||
| 96cf3d967f | |||
| 36325226eb | |||
| 6410f52c9c | |||
| 7ae14fffd0 | |||
| d213e3b106 | |||
| ba612f91c7 | |||
| 8312a8cf3b | |||
| 390dcc9a88 | |||
| cd1b45f0d6 | |||
| b8caa5dc31 | |||
| 53572b4d13 | |||
| cf0c773002 | |||
| 515fe8d9e5 | |||
| 06d1bd632b | |||
| 89f34246f0 | |||
| 7d8e128b5f | |||
| 14c642a3f7 | |||
| a67255475c | |||
| 04045dfc27 | |||
| 510a51e564 | |||
| 54b2c50109 | |||
| fe753f05df | |||
| ab76783f8b | |||
| 364a51b119 | |||
| a486db5e95 | |||
| c8e7d9e005 | |||
| 93aa690a6d | |||
| 87f1f78b67 | |||
| 0574a3db86 | |||
| 0178f3c9bb | |||
| 9eb3907d45 | |||
| 891952eb79 | |||
| e6a0b01f37 | |||
| 118c2a9db9 | |||
| 64c324a42b | |||
| f909e76260 | |||
| b7dfdc5060 | |||
| e25239a50d | |||
| 76d3edc534 | |||
| 7301182b3e | |||
| 832e5e90d1 | |||
| 7ddaabee30 | |||
| 41d57ddab6 | |||
| 8dd00f5288 | |||
| 0a9222e1ee | |||
| e0db3c0b60 | |||
| 15f217b594 | |||
| 8422178233 | |||
| eebe902917 | |||
| 04dc593df9 | |||
| e0a99730e5 | |||
| 6497bdf45a | |||
| ca430e2494 | |||
| f8439fd6e6 | |||
| 8dda7ddd04 | |||
| 5d8ea5752d | |||
| 4071d88290 | |||
| 11ed698642 | |||
| 0996570b78 | |||
| ca84040a39 | |||
| 467afc86af | |||
| 19271f90a4 | |||
| 0a9732a267 | |||
| 1bc06c9c24 | |||
| e0acc937b3 | |||
| 3a10a0129a | |||
| 18dbcf16cc | |||
| bed8dc7d34 | |||
| a0fc9844fd | |||
| 9d6dc47cf4 | |||
| d42d77d3ef | |||
| 9041891557 | |||
| dedd1fc70d | |||
| 5cf748d135 | |||
| 9ddb56088e | |||
| 9f4167a65c | |||
| 085b021587 | |||
| 5a65fd4207 | |||
| 0f321b3a69 | |||
| 53c7b789f2 | |||
| 850ea7789e | |||
| c3a3dc19a7 | |||
| 2606592f32 | |||
| 5c3791631a | |||
| 4c9108a906 | |||
| efbcaf6f64 | |||
| 18a4f831be | |||
| 6597967acd | |||
| 24825677dc | |||
| 70d5983562 | |||
| d4a9fed45e | |||
| a6b923a22e | |||
| 1e87086471 | |||
| c3fdbfe904 | |||
| 00852063c2 | |||
| 44dcf7af7d | |||
| d525d040fe | |||
| 67a774dd9b | |||
| ff7ff658e0 | |||
| 6100da75c5 | |||
| a612c3c006 | |||
| 412835d7fa | |||
| 6a4f7466f0 | |||
| b3ea7ecd0d | |||
| 50e6d0d256 | |||
| f948786f6a | |||
| 4d0179d525 | |||
| c851cd3f12 | |||
| b6875564d4 | |||
| 0240c61952 | |||
| 7864a5285d | |||
| 538921701c | |||
| 3cf4d4af1b | |||
| c70c7e13ec | |||
| 9980dfe80e | |||
| 42a51eb373 | |||
| 932dd836d0 | |||
| adf36bf912 | |||
| e7ef4b5484 | |||
| 3d1521857e | |||
| 9707b53df2 | |||
| 5d6d489889 | |||
| 8f4e2e99db | |||
| 377c6a87a2 | |||
| b36cc3ab08 | |||
| 339b8e37a6 | |||
| 8f3e9b4a7a | |||
| 633583c266 | |||
| 3b048ee8a2 | |||
| 52ae78709b | |||
| dec290ba96 | |||
| cef1dfd0c0 | |||
| 3262bee6c5 | |||
| 2dbd616725 | |||
| eb98563fa1 | |||
| 7f92e96ae7 | |||
| a48138dfd6 | |||
| 0b486b3f76 | |||
| 46980e5260 | |||
| 44f9e5495e | |||
| 97f59282cf | |||
| b112dfe860 | |||
| 2a4a5b1beb | |||
| 232d61b983 | |||
| 4e10b77980 | |||
| c1469a3a8e | |||
| 9d5f427f57 | |||
| cdd1e17348 | |||
| 20e978b676 | |||
| 163906e0f0 | |||
| c9bd662b57 | |||
| 8529384b00 | |||
| 7f89191ffc | |||
| aaf5f8c930 | |||
| 2bdc44dfb2 | |||
| 6e7136ea18 | |||
| 7a507e8d1e | |||
| 76fdfa87c1 | |||
| 19486bac0d | |||
| de47755320 | |||
| 6b90f883cd | |||
| 5c640b2d40 | |||
| a568a6f194 | |||
| 85df09b3f2 | |||
| 16d47a2c47 | |||
| 9a5d2d2bc5 | |||
| 3b16c86007 | |||
| 7c451f8170 | |||
| 2e1b75e95b | |||
| 1cd5970649 | |||
| 1bccdf57ee | |||
| d03232ce1b | |||
| ba6a3ac94b | |||
| 85bd837a66 | |||
| 264024e8fc | |||
| 0d09f5d536 | |||
| 840f936c2f | |||
| ca380edfc8 | |||
| 389fa922e5 | |||
| f9423b018c | |||
| 05ccab87f3 | |||
| 27dec16551 | |||
| 07a2cbe9a5 | |||
| 4821ed79fb | |||
| 5bf49d2ef9 | |||
| cd0824ee71 | |||
| 8394cc9e2b | |||
| 504a8b19ce | |||
| 0b63eaa25d | |||
| 7fc21b9e3a | |||
| 8369570b50 | |||
| e429260763 | |||
| 06f18225ce | |||
| 9ff0c414c1 | |||
| 850d1e7c28 | |||
| 2df823d2db | |||
| 2e84781594 | |||
| 405884f47d | |||
| 6457c00548 | |||
| 2e80e56af1 | |||
| 0ad4ffe33f | |||
| 833227f7f6 | |||
| e731cfd48d | |||
| cf7574d9b8 | |||
| 16f112a281 | |||
| 69944d907d | |||
| 663dbf9fc2 | |||
| a4a8a1aba5 | |||
| fb84f7f84f | |||
| 1c295453da | |||
| 8199821343 | |||
| b59e856b33 | |||
| f81acf23a7 | |||
| 27eba2e6e9 | |||
| 10d384f131 | |||
| 00b8c8ce47 | |||
| cab43f41be | |||
| fc0d589f12 | |||
| 743175d4ff | |||
| b497b07fed | |||
| aab5ed2267 | |||
| 46c9fe46e9 | |||
| e8c92c6fcc | |||
| 765eaf7f4f | |||
| 699c8cc1eb | |||
| 5839921e08 | |||
| a3bde6e1f1 | |||
| 0ece5bf178 | |||
| fbefad9eaf | |||
| 351a7a52fe | |||
| 8441ffda31 | |||
| 8b19c76e89 | |||
| e79747c919 | |||
| 8525d819c1 | |||
| fe600bb084 | |||
| babaff1985 | |||
| 909ca5440d | |||
| e25f64d03b | |||
| 2df66bd625 | |||
| 2028a5846c | |||
| 2fd2cd4cec | |||
| 17b175daa4 | |||
| 5cabe109da | |||
| c6e82448b6 | |||
| 8384ab9d2f | |||
| b846d89b5d | |||
| d5a5635a14 | |||
| f8dc8be6e6 | |||
| 5f9676d1a5 | |||
| 964c4c83df | |||
| 322cea7342 | |||
| 205e1d404e | |||
| 9769a96ebd | |||
| 74d3192c2e | |||
| 41769a3fa8 | |||
| a7efa9d4e4 | |||
| 9ed69999a5 | |||
| e19a59b269 | |||
| d234016224 | |||
| c160d6d929 | |||
| 62ad60b4ad | |||
| d44d7c6bbd | |||
| efd97bad14 | |||
| bc884f5daf | |||
| 0f47b73a64 | |||
| e9c6e96452 | |||
| 09713311f6 | |||
| c666d9c553 | |||
| 3777e8d1ce | |||
| e60658c684 | |||
| 046da9efae | |||
| 09332f6c26 | |||
| ce507d891a | |||
| 96f122f901 | |||
| 3479525f39 | |||
| 4f9d4b0023 | |||
| bcdfd32bc0 | |||
| 693dde04e3 | |||
| f1bb019933 | |||
| 5a6373c429 | |||
| 19e04a1875 | |||
| 029314ec7f | |||
| cee4a3f475 | |||
| 2bc58a97bc | |||
| 2eb270376f | |||
| 5e858678e9 | |||
| 12a59853b5 | |||
| 971c3f633f | |||
| 826f7d0efd | |||
| 5da5e9b5de | |||
| 7a3c05a41f | |||
| 01382e87a0 | |||
| f0abaad84f | |||
| 5946af88a6 | |||
| fe718a81f3 | |||
| 2f30488cd5 | |||
| 8b69de46e9 | |||
| c466317082 | |||
| 06b0bd6da4 | |||
| 334e29a6d6 | |||
| cab0beb77f | |||
| 5f2db0d1cb | |||
| b654729383 | |||
| 5fec840f06 | |||
| 1b6ccca709 | |||
| 957671e649 | |||
| 79a9e393d2 | |||
| 50c186b608 | |||
| 9054b93338 | |||
| cf1f03fd5b | |||
| 7742273237 | |||
| 536773db44 | |||
| cf4145dad4 | |||
| bc90ab795b | |||
| 21ba9953f8 | |||
| 1c87a6069a | |||
| 9867fdd4d2 | |||
| 64cd589ca3 | |||
| 110d22e775 | |||
| 3bc582885b | |||
| e33e8b713e | |||
| 4214cf47c2 | |||
| 68115505f8 | |||
| d87c95c1f8 | |||
| cec990716f | |||
| f22b26f80f | |||
| 236d227319 | |||
| a5020a68f0 | |||
| c613f362a7 | |||
| 977b28cb9c | |||
| 8b89beb02e | |||
| 748748dda9 | |||
| 6364d2c31d | |||
| e618fe87bd | |||
| 4e71330508 | |||
| c6091c4f27 | |||
| 49d231f5dd | |||
| e907ab4f3e | |||
| 9814a6e5a2 | |||
| 65e865a550 | |||
| 9cdf0a7a83 | |||
| 43326c1804 | |||
| e2d85337d0 | |||
| c4f1f57f74 | |||
| ab70427b7d | |||
| 0af394fb96 | |||
| e4320f98f8 | |||
| b5a46735df | |||
| 352d46d2ee | |||
| b672475166 | |||
| 7692793289 | |||
| 8d909ea8e2 | |||
| f7781e6d1d | |||
| 810553de2a | |||
| c6b2b1da4e | |||
| 5234eb6fc8 | |||
| d8856a7bae | |||
| 6ca5fb19f4 | |||
| 4d83397506 | |||
| 3720d9e50f | |||
| d73449104a | |||
| 580f32c190 | |||
| 65cc3a4b0a | |||
| 52344bfe24 | |||
| 7b33ef67f2 | |||
| 9270c45a5e | |||
| 34f051ab9a | |||
| a2280d1fe5 | |||
| 042613d234 | |||
| 8b05eff179 | |||
| fcb022b8ae | |||
| 41182de4f2 | |||
| 37b45be6d8 | |||
| dd044ca453 | |||
| b234c67622 | |||
| 529408fca0 | |||
| 84e95d9a28 | |||
| b439881f37 | |||
| a75b53f9b0 | |||
| 85ebb32176 | |||
| 6450b08fd6 | |||
| 0353dcb28c | |||
| 230296e777 | |||
| ad987c5531 | |||
| 503a2c0d04 | |||
| b7bcd13cbd | |||
| 446da590d8 | |||
| 24732eff88 | |||
| b98f8c6262 | |||
| 11c327e1d7 | |||
| 1253fa2a25 | |||
| f052c6004a | |||
| 3cde8d9af8 | |||
| cbed61db7e | |||
| e360ba5209 | |||
| fd8dc1214c | |||
| 327fa38232 | |||
| 845ed720b3 | |||
| ea0c8f86fe | |||
| 76f727b7ff | |||
| 449d5f9358 | |||
| b2ca66267e | |||
| f292cbc3e7 | |||
| df705e34ad | |||
| 364f133ffd | |||
| c7e2d3b355 | |||
| 553d12412b | |||
| a701541fce | |||
| dd06ecf99b | |||
| 9e5fdc50d9 | |||
| 80cc6e4ef3 | |||
| 34a56f75cf | |||
| 941f1cc395 | |||
| 9eec8f37f5 | |||
| 1734641d12 | |||
| 3856f7f1e5 | |||
| 94110dbe52 | |||
| 8a44271b2f | |||
| cca9ddab43 | |||
| 7b440bbd9f | |||
| a2d4376763 | |||
| a91b6a0db8 | |||
| 22367622be | |||
| 87efd22394 | |||
| 69b7d500d8 | |||
| 00321126f1 | |||
| 9e1549b61b | |||
| a85bb6aca6 | |||
| 9207220238 | |||
| 539c09adc5 | |||
| 8ef17f2ccd | |||
| 8b08f19628 | |||
| adc801a069 | |||
| 0f5214f481 | |||
| eb609f2ea4 | |||
| a3069b63df | |||
| f7bb763aac | |||
| bce3b1b961 | |||
| e2874b2cc6 | |||
| dc6e6fd05f | |||
| c2282ced0e | |||
| 6badd7e00e | |||
| 12b9531d8a | |||
| 1ba4b6fc31 | |||
| cb3fa2d4a3 | |||
| cfd6364999 | |||
| f1b8908c9a | |||
| 11abc45e3f | |||
| 321cf17eac | |||
| 091047d08b | |||
| f0c46664d2 | |||
| 8b2dba9715 | |||
| 26ff1ae941 | |||
| 12ded4b506 | |||
| 2b66af2d91 | |||
| 8940e987c1 | |||
| c02cb2c343 | |||
| 99b25f42e4 | |||
| a327a0028d | |||
| 478eb35a3b | |||
| d7eb28c7f8 | |||
| e1996e62b0 | |||
| bb9f440882 | |||
| b7be8fb625 | |||
| 2aec190afc | |||
| f0496a6f59 | |||
| aab3cac29c | |||
| 9561f841c4 | |||
| 32243aa383 | |||
| 13f3c13c0e | |||
| 92a1abbbee | |||
| 4b7fa0654c | |||
| f3710856ad | |||
| ef982b9ce2 | |||
| 52d92b7181 | |||
| e0e473ce06 | |||
| 9c92c5dbe4 | |||
| b65d3c85b6 | |||
| 71b7fc57f6 | |||
| 454f2520c3 | |||
| e1e219ae97 | |||
| af57ca3b05 | |||
| a98eeb7be6 | |||
| cc0f2ac37a | |||
| 842f1fb9c7 | |||
| 8b14c21a24 | |||
| 0f6ce6a1f4 | |||
| 7aaf9ae00d | |||
| e902373ce7 | |||
| 0ad7c4470b | |||
| 36a2d52f1c | |||
| d0756ff2af | |||
| 9fcea56fbf | |||
| 1b239b7119 | |||
| 83f94da43b | |||
| 0d5a0525cd | |||
| 4f07be2343 | |||
| 152a7410b6 | |||
| 9e4a21d934 | |||
| 6b107d4197 | |||
| d99f9c1c09 | |||
| 089360a3a5 | |||
| d7c2d6108f | |||
| b7e36feeeb | |||
| 658bf04d0b | |||
| b43ab783b0 | |||
| be90b4e0cc | |||
| b3895f717a | |||
| 77a5d82de4 | |||
| a7ac4b8deb | |||
| 9cd2225f8c | |||
| f2e7f8ec64 | |||
| 899c34ff63 | |||
| 79819a85d6 | |||
| e66b4e4a3d | |||
| 48c24186d1 | |||
| 965bb039be | |||
| d606d8f4f2 | |||
| a862d9a06d | |||
| c4d9e543e3 | |||
| 5104b507bb | |||
| cb5cecd0c2 | |||
| 77c793166c | |||
| e08533c634 | |||
| 39196efcb3 | |||
| cc9bef9706 | |||
| 9d38c6d44e | |||
| fb213e6ee5 | |||
| aafc681034 | |||
| 11dc235121 | |||
| cb510e13d1 | |||
| 784b16bd43 | |||
| c6c47aba22 | |||
| 3581b0bf1a | |||
| b5f5dae9e8 | |||
| d68fca8e51 | |||
| dc6e5bc48e | |||
| 12c15c6db0 | |||
| d21c4a58b4 | |||
| 652b158ca4 | |||
| 71da40c757 | |||
| 3cf9c71c27 | |||
| c1b69594e5 | |||
| 8e8a21349f | |||
| b7fb8fa434 | |||
| e3d02cdf40 | |||
| 3b18c4891c | |||
| 0862feeba8 | |||
| 34a7b46163 | |||
| 538979716d | |||
| ed21229bba | |||
| 1ec7da0f36 | |||
| 61732658f2 | |||
| 474d5d1340 | |||
| fdb4e54ff6 | |||
| bde62709b5 | |||
| d4aaa93047 | |||
| 4ce7081ace | |||
| 6f8e7fc720 | |||
| 422f3b1ce9 | |||
| 397e3998ff | |||
| cff96b23a8 | |||
| 40798d38c5 | |||
| 09ede557b1 | |||
| 1f15f7ff9a | |||
| a96784aa18 | |||
| 3a2ceab58a | |||
| 84499e43dd | |||
| 2e8ff36ef7 | |||
| 6430a62c86 | |||
| ec47f8644c | |||
| 8b3afbdf10 | |||
| 57b11629ce | |||
| 396eced36e | |||
| 66070e9bf6 | |||
| 97588fbcf4 | |||
| d7a98e7655 | |||
| 4804cca0ab | |||
| 0850b1edad | |||
| c2e5875f02 | |||
| 56de9072c0 | |||
| 341121da32 | |||
| 869c041846 | |||
| 879ab418fd | |||
| 2ffc77be3d | |||
| 2f8cc6e57b | |||
| a64ef36d06 | |||
| 85895d01eb | |||
| fa3d8c9720 | |||
| 80a8a1fde3 | |||
| bf5ce11ff1 | |||
| 4a10bdb91a | |||
| 74b73e6f39 | |||
| d287d9731e | |||
| 95c072f692 | |||
| 41f453d5a4 | |||
| ddcaf855fe | |||
| d943183994 | |||
| 2424b1d3f1 | |||
| a036200369 | |||
| 0ddceb78ba | |||
| b23fb0e635 | |||
| 98ebbd50a1 | |||
| c39eb3ca86 | |||
| 2278ec023f | |||
| 2afd05de98 | |||
| 1655050730 | |||
| 9a30c24654 | |||
| 727d8a2bf8 | |||
| cdcb5e0692 | |||
| 01991f4beb | |||
| 28212ab8f8 | |||
| 22d06bc3d1 | |||
| 167ce7829c | |||
| bb2dc991eb | |||
| 989b5d96c5 | |||
| 0ea1010e3f | |||
| 4f4f9e8eb3 | |||
| d32f16fef5 | |||
| 41660240fb | |||
| c160059612 | |||
| c055b20b93 | |||
| e1b251ee8f | |||
| e60117cabb | |||
| 3449f5e11c | |||
| 010bc76440 | |||
| 4b647602b3 | |||
| 9abdf5f4b3 | |||
| 903a3a9060 | |||
| 4541bd5369 | |||
| 94e4da9456 | |||
| 2f3c1ed169 | |||
| 3db115b52f | |||
| 96c4b283fa | |||
| 7dce9d6c8e | |||
| bc46b1371d | |||
| 4a09b9b1a0 | |||
| a08c6c9a00 | |||
| 9b4491df57 | |||
| e81e47e9c5 | |||
| 34739b71b3 | |||
| c80f803ba7 | |||
| 6132fa0cb9 | |||
| 586e177f98 | |||
| 695e6f2026 | |||
| 9bbde71964 | |||
| 7a5afd8597 | |||
| c6f707d95c | |||
| b0612f8cdf | |||
| ceccf2b1ca | |||
| 137b624008 | |||
| 632b9b9c27 | |||
| 819de185ef | |||
| 61abdeb3f7 | |||
| cc9267707a | |||
| c82ce7cecc | |||
| 00db7e5c93 | |||
| f0106c90a8 | |||
| edf24308fb | |||
| 705ffa89bc | |||
| 8cdcd189f5 | |||
| 9e26ebb9e5 | |||
| 7b085c8018 | |||
| 41d3b177ea | |||
| effe2149da | |||
| 9af74e6468 | |||
| ede9d557a3 | |||
| 0be08b7899 | |||
| 2b204fa756 | |||
| 2c78a47a94 | |||
| e599820383 | |||
| cc69e81dab | |||
| 7048fcc358 | |||
| b169dbd09d | |||
| f7c637a0d9 | |||
| a054b83b92 | |||
| 4eea1e0468 | |||
| 853f1b56e5 | |||
| bf2d65d7e9 | |||
| 7b551f0399 | |||
| fdbb166076 | |||
| 2fe133fa0e | |||
| 6a59b83d43 | |||
| 9a634a2056 | |||
| d0416d5f35 | |||
| 3e0f6b8520 | |||
| 6877e40b38 | |||
| 1cd20c65e2 | |||
| 4672f223c1 | |||
| 042f6f3789 | |||
| 718ba3edbf | |||
| 32d20f22ef | |||
| d3ce9792b5 | |||
| 2afa08e361 | |||
| 25c20f0629 | |||
| 786b8c80fd | |||
| 6c4e69a71d | |||
| ef79a0607b | |||
| fbdc104c12 | |||
| 34bbb9236e | |||
| 54d1cff546 | |||
| 4684d92758 | |||
| 75fb34934d | |||
| a1f2e1c8fd | |||
| dc6154f71f | |||
| b7cc19f983 | |||
| ee6a4bd244 | |||
| e7051d0289 | |||
| 9680f39203 | |||
| 11918fccbf | |||
| 53fb53e822 | |||
| ad31de5f78 | |||
| 6821dc27f5 | |||
| ef7e107443 | |||
| 60dcdbd181 | |||
| b732133184 | |||
| 611f0e2aba | |||
| 5a4f80621b | |||
| 606bd86e3a | |||
| 3253f7494e | |||
| 31a774a92a | |||
| a0d5e5ad72 | |||
| cf8cfd8b17 | |||
| e607f5c079 | |||
| 397f7050ef | |||
| e20e5e59b8 | |||
| 20e40a9a9c | |||
| da2673d35e | |||
| 5c8cd19477 | |||
| 2a19a3ced4 | |||
| 24d08857e8 | |||
| 329fcc8302 | |||
| 91c8233a71 | |||
| ee696c2122 | |||
| 3dfff739fa | |||
| 6d6746f5a4 | |||
| 74d65f6fda | |||
| 87cb659dc2 | |||
| 4e25f4b68c | |||
| 5ef05d1bb6 | |||
| 20e80ebb92 | |||
| 9c6b538176 | |||
| 5e629a3e5c | |||
| 0aacecbee5 | |||
| 3aacf7df6a | |||
| 3cb7d9e3fe | |||
| 02b1b5ac0c | |||
| e3de570f29 | |||
| 2e7f7ad477 | |||
| ed6db3e7b0 | |||
| 0ab8c2481b | |||
| 95c82d9968 | |||
| 1bfdeeeb16 | |||
| 418e4ffee8 | |||
| cbf49b303b | |||
| 7f135d6e55 | |||
| 02f21ad7c9 | |||
| e6023a7013 | |||
| 699b27cecc | |||
| 4707e0f858 | |||
| fc721b8ec8 | |||
| 2918f6bc07 | |||
| b27ff80c75 | |||
| 0e0dee3d3d | |||
| d22d0a8145 | |||
| c175369ff6 | |||
| 923adc3ea5 | |||
| 0e438942e4 | |||
| 44aa1285ee | |||
| 122d180f02 | |||
| f3340343ad | |||
| d514eef59b | |||
| 3a4e72e3e7 | |||
| 58d585e2a6 | |||
| 9a76df62dd | |||
| fe5416958a | |||
| 3b9e9ae0fd | |||
| 773ab21085 | |||
| eb62481766 | |||
| 6197fb07e1 | |||
| c9830dff57 | |||
| 192f9f0cb5 | |||
| e599555ddb | |||
| 328cce33b9 | |||
| 127682cc84 | |||
| 065db3b396 | |||
| c645b81890 | |||
| 2734307ba2 | |||
| 53fd5e0a5c | |||
| 5a30d3ed03 | |||
| 28493488ac | |||
| 0d2127f874 | |||
| ee741048e9 | |||
| 90f74d6847 | |||
| a92b4c04e9 | |||
| 8453d5bc48 | |||
| 542c0913d6 | |||
| 35e72692c1 | |||
| 4a49a11e73 | |||
| ee6d7ae6ba | |||
| bd86e70766 | |||
| 5d85a26be1 | |||
| ede7f9899c | |||
| 3b8993a302 | |||
| c412038db8 | |||
| 2ef6d3f93e | |||
| 5e7d2fd07d | |||
| 8edb73dc3a | |||
| 93900086e1 | |||
| 70f10782b0 | |||
| 8a92fada5a | |||
| ce2a79b63e | |||
| 2fb95b00a5 | |||
| 1867088e1a | |||
| a573e840db | |||
| 87e7b9c3f0 | |||
| ec35c0d933 | |||
| 2a48b199d2 | |||
| 02e780025d | |||
| 677ba36d55 | |||
| b23af6d436 | |||
| db798ea4f4 | |||
| 6ef11777e3 | |||
| a4fe14a3d3 | |||
| 660db94607 | |||
| aa8195565d | |||
| a6589e283b | |||
| 58175a5442 | |||
| 41b190930f | |||
| f28a392f71 | |||
| 8ad9ad578c | |||
| a4769239fa | |||
| c20f35b3e8 | |||
| 5a14a85f52 | |||
| 3054a4c307 | |||
| 70476bfb06 | |||
| b3292e1d22 | |||
| a34a69b4c4 | |||
| aa6af15cb5 | |||
| da70a45d22 | |||
| 57a216cb44 | |||
| 308562f939 | |||
| 64784be57e | |||
| f0e8d88178 | |||
| 5137b84ba8 | |||
| 216113e14b | |||
| a1adda36fa | |||
| 5d074ea998 | |||
| e9c4613368 | |||
| 3690f93302 | |||
| 97e1963674 | |||
| dd73b82ec2 | |||
| 8a5405060f | |||
| 83270d0983 | |||
| fd4343702f | |||
| 0483e8bd1b | |||
| 39cbdbd5c2 | |||
| 5af47c5951 | |||
| c447c251cd | |||
| 3a2ccd7521 | |||
| 8c92271804 | |||
| cd7b5e4dce | |||
| ecc3459d93 | |||
| cc6dce25ad | |||
| 87ecdd38e5 | |||
| fc79521dd3 | |||
| 7d8f1bef87 | |||
| 10c43bfa51 | |||
| f50b83b293 | |||
| f89357f3c8 | |||
| 1f43e69b4c | |||
| 670c5e2e1a | |||
| e097722ec6 | |||
| b54c50ba7a | |||
| 7b1a084d39 | |||
| 6477de8c4f | |||
| 5c0a75071c | |||
| 391eee4289 | |||
| 2d6670cfe5 | |||
| 2cf546accd | |||
| ffa8e5ff62 | |||
| 84f99b6d6b | |||
| eb33e8ae11 | |||
| 5af0cb2844 | |||
| 26255b79db | |||
| f6e6f10716 | |||
| b5ca3219a1 | |||
| fb1d4109a9 | |||
| a2e86ebec5 | |||
| c6b637e5a5 | |||
| 0c9d640683 | |||
| db63c947b8 | |||
| 649f363917 | |||
| 6ad4a95cc6 | |||
| d652cc8ea4 | |||
| 989bffee81 | |||
| cd9cf9f52f | |||
| d3a9d509a8 | |||
| 380cf8691a | |||
| 62e48e7701 | |||
| 5e81848445 | |||
| e047d99a6c | |||
| d8ad337c0e | |||
| 391b6ed515 | |||
| d64f762277 | |||
| 4d3ba5087d | |||
| aba1acea9c | |||
| 9502f0aadf | |||
| 564c31c54d | |||
| 6aa0c9d694 | |||
| e726a82cc3 | |||
| dd1f5f6a11 | |||
| f08799f7ff | |||
| dffee38dc6 | |||
| fe542deb89 | |||
| 8aa13b51f4 | |||
| c16fe3c810 | |||
| 635d28cd65 | |||
| f915eed0f4 | |||
| 87994ebfba | |||
| 0b2281967b | |||
| fc9e7a3a3b | |||
| 884b0291f7 | |||
| 8d8b3241d1 | |||
| 272bbdb4d2 | |||
| 168183201a | |||
| aedd70f5fa | |||
| f9b46b46b1 | |||
| 983c7a9c91 | |||
| 48a9f05efb | |||
| f0a0f0677f | |||
| 35cd98c7a7 | |||
| 8b2f325cd0 | |||
| 4d70cb20e7 | |||
| 8e55b6618e | |||
| 7e75f7559a | |||
| 8ad1c1d8a9 | |||
| fb03db8980 | |||
| 11d5e4b6ca | |||
| 8db6060089 | |||
| 07625336fd | |||
| 35fad4d5a7 | |||
| 0f67e93a0f | |||
| 628a5764cc | |||
| 7cfc5b085e | |||
| fb3c6365e1 | |||
| 2c69dd7c93 | |||
| 1d6e947387 | |||
| c26637de53 | |||
| d1ecb32652 | |||
| 4b14ec53f1 | |||
| f6046477b4 | |||
| 2cdd50b9e9 | |||
| bb541eeb60 | |||
| 8866b3170e | |||
| 174cb1876a | |||
| 955f164efb | |||
| d939820918 | |||
| 12f8357373 | |||
| cbe0e94ca7 | |||
| 079d1ca870 | |||
| 41903e8f09 | |||
| 6906125725 | |||
| 11fbb86f8b | |||
| cfdd48b2a3 | |||
| 2cef299775 | |||
| 02e291d4e8 | |||
| 02d6471c88 | |||
| 02633d4b01 | |||
| 95176fc813 | |||
| 8571c35e77 | |||
| a84862897a | |||
| 2781f82d29 | |||
| f809f503c9 | |||
| 4170434b96 | |||
| 65e8c2ffde | |||
| c239964427 | |||
| 21bdc8c5b6 | |||
| 39abb4f50c | |||
| 93105966b6 | |||
| 2e4b4b94ed | |||
| bad963ddbc | |||
| 9ecf98195c | |||
| 1476ebdfe6 | |||
| e25fd47828 | |||
| d559a9ac0d | |||
| e8394c2b01 | |||
| 3ec1c894ee | |||
| fb3e3c8447 | |||
| 496f8151c9 | |||
| 55f5d4affa | |||
| d22c8832f7 | |||
| d8138d2c56 | |||
| 6c00eb9344 | |||
| b0e24b346e | |||
| 822a1b1003 | |||
| 3d5f99e14a | |||
| 0e8f62b480 | |||
| d70c4d7bbe | |||
| 05df6c5b21 | |||
| 3f6036a512 | |||
| 58f42f1af1 | |||
| 0ef95d8fe6 | |||
| ea677389ad | |||
| 057e4603db | |||
| a67aed9538 | |||
| 00068158c1 | |||
| 9e4cf19e0c | |||
| 84c85a4605 | |||
| c02ba17845 | |||
| f4b30c5861 | |||
| 5d9e400e86 | |||
| 39914c8eb4 | |||
| 7133357b1a | |||
| 629f9863ae | |||
| be57c66256 | |||
| e0edd7a290 | |||
| d46912fcdf | |||
| 5c7484cea2 | |||
| d525d23217 | |||
| c030cfe0ad | |||
| cb633e4b6a | |||
| 16afa277de | |||
| c18e9d9503 | |||
| a490b2ff22 | |||
| f32a30fb9a | |||
| 0f60fb06e3 | |||
| 01bd8bd9fa | |||
| 489a6ffd16 | |||
| f89d783308 | |||
| 1d6bd3cc5e | |||
| ea31a29f8a | |||
| 205dd8a1e5 | |||
| 8caac162b2 | |||
| 970b30b467 | |||
| 746569b471 | |||
| 20869a0aec | |||
| 88ec04e5ca | |||
| 33a8a398fe | |||
| d887c77a1b | |||
| 60c280a521 | |||
| 837c02ffd6 | |||
| 6b94e08404 | |||
| 1f471aa9f9 | |||
| 951c321ba6 | |||
| eabea6ea16 | |||
| 14649ce611 | |||
| c6377b93d5 | |||
| 5a6c25887a | |||
| 0e44a3625c | |||
| 476dc6e783 | |||
| 4ad2e5f9b5 | |||
| 2a28e88bcf | |||
| 44c833fbe6 | |||
| 026f019f58 | |||
| 451d422b8a | |||
| 808977f69a | |||
| 402a10c488 | |||
| 0caa1fd40b | |||
| 754d70d513 | |||
| eb3a11b49a | |||
| 916b33f714 | |||
| 58c5003ad5 | |||
| 0ca01641ff | |||
| 0fc7dade47 | |||
| ab4c9581ad | |||
| 6e474f22a2 | |||
| 068bd57fbc | |||
| d7f9cdf6b6 | |||
| a503c1af97 | |||
| 53a14381ba | |||
| 169b9161b9 | |||
| 85f2b46fe9 | |||
| 0dfa1e192d | |||
| 88eb0dcdfc | |||
| bb8a82030f | |||
| 16a6fc7d2c | |||
| 1ebf88abbb | |||
| 93e9f29c77 | |||
| 1b7271359e | |||
| 49df0a5d33 | |||
| 46f8723314 | |||
| 5f02de1c95 | |||
| 9d938cdd58 | |||
| e5fd0f5d75 | |||
| a3f9d5e707 | |||
| 5344679c7c | |||
| e09adbd13d | |||
| 275f9d6aaf | |||
| 9461067fdb | |||
| 7623770613 | |||
| 584278bf20 | |||
| 1ec0add76f | |||
| 51dff22b93 | |||
| c85c4a969d | |||
| 6a8a6e530b | |||
| ce4f4995b5 | |||
| a4260e54fe | |||
| f074ead7f6 | |||
| b819137e35 | |||
| 4d653caca3 | |||
| 75663774fe | |||
| 5ec5b398ac | |||
| 24c70a04ca | |||
| a602f70bf4 | |||
| 5733124c40 | |||
| 5216532e96 | |||
| c8bead6bdd | |||
| 72cec5608d | |||
| 8b1262b198 | |||
| 6e0a214bcc | |||
| 1ab19920f4 | |||
| 751d51c4d0 | |||
| 4a54e262f6 | |||
| bd0c325762 | |||
| de55f99174 | |||
| 044cf8da1a | |||
| aa57642103 | |||
| d98ed8f419 | |||
| 4b07f4ffc5 | |||
| 5a526a89aa | |||
| 3dbf863255 | |||
| 17f0cffca6 | |||
| d51e60cf8b | |||
| 85d6db1de1 | |||
| 1bf794c29f | |||
| 0e8f7a4542 | |||
| b72fe81e28 | |||
| a76889959f | |||
| 0166486e07 | |||
| bb793e5582 | |||
| a55c095d1b | |||
| 3d47d912fd | |||
| cc02d94bdf | |||
| 5121cc25a4 | |||
| e78d91104c | |||
| 38c5c79218 | |||
| b065f973c4 | |||
| 13609c4f09 | |||
| a93116aa19 | |||
| 95a5c7d4cc | |||
| 5d0136a4b6 | |||
| 2c74b4f1ac | |||
| 6bb8d87225 | |||
| 935ce8f968 | |||
| 70f994cda5 | |||
| 3970bb5955 | |||
| 3159453e75 | |||
| a1cb8d7ae7 | |||
| 4191c195c1 | |||
| b16ce6f809 | |||
| 88ba962a4c | |||
| 0315d15ce8 | |||
| 12681f4623 | |||
| a7a4f9373d | |||
| d2e66214f4 | |||
| 0a6d98b5e1 | |||
| 497c10e513 | |||
| 53765ebc62 | |||
| 4216627604 | |||
| 47c33f3b31 | |||
| 32359da1cc | |||
| f4e085c121 | |||
| 7972937072 | |||
| 5a6f2467f8 | |||
| 1822347a46 | |||
| 821ba8b701 | |||
| fdced53be1 | |||
| a394bf25b2 | |||
| f2c1c9f70e | |||
| 5199364091 | |||
| 50caef0086 | |||
| 8a04d8e2b7 | |||
| e7032bc2c2 | |||
| d128ef1b97 | |||
| 0645908762 | |||
| abbd0558a0 | |||
| c725ee84bb | |||
| a9b4e7819f | |||
| ae68deb4f8 | |||
| e4108d089f | |||
| 4d9d50c9ac | |||
| b727cbbfe9 | |||
| 864338a881 | |||
| 6dc444d2d1 | |||
| 13fcccefd5 | |||
| 30e8eac46e | |||
| 646e1f541c | |||
| a7c15ef598 | |||
| bddb03ba3b | |||
| 2ac1f37b02 | |||
| a96f10b6aa | |||
| ccf6b5ff68 | |||
| 0d661204ed | |||
| b0e50f13c9 | |||
| d3ad253b51 | |||
| 5ac23a2f8f | |||
| 9fff694382 | |||
| 4512326fe8 | |||
| bfb17a2fb5 | |||
| 53c124526c | |||
| 8007097aae | |||
| 32e5ed5ad8 | |||
| 65afbd4147 | |||
| 81e04ee185 | |||
| 52722dc0c8 | |||
| b9c270fab6 | |||
| 48db481fbb | |||
| 37cacd27b1 | |||
| 466f541798 | |||
| 9781af5696 | |||
| f6d5e8031f | |||
| c70ea4a621 | |||
| 76ec6e4da2 | |||
| cd2825288d | |||
| d95fdda30f | |||
| 4fdcf604f2 | |||
| 02c9007765 | |||
| 0f54830bc5 | |||
| d329fe0c12 | |||
| a7ce852ca5 | |||
| b4fce37c14 | |||
| 51181c8c8b | |||
| 1c07ae9172 | |||
| 2f8cbb3a9d | |||
| 093af6af0b | |||
| 0567073ca0 | |||
| e33eb9d7b0 | |||
| fd10ddf86d | |||
| edd4d47929 | |||
| f31b9ad98b | |||
| 10ee3ea346 | |||
| 62b7eda9e9 | |||
| 8b7984cf7d | |||
| 4a0e07a54c | |||
| 6e520c8476 | |||
| 917a8ed389 | |||
| 86bba4ff0e | |||
| 300799fdc8 | |||
| 65e36e02fb | |||
| 09dd3c1b37 | |||
| 36233538fd | |||
| 3d5b3d1e8c | |||
| 3c2ae8250f | |||
| 6a95abb01f | |||
| 4c6fce5d5c | |||
| 08b5225a13 | |||
| 765b5ee826 | |||
| a40a34d2e8 | |||
| 983ee2d39b | |||
| e1255af708 | |||
| b99d476754 | |||
| 23ab896dfc | |||
| d094a09ded | |||
| 3f8ee533d3 | |||
| 0c3c84d711 | |||
| 79c53a41a8 | |||
| 2ffa13c993 | |||
| 8af48bbe48 | |||
| 65c0772d37 | |||
| 78ab347171 | |||
| d83b94d231 | |||
| ed6c46f7ff | |||
| 925e19b15c | |||
| 2be71fc2ec | |||
| bc2ee8dce8 | |||
| 1deef77f07 | |||
| e00c57bc47 | |||
| da3ba12560 | |||
| f68b89b7d9 | |||
| c944aafb39 | |||
| 0e6c9820cd | |||
| b8d1838dcc | |||
| aba535b589 | |||
| cf117b1a4d | |||
| 1bae570b68 | |||
| 1f0e263b6e | |||
| 08706055af | |||
| 28bcf074fc | |||
| 1c8aaf97bc | |||
| a891597f4c | |||
| e3805d5920 | |||
| 3e6be197e6 | |||
| 0d5fc26841 | |||
| df47e17c8e | |||
| e53fa1d873 | |||
| d5152a0e59 | |||
| 78e04dee99 | |||
| b3d117f8c1 | |||
| cab77e83da | |||
| b4068823ed | |||
| a694cf3079 | |||
| 3c09613d01 | |||
| 36d336e69c | |||
| 4270d77692 | |||
| ec6c5519a5 | |||
| a06fe1d02e | |||
| 56ba87577b | |||
| cdb29be4f3 | |||
| 4ef9732e37 | |||
| f2f4e55818 | |||
| 403ac53a9e | |||
| cdcda943be | |||
| 2c25241763 | |||
| 17729365db | |||
| 5d5dc1b544 | |||
| 244c7e019c | |||
| a7fea4fc69 | |||
| 809925dc3e | |||
| 98c835e470 | |||
| 8ac4845930 | |||
| 765f23febc | |||
| f1b70b3340 | |||
| 549dfc9781 | |||
| 2019379a42 | |||
| 15335509c2 | |||
| da401acdb2 | |||
| 8327f22f6f | |||
| 6154cfce99 | |||
| c13c039721 | |||
| 7ee417ab05 | |||
| 3a95f81196 | |||
| 9a19a00bdc | |||
| 24308aec6c | |||
| 6b4b259753 | |||
| bf77bc47d1 | |||
| 2bde0b40bb | |||
| 478f7b8e49 | |||
| f289dffc48 | |||
| d119ed058b | |||
| fdb6f0fe84 | |||
| bef02b3511 | |||
| fcd9b525a8 | |||
| 590d8f4043 | |||
| 406e2f84eb | |||
| 926e2f7939 | |||
| b92a009539 | |||
| cfab1c4649 | |||
| fc03ee94e2 | |||
| 936c8cce4b | |||
| 1f2145a45d | |||
| 2331678312 | |||
| c216ece72c | |||
| 36e12110d5 | |||
| aa5ac1518b | |||
| d472c05f5d | |||
| 485fc2b2b7 | |||
| bdc83f4f37 | |||
| da178c9fba | |||
| a1dc390f49 | |||
| dfe63f87c3 | |||
| 239d4afb13 | |||
| ab2c184b54 | |||
| 31ede315f2 | |||
| 3992ac02bb | |||
| e6ad26f03c | |||
| 2f335372a0 | |||
| 63d678ce29 | |||
| 0c675c33e2 | |||
| 3c8d83f2a8 | |||
| b11ed32bcf | |||
| 9a63ee65c9 | |||
| 8b8742b242 | |||
| bccbc0f064 | |||
| b7fcd5b02a | |||
| 56b9dda60b | |||
| 1868d0e7a3 | |||
| 38b3433406 | |||
| 6d21823959 | |||
| 02eb56a696 | |||
| 6fe5c06fa0 | |||
| 2c68e813e9 | |||
| e42c7a38a5 | |||
| 7b5b1b2583 | |||
| 0578f45490 | |||
| f46f7bd528 | |||
| 945cc2117f | |||
| a5db4310c6 | |||
| d25205d9d3 | |||
| d12c700bbf | |||
| db70ad37dd | |||
| 9e1115f899 | |||
| 82f4b4ee53 | |||
| 4ff2efea43 | |||
| d2a3c051e5 | |||
| 16d3825df4 | |||
| 602b17f0e8 | |||
| 488b2888a8 | |||
| 1480b8911f | |||
| 72ef7f6557 | |||
| f35afed89a | |||
| ffe6494147 | |||
| 342a4c1b17 | |||
| b904689a98 | |||
| 0dc66b3dd7 | |||
| bb1282de30 | |||
| c5e4cf35c0 | |||
| 2529a7700e | |||
| 7e2806119b | |||
| 536e31d771 | |||
| 2a39449f6e | |||
| 7af04798fb | |||
| 76e25f75fa | |||
| 7b894a7c61 | |||
| d8a1d84a49 | |||
| bb8d11a57b | |||
| e811e3975b | |||
| 68261e0308 | |||
| d03e8d05ec | |||
| 3f2815e30c | |||
| 91b01c2fcc | |||
| 179063c863 | |||
| 28eb80e27f | |||
| c0d37b2e04 | |||
| 0dbd0478c0 | |||
| 56b41c882b | |||
| 8c3cce822a | |||
| b87d4a3e5f | |||
| cec60feba9 | |||
| 29c0c4801c | |||
| a3738dc131 | |||
| 6d0c0aee7d | |||
| 1b290b577d | |||
| 85c7e1b059 | |||
| a8de7e9ffc | |||
| bc82bff4b4 | |||
| ff091e940c | |||
| 55a964267e | |||
| d14608356d | |||
| 7fca5a7a89 | |||
| ac5926bdfe | |||
| b16cf57510 | |||
| 851c842529 | |||
| a1080fdb2d | |||
| 344feb7484 | |||
| 567c17cc9e | |||
| 0ee54f1117 | |||
| 69f1187722 | |||
| 39426789f4 | |||
| 49c3a81e18 | |||
| fa0196b987 | |||
| 44477a0d47 | |||
| 510ce16f0e | |||
| 1e7c5bb9b7 | |||
| 850fa5aecc | |||
| 79a9d2112a | |||
| d25d8187b6 | |||
| e47de5deed | |||
| 52b8c0e078 | |||
| 3c7f7beb6d | |||
| ee7d7c6f24 | |||
| a66ef1b778 | |||
| b47597b813 | |||
| d6ff01d63c | |||
| a3e24b6854 | |||
| fcb769e353 | |||
| ce63503bab | |||
| 815c3dc73f | |||
| efe7092995 | |||
| 12ddd30f67 | |||
| 879ddb208b | |||
| 70dab7d920 | |||
| 2840e32853 | |||
| 320494c83d | |||
| e6fba5ba82 | |||
| 5255c236c3 | |||
| e5d4b35a32 | |||
| b4e65a8840 | |||
| ac78841e55 | |||
| 54914a970e | |||
| ea2a1651d5 | |||
| 5c6e95f921 | |||
| 555e21c3c7 | |||
| 0fdfe025cb | |||
| 930fda07c9 | |||
| 41dcd5bc29 | |||
| d7546e09ee | |||
| e9577db9c2 | |||
| cdc7b2a000 | |||
| a7084b4d6c | |||
| 64212176ec | |||
| 70eb226fea | |||
| c18d868d03 | |||
| 9002bfb9a0 | |||
| 26143750f3 | |||
| 3c11f8f26b | |||
| dcec112b91 | |||
| 7b0de551e1 | |||
| d41331d948 | |||
| 1e5d6b0e34 | |||
| 1363d5d209 | |||
| f1a487f606 | |||
| fca9c1458b | |||
| 69bad31019 | |||
| 17954dd8fe | |||
| 7b21e3be72 | |||
| 7adcf6d3e5 | |||
| bec6acc01e | |||
| 1b9647f57e | |||
| 2d1805c983 | |||
| 1f265af1e7 | |||
| 3ddc61420b | |||
| b10de6f4e7 | |||
| 7185ff25be | |||
| f2e0f9cca5 | |||
| 55c66022eb | |||
| b26df187e6 | |||
| 312100e1c6 | |||
| f51f6e00c4 | |||
| 9e13a2271c | |||
| 6887ae18ae | |||
| 2336aa0e4f | |||
| 3cc1065873 | |||
| 38521e0009 | |||
| 20fc585b5e | |||
| 7b23c8dc75 | |||
| b0fb8aa4be | |||
| b9a32185d7 | |||
| 0f880177e4 | |||
| 7683252896 | |||
| ca9a1de44c | |||
| 2445576ae8 | |||
| 7648f071f1 | |||
| 60c93595f5 | |||
| 70998d25e3 | |||
| fa908040ca | |||
| 73a4e87379 | |||
| 3a31ad55fb | |||
| d1f7935ee2 | |||
| b19755a313 | |||
| 9a139a7604 | |||
| 373ff66240 | |||
| babd3949f6 | |||
| 3521472942 | |||
| dc045591e4 | |||
| 9ea71dd94f | |||
| 7a4cac84ac | |||
| 43d0350870 | |||
| c98c115cb6 | |||
| 0e4ac63b6b | |||
| 4bdd8b2502 | |||
| ffcff4aea1 | |||
| 56b15f558c | |||
| 6ea9c9218d | |||
| b6c0e7c302 | |||
| bdcb9d0c00 | |||
| 7a93966158 | |||
| b8adbee4ee | |||
| feae79b417 | |||
| bcf9546b2d | |||
| 273cb928bf | |||
| 7735639e57 | |||
| 23c524812d | |||
| c6ca89907c | |||
| 87a75c6100 | |||
| f6100ed834 | |||
| 21a9434f89 | |||
| ea6e239d58 | |||
| 4ee4992330 | |||
| 059ecdb50b | |||
| 0838d4507a | |||
| 5cda797531 | |||
| 308a21e0e2 | |||
| a0a92587b4 | |||
| 8e49ab9179 | |||
| ac1d931b5e | |||
| 90c7fab452 | |||
| a4b985cd96 | |||
| 6e9e81a890 | |||
| d7dff7d7a6 | |||
| 37b7a49faf | |||
| 05d7c12d38 | |||
| f983d19e01 | |||
| 4a0749f811 | |||
| e2fd78b510 | |||
| 7560b6b0a7 | |||
| 824b101831 | |||
| e1c2657b11 | |||
| d3588d2c95 | |||
| c5c945f0c3 | |||
| 022713996a | |||
| d2c7f23ec9 | |||
| 232d1e2ca8 | |||
| 401e897019 | |||
| 61f7009378 | |||
| 43b91b5938 | |||
| e2f25d1c92 | |||
| 56490400ca | |||
| b15cb08f54 | |||
| 9b015a2975 | |||
| b09a3840eb | |||
| 495510a02e | |||
| ea606ef80d | |||
| 27493c3d75 | |||
| cc07d511a5 | |||
| 5b3ec4fb7c | |||
| 18da8fe44d | |||
| 211248b50e | |||
| 969f0c535e | |||
| a7ce66856b | |||
| 3b42f295d6 | |||
| b8febdd440 | |||
| f8795bcd72 | |||
| 53301289f5 | |||
| 51896050ed | |||
| 81ca7a1bfd | |||
| 91c817d9dd | |||
| 88b9f96b91 | |||
| b2d5ad6904 | |||
| 20f086dc37 | |||
| 6fa93f243f | |||
| 15e31d1c03 | |||
| a787a7ce72 | |||
| 989d132423 | |||
| 757fc01b78 | |||
| 353d7cede0 | |||
| fb0add070b | |||
| 96b42ed86f | |||
| 2dde4dce12 | |||
| c7ff207017 | |||
| 23820a369e | |||
| 24d4eaf65d | |||
| e0b05e573e | |||
| e2b9efaf49 | |||
| 349eb371c6 | |||
| afe3ba40cf | |||
| 5e618a1ca4 | |||
| d011332647 | |||
| bc73e9c4e3 | |||
| e609ec1df6 | |||
| 2073ca8d38 | |||
| a6f2c1be8a | |||
| 18e9714273 | |||
| fa18991917 | |||
| b0b342a020 | |||
| 8e604fd3db | |||
| abaad22eb4 | |||
| ac040b5197 | |||
| 9b1a18d9a3 | |||
| a20c7735e8 | |||
| c94822a2a1 | |||
| 2124b63982 | |||
| 886c7bf634 | |||
| 56825e9ed0 | |||
| 925ba2199e | |||
| fd8650b8a0 | |||
| 549455b3df | |||
| f90a5b5b71 | |||
| 5c76297e5f | |||
| cabf8631d4 | |||
| 6ae8fbc0e4 | |||
| f32a277643 | |||
| 09df77b56e | |||
| f5e58e0125 | |||
| 660ab53476 | |||
| 5c9f2c0d50 | |||
| d036afee5b | |||
| 4ab7786828 | |||
| 981cabe857 | |||
| 8eef122cec | |||
| 1dc1655891 | |||
| 0bc942f4d5 | |||
| 9fbf9abd47 | |||
| b8170df498 | |||
| d76a8bd34a | |||
| 021faf68b3 | |||
| 7c264ad097 | |||
| 810fdf3cca | |||
| c301b30c3a | |||
| 735b4181fa | |||
| a14fecaf78 | |||
| e12b06a9ad | |||
| 9a82875ad4 | |||
| 0b0ee921a5 | |||
| 7109a40637 | |||
| 0a805feeec | |||
| 9fdb6862f8 | |||
| e53ae5f6d5 | |||
| 0ad1044b2e | |||
| 64c53fe37b | |||
| faa93c3739 | |||
| 0e6272e6d8 | |||
| c363261d00 | |||
| a2500ff814 | |||
| 2af6e8cd16 | |||
| eb1e88b38c | |||
| c81549a441 | |||
| adf42c8750 | |||
| 2ee8e17ac0 | |||
| f7469412f1 | |||
| 55a72c86cf | |||
| a80eb397d5 | |||
| 7926362ab5 | |||
| 7af51ff346 | |||
| c8ca362eba | |||
| 4964c17abb | |||
| 0c6eee6d81 | |||
| 950f00fae6 | |||
| d8628170b5 | |||
| 68338dace1 | |||
| af1f87a00f | |||
| 9a47e79e8e | |||
| aceaba0fb0 | |||
| e0887d81aa | |||
| ff9e4e0780 | |||
| 6a4f61d3a3 | |||
| c8da17c664 | |||
| 7c34a89ec5 | |||
| da4cddf1ef | |||
| 9262c0895f | |||
| b5405c35e2 | |||
| 0137a271cc | |||
| 5d8af58e57 | |||
| c054cb3dd0 | |||
| 8640a89323 | |||
| ea72975e69 | |||
| 7237c1f54c | |||
| 92ed7e694f | |||
| ffe24cdfaa | |||
| 04dfe4512f | |||
| a95205905e | |||
| 55347aeab6 | |||
| 945db17cb8 | |||
| e48d59b07b | |||
| aff4d53d7e | |||
| 5bb604248f | |||
| 7e63135a3d | |||
| 3092286604 | |||
| d42ff6ce19 | |||
| 26f965e251 | |||
| 34a4b2ab37 | |||
| 9c1159837a | |||
| 147c96970c | |||
| e7e1b46b36 | |||
| 299dc525d0 | |||
| 5a69f41f4d | |||
| c31b2b65c1 | |||
| 8937c5be86 | |||
| 54883b0795 | |||
| 39a77a855e | |||
| 4c10d4dd2f | |||
| f32048808a | |||
| 86c8b11102 | |||
| 8c425ff9d8 | |||
| 1b44123551 | |||
| 306cf7a5f5 | |||
| dd913de1a2 | |||
| 9eaa98675b | |||
| 6f13d0cfbc | |||
| 543ef3fb32 | |||
| 60172a7801 | |||
| 998cfb6528 | |||
| 3e9c2a06a3 | |||
| 0115b18e67 | |||
| ef9498b03a | |||
| 8eb7d0aaa8 | |||
| 12bde7434a | |||
| 23dbd00d40 | |||
| f8bae86082 | |||
| acecff23f4 | |||
| 7ce6f4de0d | |||
| 78b2385785 | |||
| e0b38cf3cc | |||
| 74194cd38c | |||
| d4dbf0042e | |||
| e36eefc060 | |||
| cb01d245e6 | |||
| 0d16361a40 | |||
| 70543c2b8a | |||
| 04bad157f5 | |||
| 357646466a | |||
| 11d9838faa | |||
| 9680c039f0 | |||
| 9f63498a64 | |||
| aa20e5b5e3 | |||
| c9d4816a88 | |||
| 3feeced884 | |||
| edc4b4039b | |||
| a5ad05f274 | |||
| a41874b6a7 | |||
| a37211cb83 | |||
| 4e802921a5 | |||
| c6d8895b70 | |||
| 53d6e4000c | |||
| a192e726d4 | |||
| 886fe5cc31 | |||
| 23b2b599a7 | |||
| c734708809 | |||
| 1c0f35a945 | |||
| 06a3873c9b | |||
| 7a2be102aa | |||
| 07979ce2de | |||
| d1afad47aa | |||
| 15dc9cfaf4 | |||
| 7c706d9871 | |||
| 0a9642e776 | |||
| 20fb899d5d | |||
| 38d4fbc863 | |||
| b6010afa9c | |||
| 234cd0c4ff | |||
| a510d2593f | |||
| 0aa958de8f | |||
| 07950b7a58 | |||
| 710554efcd | |||
| b14519b1f5 | |||
| da7347f76f | |||
| 88c9715fb0 | |||
| bf990504b0 | |||
| 9175ad64ff | |||
| 45a694b64f |
@@ -0,0 +1,26 @@
|
||||
# automatic eol conversions
|
||||
* text=auto
|
||||
|
||||
*.c text
|
||||
*.cc text
|
||||
*.cpp text
|
||||
*.h text
|
||||
*.hpp text
|
||||
*.txt text
|
||||
*.pl text
|
||||
*.sql text
|
||||
*.xml text
|
||||
*.yaml text
|
||||
*.conf text
|
||||
*.resx text
|
||||
*.cs text
|
||||
*.ini text
|
||||
*.settings text
|
||||
*.html text
|
||||
*.css text
|
||||
*.js text
|
||||
*.types text
|
||||
|
||||
*.vcproj text merge=union
|
||||
*.csproj text merge=union
|
||||
*.sln text merge=union eol=crlf
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
# Object files
|
||||
*.o
|
||||
*.obj
|
||||
|
||||
# Libraries
|
||||
*.lib
|
||||
*.a
|
||||
|
||||
# Shared objects (inc. Windows DLLs)
|
||||
*.dll
|
||||
*.so
|
||||
*.so.*
|
||||
*.dylib
|
||||
|
||||
# Executables
|
||||
*.exe
|
||||
*.out
|
||||
*.app
|
||||
|
||||
# CMake
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
install_manifest.txt
|
||||
Build/
|
||||
build/
|
||||
Build32/
|
||||
build32/
|
||||
Build64/
|
||||
build64/
|
||||
Build_32/
|
||||
build_32/
|
||||
Build_64/
|
||||
build_64/
|
||||
log/
|
||||
logs/
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
language: cpp
|
||||
compiler: gcc
|
||||
before_install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -y libmysqlclient-dev libperl-dev libboost-dev liblua5.1-0-dev zlib1g-dev
|
||||
script:
|
||||
- cmake -G "Unix Makefiles" -DEQEMU_BUILD_TESTS=ON -DEQEMU_ENABLE_BOTS=ON
|
||||
- make
|
||||
- ./bin/tests
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- stable
|
||||
notifications:
|
||||
email: false
|
||||
irc:
|
||||
channels: "irc.eqemulator.net#eqemucoders"
|
||||
os: linux
|
||||
+354
@@ -0,0 +1,354 @@
|
||||
#EQEmu CMake
|
||||
#Variables used:
|
||||
#EQEMU_DISABLE_CRT_SECURE_WARNINGS
|
||||
#EQEMU_FAST_FLOATINGPOINT
|
||||
#EQEMU_ENABLE_CRASH_LOGGING
|
||||
#EQEMU_DISABLE_SAFESEH
|
||||
#EQEMU_BUILD_MSVC_MP
|
||||
#EQEMU_DEBUG_LEVEL
|
||||
#EQEMU_LOG_LEVEL_STATUS
|
||||
#EQEMU_LOG_LEVEL_NORMAL
|
||||
#EQEMU_LOG_LEVEL_ERROR
|
||||
#EQEMU_LOG_LEVEL_DEBUG
|
||||
#EQEMU_LOG_LEVEL_QUEST
|
||||
#EQEMU_LOG_LEVEL_COMMANDS
|
||||
#EQEMU_LOG_LEVEL_CRASH
|
||||
#EQEMU_STREAM_SEND_RATE
|
||||
#EQEMU_STREAM_DECAY_RATE
|
||||
#EQEMU_STREAM_RETRANSMIT_TIMEOUT_MUL
|
||||
#EQEMU_STREAM_RETRANSMIT_TIMEOUT_MAX
|
||||
#EQEMU_STREAM_AVERAGE_DELTA_MAX
|
||||
#EQEMU_STREAM_RETRANSMIT_ACKED_PACKETS
|
||||
#EQEMU_DEPOP_INVALIDATES_CACHE
|
||||
#EQEMU_ENABLE_BOTS
|
||||
#EQEMU_DISABLE_LOGSYS
|
||||
#EQEMU_COMMANDS_LOGGING
|
||||
#EQEMU_BUILD_SERVER
|
||||
#EQEMU_BUILD_LOGIN
|
||||
#EQEMU_BUILD_TESTS
|
||||
#EQEMU_BUILD_PERL
|
||||
#EQEMU_BUILD_LUA
|
||||
#EQEMU_SANITIZE_LUA_LIBS
|
||||
#EQEMU_BUILD_CLIENT_FILES
|
||||
#EQEMU_MAP_DIR
|
||||
|
||||
#We set a fairly new version (as of 2013) because I found finding perl was a bit... buggy on older ones
|
||||
#Can change this if you really want but you should upgrade!
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
#FindMySQL is located here so lets make it so CMake can find it
|
||||
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/" ${CMAKE_MODULE_PATH})
|
||||
|
||||
#Our project name is EQEmu
|
||||
PROJECT(EQEmu)
|
||||
|
||||
#Default build type is set to RelWithDebInfo for generators that honor that like makefiles
|
||||
IF(NOT CMAKE_BUILD_TYPE)
|
||||
SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build." FORCE)
|
||||
ENDIF(NOT CMAKE_BUILD_TYPE)
|
||||
|
||||
#Add our various windows definitions
|
||||
IF(MSVC OR MINGW)
|
||||
ADD_DEFINITIONS(-D_WINDOWS)
|
||||
IF(CMAKE_CL_64)
|
||||
ADD_DEFINITIONS(-DWIN64)
|
||||
ELSE(CMAKE_CL_64)
|
||||
ADD_DEFINITIONS(-DWIN32)
|
||||
ENDIF(CMAKE_CL_64)
|
||||
ENDIF(MSVC OR MINGW)
|
||||
|
||||
IF(MSVC)
|
||||
#Set our default locations for zlib/mysql based on x86/x64
|
||||
IF(CMAKE_CL_64)
|
||||
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x64")
|
||||
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x64")
|
||||
SET(LUA_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/luaj_x64")
|
||||
ELSE(CMAKE_CL_64)
|
||||
SET(ZLIB_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zlib_x86")
|
||||
SET(MYSQL_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/mysql_x86")
|
||||
SET(LUA_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/luaj_x86")
|
||||
ENDIF(CMAKE_CL_64)
|
||||
|
||||
#disable CRT warnings on windows cause they're annoying as shit and we use C functions everywhere
|
||||
OPTION(EQEMU_DISABLE_CRT_SECURE_WARNINGS "Disable Secure CRT Warnings" ON)
|
||||
IF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
|
||||
ENDIF(EQEMU_DISABLE_CRT_SECURE_WARNINGS)
|
||||
|
||||
#fast FP if you'd like it
|
||||
OPTION(EQEMU_FAST_FLOATINGPOINT "Use MSVC /fp:fast option" ON)
|
||||
IF(EQEMU_FAST_FLOATINGPOINT)
|
||||
ADD_DEFINITIONS(/fp:fast)
|
||||
ENDIF(EQEMU_FAST_FLOATINGPOINT)
|
||||
|
||||
#crash logging currently only works on windows x86/x64
|
||||
OPTION(EQEMU_ENABLE_CRASH_LOGGING "Enable crash logging" ON)
|
||||
IF(EQEMU_ENABLE_CRASH_LOGGING)
|
||||
ADD_DEFINITIONS(-DCRASH_LOGGING)
|
||||
ENDIF(EQEMU_ENABLE_CRASH_LOGGING)
|
||||
|
||||
#Disable safe SEH or not?
|
||||
OPTION(EQEMU_DISABLE_SAFESEH "Disable Safe SEH (Needed for Strawberry Perl)" OFF)
|
||||
IF(EQEMU_DISABLE_SAFESEH)
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /SAFESEH:NO")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /SAFESEH:NO")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
|
||||
SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
|
||||
SET(CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL "${CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL} /SAFESEH:NO")
|
||||
SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /SAFESEH:NO")
|
||||
SET(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO} /SAFESEH:NO")
|
||||
ENDIF(EQEMU_DISABLE_SAFESEH)
|
||||
|
||||
OPTION(EQEMU_BUILD_MSVC_MP "Enable build with multiple processes." ON)
|
||||
IF(EQEMU_BUILD_MSVC_MP)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
||||
ENDIF(EQEMU_BUILD_MSVC_MP)
|
||||
|
||||
#We want to compile /MT not /MD so we change that
|
||||
FOREACH(flag_var CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO)
|
||||
IF(${flag_var} MATCHES "/MD")
|
||||
STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||
ENDIF(${flag_var} MATCHES "/MD")
|
||||
ENDFOREACH(flag_var)
|
||||
|
||||
ADD_DEFINITIONS(-DNOMINMAX)
|
||||
ELSE(MSVC)
|
||||
#Normally set by perl but we don't use the perl flags anymore so we set it.
|
||||
ADD_DEFINITIONS(-DHAS_UNION_SEMUN)
|
||||
ENDIF(MSVC)
|
||||
|
||||
#FreeBSD support
|
||||
IF(UNIX)
|
||||
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
ADD_DEFINITIONS(-DFREEBSD)
|
||||
SET(FREEBSD TRUE)
|
||||
ENDIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
IF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
ADD_DEFINITIONS(-DDARWIN)
|
||||
SET(DARWIN TRUE)
|
||||
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
ENDIF(UNIX)
|
||||
|
||||
#debug level, 5 is default. Most people wont ever change this but it's there if you want to
|
||||
SET(EQEMU_DEBUG_LEVEL 5 CACHE STRING "EQEmu debug level:
|
||||
0 - Quiet mode Errors to file Status and Normal ignored
|
||||
1 - Status and Normal to console, Errors to logfile
|
||||
2 - Status, Normal, and Error to console and logfile
|
||||
3 - Light debug release errors and status
|
||||
4 - Moderate debug release errors and status
|
||||
5 - Maximum debug release errors and status
|
||||
10 - More errors than you ever wanted to see"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_STATUS 2 CACHE STRING "EQEmu logging level for [Status]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_NORMAL 3 CACHE STRING "EQEmu logging level for [Normal]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_ERROR 2 CACHE STRING "EQEmu logging level for [Error]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_DEBUG 3 CACHE STRING "EQEmu logging level for [Debug]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_QUEST 2 CACHE STRING "EQEmu logging level for [Quest]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_COMMANDS 1 CACHE STRING "EQEmu logging level for [Commands]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
SET(EQEMU_LOG_LEVEL_CRASH 3 CACHE STRING "EQEmu logging level for [Crash]:
|
||||
0 - Disabled
|
||||
1 - Ouput to File Enabled
|
||||
2 - Output to stdout Enabled
|
||||
3 - Output to File and stdout Enabled
|
||||
8 - Output to stderr Enabled
|
||||
9 - Output to File and stderr Enabled
|
||||
11 - Output to File, stdout and stderr Enabled"
|
||||
)
|
||||
|
||||
MARK_AS_ADVANCED(EQEMU_LOG_LEVEL_STATUS EQEMU_LOG_LEVEL_NORMAL EQEMU_LOG_LEVEL_ERROR EQEMU_LOG_LEVEL_DEBUG EQEMU_LOG_LEVEL_QUEST EQEMU_LOG_LEVEL_COMMANDS EQEMU_LOG_LEVEL_CRASH)
|
||||
|
||||
SET(EQEMU_STREAM_SEND_RATE 1048576 CACHE STRING "Advanced: Base amount of data stream can send before throttle.")
|
||||
SET(EQEMU_STREAM_DECAY_RATE 78642 CACHE STRING "Advanced: Base amount of data stream recovers per tic.")
|
||||
SET(EQEMU_STREAM_RETRANSMIT_TIMEOUT_MUL 3.0 CACHE STRING "Advanced: Multiplier on retransmit timeout.")
|
||||
SET(EQEMU_STREAM_RETRANSMIT_TIMEOUT_MAX 5000 CACHE STRING "Advanced: Max in ms for retransmit timeout timer.")
|
||||
SET(EQEMU_STREAM_AVERAGE_DELTA_MAX 2500 CACHE STRING "Advanced: The maximum average delta in ms allowed.")
|
||||
SET(EQEMU_STREAM_RETRANSMIT_ACKED_PACKETS TRUE CACHE BOOL "Advanced: Whether or not acked packets can be retransmitted")
|
||||
MARK_AS_ADVANCED(EQEMU_STREAM_SEND_RATE EQEMU_STREAM_DECAY_RATE EQEMU_STREAM_RETRANSMIT_TIMEOUT_MUL EQEMU_STREAM_RETRANSMIT_TIMEOUT_MAX EQEMU_STREAM_AVERAGE_DELTA_MAX EQEMU_STREAM_RETRANSMIT_ACKED_PACKETS)
|
||||
|
||||
#NPC Types Cache Behavior
|
||||
OPTION(EQEMU_DEPOP_INVALIDATES_CACHE "#repop invalidates the npc_types cache (will cause a larger database hit on #repop but is more convienent)." ON)
|
||||
|
||||
#Bots are a compile time option so on/off
|
||||
OPTION(EQEMU_ENABLE_BOTS "Enable Bots" OFF)
|
||||
|
||||
#Disable entire _mlog system (excludes trade/command logs)
|
||||
OPTION(EQEMU_DISABLE_LOGSYS "Disable Logging INI System" ON)
|
||||
|
||||
#Enable GM Command log system
|
||||
OPTION(EQEMU_COMMANDS_LOGGING "Enable GM Command logs" ON)
|
||||
|
||||
IF(EQEMU_COMMANDS_LOGGING)
|
||||
ADD_DEFINITIONS(-DCOMMANDS_LOGGING)
|
||||
ENDIF(EQEMU_COMMANDS_LOGGING)
|
||||
|
||||
IF(EQEMU_DISABLE_LOGSYS)
|
||||
ADD_DEFINITIONS(-DDISABLE_LOGSYS)
|
||||
ENDIF(EQEMU_DISABLE_LOGSYS)
|
||||
|
||||
IF(EQEMU_ENABLE_BOTS)
|
||||
ADD_DEFINITIONS(-DBOTS)
|
||||
ENDIF(EQEMU_ENABLE_BOTS)
|
||||
|
||||
#What to build
|
||||
OPTION(EQEMU_BUILD_SERVER "Build the game server." ON)
|
||||
OPTION(EQEMU_BUILD_LOGIN "Build the login server." OFF)
|
||||
OPTION(EQEMU_BUILD_TESTS "Build utility tests." OFF)
|
||||
OPTION(EQEMU_BUILD_PERL "Build Perl parser." ON)
|
||||
OPTION(EQEMU_BUILD_LUA "Build Lua parser." ON)
|
||||
OPTION(EQEMU_BUILD_CLIENT_FILES "Build Client Import/Export Data Programs." ON)
|
||||
|
||||
#C++11 stuff
|
||||
IF(NOT MSVC)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reserved-user-defined-literal")
|
||||
ENDIF()
|
||||
ENDIF(NOT MSVC)
|
||||
|
||||
#Various definitions
|
||||
IF(EQEMU_BUILD_PERL)
|
||||
ADD_DEFINITIONS(-DEMBPERL)
|
||||
ADD_DEFINITIONS(-DEMBPERL_PLUGIN)
|
||||
ENDIF(EQEMU_BUILD_PERL)
|
||||
IF(EQEMU_BUILD_LUA)
|
||||
ADD_DEFINITIONS(-DLUA_EQEMU)
|
||||
ENDIF(EQEMU_BUILD_LUA)
|
||||
|
||||
SET(EQEMU_MAP_DIR "./Maps" CACHE STRING "The dir that maps, water maps, and paths are located in.")
|
||||
|
||||
ADD_DEFINITIONS(-DEQDEBUG=${EQEMU_DEBUG_LEVEL})
|
||||
ADD_DEFINITIONS(-DINVERSEXY)
|
||||
ADD_DEFINITIONS(-DFIELD_ITEMS)
|
||||
ADD_DEFINITIONS(-DMAP_DIR="${EQEMU_MAP_DIR}")
|
||||
ADD_DEFINITIONS(-DRATEBASE=${EQEMU_STREAM_SEND_RATE})
|
||||
ADD_DEFINITIONS(-DDECAYBASE=${EQEMU_STREAM_DECAY_RATE})
|
||||
ADD_DEFINITIONS(-DRETRANSMIT_TIMEOUT_MULT=${EQEMU_STREAM_RETRANSMIT_TIMEOUT_MUL})
|
||||
ADD_DEFINITIONS(-DRETRANSMIT_TIMEOUT_MAX=${EQEMU_STREAM_RETRANSMIT_TIMEOUT_MAX})
|
||||
ADD_DEFINITIONS(-DAVERAGE_DELTA_MAX=${EQEMU_STREAM_AVERAGE_DELTA_MAX})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_STATUS=${EQEMU_LOG_LEVEL_STATUS})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_NORMAL=${EQEMU_LOG_LEVEL_NORMAL})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_ERROR=${EQEMU_LOG_LEVEL_ERROR})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_DEBUG=${EQEMU_LOG_LEVEL_DEBUG})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_QUEST=${EQEMU_LOG_LEVEL_QUEST})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_COMMANDS=${EQEMU_LOG_LEVEL_COMMANDS})
|
||||
ADD_DEFINITIONS(-DLOG_LEVEL_CRASH=${EQEMU_LOG_LEVEL_CRASH})
|
||||
ADD_DEFINITIONS(-DGLM_FORCE_RADIANS)
|
||||
|
||||
IF(EQEMU_STREAM_RETRANSMIT_ACKED_PACKETS)
|
||||
ADD_DEFINITIONS(-DRETRANSMIT_ACKED_PACKETS=true)
|
||||
ELSE(EQEMU_STREAM_RETRANSMIT_ACKED_PACKETS)
|
||||
ADD_DEFINITIONS(-DRETRANSMIT_ACKED_PACKETS=false)
|
||||
ENDIF(EQEMU_STREAM_RETRANSMIT_ACKED_PACKETS)
|
||||
|
||||
#Find everything we need
|
||||
FIND_PACKAGE(ZLIB REQUIRED)
|
||||
FIND_PACKAGE(MySQL REQUIRED)
|
||||
IF(EQEMU_BUILD_PERL)
|
||||
FIND_PACKAGE(PerlLibs REQUIRED)
|
||||
INCLUDE_DIRECTORIES("${PERL_INCLUDE_PATH}")
|
||||
ENDIF(EQEMU_BUILD_PERL)
|
||||
|
||||
IF(EQEMU_BUILD_LUA)
|
||||
FIND_PACKAGE(EQLua51 REQUIRED)
|
||||
SET(Boost_USE_STATIC_LIBS OFF)
|
||||
SET(Boost_USE_MULTITHREADED ON)
|
||||
SET(Boost_USE_STATIC_RUNTIME OFF)
|
||||
SET(BOOST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/boost")
|
||||
|
||||
FIND_PACKAGE(Boost REQUIRED)
|
||||
INCLUDE_DIRECTORIES("${LUA_INCLUDE_DIR}" "${Boost_INCLUDE_DIRS}" "luabind")
|
||||
|
||||
OPTION(EQEMU_SANITIZE_LUA_LIBS "Sanitize Lua Libraries (Remove OS and IO standard libraries from being able to run)." ON)
|
||||
IF(EQEMU_SANITIZE_LUA_LIBS)
|
||||
ADD_DEFINITIONS(-DSANITIZE_LUA_LIBS)
|
||||
ENDIF(EQEMU_SANITIZE_LUA_LIBS)
|
||||
ENDIF(EQEMU_BUILD_LUA)
|
||||
|
||||
INCLUDE_DIRECTORIES("${ZLIB_INCLUDE_DIRS}" "${MySQL_INCLUDE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/common/glm/glm")
|
||||
|
||||
IF(EQEMU_BUILD_LUA)
|
||||
ADD_SUBDIRECTORY(luabind)
|
||||
ENDIF(EQEMU_BUILD_LUA)
|
||||
|
||||
IF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS)
|
||||
ADD_SUBDIRECTORY(common)
|
||||
ENDIF(EQEMU_BUILD_SERVER OR EQEMU_BUILD_LOGIN OR EQEMU_BUILD_TESTS)
|
||||
IF(EQEMU_BUILD_SERVER)
|
||||
ADD_SUBDIRECTORY(shared_memory)
|
||||
ADD_SUBDIRECTORY(world)
|
||||
ADD_SUBDIRECTORY(zone)
|
||||
ADD_SUBDIRECTORY(ucs)
|
||||
ADD_SUBDIRECTORY(queryserv)
|
||||
ADD_SUBDIRECTORY(eqlaunch)
|
||||
ENDIF(EQEMU_BUILD_SERVER)
|
||||
IF(EQEMU_BUILD_LOGIN)
|
||||
ADD_SUBDIRECTORY(loginserver)
|
||||
ENDIF(EQEMU_BUILD_LOGIN)
|
||||
|
||||
IF(EQEMU_BUILD_TESTS)
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
ENDIF(EQEMU_BUILD_TESTS)
|
||||
|
||||
IF(EQEMU_BUILD_CLIENT_FILES)
|
||||
ADD_SUBDIRECTORY(client_files)
|
||||
ENDIF(EQEMU_BUILD_CLIENT_FILES)
|
||||
@@ -0,0 +1,339 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
The server code and utilities are released under GPLv3.
|
||||
|
||||
We also include some small libraries for convienence that may be under different licensing:
|
||||
|
||||
SocketLib - GPL
|
||||
LibXML - ZLib License
|
||||
StackWalker - New BSD License
|
||||
ZLib - ZLib License
|
||||
MySQL - GPL
|
||||
Perl - GPL / ActiveState (under the assumption that this is a free project).
|
||||
CPPUnit - GLP
|
||||
StringUtilities - Apache
|
||||
@@ -0,0 +1,53 @@
|
||||
EQEmu
|
||||
===
|
||||
|
||||
[](https://travis-ci.org/EQEmu/Server)
|
||||
|
||||
Overview
|
||||
---
|
||||
|
||||
EQEmu is a custom server implementation for EverQuest
|
||||
|
||||
Dependencies
|
||||
---
|
||||
|
||||
For Windows: http://eqemu.github.io
|
||||
|
||||
Login Server dependencies for Windows/Linux/OSX: http://eqemu.github.io
|
||||
|
||||
For Debian based distros (adjust to your local flavor):
|
||||
|
||||
- libmysqlclient-dev
|
||||
- libperl-dev
|
||||
- liblua5.1-0-dev (5.2 should work as well)
|
||||
- libboost-dev
|
||||
|
||||
Further instructions on building the source can be found on the
|
||||
[wiki](http://wiki.eqemulator.org/i?M=Wiki).
|
||||
|
||||
Bug reports
|
||||
---
|
||||
|
||||
Please use the [issue tracker](https://github.com/EQEmu/Server/issues) provided by GitHub to send us bug
|
||||
reports or feature requests.
|
||||
|
||||
The [EQEmu Forums](http://www.eqemulator.org/forums/) also have forums to submit
|
||||
bugs/get help with bugs.
|
||||
|
||||
Contributions
|
||||
---
|
||||
|
||||
The preferred way to contribute is to fork the repo and submit a pull request on
|
||||
GitHub. If you need help with your changes, you can always post on the forums or
|
||||
try IRC. You can also post unified diffs (`git diff` should do the trick) on the
|
||||
[Server Code Submissions](http://www.eqemulator.org/forums/forumdisplay.php?f=669)
|
||||
forum, although pull requests will be much quicker and easier on all parties.
|
||||
|
||||
Contact
|
||||
---
|
||||
- **User IRC Channel**: `#eqemu` on `irc.eqemulator.net`
|
||||
- **Developer IRC Channel**: `#eqemucoders` on `irc.eqemulator.net`
|
||||
|
||||
- [EQEmulator Forums](http://www.eqemulator.org/forums)
|
||||
- [EQEmulator Wiki](http://wiki.eqemulator.org/i?M=Wiki)
|
||||
|
||||
+9211
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,4 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
add_subdirectory(import)
|
||||
add_subdirectory(export)
|
||||
@@ -0,0 +1,36 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
SET(export_sources
|
||||
main.cpp
|
||||
)
|
||||
|
||||
SET(export_headers
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(export_client_files ${export_sources} ${export_headers})
|
||||
|
||||
INSTALL(TARGETS export_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
|
||||
TARGET_LINK_LIBRARIES(export_client_files common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
|
||||
|
||||
IF(MSVC)
|
||||
SET_TARGET_PROPERTIES(export_client_files PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
|
||||
TARGET_LINK_LIBRARIES(export_client_files "Ws2_32.lib")
|
||||
ENDIF(MSVC)
|
||||
|
||||
IF(MINGW)
|
||||
TARGET_LINK_LIBRARIES(export_client_files "WS2_32")
|
||||
ENDIF(MINGW)
|
||||
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(export_client_files "${CMAKE_DL_LIBS}")
|
||||
TARGET_LINK_LIBRARIES(export_client_files "z")
|
||||
TARGET_LINK_LIBRARIES(export_client_files "m")
|
||||
IF(NOT DARWIN)
|
||||
TARGET_LINK_LIBRARIES(export_client_files "rt")
|
||||
ENDIF(NOT DARWIN)
|
||||
TARGET_LINK_LIBRARIES(export_client_files "pthread")
|
||||
ADD_DEFINITIONS(-fPIC)
|
||||
ENDIF(UNIX)
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
@@ -0,0 +1,198 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../../common/debug.h"
|
||||
#include "../../common/shareddb.h"
|
||||
#include "../../common/eqemu_config.h"
|
||||
#include "../../common/platform.h"
|
||||
#include "../../common/crash.h"
|
||||
#include "../../common/rulesys.h"
|
||||
#include "../../common/string_util.h"
|
||||
|
||||
void ExportSpells(SharedDatabase *db);
|
||||
void ExportSkillCaps(SharedDatabase *db);
|
||||
void ExportBaseData(SharedDatabase *db);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
RegisterExecutablePlatform(ExePlatformClientExport);
|
||||
set_exception_handler();
|
||||
|
||||
LogFile->write(EQEMuLog::Status, "Client Files Export Utility");
|
||||
if(!EQEmuConfig::LoadConfig()) {
|
||||
LogFile->write(EQEMuLog::Error, "Unable to load configuration file.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
const EQEmuConfig *config = EQEmuConfig::get();
|
||||
if(!load_log_settings(config->LogSettingsFile.c_str())) {
|
||||
LogFile->write(EQEMuLog::Error, "Warning: unable to read %s.", config->LogSettingsFile.c_str());
|
||||
}
|
||||
|
||||
SharedDatabase database;
|
||||
LogFile->write(EQEMuLog::Status, "Connecting to database...");
|
||||
if(!database.Connect(config->DatabaseHost.c_str(), config->DatabaseUsername.c_str(),
|
||||
config->DatabasePassword.c_str(), config->DatabaseDB.c_str(), config->DatabasePort)) {
|
||||
LogFile->write(EQEMuLog::Error, "Unable to connect to the database, cannot continue without a "
|
||||
"database connection");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ExportSpells(&database);
|
||||
ExportSkillCaps(&database);
|
||||
ExportBaseData(&database);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ExportSpells(SharedDatabase *db) {
|
||||
LogFile->write(EQEMuLog::Status, "Exporting Spells...");
|
||||
|
||||
FILE *f = fopen("export/spells_us.txt", "w");
|
||||
if(!f) {
|
||||
LogFile->write(EQEMuLog::Error, "Unable to open export/spells_us.txt to write, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string query = "SELECT * FROM spells_new ORDER BY id";
|
||||
auto results = db->QueryDatabase(query);
|
||||
|
||||
if(results.Success()) {
|
||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
||||
std::string line;
|
||||
unsigned int fields = results.ColumnCount();
|
||||
for(unsigned int i = 0; i < fields; ++i) {
|
||||
if(i != 0) {
|
||||
line.push_back('^');
|
||||
}
|
||||
|
||||
if(row[i] != nullptr) {
|
||||
line += row[i];
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(f, "%s\n", line.c_str());
|
||||
}
|
||||
} else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in ExportSpells query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
bool SkillUsable(SharedDatabase *db, int skill_id, int class_id) {
|
||||
|
||||
bool res = false;
|
||||
|
||||
std::string query = StringFormat("SELECT max(cap) FROM skill_caps WHERE class=%d AND skillID=%d",
|
||||
class_id, skill_id);
|
||||
auto results = db->QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
LogFile->write(EQEMuLog::Error, "Error in skill_usable query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
return false;
|
||||
|
||||
auto row = results.begin();
|
||||
if(row[0] && atoi(row[0]) > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int GetSkill(SharedDatabase *db, int skill_id, int class_id, int level) {
|
||||
|
||||
std::string query = StringFormat("SELECT cap FROM skill_caps WHERE class=%d AND skillID=%d AND level=%d",
|
||||
class_id, skill_id, level);
|
||||
auto results = db->QueryDatabase(query);
|
||||
if (!results.Success()) {
|
||||
LogFile->write(EQEMuLog::Error, "Error in get_skill query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0)
|
||||
return 0;
|
||||
|
||||
auto row = results.begin();
|
||||
return atoi(row[0]);
|
||||
}
|
||||
|
||||
void ExportSkillCaps(SharedDatabase *db) {
|
||||
LogFile->write(EQEMuLog::Status, "Exporting Skill Caps...");
|
||||
|
||||
FILE *f = fopen("export/SkillCaps.txt", "w");
|
||||
if(!f) {
|
||||
LogFile->write(EQEMuLog::Error, "Unable to open export/SkillCaps.txt to write, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
for(int cl = 1; cl <= 16; ++cl) {
|
||||
for(int skill = 0; skill <= 77; ++skill) {
|
||||
if(SkillUsable(db, skill, cl)) {
|
||||
int previous_cap = 0;
|
||||
for(int level = 1; level <= 100; ++level) {
|
||||
int cap = GetSkill(db, skill, cl, level);
|
||||
if(cap < previous_cap) {
|
||||
cap = previous_cap;
|
||||
}
|
||||
|
||||
fprintf(f, "%d^%d^%d^%d^0\n", cl, skill, level, cap);
|
||||
previous_cap = cap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void ExportBaseData(SharedDatabase *db) {
|
||||
LogFile->write(EQEMuLog::Status, "Exporting Base Data...");
|
||||
|
||||
FILE *f = fopen("export/BaseData.txt", "w");
|
||||
if(!f) {
|
||||
LogFile->write(EQEMuLog::Error, "Unable to open export/BaseData.txt to write, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string query = "SELECT * FROM base_data ORDER BY level, class";
|
||||
auto results = db->QueryDatabase(query);
|
||||
if(results.Success()) {
|
||||
for (auto row = results.begin();row != results.end();++row) {
|
||||
std::string line;
|
||||
unsigned int fields = results.ColumnCount();
|
||||
for(unsigned int rowIndex = 0; rowIndex < fields; ++rowIndex) {
|
||||
if(rowIndex != 0)
|
||||
line.push_back('^');
|
||||
|
||||
if(row[rowIndex] != nullptr) {
|
||||
line += row[rowIndex];
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(f, "%s\n", line.c_str());
|
||||
}
|
||||
} else {
|
||||
LogFile->write(EQEMuLog::Error, "Error in ExportBaseData query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
SET(import_sources
|
||||
main.cpp
|
||||
)
|
||||
|
||||
SET(import_headers
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(import_client_files ${import_sources} ${import_headers})
|
||||
|
||||
INSTALL(TARGETS import_client_files RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||
|
||||
TARGET_LINK_LIBRARIES(import_client_files common debug ${MySQL_LIBRARY_DEBUG} optimized ${MySQL_LIBRARY_RELEASE} ${ZLIB_LIBRARY})
|
||||
|
||||
IF(MSVC)
|
||||
SET_TARGET_PROPERTIES(import_client_files PROPERTIES LINK_FLAGS_RELEASE "/OPT:REF /OPT:ICF")
|
||||
TARGET_LINK_LIBRARIES(import_client_files "Ws2_32.lib")
|
||||
ENDIF(MSVC)
|
||||
|
||||
IF(MINGW)
|
||||
TARGET_LINK_LIBRARIES(import_client_files "WS2_32")
|
||||
ENDIF(MINGW)
|
||||
|
||||
IF(UNIX)
|
||||
TARGET_LINK_LIBRARIES(import_client_files "${CMAKE_DL_LIBS}")
|
||||
TARGET_LINK_LIBRARIES(import_client_files "z")
|
||||
TARGET_LINK_LIBRARIES(import_client_files "m")
|
||||
IF(NOT DARWIN)
|
||||
TARGET_LINK_LIBRARIES(import_client_files "rt")
|
||||
ENDIF(NOT DARWIN)
|
||||
TARGET_LINK_LIBRARIES(import_client_files "pthread")
|
||||
ADD_DEFINITIONS(-fPIC)
|
||||
ENDIF(UNIX)
|
||||
|
||||
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
@@ -0,0 +1,231 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "../../common/debug.h"
|
||||
#include "../../common/shareddb.h"
|
||||
#include "../../common/eqemu_config.h"
|
||||
#include "../../common/platform.h"
|
||||
#include "../../common/crash.h"
|
||||
#include "../../common/rulesys.h"
|
||||
#include "../../common/string_util.h"
|
||||
|
||||
void ImportSpells(SharedDatabase *db);
|
||||
void ImportSkillCaps(SharedDatabase *db);
|
||||
void ImportBaseData(SharedDatabase *db);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
RegisterExecutablePlatform(ExePlatformClientImport);
|
||||
set_exception_handler();
|
||||
|
||||
LogFile->write(EQEMuLog::Status, "Client Files Import Utility");
|
||||
if(!EQEmuConfig::LoadConfig()) {
|
||||
LogFile->write(EQEMuLog::Error, "Unable to load configuration file.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
const EQEmuConfig *config = EQEmuConfig::get();
|
||||
if(!load_log_settings(config->LogSettingsFile.c_str())) {
|
||||
LogFile->write(EQEMuLog::Error, "Warning: unable to read %s.", config->LogSettingsFile.c_str());
|
||||
}
|
||||
|
||||
SharedDatabase database;
|
||||
LogFile->write(EQEMuLog::Status, "Connecting to database...");
|
||||
if(!database.Connect(config->DatabaseHost.c_str(), config->DatabaseUsername.c_str(),
|
||||
config->DatabasePassword.c_str(), config->DatabaseDB.c_str(), config->DatabasePort)) {
|
||||
LogFile->write(EQEMuLog::Error, "Unable to connect to the database, cannot continue without a "
|
||||
"database connection");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ImportSpells(&database);
|
||||
ImportSkillCaps(&database);
|
||||
ImportBaseData(&database);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GetSpellColumns(SharedDatabase *db) {
|
||||
|
||||
const std::string query = "DESCRIBE spells_new";
|
||||
auto results = db->QueryDatabase(query);
|
||||
if(!results.Success()) {
|
||||
LogFile->write(EQEMuLog::Error, "Error in GetSpellColumns query '%s' %s", query.c_str(), results.ErrorMessage().c_str());
|
||||
return 0;
|
||||
}
|
||||
|
||||
return results.RowCount();
|
||||
}
|
||||
|
||||
void ImportSpells(SharedDatabase *db) {
|
||||
LogFile->write(EQEMuLog::Status, "Importing Spells...");
|
||||
FILE *f = fopen("import/spells_us.txt", "r");
|
||||
if(!f) {
|
||||
LogFile->write(EQEMuLog::Error, "Unable to open import/spells_us.txt to read, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string query = "DELETE FROM spells_new";
|
||||
db->QueryDatabase(query);
|
||||
|
||||
int columns = GetSpellColumns(db);
|
||||
int spells_imported = 0;
|
||||
|
||||
char buffer[2048];
|
||||
while(fgets(buffer, 2048, f)) {
|
||||
for(int i = 0; i < 2048; ++i) {
|
||||
if(buffer[i] == '\n') {
|
||||
buffer[i] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::string escaped = ::EscapeString(buffer);
|
||||
auto split = SplitString(escaped, '^');
|
||||
int line_columns = (int)split.size();
|
||||
|
||||
std::string sql;
|
||||
if(line_columns >= columns) {
|
||||
sql = "INSERT INTO spells_new VALUES(";
|
||||
for(int i = 0; i < columns; ++i) {
|
||||
if(i != 0) {
|
||||
sql += ", '";
|
||||
} else {
|
||||
sql += "'";
|
||||
}
|
||||
|
||||
sql += split[i];
|
||||
sql += "'";
|
||||
}
|
||||
|
||||
sql += ");";
|
||||
} else {
|
||||
int i = 0;
|
||||
sql = "INSERT INTO spells_new VALUES(";
|
||||
for(; i < line_columns; ++i) {
|
||||
if(i != 0) {
|
||||
sql += ", '";
|
||||
} else {
|
||||
sql += "'";
|
||||
}
|
||||
|
||||
sql += split[i];
|
||||
sql += "'";
|
||||
}
|
||||
|
||||
for(; i < columns; ++i) {
|
||||
sql += ", '0'";
|
||||
}
|
||||
|
||||
sql += ");";
|
||||
}
|
||||
|
||||
db->QueryDatabase(sql);
|
||||
|
||||
spells_imported++;
|
||||
if(spells_imported % 1000 == 0) {
|
||||
LogFile->write(EQEMuLog::Status, "%d spells imported.", spells_imported);
|
||||
}
|
||||
}
|
||||
|
||||
if(spells_imported % 1000 != 0) {
|
||||
LogFile->write(EQEMuLog::Status, "%d spells imported.", spells_imported);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void ImportSkillCaps(SharedDatabase *db) {
|
||||
LogFile->write(EQEMuLog::Status, "Importing Skill Caps...");
|
||||
|
||||
FILE *f = fopen("import/SkillCaps.txt", "r");
|
||||
if(!f) {
|
||||
LogFile->write(EQEMuLog::Error, "Unable to open import/SkillCaps.txt to read, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string delete_sql = "DELETE FROM skill_caps";
|
||||
db->QueryDatabase(delete_sql);
|
||||
|
||||
char buffer[2048];
|
||||
while(fgets(buffer, 2048, f)) {
|
||||
auto split = SplitString(buffer, '^');
|
||||
|
||||
if(split.size() < 4) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
int class_id, skill_id, level, cap;
|
||||
class_id = atoi(split[0].c_str());
|
||||
skill_id = atoi(split[1].c_str());
|
||||
level = atoi(split[2].c_str());
|
||||
cap = atoi(split[3].c_str());
|
||||
|
||||
std::string sql = StringFormat("INSERT INTO skill_caps(class, skillID, level, cap) VALUES(%d, %d, %d, %d)",
|
||||
class_id, skill_id, level, cap);
|
||||
|
||||
db->QueryDatabase(sql);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
void ImportBaseData(SharedDatabase *db) {
|
||||
LogFile->write(EQEMuLog::Status, "Importing Base Data...");
|
||||
|
||||
FILE *f = fopen("import/BaseData.txt", "r");
|
||||
if(!f) {
|
||||
LogFile->write(EQEMuLog::Error, "Unable to open import/BaseData.txt to read, skipping.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string delete_sql = "DELETE FROM base_data";
|
||||
db->QueryDatabase(delete_sql);
|
||||
|
||||
char buffer[2048];
|
||||
while(fgets(buffer, 2048, f)) {
|
||||
auto split = SplitString(buffer, '^');
|
||||
|
||||
if(split.size() < 10) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string sql;
|
||||
int level, class_id;
|
||||
double hp, mana, end, unk1, unk2, hp_fac, mana_fac, end_fac;
|
||||
|
||||
level = atoi(split[0].c_str());
|
||||
class_id = atoi(split[1].c_str());
|
||||
hp = atof(split[2].c_str());
|
||||
mana = atof(split[3].c_str());
|
||||
end = atof(split[4].c_str());
|
||||
unk1 = atof(split[5].c_str());
|
||||
unk2 = atof(split[6].c_str());
|
||||
hp_fac = atof(split[7].c_str());
|
||||
mana_fac = atof(split[8].c_str());
|
||||
end_fac = atof(split[9].c_str());
|
||||
|
||||
sql = StringFormat("INSERT INTO base_data(level, class, hp, mana, end, unk1, unk2, hp_fac, "
|
||||
"mana_fac, end_fac) VALUES(%d, %d, %f, %f, %f, %f, %f, %f, %f, %f)",
|
||||
level, class_id, hp, mana, end, unk1, unk2, hp_fac, mana_fac, end_fac);
|
||||
|
||||
db->QueryDatabase(sql);
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
#CMake - Cross Platform Makefile Generator
|
||||
#Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
|
||||
#All rights reserved.
|
||||
#
|
||||
#Redistribution and use in source and binary forms, with or without
|
||||
#modification, are permitted provided that the following conditions
|
||||
#are met:
|
||||
#
|
||||
#* Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
#
|
||||
#* Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
#
|
||||
#* Neither the names of Kitware, Inc., the Insight Software Consortium,
|
||||
# nor the names of their contributors may be used to endorse or promote
|
||||
# products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
#A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
#HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
#SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
#LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
#DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
#THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
#OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# This module defines
|
||||
# LUA51_FOUND, if false, do not try to link to Lua
|
||||
# LUA_LIBRARIES
|
||||
# LUA_INCLUDE_DIR, where to find lua.h
|
||||
# LUA_VERSION_STRING, the version of Lua found (since CMake 2.8.8)
|
||||
|
||||
IF(LUA_ROOT)
|
||||
FIND_PATH(LUA_INCLUDE_DIR
|
||||
NAMES lua.h
|
||||
HINTS
|
||||
ENV LUA_DIR
|
||||
PATHS
|
||||
${LUA_ROOT}
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include src
|
||||
)
|
||||
|
||||
FIND_LIBRARY(LUA_LIBRARY
|
||||
NAMES lua51 lua5.1 lua-5.1 lua
|
||||
HINTS
|
||||
ENV LUA_DIR
|
||||
PATHS
|
||||
${LUA_ROOT}
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
PATH_SUFFIXES lib bin
|
||||
)
|
||||
ELSE(LUA_ROOT)
|
||||
FIND_PATH(LUA_INCLUDE_DIR
|
||||
NAMES lua.h
|
||||
HINTS
|
||||
ENV LUA_DIR
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
PATH_SUFFIXES include/lua51 include/lua5.1 include/lua include
|
||||
)
|
||||
|
||||
FIND_LIBRARY(LUA_LIBRARY
|
||||
NAMES lua51 lua5.1 lua-5.1 lua
|
||||
HINTS
|
||||
ENV LUA_DIR
|
||||
PATHS
|
||||
~/Library/Frameworks
|
||||
/Library/Frameworks
|
||||
/sw
|
||||
/opt/local
|
||||
/opt/csw
|
||||
/opt
|
||||
PATH_SUFFIXES lib bin
|
||||
)
|
||||
ENDIF(LUA_ROOT)
|
||||
|
||||
IF(LUA_LIBRARY)
|
||||
# include the math library for Unix
|
||||
IF(UNIX AND NOT APPLE)
|
||||
FIND_LIBRARY(LUA_MATH_LIBRARY m)
|
||||
SET(LUA_LIBRARIES "${LUA_LIBRARY};${LUA_MATH_LIBRARY}" CACHE STRING "Lua Libraries")
|
||||
# For Windows and Mac, don't need to explicitly include the math library
|
||||
ELSE()
|
||||
SET( LUA_LIBRARIES "${LUA_LIBRARY}" CACHE STRING "Lua Libraries")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF(LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
|
||||
FILE(STRINGS "${LUA_INCLUDE_DIR}/lua.h" lua_version_str REGEX "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua .+\"")
|
||||
|
||||
STRING(REGEX REPLACE "^#define[ \t]+LUA_RELEASE[ \t]+\"Lua ([^\"]+)\".*" "\\1" LUA_VERSION_STRING "${lua_version_str}")
|
||||
UNSET(lua_version_str)
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Lua51
|
||||
REQUIRED_VARS LUA_LIBRARIES LUA_INCLUDE_DIR
|
||||
VERSION_VAR LUA_VERSION_STRING)
|
||||
|
||||
MARK_AS_ADVANCED(LUA_INCLUDE_DIR LUA_LIBRARIES LUA_LIBRARY LUA_MATH_LIBRARY)
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
# - Find mysqlclient
|
||||
#
|
||||
# -*- cmake -*-
|
||||
#
|
||||
# Find the native MySQL includes and library
|
||||
#
|
||||
# MySQL_INCLUDE_DIR - where to find mysql.h, etc.
|
||||
# MySQL_LIBRARIES - List of libraries when using MySQL.
|
||||
# MySQL_FOUND - True if MySQL found.
|
||||
# The following can be used as a hint as to where to search:
|
||||
# MYSQL_ROOT
|
||||
|
||||
IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARIES)
|
||||
# Already in cache, be silent
|
||||
SET(MySQL_FIND_QUIETLY TRUE)
|
||||
ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARIES)
|
||||
|
||||
# Include dir
|
||||
IF(MYSQL_ROOT)
|
||||
FIND_PATH(MySQL_INCLUDE_DIR
|
||||
NAMES mysql.h
|
||||
PATHS ${MYSQL_ROOT}/include
|
||||
PATH_SUFFIXES mysql
|
||||
)
|
||||
ELSE(MYSQL_ROOT)
|
||||
FIND_PATH(MySQL_INCLUDE_DIR
|
||||
NAMES mysql.h
|
||||
PATH_SUFFIXES mysql
|
||||
)
|
||||
ENDIF(MYSQL_ROOT)
|
||||
|
||||
# Library
|
||||
SET(MySQL_NAMES mysqlclient_r mysqlclient)
|
||||
IF(MYSQL_ROOT)
|
||||
FIND_LIBRARY(MySQL_LIBRARY_DEBUG
|
||||
NAMES ${MySQL_NAMES}
|
||||
PATHS ${MYSQL_ROOT}/lib/debug /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
||||
PATH_SUFFIXES mysql
|
||||
)
|
||||
|
||||
FIND_LIBRARY(MySQL_LIBRARY_RELEASE
|
||||
NAMES ${MySQL_NAMES}
|
||||
PATHS ${MYSQL_ROOT}/lib /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
||||
PATH_SUFFIXES mysql
|
||||
)
|
||||
ELSE(MYSQL_ROOT)
|
||||
FIND_LIBRARY(MySQL_LIBRARY_DEBUG
|
||||
NAMES ${MySQL_NAMES}
|
||||
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
||||
PATH_SUFFIXES mysql
|
||||
)
|
||||
|
||||
FIND_LIBRARY(MySQL_LIBRARY_RELEASE
|
||||
NAMES ${MySQL_NAMES}
|
||||
PATHS /usr/lib /usr/local/lib /usr/lib64 /usr/local/lib64
|
||||
PATH_SUFFIXES mysql
|
||||
)
|
||||
ENDIF(MYSQL_ROOT)
|
||||
|
||||
IF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE)
|
||||
SET(MySQL_FOUND TRUE)
|
||||
SET( MySQL_LIBRARIES ${MySQL_LIBRARY_DEBUG} ${MySQL_LIBRARY_RELEASE} )
|
||||
ELSE (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE)
|
||||
SET(MySQL_FOUND FALSE)
|
||||
SET( MySQL_LIBRARIES )
|
||||
ENDIF (MySQL_INCLUDE_DIR AND MySQL_LIBRARY_DEBUG AND MySQL_LIBRARY_RELEASE)
|
||||
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set MySQL_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(MySQL DEFAULT_MSG MySQL_LIBRARY_DEBUG MySQL_LIBRARY_RELEASE MySQL_INCLUDE_DIR)
|
||||
|
||||
IF(MySQL_FOUND)
|
||||
SET( MySQL_LIBRARIES ${MySQL_LIBRARY_DEBUG} ${MySQL_LIBRARY_RELEASE} )
|
||||
ELSE(MySQL_FOUND)
|
||||
SET( MySQL_LIBRARIES )
|
||||
ENDIF(MySQL_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
MySQL_LIBRARY_DEBUG
|
||||
MySQL_LIBRARY_RELEASE
|
||||
MySQL_INCLUDE_DIR
|
||||
)
|
||||
@@ -0,0 +1,342 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
SET(common_sources
|
||||
base_packet.cpp
|
||||
classes.cpp
|
||||
condition.cpp
|
||||
crash.cpp
|
||||
crc16.cpp
|
||||
crc32.cpp
|
||||
database.cpp
|
||||
dbcore.cpp
|
||||
debug.cpp
|
||||
emu_opcodes.cpp
|
||||
emu_tcp_connection.cpp
|
||||
emu_tcp_server.cpp
|
||||
eq_dictionary.cpp
|
||||
eqdb.cpp
|
||||
eqdb_res.cpp
|
||||
eqemu_exception.cpp
|
||||
eqemu_config.cpp
|
||||
eqemu_error.cpp
|
||||
eq_packet.cpp
|
||||
eq_stream.cpp
|
||||
eq_stream_factory.cpp
|
||||
eq_stream_ident.cpp
|
||||
eq_stream_proxy.cpp
|
||||
eqtime.cpp
|
||||
extprofile.cpp
|
||||
faction.cpp
|
||||
guild_base.cpp
|
||||
guilds.cpp
|
||||
ipc_mutex.cpp
|
||||
item.cpp
|
||||
logsys.cpp
|
||||
logsys_eqemu.cpp
|
||||
md5.cpp
|
||||
memory_mapped_file.cpp
|
||||
misc.cpp
|
||||
misc_functions.cpp
|
||||
moremath.cpp
|
||||
mutex.cpp
|
||||
mysql_request_result.cpp
|
||||
mysql_request_row.cpp
|
||||
opcode_map.cpp
|
||||
opcodemgr.cpp
|
||||
packet_dump.cpp
|
||||
packet_dump_file.cpp
|
||||
packet_functions.cpp
|
||||
perl_eqdb.cpp
|
||||
perl_eqdb_res.cpp
|
||||
proc_launcher.cpp
|
||||
ptimer.cpp
|
||||
races.cpp
|
||||
rdtsc.cpp
|
||||
rulesys.cpp
|
||||
serverinfo.cpp
|
||||
shareddb.cpp
|
||||
skills.cpp
|
||||
spdat.cpp
|
||||
string_util.cpp
|
||||
struct_strategy.cpp
|
||||
tcp_connection.cpp
|
||||
tcp_server.cpp
|
||||
timeoutmgr.cpp
|
||||
timer.cpp
|
||||
unix.cpp
|
||||
worldconn.cpp
|
||||
xml_parser.cpp
|
||||
platform.cpp
|
||||
patches/client62.cpp
|
||||
patches/patches.cpp
|
||||
patches/sod.cpp
|
||||
patches/sof.cpp
|
||||
patches/rof.cpp
|
||||
patches/titanium.cpp
|
||||
patches/underfoot.cpp
|
||||
SocketLib/Base64.cpp
|
||||
SocketLib/File.cpp
|
||||
SocketLib/HttpdCookies.cpp
|
||||
SocketLib/HttpdForm.cpp
|
||||
SocketLib/HttpdSocket.cpp
|
||||
SocketLib/HTTPSocket.cpp
|
||||
SocketLib/MemFile.cpp
|
||||
SocketLib/Mime.cpp
|
||||
SocketLib/Parse.cpp
|
||||
SocketLib/socket_include.cpp
|
||||
SocketLib/Utility.cpp
|
||||
StackWalker/StackWalker.cpp
|
||||
tinyxml/tinystr.cpp
|
||||
tinyxml/tinyxml.cpp
|
||||
tinyxml/tinyxmlerror.cpp
|
||||
tinyxml/tinyxmlparser.cpp
|
||||
)
|
||||
|
||||
SET(common_headers
|
||||
any.h
|
||||
base_packet.h
|
||||
base_data.h
|
||||
bodytypes.h
|
||||
breakdowns.h
|
||||
classes.h
|
||||
condition.h
|
||||
crash.h
|
||||
crc16.h
|
||||
crc32.h
|
||||
data_verification.h
|
||||
database.h
|
||||
dbcore.h
|
||||
debug.h
|
||||
deity.h
|
||||
emu_opcodes.h
|
||||
emu_oplist.h
|
||||
emu_tcp_connection.h
|
||||
emu_tcp_server.h
|
||||
eq_constants.h
|
||||
eq_dictionary.h
|
||||
eq_packet_structs.h
|
||||
eqdb.h
|
||||
eqdb_res.h
|
||||
eqemu_exception.h
|
||||
eqemu_config.h
|
||||
eqemu_config_elements.h
|
||||
eqemu_error.h
|
||||
eq_packet.h
|
||||
eq_stream.h
|
||||
eq_stream_factory.h
|
||||
eq_stream_ident.h
|
||||
eq_stream_intf.h
|
||||
eq_stream_locator.h
|
||||
eq_stream_proxy.h
|
||||
eq_stream_type.h
|
||||
eqtime.h
|
||||
errmsg.h
|
||||
extprofile.h
|
||||
faction.h
|
||||
features.h
|
||||
fixed_memory_hash_set.h
|
||||
fixed_memory_variable_hash_set.h
|
||||
guild_base.h
|
||||
guilds.h
|
||||
ipc_mutex.h
|
||||
item.h
|
||||
item_fieldlist.h
|
||||
item_struct.h
|
||||
languages.h
|
||||
linked_list.h
|
||||
logsys.h
|
||||
logtypes.h
|
||||
loottable.h
|
||||
mail_oplist.h
|
||||
md5.h
|
||||
memory_mapped_file.h
|
||||
misc.h
|
||||
misc_functions.h
|
||||
moremath.h
|
||||
mutex.h
|
||||
mysql_request_result.h
|
||||
mysql_request_row.h
|
||||
op_codes.h
|
||||
opcode_dispatch.h
|
||||
opcodemgr.h
|
||||
packet_dump.h
|
||||
packet_dump_file.h
|
||||
packet_functions.h
|
||||
platform.h
|
||||
proc_launcher.h
|
||||
profiler.h
|
||||
ptimer.h
|
||||
queue.h
|
||||
races.h
|
||||
rdtsc.h
|
||||
rulesys.h
|
||||
ruletypes.h
|
||||
seperator.h
|
||||
serverinfo.h
|
||||
servertalk.h
|
||||
shareddb.h
|
||||
skills.h
|
||||
spdat.h
|
||||
string_util.h
|
||||
struct_strategy.h
|
||||
tcp_basic_server.h
|
||||
tcp_connection.h
|
||||
tcp_server.h
|
||||
timeoutmgr.h
|
||||
timer.h
|
||||
types.h
|
||||
unix.h
|
||||
useperl.h
|
||||
version.h
|
||||
worldconn.h
|
||||
xml_parser.h
|
||||
zone_numbers.h
|
||||
patches/client62.h
|
||||
patches/client62_constants.h
|
||||
patches/client62_itemfields.h
|
||||
patches/client62_ops.h
|
||||
patches/client62_structs.h
|
||||
patches/patches.h
|
||||
patches/sod.h
|
||||
patches/sod_constants.h
|
||||
patches/sod_itemfields.h
|
||||
patches/sod_ops.h
|
||||
patches/sod_structs.h
|
||||
patches/sof.h
|
||||
patches/sof_constants.h
|
||||
patches/sof_itemfields.h
|
||||
patches/sof_opcode_list.h
|
||||
patches/sof_ops.h
|
||||
patches/sof_structs.h
|
||||
patches/ss_declare.h
|
||||
patches/ss_define.h
|
||||
patches/ss_register.h
|
||||
patches/rof.h
|
||||
patches/rof_constants.h
|
||||
patches/rof_itemfields.h
|
||||
patches/rof_ops.h
|
||||
patches/rof_structs.h
|
||||
patches/rof2_constants.h
|
||||
patches/titanium.h
|
||||
patches/titanium_constants.h
|
||||
patches/titanium_itemfields.h
|
||||
patches/titanium_ops.h
|
||||
patches/titanium_structs.h
|
||||
patches/underfoot.h
|
||||
patches/underfoot_constants.h
|
||||
patches/underfoot_itemfields.h
|
||||
patches/underfoot_ops.h
|
||||
patches/underfoot_structs.h
|
||||
SocketLib/Base64.h
|
||||
SocketLib/File.h
|
||||
SocketLib/HttpdCookies.h
|
||||
SocketLib/HttpdForm.h
|
||||
SocketLib/HttpdSocket.h
|
||||
SocketLib/HTTPSocket.h
|
||||
SocketLib/IFile.h
|
||||
SocketLib/MemFile.h
|
||||
SocketLib/Mime.h
|
||||
SocketLib/Parse.h
|
||||
SocketLib/socket_include.h
|
||||
SocketLib/Utility.h
|
||||
StackWalker/StackWalker.h
|
||||
tinyxml/tinystr.h
|
||||
tinyxml/tinyxml.h
|
||||
)
|
||||
|
||||
SOURCE_GROUP(Patches FILES
|
||||
patches/client62.h
|
||||
patches/client62_itemfields.h
|
||||
patches/client62_ops.h
|
||||
patches/client62_constants.h
|
||||
patches/client62_structs.h
|
||||
patches/patches.h
|
||||
patches/sod.h
|
||||
patches/sod_itemfields.h
|
||||
patches/sod_ops.h
|
||||
patches/sod_constants.h
|
||||
patches/sod_structs.h
|
||||
patches/sof.h
|
||||
patches/sof_itemfields.h
|
||||
patches/sof_opcode_list.h
|
||||
patches/sof_ops.h
|
||||
patches/sof_constants.h
|
||||
patches/sof_structs.h
|
||||
patches/ss_declare.h
|
||||
patches/ss_define.h
|
||||
patches/ss_register.h
|
||||
patches/rof.h
|
||||
patches/rof_itemfields.h
|
||||
patches/rof_ops.h
|
||||
patches/rof_constants.h
|
||||
patches/rof2_constants.h
|
||||
patches/rof_structs.h
|
||||
patches/titanium.h
|
||||
patches/titanium_itemfields.h
|
||||
patches/titanium_ops.h
|
||||
patches/titanium_constants.h
|
||||
patches/titanium_structs.h
|
||||
patches/underfoot.h
|
||||
patches/underfoot_itemfields.h
|
||||
patches/underfoot_ops.h
|
||||
patches/underfoot_constants.h
|
||||
patches/underfoot_structs.h
|
||||
patches/client62.cpp
|
||||
patches/patches.cpp
|
||||
patches/sod.cpp
|
||||
patches/sof.cpp
|
||||
patches/rof.cpp
|
||||
patches/titanium.cpp
|
||||
patches/underfoot.cpp
|
||||
)
|
||||
|
||||
SOURCE_GROUP(SocketLib FILES
|
||||
SocketLib/Base64.h
|
||||
SocketLib/File.h
|
||||
SocketLib/HttpdCookies.h
|
||||
SocketLib/HttpdForm.h
|
||||
SocketLib/HttpdSocket.h
|
||||
SocketLib/HTTPSocket.h
|
||||
SocketLib/IFile.h
|
||||
SocketLib/MemFile.h
|
||||
SocketLib/Mime.h
|
||||
SocketLib/Parse.h
|
||||
SocketLib/socket_include.h
|
||||
SocketLib/Utility.h
|
||||
SocketLib/Base64.cpp
|
||||
SocketLib/File.cpp
|
||||
SocketLib/HttpdCookies.cpp
|
||||
SocketLib/HttpdForm.cpp
|
||||
SocketLib/HttpdSocket.cpp
|
||||
SocketLib/HTTPSocket.cpp
|
||||
SocketLib/MemFile.cpp
|
||||
SocketLib/Mime.cpp
|
||||
SocketLib/Parse.cpp
|
||||
SocketLib/socket_include.cpp
|
||||
SocketLib/Utility.cpp
|
||||
)
|
||||
|
||||
SOURCE_GROUP(StackWalker FILES
|
||||
StackWalker/StackWalker.h
|
||||
StackWalker/StackWalker.cpp
|
||||
)
|
||||
|
||||
SOURCE_GROUP(TinyXML FILES
|
||||
tinyxml/tinystr.h
|
||||
tinyxml/tinyxml.h
|
||||
tinyxml/tinystr.cpp
|
||||
tinyxml/tinyxml.cpp
|
||||
tinyxml/tinyxmlerror.cpp
|
||||
tinyxml/tinyxmlparser.cpp
|
||||
)
|
||||
|
||||
INCLUDE_DIRECTORIES(Patches SocketLib StackWalker TinyXML)
|
||||
|
||||
ADD_LIBRARY(common ${common_sources} ${common_headers})
|
||||
|
||||
IF(UNIX)
|
||||
ADD_DEFINITIONS(-fPIC)
|
||||
SET_SOURCE_FILES_PROPERTIES("patches/sod.cpp" "patches/sof.cpp" "patches/rof.cpp" "patches/underfoot.cpp" PROPERTIES COMPILE_FLAGS -O0)
|
||||
ENDIF(UNIX)
|
||||
|
||||
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
@@ -0,0 +1,266 @@
|
||||
/** \file Base64.cpp
|
||||
** \date 2004-02-13
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Base64.h"
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
const char *Base64::bstr =
|
||||
"ABCDEFGHIJKLMNOPQ"
|
||||
"RSTUVWXYZabcdefgh"
|
||||
"ijklmnopqrstuvwxy"
|
||||
"z0123456789+/";
|
||||
|
||||
const char Base64::rstr[] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, 63,
|
||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0, 0, 0, 0, 0,
|
||||
0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0};
|
||||
|
||||
|
||||
void Base64::encode(FILE *fil, std::string& output, bool add_crlf)
|
||||
{
|
||||
size_t remain;
|
||||
size_t i = 0;
|
||||
size_t o = 0;
|
||||
char input[4];
|
||||
|
||||
output = "";
|
||||
remain = fread(input,1,3,fil);
|
||||
while (remain > 0)
|
||||
{
|
||||
if (add_crlf && o && o % 76 == 0)
|
||||
output += "\n";
|
||||
switch (remain)
|
||||
{
|
||||
case 1:
|
||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
||||
output += bstr[ ((input[i] << 4) & 0x30) ];
|
||||
output += "==";
|
||||
break;
|
||||
case 2:
|
||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
||||
output += bstr[ ((input[i] << 4) & 0x30) + ((input[i + 1] >> 4) & 0x0f) ];
|
||||
output += bstr[ ((input[i + 1] << 2) & 0x3c) ];
|
||||
output += "=";
|
||||
break;
|
||||
default:
|
||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
||||
output += bstr[ ((input[i] << 4) & 0x30) + ((input[i + 1] >> 4) & 0x0f) ];
|
||||
output += bstr[ ((input[i + 1] << 2) & 0x3c) + ((input[i + 2] >> 6) & 0x03) ];
|
||||
output += bstr[ (input[i + 2] & 0x3f) ];
|
||||
}
|
||||
o += 4;
|
||||
//
|
||||
remain = fread(input,1,3,fil);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Base64::encode(const std::string& str_in, std::string& str_out, bool add_crlf)
|
||||
{
|
||||
encode(str_in.c_str(), str_in.size(), str_out, add_crlf);
|
||||
}
|
||||
|
||||
|
||||
void Base64::encode(const char* input,size_t l,std::string& output, bool add_crlf)
|
||||
{
|
||||
size_t i = 0;
|
||||
size_t o = 0;
|
||||
|
||||
output = "";
|
||||
while (i < l)
|
||||
{
|
||||
size_t remain = l - i;
|
||||
if (add_crlf && o && o % 76 == 0)
|
||||
output += "\n";
|
||||
switch (remain)
|
||||
{
|
||||
case 1:
|
||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
||||
output += bstr[ ((input[i] << 4) & 0x30) ];
|
||||
output += "==";
|
||||
break;
|
||||
case 2:
|
||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
||||
output += bstr[ ((input[i] << 4) & 0x30) + ((input[i + 1] >> 4) & 0x0f) ];
|
||||
output += bstr[ ((input[i + 1] << 2) & 0x3c) ];
|
||||
output += "=";
|
||||
break;
|
||||
default:
|
||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
||||
output += bstr[ ((input[i] << 4) & 0x30) + ((input[i + 1] >> 4) & 0x0f) ];
|
||||
output += bstr[ ((input[i + 1] << 2) & 0x3c) + ((input[i + 2] >> 6) & 0x03) ];
|
||||
output += bstr[ (input[i + 2] & 0x3f) ];
|
||||
}
|
||||
o += 4;
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Base64::encode(unsigned char* input,size_t l,std::string& output,bool add_crlf)
|
||||
{
|
||||
size_t i = 0;
|
||||
size_t o = 0;
|
||||
|
||||
output = "";
|
||||
while (i < l)
|
||||
{
|
||||
size_t remain = l - i;
|
||||
if (add_crlf && o && o % 76 == 0)
|
||||
output += "\n";
|
||||
switch (remain)
|
||||
{
|
||||
case 1:
|
||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
||||
output += bstr[ ((input[i] << 4) & 0x30) ];
|
||||
output += "==";
|
||||
break;
|
||||
case 2:
|
||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
||||
output += bstr[ ((input[i] << 4) & 0x30) + ((input[i + 1] >> 4) & 0x0f) ];
|
||||
output += bstr[ ((input[i + 1] << 2) & 0x3c) ];
|
||||
output += "=";
|
||||
break;
|
||||
default:
|
||||
output += bstr[ ((input[i] >> 2) & 0x3f) ];
|
||||
output += bstr[ ((input[i] << 4) & 0x30) + ((input[i + 1] >> 4) & 0x0f) ];
|
||||
output += bstr[ ((input[i + 1] << 2) & 0x3c) + ((input[i + 2] >> 6) & 0x03) ];
|
||||
output += bstr[ (input[i + 2] & 0x3f) ];
|
||||
}
|
||||
o += 4;
|
||||
i += 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Base64::decode(const std::string& input,std::string& output)
|
||||
{
|
||||
size_t i = 0;
|
||||
size_t l = input.size();
|
||||
|
||||
output = "";
|
||||
while (i < l)
|
||||
{
|
||||
while (i < l && (input[i] == 13 || input[i] == 10))
|
||||
i++;
|
||||
if (i < l)
|
||||
{
|
||||
char b1 = (char)((rstr[(int)input[i]] << 2 & 0xfc) +
|
||||
(rstr[(int)input[i + 1]] >> 4 & 0x03));
|
||||
output += b1;
|
||||
if (input[i + 2] != '=')
|
||||
{
|
||||
char b2 = (char)((rstr[(int)input[i + 1]] << 4 & 0xf0) +
|
||||
(rstr[(int)input[i + 2]] >> 2 & 0x0f));
|
||||
output += b2;
|
||||
}
|
||||
if (input[i + 3] != '=')
|
||||
{
|
||||
char b3 = (char)((rstr[(int)input[i + 2]] << 6 & 0xc0) +
|
||||
rstr[(int)input[i + 3]]);
|
||||
output += b3;
|
||||
}
|
||||
i += 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Base64::decode(const std::string& input, unsigned char *output, size_t& sz)
|
||||
{
|
||||
size_t i = 0;
|
||||
size_t l = input.size();
|
||||
size_t j = 0;
|
||||
|
||||
while (i < l)
|
||||
{
|
||||
while (i < l && (input[i] == 13 || input[i] == 10))
|
||||
i++;
|
||||
if (i < l)
|
||||
{
|
||||
unsigned char b1 = (unsigned char)((rstr[(int)input[i]] << 2 & 0xfc) +
|
||||
(rstr[(int)input[i + 1]] >> 4 & 0x03));
|
||||
if (output)
|
||||
{
|
||||
output[j] = b1;
|
||||
}
|
||||
j++;
|
||||
if (input[i + 2] != '=')
|
||||
{
|
||||
unsigned char b2 = (unsigned char)((rstr[(int)input[i + 1]] << 4 & 0xf0) +
|
||||
(rstr[(int)input[i + 2]] >> 2 & 0x0f));
|
||||
if (output)
|
||||
{
|
||||
output[j] = b2;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if (input[i + 3] != '=')
|
||||
{
|
||||
unsigned char b3 = (unsigned char)((rstr[(int)input[i + 2]] << 6 & 0xc0) +
|
||||
rstr[(int)input[i + 3]]);
|
||||
if (output)
|
||||
{
|
||||
output[j] = b3;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
i += 4;
|
||||
}
|
||||
}
|
||||
sz = j;
|
||||
}
|
||||
|
||||
|
||||
size_t Base64::decode_length(const std::string& str64)
|
||||
{
|
||||
if (!str64.size() || str64.size() % 4)
|
||||
return 0;
|
||||
size_t l = 3 * (str64.size() / 4 - 1) + 1;
|
||||
if (str64[str64.size() - 2] != '=')
|
||||
l++;
|
||||
if (str64[str64.size() - 1] != '=')
|
||||
l++;
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/** \file Base64.h
|
||||
** \date 2004-02-13
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef _BASE64_H
|
||||
#define _BASE64_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
/** \defgroup util Utilities */
|
||||
|
||||
/** Base64 encode/decode.
|
||||
\ingroup util */
|
||||
class Base64 {
|
||||
public:
|
||||
|
||||
static void encode(FILE *, std::string& , bool add_crlf = true);
|
||||
static void encode(const std::string&, std::string& , bool add_crlf = true);
|
||||
static void encode(const char *, size_t, std::string& , bool add_crlf = true);
|
||||
static void encode(unsigned char *, size_t, std::string& , bool add_crlf = true);
|
||||
|
||||
static void decode(const std::string&, std::string& );
|
||||
static void decode(const std::string& in, unsigned char *out, size_t&);
|
||||
|
||||
static size_t decode_length(const std::string& );
|
||||
|
||||
private:
|
||||
static const char *bstr;
|
||||
static const char rstr[128];
|
||||
};
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _BASE64_H
|
||||
@@ -0,0 +1,126 @@
|
||||
/** \file File.cpp
|
||||
** \date 2005-04-25
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "File.h"
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
File::File()
|
||||
:m_fil(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
File::~File()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool File::fopen(const std::string& path, const std::string& mode)
|
||||
{
|
||||
m_path = path;
|
||||
m_mode = mode;
|
||||
m_fil = ::fopen(path.c_str(), mode.c_str());
|
||||
return m_fil ? true : false;
|
||||
}
|
||||
|
||||
|
||||
void File::fclose()
|
||||
{
|
||||
if (m_fil)
|
||||
::fclose(m_fil);
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t File::fread(char *ptr, size_t size, size_t nmemb)
|
||||
{
|
||||
return m_fil ? ::fread(ptr, size, nmemb, m_fil) : 0;
|
||||
}
|
||||
|
||||
|
||||
size_t File::fwrite(const char *ptr, size_t size, size_t nmemb)
|
||||
{
|
||||
return m_fil ? ::fwrite(ptr, size, nmemb, m_fil) : 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *File::fgets(char *s, int size)
|
||||
{
|
||||
return m_fil ? ::fgets(s, size, m_fil) : nullptr;
|
||||
}
|
||||
|
||||
|
||||
void File::fprintf(char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vfprintf(m_fil, format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
|
||||
off_t File::size()
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(m_path.c_str(), &st) == -1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return st.st_size;
|
||||
}
|
||||
|
||||
|
||||
bool File::eof()
|
||||
{
|
||||
if (m_fil)
|
||||
{
|
||||
if (feof(m_fil))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
/** \file File.h
|
||||
** \date 2005-04-25
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef _FILE_H
|
||||
#define _FILE_H
|
||||
|
||||
#include "IFile.h"
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
/** IFile implementation of a disk file.
|
||||
\ingroup file */
|
||||
class File : public IFile
|
||||
{
|
||||
public:
|
||||
File();
|
||||
~File();
|
||||
|
||||
bool fopen(const std::string&, const std::string&);
|
||||
void fclose();
|
||||
|
||||
size_t fread(char *, size_t, size_t);
|
||||
size_t fwrite(const char *, size_t, size_t);
|
||||
|
||||
char *fgets(char *, int);
|
||||
void fprintf(char *format, ...);
|
||||
|
||||
off_t size();
|
||||
bool eof();
|
||||
|
||||
private:
|
||||
File(const File& ) {} // copy constructor
|
||||
File& operator=(const File& ) { return *this; } // assignment operator
|
||||
|
||||
std::string m_path;
|
||||
std::string m_mode;
|
||||
FILE *m_fil;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _FILE_H
|
||||
@@ -0,0 +1,366 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
*
|
||||
* This code originated from `C++ Sockets Library` referenced below.
|
||||
* Taken and stripped/modified to remove dependancies on parts of
|
||||
* the library which we are not using, and to suit other needs.
|
||||
* 2006 - EQEMu Development Team (http://eqemulator.net)
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file HTTPSocket.cpp
|
||||
** \date 2004-04-06
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
#include "../debug.h"
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <stdarg.h>
|
||||
#include "Parse.h"
|
||||
#include "HTTPSocket.h"
|
||||
#include "../tcp_connection.h"
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
HTTPSocket::HTTPSocket(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort)
|
||||
:TCPConnection(ID,in_socket,irIP,irPort)
|
||||
,m_first(true)
|
||||
,m_header(true)
|
||||
,m_http_version("HTTP/1.0")
|
||||
,m_request(false)
|
||||
,m_response(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
HTTPSocket::~HTTPSocket()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* eqemu stuff
|
||||
*/
|
||||
|
||||
bool HTTPSocket::ProcessReceivedData(char *errbuf)
|
||||
{
|
||||
if (errbuf)
|
||||
errbuf[0] = 0;
|
||||
if (!recvbuf)
|
||||
return true;
|
||||
|
||||
char *buff=(char *)recvbuf;
|
||||
unsigned long bufflen=recvbuf_used;
|
||||
|
||||
while(1) {
|
||||
if (m_header) {
|
||||
char *ptr=(char *)memchr(buff,'\n',bufflen);
|
||||
if (!ptr)
|
||||
break;
|
||||
int length=(ptr-buff)+1;
|
||||
std::string line;
|
||||
line.append(buff,length-2);
|
||||
OnLine(line);
|
||||
|
||||
buff+=length;
|
||||
bufflen-=length;
|
||||
} else {
|
||||
OnData(buff,bufflen);
|
||||
buff+=bufflen;
|
||||
bufflen=0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bufflen) {
|
||||
memmove(recvbuf,buff,bufflen);
|
||||
recvbuf_used=bufflen;
|
||||
} else {
|
||||
safe_delete_array(recvbuf);
|
||||
}
|
||||
}
|
||||
|
||||
bool HTTPSocket::SendString(const char *str) {
|
||||
return(TCPConnection::Send((const uchar *) str, strlen(str)));
|
||||
}
|
||||
|
||||
bool HTTPSocket::SendBuf(const char *dat, unsigned int len) {
|
||||
return(TCPConnection::Send((const uchar *) dat, len));
|
||||
}
|
||||
|
||||
/*
|
||||
* /eqemu stuff
|
||||
*/
|
||||
|
||||
void HTTPSocket::OnLine(const std::string& line)
|
||||
{
|
||||
if (m_first)
|
||||
{
|
||||
Parse pa(line);
|
||||
std::string str = pa.getword();
|
||||
if (str.substr(0,4) == "HTTP") // response
|
||||
{
|
||||
m_http_version = str;
|
||||
m_status = pa.getword();
|
||||
m_status_text = pa.getrest();
|
||||
m_response = true;
|
||||
}
|
||||
else // request
|
||||
{
|
||||
m_method = str;
|
||||
m_url = pa.getword();
|
||||
size_t spl = m_url.find("?");
|
||||
if (spl != std::string::npos)
|
||||
{
|
||||
m_uri = m_url.substr(0,spl);
|
||||
m_query_string = m_url.substr(spl + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_uri = m_url;
|
||||
}
|
||||
m_http_version = pa.getword();
|
||||
m_request = true;
|
||||
}
|
||||
m_first = false;
|
||||
OnFirst();
|
||||
return;
|
||||
}
|
||||
if (!line.size())
|
||||
{
|
||||
// SetLineProtocol(false);
|
||||
m_header = false;
|
||||
OnHeaderComplete();
|
||||
return;
|
||||
}
|
||||
Parse pa(line,":");
|
||||
std::string key = pa.getword();
|
||||
std::string value = pa.getrest();
|
||||
OnHeader(key,value);
|
||||
/* If remote end tells us to keep connection alive, and we're operating
|
||||
in http/1.1 mode (not http/1.0 mode), then we mark the socket to be
|
||||
retained. */
|
||||
/* if (!strcasecmp(key.c_str(), "connection") &&
|
||||
!strcasecmp(value.c_str(), "keep-alive") )
|
||||
{
|
||||
SetRetain();
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::SendResponse()
|
||||
{
|
||||
std::string msg;
|
||||
msg = m_http_version + " " + m_status + " " + m_status_text + "\r\n";
|
||||
for (string_m::iterator it = m_response_header.begin(); it != m_response_header.end(); it++)
|
||||
{
|
||||
std::string key = (*it).first;
|
||||
std::string val = (*it).second;
|
||||
msg += key + ": " + val + "\r\n";
|
||||
}
|
||||
msg += "\r\n";
|
||||
SendString( msg.c_str() );
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::AddResponseHeader(const std::string& header, const char *format, ...)
|
||||
{
|
||||
static char slask[5000];
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
#ifdef _WIN32
|
||||
vsprintf(slask, format, ap);
|
||||
#else
|
||||
vsnprintf(slask, 5000, format, ap);
|
||||
#endif
|
||||
va_end(ap);
|
||||
|
||||
m_response_header[header] = slask;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::SendRequest()
|
||||
{
|
||||
std::string msg;
|
||||
msg = m_method + " " + m_url + " " + m_http_version + "\r\n";
|
||||
for (string_m::iterator it = m_response_header.begin(); it != m_response_header.end(); it++)
|
||||
{
|
||||
std::string key = (*it).first;
|
||||
std::string val = (*it).second;
|
||||
msg += key + ": " + val + "\r\n";
|
||||
}
|
||||
msg += "\r\n";
|
||||
SendString( msg.c_str() );
|
||||
}
|
||||
|
||||
|
||||
std::string HTTPSocket::MyUseragent()
|
||||
{
|
||||
std::string version = "C++Sockets/";
|
||||
#ifdef _VERSION
|
||||
version += _VERSION;
|
||||
#endif
|
||||
return version;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::Reset()
|
||||
{
|
||||
m_first = true;
|
||||
m_header = true;
|
||||
m_request = false;
|
||||
m_response = false;
|
||||
// SetLineProtocol(true);
|
||||
while (m_response_header.size())
|
||||
{
|
||||
string_m::iterator it = m_response_header.begin();
|
||||
m_response_header.erase(it);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
const std::string& HTTPSocket::GetMethod()
|
||||
{
|
||||
return m_method;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::SetMethod(const std::string& x)
|
||||
{
|
||||
m_method = x;
|
||||
}
|
||||
|
||||
|
||||
const std::string& HTTPSocket::GetUrl()
|
||||
{
|
||||
return m_url;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::SetUrl(const std::string& x)
|
||||
{
|
||||
m_url = x;
|
||||
}
|
||||
|
||||
|
||||
const std::string& HTTPSocket::GetUri()
|
||||
{
|
||||
return m_uri;
|
||||
}
|
||||
|
||||
|
||||
const std::string& HTTPSocket::GetQueryString()
|
||||
{
|
||||
return m_query_string;
|
||||
}
|
||||
|
||||
|
||||
const std::string& HTTPSocket::GetHttpVersion()
|
||||
{
|
||||
return m_http_version;
|
||||
}
|
||||
|
||||
|
||||
const std::string& HTTPSocket::GetStatus()
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
|
||||
const std::string& HTTPSocket::GetStatusText()
|
||||
{
|
||||
return m_status_text;
|
||||
}
|
||||
|
||||
|
||||
bool HTTPSocket::IsRequest()
|
||||
{
|
||||
return m_request;
|
||||
}
|
||||
|
||||
|
||||
bool HTTPSocket::IsResponse()
|
||||
{
|
||||
return m_response;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::SetHttpVersion(const std::string& x)
|
||||
{
|
||||
m_http_version = x;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::SetStatus(const std::string& num, const std::string& text) {
|
||||
m_status = num;
|
||||
m_status_text = text;
|
||||
}
|
||||
|
||||
void HTTPSocket::SetStatus(const std::string& x)
|
||||
{
|
||||
m_status = x;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::SetStatusText(const std::string& x)
|
||||
{
|
||||
m_status_text = x;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::AddResponseHeader(const std::string& x,const std::string& y)
|
||||
{
|
||||
m_response_header[x] = y;
|
||||
}
|
||||
|
||||
|
||||
void HTTPSocket::SetUri(const std::string& x)
|
||||
{
|
||||
m_uri = x;
|
||||
}
|
||||
|
||||
void HTTPSocket::SendResponse(const std::string& status_num, const std::string& status_text) {
|
||||
SetStatus(status_num, status_text);
|
||||
SendResponse();
|
||||
}
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
*
|
||||
* This code originated from `C++ Sockets Library` referenced below.
|
||||
* Taken and stripped/modified to remove dependancies on parts of
|
||||
* the library which we are not using, and to suit other needs.
|
||||
* 2006 - EQEMu Development Team (http://eqemulator.net)
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
/** \file HTTPSocket.h Class HTTPSocket definition.
|
||||
** \date 2004-04-06
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef _HTTPSOCKET_H
|
||||
#define _HTTPSOCKET_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "../tcp_connection.h"
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
/** \defgroup http HTTP Sockets */
|
||||
/** HTTP request/response base class.
|
||||
\ingroup http */
|
||||
class HTTPSocket : public TCPConnection
|
||||
{
|
||||
/** map to hold http header values. */
|
||||
typedef std::map<std::string,std::string> string_m;
|
||||
public:
|
||||
HTTPSocket(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort);
|
||||
virtual ~HTTPSocket();
|
||||
|
||||
void OnLine(const std::string& line);
|
||||
|
||||
/** Callback executes when first line has been received.
|
||||
GetMethod, GetUrl/GetUri, and GetHttpVersion are valid when this callback is executed. */
|
||||
virtual void OnFirst() = 0;
|
||||
/** For each header line this callback is executed.
|
||||
\param key Http header name
|
||||
\param value Http header value */
|
||||
virtual void OnHeader(const std::string& key,const std::string& value) = 0;
|
||||
/** Callback fires when all http headers have been received. */
|
||||
virtual void OnHeaderComplete() = 0;
|
||||
/** Chunk of http body data recevied. */
|
||||
virtual void OnData(const char *,size_t) = 0;
|
||||
|
||||
const std::string& GetMethod();
|
||||
void SetMethod(const std::string& x);
|
||||
const std::string& GetUrl();
|
||||
void SetUrl(const std::string& x);
|
||||
const std::string& GetUri();
|
||||
void SetUri(const std::string& x);
|
||||
const std::string& GetQueryString();
|
||||
const std::string& GetHttpVersion();
|
||||
const std::string& GetStatus();
|
||||
const std::string& GetStatusText();
|
||||
bool IsRequest();
|
||||
bool IsResponse();
|
||||
|
||||
void SetHttpVersion(const std::string& x);
|
||||
void SetStatus(const std::string& x);
|
||||
void SetStatus(const std::string& num, const std::string& text);
|
||||
void SetStatusText(const std::string& x);
|
||||
void AddResponseHeader(const std::string& x,const std::string& y);
|
||||
void AddResponseHeader(const std::string& x,const char *format, ...);
|
||||
void SendResponse();
|
||||
void SendResponse(const std::string& status_num, const std::string& status_text);
|
||||
void SendRequest();
|
||||
|
||||
/** Implement this to return your own User-agent string. */
|
||||
virtual std::string MyUseragent();
|
||||
|
||||
protected:
|
||||
/** Reset state of socket to sucessfully implement keep-alive. */
|
||||
virtual void Reset();
|
||||
|
||||
//stubs for crap which used to be in our parent class (TcpSocket)
|
||||
bool SendString(const char *str);
|
||||
bool SendBuf(const char *dat, unsigned int len);
|
||||
|
||||
virtual bool ProcessReceivedData(char* errbuf = 0);
|
||||
|
||||
private:
|
||||
// HTTPSocket& operator=(const HTTPSocket& ) { return *this; }
|
||||
bool m_first;
|
||||
bool m_header;
|
||||
std::string m_line;
|
||||
std::string m_method;
|
||||
std::string m_url;
|
||||
std::string m_uri;
|
||||
std::string m_query_string;
|
||||
std::string m_http_version;
|
||||
std::string m_status;
|
||||
std::string m_status_text;
|
||||
bool m_request;
|
||||
bool m_response;
|
||||
string_m m_response_header;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _HTTPSOCKET_H
|
||||
@@ -0,0 +1,250 @@
|
||||
/** \file HttpdCookies.cpp
|
||||
*/
|
||||
/*
|
||||
Copyright (C) 2003-2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "../debug.h"
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
#include "Parse.h"
|
||||
#include "Utility.h"
|
||||
#include "HTTPSocket.h"
|
||||
#include "HttpdCookies.h"
|
||||
#include "../types.h"
|
||||
#include <time.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
HttpdCookies::HttpdCookies()
|
||||
{
|
||||
}
|
||||
|
||||
HttpdCookies::HttpdCookies(const std::string& s)
|
||||
{
|
||||
Parse *pa = new Parse(s,";");
|
||||
|
||||
std::string slask = pa -> getword();
|
||||
while (slask.size())
|
||||
{
|
||||
Parse *pa2 = new Parse(slask,"=");
|
||||
std::string name = pa2 -> getword();
|
||||
std::string value = pa2 -> getword();
|
||||
delete pa2;
|
||||
COOKIE *c = new COOKIE(name,value);
|
||||
m_cookies.push_back(c);
|
||||
//
|
||||
slask = pa -> getword();
|
||||
}
|
||||
delete pa;
|
||||
}
|
||||
|
||||
HttpdCookies::~HttpdCookies()
|
||||
{
|
||||
for (cookie_v::iterator it = m_cookies.begin(); it != m_cookies.end(); it++)
|
||||
{
|
||||
COOKIE *c = *it;
|
||||
delete c;
|
||||
}
|
||||
}
|
||||
|
||||
bool HttpdCookies::getvalue(const std::string& name,std::string& buffer) //char *buffer,size_t length)
|
||||
{
|
||||
for (cookie_v::iterator it = m_cookies.begin(); it != m_cookies.end(); it++)
|
||||
{
|
||||
COOKIE *c = *it;
|
||||
if (!strcasecmp(c -> name.c_str(),name.c_str()))
|
||||
{
|
||||
buffer = c -> value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
buffer = "";
|
||||
return false;
|
||||
}
|
||||
|
||||
void HttpdCookies::replacevalue(const std::string& name,const std::string& value)
|
||||
{
|
||||
COOKIE *c = nullptr;
|
||||
|
||||
for (cookie_v::iterator it = m_cookies.begin(); it != m_cookies.end(); it++)
|
||||
{
|
||||
c = *it;
|
||||
if (!strcasecmp(c -> name.c_str(),name.c_str()))
|
||||
break;
|
||||
c = nullptr;
|
||||
}
|
||||
|
||||
if (c)
|
||||
{
|
||||
c -> value = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
c = new COOKIE(name,value);
|
||||
m_cookies.push_back(c);
|
||||
}
|
||||
}
|
||||
|
||||
void HttpdCookies::replacevalue(const std::string& name,long l)
|
||||
{
|
||||
replacevalue(name, Utility::l2string(l));
|
||||
}
|
||||
|
||||
void HttpdCookies::replacevalue(const std::string& name,int i)
|
||||
{
|
||||
replacevalue(name, Utility::l2string(i));
|
||||
}
|
||||
|
||||
size_t HttpdCookies::getlength(const std::string& name)
|
||||
{
|
||||
COOKIE *c = nullptr;
|
||||
|
||||
for (cookie_v::iterator it = m_cookies.begin(); it != m_cookies.end(); it++)
|
||||
{
|
||||
c = *it;
|
||||
if (!strcasecmp(c -> name.c_str(),name.c_str()))
|
||||
break;
|
||||
c = nullptr;
|
||||
}
|
||||
return c ? c -> value.size() : 0;
|
||||
}
|
||||
|
||||
void HttpdCookies::setcookie(HTTPSocket *sock, const std::string& domain, const std::string& path, const std::string& name, const std::string& value)
|
||||
{
|
||||
char *str = new char[name.size() + value.size() + domain.size() + path.size() + 100];
|
||||
|
||||
// set-cookie response
|
||||
if (domain.size())
|
||||
{
|
||||
sprintf(str, "%s=%s; domain=%s; path=%s; expires=%s",
|
||||
name.c_str(), value.c_str(),
|
||||
domain.c_str(),
|
||||
path.c_str(),
|
||||
expiredatetime().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(str, "%s=%s; path=%s; expires=%s",
|
||||
name.c_str(), value.c_str(),
|
||||
path.c_str(),
|
||||
expiredatetime().c_str());
|
||||
}
|
||||
sock -> AddResponseHeader("Set-cookie", str);
|
||||
delete[] str;
|
||||
|
||||
replacevalue(name, value);
|
||||
}
|
||||
|
||||
void HttpdCookies::setcookie(HTTPSocket *sock, const std::string& domain, const std::string& path, const std::string& name, long value)
|
||||
{
|
||||
char *str = new char[name.size() + domain.size() + path.size() + 100];
|
||||
char dt[80];
|
||||
|
||||
// set-cookie response
|
||||
if (domain.size())
|
||||
{
|
||||
sprintf(str, "%s=%ld; domain=%s; path=%s; expires=%s",
|
||||
name.c_str(), value,
|
||||
domain.c_str(),
|
||||
path.c_str(),
|
||||
expiredatetime().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(str, "%s=%ld; path=%s; expires=%s",
|
||||
name.c_str(), value,
|
||||
path.c_str(),
|
||||
expiredatetime().c_str());
|
||||
}
|
||||
sock -> AddResponseHeader("Set-cookie", str);
|
||||
delete[] str;
|
||||
|
||||
sprintf(dt, "%ld", value);
|
||||
replacevalue(name, dt);
|
||||
}
|
||||
|
||||
void HttpdCookies::setcookie(HTTPSocket *sock, const std::string& domain, const std::string& path, const std::string& name, int value)
|
||||
{
|
||||
char *str = new char[name.size() + domain.size() + path.size() + 100];
|
||||
char dt[80];
|
||||
|
||||
// set-cookie response
|
||||
if (domain.size())
|
||||
{
|
||||
sprintf(str, "%s=%d; domain=%s; path=%s; expires=%s",
|
||||
name.c_str(), value,
|
||||
domain.c_str(),
|
||||
path.c_str(),
|
||||
expiredatetime().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(str, "%s=%d; path=%s; expires=%s",
|
||||
name.c_str(), value,
|
||||
path.c_str(),
|
||||
expiredatetime().c_str());
|
||||
}
|
||||
sock -> AddResponseHeader("Set-cookie", str);
|
||||
delete[] str;
|
||||
|
||||
sprintf(dt, "%d", value);
|
||||
replacevalue(name, dt);
|
||||
}
|
||||
|
||||
|
||||
const std::string& HttpdCookies::expiredatetime()
|
||||
{
|
||||
time_t t = time(nullptr);
|
||||
struct tm * tp = gmtime(&t);
|
||||
const char *days[7] = {"Sunday", "Monday",
|
||||
"Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
|
||||
const char *months[12] = {"Jan", "Feb", "Mar", "Apr", "May",
|
||||
"Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
char dt[100];
|
||||
|
||||
sprintf(dt, "%s, %02d-%s-%04d %02d:%02d:%02d GMT",
|
||||
days[tp -> tm_wday],
|
||||
tp -> tm_mday,
|
||||
months[tp -> tm_mon],
|
||||
tp -> tm_year + 1910,
|
||||
tp -> tm_hour,
|
||||
tp -> tm_min,
|
||||
tp -> tm_sec);
|
||||
m_date = dt;
|
||||
return m_date;
|
||||
}
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/** \file HttpdCookies.h
|
||||
*/
|
||||
/*
|
||||
Copyright (C) 2003-2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _COOKIES_H
|
||||
#define _COOKIES_H
|
||||
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
//! Store the cookies name/value pairs.
|
||||
|
||||
|
||||
|
||||
//! Retrieve and manage cookies during a cgi call.
|
||||
class HTTPSocket;
|
||||
|
||||
/** HTTP Cookie parse/container class.
|
||||
\sa HttpdSocket
|
||||
\sa HttpdForm
|
||||
\ingroup webserver */
|
||||
class HttpdCookies
|
||||
{
|
||||
/** Name/value pair store struct.
|
||||
\ingroup webserver */
|
||||
struct COOKIE
|
||||
{
|
||||
COOKIE(const std::string& n,const std::string& v) : name(n),value(v) {}
|
||||
std::string name;
|
||||
std::string value;
|
||||
};
|
||||
/** list of key/value structs. */
|
||||
typedef std::list<COOKIE *> cookie_v;
|
||||
public:
|
||||
HttpdCookies();
|
||||
HttpdCookies(const std::string& query_string);
|
||||
~HttpdCookies();
|
||||
|
||||
// int getvalue(const std::string& ,char *,size_t); // (name, buffer, length)
|
||||
bool getvalue(const std::string&,std::string&);
|
||||
void replacevalue(const std::string& ,const std::string& );
|
||||
void replacevalue(const std::string& ,long);
|
||||
void replacevalue(const std::string& ,int);
|
||||
size_t getlength(const std::string& );
|
||||
void setcookie(HTTPSocket *,const std::string& d,const std::string& p,const std::string& c,const std::string& v);
|
||||
void setcookie(HTTPSocket *,const std::string& d,const std::string& p,const std::string& c,long v);
|
||||
void setcookie(HTTPSocket *,const std::string& d,const std::string& p,const std::string& c,int v);
|
||||
const std::string& expiredatetime();
|
||||
|
||||
cookie_v& GetHttpdCookies() { return m_cookies; }
|
||||
|
||||
private:
|
||||
cookie_v m_cookies;
|
||||
std::string m_date;
|
||||
};
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _COOKIES_H
|
||||
@@ -0,0 +1,621 @@
|
||||
/** \file HttpdForm.cpp - read stdin, parse cgi input
|
||||
**
|
||||
** Written: 1999-Feb-10 grymse@alhem.net
|
||||
**/
|
||||
|
||||
/*
|
||||
Copyright (C) 1999-2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable:4786)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#include "socket_include.h"
|
||||
#include "Parse.h"
|
||||
#include "IFile.h"
|
||||
#include "HttpdForm.h"
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
HttpdForm::HttpdForm(IFile *infil) : raw(false)
|
||||
{
|
||||
CGI *cgi = nullptr;
|
||||
char *c_t = getenv("CONTENT_TYPE");
|
||||
char *c_l = getenv("CONTENT_LENGTH");
|
||||
size_t extra = 2;
|
||||
char name[200];
|
||||
|
||||
m_current = m_cgi.end();
|
||||
*name = 0;
|
||||
|
||||
if (c_t && !strncmp(c_t, "multipart/form-data",19))
|
||||
{
|
||||
Parse pa(c_t,";=");
|
||||
char *tempcmp = nullptr;
|
||||
size_t tc = 0;
|
||||
size_t l = 0;
|
||||
std::string str = pa.getword();
|
||||
m_strBoundary = "";
|
||||
while (str.size())
|
||||
{
|
||||
if (!strcmp(str.c_str(),"boundary"))
|
||||
{
|
||||
m_strBoundary = pa.getword();
|
||||
l = m_strBoundary.size();
|
||||
tempcmp = new char[l + extra];
|
||||
}
|
||||
//
|
||||
str = pa.getword();
|
||||
}
|
||||
if (m_strBoundary.size())
|
||||
{
|
||||
std::string content_type;
|
||||
std::string current_name;
|
||||
std::string current_filename;
|
||||
char slask[2000];
|
||||
infil -> fgets(slask, 200);
|
||||
while (!infil -> eof())
|
||||
{
|
||||
while (strlen(slask) && (slask[strlen(slask) - 1] == 13 || slask[strlen(slask) - 1] == 10))
|
||||
{
|
||||
slask[strlen(slask) - 1] = 0;
|
||||
}
|
||||
content_type = "";
|
||||
current_name = "";
|
||||
current_filename = "";
|
||||
if ((strstr(slask,m_strBoundary.c_str()) || strstr(m_strBoundary.c_str(),slask)) && strcmp(slask, m_strBoundary.c_str()))
|
||||
{
|
||||
m_strBoundary = slask;
|
||||
l = m_strBoundary.size();
|
||||
delete[] tempcmp;
|
||||
tempcmp = new char[l + extra];
|
||||
}
|
||||
if (!strcmp(slask, m_strBoundary.c_str()))
|
||||
{
|
||||
// Get headers until empty line
|
||||
infil -> fgets(slask, 200);
|
||||
while (strlen(slask) && (slask[strlen(slask) - 1] == 13 || slask[strlen(slask) - 1] == 10))
|
||||
{
|
||||
slask[strlen(slask) - 1] = 0;
|
||||
}
|
||||
while (!infil -> eof() && *slask)
|
||||
{
|
||||
Parse pa(slask,";");
|
||||
std::string h = pa.getword();
|
||||
if (!strcasecmp(h.c_str(),"Content-type:"))
|
||||
{
|
||||
content_type = pa.getword();
|
||||
}
|
||||
else
|
||||
if (!strcasecmp(h.c_str(),"Content-Disposition:"))
|
||||
{
|
||||
h = pa.getword();
|
||||
if (!strcmp(h.c_str(),"form-data"))
|
||||
{
|
||||
pa.EnableQuote(true);
|
||||
h = pa.getword();
|
||||
while (h.size())
|
||||
{
|
||||
Parse pa2(slask,"=");
|
||||
std::string name = pa2.getword();
|
||||
std::string h = pa2.getrest();
|
||||
if (!strcmp(name.c_str(),"name"))
|
||||
{
|
||||
if (h.size() && h[0] == '"')
|
||||
{
|
||||
current_name = h.substr(1, h.size() - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
current_name = h;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!strcmp(name.c_str(),"filename"))
|
||||
{
|
||||
if (h.size() && h[0] == '"')
|
||||
{
|
||||
current_filename = h.substr(1, h.size() - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
current_filename = h;
|
||||
}
|
||||
size_t x = 0;
|
||||
for (size_t i = 0; i < current_filename.size(); i++)
|
||||
{
|
||||
if (current_filename[i] == '/' || current_filename[i] == '\\')
|
||||
x = i + 1;
|
||||
}
|
||||
if (x)
|
||||
{
|
||||
current_filename = current_filename.substr(x);
|
||||
}
|
||||
}
|
||||
h = pa.getword();
|
||||
}
|
||||
}
|
||||
}
|
||||
// get next header value
|
||||
infil -> fgets(slask, 200);
|
||||
while (strlen(slask) && (slask[strlen(slask) - 1] == 13 || slask[strlen(slask) - 1] == 10))
|
||||
{
|
||||
slask[strlen(slask) - 1] = 0;
|
||||
}
|
||||
}
|
||||
// Read content, save...?
|
||||
if (!current_filename.size()) // not a file
|
||||
{
|
||||
std::string val;
|
||||
infil -> fgets(slask,1000);
|
||||
while (!infil -> eof() && strncmp(slask,m_strBoundary.c_str(),m_strBoundary.size() ))
|
||||
{
|
||||
val += slask;
|
||||
infil -> fgets(slask,1000);
|
||||
}
|
||||
// remove trailing cr/linefeed
|
||||
while (val.size() && (val[val.size() - 1] == 13 || val[val.size() - 1] == 10))
|
||||
{
|
||||
val = val.substr(0,val.size() - 1);
|
||||
}
|
||||
cgi = new CGI(current_name, val);
|
||||
m_cgi.push_back(cgi);
|
||||
}
|
||||
else // current_filename.size() > 0
|
||||
{
|
||||
// read until m_strBoundary...
|
||||
FILE *fil;
|
||||
int out = 0;
|
||||
char c;
|
||||
char fn[1000]; // where post'd file will be saved
|
||||
#ifdef _WIN32
|
||||
{
|
||||
char tmp_path[1000];
|
||||
::GetTempPath(1000, tmp_path);
|
||||
if (tmp_path[strlen(tmp_path) - 1] != '\\')
|
||||
{
|
||||
strcat(tmp_path, "\\");
|
||||
}
|
||||
sprintf(fn,"%s%s",tmp_path,current_filename.c_str());
|
||||
}
|
||||
#else
|
||||
sprintf(fn,"/tmp/%s",current_filename.c_str());
|
||||
#endif
|
||||
if ((fil = fopen(fn, "wb")) != nullptr)
|
||||
{
|
||||
infil -> fread(&c,1,1);
|
||||
while (!infil -> eof())
|
||||
{
|
||||
if (out)
|
||||
{
|
||||
fwrite(&tempcmp[tc],1,1,fil);
|
||||
}
|
||||
tempcmp[tc] = c;
|
||||
tc++;
|
||||
if (tc >= l + extra)
|
||||
{
|
||||
tc = 0;
|
||||
out = 1;
|
||||
}
|
||||
if (tc)
|
||||
{
|
||||
if (!strncmp(tempcmp + tc + extra, m_strBoundary.c_str(), l - tc) &&
|
||||
!strncmp(tempcmp, m_strBoundary.c_str() + l - tc, tc))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!strncmp(tempcmp + extra, m_strBoundary.c_str(), l))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
infil -> fread(&c,1,1);
|
||||
}
|
||||
fclose(fil);
|
||||
|
||||
cgi = new CGI(current_name,fn,fn);
|
||||
m_cgi.push_back(cgi);
|
||||
|
||||
strcpy(slask, m_strBoundary.c_str());
|
||||
infil -> fgets(slask + strlen(slask), 200); // next line
|
||||
}
|
||||
else
|
||||
{
|
||||
// couldn't open file
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Probably '<m_strBoundary>--'
|
||||
break;
|
||||
}
|
||||
} // while (!infil -> eof())
|
||||
} // if (m_strBoundary)
|
||||
if (tempcmp)
|
||||
{
|
||||
delete[] tempcmp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = 0;
|
||||
int cl = c_l ? atoi(c_l) : -1;
|
||||
char c,chigh,clow;
|
||||
char *slask = new char[8888];
|
||||
bool got_name = false;
|
||||
m_current = m_cgi.end();
|
||||
|
||||
*name = 0;
|
||||
|
||||
infil -> fread(&c,1,1);
|
||||
cl--;
|
||||
while (cl >= 0)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case '=': /* end of name */
|
||||
slask[i] = 0;
|
||||
i = 0;
|
||||
strcpy(name,slask);
|
||||
got_name = true;
|
||||
break;
|
||||
case '&': /* end of value */
|
||||
slask[i] = 0;
|
||||
i = 0;
|
||||
if(got_name) {
|
||||
got_name = false;
|
||||
cgi = new CGI(name,slask);
|
||||
m_cgi.push_back(cgi);
|
||||
} else {
|
||||
cgi = new CGI(slask,"");
|
||||
m_cgi.push_back(cgi);
|
||||
}
|
||||
break;
|
||||
case '+': /* space */
|
||||
slask[i++] = ' ';
|
||||
break;
|
||||
case '%': /* hex value */
|
||||
infil -> fread(&chigh,1,1);
|
||||
cl--;
|
||||
chigh -= 48;
|
||||
chigh &= 0xff - 32;
|
||||
if (chigh > 9)
|
||||
chigh -= 7;
|
||||
infil -> fread(&clow,1,1);
|
||||
cl--;
|
||||
clow -= 48;
|
||||
clow &= 0xff - 32;
|
||||
if (clow > 9)
|
||||
clow -= 7;
|
||||
slask[i++] = (char)(chigh * 16 + clow);
|
||||
break;
|
||||
default: /* just another char */
|
||||
slask[i++] = c;
|
||||
break;
|
||||
}
|
||||
if(infil -> eof())
|
||||
break;
|
||||
//
|
||||
if (cl > 0)
|
||||
{
|
||||
infil -> fread(&c,1,1);
|
||||
}
|
||||
cl--;
|
||||
}
|
||||
slask[i] = 0;
|
||||
i = 0;
|
||||
if(got_name) {
|
||||
cgi = new CGI(name,slask);
|
||||
m_cgi.push_back(cgi);
|
||||
} else {
|
||||
cgi = new CGI(slask,"");
|
||||
m_cgi.push_back(cgi);
|
||||
}
|
||||
delete[] slask;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// HttpdForm(buffer,l) -- request_method GET
|
||||
|
||||
HttpdForm::HttpdForm(const std::string& buffer,size_t l) : raw(false)
|
||||
{
|
||||
CGI *cgi = nullptr;
|
||||
char slask[8888];
|
||||
char name[200];
|
||||
int i = 0;
|
||||
char c,chigh,clow;
|
||||
bool got_name = false;
|
||||
size_t ptr = 0;
|
||||
|
||||
m_current = m_cgi.end();
|
||||
|
||||
*name = 0;
|
||||
|
||||
ptr = 0;
|
||||
while (ptr < l)
|
||||
{
|
||||
c = buffer[ptr++];
|
||||
switch (c)
|
||||
{
|
||||
case '=': /* end of name */
|
||||
slask[i] = 0;
|
||||
i = 0;
|
||||
got_name = true;
|
||||
strcpy(name,slask);
|
||||
break;
|
||||
case '&': /* end of value */
|
||||
slask[i] = 0;
|
||||
i = 0;
|
||||
if(got_name) {
|
||||
got_name = false;
|
||||
cgi = new CGI(name,slask);
|
||||
m_cgi.push_back(cgi);
|
||||
} else {
|
||||
cgi = new CGI(slask, "");
|
||||
m_cgi.push_back(cgi);
|
||||
}
|
||||
break;
|
||||
case '+': /* space */
|
||||
slask[i++] = ' ';
|
||||
break;
|
||||
case '%': /* hex value */
|
||||
chigh = buffer[ptr++];
|
||||
chigh -= 48;
|
||||
chigh &= 0xff - 32;
|
||||
if (chigh > 9)
|
||||
chigh -= 7;
|
||||
clow = buffer[ptr++];
|
||||
clow -= 48;
|
||||
clow &= 0xff - 32;
|
||||
if (clow > 9)
|
||||
clow -= 7;
|
||||
slask[i++] = (char)(chigh * 16 + clow);
|
||||
break;
|
||||
default: /* just another char */
|
||||
slask[i++] = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
slask[i] = 0;
|
||||
i = 0;
|
||||
if(got_name) {
|
||||
cgi = new CGI(name,slask);
|
||||
m_cgi.push_back(cgi);
|
||||
} else {
|
||||
cgi = new CGI(slask, "");
|
||||
m_cgi.push_back(cgi);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
HttpdForm::~HttpdForm()
|
||||
{
|
||||
CGI *cgi = nullptr; //,*tmp;
|
||||
|
||||
for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++)
|
||||
{
|
||||
cgi = *it;
|
||||
delete cgi;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HttpdForm::EnableRaw(bool b)
|
||||
{
|
||||
raw = b;
|
||||
}
|
||||
|
||||
|
||||
void HttpdForm::strcpyval(std::string& v,const char *value) //,size_t len)
|
||||
{
|
||||
v = "";
|
||||
for (size_t i = 0; i < strlen(value); i++)
|
||||
{
|
||||
if (value[i] == '<')
|
||||
{
|
||||
v += "<";
|
||||
}
|
||||
else
|
||||
if (value[i] == '>')
|
||||
{
|
||||
v += ">";
|
||||
}
|
||||
else
|
||||
if (value[i] == '&')
|
||||
{
|
||||
v += "&";
|
||||
}
|
||||
else
|
||||
{
|
||||
v += value[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool HttpdForm::getfirst(std::string& n) //char *n,size_t len)
|
||||
{
|
||||
m_current = m_cgi.begin();
|
||||
return getnext(n);
|
||||
}
|
||||
|
||||
|
||||
bool HttpdForm::getnext(std::string& n) //char *n,size_t len)
|
||||
{
|
||||
if (m_current != m_cgi.end() )
|
||||
{
|
||||
CGI *current = *m_current;
|
||||
n = current -> name;
|
||||
m_current++;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
n = "";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool HttpdForm::getfirst(std::string& n,std::string& v) //char *n,size_t len,char *v,size_t vlen)
|
||||
{
|
||||
m_current = m_cgi.begin();
|
||||
return getnext(n,v);
|
||||
}
|
||||
|
||||
|
||||
bool HttpdForm::getnext(std::string& n,std::string& v) //char *n,size_t len,char *v,size_t vlen)
|
||||
{
|
||||
if (m_current != m_cgi.end() )
|
||||
{
|
||||
CGI *current = *m_current;
|
||||
n = current -> name;
|
||||
if (raw)
|
||||
{
|
||||
v = current -> value;
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpyval(v,current -> value.c_str());
|
||||
}
|
||||
m_current++;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
n = "";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int HttpdForm::getvalue(const std::string& n,std::string& v) //char *v,size_t len)
|
||||
{
|
||||
CGI *cgi = nullptr;
|
||||
int r = 0;
|
||||
|
||||
for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++)
|
||||
{
|
||||
cgi = *it;
|
||||
if (cgi -> name == n)
|
||||
break;
|
||||
cgi = nullptr;
|
||||
}
|
||||
if (cgi)
|
||||
{
|
||||
if (raw)
|
||||
{
|
||||
v = cgi -> value;
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpyval(v,cgi -> value.c_str());
|
||||
}
|
||||
r++;
|
||||
}
|
||||
else
|
||||
{
|
||||
v = "";
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
std::string HttpdForm::getvalue(const std::string& n)
|
||||
{
|
||||
for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++)
|
||||
{
|
||||
CGI *cgi = *it;
|
||||
if (cgi -> name == n)
|
||||
{
|
||||
return cgi -> value;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
size_t HttpdForm::getlength(const std::string& n)
|
||||
{
|
||||
CGI *cgi = nullptr;
|
||||
size_t l;
|
||||
|
||||
for (cgi_v::iterator it = m_cgi.begin(); it != m_cgi.end(); it++)
|
||||
{
|
||||
cgi = *it;
|
||||
if (cgi -> name == n)
|
||||
break;
|
||||
cgi = nullptr;
|
||||
}
|
||||
l = cgi ? cgi -> value.size() : 0;
|
||||
if (cgi && !raw)
|
||||
{
|
||||
for (size_t i = 0; i < cgi -> value.size(); i++)
|
||||
{
|
||||
switch (cgi -> value[i])
|
||||
{
|
||||
case '<': // <
|
||||
case '>': // >
|
||||
l += 4;
|
||||
break;
|
||||
case '&': // &
|
||||
l += 5;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
HttpdForm::cgi_v& HttpdForm::getbase()
|
||||
{
|
||||
return m_cgi;
|
||||
}
|
||||
|
||||
|
||||
const std::string& HttpdForm::GetBoundary()
|
||||
{
|
||||
return m_strBoundary;
|
||||
}
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
/** \file HttpdForm.h - read stdin, parse cgi input
|
||||
**
|
||||
** Written: 1999-Feb-10 grymse@alhem.net
|
||||
**/
|
||||
|
||||
/*
|
||||
Copyright (C) 1999-2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _FORM_H
|
||||
#define _FORM_H
|
||||
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
class IFile;
|
||||
|
||||
/** Parse/store a http query_string/form-data body.
|
||||
\ingroup webserver */
|
||||
class HttpdForm
|
||||
{
|
||||
/**
|
||||
* Store the name/value pairs from a GET/POST operation.
|
||||
* "name" does not have to be unique.
|
||||
\ingroup webserver
|
||||
*/
|
||||
struct CGI
|
||||
{
|
||||
CGI(const std::string& n,const std::string& v) : name(n),value(v) {}
|
||||
CGI(const std::string& n,const std::string& v,const std::string& p) : name(n),value(v),path(p) {}
|
||||
std::string name;
|
||||
std::string value;
|
||||
std::string path;
|
||||
};
|
||||
/** list of key/value pairs. */
|
||||
typedef std::list<CGI *> cgi_v;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Default constructor (used in POST operations).
|
||||
* Input is read from stdin. Number of characters to read
|
||||
* can be found in the environment variable CONTENT_LENGTH.
|
||||
*/
|
||||
HttpdForm(IFile *);
|
||||
/**
|
||||
* Another constructor (used in GET operations).
|
||||
* Input is read from the environment variable QUERY_STRING.
|
||||
* @param query_string The httpd server provided QUERY_STRING
|
||||
* @param length Query string length.
|
||||
*/
|
||||
HttpdForm(const std::string& query_string,size_t length);
|
||||
~HttpdForm();
|
||||
|
||||
void EnableRaw(bool);
|
||||
|
||||
void strcpyval(std::string&,const char *); //,size_t);
|
||||
|
||||
/* get names */
|
||||
bool getfirst(std::string& n); //char *,size_t);
|
||||
bool getnext(std::string& n); //char *,size_t);
|
||||
|
||||
/* get names and values */
|
||||
bool getfirst(std::string& n,std::string& v); //char *,size_t,char *,size_t);
|
||||
bool getnext(std::string& n,std::string& v); //char *,size_t,char *,size_t);
|
||||
|
||||
/* get value */
|
||||
int getvalue(const std::string& ,std::string& ); //char *,size_t);
|
||||
std::string getvalue(const std::string& );
|
||||
size_t getlength(const std::string& );
|
||||
cgi_v& getbase();
|
||||
|
||||
const std::string& GetBoundary();
|
||||
|
||||
private:
|
||||
HttpdForm(const HttpdForm& ) {}
|
||||
HttpdForm& operator=(const HttpdForm& ) { return *this; }
|
||||
cgi_v m_cgi;
|
||||
cgi_v::iterator m_current;
|
||||
std::string m_strBoundary;
|
||||
bool raw;
|
||||
};
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _FORM_H
|
||||
@@ -0,0 +1,353 @@
|
||||
/** \file HttpdSocket.cpp
|
||||
*/
|
||||
/*
|
||||
Copyright (C) 2001-2004,2005 Anders Hedstrom (grymse@alhem.net)
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
#include "../debug.h"
|
||||
#include "Utility.h"
|
||||
#include "HttpdCookies.h"
|
||||
#include "HttpdForm.h"
|
||||
#include "MemFile.h"
|
||||
#include "HttpdSocket.h"
|
||||
#include "../types.h"
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#define DEB(x)
|
||||
/*
|
||||
#define DEB(x) { \
|
||||
FILE *fil = fopen("httpdlog","at"); \
|
||||
if (!fil) \
|
||||
fil = fopen("httpdlog","wt"); \
|
||||
if (fil) { x; fclose(fil); } \
|
||||
}
|
||||
*/
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// statics
|
||||
int HttpdSocket::m_request_count = 0;
|
||||
std::string HttpdSocket::m_start = "";
|
||||
|
||||
|
||||
HttpdSocket::HttpdSocket(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort)
|
||||
: HTTPSocket(ID,in_socket,irIP,irPort)
|
||||
,m_content_length(0)
|
||||
,m_file(nullptr)
|
||||
,m_received(0)
|
||||
,m_request_id(++m_request_count)
|
||||
,m_cookies(nullptr)
|
||||
,m_form(nullptr)
|
||||
{
|
||||
m_http_date = datetime2httpdate(GetDate());
|
||||
if (!m_start.size())
|
||||
m_start = m_http_date;
|
||||
}
|
||||
|
||||
|
||||
HttpdSocket::~HttpdSocket()
|
||||
{
|
||||
if (m_file)
|
||||
{
|
||||
delete m_file;
|
||||
}
|
||||
if (m_cookies)
|
||||
delete m_cookies;
|
||||
if (m_form)
|
||||
delete m_form;
|
||||
}
|
||||
|
||||
|
||||
void HttpdSocket::OnFirst()
|
||||
{
|
||||
// printf("Request: %s %s %s\n",GetMethod().c_str(),GetUrl().c_str(),GetHttpVersion().c_str());
|
||||
}
|
||||
|
||||
|
||||
void HttpdSocket::OnHeader(const std::string& key,const std::string& value)
|
||||
{
|
||||
if (!strcasecmp(key.c_str(),"content-length"))
|
||||
{
|
||||
m_content_length = atoi(value.c_str());
|
||||
m_content_length_str = value;
|
||||
}
|
||||
else
|
||||
if (!strcasecmp(key.c_str(),"cookie"))
|
||||
{
|
||||
m_http_cookie = value;
|
||||
}
|
||||
else
|
||||
if (!strcasecmp(key.c_str(),"content-type"))
|
||||
{
|
||||
m_content_type = value;
|
||||
}
|
||||
else
|
||||
if (!strcasecmp(key.c_str(),"if-modified-since"))
|
||||
{
|
||||
m_if_modified_since = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HttpdSocket::OnHeaderComplete()
|
||||
{
|
||||
m_cookies = new HttpdCookies(m_http_cookie);
|
||||
|
||||
#if (defined(SOLARIS8) || defined(SOLARIS))
|
||||
{
|
||||
char slask[1000];
|
||||
if (GetMethod() == "GET")
|
||||
{
|
||||
sprintf(slask,"QUERY_STRING=%s", GetQueryString().c_str());
|
||||
putenv(slask);
|
||||
}
|
||||
sprintf(slask,"REQUEST_METHOD=%s", GetMethod().c_str());
|
||||
putenv(slask);
|
||||
sprintf(slask,"HTTP_COOKIE=%s", m_http_cookie.c_str());
|
||||
putenv(slask);
|
||||
sprintf(slask,"CONTENT_TYPE=%s", m_content_type.c_str());
|
||||
putenv(slask);
|
||||
sprintf(slask,"CONTENT_LENGTH=%s", m_content_length_str.c_str());
|
||||
putenv(slask);
|
||||
}
|
||||
#elif defined _WIN32
|
||||
{
|
||||
char slask[1000];
|
||||
if (GetMethod() == "GET")
|
||||
{
|
||||
sprintf(slask,"QUERY_STRING=%s", GetQueryString().c_str());
|
||||
_putenv(slask);
|
||||
}
|
||||
sprintf(slask,"REQUEST_METHOD=%s", GetMethod().c_str());
|
||||
_putenv(slask);
|
||||
sprintf(slask,"HTTP_COOKIE=%s", m_http_cookie.c_str());
|
||||
_putenv(slask);
|
||||
sprintf(slask,"CONTENT_TYPE=%s", m_content_type.c_str());
|
||||
_putenv(slask);
|
||||
sprintf(slask,"CONTENT_LENGTH=%s", m_content_length_str.c_str());
|
||||
_putenv(slask);
|
||||
}
|
||||
#else
|
||||
if (GetMethod() == "GET")
|
||||
{
|
||||
setenv("QUERY_STRING", GetQueryString().c_str(), 1);
|
||||
}
|
||||
setenv("REQUEST_METHOD", GetMethod().c_str(), 1);
|
||||
setenv("HTTP_COOKIE", m_http_cookie.c_str(), 1);
|
||||
setenv("CONTENT_TYPE", m_content_type.c_str(), 1);
|
||||
setenv("CONTENT_LENGTH", m_content_length_str.c_str(), 1);
|
||||
#endif
|
||||
|
||||
if (GetMethod() == "POST")
|
||||
{
|
||||
m_file = new MemFile;
|
||||
}
|
||||
else
|
||||
if (GetMethod() == "GET")
|
||||
{
|
||||
m_form = new HttpdForm(GetQueryString(), GetQueryString().size() );
|
||||
AddResponseHeader("Date", datetime2httpdate(GetDate()) );
|
||||
Exec();
|
||||
Reset(); // prepare for next request
|
||||
}
|
||||
else
|
||||
{
|
||||
AddResponseHeader("Date", GetHttpDate());
|
||||
AddResponseHeader("Connection", "close");
|
||||
SetStatus("405");
|
||||
SetStatusText("Method not allowed");
|
||||
SendResponse();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HttpdSocket::OnData(const char *p,size_t l)
|
||||
{
|
||||
//printf("Got %d bytes: %.*s\n", l, l, p);
|
||||
if (m_file)
|
||||
{
|
||||
m_file -> fwrite(p,1,l);
|
||||
}
|
||||
m_received += l;
|
||||
if (m_received >= m_content_length && m_content_length)
|
||||
{
|
||||
// all done
|
||||
if (m_file && !m_form)
|
||||
{
|
||||
m_form = new HttpdForm(m_file);
|
||||
AddResponseHeader("Date", datetime2httpdate(GetDate()) );
|
||||
Exec();
|
||||
Reset(); // prepare for next request
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void HttpdSocket::Send64(const std::string& str64, const std::string& type)
|
||||
{
|
||||
if (!strcasecmp(m_start.c_str(), m_if_modified_since.c_str()))
|
||||
{
|
||||
SetStatus("304");
|
||||
SetStatusText("Not Modified");
|
||||
SendResponse();
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t len = Base64::decode_length(str64);
|
||||
unsigned char *buf = new unsigned char[len];
|
||||
|
||||
SetStatus("200");
|
||||
SetStatusText("OK");
|
||||
|
||||
AddResponseHeader("Content-length", Utility::l2string( (long)len) );
|
||||
AddResponseHeader("Content-type", type );
|
||||
AddResponseHeader("Last-modified", m_start);
|
||||
SendResponse();
|
||||
|
||||
Base64::decode(str64, buf, len);
|
||||
SendBuf( (char *)buf, len);
|
||||
delete[] buf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::string HttpdSocket::datetime2httpdate(const std::string& dt)
|
||||
{
|
||||
struct tm tp;
|
||||
time_t t;
|
||||
const char *days[] = { "Sun","Mon","Tue","Wed","Thu","Fri","Sat" };
|
||||
const char *months[] = { "Jan","Feb","Mar","Apr","May","Jun",
|
||||
"Jul","Aug","Sep","Oct","Nov","Dec" };
|
||||
int i;
|
||||
char s[40];
|
||||
|
||||
/* 1997-12-16 09:50:40 */
|
||||
|
||||
if (dt.size() == 19)
|
||||
{
|
||||
tp.tm_year = atoi(dt.substr(0,4).c_str()) - 1900;
|
||||
i = atoi(dt.substr(5,2).c_str()) - 1;
|
||||
tp.tm_mon = i >= 0 ? i : 0;
|
||||
tp.tm_mday = atoi(dt.substr(8,2).c_str());
|
||||
tp.tm_hour = atoi(dt.substr(11,2).c_str());
|
||||
tp.tm_min = atoi(dt.substr(14,2).c_str());
|
||||
tp.tm_sec = atoi(dt.substr(17,2).c_str());
|
||||
tp.tm_wday = 0;
|
||||
tp.tm_yday = 0;
|
||||
tp.tm_isdst = 0;
|
||||
t = mktime(&tp);
|
||||
/*if (t == -1)
|
||||
{
|
||||
Handler().LogError(this, "datetime2httpdate", 0, "mktime() failed");
|
||||
}*/
|
||||
|
||||
sprintf(s,"%s, %02d %s %d %02d:%02d:%02d GMT",
|
||||
days[tp.tm_wday],
|
||||
tp.tm_mday,
|
||||
months[tp.tm_mon],
|
||||
tp.tm_year + 1900,
|
||||
tp.tm_hour,tp.tm_min,tp.tm_sec);
|
||||
}
|
||||
else
|
||||
{
|
||||
*s = 0;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
std::string HttpdSocket::GetDate()
|
||||
{
|
||||
time_t t = time(nullptr);
|
||||
struct tm* tp = localtime(&t);
|
||||
char slask[40];
|
||||
if (tp)
|
||||
{
|
||||
sprintf(slask,"%d-%02d-%02d %02d:%02d:%02d",
|
||||
tp -> tm_year + 1900,
|
||||
tp -> tm_mon + 1,
|
||||
tp -> tm_mday,
|
||||
tp -> tm_hour,tp -> tm_min,tp -> tm_sec);
|
||||
}
|
||||
else
|
||||
{
|
||||
*slask = 0;
|
||||
}
|
||||
return slask;
|
||||
}
|
||||
|
||||
|
||||
void HttpdSocket::Reset()
|
||||
{
|
||||
HTTPSocket::Reset();
|
||||
m_content_length = 0;
|
||||
if (m_file)
|
||||
{
|
||||
delete m_file;
|
||||
m_file = nullptr;
|
||||
}
|
||||
m_received = 0;
|
||||
m_request_id = ++m_request_count;
|
||||
if (m_cookies)
|
||||
delete m_cookies;
|
||||
m_cookies = nullptr;
|
||||
if (m_form)
|
||||
delete m_form;
|
||||
m_form = nullptr;
|
||||
}
|
||||
|
||||
|
||||
const std::string& HttpdSocket::GetHttpDate()
|
||||
{
|
||||
return m_http_date;
|
||||
}
|
||||
|
||||
|
||||
HttpdCookies *HttpdSocket::GetCookies()
|
||||
{
|
||||
return m_cookies;
|
||||
}
|
||||
|
||||
|
||||
HttpdForm *HttpdSocket::GetHttpForm()
|
||||
{
|
||||
return m_form;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
/** \file HttpdSocket.h
|
||||
*/
|
||||
/*
|
||||
Copyright (C) 2001-2004,2005 Anders Hedstrom (grymse@alhem.net)
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef _HTTPDSOCKET_H
|
||||
#define _HTTPDSOCKET_H
|
||||
|
||||
#include "HTTPSocket.h"
|
||||
|
||||
class TCPConnection;
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
class HttpdCookies;
|
||||
class HttpdForm;
|
||||
class IFile;
|
||||
|
||||
/** \defgroup webserver Webserver framework */
|
||||
/** Web server socket framework.
|
||||
\ingroup webserver */
|
||||
class HttpdSocket : public HTTPSocket
|
||||
{
|
||||
public:
|
||||
HttpdSocket(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort);
|
||||
~HttpdSocket();
|
||||
|
||||
void OnFirst();
|
||||
void OnHeader(const std::string& key,const std::string& value);
|
||||
void OnHeaderComplete();
|
||||
void OnData(const char *,size_t);
|
||||
|
||||
/** This method needs to be implemented with logic to produce
|
||||
a response to an incoming request. */
|
||||
virtual void Exec() = 0;
|
||||
/** Get current date in http rfc format. */
|
||||
const std::string& GetHttpDate();
|
||||
/** Get pointer to cookie class. */
|
||||
HttpdCookies *GetCookies();
|
||||
/** Get pointer to query string/form data class. */
|
||||
HttpdForm *GetHttpForm();
|
||||
|
||||
protected:
|
||||
/** Decode and send a base64-encoded string.
|
||||
\param str64 Base64-encoded string
|
||||
\param type Mime type of content (content-type header) */
|
||||
void Send64(const std::string& str64, const std::string& type);
|
||||
std::string datetime2httpdate(const std::string& dt);
|
||||
std::string GetDate();
|
||||
void Reset();
|
||||
// headers
|
||||
std::string m_http_cookie;
|
||||
std::string m_content_type;
|
||||
std::string m_content_length_str;
|
||||
std::string m_if_modified_since;
|
||||
|
||||
private:
|
||||
static int m_request_count;
|
||||
static std::string m_start;
|
||||
size_t m_content_length;
|
||||
IFile *m_file;
|
||||
size_t m_received;
|
||||
int m_request_id;
|
||||
std::string m_http_date;
|
||||
HttpdCookies *m_cookies;
|
||||
HttpdForm *m_form;
|
||||
};
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _HTTPDSOCKET_H
|
||||
@@ -0,0 +1,65 @@
|
||||
/** \file IFile.h
|
||||
** \date 2005-04-25
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef _IFILE_H
|
||||
#define _IFILE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
/** \defgroup file File handling */
|
||||
/** Pure virtual file I/O interface.
|
||||
\ingroup file */
|
||||
class IFile
|
||||
{
|
||||
public:
|
||||
virtual ~IFile() {}
|
||||
|
||||
virtual bool fopen(const std::string&, const std::string&) = 0;
|
||||
virtual void fclose() = 0;
|
||||
|
||||
virtual size_t fread(char *, size_t, size_t) = 0;
|
||||
virtual size_t fwrite(const char *, size_t, size_t) = 0;
|
||||
|
||||
virtual char *fgets(char *, int) = 0;
|
||||
virtual void fprintf(char *format, ...) = 0;
|
||||
|
||||
virtual off_t size() = 0;
|
||||
virtual bool eof() = 0;
|
||||
};
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _IFILE_H
|
||||
@@ -0,0 +1,214 @@
|
||||
/** \file MemFile.cpp
|
||||
** \date 2005-04-25
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "MemFile.h"
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define DEB(x) x
|
||||
#else
|
||||
#define DEB(x)
|
||||
#endif
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
std::map<std::string,MemFile::block_t *> MemFile::m_files;
|
||||
|
||||
|
||||
MemFile::MemFile()
|
||||
:m_temporary(true)
|
||||
,m_base(new block_t)
|
||||
,m_current_read(m_base)
|
||||
,m_current_write(m_base)
|
||||
,m_read_ptr(0)
|
||||
,m_write_ptr(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
MemFile::MemFile(const std::string& path)
|
||||
:m_path(path)
|
||||
,m_temporary(false)
|
||||
,m_base(m_files[path])
|
||||
,m_current_read(nullptr)
|
||||
,m_current_write(nullptr)
|
||||
,m_read_ptr(0)
|
||||
,m_write_ptr(0)
|
||||
{
|
||||
if (!m_base)
|
||||
{
|
||||
m_base = new block_t;
|
||||
m_files[path] = m_base;
|
||||
}
|
||||
m_current_read = m_base;
|
||||
m_current_write = m_base;
|
||||
}
|
||||
|
||||
|
||||
MemFile::~MemFile()
|
||||
{
|
||||
while (m_base && m_temporary)
|
||||
{
|
||||
block_t *p = m_base;
|
||||
m_base = p -> next;
|
||||
delete p;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool MemFile::fopen(const std::string& path, const std::string& mode)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void MemFile::fclose()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
size_t MemFile::fread(char *ptr, size_t size, size_t nmemb)
|
||||
{
|
||||
size_t p = m_read_ptr % BLOCKSIZE;
|
||||
size_t sz = size * nmemb;
|
||||
if (p + sz < BLOCKSIZE)
|
||||
{
|
||||
//printf("Read @ %d(%d). %d bytes. (%c)\n", m_read_ptr, p, sz, *(m_current_read -> data + p));
|
||||
memcpy(ptr, m_current_read -> data + p, sz);
|
||||
m_read_ptr += sz;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t sz1 = BLOCKSIZE - p;
|
||||
size_t sz2 = size - sz1;
|
||||
memcpy(ptr, m_current_read -> data + p, sz1);
|
||||
m_read_ptr += sz1;
|
||||
if (m_current_read -> next)
|
||||
{
|
||||
m_current_read = m_current_read -> next;
|
||||
memcpy(ptr + sz1, m_current_read -> data, sz2);
|
||||
m_read_ptr += sz2;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEB(printf("Read beyond available data\n");)
|
||||
return sz1;
|
||||
}
|
||||
}
|
||||
return sz;
|
||||
}
|
||||
|
||||
|
||||
size_t MemFile::fwrite(const char *ptr, size_t size, size_t nmemb)
|
||||
{
|
||||
size_t p = m_write_ptr % BLOCKSIZE;
|
||||
size_t sz = size * nmemb;
|
||||
if (p + sz < BLOCKSIZE)
|
||||
{
|
||||
//printf("Write @ %d(%d). %d bytes.\n", m_write_ptr, p, sz);
|
||||
memcpy(m_current_write -> data + p, ptr, sz);
|
||||
m_write_ptr += sz;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t sz1 = BLOCKSIZE - p;
|
||||
size_t sz2 = size - sz1;
|
||||
memcpy(m_current_write -> data + p, ptr, sz1);
|
||||
block_t *next = new block_t;
|
||||
m_current_write -> next = next;
|
||||
m_current_write = next;
|
||||
memcpy(m_current_write -> data, ptr + sz1, sz2);
|
||||
m_write_ptr += sz;
|
||||
}
|
||||
return sz;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *MemFile::fgets(char *s, int size)
|
||||
{
|
||||
int n = 0;
|
||||
while (n < size - 1 && !eof())
|
||||
{
|
||||
char c;
|
||||
fread(&c, 1, 1);
|
||||
if (c == 10)
|
||||
{
|
||||
s[n] = 0;
|
||||
return s;
|
||||
}
|
||||
s[n++] = c;
|
||||
}
|
||||
s[n] = 0;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
void MemFile::fprintf(char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char tmp[BLOCKSIZE];
|
||||
va_start(ap, format);
|
||||
#ifdef _WIN32
|
||||
vsprintf(tmp, format, ap);
|
||||
#else
|
||||
vsnprintf(tmp, BLOCKSIZE - 1, format, ap);
|
||||
#endif
|
||||
va_end(ap);
|
||||
fwrite(tmp, 1, strlen(tmp));
|
||||
}
|
||||
|
||||
|
||||
off_t MemFile::size()
|
||||
{
|
||||
return (off_t)m_write_ptr;
|
||||
}
|
||||
|
||||
|
||||
bool MemFile::eof()
|
||||
{
|
||||
return (m_read_ptr < m_write_ptr) ? false : true;
|
||||
}
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
/** \file MemFile.h
|
||||
** \date 2005-04-25
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef _MEMFILE_H
|
||||
#define _MEMFILE_H
|
||||
|
||||
#include <map>
|
||||
#include "IFile.h"
|
||||
|
||||
#define BLOCKSIZE 32768
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
/** Implements a memory file.
|
||||
\ingroup file */
|
||||
class MemFile : public IFile
|
||||
{
|
||||
public:
|
||||
/** File block structure.
|
||||
\ingroup file */
|
||||
struct block_t {
|
||||
block_t() : next(nullptr) {}
|
||||
struct block_t *next;
|
||||
char data[BLOCKSIZE];
|
||||
};
|
||||
public:
|
||||
MemFile();
|
||||
MemFile(const std::string& path);
|
||||
~MemFile();
|
||||
|
||||
bool fopen(const std::string& path, const std::string& mode);
|
||||
void fclose();
|
||||
|
||||
size_t fread(char *ptr, size_t size, size_t nmemb);
|
||||
size_t fwrite(const char *ptr, size_t size, size_t nmemb);
|
||||
|
||||
char *fgets(char *s, int size);
|
||||
void fprintf(char *format, ...);
|
||||
|
||||
off_t size();
|
||||
bool eof();
|
||||
|
||||
private:
|
||||
MemFile(const MemFile& ) {} // copy constructor
|
||||
MemFile& operator=(const MemFile& ) { return *this; } // assignment operator
|
||||
|
||||
static std::map<std::string,block_t *> m_files;
|
||||
std::string m_path;
|
||||
bool m_temporary;
|
||||
block_t *m_base;
|
||||
block_t *m_current_read;
|
||||
block_t *m_current_write;
|
||||
size_t m_read_ptr;
|
||||
size_t m_write_ptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _MEMFILE_H
|
||||
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
** File ......... Mime.cpp
|
||||
** Published .... 2004-07-13
|
||||
** Author ....... grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004 Anders Hedstrom
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
#include "Parse.h"
|
||||
#include "Mime.h"
|
||||
#include <cstring>
|
||||
|
||||
|
||||
|
||||
Mime::Mime() {
|
||||
}
|
||||
|
||||
Mime::Mime(const std::string& filename) {
|
||||
LoadMimeFile(filename);
|
||||
}
|
||||
|
||||
bool Mime::LoadMimeFile(const std::string& filename) {
|
||||
FILE *fil;
|
||||
if ((fil = fopen(filename.c_str(),"rt")) != nullptr) {
|
||||
char * slask = new char[1000];
|
||||
fgets(slask,1000,fil);
|
||||
while (!feof(fil))
|
||||
{
|
||||
while (strlen(slask) && (slask[strlen(slask) - 1] == 13 || slask[strlen(slask) - 1] == 10))
|
||||
{
|
||||
slask[strlen(slask) - 1] = 0;
|
||||
}
|
||||
Parse pa(slask);
|
||||
std::string mime_type = pa.getword();
|
||||
std::string ext = pa.getword();
|
||||
while (ext.size())
|
||||
{
|
||||
m_mime[ext] = mime_type;
|
||||
ext = pa.getword();
|
||||
}
|
||||
//
|
||||
fgets(slask,1000,fil);
|
||||
}
|
||||
delete[] slask;
|
||||
fclose(fil);
|
||||
return(true);
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
|
||||
Mime::~Mime()
|
||||
{
|
||||
}
|
||||
|
||||
void Mime::Clear() {
|
||||
m_mime.clear();
|
||||
}
|
||||
|
||||
std::string Mime::GetMimeFromFilename(const std::string &filename) const {
|
||||
std::string::size_type pos = filename.find_last_of('.');
|
||||
if(pos == std::string::npos)
|
||||
return(std::string("text/plain"));
|
||||
return(GetMimeFromExtension(filename.substr(pos+1)));
|
||||
}
|
||||
|
||||
std::string Mime::GetMimeFromExtension(const std::string& ext) const {
|
||||
mime_m::const_iterator res;
|
||||
res = m_mime.find(ext);
|
||||
if(res == m_mime.end())
|
||||
return(std::string("text/plain"));
|
||||
|
||||
return res->second;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
** File ......... Mime.h
|
||||
** Published .... 2004-07-13
|
||||
** Author ....... grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004 Anders Hedstrom
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef _MIME_H
|
||||
#define _MIME_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
class Mime {
|
||||
typedef std::map<std::string,std::string> mime_m;
|
||||
public:
|
||||
Mime();
|
||||
Mime(const std::string& mime_file);
|
||||
~Mime();
|
||||
|
||||
void Clear();
|
||||
bool LoadMimeFile(const std::string& mime_file);
|
||||
|
||||
std::string GetMimeFromFilename(const std::string &filename) const;
|
||||
std::string GetMimeFromExtension(const std::string &ext) const;
|
||||
|
||||
private:
|
||||
mime_m m_mime;
|
||||
};
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _MIME_H
|
||||
@@ -0,0 +1,327 @@
|
||||
/** \file Parse.cpp - parse a string
|
||||
**
|
||||
** Written: 1999-Feb-10 grymse@alhem.net
|
||||
**/
|
||||
|
||||
/*
|
||||
Copyright (C) 1999-2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "Parse.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define DEB(x)
|
||||
#else
|
||||
#define DEB(x)
|
||||
#endif
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
/* implementation of class Parse */
|
||||
|
||||
Parse::Parse()
|
||||
:pa_the_str("")
|
||||
,pa_splits("")
|
||||
,pa_ord("")
|
||||
,pa_the_ptr(0)
|
||||
,pa_breakchar(0)
|
||||
,pa_enable(0)
|
||||
,pa_disable(0)
|
||||
,pa_nospace(0)
|
||||
,pa_quote(false)
|
||||
{
|
||||
}
|
||||
|
||||
Parse::Parse(const std::string&s)
|
||||
:pa_the_str(s)
|
||||
,pa_splits("")
|
||||
,pa_ord("")
|
||||
,pa_the_ptr(0)
|
||||
,pa_breakchar(0)
|
||||
,pa_enable(0)
|
||||
,pa_disable(0)
|
||||
,pa_nospace(0)
|
||||
,pa_quote(false)
|
||||
{
|
||||
}
|
||||
|
||||
Parse::Parse(const std::string&s,const std::string&sp)
|
||||
:pa_the_str(s)
|
||||
,pa_splits(sp)
|
||||
,pa_ord("")
|
||||
,pa_the_ptr(0)
|
||||
,pa_breakchar(0)
|
||||
,pa_enable(0)
|
||||
,pa_disable(0)
|
||||
,pa_nospace(0)
|
||||
,pa_quote(false)
|
||||
{
|
||||
}
|
||||
|
||||
Parse::Parse(const std::string&s,const std::string&sp,short nospace)
|
||||
:pa_the_str(s)
|
||||
,pa_splits(sp)
|
||||
,pa_ord("")
|
||||
,pa_the_ptr(0)
|
||||
,pa_breakchar(0)
|
||||
,pa_enable(0)
|
||||
,pa_disable(0)
|
||||
,pa_nospace(1)
|
||||
,pa_quote(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Parse::~Parse()
|
||||
{
|
||||
}
|
||||
|
||||
#define C ((pa_the_ptr<pa_the_str.size()) ? pa_the_str[pa_the_ptr] : 0)
|
||||
|
||||
short Parse::issplit(char c)
|
||||
{
|
||||
for (size_t i = 0; i < pa_splits.size(); i++)
|
||||
if (pa_splits[i] == c)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Parse::getsplit(void)
|
||||
{
|
||||
size_t x;
|
||||
|
||||
if (C == '=')
|
||||
{
|
||||
x = pa_the_ptr++;
|
||||
} else
|
||||
{
|
||||
while (C && (issplit(C)))
|
||||
pa_the_ptr++;
|
||||
x = pa_the_ptr;
|
||||
while (C && !issplit(C) && C != '=')
|
||||
pa_the_ptr++;
|
||||
}
|
||||
if (x == pa_the_ptr && C == '=')
|
||||
pa_the_ptr++;
|
||||
pa_ord = (x < pa_the_str.size()) ? pa_the_str.substr(x,pa_the_ptr - x) : "";
|
||||
}
|
||||
|
||||
std::string Parse::getword(void)
|
||||
{
|
||||
size_t x;
|
||||
int disabled = 0;
|
||||
int quote = 0;
|
||||
int rem = 0;
|
||||
|
||||
if (pa_nospace)
|
||||
{
|
||||
while (C && issplit(C))
|
||||
pa_the_ptr++;
|
||||
x = pa_the_ptr;
|
||||
while (C && !issplit(C) && (C != pa_breakchar || !pa_breakchar || disabled))
|
||||
{
|
||||
if (pa_breakchar && C == pa_disable)
|
||||
disabled = 1;
|
||||
if (pa_breakchar && C == pa_enable)
|
||||
disabled = 0;
|
||||
if (pa_quote && C == '"')
|
||||
quote = 1;
|
||||
pa_the_ptr++;
|
||||
while (quote && C && C != '"')
|
||||
{
|
||||
pa_the_ptr++;
|
||||
}
|
||||
if (pa_quote && C == '"')
|
||||
{
|
||||
pa_the_ptr++;
|
||||
}
|
||||
quote = 0;
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (C == pa_breakchar && pa_breakchar)
|
||||
{
|
||||
x = pa_the_ptr++;
|
||||
rem = 1;
|
||||
} else
|
||||
{
|
||||
while (C && (C == ' ' || C == 9 || C == 13 || C == 10 || issplit(C)))
|
||||
pa_the_ptr++;
|
||||
x = pa_the_ptr;
|
||||
while (C && C != ' ' && C != 9 && C != 13 && C != 10 && !issplit(C) &&
|
||||
(C != pa_breakchar || !pa_breakchar || disabled))
|
||||
{
|
||||
if (pa_breakchar && C == pa_disable)
|
||||
disabled = 1;
|
||||
if (pa_breakchar && C == pa_enable)
|
||||
disabled = 0;
|
||||
if (pa_quote && C == '"')
|
||||
{
|
||||
quote = 1;
|
||||
pa_the_ptr++;
|
||||
while (quote && C && C != '"')
|
||||
{
|
||||
pa_the_ptr++;
|
||||
}
|
||||
if (pa_quote && C == '"')
|
||||
{
|
||||
pa_the_ptr++;
|
||||
}
|
||||
}
|
||||
else
|
||||
pa_the_ptr++;
|
||||
quote = 0;
|
||||
}
|
||||
pa_the_ptr++;
|
||||
rem = 1;
|
||||
}
|
||||
if (x == pa_the_ptr && C == pa_breakchar && pa_breakchar)
|
||||
pa_the_ptr++;
|
||||
}
|
||||
if (x < pa_the_str.size())
|
||||
{
|
||||
pa_ord = pa_the_str.substr(x,pa_the_ptr - x - rem);
|
||||
}
|
||||
else
|
||||
{
|
||||
pa_ord = "";
|
||||
}
|
||||
return pa_ord;
|
||||
}
|
||||
|
||||
void Parse::getword(std::string&s)
|
||||
{
|
||||
s = Parse::getword();
|
||||
}
|
||||
|
||||
void Parse::getsplit(std::string&s)
|
||||
{
|
||||
Parse::getsplit();
|
||||
s = pa_ord;
|
||||
}
|
||||
|
||||
void Parse::getword(std::string&s,std::string&fill,int l)
|
||||
{
|
||||
Parse::getword();
|
||||
s = "";
|
||||
while (s.size() + pa_ord.size() < (size_t)l)
|
||||
s += fill;
|
||||
s += pa_ord;
|
||||
}
|
||||
|
||||
std::string Parse::getrest()
|
||||
{
|
||||
std::string s;
|
||||
while (C && (C == ' ' || C == 9 || issplit(C)))
|
||||
pa_the_ptr++;
|
||||
s = (pa_the_ptr < pa_the_str.size()) ? pa_the_str.substr(pa_the_ptr) : "";
|
||||
return s;
|
||||
}
|
||||
|
||||
void Parse::getrest(std::string&s)
|
||||
{
|
||||
while (C && (C == ' ' || C == 9 || issplit(C)))
|
||||
pa_the_ptr++;
|
||||
s = (pa_the_ptr < pa_the_str.size()) ? pa_the_str.substr(pa_the_ptr) : "";
|
||||
}
|
||||
|
||||
long Parse::getvalue(void)
|
||||
{
|
||||
Parse::getword();
|
||||
return atol(pa_ord.c_str());
|
||||
}
|
||||
|
||||
void Parse::setbreak(char c)
|
||||
{
|
||||
pa_breakchar = c;
|
||||
}
|
||||
|
||||
int Parse::getwordlen(void)
|
||||
{
|
||||
size_t x,y = pa_the_ptr,len;
|
||||
|
||||
if (C == pa_breakchar && pa_breakchar)
|
||||
{
|
||||
x = pa_the_ptr++;
|
||||
} else
|
||||
{
|
||||
while (C && (C == ' ' || C == 9 || C == 13 || C == 10 || issplit(C)))
|
||||
pa_the_ptr++;
|
||||
x = pa_the_ptr;
|
||||
while (C && C != ' ' && C != 9 && C != 13 && C != 10 && !issplit(C) && (C != pa_breakchar || !pa_breakchar))
|
||||
pa_the_ptr++;
|
||||
}
|
||||
if (x == pa_the_ptr && C == pa_breakchar && pa_breakchar)
|
||||
pa_the_ptr++;
|
||||
len = pa_the_ptr - x;
|
||||
pa_the_ptr = y;
|
||||
return (int)len;
|
||||
}
|
||||
|
||||
int Parse::getrestlen(void)
|
||||
{
|
||||
size_t y = pa_the_ptr;
|
||||
size_t len;
|
||||
|
||||
while (C && (C == ' ' || C == 9 || issplit(C)))
|
||||
pa_the_ptr++;
|
||||
len = strlen(pa_the_str.c_str() + pa_the_ptr);
|
||||
pa_the_ptr = y;
|
||||
return (int)len;
|
||||
}
|
||||
|
||||
void Parse::getline(void)
|
||||
{
|
||||
size_t x;
|
||||
|
||||
x = pa_the_ptr;
|
||||
while (C && C != 13 && C != 10)
|
||||
pa_the_ptr++;
|
||||
pa_ord = (x < pa_the_str.size()) ? pa_the_str.substr(x,pa_the_ptr - x) : "";
|
||||
if (C == 13)
|
||||
pa_the_ptr++;
|
||||
if (C == 10)
|
||||
pa_the_ptr++;
|
||||
}
|
||||
|
||||
void Parse::getline(std::string&s)
|
||||
{
|
||||
getline();
|
||||
s = pa_ord;
|
||||
}
|
||||
|
||||
/* end of implementation of class Parse */
|
||||
/***************************************************/
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
/** \file Parse.h - parse a string
|
||||
**
|
||||
** Written: 1999-Feb-10 grymse@alhem.net
|
||||
**/
|
||||
|
||||
/*
|
||||
Copyright (C) 1999-2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _PARSE_H
|
||||
#define _PARSE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
/***************************************************/
|
||||
/* interface of class Parse */
|
||||
|
||||
/** Splits a string whatever way you want.
|
||||
\ingroup util */
|
||||
class Parse
|
||||
{
|
||||
public:
|
||||
Parse();
|
||||
Parse(const std::string&);
|
||||
Parse(const std::string&,const std::string&);
|
||||
Parse(const std::string&,const std::string&,short);
|
||||
~Parse();
|
||||
short issplit(char);
|
||||
void getsplit(void);
|
||||
void getsplit(std::string&);
|
||||
std::string getword(void);
|
||||
void getword(std::string&);
|
||||
void getword(std::string&,std::string&,int);
|
||||
std::string getrest();
|
||||
void getrest(std::string&);
|
||||
long getvalue(void);
|
||||
void setbreak(char);
|
||||
int getwordlen(void);
|
||||
int getrestlen(void);
|
||||
void enablebreak(char c) {
|
||||
pa_enable = c;
|
||||
}
|
||||
void disablebreak(char c) {
|
||||
pa_disable = c;
|
||||
}
|
||||
void getline(void);
|
||||
void getline(std::string&);
|
||||
size_t getptr(void) { return pa_the_ptr; }
|
||||
void EnableQuote(bool b) { pa_quote = b; }
|
||||
|
||||
private:
|
||||
std::string pa_the_str;
|
||||
std::string pa_splits;
|
||||
std::string pa_ord;
|
||||
size_t pa_the_ptr;
|
||||
char pa_breakchar;
|
||||
char pa_enable;
|
||||
char pa_disable;
|
||||
short pa_nospace;
|
||||
bool pa_quote;
|
||||
};
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _PARSE_H
|
||||
@@ -0,0 +1,5 @@
|
||||
EQEmu took this code from `C++ Sockets Library`
|
||||
http://www.alhem.net/Sockets/
|
||||
and integrated it into our world server. We did not care for the actual
|
||||
socket code (didnt work on windows) so we scrapped all of it, and just
|
||||
used the HTTP framework code.
|
||||
@@ -0,0 +1,5 @@
|
||||
Find uuid.h here
|
||||
http://www.die.net/doc/linux/include/uuid/uuid.h
|
||||
or here
|
||||
http://www.thedna.net/uuid.h
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
/** \file Utility.cpp
|
||||
** \date 2004-02-13
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "Utility.h"
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
|
||||
std::string Utility::base64(const std::string& str_in)
|
||||
{
|
||||
std::string str;
|
||||
Base64::encode(str_in, str, false); // , false == do not add cr/lf
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string Utility::base64d(const std::string& str_in)
|
||||
{
|
||||
std::string str;
|
||||
Base64::decode(str_in, str);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string Utility::l2string(long l)
|
||||
{
|
||||
std::string str;
|
||||
char tmp[100];
|
||||
sprintf(tmp,"%ld",l);
|
||||
str = tmp;
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
std::string Utility::bigint2string(uint64_t l)
|
||||
{
|
||||
std::string str;
|
||||
uint64_t tmp = l;
|
||||
while (tmp)
|
||||
{
|
||||
uint64_t a = tmp % 10;
|
||||
str = (char)(a + 48) + str;
|
||||
tmp /= 10;
|
||||
}
|
||||
if (!str.size())
|
||||
{
|
||||
str = "0";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
uint64_t Utility::atoi64(const std::string& str)
|
||||
{
|
||||
uint64_t l = 0;
|
||||
for (size_t i = 0; i < str.size(); i++)
|
||||
{
|
||||
l = l * 10 + str[i] - 48;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
unsigned int Utility::hex2unsigned(const std::string& str)
|
||||
{
|
||||
unsigned int r = 0;
|
||||
for (size_t i = 0; i < str.size(); i++)
|
||||
{
|
||||
r = r * 16 + str[i] - 48 - ((str[i] >= 'A') ? 7 : 0) - ((str[i] >= 'a') ? 32 : 0);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Encode string per RFC1738 URL encoding rules
|
||||
* tnx rstaveley
|
||||
*/
|
||||
std::string Utility::rfc1738_encode(const std::string& src)
|
||||
{
|
||||
static char hex[] = "0123456789ABCDEF";
|
||||
std::string dst;
|
||||
for (size_t i = 0; i < src.size(); i++)
|
||||
{
|
||||
if (isalnum(src[i]))
|
||||
{
|
||||
dst += src[i];
|
||||
}
|
||||
else
|
||||
if (src[i] == ' ')
|
||||
{
|
||||
dst += '+';
|
||||
}
|
||||
else
|
||||
{
|
||||
dst += '%';
|
||||
dst += hex[src[i] / 16];
|
||||
dst += hex[src[i] % 16];
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
} // rfc1738_encode
|
||||
|
||||
|
||||
/*
|
||||
* Decode string per RFC1738 URL encoding rules
|
||||
* tnx rstaveley
|
||||
*/
|
||||
std::string Utility::rfc1738_decode(const std::string& src)
|
||||
{
|
||||
std::string dst;
|
||||
for (size_t i = 0; i < src.size(); i++)
|
||||
{
|
||||
if (src[i] == '%' && isxdigit(src[i + 1]) && isxdigit(src[i + 2]))
|
||||
{
|
||||
char c1 = src[++i];
|
||||
char c2 = src[++i];
|
||||
c1 = c1 - 48 - ((c1 >= 'A') ? 7 : 0) - ((c1 >= 'a') ? 32 : 0);
|
||||
c2 = c2 - 48 - ((c2 >= 'A') ? 7 : 0) - ((c2 >= 'a') ? 32 : 0);
|
||||
dst += (char)(c1 * 16 + c2);
|
||||
}
|
||||
else
|
||||
if (src[i] == '+')
|
||||
{
|
||||
dst += ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
dst += src[i];
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
} // rfc1738_decode
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/** \file Utility.h
|
||||
** \date 2004-02-13
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef _UTILITY_H
|
||||
#define _UTILITY_H
|
||||
|
||||
#include <ctype.h>
|
||||
#ifdef _WIN32
|
||||
typedef unsigned __int64 uint64_t;
|
||||
#else
|
||||
#include <stdlib.h>
|
||||
#ifdef SOLARIS
|
||||
# include <sys/types.h>
|
||||
#else
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#endif
|
||||
#include "Base64.h"
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
/** Conversion utilities.
|
||||
\ingroup util */
|
||||
class Utility
|
||||
{
|
||||
public:
|
||||
static std::string base64(const std::string& str_in);
|
||||
static std::string base64d(const std::string& str_in);
|
||||
static std::string l2string(long l);
|
||||
static std::string bigint2string(uint64_t l);
|
||||
static uint64_t atoi64(const std::string& str);
|
||||
static unsigned int hex2unsigned(const std::string& str);
|
||||
static std::string rfc1738_encode(const std::string& src);
|
||||
static std::string rfc1738_decode(const std::string& src);
|
||||
};
|
||||
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _UTILITY_H
|
||||
@@ -0,0 +1,340 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
@@ -0,0 +1,87 @@
|
||||
/** \file socket_include.cpp
|
||||
** \date 2004-11-28
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
|
||||
// only to be included in win32 projects
|
||||
const char *StrError(int x)
|
||||
{
|
||||
static char tmp[100];
|
||||
switch (x)
|
||||
{
|
||||
case 10004: return "Interrupted function call.";
|
||||
case 10013: return "Permission denied.";
|
||||
case 10014: return "Bad address.";
|
||||
case 10022: return "Invalid argument.";
|
||||
case 10024: return "Too many open files.";
|
||||
case 10035: return "Resource temporarily unavailable.";
|
||||
case 10036: return "Operation now in progress.";
|
||||
case 10037: return "Operation already in progress.";
|
||||
case 10038: return "Socket operation on nonsocket.";
|
||||
case 10039: return "Destination address required.";
|
||||
case 10040: return "Message too long.";
|
||||
case 10041: return "Protocol wrong type for socket.";
|
||||
case 10042: return "Bad protocol option.";
|
||||
case 10043: return "Protocol not supported.";
|
||||
case 10044: return "Socket type not supported.";
|
||||
case 10045: return "Operation not supported.";
|
||||
case 10046: return "Protocol family not supported.";
|
||||
case 10047: return "Address family not supported by protocol family.";
|
||||
case 10048: return "Address already in use.";
|
||||
case 10049: return "Cannot assign requested address.";
|
||||
case 10050: return "Network is down.";
|
||||
case 10051: return "Network is unreachable.";
|
||||
case 10052: return "Network dropped connection on reset.";
|
||||
case 10053: return "Software caused connection abort.";
|
||||
case 10054: return "Connection reset by peer.";
|
||||
case 10055: return "No buffer space available.";
|
||||
case 10056: return "Socket is already connected.";
|
||||
case 10057: return "Socket is not connected.";
|
||||
case 10058: return "Cannot send after socket shutdown.";
|
||||
case 10060: return "Connection timed out.";
|
||||
case 10061: return "Connection refused.";
|
||||
case 10064: return "Host is down.";
|
||||
case 10065: return "No route to host.";
|
||||
case 10067: return "Too many processes.";
|
||||
case 10091: return "Network subsystem is unavailable.";
|
||||
case 10092: return "Winsock.dll version out of range.";
|
||||
case 10093: return "Successful WSAStartup not yet performed.";
|
||||
case 10101: return "Graceful shutdown in progress.";
|
||||
case 10109: return "Class type not found.";
|
||||
case 11001: return "Host not found.";
|
||||
case 11002: return "Nonauthoritative host not found.";
|
||||
case 11003: return "This is a nonrecoverable error.";
|
||||
case 11004: return "Valid name, no data record of requested type.";
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
sprintf(tmp, "Winsock error code: %d", x);
|
||||
return tmp;
|
||||
}
|
||||
@@ -0,0 +1,218 @@
|
||||
/** \file socket_include.h
|
||||
** \date 2005-04-12
|
||||
** \author grymse@alhem.net
|
||||
**/
|
||||
/*
|
||||
Copyright (C) 2004,2005 Anders Hedstrom
|
||||
|
||||
This library is made available under the terms of the GNU GPL.
|
||||
|
||||
If you would like to use this library in a closed-source application,
|
||||
a separate license agreement is available. For information about
|
||||
the closed-source license agreement for the C++ sockets library,
|
||||
please visit http://www.alhem.net/Sockets/license.html and/or
|
||||
email license@alhem.net.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef _SOCKET_INCLUDE_H
|
||||
#define _SOCKET_INCLUDE_H
|
||||
|
||||
#if (defined(__unix__) || defined(unix)) && !defined(USG)
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef _WIN32
|
||||
// ----------------------------------------
|
||||
// common unix includes / defines
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
#define Errno errno
|
||||
#define StrError strerror
|
||||
|
||||
// WIN32 adapt
|
||||
#define closesocket close
|
||||
#define INVALID_SOCKET -1
|
||||
#define SOCKET_ERROR -1
|
||||
typedef int SOCKET;
|
||||
|
||||
#ifndef INADDR_NONE
|
||||
#define INADDR_NONE ((unsigned long) -1)
|
||||
#endif // INADDR_NONE
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // !_WIN32
|
||||
|
||||
|
||||
// ----------------------------------------
|
||||
// Generic
|
||||
#ifndef SOL_IP
|
||||
#define SOL_IP IPPROTO_IP
|
||||
#endif
|
||||
|
||||
|
||||
// ----------------------------------------
|
||||
// OS specific adaptions
|
||||
|
||||
#ifdef SOLARIS
|
||||
// ----------------------------------------
|
||||
// Solaris
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
typedef unsigned short port_t;
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#define s6_addr16 _S6_un._S6_u8
|
||||
#define MSG_NOSIGNAL 0
|
||||
|
||||
#elif defined __FreeBSD__
|
||||
// ----------------------------------------
|
||||
// FreeBSD
|
||||
# if __FreeBSD_version >= 400014
|
||||
# define s6_addr16 __u6_addr.__u6_addr16
|
||||
# if !defined(MSG_NOSIGNAL)
|
||||
# define MSG_NOSIGNAL 0
|
||||
# endif
|
||||
# include <netinet/in.h>
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
typedef in_addr_t ipaddr_t;
|
||||
typedef in_port_t port_t;
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
# define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
|
||||
# define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
|
||||
# else
|
||||
# error FreeBSD versions prior to 400014 does not support ipv6
|
||||
# endif
|
||||
|
||||
#elif defined MACOSX
|
||||
// ----------------------------------------
|
||||
// Mac OS X
|
||||
#include <string.h>
|
||||
#include <mach/port.h>
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
typedef unsigned long ipaddr_t;
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#define s6_addr16 __u6_addr.__u6_addr16
|
||||
#define MSG_NOSIGNAL 0 // oops - thanks Derek
|
||||
#define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP
|
||||
#define IPV6_DROP_MEMBERSHIP IPV6_LEAVE_GROUP
|
||||
|
||||
#elif defined _WIN32
|
||||
// ----------------------------------------
|
||||
// Win32
|
||||
#pragma comment(lib, "wsock32.lib")
|
||||
#define strcasecmp _stricmp
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
typedef unsigned long ipaddr_t;
|
||||
typedef unsigned short port_t;
|
||||
typedef int socklen_t;
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#define MSG_NOSIGNAL 0
|
||||
#define SHUT_RDWR 2
|
||||
|
||||
// 1.8.6: define FD_SETSIZE to something bigger than 64 if there are a lot of
|
||||
// simultaneous connections (must be done before including winsock.h)
|
||||
//#define FD_SETSIZE 1024
|
||||
#include <winsock.h>
|
||||
|
||||
#define Errno WSAGetLastError()
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
const char *StrError(int x);
|
||||
|
||||
// class WSAInitializer is a part of the Socket class (on win32)
|
||||
// as a static instance - so whenever an application uses a Socket,
|
||||
// winsock is initialized
|
||||
class WSAInitializer // Winsock Initializer
|
||||
{
|
||||
public:
|
||||
WSAInitializer() {
|
||||
if (WSAStartup(0x101,&m_wsadata))
|
||||
{
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
~WSAInitializer() {
|
||||
WSACleanup();
|
||||
}
|
||||
private:
|
||||
WSADATA m_wsadata;
|
||||
};
|
||||
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
#else
|
||||
// ----------------------------------------
|
||||
// LINUX
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
namespace SOCKETS_NAMESPACE {
|
||||
#endif
|
||||
|
||||
typedef unsigned long ipaddr_t;
|
||||
typedef unsigned short port_t;
|
||||
#ifdef SOCKETS_NAMESPACE
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _THREADSAFE_SOCKETS
|
||||
#include "mutex.h"
|
||||
#include "Lock.h"
|
||||
#endif
|
||||
|
||||
#endif // _SOCKET_INCLUDE_H
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,192 @@
|
||||
/**********************************************************************
|
||||
*
|
||||
* StackWalker.h
|
||||
*
|
||||
*
|
||||
* History:
|
||||
* 2005-07-27 v1 - First public release on http://www.codeproject.com/
|
||||
* (for additional changes see History in 'StackWalker.cpp'!
|
||||
* 2013-01-26 - Modified by KimLS(KLS) for EQEmu's purposes
|
||||
*
|
||||
**********************************************************************/
|
||||
#ifdef _WINDOWS
|
||||
// #pragma once is supported starting with _MCS_VER 1000,
|
||||
// so we need not to check the version (because we only support _MSC_VER >= 1100)!
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// special defines for VC5/6 (if no actual PSDK is installed):
|
||||
#if _MSC_VER < 1300
|
||||
typedef unsigned __int64 DWORD64, *PDWORD64;
|
||||
#if defined(_WIN64)
|
||||
typedef unsigned __int64 SIZE_T, *PSIZE_T;
|
||||
#else
|
||||
typedef unsigned long SIZE_T, *PSIZE_T;
|
||||
#endif
|
||||
#endif // _MSC_VER < 1300
|
||||
|
||||
class StackWalkerInternal; // forward
|
||||
class StackWalker
|
||||
{
|
||||
public:
|
||||
typedef enum StackWalkOptions
|
||||
{
|
||||
// No addition info will be retrived
|
||||
// (only the address is available)
|
||||
RetrieveNone = 0,
|
||||
|
||||
// Try to get the symbol-name
|
||||
RetrieveSymbol = 1,
|
||||
|
||||
// Try to get the line for this symbol
|
||||
RetrieveLine = 2,
|
||||
|
||||
// Try to retrieve the module-infos
|
||||
RetrieveModuleInfo = 4,
|
||||
|
||||
// Also retrieve the version for the DLL/EXE
|
||||
RetrieveFileVersion = 8,
|
||||
|
||||
// Contains all the abouve
|
||||
RetrieveVerbose = 0xF,
|
||||
|
||||
// Generate a "good" symbol-search-path
|
||||
SymBuildPath = 0x10,
|
||||
|
||||
// Also use the public Microsoft-Symbol-Server
|
||||
SymUseSymSrv = 0x20,
|
||||
|
||||
// Contains all the abouve "Sym"-options
|
||||
SymAll = 0x30,
|
||||
|
||||
// Contains all options (default)
|
||||
OptionsAll = 0x3F
|
||||
} StackWalkOptions;
|
||||
|
||||
StackWalker(
|
||||
int options = OptionsAll, // 'int' is by design, to combine the enum-flags
|
||||
LPCSTR szSymPath = nullptr,
|
||||
DWORD dwProcessId = GetCurrentProcessId(),
|
||||
HANDLE hProcess = GetCurrentProcess()
|
||||
);
|
||||
StackWalker(DWORD dwProcessId, HANDLE hProcess);
|
||||
virtual ~StackWalker();
|
||||
|
||||
typedef BOOL (__stdcall *PReadProcessMemoryRoutine)(
|
||||
HANDLE hProcess,
|
||||
DWORD64 qwBaseAddress,
|
||||
PVOID lpBuffer,
|
||||
DWORD nSize,
|
||||
LPDWORD lpNumberOfBytesRead,
|
||||
LPVOID pUserData // optional data, which was passed in "ShowCallstack"
|
||||
);
|
||||
|
||||
BOOL LoadModules();
|
||||
|
||||
BOOL ShowCallstack(
|
||||
HANDLE hThread = GetCurrentThread(),
|
||||
const CONTEXT *context = nullptr,
|
||||
PReadProcessMemoryRoutine readMemoryFunction = nullptr,
|
||||
LPVOID pUserData = nullptr // optional to identify some data in the 'readMemoryFunction'-callback
|
||||
);
|
||||
|
||||
#if _MSC_VER >= 1300
|
||||
// due to some reasons, the "STACKWALK_MAX_NAMELEN" must be declared as "public"
|
||||
// in older compilers in order to use it... starting with VC7 we can declare it as "protected"
|
||||
protected:
|
||||
#endif
|
||||
enum { STACKWALK_MAX_NAMELEN = 1024 }; // max name length for found symbols
|
||||
|
||||
protected:
|
||||
// Entry for each Callstack-Entry
|
||||
typedef struct CallstackEntry
|
||||
{
|
||||
DWORD64 offset; // if 0, we have no valid entry
|
||||
CHAR name[STACKWALK_MAX_NAMELEN];
|
||||
CHAR undName[STACKWALK_MAX_NAMELEN];
|
||||
CHAR undFullName[STACKWALK_MAX_NAMELEN];
|
||||
DWORD64 offsetFromSmybol;
|
||||
DWORD offsetFromLine;
|
||||
DWORD lineNumber;
|
||||
CHAR lineFileName[STACKWALK_MAX_NAMELEN];
|
||||
DWORD symType;
|
||||
LPCSTR symTypeString;
|
||||
CHAR moduleName[STACKWALK_MAX_NAMELEN];
|
||||
DWORD64 baseOfImage;
|
||||
CHAR loadedImageName[STACKWALK_MAX_NAMELEN];
|
||||
} CallstackEntry;
|
||||
|
||||
typedef enum CallstackEntryType {firstEntry, nextEntry, lastEntry};
|
||||
|
||||
virtual void OnSymInit(LPCSTR szSearchPath, DWORD symOptions, LPCSTR szUserName);
|
||||
virtual void OnLoadModule(LPCSTR img, LPCSTR mod, DWORD64 baseAddr, DWORD size, DWORD result, LPCSTR symType, LPCSTR pdbName, ULONGLONG fileVersion);
|
||||
virtual void OnCallstackEntry(CallstackEntryType eType, CallstackEntry &entry);
|
||||
virtual void OnDbgHelpErr(LPCSTR szFuncName, DWORD gle, DWORD64 addr);
|
||||
virtual void OnOutput(LPCSTR szText);
|
||||
|
||||
StackWalkerInternal *m_sw;
|
||||
HANDLE m_hProcess;
|
||||
DWORD m_dwProcessId;
|
||||
BOOL m_modulesLoaded;
|
||||
LPSTR m_szSymPath;
|
||||
|
||||
int m_options;
|
||||
|
||||
static BOOL __stdcall myReadProcMem(HANDLE hProcess, DWORD64 qwBaseAddress, PVOID lpBuffer, DWORD nSize, LPDWORD lpNumberOfBytesRead);
|
||||
|
||||
friend StackWalkerInternal;
|
||||
};
|
||||
|
||||
|
||||
// The "ugly" assembler-implementation is needed for systems before XP
|
||||
// If you have a new PSDK and you only compile for XP and later, then you can use
|
||||
// the "RtlCaptureContext"
|
||||
// Currently there is no define which determines the PSDK-Version...
|
||||
// So we just use the compiler-version (and assumes that the PSDK is
|
||||
// the one which was installed by the VS-IDE)
|
||||
|
||||
// INFO: If you want, you can use the RtlCaptureContext if you only target XP and later...
|
||||
// But I currently use it in x64/IA64 environments...
|
||||
//#if defined(_M_IX86) && (_WIN32_WINNT <= 0x0500) && (_MSC_VER < 1400)
|
||||
|
||||
#if defined(_M_IX86)
|
||||
#ifdef CURRENT_THREAD_VIA_EXCEPTION
|
||||
// TODO: The following is not a "good" implementation,
|
||||
// because the callstack is only valid in the "__except" block...
|
||||
#define GET_CURRENT_CONTEXT(c, contextFlags) \
|
||||
do { \
|
||||
memset(&c, 0, sizeof(CONTEXT)); \
|
||||
EXCEPTION_POINTERS *pExp = nullptr; \
|
||||
__try { \
|
||||
throw 0; \
|
||||
} __except( ( (pExp = GetExceptionInformation()) ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_EXECUTE_HANDLER)) {} \
|
||||
if (pExp != nullptr) \
|
||||
memcpy(&c, pExp->ContextRecord, sizeof(CONTEXT)); \
|
||||
c.ContextFlags = contextFlags; \
|
||||
} while(0);
|
||||
#else
|
||||
// The following should be enough for walking the callstack...
|
||||
#define GET_CURRENT_CONTEXT(c, contextFlags) \
|
||||
do { \
|
||||
memset(&c, 0, sizeof(CONTEXT)); \
|
||||
c.ContextFlags = contextFlags; \
|
||||
__asm call x \
|
||||
__asm x: pop eax \
|
||||
__asm mov c.Eip, eax \
|
||||
__asm mov c.Ebp, ebp \
|
||||
__asm mov c.Esp, esp \
|
||||
} while(0);
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
// The following is defined for x86 (XP and higher), x64 and IA64:
|
||||
#define GET_CURRENT_CONTEXT(c, contextFlags) \
|
||||
do { \
|
||||
memset(&c, 0, sizeof(CONTEXT)); \
|
||||
c.ContextFlags = contextFlags; \
|
||||
RtlCaptureContext(&c); \
|
||||
} while(0);
|
||||
#endif
|
||||
#endif
|
||||
+190
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* Boost Software License - Version 1.0 - August 17th, 2003
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person or organization
|
||||
* obtaining a copy of the software and accompanying documentation covered by
|
||||
* this license (the "Software") to use, reproduce, display, distribute,
|
||||
* execute, and transmit the Software, and to prepare derivative works of the
|
||||
* Software, and to permit third-parties to whom the Software is furnished to
|
||||
* do so, all subject to the following:
|
||||
*
|
||||
* The copyright notices in the Software and this entire statement, including
|
||||
* the above license grant, this restriction and the following disclaimer,
|
||||
* must be included in all copies of the Software, in whole or in part, and
|
||||
* all derivative works of the Software, unless such copies or derivative
|
||||
* works are solely in the form of machine-executable object code generated by
|
||||
* a source language processor.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
// EQEmu::Any is a modified version of Boost::Any and as such retains the Boost licensing.
|
||||
|
||||
#ifndef EQEMU_COMMON_ANY_H
|
||||
#define EQEMU_COMMON_ANY_H
|
||||
|
||||
#include <algorithm>
|
||||
#include <typeinfo>
|
||||
|
||||
namespace EQEmu
|
||||
{
|
||||
class Any
|
||||
{
|
||||
public:
|
||||
Any()
|
||||
: content(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
Any(const ValueType &value)
|
||||
: content(new Holder<ValueType>(value))
|
||||
{
|
||||
}
|
||||
|
||||
Any(const Any &other)
|
||||
: content(other.content ? other.content->clone() : 0)
|
||||
{
|
||||
}
|
||||
|
||||
~Any()
|
||||
{
|
||||
if(content)
|
||||
delete content;
|
||||
}
|
||||
|
||||
Any& swap(Any &rhs)
|
||||
{
|
||||
std::swap(content, rhs.content);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
Any& operator=(const ValueType &rhs)
|
||||
{
|
||||
Any(rhs).swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
Any& operator=(Any rhs)
|
||||
{
|
||||
rhs.swap(*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool empty() const
|
||||
{
|
||||
return !content;
|
||||
}
|
||||
|
||||
const std::type_info& type() const
|
||||
{
|
||||
return content ? content->type() : typeid(void);
|
||||
}
|
||||
|
||||
class Placeholder
|
||||
{
|
||||
public:
|
||||
virtual ~Placeholder()
|
||||
{
|
||||
}
|
||||
|
||||
virtual const std::type_info& type() const = 0;
|
||||
virtual Placeholder* clone() const = 0;
|
||||
};
|
||||
|
||||
|
||||
template<typename ValueType>
|
||||
class Holder : public Placeholder
|
||||
{
|
||||
public:
|
||||
Holder(const ValueType &value)
|
||||
: held(value)
|
||||
{
|
||||
}
|
||||
|
||||
virtual const std::type_info& type() const
|
||||
{
|
||||
return typeid(ValueType);
|
||||
}
|
||||
|
||||
virtual Placeholder* clone() const
|
||||
{
|
||||
return new Holder(held);
|
||||
}
|
||||
|
||||
ValueType held;
|
||||
|
||||
private:
|
||||
Holder& operator=(const Holder&);
|
||||
};
|
||||
|
||||
private:
|
||||
template<typename ValueType>
|
||||
friend ValueType* any_cast(Any*);
|
||||
|
||||
template<typename ValueType>
|
||||
friend ValueType* unsafe_any_cast(Any*);
|
||||
|
||||
Placeholder* content;
|
||||
};
|
||||
|
||||
class bad_any_cast : public std::bad_cast
|
||||
{
|
||||
public:
|
||||
virtual const char * what() const throw()
|
||||
{
|
||||
return "DBI::bad_any_cast: failed conversion using DBI::any_cast";
|
||||
}
|
||||
};
|
||||
|
||||
template<typename ValueType>
|
||||
ValueType* any_cast(Any* operand)
|
||||
{
|
||||
return operand &&
|
||||
operand->type() == typeid(ValueType) ? &static_cast<Any::Holder<ValueType>*>(operand->content)->held : nullptr;
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
inline const ValueType* any_cast(const Any* operand)
|
||||
{
|
||||
return any_cast<ValueType>(const_cast<Any*>(operand));
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
ValueType any_cast(Any& operand)
|
||||
{
|
||||
typedef typename std::remove_reference<ValueType>::type nonref;
|
||||
nonref* result = any_cast<nonref>(&operand);
|
||||
if(!result)
|
||||
throw bad_any_cast();
|
||||
return *result;
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
inline ValueType any_cast(const Any& operand)
|
||||
{
|
||||
typedef typename std::remove_reference<ValueType>::type nonref;
|
||||
return any_cast<const nonref&>(const_cast<Any&>(operand));
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
inline ValueType* unsafe_any_cast(Any* operand)
|
||||
{
|
||||
return &static_cast<Any::Holder<ValueType>*>(operand->content)->held;
|
||||
}
|
||||
|
||||
template<typename ValueType>
|
||||
inline const ValueType* unsafe_any_cast(const Any* operand)
|
||||
{
|
||||
return unsafe_any_cast<ValueType>(const_cast<Any*>(operand));
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,34 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2013 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef __EQEMU_COMMON_BASE_DATA_H
|
||||
#define __EQEMU_COMMON_BASE_DATA_H
|
||||
|
||||
struct BaseDataStruct
|
||||
{
|
||||
double base_hp;
|
||||
double base_mana;
|
||||
double base_end;
|
||||
double unk1;
|
||||
double unk2;
|
||||
double hp_factor;
|
||||
double mana_factor;
|
||||
double endurance_factor;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,126 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "debug.h"
|
||||
#include "base_packet.h"
|
||||
#include "misc.h"
|
||||
#include "packet_dump.h"
|
||||
|
||||
|
||||
|
||||
BasePacket::BasePacket(const unsigned char *buf, uint32 len)
|
||||
{
|
||||
this->pBuffer=nullptr;
|
||||
this->size=0;
|
||||
this->_wpos = 0;
|
||||
this->_rpos = 0;
|
||||
this->timestamp.tv_sec = 0;
|
||||
if (len>0) {
|
||||
this->size=len;
|
||||
pBuffer= new unsigned char[len];
|
||||
if (buf) {
|
||||
memcpy(this->pBuffer,buf,len);
|
||||
} else {
|
||||
memset(this->pBuffer,0,len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BasePacket::~BasePacket()
|
||||
{
|
||||
if (pBuffer)
|
||||
delete[] pBuffer;
|
||||
pBuffer=nullptr;
|
||||
}
|
||||
|
||||
|
||||
void BasePacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
{
|
||||
if (timestamp.tv_sec) {
|
||||
char temp[20];
|
||||
strftime(temp,20,"%F %T",localtime((const time_t *)×tamp.tv_sec));
|
||||
buffer += sprintf(buffer, "%s.%06lu ",temp,timestamp.tv_usec);
|
||||
}
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
dIP=long2ip(dst_ip);
|
||||
buffer += sprintf(buffer, "[%s:%d->%s:%d]\n",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
||||
}
|
||||
if (seq != 0xffff)
|
||||
buffer += sprintf(buffer, "[Seq=%u] ",seq);
|
||||
}
|
||||
|
||||
void BasePacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
char buff[128];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
}
|
||||
|
||||
void BasePacket::build_header_dump(char *buffer) const
|
||||
{
|
||||
sprintf(buffer, "[packet]\n");
|
||||
}
|
||||
|
||||
void BasePacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
dIP=long2ip(dst_ip);
|
||||
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
||||
}
|
||||
if (seq != 0xffff)
|
||||
fprintf(to, "[Seq=%u] ",seq);
|
||||
}
|
||||
|
||||
void BasePacket::DumpRaw(FILE *to) const
|
||||
{
|
||||
DumpRawHeader();
|
||||
if (pBuffer && size)
|
||||
dump_message_column(pBuffer, size, " ", to);
|
||||
fprintf(to, "\n");
|
||||
}
|
||||
|
||||
void BasePacket::ReadString(char *str, uint32 Offset, uint32 MaxLength) const
|
||||
{
|
||||
uint32 i = 0, j = Offset;
|
||||
|
||||
do
|
||||
{
|
||||
str[i++] = pBuffer[j++];
|
||||
}
|
||||
while((j < size) && (i < MaxLength) && (str[i - 1] != 0));
|
||||
|
||||
str[i - 1] = '\0';
|
||||
}
|
||||
|
||||
void DumpPacketHex(const BasePacket* app)
|
||||
{
|
||||
DumpPacketHex(app->pBuffer, app->size);
|
||||
}
|
||||
|
||||
void DumpPacketAscii(const BasePacket* app)
|
||||
{
|
||||
DumpPacketAscii(app->pBuffer, app->size);
|
||||
}
|
||||
|
||||
void DumpPacketBin(const BasePacket* app) {
|
||||
DumpPacketBin(app->pBuffer, app->size);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef BASEPACKET_H_
|
||||
#define BASEPACKET_H_
|
||||
|
||||
#include "types.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <time.h>
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
||||
class BasePacket {
|
||||
public:
|
||||
unsigned char *pBuffer;
|
||||
uint32 size, _wpos, _rpos;
|
||||
uint32 src_ip,dst_ip;
|
||||
uint16 src_port,dst_port;
|
||||
uint32 priority;
|
||||
timeval timestamp;
|
||||
|
||||
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
|
||||
virtual void build_header_dump(char *buffer) const;
|
||||
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||
void DumpRaw(FILE *to = stdout) const;
|
||||
|
||||
void setSrcInfo(uint32 sip, uint16 sport) { src_ip=sip; src_port=sport; }
|
||||
void setDstInfo(uint32 dip, uint16 dport) { dst_ip=dip; dst_port=dport; }
|
||||
void setTimeInfo(uint32 ts_sec, uint32 ts_usec) { timestamp.tv_sec=ts_sec; timestamp.tv_usec=ts_usec; }
|
||||
void copyInfo(const BasePacket *p) { src_ip=p->src_ip; src_port=p->src_port; dst_ip=p->dst_ip; dst_port=p->dst_port; timestamp.tv_sec=p->timestamp.tv_sec; timestamp.tv_usec=p->timestamp.tv_usec; }
|
||||
|
||||
inline bool operator<(const BasePacket &rhs) {
|
||||
return (timestamp.tv_sec < rhs.timestamp.tv_sec || (timestamp.tv_sec==rhs.timestamp.tv_sec && timestamp.tv_usec < rhs.timestamp.tv_usec));
|
||||
}
|
||||
|
||||
void WriteUInt8(uint8 value) { *(uint8 *)(pBuffer + _wpos) = value; _wpos += sizeof(uint8); }
|
||||
void WriteUInt32(uint32 value) { *(uint32 *)(pBuffer + _wpos) = value; _wpos += sizeof(uint32); }
|
||||
void WriteUInt64(uint64 value) { *(uint64 *)(pBuffer + _wpos) = value; _wpos += sizeof(uint64); }
|
||||
void WriteUInt16(uint32 value) { *(uint16 *)(pBuffer + _wpos) = value; _wpos += sizeof(uint16); }
|
||||
void WriteSInt32(int32 value) { *(int32 *)(pBuffer + _wpos) = value; _wpos += sizeof(int32); }
|
||||
void WriteFloat(float value) { *(float *)(pBuffer + _wpos) = value; _wpos += sizeof(float); }
|
||||
void WriteDouble(double value) { *(double *)(pBuffer + _wpos) = value; _wpos += sizeof(double); }
|
||||
void WriteString(const char * str) { uint32 len = static_cast<uint32>(strlen(str)) + 1; memcpy(pBuffer + _wpos, str, len); _wpos += len; }
|
||||
|
||||
uint8 ReadUInt8() { uint8 value = *(uint8 *)(pBuffer + _rpos); _rpos += sizeof(uint8); return value; }
|
||||
uint8 ReadUInt8(uint32 Offset) const { uint8 value = *(uint8 *)(pBuffer + Offset); return value; }
|
||||
uint32 ReadUInt32() { uint32 value = *(uint32 *)(pBuffer + _rpos); _rpos += sizeof(uint32); return value; }
|
||||
uint32 ReadUInt32(uint32 Offset) const { uint32 value = *(uint32 *)(pBuffer + Offset); return value; }
|
||||
void ReadString(char *str) { uint32 len = static_cast<uint32>(strlen((char *)(pBuffer + _rpos))) + 1; memcpy(str, pBuffer + _rpos, len); _rpos += len; }
|
||||
void ReadString(char *str, uint32 Offset, uint32 MaxLength) const;
|
||||
|
||||
uint32 GetWritePosition() { return _wpos; }
|
||||
uint32 GetReadPosition() { return _rpos; }
|
||||
void SetWritePosition(uint32 Newwpos) { _wpos = Newwpos; }
|
||||
void SetReadPosition(uint32 Newrpos) { _rpos = Newrpos; }
|
||||
|
||||
protected:
|
||||
virtual ~BasePacket();
|
||||
BasePacket() { pBuffer=nullptr; size=0; _wpos = 0; _rpos = 0; }
|
||||
BasePacket(const unsigned char *buf, const uint32 len);
|
||||
};
|
||||
|
||||
extern void DumpPacketHex(const BasePacket* app);
|
||||
extern void DumpPacketAscii(const BasePacket* app);
|
||||
extern void DumpPacketBin(const BasePacket* app);
|
||||
|
||||
#endif /*BASEPACKET_H_*/
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef BODYTYPES_H
|
||||
#define BODYTYPES_H
|
||||
|
||||
typedef enum {
|
||||
BT_Humanoid = 1,
|
||||
BT_Lycanthrope = 2,
|
||||
BT_Undead = 3,
|
||||
BT_Giant = 4,
|
||||
BT_Construct = 5,
|
||||
BT_Extraplanar = 6,
|
||||
BT_Magical = 7, //this name might be a bit off,
|
||||
BT_SummonedUndead = 8,
|
||||
BT_RaidGiant = 9,
|
||||
// ...
|
||||
BT_NoTarget = 11, //no name, can't target this bodytype
|
||||
BT_Vampire = 12,
|
||||
BT_Atenha_Ra = 13,
|
||||
BT_Greater_Akheva = 14,
|
||||
BT_Khati_Sha = 15,
|
||||
BT_Seru = 16, //not confirmed....
|
||||
BT_Zek = 19,
|
||||
BT_Luggald = 20,
|
||||
BT_Animal = 21,
|
||||
BT_Insect = 22,
|
||||
BT_Monster = 23,
|
||||
BT_Summoned = 24, //Elemental?
|
||||
BT_Plant = 25,
|
||||
BT_Dragon = 26,
|
||||
BT_Summoned2 = 27,
|
||||
BT_Summoned3 = 28,
|
||||
//29
|
||||
BT_VeliousDragon = 30, //might not be a tight set
|
||||
// ...
|
||||
BT_Dragon3 = 32,
|
||||
BT_Boxes = 33,
|
||||
BT_Muramite = 34, //tribal dudes
|
||||
// ...
|
||||
BT_NoTarget2 = 60,
|
||||
// ...
|
||||
BT_SwarmPet = 63, //is this valid, or made up?
|
||||
// ...
|
||||
BT_InvisMan = 66, //no name, seen on 'InvisMan', can be /targeted
|
||||
BT_Special = 67
|
||||
} bodyType;
|
||||
/* bodytypes above 64 make the mob not show up */
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,134 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef BREAKDOWNS_H_
|
||||
#define BREAKDOWNS_H_
|
||||
|
||||
#include "types.h"
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
struct uint16_breakdown {
|
||||
union {
|
||||
uint16 all;
|
||||
struct {
|
||||
uint8 b1;
|
||||
uint8 b2;
|
||||
} bytes;
|
||||
};
|
||||
inline uint16& operator=(const uint16& val) { return (all=val); }
|
||||
inline uint16* operator&() { return &all; }
|
||||
inline operator uint16&() { return all; }
|
||||
inline uint8& b1() { return bytes.b1; }
|
||||
inline uint8& b2() { return bytes.b2; }
|
||||
};
|
||||
|
||||
struct uint32_breakdown {
|
||||
union {
|
||||
uint32 all;
|
||||
struct {
|
||||
uint16 w1;
|
||||
uint16 w2;
|
||||
} words;
|
||||
struct {
|
||||
uint8 b1;
|
||||
union {
|
||||
struct {
|
||||
uint8 b2;
|
||||
uint8 b3;
|
||||
} middle;
|
||||
uint16 w2_3; // word bytes 2 to 3
|
||||
};
|
||||
uint8 b4;
|
||||
} bytes;
|
||||
};
|
||||
inline uint32& operator=(const uint32& val) { return (all=val); }
|
||||
inline uint32* operator&() { return &all; }
|
||||
inline operator uint32&() { return all; }
|
||||
|
||||
inline uint16& w1() { return words.w1; }
|
||||
inline uint16& w2() { return words.w2; }
|
||||
inline uint16& w2_3() { return bytes.w2_3; }
|
||||
inline uint8& b1() { return bytes.b1; }
|
||||
inline uint8& b2() { return bytes.middle.b2; }
|
||||
inline uint8& b3() { return bytes.middle.b3; }
|
||||
inline uint8& b4() { return bytes.b4; }
|
||||
};
|
||||
/*
|
||||
struct uint64_breakdown {
|
||||
union {
|
||||
uint64 all;
|
||||
struct {
|
||||
uint16 w1; // 1 2
|
||||
uint16 w2; // 3 4
|
||||
uint16 w3; // 5 6
|
||||
uint16 w4; // 7 8
|
||||
};
|
||||
struct {
|
||||
uint32 dw1; // 1 4
|
||||
uint32 dw2; // 5 6
|
||||
};
|
||||
struct {
|
||||
uint8 b1;
|
||||
union {
|
||||
struct {
|
||||
uint16 w2_3;
|
||||
uint16 w4_5;
|
||||
uint16 w6_7;
|
||||
};
|
||||
uint32 dw2_5;
|
||||
struct {
|
||||
uint8 b2;
|
||||
union {
|
||||
uint32 dw3_6;
|
||||
struct {
|
||||
uint8 b3;
|
||||
union {
|
||||
uint32 dw4_7;
|
||||
struct {
|
||||
uint8 b4;
|
||||
uint8 b5;
|
||||
uint8 b6;
|
||||
uint8 b7;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
inline uint64* operator&() { return &all; }
|
||||
inline operator uint64&() { return all; }
|
||||
};
|
||||
*/
|
||||
#pragma pack()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /*BREAKDOWNS_H_*/
|
||||
@@ -0,0 +1,339 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "../common/debug.h"
|
||||
#include "../common/classes.h"
|
||||
|
||||
const char* GetEQClassName(uint8 class_, uint8 level) {
|
||||
switch(class_) {
|
||||
case WARRIOR:
|
||||
if (level >= 70)
|
||||
return "Vanquisher";
|
||||
else if (level >= 65)
|
||||
return "Overlord"; //Baron-Sprite: LEAVE MY CLASSES ALONE.
|
||||
else if (level >= 60)
|
||||
return "Warlord";
|
||||
else if (level >= 55)
|
||||
return "Myrmidon";
|
||||
else if (level >= 51)
|
||||
return "Champion";
|
||||
else
|
||||
return "Warrior";
|
||||
case CLERIC:
|
||||
if (level >= 70)
|
||||
return "Prelate";
|
||||
else if (level >= 65)
|
||||
return "Archon";
|
||||
else if (level >= 60)
|
||||
return "High Priest";
|
||||
else if (level >= 55)
|
||||
return "Templar";
|
||||
else if (level >= 51)
|
||||
return "Vicar";
|
||||
else
|
||||
return "Cleric";
|
||||
case PALADIN:
|
||||
if (level >= 70)
|
||||
return "Lord";
|
||||
else if (level >= 65)
|
||||
return "Lord Protector";
|
||||
else if (level >= 60)
|
||||
return "Crusader";
|
||||
else if (level >= 55)
|
||||
return "Knight";
|
||||
else if (level >= 51)
|
||||
return "Cavalier";
|
||||
else
|
||||
return "Paladin";
|
||||
case RANGER:
|
||||
if (level >= 70)
|
||||
return "Plainswalker";
|
||||
else if (level >= 65)
|
||||
return "Forest Stalker";
|
||||
else if (level >= 60)
|
||||
return "Warder";
|
||||
else if (level >= 55)
|
||||
return "Outrider";
|
||||
else if (level >= 51)
|
||||
return "Pathfinder";
|
||||
else
|
||||
return "Ranger";
|
||||
case SHADOWKNIGHT:
|
||||
if (level >= 70)
|
||||
return "Scourge Knight";
|
||||
else if (level >= 65)
|
||||
return "Dread Lord";
|
||||
else if (level >= 60)
|
||||
return "Grave Lord";
|
||||
else if (level >= 55)
|
||||
return "Revenant";
|
||||
else if (level >= 51)
|
||||
return "Reaver";
|
||||
else
|
||||
return "Shadowknight";
|
||||
case DRUID:
|
||||
if (level >= 70)
|
||||
return "Natureguard";
|
||||
else if (level >= 65)
|
||||
return "Storm Warden";
|
||||
else if (level >= 60)
|
||||
return "Hierophant";
|
||||
else if (level >= 55)
|
||||
return "Preserver";
|
||||
else if (level >= 51)
|
||||
return "Wanderer";
|
||||
else
|
||||
return "Druid";
|
||||
case MONK:
|
||||
if (level >= 70)
|
||||
return "Stone Fist";
|
||||
else if (level >= 65)
|
||||
return "Transcendent";
|
||||
else if (level >= 60)
|
||||
return "Grandmaster";
|
||||
else if (level >= 55)
|
||||
return "Master";
|
||||
else if (level >= 51)
|
||||
return "Disciple";
|
||||
else
|
||||
return "Monk";
|
||||
case BARD:
|
||||
if (level >= 70)
|
||||
return "Performer";
|
||||
else if (level >= 65)
|
||||
return "Maestro";
|
||||
else if (level >= 60)
|
||||
return "Virtuoso";
|
||||
else if (level >= 55)
|
||||
return "Troubadour";
|
||||
else if (level >= 51)
|
||||
return "Minstrel";
|
||||
else
|
||||
return "Bard";
|
||||
case ROGUE:
|
||||
if (level >= 70)
|
||||
return "Nemesis";
|
||||
else if (level >= 65)
|
||||
return "Deceiver";
|
||||
else if (level >= 60)
|
||||
return "Assassin";
|
||||
else if (level >= 55)
|
||||
return "Blackguard";
|
||||
else if (level >= 51)
|
||||
return "Rake";
|
||||
else
|
||||
return "Rogue";
|
||||
case SHAMAN:
|
||||
if (level >= 70)
|
||||
return "Soothsayer";
|
||||
else if (level >= 65)
|
||||
return "Prophet";
|
||||
else if (level >= 60)
|
||||
return "Oracle";
|
||||
else if (level >= 55)
|
||||
return "Luminary";
|
||||
else if (level >= 51)
|
||||
return "Mystic";
|
||||
else
|
||||
return "Shaman";
|
||||
case NECROMANCER:
|
||||
if (level >= 70)
|
||||
return "Wraith";
|
||||
else if (level >= 65)
|
||||
return "Arch Lich";
|
||||
else if (level >= 60)
|
||||
return "Warlock";
|
||||
else if (level >= 55)
|
||||
return "Defiler";
|
||||
else if (level >= 51)
|
||||
return "Heretic";
|
||||
else
|
||||
return "Necromancer";
|
||||
case WIZARD:
|
||||
if (level >= 70)
|
||||
return "Grand Arcanist";
|
||||
else if (level >= 65)
|
||||
return "Arcanist";
|
||||
else if (level >= 60)
|
||||
return "Sorcerer";
|
||||
else if (level >= 55)
|
||||
return "Evoker";
|
||||
else if (level >= 51)
|
||||
return "Channeler";
|
||||
else
|
||||
return "Wizard";
|
||||
case MAGICIAN:
|
||||
if (level >= 70)
|
||||
return "Arch Magus";
|
||||
else if (level >= 65)
|
||||
return "Arch Convoker";
|
||||
else if (level >= 60)
|
||||
return "Arch Mage";
|
||||
else if (level >= 55)
|
||||
return "Conjurer";
|
||||
if (level >= 51)
|
||||
return "Elementalist";
|
||||
else
|
||||
return "Magician";
|
||||
case ENCHANTER:
|
||||
if (level >= 70)
|
||||
return "Bedazzler";
|
||||
else if (level >= 65)
|
||||
return "Coercer";
|
||||
else if (level >= 60)
|
||||
return "Phantasmist";
|
||||
else if (level >= 55)
|
||||
return "Beguiler";
|
||||
else if (level >= 51)
|
||||
return "Illusionist";
|
||||
else
|
||||
return "Enchanter";
|
||||
case BEASTLORD:
|
||||
if (level >= 70)
|
||||
return "Wildblood";
|
||||
else if (level >= 65)
|
||||
return "Feral Lord";
|
||||
else if (level >= 60)
|
||||
return "Savage Lord";
|
||||
else if (level >= 55)
|
||||
return "Animist";
|
||||
else if (level >= 51)
|
||||
return "Primalist";
|
||||
else
|
||||
return "Beastlord";
|
||||
case BERSERKER:
|
||||
if (level >= 70)
|
||||
return "Ravager";
|
||||
else if (level >= 65)
|
||||
return "Fury";
|
||||
else if (level >= 60)
|
||||
return "Rager";
|
||||
else if (level >= 55)
|
||||
return "Vehement";
|
||||
else if (level >= 51)
|
||||
return "Brawler";
|
||||
else
|
||||
return "Berserker";
|
||||
case BANKER:
|
||||
if (level >= 70)
|
||||
return "Master Banker";
|
||||
else if (level >= 65)
|
||||
return "Elder Banker";
|
||||
else if (level >= 60)
|
||||
return "Oldest Banker";
|
||||
else if (level >= 55)
|
||||
return "Older Banker";
|
||||
else if (level >= 51)
|
||||
return "Old Banker";
|
||||
else
|
||||
return "Banker";
|
||||
case WARRIORGM:
|
||||
return "Warrior Guildmaster";
|
||||
case CLERICGM:
|
||||
return "Cleric Guildmaster";
|
||||
case PALADINGM:
|
||||
return "Paladin Guildmaster";
|
||||
case RANGERGM:
|
||||
return "Ranger Guildmaster";
|
||||
case SHADOWKNIGHTGM:
|
||||
return "Shadowknight Guildmaster";
|
||||
case DRUIDGM:
|
||||
return "Druid Guildmaster";
|
||||
case MONKGM:
|
||||
return "Monk Guildmaster";
|
||||
case BARDGM:
|
||||
return "Bard Guildmaster";
|
||||
case ROGUEGM:
|
||||
return "Rogue Guildmaster";
|
||||
case SHAMANGM:
|
||||
return "Shaman Guildmaster";
|
||||
case NECROMANCERGM:
|
||||
return "Necromancer Guildmaster";
|
||||
case WIZARDGM:
|
||||
return "Wizard Guildmaster";
|
||||
case MAGICIANGM:
|
||||
return "Magician Guildmaster";
|
||||
case ENCHANTERGM:
|
||||
return "Enchanter Guildmaster";
|
||||
case BEASTLORDGM:
|
||||
return "Beastlord Guildmaster";
|
||||
case BERSERKERGM:
|
||||
return "Berserker Guildmaster";
|
||||
case MERCHANT:
|
||||
return "Merchant";
|
||||
case ADVENTURERECRUITER:
|
||||
return "Adventure Recruiter";
|
||||
case ADVENTUREMERCHANT:
|
||||
return "Adventure Merchant";
|
||||
case CORPSE_CLASS:
|
||||
return "Corpse Class";
|
||||
case TRIBUTE_MASTER:
|
||||
return "Tribute Master";
|
||||
case GUILD_TRIBUTE_MASTER:
|
||||
return "Guild Tribute Master";
|
||||
default:
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
uint32 GetArrayEQClass(uint8 eqclass) {
|
||||
switch (eqclass) {
|
||||
case WARRIOR:
|
||||
return WARRIOR;
|
||||
case CLERIC:
|
||||
return CLERIC;
|
||||
case PALADIN:
|
||||
return PALADIN;
|
||||
case RANGER:
|
||||
return RANGER;
|
||||
case SHADOWKNIGHT:
|
||||
return SHADOWKNIGHT;
|
||||
case DRUID:
|
||||
return DRUID;
|
||||
case MONK:
|
||||
return MONK;
|
||||
case BARD:
|
||||
return BARD;
|
||||
case ROGUE:
|
||||
return ROGUE;
|
||||
case SHAMAN:
|
||||
return SHAMAN;
|
||||
case NECROMANCER:
|
||||
return NECROMANCER;
|
||||
case WIZARD:
|
||||
return WIZARD;
|
||||
case MAGICIAN:
|
||||
return MAGICIAN;
|
||||
case ENCHANTER:
|
||||
return ENCHANTER;
|
||||
case BEASTLORD:
|
||||
return BEASTLORD;
|
||||
case BERSERKER:
|
||||
return BERSERKER;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint8 GetEQArrayEQClass(uint8 eqclass) {
|
||||
if (eqclass >= WARRIOR && eqclass <= BERSERKER)
|
||||
return eqclass - WARRIOR;
|
||||
if (eqclass >= WARRIORGM && eqclass <= BERSERKERGM)
|
||||
return eqclass - WARRIORGM;
|
||||
return WARRIOR;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef CLASSES_CH
|
||||
#define CLASSES_CH
|
||||
#include "../common/types.h"
|
||||
|
||||
#define Array_Class_UNKNOWN 0
|
||||
#define WARRIOR 1
|
||||
#define CLERIC 2
|
||||
#define PALADIN 3
|
||||
#define RANGER 4
|
||||
#define SHADOWKNIGHT 5
|
||||
#define DRUID 6
|
||||
#define MONK 7
|
||||
#define BARD 8
|
||||
#define ROGUE 9
|
||||
#define SHAMAN 10
|
||||
#define NECROMANCER 11
|
||||
#define WIZARD 12
|
||||
#define MAGICIAN 13
|
||||
#define ENCHANTER 14
|
||||
#define BEASTLORD 15
|
||||
#define BERSERKER 16
|
||||
#define PLAYER_CLASS_COUNT 16 // used for array defines, must be the count of playable classes
|
||||
#define WARRIORGM 20
|
||||
#define CLERICGM 21
|
||||
#define PALADINGM 22
|
||||
#define RANGERGM 23
|
||||
#define SHADOWKNIGHTGM 24
|
||||
#define DRUIDGM 25
|
||||
#define MONKGM 26
|
||||
#define BARDGM 27
|
||||
#define ROGUEGM 28
|
||||
#define SHAMANGM 29
|
||||
#define NECROMANCERGM 30
|
||||
#define WIZARDGM 31
|
||||
#define MAGICIANGM 32
|
||||
#define ENCHANTERGM 33
|
||||
#define BEASTLORDGM 34
|
||||
#define BERSERKERGM 35
|
||||
#define BANKER 40
|
||||
#define MERCHANT 41
|
||||
#define DISCORD_MERCHANT 59
|
||||
#define ADVENTURERECRUITER 60
|
||||
#define ADVENTUREMERCHANT 61
|
||||
#define LDON_TREASURE 62 //objects you can use /open on first seen in LDONs
|
||||
#define CORPSE_CLASS 62 //only seen on Danvi's Corpse in Akheva so far..
|
||||
#define TRIBUTE_MASTER 63
|
||||
#define GUILD_TRIBUTE_MASTER 64 //not sure
|
||||
#define NORRATHS_KEEPERS_MERCHANT 67
|
||||
#define DARK_REIGN_MERCHANT 68
|
||||
#define FELLOWSHIP_MASTER 69
|
||||
#define ALT_CURRENCY_MERCHANT 70
|
||||
#define MERCERNARY_MASTER 71
|
||||
#define warrior_1 1
|
||||
#define monk_1 64
|
||||
#define paladin_1 4
|
||||
#define shadow_1 16
|
||||
#define bard_1 128
|
||||
#define cleric_1 2
|
||||
#define necromancer_1 1024
|
||||
#define ranger_1 8
|
||||
#define druid_1 32
|
||||
#define mage_1 4096
|
||||
#define wizard_1 2048
|
||||
#define enchanter_1 8192
|
||||
#define rogue_1 256
|
||||
#define shaman_1 512
|
||||
#define beastlord_1 16384
|
||||
#define berserker_1 32768
|
||||
#define call_1 65536
|
||||
|
||||
const char* GetEQClassName(uint8 class_, uint8 level = 0);
|
||||
uint32 GetArrayEQClass(uint8 eqclass);
|
||||
uint8 GetEQArrayEQClass(uint8 eqclass);
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
#ifndef CLIENTVERSIONS_H
|
||||
#define CLIENTVERSIONS_H
|
||||
|
||||
static const uint32 BIT_Client62 = 1;
|
||||
static const uint32 BIT_Titanium = 2;
|
||||
static const uint32 BIT_SoF = 4;
|
||||
static const uint32 BIT_SoD = 8;
|
||||
static const uint32 BIT_Underfoot = 16;
|
||||
static const uint32 BIT_RoF = 32;
|
||||
static const uint32 BIT_RoF2 = 64;
|
||||
|
||||
static const uint32 BIT_TitaniumAndEarlier = 0x00000003;
|
||||
static const uint32 BIT_SoFAndLater = 0xFFFFFFFC;
|
||||
static const uint32 BIT_SoDAndLater = 0xFFFFFFF8;
|
||||
static const uint32 BIT_UnderfootAndLater = 0xFFFFFFF0;
|
||||
static const uint32 BIT_RoFAndLater = 0xFFFFFFE0;
|
||||
static const uint32 BIT_RoF2AndLater = 0xFFFFFFC0;
|
||||
static const uint32 BIT_AllClients = 0xFFFFFFFF;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EQClientUnknown = 0,
|
||||
EQClient62, // Build: 'Aug 4 2005 15:40:59'
|
||||
EQClientTitanium, // Build: 'Oct 31 2005 10:33:37'
|
||||
EQClientSoF, // Build: 'Sep 7 2007 09:11:49'
|
||||
EQClientSoD, // Build: 'Dec 19 2008 15:22:49'
|
||||
EQClientUnderfoot, // Build: 'Jun 8 2010 16:44:32'
|
||||
EQClientRoF, // Build: 'Dec 10 2012 17:35:44'
|
||||
EQClientRoF2, // Build: 'May 10 2013 23:30:08'
|
||||
|
||||
_EQClientCount, // place new clients before this point (preferably, in release/attribute order)
|
||||
|
||||
// Values below are not implemented, as yet...
|
||||
|
||||
EmuNPC = _EQClientCount,
|
||||
EmuMerc,
|
||||
EmuBot,
|
||||
EmuPet,
|
||||
|
||||
_EmuClientCount // array size for EQLimits
|
||||
} EQClientVersion;
|
||||
|
||||
static const char* EQClientVersionName(EQClientVersion version)
|
||||
{
|
||||
switch (version)
|
||||
{
|
||||
case EQClientUnknown:
|
||||
return "EQClientUnknown";
|
||||
case EQClient62:
|
||||
return "EQClient62";
|
||||
case EQClientTitanium:
|
||||
return "EQClientTitanium";
|
||||
case EQClientSoF:
|
||||
return "EQClientSoF";
|
||||
case EQClientSoD:
|
||||
return "EQClientSoD";
|
||||
case EQClientUnderfoot:
|
||||
return "EQClientUnderfoot";
|
||||
case EQClientRoF:
|
||||
return "EQClientRoF";
|
||||
case EQClientRoF2:
|
||||
return "EQClientRoF2";
|
||||
case EmuNPC:
|
||||
return "EmuNPC";
|
||||
case EmuMerc:
|
||||
return "EmuMerc";
|
||||
case EmuBot:
|
||||
return "EmuBot";
|
||||
case EmuPet:
|
||||
return "EmuPet";
|
||||
default:
|
||||
return "ERROR: Invalid EQClientVersion";
|
||||
};
|
||||
}
|
||||
|
||||
#endif /* CLIENTVERSIONS_H */
|
||||
@@ -0,0 +1,148 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
#include "condition.h"
|
||||
|
||||
#ifdef _WINDOWS
|
||||
|
||||
Condition::Condition()
|
||||
{
|
||||
m_events[SignalEvent] = CreateEvent (nullptr, // security
|
||||
FALSE, // is auto-reset event?
|
||||
FALSE, // is signaled initially?
|
||||
nullptr); // name
|
||||
m_events[BroadcastEvent] = CreateEvent (nullptr, // security
|
||||
TRUE, // is auto-reset event?
|
||||
FALSE, // is signaled initially?
|
||||
nullptr); // name
|
||||
m_waiters = 0;
|
||||
InitializeCriticalSection(&CSMutex);
|
||||
}
|
||||
|
||||
Condition::~Condition()
|
||||
{
|
||||
DeleteCriticalSection(&CSMutex);
|
||||
CloseHandle(m_events[SignalEvent]);
|
||||
CloseHandle(m_events[BroadcastEvent]);
|
||||
}
|
||||
|
||||
void Condition::Signal()
|
||||
{
|
||||
EnterCriticalSection(&CSMutex);
|
||||
if(m_waiters > 0)
|
||||
SetEvent(m_events[SignalEvent]);
|
||||
LeaveCriticalSection(&CSMutex);
|
||||
}
|
||||
|
||||
void Condition::SignalAll()
|
||||
{
|
||||
EnterCriticalSection(&CSMutex);
|
||||
if(m_waiters > 0)
|
||||
SetEvent(m_events[BroadcastEvent]);
|
||||
LeaveCriticalSection(&CSMutex);
|
||||
}
|
||||
|
||||
void Condition::Wait()
|
||||
{
|
||||
EnterCriticalSection(&CSMutex);
|
||||
|
||||
m_waiters++;
|
||||
|
||||
|
||||
LeaveCriticalSection(&CSMutex);
|
||||
int result = WaitForMultipleObjects (_eventCount, m_events, FALSE, INFINITE);
|
||||
EnterCriticalSection(&CSMutex);
|
||||
|
||||
m_waiters--;
|
||||
|
||||
//see if we are the last person waiting on the condition, and there was a broadcast
|
||||
//if so, we need to reset the broadcast event.
|
||||
if(m_waiters == 0 && result == (WAIT_OBJECT_0+BroadcastEvent))
|
||||
ResetEvent(m_events[BroadcastEvent]);
|
||||
|
||||
LeaveCriticalSection(&CSMutex);
|
||||
}
|
||||
|
||||
#else
|
||||
#include <pthread.h>
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
|
||||
Condition::Condition()
|
||||
{
|
||||
pthread_cond_init(&cond,nullptr);
|
||||
pthread_mutex_init(&mutex,nullptr);
|
||||
}
|
||||
|
||||
void Condition::Signal()
|
||||
{
|
||||
pthread_mutex_lock(&mutex);
|
||||
pthread_cond_signal(&cond);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
}
|
||||
|
||||
void Condition::SignalAll()
|
||||
{
|
||||
pthread_mutex_lock(&mutex);
|
||||
pthread_cond_broadcast(&cond);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
}
|
||||
|
||||
void Condition::Wait()
|
||||
{
|
||||
pthread_mutex_lock(&mutex);
|
||||
pthread_cond_wait(&cond,&mutex);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
}
|
||||
|
||||
/*
|
||||
I commented this specifically because I think it might be very
|
||||
difficult to write a windows counterpart to it, so I would like
|
||||
to discourage its use until we can confirm that it can be reasonably
|
||||
implemented on windows.
|
||||
|
||||
bool Condition::TimedWait(unsigned long usec)
|
||||
{
|
||||
struct timeval now;
|
||||
struct timespec timeout;
|
||||
int retcode=0;
|
||||
pthread_mutex_lock(&mutex);
|
||||
gettimeofday(&now,nullptr);
|
||||
now.tv_usec+=usec;
|
||||
timeout.tv_sec = now.tv_sec + (now.tv_usec/1000000);
|
||||
timeout.tv_nsec = (now.tv_usec%1000000) *1000;
|
||||
//cout << "now=" << now.tv_sec << "."<<now.tv_usec << endl;
|
||||
//cout << "timeout=" << timeout.tv_sec << "."<<timeout.tv_nsec << endl;
|
||||
retcode=pthread_cond_timedwait(&cond,&mutex,&timeout);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
return retcode!=ETIMEDOUT;
|
||||
}
|
||||
*/
|
||||
|
||||
Condition::~Condition()
|
||||
{
|
||||
pthread_mutex_lock(&mutex);
|
||||
pthread_cond_destroy(&cond);
|
||||
pthread_mutex_unlock(&mutex);
|
||||
pthread_mutex_destroy(&mutex);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef __CONDITION_H
|
||||
#define __CONDITION_H
|
||||
|
||||
#include "debug.h"
|
||||
#ifndef WIN32
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
//Sombody, someday needs to figure out how to implement a condition
|
||||
//system on windows...
|
||||
|
||||
|
||||
class Condition {
|
||||
private:
|
||||
#ifdef WIN32
|
||||
enum {
|
||||
SignalEvent = 0,
|
||||
BroadcastEvent,
|
||||
_eventCount
|
||||
};
|
||||
|
||||
HANDLE m_events[_eventCount];
|
||||
uint32 m_waiters;
|
||||
CRITICAL_SECTION CSMutex;
|
||||
#else
|
||||
pthread_cond_t cond;
|
||||
pthread_mutex_t mutex;
|
||||
#endif
|
||||
public:
|
||||
Condition();
|
||||
void Signal();
|
||||
void SignalAll();
|
||||
void Wait();
|
||||
// bool TimedWait(unsigned long usec);
|
||||
~Condition();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
#include "debug.h"
|
||||
#include "crash.h"
|
||||
|
||||
#if defined(_WINDOWS) && defined(CRASH_LOGGING)
|
||||
#include "StackWalker.h"
|
||||
|
||||
class EQEmuStackWalker : public StackWalker
|
||||
{
|
||||
public:
|
||||
EQEmuStackWalker() : StackWalker() { }
|
||||
EQEmuStackWalker(DWORD dwProcessId, HANDLE hProcess) : StackWalker(dwProcessId, hProcess) { }
|
||||
virtual void OnOutput(LPCSTR szText) {
|
||||
char buffer[4096];
|
||||
for(int i = 0; i < 4096; ++i) {
|
||||
if(szText[i] == 0) {
|
||||
buffer[i] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
if(szText[i] == '\n' || szText[i] == '\r') {
|
||||
buffer[i] = ' ';
|
||||
} else {
|
||||
buffer[i] = szText[i];
|
||||
}
|
||||
}
|
||||
|
||||
LogFile->write(EQEMuLog::Crash, buffer);
|
||||
StackWalker::OnOutput(szText);
|
||||
}
|
||||
};
|
||||
|
||||
LONG WINAPI windows_exception_handler(EXCEPTION_POINTERS *ExceptionInfo)
|
||||
{
|
||||
switch(ExceptionInfo->ExceptionRecord->ExceptionCode)
|
||||
{
|
||||
case EXCEPTION_ACCESS_VIOLATION:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_ACCESS_VIOLATION");
|
||||
break;
|
||||
case EXCEPTION_ARRAY_BOUNDS_EXCEEDED:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_ARRAY_BOUNDS_EXCEEDED");
|
||||
break;
|
||||
case EXCEPTION_BREAKPOINT:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_BREAKPOINT");
|
||||
break;
|
||||
case EXCEPTION_DATATYPE_MISALIGNMENT:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_DATATYPE_MISALIGNMENT");
|
||||
break;
|
||||
case EXCEPTION_FLT_DENORMAL_OPERAND:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_DENORMAL_OPERAND");
|
||||
break;
|
||||
case EXCEPTION_FLT_DIVIDE_BY_ZERO:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_DIVIDE_BY_ZERO");
|
||||
break;
|
||||
case EXCEPTION_FLT_INEXACT_RESULT:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_INEXACT_RESULT");
|
||||
break;
|
||||
case EXCEPTION_FLT_INVALID_OPERATION:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_INVALID_OPERATION");
|
||||
break;
|
||||
case EXCEPTION_FLT_OVERFLOW:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_OVERFLOW");
|
||||
break;
|
||||
case EXCEPTION_FLT_STACK_CHECK:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_STACK_CHECK");
|
||||
break;
|
||||
case EXCEPTION_FLT_UNDERFLOW:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_FLT_UNDERFLOW");
|
||||
break;
|
||||
case EXCEPTION_ILLEGAL_INSTRUCTION:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_ILLEGAL_INSTRUCTION");
|
||||
break;
|
||||
case EXCEPTION_IN_PAGE_ERROR:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_IN_PAGE_ERROR");
|
||||
break;
|
||||
case EXCEPTION_INT_DIVIDE_BY_ZERO:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_INT_DIVIDE_BY_ZERO");
|
||||
break;
|
||||
case EXCEPTION_INT_OVERFLOW:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_INT_OVERFLOW");
|
||||
break;
|
||||
case EXCEPTION_INVALID_DISPOSITION:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_INVALID_DISPOSITION");
|
||||
break;
|
||||
case EXCEPTION_NONCONTINUABLE_EXCEPTION:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_NONCONTINUABLE_EXCEPTION");
|
||||
break;
|
||||
case EXCEPTION_PRIV_INSTRUCTION:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_PRIV_INSTRUCTION");
|
||||
break;
|
||||
case EXCEPTION_SINGLE_STEP:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_SINGLE_STEP");
|
||||
break;
|
||||
case EXCEPTION_STACK_OVERFLOW:
|
||||
LogFile->write(EQEMuLog::Crash, "EXCEPTION_STACK_OVERFLOW");
|
||||
break;
|
||||
default:
|
||||
LogFile->write(EQEMuLog::Crash, "Unknown Exception");
|
||||
break;
|
||||
}
|
||||
|
||||
if(EXCEPTION_STACK_OVERFLOW != ExceptionInfo->ExceptionRecord->ExceptionCode)
|
||||
{
|
||||
EQEmuStackWalker sw; sw.ShowCallstack(GetCurrentThread(), ExceptionInfo->ContextRecord);
|
||||
}
|
||||
|
||||
return EXCEPTION_EXECUTE_HANDLER;
|
||||
}
|
||||
|
||||
void set_exception_handler() {
|
||||
SetUnhandledExceptionFilter(windows_exception_handler);
|
||||
}
|
||||
#else
|
||||
// crash is off or an unhandled platform
|
||||
void set_exception_handler() {
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef __EQEMU_CRASH_H
|
||||
#define __EQEMU_CRASH_H
|
||||
|
||||
void set_exception_handler();
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "crc32.h"
|
||||
|
||||
uint16 CRC16(const unsigned char *buf, int size, int key)
|
||||
{
|
||||
// This is computed as the lowest 16 bits of an Ethernet CRC32 checksum
|
||||
// where the key is prepended to the data in little endian order.
|
||||
uint8 keyBuf[] = {(uint8)((key >> 0) & 0xff),
|
||||
(uint8)((key >> 8) & 0xff),
|
||||
(uint8)((key >> 16) & 0xff),
|
||||
(uint8)((key >> 24) & 0xff)};
|
||||
uint32 crc = CRC32::Update(keyBuf, sizeof(uint32));
|
||||
crc = CRC32::Update(buf, size, crc);
|
||||
return CRC32::Finish(crc) & 0xffff;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef _CRC16_H
|
||||
#define _CRC16_H
|
||||
#include "types.h"
|
||||
|
||||
uint16 CRC16(const unsigned char *buf, int size, int key);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,112 @@
|
||||
#include "crc32.h"
|
||||
#include <assert.h>
|
||||
#include <memory.h>
|
||||
|
||||
uint32 CRC32Table[256] =
|
||||
{
|
||||
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
|
||||
0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
|
||||
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
|
||||
0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
|
||||
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
|
||||
0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
|
||||
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
|
||||
0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
|
||||
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
|
||||
0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
|
||||
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
|
||||
0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
|
||||
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
|
||||
0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
|
||||
0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
|
||||
0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
|
||||
|
||||
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
|
||||
0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
|
||||
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
|
||||
0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
|
||||
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
|
||||
0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
|
||||
0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
|
||||
0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
|
||||
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
|
||||
0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
|
||||
0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
|
||||
0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
|
||||
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
|
||||
0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
|
||||
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
|
||||
0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
|
||||
|
||||
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
|
||||
0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
|
||||
0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
|
||||
0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
|
||||
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
|
||||
0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
|
||||
0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
|
||||
0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
|
||||
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
|
||||
0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
|
||||
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
|
||||
0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
|
||||
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
|
||||
0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
|
||||
0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
|
||||
0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
|
||||
|
||||
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
|
||||
0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
|
||||
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
|
||||
0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
|
||||
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
|
||||
0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
|
||||
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
|
||||
0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
|
||||
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
|
||||
0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
|
||||
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
|
||||
0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
|
||||
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
|
||||
0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
|
||||
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
|
||||
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
|
||||
};
|
||||
|
||||
uint32 CRC32::Generate(const uint8* buf, uint32 bufsize) {
|
||||
return Finish(Update(buf, bufsize));
|
||||
}
|
||||
|
||||
uint32 CRC32::GenerateNoFlip(const uint8* buf, uint32 bufsize) {
|
||||
return Update(buf, bufsize);
|
||||
}
|
||||
|
||||
void CRC32::SetEQChecksum(uchar* in_data, uint32 in_length, uint32 start_at)
|
||||
{
|
||||
unsigned long data;
|
||||
unsigned long check = 0xffffffff;
|
||||
|
||||
assert(in_length >= start_at && in_data);
|
||||
|
||||
for(uint32 i=start_at; i<in_length; i++)
|
||||
{
|
||||
data = in_data[i];
|
||||
data = data ^ (check);
|
||||
data = data & 0x000000ff;
|
||||
check = check >> 8;
|
||||
data = CRC32Table[data];
|
||||
check = check ^ data;
|
||||
}
|
||||
|
||||
memcpy(in_data, (char*)&check, 4);
|
||||
}
|
||||
|
||||
uint32 CRC32::Update(const uint8* buf, uint32 bufsize, uint32 crc32var) {
|
||||
for(uint32 i=0; i < bufsize; i++)
|
||||
Calc(buf[i], crc32var);
|
||||
return crc32var;
|
||||
}
|
||||
|
||||
inline void CRC32::Calc(const uint8 byte, uint32& crc32var) {
|
||||
crc32var = ((crc32var) >> 8) ^ CRC32Table[(byte) ^ ((crc32var) & 0x000000FF)];
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef CRC32_H
|
||||
#define CRC32_H
|
||||
#include "types.h"
|
||||
|
||||
class CRC32 {
|
||||
public:
|
||||
// one buffer CRC32
|
||||
static uint32 Generate(const uint8* buf, uint32 bufsize);
|
||||
static uint32 GenerateNoFlip(const uint8* buf, uint32 bufsize); // Same as Generate(), but without the ~
|
||||
static void SetEQChecksum(uchar* in_data, uint32 in_length, uint32 start_at=4);
|
||||
|
||||
// Multiple buffer CRC32
|
||||
static uint32 Update(const uint8* buf, uint32 bufsize, uint32 crc32 = 0xFFFFFFFF);
|
||||
static inline uint32 Finish(uint32 crc32) { return ~crc32; }
|
||||
static inline void Finish(uint32* crc32) { *crc32 = ~(*crc32); }
|
||||
|
||||
private:
|
||||
static inline void Calc(const uint8 byte, uint32& crc32);
|
||||
};
|
||||
#endif
|
||||
@@ -0,0 +1,48 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2014 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef COMMON_DATA_VERIFICATION_H
|
||||
#define COMMON_DATA_VERIFICATION_H
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace EQEmu
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
T Clamp(const T& value, const T& lower, const T& upper) {
|
||||
return std::max(lower, std::min(value, upper));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T ClampLower(const T& value, const T& lower) {
|
||||
return std::max(lower, value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T ClampUpper(const T& value, const T& upper) {
|
||||
return std::min(value, upper);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool ValueWithin(const T& value, const T& lower, const T& upper) {
|
||||
return value >= lower && value <= upper;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
+3746
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,279 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef EQEMU_DATABASE_H
|
||||
#define EQEMU_DATABASE_H
|
||||
|
||||
#define AUTHENTICATION_TIMEOUT 60
|
||||
#define INVALID_ID 0xFFFFFFFF
|
||||
|
||||
#include "debug.h"
|
||||
#include "types.h"
|
||||
#include "dbcore.h"
|
||||
#include "linked_list.h"
|
||||
#include "eq_packet_structs.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
//atoi is not uint32 or uint32 safe!!!!
|
||||
#define atoul(str) strtoul(str, nullptr, 10)
|
||||
|
||||
//class Spawn;
|
||||
class Corpse;
|
||||
class Spawn2;
|
||||
class NPC;
|
||||
class SpawnGroupList;
|
||||
class Petition;
|
||||
class Client;
|
||||
class Merc;
|
||||
struct Combine_Struct;
|
||||
//struct Faction;
|
||||
//struct FactionMods;
|
||||
//struct FactionValue;
|
||||
struct ZonePoint;
|
||||
struct NPCType;
|
||||
class Inventory;
|
||||
class ItemInst;
|
||||
|
||||
struct EventLogDetails_Struct {
|
||||
uint32 id;
|
||||
char accountname[64];
|
||||
uint32 account_id;
|
||||
int16 status;
|
||||
char charactername[64];
|
||||
char targetname[64];
|
||||
char timestamp[64];
|
||||
char descriptiontype[64];
|
||||
char details[128];
|
||||
};
|
||||
|
||||
struct CharacterEventLog_Struct {
|
||||
uint32 count;
|
||||
uint8 eventid;
|
||||
EventLogDetails_Struct eld[255];
|
||||
};
|
||||
|
||||
|
||||
// Added By Hogie
|
||||
// INSERT into variables (varname,value) values('decaytime [minlevel] [maxlevel]','[number of seconds]');
|
||||
// IE: decaytime 1 54 = Levels 1 through 54
|
||||
// decaytime 55 100 = Levels 55 through 100
|
||||
// It will always put the LAST time for the level (I think) from the Database
|
||||
struct npcDecayTimes_Struct {
|
||||
uint16 minlvl;
|
||||
uint16 maxlvl;
|
||||
uint32 seconds;
|
||||
};
|
||||
// Added By Hogie -- End
|
||||
|
||||
struct VarCache_Struct {
|
||||
char varname[26]; // varname is char(25) in database
|
||||
char value[0];
|
||||
};
|
||||
|
||||
struct PlayerProfile_Struct;
|
||||
struct GuildRankLevel_Struct;
|
||||
struct GuildRanks_Struct;
|
||||
struct ExtendedProfile_Struct;
|
||||
struct GuildMember_Struct;
|
||||
class PTimerList;
|
||||
|
||||
class Database : public DBcore {
|
||||
public:
|
||||
Database();
|
||||
Database(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
|
||||
bool Connect(const char* host, const char* user, const char* passwd, const char* database,uint32 port);
|
||||
~Database();
|
||||
bool ThrowDBError(std::string ErrorMessage, std::string query_title, std::string query);
|
||||
|
||||
|
||||
/*
|
||||
* General Character Related Stuff
|
||||
*/
|
||||
|
||||
/* Character Creation */
|
||||
bool SaveCharacterCreate(uint32 character_id, uint32 account_id, PlayerProfile_Struct* pp);
|
||||
|
||||
bool MoveCharacterToZone(const char* charname, const char* zonename);
|
||||
bool MoveCharacterToZone(const char* charname, const char* zonename,uint32 zoneid);
|
||||
bool MoveCharacterToZone(uint32 iCharID, const char* iZonename);
|
||||
bool UpdateName(const char* oldname, const char* newname);
|
||||
bool SetHackerFlag(const char* accountname, const char* charactername, const char* hacked);
|
||||
bool SetMQDetectionFlag(const char* accountname, const char* charactername, const char* hacked, const char* zone);
|
||||
bool AddToNameFilter(const char* name);
|
||||
bool ReserveName(uint32 account_id, char* name);
|
||||
bool CreateCharacter(uint32 account_id, char* name, uint16 gender, uint16 race, uint16 class_, uint8 str, uint8 sta, uint8 cha, uint8 dex, uint8 int_, uint8 agi, uint8 wis, uint8 face);
|
||||
bool StoreCharacter(uint32 account_id, PlayerProfile_Struct* pp, Inventory* inv);
|
||||
bool DeleteCharacter(char* name);
|
||||
|
||||
/*
|
||||
* General Information Getting Queries
|
||||
*/
|
||||
bool CheckNameFilter(const char* name, bool surname = false);
|
||||
bool CheckUsedName(const char* name);
|
||||
uint32 GetAccountIDByChar(const char* charname, uint32* oCharID = 0);
|
||||
uint32 GetAccountIDByChar(uint32 char_id);
|
||||
uint32 GetAccountIDByName(const char* accname, int16* status = 0, uint32* lsid = 0);
|
||||
uint32 GetGuildIDByCharID(uint32 char_id);
|
||||
void GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID = 0);
|
||||
void GetCharName(uint32 char_id, char* name);
|
||||
uint32 GetCharacterInfo(const char* iName, uint32* oAccID = 0, uint32* oZoneID = 0, uint32* oInstanceID = 0,float* oX = 0, float* oY = 0, float* oZ = 0);
|
||||
uint32 GetCharacterID(const char *name);
|
||||
bool CheckBannedIPs(const char* loginIP); //Lieka Edit: Check incomming connection against banned IP table.
|
||||
bool AddBannedIP(char* bannedIP, const char* notes); //Lieka Edit: Add IP address to the Banned_IPs table.
|
||||
bool CheckGMIPs(const char* loginIP, uint32 account_id);
|
||||
bool AddGMIP(char* ip_address, char* name);
|
||||
void LoginIP(uint32 AccountID, const char* LoginIP);
|
||||
|
||||
/*
|
||||
* Instancing Stuff
|
||||
*/
|
||||
bool VerifyZoneInstance(uint32 zone_id, uint16 instance_id);
|
||||
bool VerifyInstanceAlive(uint16 instance_id, uint32 char_id);
|
||||
bool CharacterInInstanceGroup(uint16 instance_id, uint32 char_id);
|
||||
void DeleteInstance(uint16 instance_id);
|
||||
bool CheckInstanceExpired(uint16 instance_id);
|
||||
uint32 ZoneIDFromInstanceID(uint16 instance_id);
|
||||
uint32 VersionFromInstanceID(uint16 instance_id);
|
||||
uint32 GetTimeRemainingInstance(uint16 instance_id, bool &is_perma);
|
||||
bool GetUnusedInstanceID(uint16 &instance_id);
|
||||
bool CreateInstance(uint16 instance_id, uint32 zone_id, uint32 version, uint32 duration);
|
||||
void PurgeExpiredInstances();
|
||||
bool AddClientToInstance(uint16 instance_id, uint32 char_id);
|
||||
bool RemoveClientFromInstance(uint16 instance_id, uint32 char_id);
|
||||
bool RemoveClientsFromInstance(uint16 instance_id);
|
||||
bool CheckInstanceExists(uint16 instance_id);
|
||||
void BuryCorpsesInInstance(uint16 instance_id);
|
||||
uint16 GetInstanceVersion(uint16 instance_id);
|
||||
uint16 GetInstanceID(const char* zone, uint32 charid, int16 version);
|
||||
uint16 GetInstanceID(uint32 zone, uint32 charid, int16 version);
|
||||
void GetCharactersInInstance(uint16 instance_id, std::list<uint32> &charid_list);
|
||||
void AssignGroupToInstance(uint32 gid, uint32 instance_id);
|
||||
void AssignRaidToInstance(uint32 rid, uint32 instance_id);
|
||||
void FlagInstanceByGroupLeader(uint32 zone, int16 version, uint32 charid, uint32 gid);
|
||||
void FlagInstanceByRaidLeader(uint32 zone, int16 version, uint32 charid, uint32 rid);
|
||||
void SetInstanceDuration(uint16 instance_id, uint32 new_duration);
|
||||
bool GlobalInstance(uint16 instance_id);
|
||||
|
||||
/*
|
||||
* Adventure related.
|
||||
*/
|
||||
void UpdateAdventureStatsEntry(uint32 char_id, uint8 theme, bool win);
|
||||
bool GetAdventureStats(uint32 char_id, uint32 &guk_w, uint32 &mir_w, uint32 &mmc_w, uint32 &ruj_w, uint32 &tak_w,
|
||||
uint32 &guk_l, uint32 &mir_l, uint32 &mmc_l, uint32 &ruj_l, uint32 &tak_l);
|
||||
|
||||
/*
|
||||
* Account Related
|
||||
*/
|
||||
uint32 GetMiniLoginAccount(char* ip);
|
||||
void GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus);
|
||||
uint32 CheckLogin(const char* name, const char* password, int16* oStatus = 0);
|
||||
int16 CheckStatus(uint32 account_id);
|
||||
uint32 CreateAccount(const char* name, const char* password, int16 status, uint32 lsaccount_id = 0);
|
||||
bool DeleteAccount(const char* name);
|
||||
bool SetAccountStatus(const char* name, int16 status);
|
||||
bool SetLocalPassword(uint32 accid, const char* password);
|
||||
uint32 GetAccountIDFromLSID(uint32 iLSID, char* oAccountName = 0, int16* oStatus = 0);
|
||||
bool UpdateLiveChar(char* charname,uint32 lsaccount_id);
|
||||
bool GetLiveChar(uint32 account_id, char* cname);
|
||||
uint8 GetAgreementFlag(uint32 acctid);
|
||||
void SetAgreementFlag(uint32 acctid);
|
||||
|
||||
/*
|
||||
* Groups
|
||||
*/
|
||||
uint32 GetGroupID(const char* name);
|
||||
void SetGroupID(const char* name, uint32 id, uint32 charid, uint32 ismerc = false);
|
||||
void ClearGroup(uint32 gid = 0);
|
||||
char* GetGroupLeaderForLogin(const char* name,char* leaderbuf);
|
||||
|
||||
void SetGroupLeaderName(uint32 gid, const char* name);
|
||||
char* GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* maintank = nullptr, char* assist = nullptr, char* puller = nullptr, char *marknpc = nullptr,
|
||||
GroupLeadershipAA_Struct* GLAA = nullptr);
|
||||
void ClearGroupLeader(uint32 gid = 0);
|
||||
|
||||
|
||||
/*
|
||||
* Raids
|
||||
*/
|
||||
void ClearRaid(uint32 rid = 0);
|
||||
void ClearRaidDetails(uint32 rid = 0);
|
||||
uint32 GetRaidID(const char* name);
|
||||
const char *GetRaidLeaderName(uint32 rid);
|
||||
|
||||
bool CheckDatabaseConversions();
|
||||
|
||||
/*
|
||||
* Database Variables
|
||||
*/
|
||||
bool GetVariable(const char* varname, char* varvalue, uint16 varvalue_len);
|
||||
bool SetVariable(const char* varname, const char* varvalue);
|
||||
bool LoadVariables();
|
||||
uint32 LoadVariables_MQ(char** query);
|
||||
bool LoadVariables_result(MySQLRequestResult results);
|
||||
|
||||
/*
|
||||
* General Queries
|
||||
*/
|
||||
bool LoadZoneNames();
|
||||
bool GetZoneLongName(const char* short_name, char** long_name, char* file_name = 0, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, uint32* graveyard_id = 0, uint32* maxclients = 0);
|
||||
bool GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zoneid = 0, float* graveyard_x = 0, float* graveyard_y = 0, float* graveyard_z = 0, float* graveyard_heading = 0);
|
||||
uint32 GetZoneGraveyardID(uint32 zone_id, uint32 version);
|
||||
uint32 GetZoneID(const char* zonename);
|
||||
uint8 GetPEQZone(uint32 zoneID, uint32 version);
|
||||
const char* GetZoneName(uint32 zoneID, bool ErrorUnknown = false);
|
||||
uint8 GetServerType();
|
||||
bool GetSafePoints(const char* short_name, uint32 version, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, int16* minstatus = 0, uint8* minlevel = 0, char *flag_needed = nullptr);
|
||||
bool GetSafePoints(uint32 zoneID, uint32 version, float* safe_x = 0, float* safe_y = 0, float* safe_z = 0, int16* minstatus = 0, uint8* minlevel = 0, char *flag_needed = nullptr) { return GetSafePoints(GetZoneName(zoneID), version, safe_x, safe_y, safe_z, minstatus, minlevel, flag_needed); }
|
||||
uint8 GetSkillCap(uint8 skillid, uint8 in_race, uint8 in_class, uint16 in_level);
|
||||
uint8 GetRaceSkill(uint8 skillid, uint8 in_race);
|
||||
bool LoadPTimers(uint32 charid, PTimerList &into);
|
||||
void ClearPTimers(uint32 charid);
|
||||
void ClearMerchantTemp();
|
||||
void SetLFP(uint32 CharID, bool LFP);
|
||||
void SetLFG(uint32 CharID, bool LFG);
|
||||
void SetFirstLogon(uint32 CharID, uint8 firstlogon);
|
||||
void SetLoginFlags(uint32 CharID, bool LFP, bool LFG, uint8 firstlogon);
|
||||
void AddReport(std::string who, std::string against, std::string lines);
|
||||
|
||||
private:
|
||||
void DBInitVars();
|
||||
|
||||
std::map<uint32,std::string> zonename_array;
|
||||
|
||||
Mutex Mvarcache;
|
||||
uint32 varcache_max;
|
||||
VarCache_Struct** varcache_array;
|
||||
uint32 varcache_lastupdate;
|
||||
|
||||
|
||||
/*
|
||||
* Groups, utility methods.
|
||||
*/
|
||||
void ClearAllGroupLeaders();
|
||||
void ClearAllGroups();
|
||||
|
||||
|
||||
/*
|
||||
* Raid, utility methods.
|
||||
*/
|
||||
void ClearAllRaids();
|
||||
void ClearAllRaidDetails();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,299 @@
|
||||
#include "../common/debug.h"
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <errmsg.h>
|
||||
#include <mysqld_error.h>
|
||||
#include <limits.h>
|
||||
#include "dbcore.h"
|
||||
#include <string.h>
|
||||
#include "../common/misc_functions.h"
|
||||
#include <cstdlib>
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#define snprintf _snprintf
|
||||
#define strncasecmp _strnicmp
|
||||
#define strcasecmp _stricmp
|
||||
#include <process.h>
|
||||
#else
|
||||
#include "unix.h"
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef _EQDEBUG
|
||||
#define DEBUG_MYSQL_QUERIES 0
|
||||
#else
|
||||
#define DEBUG_MYSQL_QUERIES 0
|
||||
#endif
|
||||
|
||||
DBcore::DBcore() {
|
||||
mysql_init(&mysql);
|
||||
pHost = 0;
|
||||
pUser = 0;
|
||||
pPassword = 0;
|
||||
pDatabase = 0;
|
||||
pCompress = false;
|
||||
pSSL = false;
|
||||
pStatus = Closed;
|
||||
}
|
||||
|
||||
DBcore::~DBcore() {
|
||||
mysql_close(&mysql);
|
||||
safe_delete_array(pHost);
|
||||
safe_delete_array(pUser);
|
||||
safe_delete_array(pPassword);
|
||||
safe_delete_array(pDatabase);
|
||||
}
|
||||
|
||||
// Sends the MySQL server a keepalive
|
||||
void DBcore::ping() {
|
||||
if (!MDatabase.trylock()) {
|
||||
// well, if's it's locked, someone's using it. If someone's using it, it doesnt need a keepalive
|
||||
return;
|
||||
}
|
||||
mysql_ping(&mysql);
|
||||
MDatabase.unlock();
|
||||
}
|
||||
|
||||
MySQLRequestResult DBcore::QueryDatabase(std::string query, bool retryOnFailureOnce)
|
||||
{
|
||||
return QueryDatabase(query.c_str(), query.length(), retryOnFailureOnce);
|
||||
}
|
||||
|
||||
MySQLRequestResult DBcore::QueryDatabase(const char* query, uint32 querylen, bool retryOnFailureOnce)
|
||||
{
|
||||
LockMutex lock(&MDatabase);
|
||||
|
||||
// Reconnect if we are not connected before hand.
|
||||
if (pStatus != Connected)
|
||||
Open();
|
||||
|
||||
// request query. != 0 indicates some kind of error.
|
||||
if (mysql_real_query(&mysql, query, querylen) != 0)
|
||||
{
|
||||
unsigned int errorNumber = mysql_errno(&mysql);
|
||||
|
||||
if (errorNumber == CR_SERVER_GONE_ERROR)
|
||||
pStatus = Error;
|
||||
|
||||
// error appears to be a disconnect error, may need to try again.
|
||||
if (errorNumber == CR_SERVER_LOST || errorNumber == CR_SERVER_GONE_ERROR)
|
||||
{
|
||||
|
||||
if (retryOnFailureOnce)
|
||||
{
|
||||
std::cout << "Database Error: Lost connection, attempting to recover...." << std::endl;
|
||||
MySQLRequestResult requestResult = QueryDatabase(query, querylen, false);
|
||||
|
||||
if (requestResult.Success())
|
||||
{
|
||||
std::cout << "Reconnection to database successful." << std::endl;
|
||||
return requestResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pStatus = Error;
|
||||
|
||||
char *errorBuffer = new char[MYSQL_ERRMSG_SIZE];
|
||||
|
||||
snprintf(errorBuffer, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
|
||||
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||
|
||||
return MySQLRequestResult(nullptr, 0, 0, 0, 0, (uint32)mysql_errno(&mysql), errorBuffer);
|
||||
}
|
||||
|
||||
char *errorBuffer = new char[MYSQL_ERRMSG_SIZE];
|
||||
snprintf(errorBuffer, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
|
||||
#ifdef _EQDEBUG
|
||||
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||
#endif
|
||||
return MySQLRequestResult(nullptr, 0, 0, 0, 0, mysql_errno(&mysql),errorBuffer);
|
||||
|
||||
}
|
||||
|
||||
// successful query. get results.
|
||||
MYSQL_RES* res = mysql_store_result(&mysql);
|
||||
uint32 rowCount = 0;
|
||||
|
||||
if (res != nullptr)
|
||||
rowCount = (uint32)mysql_num_rows(res);
|
||||
|
||||
MySQLRequestResult requestResult(res, (uint32)mysql_affected_rows(&mysql), rowCount, (uint32)mysql_field_count(&mysql), (uint32)mysql_insert_id(&mysql));
|
||||
|
||||
|
||||
#if DEBUG_MYSQL_QUERIES >= 1
|
||||
if (requestResult.Success())
|
||||
{
|
||||
std::cout << "query successful";
|
||||
if (requestResult.Result())
|
||||
std::cout << ", " << (int) mysql_num_rows(requestResult.Result()) << " rows returned";
|
||||
|
||||
std::cout << ", " << requestResult.RowCount() << " rows affected";
|
||||
std::cout<< std::endl;
|
||||
}
|
||||
else {
|
||||
std::cout << "QUERY: query FAILED" << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
return requestResult;
|
||||
}
|
||||
|
||||
bool DBcore::RunQuery(const char* query, uint32 querylen, char* errbuf, MYSQL_RES** result, uint32* affected_rows, uint32* last_insert_id, uint32* errnum, bool retry) {
|
||||
if (errnum)
|
||||
*errnum = 0;
|
||||
if (errbuf)
|
||||
errbuf[0] = 0;
|
||||
bool ret = false;
|
||||
LockMutex lock(&MDatabase);
|
||||
if (pStatus != Connected)
|
||||
Open();
|
||||
|
||||
if (mysql_real_query(&mysql, query, querylen)) {
|
||||
if (mysql_errno(&mysql) == CR_SERVER_GONE_ERROR)
|
||||
pStatus = Error;
|
||||
if (mysql_errno(&mysql) == CR_SERVER_LOST || mysql_errno(&mysql) == CR_SERVER_GONE_ERROR) {
|
||||
if (retry) {
|
||||
std::cout << "Database Error: Lost connection, attempting to recover...." << std::endl;
|
||||
ret = RunQuery(query, querylen, errbuf, result, affected_rows, last_insert_id, errnum, false);
|
||||
if (ret)
|
||||
std::cout << "Reconnection to database successful." << std::endl;
|
||||
}
|
||||
else {
|
||||
pStatus = Error;
|
||||
if (errnum)
|
||||
*errnum = mysql_errno(&mysql);
|
||||
if (errbuf)
|
||||
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (errnum)
|
||||
*errnum = mysql_errno(&mysql);
|
||||
if (errbuf)
|
||||
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
#ifdef _EQDEBUG
|
||||
std::cout << "DB Query Error #" << mysql_errno(&mysql) << ": " << mysql_error(&mysql) << std::endl;
|
||||
#endif
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (result && mysql_field_count(&mysql)) {
|
||||
*result = mysql_store_result(&mysql);
|
||||
#ifdef _EQDEBUG
|
||||
DBMemLeak::Alloc(*result, query);
|
||||
#endif
|
||||
}
|
||||
else if (result)
|
||||
*result = 0;
|
||||
if (affected_rows)
|
||||
*affected_rows = mysql_affected_rows(&mysql);
|
||||
if (last_insert_id)
|
||||
*last_insert_id = (uint32)mysql_insert_id(&mysql);
|
||||
if (result) {
|
||||
if (*result) {
|
||||
ret = true;
|
||||
}
|
||||
else {
|
||||
#ifdef _EQDEBUG
|
||||
std::cout << "DB Query Error: No Result" << std::endl;
|
||||
#endif
|
||||
if (errnum)
|
||||
*errnum = UINT_MAX;
|
||||
if (errbuf)
|
||||
strcpy(errbuf, "DBcore::RunQuery: No Result");
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
#if DEBUG_MYSQL_QUERIES >= 1
|
||||
if (ret) {
|
||||
std::cout << "query successful";
|
||||
if (result && (*result))
|
||||
std::cout << ", " << (int) mysql_num_rows(*result) << " rows returned";
|
||||
if (affected_rows)
|
||||
std::cout << ", " << (*affected_rows) << " rows affected";
|
||||
std::cout<< std::endl;
|
||||
}
|
||||
else {
|
||||
std::cout << "QUERY: query FAILED" << std::endl;
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32 DBcore::DoEscapeString(char* tobuf, const char* frombuf, uint32 fromlen) {
|
||||
// No good reason to lock the DB, we only need it in the first place to check char encoding.
|
||||
// LockMutex lock(&MDatabase);
|
||||
return mysql_real_escape_string(&mysql, tobuf, frombuf, fromlen);
|
||||
}
|
||||
|
||||
bool DBcore::Open(const char* iHost, const char* iUser, const char* iPassword, const char* iDatabase,uint32 iPort, uint32* errnum, char* errbuf, bool iCompress, bool iSSL) {
|
||||
LockMutex lock(&MDatabase);
|
||||
safe_delete(pHost);
|
||||
safe_delete(pUser);
|
||||
safe_delete(pPassword);
|
||||
safe_delete(pDatabase);
|
||||
pHost = strcpy(new char[strlen(iHost) + 1], iHost);
|
||||
pUser = strcpy(new char[strlen(iUser) + 1], iUser);
|
||||
pPassword = strcpy(new char[strlen(iPassword) + 1], iPassword);
|
||||
pDatabase = strcpy(new char[strlen(iDatabase) + 1], iDatabase);
|
||||
pCompress = iCompress;
|
||||
pPort = iPort;
|
||||
pSSL = iSSL;
|
||||
return Open(errnum, errbuf);
|
||||
}
|
||||
|
||||
bool DBcore::Open(uint32* errnum, char* errbuf) {
|
||||
if (errbuf)
|
||||
errbuf[0] = 0;
|
||||
LockMutex lock(&MDatabase);
|
||||
if (GetStatus() == Connected)
|
||||
return true;
|
||||
if (GetStatus() == Error) {
|
||||
mysql_close(&mysql);
|
||||
mysql_init(&mysql); // Initialize structure again
|
||||
}
|
||||
if (!pHost)
|
||||
return false;
|
||||
/*
|
||||
Added CLIENT_FOUND_ROWS flag to the connect
|
||||
otherwise DB update calls would say 0 rows affected when the value already equalled
|
||||
what the function was tring to set it to, therefore the function would think it failed
|
||||
*/
|
||||
uint32 flags = CLIENT_FOUND_ROWS;
|
||||
if (pCompress)
|
||||
flags |= CLIENT_COMPRESS;
|
||||
if (pSSL)
|
||||
flags |= CLIENT_SSL;
|
||||
if (mysql_real_connect(&mysql, pHost, pUser, pPassword, pDatabase, pPort, 0, flags)) {
|
||||
pStatus = Connected;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (errnum)
|
||||
*errnum = mysql_errno(&mysql);
|
||||
if (errbuf)
|
||||
snprintf(errbuf, MYSQL_ERRMSG_SIZE, "#%i: %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
pStatus = Error;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
#ifndef DBCORE_H
|
||||
#define DBCORE_H
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <winsock.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <mysql.h>
|
||||
#include <string.h>
|
||||
#include "../common/types.h"
|
||||
#include "../common/mutex.h"
|
||||
#include "../common/linked_list.h"
|
||||
#include "../common/queue.h"
|
||||
#include "../common/timer.h"
|
||||
#include "../common/condition.h"
|
||||
#include "../common/mysql_request_result.h"
|
||||
|
||||
class DBcore {
|
||||
public:
|
||||
enum eStatus { Closed, Connected, Error };
|
||||
|
||||
DBcore();
|
||||
~DBcore();
|
||||
eStatus GetStatus() { return pStatus; }
|
||||
bool RunQuery(const char* query, uint32 querylen, char* errbuf = 0, MYSQL_RES** result = 0, uint32* affected_rows = 0, uint32* last_insert_id = 0, uint32* errnum = 0, bool retry = true);
|
||||
MySQLRequestResult QueryDatabase(const char* query, uint32 querylen, bool retryOnFailureOnce = true);
|
||||
MySQLRequestResult QueryDatabase(std::string query, bool retryOnFailureOnce = true);
|
||||
uint32 DoEscapeString(char* tobuf, const char* frombuf, uint32 fromlen);
|
||||
void ping();
|
||||
MYSQL* getMySQL(){ return &mysql; }
|
||||
|
||||
protected:
|
||||
bool Open(const char* iHost, const char* iUser, const char* iPassword, const char* iDatabase, uint32 iPort, uint32* errnum = 0, char* errbuf = 0, bool iCompress = false, bool iSSL = false);
|
||||
private:
|
||||
bool Open(uint32* errnum = 0, char* errbuf = 0);
|
||||
|
||||
MYSQL mysql;
|
||||
Mutex MDatabase;
|
||||
eStatus pStatus;
|
||||
|
||||
char* pHost;
|
||||
char* pUser;
|
||||
char* pPassword;
|
||||
char* pDatabase;
|
||||
bool pCompress;
|
||||
uint32 pPort;
|
||||
bool pSSL;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
// Doors
|
||||
#ifdef SHAREMEM
|
||||
int32 Database::GetDoorsCount(uint32* oMaxID) {
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
query = new char[256];
|
||||
strcpy(query, "SELECT MAX(id), count(*) FROM doors");
|
||||
if (RunQuery(query, strlen(query), errbuf, &result)) {
|
||||
safe_delete(query);
|
||||
row = mysql_fetch_row(result);
|
||||
if (row && row[1]) {
|
||||
int32 ret = atoi(row[1]);
|
||||
if (oMaxID) {
|
||||
if (row[0])
|
||||
*oMaxID = atoi(row[0]);
|
||||
else
|
||||
*oMaxID = 0;
|
||||
}
|
||||
mysql_free_result(result);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
else {
|
||||
cerr << "Error in GetDoorsCount query '" << query << "' " << errbuf << endl;
|
||||
delete[] query;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
extern "C" bool extDBLoadDoors(uint32 iDoorCount, uint32 iMaxDoorID) { return database.DBLoadDoors(iDoorCount, iMaxDoorID); }
|
||||
const Door* Database::GetDoor(uint8 door_id, const char* zone_name) {
|
||||
for(uint32 i=0; i<max_door_type; i++) {
|
||||
const Door* door = GetDoorDBID(i);
|
||||
if(door && door->door_id == door_id && strcasecmp(door->zone_name, zone_name) == 0)
|
||||
return door;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const Door* Database::GetDoorDBID(uint32 db_id) {
|
||||
return EMuShareMemDLL.Doors.GetDoor(db_id);
|
||||
}
|
||||
|
||||
bool Database::LoadDoors() {
|
||||
if (!EMuShareMemDLL.Load())
|
||||
return false;
|
||||
int32 tmp_max_door_type = -1;
|
||||
uint32 tmp = 0;
|
||||
tmp_max_door_type = GetDoorsCount(&tmp);
|
||||
if (tmp_max_door_type < 0) {
|
||||
cout << "Error: Database::LoadDoors-ShareMem: GetDoorsCount() returned < 0" << endl;
|
||||
return false;
|
||||
}
|
||||
max_door_type = tmp_max_door_type;
|
||||
bool ret = EMuShareMemDLL.Doors.DLLLoadDoors(&extDBLoadDoors, sizeof(Door), max_door_type, tmp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Database::DBLoadDoors(uint32 iDoorCount, uint32 iMaxDoorID) {
|
||||
cout << "Loading Doors from database..." << endl;
|
||||
char errbuf[MYSQL_ERRMSG_SIZE];
|
||||
char *query = 0;
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
query = new char[256];
|
||||
strcpy(query, "SELECT MAX(id), Count(*) FROM doors");
|
||||
if (RunQuery(query, strlen(query), errbuf, &result))
|
||||
{
|
||||
safe_delete(query);
|
||||
row = mysql_fetch_row(result);
|
||||
if (row && row[0]) {
|
||||
if (atoi(row[0]) > iMaxDoorID) {
|
||||
cout << "Error: Insufficient shared memory to load doors." << endl;
|
||||
cout << "Max(id): " << atoi(row[0]) << ", iMaxDoorID: " << iMaxDoorID << endl;
|
||||
cout << "Fix this by increasing the MMF_MAX_Door_ID define statement" << endl;
|
||||
return false;
|
||||
}
|
||||
if (atoi(row[1]) != iDoorCount) {
|
||||
cout << "Error: Insufficient shared memory to load doors." << endl;
|
||||
cout << "Count(*): " << atoi(row[1]) << ", iDoorCount: " << iDoorCount << endl;
|
||||
return false;
|
||||
}
|
||||
max_door_type = atoi(row[0]);
|
||||
mysql_free_result(result);
|
||||
Door tmpDoor;
|
||||
MakeAnyLenString(&query, "SELECT id,doorid,zone,name,pos_x,pos_y,pos_z,heading,opentype,guild,lockpick,keyitem,triggerdoor,triggertype from doors");//WHERE zone='%s'", zone_name
|
||||
if (RunQuery(query, strlen(query), errbuf, &result))
|
||||
{
|
||||
safe_delete(query);
|
||||
while((row = mysql_fetch_row(result))) {
|
||||
memset(&tmpDoor, 0, sizeof(Door));
|
||||
tmpDoor.db_id = atoi(row[0]);
|
||||
tmpDoor.door_id = atoi(row[1]);
|
||||
strn0cpy(tmpDoor.zone_name,row[2],32);
|
||||
strn0cpy(tmpDoor.door_name,row[3],32);
|
||||
tmpDoor.pos_x = (float)atof(row[4]);
|
||||
tmpDoor.pos_y = (float)atof(row[5]);
|
||||
tmpDoor.pos_z = (float)atof(row[6]);
|
||||
tmpDoor.heading = atoi(row[7]);
|
||||
tmpDoor.opentype = atoi(row[8]);
|
||||
tmpDoor.guild_id = atoi(row[9]);
|
||||
tmpDoor.lockpick = atoi(row[10]);
|
||||
tmpDoor.keyitem = atoi(row[11]);
|
||||
tmpDoor.trigger_door = atoi(row[12]);
|
||||
tmpDoor.trigger_type = atoi(row[13]);
|
||||
EMuShareMemDLL.Doors.cbAddDoor(tmpDoor.db_id, &tmpDoor);
|
||||
Sleep(0);
|
||||
}
|
||||
mysql_free_result(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
cerr << "Error in DBLoadDoors query '" << query << "' " << errbuf << endl;
|
||||
delete[] query;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,441 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <cstdarg>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <process.h>
|
||||
|
||||
#define snprintf _snprintf
|
||||
#define vsnprintf _vsnprintf
|
||||
#define strncasecmp _strnicmp
|
||||
#define strcasecmp _stricmp
|
||||
|
||||
#else
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#endif
|
||||
|
||||
#include "debug.h"
|
||||
#include "string_util.h"
|
||||
#include "misc_functions.h"
|
||||
#include "platform.h"
|
||||
|
||||
#ifndef va_copy
|
||||
#define va_copy(d,s) ((d) = (s))
|
||||
#endif
|
||||
|
||||
static volatile bool logFileValid = false;
|
||||
static EQEMuLog realLogFile;
|
||||
EQEMuLog *LogFile = &realLogFile;
|
||||
|
||||
static const char* FileNames[EQEMuLog::MaxLogID] = { "logs/eqemu", "logs/eqemu", "logs/eqemu_error", "logs/eqemu_debug", "logs/eqemu_quest", "logs/eqemu_commands", "logs/crash" };
|
||||
static const char* LogNames[EQEMuLog::MaxLogID] = { "Status", "Normal", "Error", "Debug", "Quest", "Command", "Crash" };
|
||||
|
||||
EQEMuLog::EQEMuLog() {
|
||||
for (int i=0; i<MaxLogID; i++) {
|
||||
fp[i] = 0;
|
||||
logCallbackFmt[i] = nullptr;
|
||||
logCallbackBuf[i] = nullptr;
|
||||
logCallbackPva[i] = nullptr;
|
||||
}
|
||||
|
||||
pLogStatus[Status] = LOG_LEVEL_STATUS;
|
||||
pLogStatus[Normal] = LOG_LEVEL_NORMAL;
|
||||
pLogStatus[Error] = LOG_LEVEL_ERROR;
|
||||
pLogStatus[Debug] = LOG_LEVEL_DEBUG;
|
||||
pLogStatus[Quest] = LOG_LEVEL_QUEST;
|
||||
pLogStatus[Commands] = LOG_LEVEL_COMMANDS;
|
||||
pLogStatus[Crash] = LOG_LEVEL_CRASH;
|
||||
logFileValid = true;
|
||||
}
|
||||
|
||||
EQEMuLog::~EQEMuLog() {
|
||||
logFileValid = false;
|
||||
for (int i=0; i<MaxLogID; i++) {
|
||||
LockMutex lock(&MLog[i]); //to prevent termination race
|
||||
if (fp[i])
|
||||
fclose(fp[i]);
|
||||
}
|
||||
}
|
||||
|
||||
bool EQEMuLog::open(LogIDs id) {
|
||||
if (!logFileValid) {
|
||||
return false;
|
||||
}
|
||||
if (id >= MaxLogID) {
|
||||
return false;
|
||||
}
|
||||
LockMutex lock(&MOpen);
|
||||
if (pLogStatus[id] & 4) {
|
||||
return false;
|
||||
}
|
||||
if (fp[id]) {
|
||||
//cerr<<"Warning: LogFile already open"<<endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
char exename[200] = "";
|
||||
const EQEmuExePlatform &platform = GetExecutablePlatform();
|
||||
if(platform == ExePlatformWorld) {
|
||||
snprintf(exename, sizeof(exename), "_world");
|
||||
} else if(platform == ExePlatformZone) {
|
||||
snprintf(exename, sizeof(exename), "_zone");
|
||||
} else if(platform == ExePlatformLaunch) {
|
||||
snprintf(exename, sizeof(exename), "_launch");
|
||||
} else if(platform == ExePlatformUCS) {
|
||||
snprintf(exename, sizeof(exename), "_ucs");
|
||||
} else if(platform == ExePlatformQueryServ) {
|
||||
snprintf(exename, sizeof(exename), "_queryserv");
|
||||
} else if(platform == ExePlatformSharedMemory) {
|
||||
snprintf(exename, sizeof(exename), "_shared_memory");
|
||||
} else if(platform == ExePlatformClientImport) {
|
||||
snprintf(exename, sizeof(exename), "_import");
|
||||
} else if(platform == ExePlatformClientExport) {
|
||||
snprintf(exename, sizeof(exename), "_export");
|
||||
}
|
||||
|
||||
char filename[200];
|
||||
#ifndef NO_PIDLOG
|
||||
snprintf(filename, sizeof(filename), "%s%s_%04i.log", FileNames[id], exename, getpid());
|
||||
#else
|
||||
snprintf(filename, sizeof(filename), "%s%s.log", FileNames[id], exename);
|
||||
#endif
|
||||
fp[id] = fopen(filename, "a");
|
||||
if (!fp[id]) {
|
||||
std::cerr << "Failed to open log file: " << filename << std::endl;
|
||||
pLogStatus[id] |= 4; // set file state to error
|
||||
return false;
|
||||
}
|
||||
fputs("---------------------------------------------\n",fp[id]);
|
||||
write(id, "Starting Log: %s", filename);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEMuLog::write(LogIDs id, const char *fmt, ...) {
|
||||
if (!logFileValid) {
|
||||
return false;
|
||||
}
|
||||
if (id >= MaxLogID) {
|
||||
return false;
|
||||
}
|
||||
bool dofile = false;
|
||||
if (pLogStatus[id] & 1) {
|
||||
dofile = open(id);
|
||||
}
|
||||
if (!(dofile || pLogStatus[id] & 2))
|
||||
return false;
|
||||
LockMutex lock(&MLog[id]);
|
||||
if (!logFileValid)
|
||||
return false; //check again for threading race reasons (to avoid two mutexes)
|
||||
|
||||
time_t aclock;
|
||||
struct tm *newtime;
|
||||
|
||||
time( &aclock ); /* Get time in seconds */
|
||||
newtime = localtime( &aclock ); /* Convert time to struct */
|
||||
|
||||
if (dofile)
|
||||
#ifndef NO_PIDLOG
|
||||
fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] ", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
|
||||
#else
|
||||
fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] ", getpid(), newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
|
||||
#endif
|
||||
|
||||
va_list argptr, tmpargptr;
|
||||
va_start(argptr, fmt);
|
||||
if (dofile) {
|
||||
va_copy(tmpargptr, argptr);
|
||||
vfprintf( fp[id], fmt, tmpargptr );
|
||||
}
|
||||
if(logCallbackFmt[id]) {
|
||||
msgCallbackFmt p = logCallbackFmt[id];
|
||||
va_copy(tmpargptr, argptr);
|
||||
p(id, fmt, tmpargptr );
|
||||
}
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 8) {
|
||||
fprintf(stderr, "[%s] ", LogNames[id]);
|
||||
vfprintf( stderr, fmt, argptr );
|
||||
}
|
||||
else {
|
||||
fprintf(stdout, "[%s] ", LogNames[id]);
|
||||
vfprintf( stdout, fmt, argptr );
|
||||
}
|
||||
}
|
||||
va_end(argptr);
|
||||
if (dofile)
|
||||
fprintf(fp[id], "\n");
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 8) {
|
||||
fprintf(stderr, "\n");
|
||||
fflush(stderr);
|
||||
} else {
|
||||
fprintf(stdout, "\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
}
|
||||
if(dofile)
|
||||
fflush(fp[id]);
|
||||
return true;
|
||||
}
|
||||
|
||||
//write with Prefix and a VA_list
|
||||
bool EQEMuLog::writePVA(LogIDs id, const char *prefix, const char *fmt, va_list argptr) {
|
||||
if (!logFileValid) {
|
||||
return false;
|
||||
}
|
||||
if (id >= MaxLogID) {
|
||||
return false;
|
||||
}
|
||||
bool dofile = false;
|
||||
if (pLogStatus[id] & 1) {
|
||||
dofile = open(id);
|
||||
}
|
||||
if (!(dofile || pLogStatus[id] & 2)) {
|
||||
return false;
|
||||
}
|
||||
LockMutex lock(&MLog[id]);
|
||||
if (!logFileValid)
|
||||
return false; //check again for threading race reasons (to avoid two mutexes)
|
||||
|
||||
time_t aclock;
|
||||
struct tm *newtime;
|
||||
|
||||
time( &aclock ); /* Get time in seconds */
|
||||
newtime = localtime( &aclock ); /* Convert time to struct */
|
||||
|
||||
va_list tmpargptr;
|
||||
|
||||
if (dofile) {
|
||||
#ifndef NO_PIDLOG
|
||||
fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] %s", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec, prefix);
|
||||
#else
|
||||
fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] %s", getpid(), newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec, prefix);
|
||||
#endif
|
||||
va_copy(tmpargptr, argptr);
|
||||
vfprintf( fp[id], fmt, tmpargptr );
|
||||
}
|
||||
if(logCallbackPva[id]) {
|
||||
msgCallbackPva p = logCallbackPva[id];
|
||||
va_copy(tmpargptr, argptr);
|
||||
p(id, prefix, fmt, tmpargptr );
|
||||
}
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 8) {
|
||||
fprintf(stderr, "[%s] %s", LogNames[id], prefix);
|
||||
vfprintf( stderr, fmt, argptr );
|
||||
}
|
||||
else {
|
||||
fprintf(stdout, "[%s] %s", LogNames[id], prefix);
|
||||
vfprintf( stdout, fmt, argptr );
|
||||
}
|
||||
}
|
||||
va_end(argptr);
|
||||
if (dofile)
|
||||
fprintf(fp[id], "\n");
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 8)
|
||||
fprintf(stderr, "\n");
|
||||
else
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
if(dofile)
|
||||
fflush(fp[id]);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEMuLog::writebuf(LogIDs id, const char *buf, uint8 size, uint32 count) {
|
||||
if (!logFileValid) {
|
||||
return false;
|
||||
}
|
||||
if (id >= MaxLogID) {
|
||||
return false;
|
||||
}
|
||||
bool dofile = false;
|
||||
if (pLogStatus[id] & 1) {
|
||||
dofile = open(id);
|
||||
}
|
||||
if (!(dofile || pLogStatus[id] & 2))
|
||||
return false;
|
||||
LockMutex lock(&MLog[id]);
|
||||
if (!logFileValid)
|
||||
return false; //check again for threading race reasons (to avoid two mutexes)
|
||||
|
||||
time_t aclock;
|
||||
struct tm *newtime;
|
||||
|
||||
time( &aclock ); /* Get time in seconds */
|
||||
newtime = localtime( &aclock ); /* Convert time to struct */
|
||||
|
||||
if (dofile)
|
||||
#ifndef NO_PIDLOG
|
||||
fprintf(fp[id], "[%02d.%02d. - %02d:%02d:%02d] ", newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
|
||||
#else
|
||||
fprintf(fp[id], "%04i [%02d.%02d. - %02d:%02d:%02d] ", getpid(), newtime->tm_mon+1, newtime->tm_mday, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
|
||||
#endif
|
||||
|
||||
if (dofile) {
|
||||
fwrite(buf, size, count, fp[id]);
|
||||
fprintf(fp[id], "\n");
|
||||
}
|
||||
if(logCallbackBuf[id]) {
|
||||
msgCallbackBuf p = logCallbackBuf[id];
|
||||
p(id, buf, size, count);
|
||||
}
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 8) {
|
||||
fprintf(stderr, "[%s] ", LogNames[id]);
|
||||
fwrite(buf, size, count, stderr);
|
||||
fprintf(stderr, "\n");
|
||||
} else {
|
||||
fprintf(stdout, "[%s] ", LogNames[id]);
|
||||
fwrite(buf, size, count, stdout);
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
}
|
||||
if(dofile)
|
||||
fflush(fp[id]);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EQEMuLog::writeNTS(LogIDs id, bool dofile, const char *fmt, ...) {
|
||||
va_list argptr, tmpargptr;
|
||||
va_start(argptr, fmt);
|
||||
if (dofile) {
|
||||
va_copy(tmpargptr, argptr);
|
||||
vfprintf( fp[id], fmt, tmpargptr );
|
||||
}
|
||||
if (pLogStatus[id] & 2) {
|
||||
if (pLogStatus[id] & 8)
|
||||
vfprintf( stderr, fmt, argptr );
|
||||
else
|
||||
vfprintf( stdout, fmt, argptr );
|
||||
}
|
||||
va_end(argptr);
|
||||
return true;
|
||||
};
|
||||
|
||||
bool EQEMuLog::Dump(LogIDs id, uint8* data, uint32 size, uint32 cols, uint32 skip) {
|
||||
if (!logFileValid) {
|
||||
#if EQDEBUG >= 10
|
||||
std::cerr << "Error: Dump() from null pointer" << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
if (size == 0)
|
||||
return true;
|
||||
if (!LogFile)
|
||||
return false;
|
||||
if (id >= MaxLogID)
|
||||
return false;
|
||||
bool dofile = false;
|
||||
if (pLogStatus[id] & 1) {
|
||||
dofile = open(id);
|
||||
}
|
||||
if (!(dofile || pLogStatus[id] & 2))
|
||||
return false;
|
||||
LockMutex lock(&MLog[id]);
|
||||
if (!logFileValid)
|
||||
return false; //check again for threading race reasons (to avoid two mutexes)
|
||||
|
||||
write(id, "Dumping Packet: %i", size);
|
||||
// Output as HEX
|
||||
|
||||
int beginningOfLineOffset = 0;
|
||||
uint32 indexInData;
|
||||
std::string asciiOutput;
|
||||
|
||||
for(indexInData=skip; indexInData<size; indexInData++) {
|
||||
if ((indexInData-skip)%cols==0) {
|
||||
if (indexInData != skip)
|
||||
writeNTS(id, dofile, " | %s\n", asciiOutput.c_str());
|
||||
writeNTS(id, dofile, "%4i: ", indexInData-skip);
|
||||
asciiOutput.clear();
|
||||
beginningOfLineOffset = 0;
|
||||
}
|
||||
else if ((indexInData-skip)%(cols/2) == 0) {
|
||||
writeNTS(id, dofile, "- ");
|
||||
}
|
||||
writeNTS(id, dofile, "%02X ", (unsigned char)data[indexInData]);
|
||||
|
||||
if (data[indexInData] >= 32 && data[indexInData] < 127)
|
||||
{
|
||||
// According to http://msdn.microsoft.com/en-us/library/vstudio/ee404875(v=vs.100).aspx
|
||||
// Visual Studio 2010 doesn't have std::to_string(int) but it does have the long long
|
||||
// version.
|
||||
asciiOutput.append(std::to_string((long long)data[indexInData]));
|
||||
}
|
||||
else
|
||||
{
|
||||
asciiOutput.append(".");
|
||||
}
|
||||
}
|
||||
uint32 k = ((indexInData-skip)-1)%cols;
|
||||
if (k < 8)
|
||||
writeNTS(id, dofile, " ");
|
||||
for (uint32 h = k+1; h < cols; h++) {
|
||||
writeNTS(id, dofile, " ");
|
||||
}
|
||||
writeNTS(id, dofile, " | %s\n", asciiOutput.c_str());
|
||||
if (dofile)
|
||||
fflush(fp[id]);
|
||||
return true;
|
||||
}
|
||||
|
||||
void EQEMuLog::SetCallback(LogIDs id, msgCallbackFmt proc) {
|
||||
if (!logFileValid)
|
||||
return;
|
||||
if (id >= MaxLogID) {
|
||||
return;
|
||||
}
|
||||
logCallbackFmt[id] = proc;
|
||||
}
|
||||
|
||||
void EQEMuLog::SetCallback(LogIDs id, msgCallbackBuf proc) {
|
||||
if (!logFileValid)
|
||||
return;
|
||||
if (id >= MaxLogID) {
|
||||
return;
|
||||
}
|
||||
logCallbackBuf[id] = proc;
|
||||
}
|
||||
|
||||
void EQEMuLog::SetCallback(LogIDs id, msgCallbackPva proc) {
|
||||
if (!logFileValid)
|
||||
return;
|
||||
if (id >= MaxLogID) {
|
||||
return;
|
||||
}
|
||||
logCallbackPva[id] = proc;
|
||||
}
|
||||
|
||||
void EQEMuLog::SetAllCallbacks(msgCallbackFmt proc) {
|
||||
if (!logFileValid)
|
||||
return;
|
||||
int r;
|
||||
for(r = Status; r < MaxLogID; r++) {
|
||||
SetCallback((LogIDs)r, proc);
|
||||
}
|
||||
}
|
||||
|
||||
void EQEMuLog::SetAllCallbacks(msgCallbackBuf proc) {
|
||||
if (!logFileValid)
|
||||
return;
|
||||
int r;
|
||||
for(r = Status; r < MaxLogID; r++) {
|
||||
SetCallback((LogIDs)r, proc);
|
||||
}
|
||||
}
|
||||
|
||||
void EQEMuLog::SetAllCallbacks(msgCallbackPva proc) {
|
||||
if (!logFileValid)
|
||||
return;
|
||||
int r;
|
||||
for(r = Status; r < MaxLogID; r++) {
|
||||
SetCallback((LogIDs)r, proc);
|
||||
}
|
||||
}
|
||||
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
// Debug Levels
|
||||
#ifndef EQDEBUG
|
||||
#define EQDEBUG 1
|
||||
#else
|
||||
////// File/Console options
|
||||
// 0 <= Quiet mode Errors to file Status and Normal ignored
|
||||
// 1 >= Status and Normal to console, Errors to file
|
||||
// 2 >= Status, Normal, and Error to console and logfile
|
||||
// 3 >= Lite debug
|
||||
// 4 >= Medium debug
|
||||
// 5 >= Debug release (Anything higher is not recommended for regular use)
|
||||
// 6 == (Reserved for special builds) Login opcode debug All packets dumped
|
||||
// 7 == (Reserved for special builds) Chat Opcode debug All packets dumped
|
||||
// 8 == (Reserved for special builds) World opcode debug All packets dumped
|
||||
// 9 == (Reserved for special builds) Zone Opcode debug All packets dumped
|
||||
// 10 >= More than you ever wanted to know
|
||||
//
|
||||
/////
|
||||
// Add more below to reserve for file's functions ect.
|
||||
/////
|
||||
// Any setup code based on defines should go here
|
||||
//
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_DEBUG) && defined(WIN32)
|
||||
#ifndef _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef EQDEBUG_H
|
||||
#define EQDEBUG_H
|
||||
|
||||
#ifndef _WINDOWS
|
||||
#define DebugBreak() if(0) {}
|
||||
#endif
|
||||
|
||||
#define _WINSOCKAPI_ //stupid windows, trying to fix the winsock2 vs. winsock issues
|
||||
#if defined(WIN32) && ( defined(PACKETCOLLECTOR) || defined(COLLECTOR) )
|
||||
// Packet Collector on win32 requires winsock.h due to latest pcap.h
|
||||
// winsock.h must come before windows.h
|
||||
#include <winsock.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WINDOWS
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
|
||||
#include "logsys.h"
|
||||
|
||||
#include "../common/mutex.h"
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
|
||||
class EQEMuLog {
|
||||
public:
|
||||
EQEMuLog();
|
||||
~EQEMuLog();
|
||||
|
||||
enum LogIDs {
|
||||
Status = 0, /* This must stay the first entry in this list */
|
||||
Normal, /* Normal Logs */
|
||||
Error, /* Error Logs */
|
||||
Debug, /* Debug Logs */
|
||||
Quest, /* Quest Logs */
|
||||
Commands, /* Issued Comamnds */
|
||||
Crash, /* Crash Logs */
|
||||
Save, /* Client Saves */
|
||||
MaxLogID /* Max, used in functions to get the max log ID */
|
||||
};
|
||||
|
||||
//these are callbacks called for each
|
||||
typedef void (* msgCallbackBuf)(LogIDs id, const char *buf, uint8 size, uint32 count);
|
||||
typedef void (* msgCallbackFmt)(LogIDs id, const char *fmt, va_list ap);
|
||||
typedef void (* msgCallbackPva)(LogIDs id, const char *prefix, const char *fmt, va_list ap);
|
||||
|
||||
void SetAllCallbacks(msgCallbackFmt proc);
|
||||
void SetAllCallbacks(msgCallbackBuf proc);
|
||||
void SetAllCallbacks(msgCallbackPva proc);
|
||||
void SetCallback(LogIDs id, msgCallbackFmt proc);
|
||||
void SetCallback(LogIDs id, msgCallbackBuf proc);
|
||||
void SetCallback(LogIDs id, msgCallbackPva proc);
|
||||
|
||||
bool writebuf(LogIDs id, const char *buf, uint8 size, uint32 count);
|
||||
bool write(LogIDs id, const char *fmt, ...);
|
||||
bool writePVA(LogIDs id, const char *prefix, const char *fmt, va_list args);
|
||||
bool Dump(LogIDs id, uint8* data, uint32 size, uint32 cols=16, uint32 skip=0);
|
||||
private:
|
||||
bool open(LogIDs id);
|
||||
bool writeNTS(LogIDs id, bool dofile, const char *fmt, ...); // no error checking, assumes is open, no locking, no timestamp, no newline
|
||||
|
||||
Mutex MOpen;
|
||||
Mutex MLog[MaxLogID];
|
||||
FILE* fp[MaxLogID];
|
||||
|
||||
/* LogStatus: bitwise variable
|
||||
1 = output to file
|
||||
2 = output to stdout
|
||||
4 = fopen error, dont retry
|
||||
8 = use stderr instead (2 must be set)
|
||||
*/
|
||||
uint8 pLogStatus[MaxLogID];
|
||||
|
||||
msgCallbackFmt logCallbackFmt[MaxLogID];
|
||||
msgCallbackBuf logCallbackBuf[MaxLogID];
|
||||
msgCallbackPva logCallbackPva[MaxLogID];
|
||||
};
|
||||
|
||||
extern EQEMuLog* LogFile;
|
||||
|
||||
#ifdef _EQDEBUG
|
||||
class PerformanceMonitor {
|
||||
public:
|
||||
PerformanceMonitor(int64* ip) {
|
||||
p = ip;
|
||||
QueryPerformanceCounter(&tmp);
|
||||
}
|
||||
~PerformanceMonitor() {
|
||||
LARGE_INTEGER tmp2;
|
||||
QueryPerformanceCounter(&tmp2);
|
||||
*p += tmp2.QuadPart - tmp.QuadPart;
|
||||
}
|
||||
LARGE_INTEGER tmp;
|
||||
int64* p;
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2002 EQEMu Development Team (http://eqemu.org)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef DEITY_H
|
||||
#define DEITY_H
|
||||
|
||||
#include "types.h"
|
||||
#include <string>
|
||||
|
||||
// NOTE: This code is not fully implemented since there are no references in the existing code
|
||||
|
||||
/*
|
||||
** Diety types
|
||||
**
|
||||
** (ref: eqstr_us.txt)
|
||||
**
|
||||
** (Another orphaned enumeration...)
|
||||
*/
|
||||
enum DeityTypes
|
||||
{
|
||||
/*----*/ DeityUnknown = 0,
|
||||
/*----*/ DeityAgnostic_LB = 140,
|
||||
/*3251*/ DeityBertoxxulous = 201,
|
||||
/*3262*/ DeityBrellSirilis,
|
||||
/*3253*/ DeityCazicThule,
|
||||
/*3256*/ DeityErollisiMarr,
|
||||
/*3252*/ DeityBristlebane,
|
||||
/*3254*/ DeityInnoruuk,
|
||||
/*3255*/ DeityKarana,
|
||||
/*3257*/ DeityMithanielMarr,
|
||||
/*3259*/ DeityPrexus,
|
||||
/*3260*/ DeityQuellious,
|
||||
/*3266*/ DeityRallosZek,
|
||||
/*3258*/ DeityRodcetNife,
|
||||
/*3261*/ DeitySolusekRo,
|
||||
/*3263*/ DeityTheTribunal,
|
||||
/*3264*/ DeityTunare,
|
||||
/*3265*/ DeityVeeshan,
|
||||
/*3250*/ DeityAgnostic = 396
|
||||
};
|
||||
|
||||
/*
|
||||
** Deity type bits
|
||||
**
|
||||
** (New orphan, but make use of it!)
|
||||
*/
|
||||
enum DeityTypeBits : uint32
|
||||
{
|
||||
BIT_DeityAll = 0x00000000,
|
||||
BIT_DeityAgnostic = 0x00000001,
|
||||
BIT_DeityBertoxxulous = 0x00000002,
|
||||
BIT_DeityBrellSirilis = 0x00000004,
|
||||
BIT_DeityCazicThule = 0x00000008,
|
||||
BIT_DeityErollisiMarr = 0x00000010,
|
||||
BIT_DeityBristlebane = 0x00000020,
|
||||
BIT_DeityInnoruuk = 0x00000040,
|
||||
BIT_DeityKarana = 0x00000080,
|
||||
BIT_DeityMithanielMarr = 0x00000100,
|
||||
BIT_DeityPrexus = 0x00000200,
|
||||
BIT_DeityQuellious = 0x00000400,
|
||||
BIT_DeityRallosZek = 0x00000800,
|
||||
BIT_DeityRodcetNife = 0x00001000,
|
||||
BIT_DeitySolusekRo = 0x00002000,
|
||||
BIT_DeityTheTribunal = 0x00004000,
|
||||
BIT_DeityTunare = 0x00008000,
|
||||
BIT_DeityVeeshan = 0x00010000
|
||||
};
|
||||
|
||||
static DeityTypeBits ConvertDeityToBitDeity(DeityTypes deity)
|
||||
{
|
||||
switch(deity)
|
||||
{
|
||||
case DeityBertoxxulous: { return BIT_DeityBertoxxulous; }
|
||||
case DeityBrellSirilis: { return BIT_DeityBrellSirilis; }
|
||||
case DeityCazicThule: { return BIT_DeityCazicThule; }
|
||||
case DeityErollisiMarr: { return BIT_DeityErollisiMarr; }
|
||||
case DeityBristlebane: { return BIT_DeityBristlebane; }
|
||||
case DeityInnoruuk: { return BIT_DeityInnoruuk; }
|
||||
case DeityKarana: { return BIT_DeityKarana; }
|
||||
case DeityMithanielMarr: { return BIT_DeityMithanielMarr; }
|
||||
case DeityPrexus: { return BIT_DeityPrexus; }
|
||||
case DeityQuellious: { return BIT_DeityQuellious; }
|
||||
case DeityRallosZek: { return BIT_DeityRallosZek; }
|
||||
case DeityRodcetNife: { return BIT_DeityRodcetNife; }
|
||||
case DeitySolusekRo: { return BIT_DeitySolusekRo; }
|
||||
case DeityTheTribunal: { return BIT_DeityTheTribunal; }
|
||||
case DeityTunare: { return BIT_DeityTunare; }
|
||||
case DeityVeeshan: { return BIT_DeityVeeshan; }
|
||||
case DeityAgnostic_LB:
|
||||
case DeityAgnostic: { return BIT_DeityAgnostic; }
|
||||
default: { break; }
|
||||
};
|
||||
|
||||
return BIT_DeityAll;
|
||||
};
|
||||
|
||||
static DeityTypes ConvertBitDeityToDeity(DeityTypeBits deity_bit)
|
||||
{
|
||||
switch(deity_bit)
|
||||
{
|
||||
case BIT_DeityAgnostic: { return DeityAgnostic; }
|
||||
case BIT_DeityBertoxxulous: { return DeityBertoxxulous; }
|
||||
case BIT_DeityBrellSirilis: { return DeityBrellSirilis; }
|
||||
case BIT_DeityCazicThule: { return DeityCazicThule; }
|
||||
case BIT_DeityErollisiMarr: { return DeityErollisiMarr; }
|
||||
case BIT_DeityBristlebane: { return DeityBristlebane; }
|
||||
case BIT_DeityInnoruuk: { return DeityInnoruuk; }
|
||||
case BIT_DeityKarana: { return DeityKarana; }
|
||||
case BIT_DeityMithanielMarr: { return DeityMithanielMarr; }
|
||||
case BIT_DeityPrexus: { return DeityPrexus; }
|
||||
case BIT_DeityQuellious: { return DeityQuellious; }
|
||||
case BIT_DeityRallosZek: { return DeityRallosZek; }
|
||||
case BIT_DeityRodcetNife: { return DeityRodcetNife; }
|
||||
case BIT_DeitySolusekRo: { return DeitySolusekRo; }
|
||||
case BIT_DeityTheTribunal: { return DeityTheTribunal; }
|
||||
case BIT_DeityTunare: { return DeityTunare; }
|
||||
case BIT_DeityVeeshan: { return DeityVeeshan; }
|
||||
default: { break; }
|
||||
};
|
||||
|
||||
return DeityUnknown;
|
||||
};
|
||||
|
||||
static std::string GetDeityName(DeityTypes deity)
|
||||
{
|
||||
switch(deity)
|
||||
{
|
||||
case DeityBertoxxulous: { return "Bertoxxulous"; }
|
||||
case DeityBrellSirilis: { return "Brell Serilis"; }
|
||||
case DeityCazicThule: { return "Cazic-Thule"; }
|
||||
case DeityErollisiMarr: { return "Erollisi Marr"; }
|
||||
case DeityBristlebane: { return "Bristlebane"; }
|
||||
case DeityInnoruuk: { return "Innoruuk"; }
|
||||
case DeityKarana: { return "Karana"; }
|
||||
case DeityMithanielMarr: { return "Mithaniel Marr"; }
|
||||
case DeityPrexus: { return "Prexus"; }
|
||||
case DeityQuellious: { return "Quellious"; }
|
||||
case DeityRallosZek: { return "Rallos Zek"; }
|
||||
case DeityRodcetNife: { return "Rodcet Nife"; }
|
||||
case DeitySolusekRo: { return "Solusek Ro"; }
|
||||
case DeityTheTribunal: { return "The Tribunal"; }
|
||||
case DeityTunare: { return "Tunare"; }
|
||||
case DeityVeeshan: { return "Veeshan"; }
|
||||
case DeityAgnostic_LB:
|
||||
case DeityAgnostic: { return "Agnostic"; }
|
||||
default: { break; }
|
||||
};
|
||||
|
||||
return "Unknown";
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,38 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2005 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
|
||||
*/
|
||||
|
||||
#include "debug.h"
|
||||
#include "emu_opcodes.h"
|
||||
|
||||
const char *OpcodeNames[_maxEmuOpcode+1] = {
|
||||
"OP_Unknown",
|
||||
|
||||
//a preprocessor hack so we dont have to maintain two lists
|
||||
#define N(x) #x
|
||||
#include "emu_oplist.h"
|
||||
#include "mail_oplist.h"
|
||||
#undef N
|
||||
|
||||
""
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2005 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 04111-1307 USA
|
||||
*/
|
||||
#ifndef EMU_OPCODES_H
|
||||
#define EMU_OPCODES_H
|
||||
|
||||
//this is the highest opcode possibly used in the regular EQ protocol
|
||||
#define MAX_EQ_OPCODE 0xFFFF
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
the list of opcodes is in emu_oplist.h
|
||||
|
||||
we somewhat rely on the fact that we have more than 255 opcodes,
|
||||
so we know the enum type for the opcode defines must be at least
|
||||
16 bits, so we can use the protocol flags on them.
|
||||
|
||||
*/
|
||||
|
||||
typedef enum { //EQEmu internal opcodes list
|
||||
OP_Unknown=0,
|
||||
|
||||
//a preprocessor hack so we dont have to maintain two lists
|
||||
#define N(x) x
|
||||
#include "emu_oplist.h"
|
||||
#include "mail_oplist.h"
|
||||
#undef N
|
||||
|
||||
_maxEmuOpcode
|
||||
} EmuOpcode;
|
||||
|
||||
extern const char *OpcodeNames[_maxEmuOpcode+1];
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,546 @@
|
||||
// system use
|
||||
N(OP_ExploreUnknown),
|
||||
// start (please add new opcodes in descending order and re-order any name changes where applicable)
|
||||
N(OP_0x0193),
|
||||
N(OP_0x0347),
|
||||
N(OP_AAAction),
|
||||
N(OP_AAExpUpdate),
|
||||
N(OP_AcceptNewTask),
|
||||
N(OP_AckPacket),
|
||||
N(OP_Action),
|
||||
N(OP_Action2),
|
||||
N(OP_AdventureData),
|
||||
N(OP_AdventureDetails),
|
||||
N(OP_AdventureFinish),
|
||||
N(OP_AdventureInfo),
|
||||
N(OP_AdventureInfoRequest),
|
||||
N(OP_AdventureLeaderboardReply),
|
||||
N(OP_AdventureLeaderboardRequest),
|
||||
N(OP_AdventureMerchantPurchase),
|
||||
N(OP_AdventureMerchantRequest),
|
||||
N(OP_AdventureMerchantResponse),
|
||||
N(OP_AdventureMerchantSell),
|
||||
N(OP_AdventurePointsUpdate),
|
||||
N(OP_AdventureRequest),
|
||||
N(OP_AdventureStatsReply),
|
||||
N(OP_AdventureStatsRequest),
|
||||
N(OP_AdventureUpdate),
|
||||
N(OP_AltCurrency),
|
||||
N(OP_AltCurrencyMerchantReply),
|
||||
N(OP_AltCurrencyMerchantRequest),
|
||||
N(OP_AltCurrencyPurchase),
|
||||
N(OP_AltCurrencyReclaim),
|
||||
N(OP_AltCurrencySell),
|
||||
N(OP_AltCurrencySellSelection),
|
||||
N(OP_Animation),
|
||||
N(OP_AnnoyingZoneUnknown),
|
||||
N(OP_ApplyPoison),
|
||||
N(OP_ApproveName),
|
||||
N(OP_ApproveWorld),
|
||||
N(OP_ApproveZone),
|
||||
N(OP_Assist),
|
||||
N(OP_AssistGroup),
|
||||
N(OP_AugmentInfo),
|
||||
N(OP_AugmentItem),
|
||||
N(OP_AutoAttack),
|
||||
N(OP_AutoAttack2),
|
||||
N(OP_AutoFire),
|
||||
N(OP_Bandolier),
|
||||
N(OP_BankerChange),
|
||||
N(OP_Barter),
|
||||
N(OP_Bazaar),
|
||||
N(OP_BazaarInspect),
|
||||
N(OP_BazaarSearch),
|
||||
N(OP_BecomeCorpse),
|
||||
N(OP_BecomeTrader),
|
||||
N(OP_Begging),
|
||||
N(OP_BeginCast),
|
||||
N(OP_Bind_Wound),
|
||||
N(OP_BlockedBuffs),
|
||||
N(OP_BoardBoat),
|
||||
N(OP_Buff),
|
||||
N(OP_BuffCreate),
|
||||
N(OP_BuffRemoveRequest),
|
||||
N(OP_Bug),
|
||||
N(OP_CameraEffect),
|
||||
N(OP_Camp),
|
||||
N(OP_CancelTask),
|
||||
N(OP_CancelTrade),
|
||||
N(OP_CastSpell),
|
||||
N(OP_ChangeSize),
|
||||
N(OP_ChannelMessage),
|
||||
N(OP_CharacterCreate),
|
||||
N(OP_CharacterCreateRequest),
|
||||
N(OP_CharInventory),
|
||||
N(OP_Charm),
|
||||
N(OP_ChatMessage),
|
||||
N(OP_ClearBlockedBuffs),
|
||||
N(OP_ClearNPCMarks),
|
||||
N(OP_ClearObject),
|
||||
N(OP_ClearSurname),
|
||||
N(OP_ClickDoor),
|
||||
N(OP_ClickObject),
|
||||
N(OP_ClickObjectAction),
|
||||
N(OP_ClientError),
|
||||
N(OP_ClientReady),
|
||||
N(OP_ClientTimeStamp),
|
||||
N(OP_ClientUpdate),
|
||||
N(OP_CloseContainer),
|
||||
N(OP_CloseTributeMaster),
|
||||
N(OP_ColoredText),
|
||||
N(OP_CombatAbility),
|
||||
N(OP_Command),
|
||||
N(OP_CompletedTasks),
|
||||
N(OP_ConfirmDelete),
|
||||
N(OP_Consent),
|
||||
N(OP_ConsentDeny),
|
||||
N(OP_ConsentResponse),
|
||||
N(OP_Consider),
|
||||
N(OP_ConsiderCorpse),
|
||||
N(OP_Consume),
|
||||
N(OP_ControlBoat),
|
||||
N(OP_CorpseDrag),
|
||||
N(OP_CorpseDrop),
|
||||
N(OP_CrashDump),
|
||||
N(OP_CrystalCountUpdate),
|
||||
N(OP_CrystalCreate),
|
||||
N(OP_CrystalReclaim),
|
||||
N(OP_CustomTitles),
|
||||
N(OP_Damage),
|
||||
N(OP_Death),
|
||||
N(OP_DelegateAbility),
|
||||
N(OP_DeleteCharacter),
|
||||
N(OP_DeleteCharge),
|
||||
N(OP_DeleteItem),
|
||||
N(OP_DeletePetition),
|
||||
N(OP_DeleteSpawn),
|
||||
N(OP_DeleteSpell),
|
||||
N(OP_DenyResponse),
|
||||
N(OP_Disarm),
|
||||
N(OP_DisarmTraps),
|
||||
N(OP_DisciplineTimer),
|
||||
N(OP_DisciplineUpdate),
|
||||
N(OP_DiscordMerchantInventory),
|
||||
N(OP_DoGroupLeadershipAbility),
|
||||
N(OP_DuelResponse),
|
||||
N(OP_DuelResponse2),
|
||||
N(OP_DumpName),
|
||||
N(OP_Dye),
|
||||
N(OP_DynamicWall),
|
||||
N(OP_DzAddPlayer),
|
||||
N(OP_DzChooseZone),
|
||||
N(OP_DzCompass),
|
||||
N(OP_DzExpeditionEndsWarning),
|
||||
N(OP_DzExpeditionInfo),
|
||||
N(OP_DzExpeditionList),
|
||||
N(OP_DzJoinExpeditionConfirm),
|
||||
N(OP_DzJoinExpeditionReply),
|
||||
N(OP_DzLeaderStatus),
|
||||
N(OP_DzListTimers),
|
||||
N(OP_DzMakeLeader),
|
||||
N(OP_DzMemberList),
|
||||
N(OP_DzMemberStatus),
|
||||
N(OP_DzPlayerList),
|
||||
N(OP_DzQuit),
|
||||
N(OP_DzRemovePlayer),
|
||||
N(OP_DzSwapPlayer),
|
||||
N(OP_Emote),
|
||||
N(OP_EndLootRequest),
|
||||
N(OP_EnduranceUpdate),
|
||||
N(OP_EnterChat),
|
||||
N(OP_EnterWorld),
|
||||
N(OP_EnvDamage),
|
||||
N(OP_ExpansionInfo),
|
||||
N(OP_ExpUpdate),
|
||||
N(OP_FaceChange),
|
||||
N(OP_Feedback),
|
||||
N(OP_FeignDeath),
|
||||
N(OP_FellowshipUpdate),
|
||||
N(OP_FindPersonReply),
|
||||
N(OP_FindPersonRequest),
|
||||
N(OP_FinishTrade),
|
||||
N(OP_FinishWindow),
|
||||
N(OP_FinishWindow2),
|
||||
N(OP_Fishing),
|
||||
N(OP_FloatListThing),
|
||||
N(OP_Forage),
|
||||
N(OP_ForceFindPerson),
|
||||
N(OP_FormattedMessage),
|
||||
N(OP_FriendsWho),
|
||||
N(OP_GetGuildMOTD),
|
||||
N(OP_GetGuildMOTDReply),
|
||||
N(OP_GetGuildsList),
|
||||
N(OP_GiveMoney),
|
||||
N(OP_GMApproval),
|
||||
N(OP_GMBecomeNPC),
|
||||
N(OP_GMDelCorpse),
|
||||
N(OP_GMEmoteZone),
|
||||
N(OP_GMEndTraining),
|
||||
N(OP_GMEndTrainingResponse),
|
||||
N(OP_GMFind),
|
||||
N(OP_GMGoto),
|
||||
N(OP_GMHideMe),
|
||||
N(OP_GMKick),
|
||||
N(OP_GMKill),
|
||||
N(OP_GMLastName),
|
||||
N(OP_GMNameChange),
|
||||
N(OP_GMSearchCorpse),
|
||||
N(OP_GMServers),
|
||||
N(OP_GMSummon),
|
||||
N(OP_GMToggle),
|
||||
N(OP_GMTraining),
|
||||
N(OP_GMTrainSkill),
|
||||
N(OP_GMTrainSkillConfirm),
|
||||
N(OP_GMZoneRequest),
|
||||
N(OP_GMZoneRequest2),
|
||||
N(OP_GroundSpawn),
|
||||
N(OP_GroupAcknowledge),
|
||||
N(OP_GroupCancelInvite),
|
||||
N(OP_GroupDelete),
|
||||
N(OP_GroupDisband),
|
||||
N(OP_GroupDisbandOther),
|
||||
N(OP_GroupDisbandYou),
|
||||
N(OP_GroupFollow),
|
||||
N(OP_GroupFollow2),
|
||||
N(OP_GroupInvite),
|
||||
N(OP_GroupInvite2),
|
||||
N(OP_GroupLeaderChange),
|
||||
N(OP_GroupLeadershipAAUpdate),
|
||||
N(OP_GroupMakeLeader),
|
||||
N(OP_GroupRoles),
|
||||
N(OP_GroupUpdate),
|
||||
N(OP_GroupUpdateB),
|
||||
N(OP_GroupUpdateLeaderAA),
|
||||
N(OP_GuildBank),
|
||||
N(OP_GuildCreate),
|
||||
N(OP_GuildDelete),
|
||||
N(OP_GuildDemote),
|
||||
N(OP_GuildInvite),
|
||||
N(OP_GuildInviteAccept),
|
||||
N(OP_GuildLeader),
|
||||
N(OP_GuildManageAdd),
|
||||
N(OP_GuildManageBanker),
|
||||
N(OP_GuildManageRemove),
|
||||
N(OP_GuildManageStatus),
|
||||
N(OP_GuildMemberLevelUpdate),
|
||||
N(OP_GuildMemberList),
|
||||
N(OP_GuildMemberUpdate),
|
||||
N(OP_GuildMOTD),
|
||||
N(OP_GuildPeace),
|
||||
N(OP_GuildPromote),
|
||||
N(OP_GuildPublicNote),
|
||||
N(OP_GuildRemove),
|
||||
N(OP_GuildsList),
|
||||
N(OP_GuildStatus),
|
||||
N(OP_GuildTributeInfo),
|
||||
N(OP_GuildUpdateURLAndChannel),
|
||||
N(OP_GuildWar),
|
||||
N(OP_Heartbeat),
|
||||
N(OP_Hide),
|
||||
N(OP_HideCorpse),
|
||||
N(OP_HPUpdate),
|
||||
N(OP_Illusion),
|
||||
N(OP_IncreaseStats),
|
||||
N(OP_InitialHPUpdate),
|
||||
N(OP_InitialMobHealth),
|
||||
N(OP_InspectAnswer),
|
||||
N(OP_InspectMessageUpdate),
|
||||
N(OP_InspectRequest),
|
||||
N(OP_InstillDoubt),
|
||||
N(OP_InterruptCast),
|
||||
N(OP_ItemLinkClick),
|
||||
N(OP_ItemLinkResponse),
|
||||
N(OP_ItemLinkText),
|
||||
N(OP_ItemName),
|
||||
N(OP_ItemPacket),
|
||||
N(OP_ItemPreview),
|
||||
N(OP_ItemRecastDelay),
|
||||
N(OP_ItemVerifyReply),
|
||||
N(OP_ItemVerifyRequest),
|
||||
N(OP_ItemViewUnknown),
|
||||
N(OP_Jump),
|
||||
N(OP_KeyRing),
|
||||
N(OP_KnowledgeBase),
|
||||
N(OP_LDoNButton),
|
||||
N(OP_LDoNDisarmTraps),
|
||||
N(OP_LDoNInspect),
|
||||
N(OP_LDoNOpen),
|
||||
N(OP_LDoNPickLock),
|
||||
N(OP_LDoNSenseTraps),
|
||||
N(OP_LeadershipExpToggle),
|
||||
N(OP_LeadershipExpUpdate),
|
||||
N(OP_LeaveAdventure),
|
||||
N(OP_LeaveBoat),
|
||||
N(OP_LevelAppearance),
|
||||
N(OP_LevelUpdate),
|
||||
N(OP_LFGAppearance),
|
||||
N(OP_LFGCommand),
|
||||
N(OP_LFGGetMatchesRequest),
|
||||
N(OP_LFGGetMatchesResponse),
|
||||
N(OP_LFGResponse),
|
||||
N(OP_LFGuild),
|
||||
N(OP_LFPCommand),
|
||||
N(OP_LFPGetMatchesRequest),
|
||||
N(OP_LFPGetMatchesResponse),
|
||||
N(OP_LoadSpellSet),
|
||||
N(OP_LocInfo),
|
||||
N(OP_LockoutTimerInfo),
|
||||
N(OP_Login),
|
||||
N(OP_LoginAccepted),
|
||||
N(OP_LoginComplete),
|
||||
N(OP_LoginUnknown1),
|
||||
N(OP_LoginUnknown2),
|
||||
N(OP_Logout),
|
||||
N(OP_LogoutReply),
|
||||
N(OP_LogServer),
|
||||
N(OP_LootComplete),
|
||||
N(OP_LootItem),
|
||||
N(OP_LootRequest),
|
||||
N(OP_ManaChange),
|
||||
N(OP_ManaUpdate),
|
||||
N(OP_MarkNPC),
|
||||
N(OP_Marquee),
|
||||
N(OP_MemorizeSpell),
|
||||
N(OP_Mend),
|
||||
N(OP_MendHPUpdate),
|
||||
N(OP_MercenaryAssign),
|
||||
N(OP_MercenaryCommand),
|
||||
N(OP_MercenaryDataRequest),
|
||||
N(OP_MercenaryDataResponse),
|
||||
N(OP_MercenaryDataUpdate),
|
||||
N(OP_MercenaryDataUpdateRequest),
|
||||
N(OP_MercenaryDismiss),
|
||||
N(OP_MercenaryHire),
|
||||
N(OP_MercenarySuspendRequest),
|
||||
N(OP_MercenarySuspendResponse),
|
||||
N(OP_MercenaryTimer),
|
||||
N(OP_MercenaryTimerRequest),
|
||||
N(OP_MercenaryUnknown1),
|
||||
N(OP_MercenaryUnsuspendResponse),
|
||||
N(OP_MobEnduranceUpdate),
|
||||
N(OP_MobHealth),
|
||||
N(OP_MobManaUpdate),
|
||||
N(OP_MobRename),
|
||||
N(OP_MobUpdate), // not used anymore, here for lecacy reasons (eqextractor)
|
||||
N(OP_MoneyOnCorpse),
|
||||
N(OP_MoneyUpdate),
|
||||
N(OP_MOTD),
|
||||
N(OP_MoveCoin),
|
||||
N(OP_MoveDoor),
|
||||
N(OP_MoveItem),
|
||||
N(OP_MoveLogDisregard),
|
||||
N(OP_MoveLogRequest),
|
||||
N(OP_MultiLineMsg),
|
||||
N(OP_NewSpawn),
|
||||
N(OP_NewTitlesAvailable),
|
||||
N(OP_NewZone),
|
||||
N(OP_OnLevelMessage),
|
||||
N(OP_OpenContainer),
|
||||
N(OP_OpenDiscordMerchant),
|
||||
N(OP_OpenGuildTributeMaster),
|
||||
N(OP_OpenInventory),
|
||||
N(OP_OpenNewTasksWindow),
|
||||
N(OP_OpenTributeMaster),
|
||||
N(OP_PDeletePetition),
|
||||
N(OP_PetBuffWindow),
|
||||
N(OP_PetCommands),
|
||||
N(OP_Petition),
|
||||
N(OP_PetitionBug),
|
||||
N(OP_PetitionCheckIn),
|
||||
N(OP_PetitionCheckout),
|
||||
N(OP_PetitionCheckout2),
|
||||
N(OP_PetitionDelete),
|
||||
N(OP_PetitionQue),
|
||||
N(OP_PetitionRefresh),
|
||||
N(OP_PetitionResolve),
|
||||
N(OP_PetitionSearch),
|
||||
N(OP_PetitionSearchResults),
|
||||
N(OP_PetitionSearchText),
|
||||
N(OP_PetitionUnCheckout),
|
||||
N(OP_PetitionUpdate),
|
||||
N(OP_PickPocket),
|
||||
N(OP_PlayerProfile),
|
||||
N(OP_PlayEverquestRequest),
|
||||
N(OP_PlayEverquestResponse),
|
||||
N(OP_PlayMP3),
|
||||
N(OP_Poll),
|
||||
N(OP_PollResponse),
|
||||
N(OP_PopupResponse),
|
||||
N(OP_PostEnterWorld), //this is really OP_WorldAccessGranted
|
||||
N(OP_PotionBelt),
|
||||
N(OP_PreLogoutReply),
|
||||
N(OP_PurchaseLeadershipAA),
|
||||
N(OP_PVPLeaderBoardDetailsReply),
|
||||
N(OP_PVPLeaderBoardDetailsRequest),
|
||||
N(OP_PVPLeaderBoardReply),
|
||||
N(OP_PVPLeaderBoardRequest),
|
||||
N(OP_PVPStats),
|
||||
N(OP_QueryResponseThing),
|
||||
N(OP_RaidInvite),
|
||||
N(OP_RaidJoin),
|
||||
N(OP_RaidUpdate),
|
||||
N(OP_RandomNameGenerator),
|
||||
N(OP_RandomReply),
|
||||
N(OP_RandomReq),
|
||||
N(OP_ReadBook),
|
||||
N(OP_RecipeAutoCombine),
|
||||
N(OP_RecipeDetails),
|
||||
N(OP_RecipeReply),
|
||||
N(OP_RecipesFavorite),
|
||||
N(OP_RecipesSearch),
|
||||
N(OP_ReclaimCrystals),
|
||||
N(OP_ReloadUI),
|
||||
N(OP_RemoveAllDoors),
|
||||
N(OP_RemoveBlockedBuffs),
|
||||
N(OP_RemoveNimbusEffect),
|
||||
N(OP_Report),
|
||||
N(OP_ReqClientSpawn),
|
||||
N(OP_ReqNewZone),
|
||||
N(OP_RequestClientZoneChange),
|
||||
N(OP_RequestDuel),
|
||||
N(OP_RequestKnowledgeBase),
|
||||
N(OP_RequestTitles),
|
||||
N(OP_RespawnWindow),
|
||||
N(OP_RespondAA),
|
||||
N(OP_RestState),
|
||||
N(OP_Rewind),
|
||||
N(OP_RezzAnswer),
|
||||
N(OP_RezzComplete),
|
||||
N(OP_RezzRequest),
|
||||
N(OP_Sacrifice),
|
||||
N(OP_SafeFallSuccess),
|
||||
N(OP_SafePoint),
|
||||
N(OP_Save),
|
||||
N(OP_SaveOnZoneReq),
|
||||
N(OP_SelectTribute),
|
||||
N(OP_SendAAStats),
|
||||
N(OP_SendAATable),
|
||||
N(OP_SendCharInfo),
|
||||
N(OP_SendExpZonein),
|
||||
N(OP_SendFindableNPCs),
|
||||
N(OP_SendGuildTributes),
|
||||
N(OP_SendLoginInfo),
|
||||
N(OP_SendMaxCharacters),
|
||||
N(OP_SendMembership),
|
||||
N(OP_SendMembershipDetails),
|
||||
N(OP_SendSystemStats),
|
||||
N(OP_SendTitleList),
|
||||
N(OP_SendTributes),
|
||||
N(OP_SendZonepoints),
|
||||
N(OP_SenseHeading),
|
||||
N(OP_SenseTraps),
|
||||
N(OP_ServerListRequest),
|
||||
N(OP_ServerListResponse),
|
||||
N(OP_SessionReady),
|
||||
N(OP_SetChatServer),
|
||||
N(OP_SetChatServer2),
|
||||
N(OP_SetGroupTarget),
|
||||
N(OP_SetGuildMOTD),
|
||||
N(OP_SetGuildRank),
|
||||
N(OP_SetRunMode),
|
||||
N(OP_SetServerFilter),
|
||||
N(OP_SetStartCity),
|
||||
N(OP_SetTitle),
|
||||
N(OP_SetTitleReply),
|
||||
N(OP_Shielding),
|
||||
N(OP_ShopDelItem),
|
||||
N(OP_ShopEnd),
|
||||
N(OP_ShopEndConfirm),
|
||||
N(OP_ShopItem),
|
||||
N(OP_ShopPlayerBuy),
|
||||
N(OP_ShopPlayerSell),
|
||||
N(OP_ShopRequest),
|
||||
N(OP_SimpleMessage),
|
||||
N(OP_SkillUpdate),
|
||||
N(OP_Sneak),
|
||||
N(OP_Some3ByteHPUpdate),
|
||||
N(OP_Some6ByteHPUpdate),
|
||||
N(OP_SomeItemPacketMaybe),
|
||||
N(OP_Sound),
|
||||
N(OP_SpawnAppearance),
|
||||
N(OP_SpawnDoor),
|
||||
N(OP_SpawnPositionUpdate),
|
||||
N(OP_SpecialMesg),
|
||||
N(OP_SpellEffect),
|
||||
N(OP_Split),
|
||||
N(OP_Stamina),
|
||||
N(OP_Stun),
|
||||
N(OP_Surname),
|
||||
N(OP_SwapSpell),
|
||||
N(OP_TargetBuffs),
|
||||
N(OP_TargetCommand),
|
||||
N(OP_TargetHoTT),
|
||||
N(OP_TargetMouse),
|
||||
N(OP_TargetReject),
|
||||
N(OP_TaskActivity),
|
||||
N(OP_TaskActivityComplete),
|
||||
N(OP_TaskDescription),
|
||||
N(OP_TaskHistoryReply),
|
||||
N(OP_TaskHistoryRequest),
|
||||
N(OP_TaskMemberList),
|
||||
N(OP_Taunt),
|
||||
N(OP_TestBuff),
|
||||
N(OP_TGB),
|
||||
N(OP_TimeOfDay),
|
||||
N(OP_Track),
|
||||
N(OP_TrackTarget),
|
||||
N(OP_TrackUnknown),
|
||||
N(OP_TradeAcceptClick),
|
||||
N(OP_TradeBusy),
|
||||
N(OP_TradeCoins),
|
||||
N(OP_TradeMoneyUpdate),
|
||||
N(OP_Trader),
|
||||
N(OP_TraderBuy),
|
||||
N(OP_TraderDelItem),
|
||||
N(OP_TradeRequest),
|
||||
N(OP_TradeRequestAck),
|
||||
N(OP_TraderItemUpdate),
|
||||
N(OP_TraderShop),
|
||||
N(OP_TradeSkillCombine),
|
||||
N(OP_Translocate),
|
||||
N(OP_TributeInfo),
|
||||
N(OP_TributeItem),
|
||||
N(OP_TributeMoney),
|
||||
N(OP_TributeNPC),
|
||||
N(OP_TributePointUpdate),
|
||||
N(OP_TributeTimer),
|
||||
N(OP_TributeToggle),
|
||||
N(OP_TributeUpdate),
|
||||
N(OP_Untargetable),
|
||||
N(OP_UpdateAA),
|
||||
N(OP_UpdateLeadershipAA),
|
||||
N(OP_VetClaimReply),
|
||||
N(OP_VetClaimRequest),
|
||||
N(OP_VetRewardsAvaliable),
|
||||
N(OP_VoiceMacroIn),
|
||||
N(OP_VoiceMacroOut),
|
||||
N(OP_WeaponEquip1),
|
||||
N(OP_WeaponEquip2),
|
||||
N(OP_WeaponUnequip2),
|
||||
N(OP_WearChange),
|
||||
N(OP_Weather),
|
||||
N(OP_Weblink),
|
||||
N(OP_WhoAllRequest),
|
||||
N(OP_WhoAllResponse),
|
||||
N(OP_World_Client_CRC1),
|
||||
N(OP_World_Client_CRC2),
|
||||
N(OP_WorldClientReady),
|
||||
N(OP_WorldComplete),
|
||||
N(OP_WorldLogout),
|
||||
N(OP_WorldObjectsSent),
|
||||
N(OP_WorldUnknown001),
|
||||
N(OP_XTargetAutoAddHaters),
|
||||
N(OP_XTargetRequest),
|
||||
N(OP_XTargetResponse),
|
||||
N(OP_YellForHelp),
|
||||
N(OP_ZoneChange),
|
||||
N(OP_ZoneComplete),
|
||||
N(OP_ZoneEntry),
|
||||
N(OP_ZoneGuildList),
|
||||
N(OP_ZoneInUnknown),
|
||||
N(OP_ZonePlayerToBind),
|
||||
N(OP_ZoneServerInfo),
|
||||
N(OP_ZoneServerReady),
|
||||
N(OP_ZoneSpawns),
|
||||
N(OP_ZoneUnavail),
|
||||
// mail and chat opcodes located in ../mail_oplist.h
|
||||
@@ -0,0 +1,820 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
There are really two or three different objects shoe-hored into this
|
||||
connection object. Sombody really needs to factor out the relay link
|
||||
crap into its own subclass of this object, it will clean things up
|
||||
tremendously.
|
||||
*/
|
||||
|
||||
#include "../common/debug.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <iomanip>
|
||||
|
||||
#include "emu_tcp_connection.h"
|
||||
#include "emu_tcp_server.h"
|
||||
#include "../common/servertalk.h"
|
||||
#include "../common/packet_dump.h"
|
||||
|
||||
#ifdef FREEBSD //Timothy Whitman - January 7, 2003
|
||||
#define MSG_NOSIGNAL 0
|
||||
#endif
|
||||
|
||||
#define TCPN_DEBUG 0
|
||||
#define TCPN_DEBUG_Console 0
|
||||
#define TCPN_DEBUG_Memory 0
|
||||
#define TCPN_LOG_PACKETS 0
|
||||
#define TCPN_LOG_RAW_DATA_OUT 0
|
||||
#define TCPN_LOG_RAW_DATA_IN 0
|
||||
|
||||
|
||||
//server side case
|
||||
EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET in_socket, uint32 irIP, uint16 irPort, bool iOldFormat)
|
||||
: TCPConnection(ID, in_socket, irIP, irPort),
|
||||
keepalive_timer(SERVER_TIMEOUT),
|
||||
timeout_timer(SERVER_TIMEOUT * 2)
|
||||
{
|
||||
id = 0;
|
||||
Server = nullptr;
|
||||
pOldFormat = iOldFormat;
|
||||
#ifdef MINILOGIN
|
||||
TCPMode = modePacket;
|
||||
PacketMode = packetModeLogin;
|
||||
#else
|
||||
if (pOldFormat)
|
||||
TCPMode = modePacket;
|
||||
else
|
||||
TCPMode = modeConsole;
|
||||
PacketMode = packetModeZone;
|
||||
#endif
|
||||
RelayLink = 0;
|
||||
RelayServer = false;
|
||||
RelayCount = 0;
|
||||
RemoteID = 0;
|
||||
|
||||
}
|
||||
|
||||
//client outgoing connection case (and client side relay)
|
||||
EmuTCPConnection::EmuTCPConnection(bool iOldFormat, EmuTCPServer* iRelayServer, eTCPMode iMode)
|
||||
: TCPConnection(),
|
||||
keepalive_timer(SERVER_TIMEOUT),
|
||||
timeout_timer(SERVER_TIMEOUT * 2)
|
||||
{
|
||||
Server = iRelayServer;
|
||||
if (Server)
|
||||
RelayServer = true;
|
||||
else
|
||||
RelayServer = false;
|
||||
RelayLink = 0;
|
||||
RelayCount = 0;
|
||||
RemoteID = 0;
|
||||
pOldFormat = iOldFormat;
|
||||
TCPMode = iMode;
|
||||
PacketMode = packetModeZone;
|
||||
#if TCPN_DEBUG_Memory >= 7
|
||||
std::cout << "Constructor #1 on outgoing TCP# " << GetID() << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
//server side relay case
|
||||
EmuTCPConnection::EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConnection* iRelayLink, uint32 iRemoteID, uint32 irIP, uint16 irPort)
|
||||
: TCPConnection(ID, 0, irIP, irPort),
|
||||
keepalive_timer(SERVER_TIMEOUT),
|
||||
timeout_timer(SERVER_TIMEOUT * 2)
|
||||
{
|
||||
Server = iServer;
|
||||
RelayLink = iRelayLink;
|
||||
RelayServer = true;
|
||||
RelayCount = 0;
|
||||
RemoteID = iRemoteID;
|
||||
pOldFormat = false;
|
||||
ConnectionType = Incomming;
|
||||
TCPMode = modePacket;
|
||||
PacketMode = packetModeZone;
|
||||
#if TCPN_DEBUG_Memory >= 7
|
||||
std::cout << "Constructor #3 on outgoing TCP# " << GetID() << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
EmuTCPConnection::~EmuTCPConnection() {
|
||||
//the queues free their content right now I believe.
|
||||
}
|
||||
|
||||
EmuTCPNetPacket_Struct* EmuTCPConnection::MakePacket(ServerPacket* pack, uint32 iDestination) {
|
||||
int32 size = sizeof(EmuTCPNetPacket_Struct) + pack->size;
|
||||
if (pack->compressed) {
|
||||
size += 4;
|
||||
}
|
||||
if (iDestination) {
|
||||
size += 4;
|
||||
}
|
||||
EmuTCPNetPacket_Struct* tnps = (EmuTCPNetPacket_Struct*) new uchar[size];
|
||||
tnps->size = size;
|
||||
tnps->opcode = pack->opcode;
|
||||
*((uint8*) &tnps->flags) = 0;
|
||||
uchar* buffer = tnps->buffer;
|
||||
if (pack->compressed) {
|
||||
tnps->flags.compressed = 1;
|
||||
*((int32*) buffer) = pack->InflatedSize;
|
||||
buffer += 4;
|
||||
}
|
||||
if (iDestination) {
|
||||
tnps->flags.destination = 1;
|
||||
*((int32*) buffer) = iDestination;
|
||||
buffer += 4;
|
||||
}
|
||||
memcpy(buffer, pack->pBuffer, pack->size);
|
||||
return tnps;
|
||||
}
|
||||
|
||||
SPackSendQueue* EmuTCPConnection::MakeOldPacket(ServerPacket* pack) {
|
||||
SPackSendQueue* spsq = (SPackSendQueue*) new uchar[sizeof(SPackSendQueue) + pack->size + 4];
|
||||
if (pack->pBuffer != 0 && pack->size != 0)
|
||||
memcpy((char *) &spsq->buffer[4], (char *) pack->pBuffer, pack->size);
|
||||
memcpy((char *) &spsq->buffer[0], (char *) &pack->opcode, 2);
|
||||
spsq->size = pack->size+4;
|
||||
memcpy((char *) &spsq->buffer[2], (char *) &spsq->size, 2);
|
||||
return spsq;
|
||||
}
|
||||
|
||||
bool EmuTCPConnection::SendPacket(ServerPacket* pack, uint32 iDestination) {
|
||||
if (!Connected())
|
||||
return false;
|
||||
eTCPMode tmp = GetMode();
|
||||
if (tmp != modePacket && tmp != modeTransition)
|
||||
return false;
|
||||
LockMutex lock(&MState);
|
||||
if (RemoteID)
|
||||
return RelayLink->SendPacket(pack, RemoteID);
|
||||
else if (pOldFormat) {
|
||||
#if TCPN_LOG_PACKETS >= 1
|
||||
if (pack && pack->opcode != 0) {
|
||||
struct in_addr in;
|
||||
in.s_addr = GetrIP();
|
||||
CoutTimestamp(true);
|
||||
std::cout << ": Logging outgoing TCP OldPacket. OPCode: 0x" << std::hex << std::setw(4) << std::setfill('0') << pack->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
|
||||
#if TCPN_LOG_PACKETS == 2
|
||||
if (pack->size >= 32)
|
||||
DumpPacket(pack->pBuffer, 32);
|
||||
else
|
||||
DumpPacket(pack);
|
||||
#endif
|
||||
#if TCPN_LOG_PACKETS >= 3
|
||||
DumpPacket(pack);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
SPackSendQueue* spsq = MakeOldPacket(pack);
|
||||
ServerSendQueuePushEnd(spsq->buffer, spsq->size);
|
||||
safe_delete_array(spsq);
|
||||
}
|
||||
else {
|
||||
EmuTCPNetPacket_Struct* tnps = MakePacket(pack, iDestination);
|
||||
if (tmp == modeTransition) {
|
||||
InModeQueuePush(tnps);
|
||||
}
|
||||
else {
|
||||
#if TCPN_LOG_PACKETS >= 1
|
||||
if (pack && pack->opcode != 0) {
|
||||
struct in_addr in;
|
||||
in.s_addr = GetrIP();
|
||||
CoutTimestamp(true);
|
||||
std::cout << ": Logging outgoing TCP packet. OPCode: 0x" << std::hex << std::setw(4) << std::setfill('0') << pack->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
|
||||
#if TCPN_LOG_PACKETS == 2
|
||||
if (pack->size >= 32)
|
||||
DumpPacket(pack->pBuffer, 32);
|
||||
else
|
||||
DumpPacket(pack);
|
||||
#endif
|
||||
#if TCPN_LOG_PACKETS >= 3
|
||||
DumpPacket(pack);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
ServerSendQueuePushEnd((uchar**) &tnps, tnps->size);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EmuTCPConnection::SendPacket(EmuTCPNetPacket_Struct* tnps) {
|
||||
if (RemoteID)
|
||||
return false;
|
||||
if (!Connected())
|
||||
return false;
|
||||
if (GetMode() != modePacket)
|
||||
return false;
|
||||
|
||||
LockMutex lock(&MState);
|
||||
eTCPMode tmp = GetMode();
|
||||
if (tmp == modeTransition) {
|
||||
EmuTCPNetPacket_Struct* tnps2 = (EmuTCPNetPacket_Struct*) new uchar[tnps->size];
|
||||
memcpy(tnps2, tnps, tnps->size);
|
||||
InModeQueuePush(tnps2);
|
||||
return true;
|
||||
}
|
||||
#if TCPN_LOG_PACKETS >= 1
|
||||
if (tnps && tnps->opcode != 0) {
|
||||
struct in_addr in;
|
||||
in.s_addr = GetrIP();
|
||||
CoutTimestamp(true);
|
||||
std::cout << ": Logging outgoing TCP NetPacket. OPCode: 0x" << std::hex << std::setw(4) << std::setfill('0') << tnps->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << tnps->size << " " << inet_ntoa(in) << ":" << GetrPort();
|
||||
if (pOldFormat)
|
||||
std::cout << " (OldFormat)";
|
||||
std::cout << std::endl;
|
||||
#if TCPN_LOG_PACKETS == 2
|
||||
if (tnps->size >= 32)
|
||||
DumpPacket((uchar*) tnps, 32);
|
||||
else
|
||||
DumpPacket((uchar*) tnps, tnps->size);
|
||||
#endif
|
||||
#if TCPN_LOG_PACKETS >= 3
|
||||
DumpPacket((uchar*) tnps, tnps->size);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
ServerSendQueuePushEnd((const uchar*) tnps, tnps->size);
|
||||
return true;
|
||||
}
|
||||
|
||||
ServerPacket* EmuTCPConnection::PopPacket() {
|
||||
ServerPacket* ret;
|
||||
if (!MOutQueueLock.trylock())
|
||||
return nullptr;
|
||||
ret = OutQueue.pop();
|
||||
MOutQueueLock.unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void EmuTCPConnection::InModeQueuePush(EmuTCPNetPacket_Struct* tnps) {
|
||||
MSendQueue.lock();
|
||||
InModeQueue.push(tnps);
|
||||
MSendQueue.unlock();
|
||||
}
|
||||
|
||||
void EmuTCPConnection::OutQueuePush(ServerPacket* pack) {
|
||||
MOutQueueLock.lock();
|
||||
OutQueue.push(pack);
|
||||
MOutQueueLock.unlock();
|
||||
}
|
||||
|
||||
|
||||
bool EmuTCPConnection::LineOutQueuePush(char* line) {
|
||||
#if defined(GOTFRAGS) && 0
|
||||
if (strcmp(line, "**CRASHME**") == 0) {
|
||||
int i = 0;
|
||||
std::cout << (5 / i) << std::endl;
|
||||
}
|
||||
#endif
|
||||
if(line[0] == '*') {
|
||||
if (strcmp(line, "**PACKETMODE**") == 0) {
|
||||
MSendQueue.lock();
|
||||
safe_delete_array(sendbuf);
|
||||
if (TCPMode == modeConsole)
|
||||
Send((const uchar*) "\0**PACKETMODE**\r", 16);
|
||||
TCPMode = modePacket;
|
||||
PacketMode = packetModeLogin;
|
||||
EmuTCPNetPacket_Struct* tnps = 0;
|
||||
while ((tnps = InModeQueue.pop())) {
|
||||
SendPacket(tnps);
|
||||
safe_delete_array(tnps);
|
||||
}
|
||||
MSendQueue.unlock();
|
||||
safe_delete_array(line);
|
||||
return(true);
|
||||
}
|
||||
if (strcmp(line, "**PACKETMODEZONE**") == 0) {
|
||||
MSendQueue.lock();
|
||||
safe_delete_array(sendbuf);
|
||||
if (TCPMode == modeConsole)
|
||||
Send((const uchar*) "\0**PACKETMODEZONE**\r", 20);
|
||||
TCPMode = modePacket;
|
||||
PacketMode = packetModeZone;
|
||||
EmuTCPNetPacket_Struct* tnps = 0;
|
||||
while ((tnps = InModeQueue.pop())) {
|
||||
SendPacket(tnps);
|
||||
safe_delete_array(tnps);
|
||||
}
|
||||
MSendQueue.unlock();
|
||||
safe_delete_array(line);
|
||||
return(true);
|
||||
}
|
||||
if (strcmp(line, "**PACKETMODELAUNCHER**") == 0) {
|
||||
MSendQueue.lock();
|
||||
safe_delete_array(sendbuf);
|
||||
if (TCPMode == modeConsole)
|
||||
Send((const uchar*) "\0**PACKETMODELAUNCHER**\r", 24);
|
||||
TCPMode = modePacket;
|
||||
PacketMode = packetModeLauncher;
|
||||
EmuTCPNetPacket_Struct* tnps = 0;
|
||||
while ((tnps = InModeQueue.pop())) {
|
||||
SendPacket(tnps);
|
||||
safe_delete_array(tnps);
|
||||
}
|
||||
MSendQueue.unlock();
|
||||
safe_delete_array(line);
|
||||
return(true);
|
||||
}
|
||||
if (strcmp(line, "**PACKETMODEUCS**") == 0) {
|
||||
MSendQueue.lock();
|
||||
safe_delete_array(sendbuf);
|
||||
if (TCPMode == modeConsole)
|
||||
Send((const uchar*) "\0**PACKETMODEUCS**\r", 19);
|
||||
TCPMode = modePacket;
|
||||
PacketMode = packetModeUCS;
|
||||
EmuTCPNetPacket_Struct* tnps = 0;
|
||||
while ((tnps = InModeQueue.pop())) {
|
||||
SendPacket(tnps);
|
||||
safe_delete_array(tnps);
|
||||
}
|
||||
MSendQueue.unlock();
|
||||
safe_delete_array(line);
|
||||
return(true);
|
||||
}
|
||||
if (strcmp(line, "**PACKETMODEQS**") == 0) {
|
||||
MSendQueue.lock();
|
||||
safe_delete_array(sendbuf);
|
||||
if (TCPMode == modeConsole)
|
||||
Send((const uchar*) "\0**PACKETMODEQS**\r", 18);
|
||||
TCPMode = modePacket;
|
||||
PacketMode = packetModeQueryServ;
|
||||
EmuTCPNetPacket_Struct* tnps = 0;
|
||||
while ((tnps = InModeQueue.pop())) {
|
||||
SendPacket(tnps);
|
||||
safe_delete_array(tnps);
|
||||
}
|
||||
MSendQueue.unlock();
|
||||
safe_delete_array(line);
|
||||
return(true);
|
||||
}
|
||||
}
|
||||
|
||||
return(TCPConnection::LineOutQueuePush(line));
|
||||
}
|
||||
|
||||
void EmuTCPConnection::Disconnect(bool iSendRelayDisconnect) {
|
||||
TCPConnection::Disconnect();
|
||||
|
||||
if (RelayLink) {
|
||||
RelayLink->RemoveRelay(this, iSendRelayDisconnect);
|
||||
RelayLink = 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool EmuTCPConnection::ConnectIP(uint32 irIP, uint16 irPort, char* errbuf) {
|
||||
if(!TCPConnection::ConnectIP(irIP, irPort, errbuf))
|
||||
return(false);
|
||||
|
||||
MSendQueue.lock();
|
||||
#ifdef MINILOGIN
|
||||
TCPMode = modePacket;
|
||||
#else
|
||||
if (pOldFormat) {
|
||||
TCPMode = modePacket;
|
||||
}
|
||||
else if (TCPMode == modePacket || TCPMode == modeTransition) {
|
||||
TCPMode = modeTransition;
|
||||
if(PacketMode == packetModeLauncher) {
|
||||
safe_delete_array(sendbuf);
|
||||
sendbuf_size = 24;
|
||||
sendbuf_used = sendbuf_size;
|
||||
sendbuf = new uchar[sendbuf_size];
|
||||
memcpy(sendbuf, "\0**PACKETMODELAUNCHER**\r", sendbuf_size);
|
||||
} else if(PacketMode == packetModeLogin) {
|
||||
safe_delete_array(sendbuf);
|
||||
sendbuf_size = 16;
|
||||
sendbuf_used = sendbuf_size;
|
||||
sendbuf = new uchar[sendbuf_size];
|
||||
memcpy(sendbuf, "\0**PACKETMODE**\r", sendbuf_size);
|
||||
} else if(PacketMode == packetModeUCS) {
|
||||
safe_delete_array(sendbuf);
|
||||
sendbuf_size = 19;
|
||||
sendbuf_used = sendbuf_size;
|
||||
sendbuf = new uchar[sendbuf_size];
|
||||
memcpy(sendbuf, "\0**PACKETMODEUCS**\r", sendbuf_size);
|
||||
}
|
||||
else if(PacketMode == packetModeQueryServ) {
|
||||
safe_delete_array(sendbuf);
|
||||
sendbuf_size = 18;
|
||||
sendbuf_used = sendbuf_size;
|
||||
sendbuf = new uchar[sendbuf_size];
|
||||
memcpy(sendbuf, "\0**PACKETMODEQS**\r", sendbuf_size);
|
||||
}
|
||||
else {
|
||||
//default: packetModeZone
|
||||
safe_delete_array(sendbuf);
|
||||
sendbuf_size = 20;
|
||||
sendbuf_used = sendbuf_size;
|
||||
sendbuf = new uchar[sendbuf_size];
|
||||
memcpy(sendbuf, "\0**PACKETMODEZONE**\r", sendbuf_size);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
MSendQueue.unlock();
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void EmuTCPConnection::ClearBuffers() {
|
||||
TCPConnection::ClearBuffers();
|
||||
|
||||
LockMutex lock2(&MOutQueueLock);
|
||||
ServerPacket* pack = 0;
|
||||
while ((pack = OutQueue.pop()))
|
||||
safe_delete(pack);
|
||||
|
||||
EmuTCPNetPacket_Struct* tnps = 0;
|
||||
while ((tnps = InModeQueue.pop()))
|
||||
safe_delete(tnps);
|
||||
|
||||
keepalive_timer.Start();
|
||||
timeout_timer.Start();
|
||||
}
|
||||
|
||||
void EmuTCPConnection::SendNetErrorPacket(const char* reason) {
|
||||
#if TCPC_DEBUG >= 1
|
||||
struct in_addr in;
|
||||
in.s_addr = GetrIP();
|
||||
std::cout "NetError: '";
|
||||
if (reason)
|
||||
std::cout << reason;
|
||||
std::cout << "': " << inet_ntoa(in) << ":" << GetPort() << std::endl;
|
||||
#endif
|
||||
ServerPacket* pack = new ServerPacket(0);
|
||||
pack->size = 1;
|
||||
if (reason)
|
||||
pack->size += strlen(reason) + 1;
|
||||
pack->pBuffer = new uchar[pack->size];
|
||||
memset(pack->pBuffer, 0, pack->size);
|
||||
pack->pBuffer[0] = 255;
|
||||
strcpy((char*) &pack->pBuffer[1], reason);
|
||||
SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
}
|
||||
|
||||
void EmuTCPConnection::RemoveRelay(EmuTCPConnection* relay, bool iSendRelayDisconnect) {
|
||||
if (iSendRelayDisconnect) {
|
||||
ServerPacket* pack = new ServerPacket(0, 5);
|
||||
pack->pBuffer[0] = 3;
|
||||
*((uint32*) &pack->pBuffer[1]) = relay->GetRemoteID();
|
||||
SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
}
|
||||
RelayCount--;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool EmuTCPConnection::ProcessReceivedData(char* errbuf) {
|
||||
if (errbuf)
|
||||
errbuf[0] = 0;
|
||||
timeout_timer.Start();
|
||||
if (!recvbuf)
|
||||
return true;
|
||||
if (TCPMode == modePacket) {
|
||||
if (pOldFormat)
|
||||
return ProcessReceivedDataAsOldPackets(errbuf);
|
||||
else
|
||||
return ProcessReceivedDataAsPackets(errbuf);
|
||||
}
|
||||
//else, use the base class's text processing.
|
||||
bool ret = TCPConnection::ProcessReceivedData(errbuf);
|
||||
//see if we made the transition to packet mode...
|
||||
if(ret && TCPMode == modePacket) {
|
||||
return ProcessReceivedDataAsPackets(errbuf);
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool EmuTCPConnection::ProcessReceivedDataAsPackets(char* errbuf) {
|
||||
if (errbuf)
|
||||
errbuf[0] = 0;
|
||||
int32 base = 0;
|
||||
int32 size = 7;
|
||||
uchar* buffer;
|
||||
ServerPacket* pack = 0;
|
||||
while ((recvbuf_used - base) >= size) {
|
||||
EmuTCPNetPacket_Struct* tnps = (EmuTCPNetPacket_Struct*) &recvbuf[base];
|
||||
buffer = tnps->buffer;
|
||||
size = tnps->size;
|
||||
if (size >= MaxTCPReceiveBuffferSize) {
|
||||
#if TCPN_DEBUG_Memory >= 1
|
||||
std::cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << std::endl;
|
||||
DumpPacket(&recvbuf[base], 16);
|
||||
#endif
|
||||
if (errbuf)
|
||||
snprintf(errbuf, TCPConnection_ErrorBufferSize, "EmuTCPConnection::ProcessReceivedDataAsPackets(): size >= MaxTCPReceiveBuffferSize");
|
||||
return false;
|
||||
}
|
||||
if ((recvbuf_used - base) >= size) {
|
||||
// ok, we got enough data to make this packet!
|
||||
pack = new ServerPacket;
|
||||
pack->size = size - sizeof(EmuTCPNetPacket_Struct);
|
||||
// read headers
|
||||
pack->opcode = tnps->opcode;
|
||||
if (tnps->flags.compressed) {
|
||||
pack->compressed = true;
|
||||
pack->InflatedSize = *((int32*)buffer);
|
||||
pack->size -= 4;
|
||||
buffer += 4;
|
||||
}
|
||||
if (tnps->flags.destination) {
|
||||
pack->destination = *((int32*)buffer);
|
||||
pack->size -= 4;
|
||||
buffer += 4;
|
||||
}
|
||||
// end read headers
|
||||
if (pack->size > 0) {
|
||||
if (tnps->flags.compressed) {
|
||||
// Lets decompress the packet here
|
||||
pack->compressed = false;
|
||||
pack->pBuffer = new uchar[pack->InflatedSize];
|
||||
pack->size = InflatePacket(buffer, pack->size, pack->pBuffer, pack->InflatedSize);
|
||||
}
|
||||
else {
|
||||
pack->pBuffer = new uchar[pack->size];
|
||||
memcpy(pack->pBuffer, buffer, pack->size);
|
||||
}
|
||||
}
|
||||
if (pack->opcode == 0) {
|
||||
if (pack->size) {
|
||||
#if TCPN_DEBUG >= 2
|
||||
std::cout << "Received TCP Network layer packet" << std::endl;
|
||||
#endif
|
||||
ProcessNetworkLayerPacket(pack);
|
||||
}
|
||||
#if TCPN_DEBUG >= 5
|
||||
else {
|
||||
std::cout << "Received TCP keepalive packet. (opcode=0)" << std::endl;
|
||||
}
|
||||
#endif
|
||||
// keepalive, no need to process
|
||||
safe_delete(pack);
|
||||
}
|
||||
else {
|
||||
#if TCPN_LOG_PACKETS >= 1
|
||||
if (pack && pack->opcode != 0) {
|
||||
struct in_addr in;
|
||||
in.s_addr = GetrIP();
|
||||
CoutTimestamp(true);
|
||||
std::cout << ": Logging incoming TCP packet. OPCode: 0x" << std::hex << std::setw(4) << std::setfill('0') << pack->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
|
||||
#if TCPN_LOG_PACKETS == 2
|
||||
if (pack->size >= 32)
|
||||
DumpPacket(pack->pBuffer, 32);
|
||||
else
|
||||
DumpPacket(pack);
|
||||
#endif
|
||||
#if TCPN_LOG_PACKETS >= 3
|
||||
DumpPacket(pack);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
if (RelayServer && Server && pack->destination) {
|
||||
EmuTCPConnection* con = Server->FindConnection(pack->destination);
|
||||
if (!con) {
|
||||
#if TCPN_DEBUG >= 1
|
||||
std::cout << "Error relaying packet: con = 0" << std::endl;
|
||||
#endif
|
||||
safe_delete(pack);
|
||||
}
|
||||
else
|
||||
con->OutQueuePush(pack);
|
||||
}
|
||||
else
|
||||
OutQueuePush(pack);
|
||||
}
|
||||
base += size;
|
||||
size = 7;
|
||||
}
|
||||
}
|
||||
if (base != 0) {
|
||||
if (base >= recvbuf_used) {
|
||||
safe_delete_array(recvbuf);
|
||||
} else {
|
||||
uchar* tmpbuf = new uchar[recvbuf_size - base];
|
||||
memcpy(tmpbuf, &recvbuf[base], recvbuf_used - base);
|
||||
safe_delete_array(recvbuf);
|
||||
recvbuf = tmpbuf;
|
||||
recvbuf_used -= base;
|
||||
recvbuf_size -= base;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EmuTCPConnection::ProcessReceivedDataAsOldPackets(char* errbuf) {
|
||||
int32 base = 0;
|
||||
int32 size = 4;
|
||||
uchar* buffer;
|
||||
ServerPacket* pack = 0;
|
||||
while ((recvbuf_used - base) >= size) {
|
||||
buffer = &recvbuf[base];
|
||||
memcpy(&size, &buffer[2], 2);
|
||||
if (size >= MaxTCPReceiveBuffferSize) {
|
||||
#if TCPN_DEBUG_Memory >= 1
|
||||
std::cout << "TCPConnection[" << GetID() << "]::ProcessReceivedDataAsPackets(): size[" << size << "] >= MaxTCPReceiveBuffferSize" << std::endl;
|
||||
#endif
|
||||
if (errbuf)
|
||||
snprintf(errbuf, TCPConnection_ErrorBufferSize, "EmuTCPConnection::ProcessReceivedDataAsPackets(): size >= MaxTCPReceiveBuffferSize");
|
||||
return false;
|
||||
}
|
||||
if ((recvbuf_used - base) >= size) {
|
||||
// ok, we got enough data to make this packet!
|
||||
pack = new ServerPacket;
|
||||
memcpy(&pack->opcode, &buffer[0], 2);
|
||||
pack->size = size - 4;
|
||||
/* if () { // TODO: Checksum or size check or something similar
|
||||
// Datastream corruption, get the hell outta here!
|
||||
delete pack;
|
||||
return false;
|
||||
}*/
|
||||
if (pack->size > 0) {
|
||||
pack->pBuffer = new uchar[pack->size];
|
||||
memcpy(pack->pBuffer, &buffer[4], pack->size);
|
||||
}
|
||||
if (pack->opcode == 0) {
|
||||
// keepalive, no need to process
|
||||
safe_delete(pack);
|
||||
}
|
||||
else {
|
||||
#if TCPN_LOG_PACKETS >= 1
|
||||
if (pack && pack->opcode != 0) {
|
||||
struct in_addr in;
|
||||
in.s_addr = GetrIP();
|
||||
CoutTimestamp(true);
|
||||
std::cout << ": Logging incoming TCP OldPacket. OPCode: 0x" << std::hex << std::setw(4) << std::setfill('0') << pack->opcode << std::dec << ", size: " << std::setw(5) << std::setfill(' ') << pack->size << " " << inet_ntoa(in) << ":" << GetrPort() << std::endl;
|
||||
#if TCPN_LOG_PACKETS == 2
|
||||
if (pack->size >= 32)
|
||||
DumpPacket(pack->pBuffer, 32);
|
||||
else
|
||||
DumpPacket(pack);
|
||||
#endif
|
||||
#if TCPN_LOG_PACKETS >= 3
|
||||
DumpPacket(pack);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
OutQueuePush(pack);
|
||||
}
|
||||
base += size;
|
||||
size = 4;
|
||||
}
|
||||
}
|
||||
if (base != 0) {
|
||||
if (base >= recvbuf_used) {
|
||||
safe_delete_array(recvbuf);
|
||||
}
|
||||
else {
|
||||
uchar* tmpbuf = new uchar[recvbuf_size - base];
|
||||
memcpy(tmpbuf, &recvbuf[base], recvbuf_used - base);
|
||||
safe_delete_array(recvbuf);
|
||||
recvbuf = tmpbuf;
|
||||
recvbuf_used -= base;
|
||||
recvbuf_size -= base;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void EmuTCPConnection::ProcessNetworkLayerPacket(ServerPacket* pack) {
|
||||
uint8 opcode = pack->pBuffer[0];
|
||||
uint8* data = &pack->pBuffer[1];
|
||||
switch (opcode) {
|
||||
case 0: {
|
||||
break;
|
||||
}
|
||||
case 1: { // Switch to RelayServer mode
|
||||
if (pack->size != 1) {
|
||||
SendNetErrorPacket("New RelayClient: wrong size, expected 1");
|
||||
break;
|
||||
}
|
||||
if (RelayServer) {
|
||||
SendNetErrorPacket("Switch to RelayServer mode when already in RelayServer mode");
|
||||
break;
|
||||
}
|
||||
if (RemoteID) {
|
||||
SendNetErrorPacket("Switch to RelayServer mode by a Relay Client");
|
||||
break;
|
||||
}
|
||||
if (ConnectionType != Incomming) {
|
||||
SendNetErrorPacket("Switch to RelayServer mode on outgoing connection");
|
||||
break;
|
||||
}
|
||||
#if TCPC_DEBUG >= 3
|
||||
struct in_addr in;
|
||||
in.s_addr = GetrIP();
|
||||
std::cout << "Switching to RelayServer mode: " << inet_ntoa(in) << ":" << GetPort() << std::endl;
|
||||
#endif
|
||||
RelayServer = true;
|
||||
break;
|
||||
}
|
||||
case 2: { // New Relay Client
|
||||
if (!RelayServer) {
|
||||
SendNetErrorPacket("New RelayClient when not in RelayServer mode");
|
||||
break;
|
||||
}
|
||||
if (pack->size != 11) {
|
||||
SendNetErrorPacket("New RelayClient: wrong size, expected 11");
|
||||
break;
|
||||
}
|
||||
if (ConnectionType != Incomming) {
|
||||
SendNetErrorPacket("New RelayClient: illegal on outgoing connection");
|
||||
break;
|
||||
}
|
||||
EmuTCPConnection* con = new EmuTCPConnection(Server->GetNextID(), Server, this, *((uint32*) data), *((uint32*) &data[4]), *((uint16*) &data[8]));
|
||||
Server->AddConnection(con);
|
||||
RelayCount++;
|
||||
break;
|
||||
}
|
||||
case 3: { // Delete Relay Client
|
||||
if (!RelayServer) {
|
||||
SendNetErrorPacket("Delete RelayClient when not in RelayServer mode");
|
||||
break;
|
||||
}
|
||||
if (pack->size != 5) {
|
||||
SendNetErrorPacket("Delete RelayClient: wrong size, expected 5");
|
||||
break;
|
||||
}
|
||||
EmuTCPConnection* con = Server->FindConnection(*((uint32*)data));
|
||||
if (con) {
|
||||
if (ConnectionType == Incomming) {
|
||||
if (con->GetRelayLink() != this) {
|
||||
SendNetErrorPacket("Delete RelayClient: RelayLink != this");
|
||||
break;
|
||||
}
|
||||
}
|
||||
con->Disconnect(false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 255: {
|
||||
#if TCPC_DEBUG >= 1
|
||||
struct in_addr in;
|
||||
in.s_addr = GetrIP();
|
||||
std::cout "Received NetError: '";
|
||||
if (pack->size > 1)
|
||||
std::cout << (char*) data;
|
||||
std::cout << "': " << inet_ntoa(in) << ":" << GetPort() << std::endl;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool EmuTCPConnection::SendData(bool &sent_something, char* errbuf) {
|
||||
sent_something = false;
|
||||
if(!TCPConnection::SendData(sent_something, errbuf))
|
||||
return(false);
|
||||
|
||||
if(sent_something)
|
||||
keepalive_timer.Start();
|
||||
else if (TCPMode == modePacket && keepalive_timer.Check()) {
|
||||
ServerPacket* pack = new ServerPacket(0, 0);
|
||||
SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
#if TCPN_DEBUG >= 5
|
||||
std::cout << "Sending TCP keepalive packet. (timeout=" << timeout_timer.GetRemainingTime() << " remaining)" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
bool EmuTCPConnection::RecvData(char* errbuf) {
|
||||
if(!TCPConnection::RecvData(errbuf)) {
|
||||
if (OutQueue.count())
|
||||
return(true);
|
||||
else
|
||||
return(false);
|
||||
}
|
||||
|
||||
if ((TCPMode == modePacket || TCPMode == modeTransition) && timeout_timer.Check()) {
|
||||
if (errbuf)
|
||||
snprintf(errbuf, TCPConnection_ErrorBufferSize, "TCPConnection::RecvData(): Connection timeout");
|
||||
return false;
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
#ifndef EmuTCPCONNECTION_H_
|
||||
#define EmuTCPCONNECTION_H_
|
||||
|
||||
#include "tcp_connection.h"
|
||||
#include "timer.h"
|
||||
|
||||
//moved out of TCPConnection:: to be more exportable
|
||||
#pragma pack(1)
|
||||
struct EmuTCPNetPacket_Struct {
|
||||
uint32 size;
|
||||
struct {
|
||||
uint8
|
||||
compressed : 1,
|
||||
destination : 1,
|
||||
flag3 : 1,
|
||||
flag4 : 1,
|
||||
flag5 : 1,
|
||||
flag6 : 1,
|
||||
flag7 : 1,
|
||||
flag8 : 1;
|
||||
} flags;
|
||||
uint16 opcode;
|
||||
uchar buffer[0];
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
struct SPackSendQueue;
|
||||
class EmuTCPServer;
|
||||
|
||||
class EmuTCPConnection : public TCPConnection {
|
||||
public:
|
||||
enum eTCPMode { modeConsole, modeTransition, modePacket };
|
||||
enum ePacketMode { packetModeZone, packetModeLauncher, packetModeLogin, packetModeUCS, packetModeQueryServ };
|
||||
|
||||
EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, SOCKET iSock, uint32 irIP, uint16 irPort, bool iOldFormat = false);
|
||||
EmuTCPConnection(bool iOldFormat = false, EmuTCPServer* iRelayServer = 0, eTCPMode iMode = modePacket); // for outgoing connections
|
||||
EmuTCPConnection(uint32 ID, EmuTCPServer* iServer, EmuTCPConnection* iRelayLink, uint32 iRemoteID, uint32 irIP, uint16 irPort); // for relay connections
|
||||
virtual ~EmuTCPConnection();
|
||||
|
||||
virtual bool ConnectIP(uint32 irIP, uint16 irPort, char* errbuf = 0);
|
||||
virtual void Disconnect(bool iSendRelayDisconnect = true);
|
||||
|
||||
static EmuTCPNetPacket_Struct* MakePacket(ServerPacket* pack, uint32 iDestination = 0);
|
||||
static SPackSendQueue* MakeOldPacket(ServerPacket* pack);
|
||||
|
||||
virtual bool SendPacket(ServerPacket* pack, uint32 iDestination = 0);
|
||||
virtual bool SendPacket(EmuTCPNetPacket_Struct* tnps);
|
||||
ServerPacket* PopPacket(); // OutQueuePop()
|
||||
void SetPacketMode(ePacketMode mode) { PacketMode = mode; }
|
||||
|
||||
eTCPMode GetMode() const { return TCPMode; }
|
||||
ePacketMode GetPacketMode() const { return(PacketMode); }
|
||||
|
||||
//relay crap:
|
||||
inline bool IsRelayServer() const { return RelayServer; }
|
||||
inline TCPConnection* GetRelayLink() const { return RelayLink; }
|
||||
inline uint32 GetRemoteID() const { return RemoteID; }
|
||||
|
||||
protected:
|
||||
void OutQueuePush(ServerPacket* pack);
|
||||
void RemoveRelay(EmuTCPConnection* relay, bool iSendRelayDisconnect);
|
||||
|
||||
void SendNetErrorPacket(const char* reason = 0);
|
||||
|
||||
virtual bool SendData(bool &sent_something, char* errbuf = 0);
|
||||
virtual bool RecvData(char* errbuf = 0);
|
||||
|
||||
virtual bool ProcessReceivedData(char* errbuf = 0);
|
||||
bool ProcessReceivedDataAsPackets(char* errbuf = 0);
|
||||
bool ProcessReceivedDataAsOldPackets(char* errbuf = 0);
|
||||
void ProcessNetworkLayerPacket(ServerPacket* pack);
|
||||
|
||||
virtual bool LineOutQueuePush(char* line);
|
||||
virtual void ClearBuffers();
|
||||
|
||||
EmuTCPServer* Server;
|
||||
|
||||
eTCPMode TCPMode;
|
||||
ePacketMode PacketMode;
|
||||
bool pOldFormat;
|
||||
|
||||
Timer keepalive_timer;
|
||||
Timer timeout_timer;
|
||||
|
||||
//relay crap:
|
||||
EmuTCPConnection* RelayLink;
|
||||
int32 RelayCount;
|
||||
bool RelayServer;
|
||||
uint32 RemoteID;
|
||||
|
||||
//input queue...
|
||||
void InModeQueuePush(EmuTCPNetPacket_Struct* tnps);
|
||||
MyQueue<EmuTCPNetPacket_Struct> InModeQueue;
|
||||
|
||||
//output queue...
|
||||
MyQueue<ServerPacket> OutQueue;
|
||||
Mutex MOutQueueLock;
|
||||
};
|
||||
|
||||
#endif /*EmuTCPCONNECTION_H_*/
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
#include "debug.h"
|
||||
#include "emu_tcp_server.h"
|
||||
#include "emu_tcp_connection.h"
|
||||
|
||||
EmuTCPServer::EmuTCPServer(uint16 iPort, bool iOldFormat)
|
||||
: TCPServer<EmuTCPConnection>(iPort),
|
||||
pOldFormat(iOldFormat)
|
||||
{
|
||||
}
|
||||
|
||||
EmuTCPServer::~EmuTCPServer() {
|
||||
MInQueue.lock();
|
||||
while(!m_InQueue.empty()) {
|
||||
delete m_InQueue.front();
|
||||
m_InQueue.pop();
|
||||
}
|
||||
MInQueue.unlock();
|
||||
}
|
||||
|
||||
void EmuTCPServer::Process() {
|
||||
CheckInQueue();
|
||||
TCPServer<EmuTCPConnection>::Process();
|
||||
}
|
||||
|
||||
void EmuTCPServer::CreateNewConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort)
|
||||
{
|
||||
EmuTCPConnection *conn = new EmuTCPConnection(ID, this, in_socket, irIP, irPort, pOldFormat);
|
||||
AddConnection(conn);
|
||||
}
|
||||
|
||||
|
||||
void EmuTCPServer::SendPacket(ServerPacket* pack) {
|
||||
EmuTCPNetPacket_Struct* tnps = EmuTCPConnection::MakePacket(pack);
|
||||
SendPacket(&tnps);
|
||||
}
|
||||
|
||||
void EmuTCPServer::SendPacket(EmuTCPNetPacket_Struct** tnps) {
|
||||
MInQueue.lock();
|
||||
m_InQueue.push(*tnps);
|
||||
MInQueue.unlock();
|
||||
tnps = nullptr;
|
||||
}
|
||||
|
||||
void EmuTCPServer::CheckInQueue() {
|
||||
EmuTCPNetPacket_Struct* tnps = 0;
|
||||
|
||||
while (( tnps = InQueuePop() )) {
|
||||
vitr cur, end;
|
||||
cur = m_list.begin();
|
||||
end = m_list.end();
|
||||
for(; cur != end; cur++) {
|
||||
if ((*cur)->GetMode() != EmuTCPConnection::modeConsole && (*cur)->GetRemoteID() == 0)
|
||||
(*cur)->SendPacket(tnps);
|
||||
}
|
||||
safe_delete(tnps);
|
||||
}
|
||||
}
|
||||
|
||||
EmuTCPNetPacket_Struct* EmuTCPServer::InQueuePop() {
|
||||
EmuTCPNetPacket_Struct* ret = nullptr;
|
||||
MInQueue.lock();
|
||||
if(!m_InQueue.empty()) {
|
||||
ret = m_InQueue.front();
|
||||
m_InQueue.pop();
|
||||
}
|
||||
MInQueue.unlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
EmuTCPConnection *EmuTCPServer::FindConnection(uint32 iID) {
|
||||
vitr cur, end;
|
||||
cur = m_list.begin();
|
||||
end = m_list.end();
|
||||
for(; cur != end; cur++) {
|
||||
if ((*cur)->GetID() == iID)
|
||||
return *cur;
|
||||
}
|
||||
return(nullptr);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef EmuTCPSERVER_H_
|
||||
#define EmuTCPSERVER_H_
|
||||
|
||||
#include "tcp_server.h"
|
||||
|
||||
class EmuTCPConnection;
|
||||
struct EmuTCPNetPacket_Struct;
|
||||
class ServerPacket;
|
||||
|
||||
class EmuTCPServer : public TCPServer<EmuTCPConnection> {
|
||||
public:
|
||||
EmuTCPServer(uint16 iPort = 0, bool iOldFormat = false);
|
||||
virtual ~EmuTCPServer();
|
||||
|
||||
//packet broadcast routines.
|
||||
void SendPacket(ServerPacket* pack);
|
||||
void SendPacket(EmuTCPNetPacket_Struct** tnps);
|
||||
|
||||
//special crap for relay management
|
||||
EmuTCPConnection *FindConnection(uint32 iID);
|
||||
|
||||
//exposed for some crap we pull. Do not call from outside this object.
|
||||
using TCPServer<EmuTCPConnection>::AddConnection;
|
||||
|
||||
protected:
|
||||
virtual void Process();
|
||||
|
||||
virtual void CreateNewConnection(uint32 ID, SOCKET in_socket, uint32 irIP, uint16 irPort);
|
||||
|
||||
bool pOldFormat;
|
||||
|
||||
//broadcast packet queue..
|
||||
void CheckInQueue();
|
||||
Mutex MInQueue;
|
||||
EmuTCPNetPacket_Struct* InQueuePop(); //returns ownership
|
||||
std::queue<EmuTCPNetPacket_Struct *> m_InQueue;
|
||||
};
|
||||
#endif /*EmuTCPSERVER_H_*/
|
||||
@@ -0,0 +1,906 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2003 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef EQ_CONSTANTS_H
|
||||
#define EQ_CONSTANTS_H
|
||||
|
||||
#include "skills.h"
|
||||
|
||||
/*
|
||||
** Item attributes
|
||||
**
|
||||
** (There are no grepwin hits other than these declarations... Do they have a use?)
|
||||
*/
|
||||
enum ItemAttributes : uint32
|
||||
{
|
||||
ItemAttrNone = 0x00000000,
|
||||
ItemAttrLore = 0x00000001,
|
||||
ItemAttrArtifact = 0x00000002,
|
||||
ItemAttrSummoned = 0x00000004,
|
||||
ItemAttrMagic = 0x00000008,
|
||||
ItemAttrAugment = 0x00000010,
|
||||
ItemAttrPendingLore = 0x00000020,
|
||||
ItemAttrUnknown = 0xFFFFFFFF
|
||||
};
|
||||
|
||||
/*
|
||||
** Item class types
|
||||
**
|
||||
*/
|
||||
enum ItemClassTypes
|
||||
{
|
||||
ItemClassCommon = 0,
|
||||
ItemClassContainer,
|
||||
ItemClassBook,
|
||||
_ItemClassCount
|
||||
};
|
||||
|
||||
/*
|
||||
** Item use types
|
||||
**
|
||||
** (ref: database and eqstr_us.txt)
|
||||
**
|
||||
** (Looking at a recent database, it's possible that some of the item values may be off [10-27-2013] -U)
|
||||
*/
|
||||
enum ItemUseTypes : uint8
|
||||
{
|
||||
/*9138*/ ItemType1HSlash = 0,
|
||||
/*9141*/ ItemType2HSlash,
|
||||
/*9140*/ ItemType1HPiercing,
|
||||
/*9139*/ ItemType1HBlunt,
|
||||
/*9142*/ ItemType2HBlunt,
|
||||
/*5504*/ ItemTypeBow,
|
||||
/*----*/ ItemTypeUnknown1,
|
||||
/*----*/ ItemTypeLargeThrowing,
|
||||
/*5505*/ ItemTypeShield,
|
||||
/*5506*/ ItemTypeScroll,
|
||||
/*5507*/ ItemTypeArmor,
|
||||
/*5508*/ ItemTypeMisc, // a lot of random crap has this item use.
|
||||
/*7564*/ ItemTypeLockPick,
|
||||
/*----*/ ItemTypeUnknown2,
|
||||
/*5509*/ ItemTypeFood,
|
||||
/*5510*/ ItemTypeDrink,
|
||||
/*5511*/ ItemTypeLight,
|
||||
/*5512*/ ItemTypeCombinable, // not all stackable items are this use...
|
||||
/*5513*/ ItemTypeBandage,
|
||||
/*----*/ ItemTypeSmallThrowing,
|
||||
/*----*/ ItemTypeSpell, // spells and tomes
|
||||
/*5514*/ ItemTypePotion,
|
||||
/*----*/ ItemTypeUnknown3,
|
||||
/*0406*/ ItemTypeWindInstrument,
|
||||
/*0407*/ ItemTypeStringedInstrument,
|
||||
/*0408*/ ItemTypeBrassInstrument,
|
||||
/*0405*/ ItemTypePercussionInstrument,
|
||||
/*5515*/ ItemTypeArrow,
|
||||
/*----*/ ItemTypeUnknown4,
|
||||
/*5521*/ ItemTypeJewelry,
|
||||
/*----*/ ItemTypeSkull,
|
||||
/*5516*/ ItemTypeBook, // skill-up tomes/books? (would probably need a pp flag if true...)
|
||||
/*5517*/ ItemTypeNote,
|
||||
/*5518*/ ItemTypeKey,
|
||||
/*----*/ ItemTypeCoin,
|
||||
/*5520*/ ItemType2HPiercing,
|
||||
/*----*/ ItemTypeFishingPole,
|
||||
/*----*/ ItemTypeFishingBait,
|
||||
/*5519*/ ItemTypeAlcohol,
|
||||
/*----*/ ItemTypeKey2, // keys and satchels?? (questable keys?)
|
||||
/*----*/ ItemTypeCompass,
|
||||
/*----*/ ItemTypeUnknown5,
|
||||
/*----*/ ItemTypePoison, // might be wrong, but includes poisons
|
||||
/*----*/ ItemTypeUnknown6,
|
||||
/*----*/ ItemTypeUnknown7,
|
||||
/*5522*/ ItemTypeMartial,
|
||||
/*----*/ ItemTypeUnknown8,
|
||||
/*----*/ ItemTypeUnknown9,
|
||||
/*----*/ ItemTypeUnknown10,
|
||||
/*----*/ ItemTypeUnknown11,
|
||||
/*----*/ ItemTypeSinging,
|
||||
/*5750*/ ItemTypeAllInstrumentTypes,
|
||||
/*5776*/ ItemTypeCharm,
|
||||
/*----*/ ItemTypeDye,
|
||||
/*----*/ ItemTypeAugmentation,
|
||||
/*----*/ ItemTypeAugmentationSolvent,
|
||||
/*----*/ ItemTypeAugmentationDistiller,
|
||||
/*----*/ ItemTypeUnknown12,
|
||||
/*----*/ ItemTypeFellowshipKit,
|
||||
/*----*/ ItemTypeUnknown13,
|
||||
/*----*/ ItemTypeRecipe,
|
||||
/*----*/ ItemTypeAdvancedRecipe,
|
||||
/*----*/ ItemTypeJournal, // only one(1) database entry
|
||||
/*----*/ ItemTypeAltCurrency, // alt-currency (as opposed to coinage)
|
||||
/*5881*/ ItemTypePerfectedAugmentationDistiller,
|
||||
/*----*/ _ItemTypeCount
|
||||
|
||||
/*
|
||||
Unknowns:
|
||||
|
||||
Mounts?
|
||||
Ornamentations?
|
||||
GuildBanners?
|
||||
Collectible?
|
||||
Placeable?
|
||||
(others?)
|
||||
*/
|
||||
};
|
||||
|
||||
/*
|
||||
** Augmentation use type bitmasks (1-based)
|
||||
**
|
||||
** (ref: dbstr_us.txt)
|
||||
**
|
||||
*/
|
||||
enum AugmentationUseTypeBitmasks : uint32 {
|
||||
AugUseNone = 0x00000000,
|
||||
AugUseGeneralSingleStat = 0x00000001, /*1^16^1 (General: Single Stat)^0*/
|
||||
AugUseGeneralMultipleStat = 0x00000002, /*2^16^2 (General: Multiple Stat)^0*/
|
||||
AugUseGeneralSpellEffect = 0x00000004, /*3^16^3 (General: Spell Effect)^0*/
|
||||
AugUseWeaponGeneral = 0x00000008, /*4^16^4 (Weapon: General)^0*/
|
||||
AugUseWeaponElemDamage = 0x00000010, /*5^16^5 (Weapon: Elem Damage)^0*/
|
||||
AugUseWeaponBaseDamage = 0x00000020, /*6^16^6 (Weapon: Base Damage)^0*/
|
||||
AugUseGeneralGroup = 0x00000040, /*7^16^7 (General: Group)^0*/
|
||||
AugUseGeneralRaid = 0x00000080, /*8^16^8 (General: Raid)^0*/
|
||||
AugUseGeneralDragonsPoints = 0x00000100, /*9^16^9 (General: Dragons Points)^0*/
|
||||
AugUseCraftedCommon = 0x00000200, /*10^16^10 (Crafted: Common)^0*/
|
||||
AugUseCraftedGroup1 = 0x00000400, /*11^16^11 (Crafted: Group)^0*/
|
||||
AugUseCraftedRaid1 = 0x00000800, /*12^16^12 (Crafted: Raid)^0*/
|
||||
AugUseEnergeiacGroup = 0x00001000, /*13^16^13 (Energeiac: Group)^0*/
|
||||
AugUseEnergeiacRaid = 0x00002000, /*14^16^14 (Energeiac: Raid)^0*/
|
||||
AugUseEmblem = 0x00004000, /*15^16^15 (Emblem)^0*/
|
||||
AugUseCraftedGroup2 = 0x00008000, /*16^16^16 (Crafted: Group)^0*/
|
||||
AugUseCraftedRaid2 = 0x00010000, /*17^16^17 (Crafted: Raid)^0*/
|
||||
AugUseUnknown1 = 0x00020000, /*18^16^18^0*/
|
||||
AugUseUnknown2 = 0x00040000, /*19^16^19^0*/
|
||||
AugUseOrnamentation = 0x00080000, /*20^16^20 (Ornamentation)^0*/
|
||||
AugUseSpecialOrnamentation = 0x00100000, /*21^16^21 (Special Ornamentation)^0*/
|
||||
AugUseUnknown3 = 0x00200000, /*22^16^22^0*/
|
||||
AugUseUnknown4 = 0x00400000, /*23^16^23^0*/
|
||||
AugUseUnknown5 = 0x00800000, /*24^16^24^0*/
|
||||
AugUseUnknown6 = 0x01000000, /*25^16^25^0*/
|
||||
AugUseUnknown7 = 0x02000000, /*26^16^26^0*/
|
||||
AugUseUnknown8 = 0x04000000, /*27^16^27^0*/
|
||||
AugUseUnknown9 = 0x08000000, /*28^16^28^0*/
|
||||
AugUseUnknown10 = 0x10000000, /*29^16^29^0*/
|
||||
AugUseEpic25 = 0x20000000, /*30^16^30^0*/
|
||||
AugUseTest = 0x40000000, /*31^16^Test^0*/ // listed as 31^16^31^0 in 5-10 client
|
||||
AugUseAll = 0xFFFFFFFF
|
||||
};
|
||||
|
||||
/*
|
||||
** Augmentation use types (enumerated)
|
||||
**
|
||||
*/
|
||||
enum AugmentationUseTypes : uint8 {
|
||||
AugTypeNone = 0,
|
||||
AugTypeGeneralSingleStat,
|
||||
AugTypeGeneralMultipleStat,
|
||||
AugTypeGeneralSpellEffect,
|
||||
AugTypeWeaponGeneral,
|
||||
AugTypeWeaponElemDamage,
|
||||
AugTypeWeaponBaseDamage,
|
||||
AugTypeGeneralGroup,
|
||||
AugTypeGeneralRaid,
|
||||
AugTypeGeneralDragonsPoints,
|
||||
AugTypeCraftedCommon,
|
||||
AugTypeCraftedGroup1,
|
||||
AugTypeCraftedRaid1,
|
||||
AugTypeEnergeiacGroup,
|
||||
AugTypeEnergeiacRaid,
|
||||
AugTypeEmblem,
|
||||
AugTypeCraftedGroup2,
|
||||
AugTypeCraftedRaid2,
|
||||
AugTypeUnknown1,
|
||||
AugTypeUnknown2,
|
||||
AugTypeOrnamentation,
|
||||
AugTypeSpecialOrnamentation,
|
||||
AugTypeUnknown3,
|
||||
AugTypeUnknown4,
|
||||
AugTypeUnknown5,
|
||||
AugTypeUnknown6,
|
||||
AugTypeUnknown7,
|
||||
AugTypeUnknown8,
|
||||
AugTypeUnknown9,
|
||||
AugTypeUnknown10,
|
||||
AugTypeEpic25,
|
||||
AugTypeTest,
|
||||
_AugTypeCount,
|
||||
AugTypeAll = 255
|
||||
};
|
||||
|
||||
/*
|
||||
** Augmentation restriction types (in-work)
|
||||
**
|
||||
** (ref: eqstr_us.txt)
|
||||
**
|
||||
*/
|
||||
enum AugmentationRestrictionTypes : uint8 {
|
||||
/*4690*/ AugRestrAny = 0,
|
||||
/*9134*/ AugRestrArmor,
|
||||
/*9135*/ AugRestrWeapons,
|
||||
/*9136*/ AugRestr1HWeapons,
|
||||
/*9137*/ AugRestr2HWeapons,
|
||||
/*9138*/ AugRestr1HSlash,
|
||||
/*9139*/ AugRestr1HBlunt,
|
||||
/*9140*/ AugRestrPiercing,
|
||||
/*9148*/ AugRestrHandToHand,
|
||||
/*9141*/ AugRestr2HSlash,
|
||||
/*9142*/ AugRestr2HBlunt,
|
||||
/*9143*/ AugRestr2HPierce,
|
||||
/*9144*/ AugRestrBows,
|
||||
/*9145*/ AugRestrShields,
|
||||
/*8052*/ AugRestr1HSlash1HBluntOrHandToHand,
|
||||
/*9200*/ AugRestr1HBluntOrHandToHand, // no listed peq entries
|
||||
|
||||
// these three appear to be post-RoF (12-10-2012) and can not be verified until RoF (05-10-2013) is supported
|
||||
/*????*/ AugRestrUnknown1,
|
||||
/*????*/ AugRestrUnknown2,
|
||||
/*????*/ AugRestrUnknown3, // last value in peq entries
|
||||
_AugRestrCount
|
||||
|
||||
/*4687*/ //AugTypeAllItems, // ?? unknown atm
|
||||
/*4688*/ //AugTypePrestige, // ?? unknown atm
|
||||
/*4689*/ //AugTypeNonPrestige, // ?? unknown atm
|
||||
};
|
||||
|
||||
/*
|
||||
** Container use types
|
||||
**
|
||||
** This correlates to world 'object.type' (object.h/Object.cpp) as well as Item_Struct.BagType
|
||||
**
|
||||
** (ref: database, web forums and eqstr_us.txt)
|
||||
*/
|
||||
enum ContainerUseTypes : uint8
|
||||
{
|
||||
/*3400*/ BagTypeSmallBag = 0,
|
||||
/*3401*/ BagTypeLargeBag,
|
||||
/*3402*/ BagTypeQuiver,
|
||||
/*3403*/ BagTypeBeltPouch,
|
||||
/*3404*/ BagTypeWristPouch,
|
||||
/*3405*/ BagTypeBackPack,
|
||||
/*3406*/ BagTypeSmallChest,
|
||||
/*3407*/ BagTypeLargeChest,
|
||||
/*----*/ BagTypeBandolier, // <*Database Reference Only>
|
||||
/*3408*/ BagTypeMedicineBag,
|
||||
/*3409*/ BagTypeToolBox,
|
||||
/*3410*/ BagTypeLexicon,
|
||||
/*3411*/ BagTypeMortar,
|
||||
/*3412*/ BagTypeSelfDusting, // Quest container (Auto-clear contents?)
|
||||
/*3413*/ BagTypeMixingBowl,
|
||||
/*3414*/ BagTypeOven,
|
||||
/*3415*/ BagTypeSewingKit,
|
||||
/*3416*/ BagTypeForge,
|
||||
/*3417*/ BagTypeFletchingKit,
|
||||
/*3418*/ BagTypeBrewBarrel,
|
||||
/*3419*/ BagTypeJewelersKit,
|
||||
/*3420*/ BagTypePotteryWheel,
|
||||
/*3421*/ BagTypeKiln,
|
||||
/*3422*/ BagTypeKeymaker, // (no database entries as of peq rev 69)
|
||||
/*3423*/ BagTypeWizardsLexicon,
|
||||
/*3424*/ BagTypeMagesLexicon,
|
||||
/*3425*/ BagTypeNecromancersLexicon,
|
||||
/*3426*/ BagTypeEnchantersLexicon,
|
||||
/*----*/ BagTypeUnknown1, // (a coin pouch/purse?) (no database entries as of peq rev 69)
|
||||
/*----*/ BagTypeConcordanceofResearch, // <*Database Reference Only>
|
||||
/*3427*/ BagTypeAlwaysWorks, // Quest container (Never-fail combines?)
|
||||
/*3428*/ BagTypeKoadaDalForge, // High Elf
|
||||
/*3429*/ BagTypeTeirDalForge, // Dark Elf
|
||||
/*3430*/ BagTypeOggokForge, // Ogre
|
||||
/*3431*/ BagTypeStormguardForge, // Dwarf
|
||||
/*3432*/ BagTypeAkanonForge, // Gnome
|
||||
/*3433*/ BagTypeNorthmanForge, // Barbarian
|
||||
/*----*/ BagTypeUnknown2, // (no database entries as of peq rev 69)
|
||||
/*3434*/ BagTypeCabilisForge, // Iksar
|
||||
/*3435*/ BagTypeFreeportForge, // Human 1
|
||||
/*3436*/ BagTypeRoyalQeynosForge, // Human 2
|
||||
/*3439*/ BagTypeHalflingTailoringKit,
|
||||
/*3438*/ BagTypeErudTailoringKit,
|
||||
/*3440*/ BagTypeFierDalTailoringKit, // Wood Elf
|
||||
/*3441*/ BagTypeFierDalFletchingKit, // Wood Elf
|
||||
/*3437*/ BagTypeIksarPotteryWheel,
|
||||
/*3442*/ BagTypeTackleBox,
|
||||
/*3443*/ BagTypeTrollForge,
|
||||
/*3445*/ BagTypeFierDalForge, // Wood Elf
|
||||
/*3444*/ BagTypeValeForge, // Halfling
|
||||
/*3446*/ BagTypeErudForge,
|
||||
/*----*/ BagTypeTradersSatchel, // <*Database Reference Only> (db: Yellow Trader's Satchel Token?)
|
||||
/*5785*/ BagTypeGuktaForge, // Froglok (no database entries as of peq rev 69)
|
||||
/*3359*/ BagTypeAugmentationSealer,
|
||||
/*----*/ BagTypeIceCreamChurn, // <*Database Reference Only>
|
||||
/*6325*/ BagTypeTransformationmold, // Ornamentation
|
||||
/*6340*/ BagTypeDetransformationmold, // Ornamentation Stripper
|
||||
/*5400*/ BagTypeUnattuner,
|
||||
/*7684*/ BagTypeTradeskillBag,
|
||||
/*7692*/ BagTypeCollectibleBag,
|
||||
/*----*/ _BagTypeCount
|
||||
};
|
||||
|
||||
/*
|
||||
** Item Effect Types
|
||||
**
|
||||
*/
|
||||
enum {
|
||||
ET_CombatProc = 0,
|
||||
ET_ClickEffect = 1,
|
||||
ET_WornEffect = 2,
|
||||
ET_Expendable = 3,
|
||||
ET_EquipClick = 4,
|
||||
ET_ClickEffect2 = 5, //name unknown
|
||||
ET_Focus = 6,
|
||||
ET_Scroll = 7
|
||||
};
|
||||
|
||||
//SpawnAppearance types:
|
||||
#define AT_Die 0 // this causes the client to keel over and zone to bind point
|
||||
#define AT_WhoLevel 1 // the level that shows up on /who
|
||||
#define AT_Invis 3 // 0 = visible, 1 = invisible
|
||||
#define AT_PVP 4 // 0 = blue, 1 = pvp (red)
|
||||
#define AT_Light 5 // light type emitted by player (lightstone, shiny shield)
|
||||
#define AT_Anim 14 // 100=standing, 110=sitting, 111=ducking, 115=feigned, 105=looting
|
||||
#define AT_Sneak 15 // 0 = normal, 1 = sneaking
|
||||
#define AT_SpawnID 16 // server to client, sets player spawn id
|
||||
#define AT_HP 17 // Client->Server, my HP has changed (like regen tic)
|
||||
#define AT_Linkdead 18 // 0 = normal, 1 = linkdead
|
||||
#define AT_Levitate 19 // 0=off, 1=flymode, 2=levitate
|
||||
#define AT_GM 20 // 0 = normal, 1 = GM - all odd numbers seem to make it GM
|
||||
#define AT_Anon 21 // 0 = normal, 1 = anon, 2 = roleplay
|
||||
#define AT_GuildID 22
|
||||
#define AT_GuildRank 23 // 0=member, 1=officer, 2=leader
|
||||
#define AT_AFK 24 // 0 = normal, 1 = afk
|
||||
#define AT_Pet 25 // Param is EntityID of owner, or 0 for when charm breaks
|
||||
#define AT_Split 28 // 0 = normal, 1 = autosplit on
|
||||
#define AT_Size 29 // spawn's size
|
||||
#define AT_NPCName 31 // change PC's name's color to NPC color 0 = normal, 1 = npc name
|
||||
#define AT_ShowHelm 43 // 0 = do not show helmet graphic, 1 = show graphic
|
||||
#define AT_DamageState 44 // The damage state of a destructible object (0 through 4)
|
||||
//#define AT_Trader 300 // Bazzar Trader Mode
|
||||
|
||||
// solar: animations for AT_Anim
|
||||
#define ANIM_FREEZE 102
|
||||
#define ANIM_STAND 0x64
|
||||
#define ANIM_SIT 0x6e
|
||||
#define ANIM_CROUCH 0x6f
|
||||
#define ANIM_DEATH 0x73
|
||||
#define ANIM_LOOT 0x69
|
||||
|
||||
typedef enum {
|
||||
eaStanding = 0,
|
||||
eaSitting, //1
|
||||
eaCrouching, //2
|
||||
eaDead, //3
|
||||
eaLooting, //4
|
||||
_eaMaxAppearance
|
||||
} EmuAppearance;
|
||||
|
||||
// msg_type's for custom usercolors
|
||||
#define MT_Say 256
|
||||
#define MT_Tell 257
|
||||
#define MT_Group 258
|
||||
#define MT_Guild 259
|
||||
#define MT_OOC 260
|
||||
#define MT_Auction 261
|
||||
#define MT_Shout 262
|
||||
#define MT_Emote 263
|
||||
#define MT_Spells 264
|
||||
#define MT_YouHitOther 265
|
||||
#define MT_OtherHitsYou 266
|
||||
#define MT_YouMissOther 267
|
||||
#define MT_OtherMissesYou 268
|
||||
#define MT_Broadcasts 269
|
||||
#define MT_Skills 270
|
||||
#define MT_Disciplines 271
|
||||
#define MT_Unused1 272
|
||||
#define MT_DefaultText 273
|
||||
#define MT_Unused2 274
|
||||
#define MT_MerchantOffer 275
|
||||
#define MT_MerchantBuySell 276
|
||||
#define MT_YourDeath 277
|
||||
#define MT_OtherDeath 278
|
||||
#define MT_OtherHits 279
|
||||
#define MT_OtherMisses 280
|
||||
#define MT_Who 281
|
||||
#define MT_YellForHelp 282
|
||||
#define MT_NonMelee 283
|
||||
#define MT_WornOff 284
|
||||
#define MT_MoneySplit 285
|
||||
#define MT_LootMessages 286
|
||||
#define MT_DiceRoll 287
|
||||
#define MT_OtherSpells 288
|
||||
#define MT_SpellFailure 289
|
||||
#define MT_Chat 290
|
||||
#define MT_Channel1 291
|
||||
#define MT_Channel2 292
|
||||
#define MT_Channel3 293
|
||||
#define MT_Channel4 294
|
||||
#define MT_Channel5 295
|
||||
#define MT_Channel6 296
|
||||
#define MT_Channel7 297
|
||||
#define MT_Channel8 298
|
||||
#define MT_Channel9 299
|
||||
#define MT_Channel10 300
|
||||
#define MT_CritMelee 301
|
||||
#define MT_SpellCrits 302
|
||||
#define MT_TooFarAway 303
|
||||
#define MT_NPCRampage 304
|
||||
#define MT_NPCFlurry 305
|
||||
#define MT_NPCEnrage 306
|
||||
#define MT_SayEcho 307
|
||||
#define MT_TellEcho 308
|
||||
#define MT_GroupEcho 309
|
||||
#define MT_GuildEcho 310
|
||||
#define MT_OOCEcho 311
|
||||
#define MT_AuctionEcho 312
|
||||
#define MT_ShoutECho 313
|
||||
#define MT_EmoteEcho 314
|
||||
#define MT_Chat1Echo 315
|
||||
#define MT_Chat2Echo 316
|
||||
#define MT_Chat3Echo 317
|
||||
#define MT_Chat4Echo 318
|
||||
#define MT_Chat5Echo 319
|
||||
#define MT_Chat6Echo 320
|
||||
#define MT_Chat7Echo 321
|
||||
#define MT_Chat8Echo 322
|
||||
#define MT_Chat9Echo 323
|
||||
#define MT_Chat10Echo 324
|
||||
#define MT_DoTDamage 325
|
||||
#define MT_ItemLink 326
|
||||
#define MT_RaidSay 327
|
||||
#define MT_MyPet 328
|
||||
#define MT_DS 329
|
||||
#define MT_Leadership 330
|
||||
#define MT_PetFlurry 331
|
||||
#define MT_PetCrit 332
|
||||
#define MT_FocusEffect 333
|
||||
#define MT_Experience 334
|
||||
#define MT_System 335
|
||||
#define MT_PetSpell 336
|
||||
#define MT_PetResponse 337
|
||||
#define MT_ItemSpeech 338
|
||||
#define MT_StrikeThrough 339
|
||||
#define MT_Stun 340
|
||||
|
||||
//from showeq
|
||||
enum ChatColor
|
||||
{
|
||||
CC_Default = 0,
|
||||
CC_DarkGrey = 1,
|
||||
CC_DarkGreen = 2,
|
||||
CC_DarkBlue = 3,
|
||||
CC_Purple = 5,
|
||||
CC_LightGrey = 6,
|
||||
CC_User_Say = 256,
|
||||
CC_User_Tell = 257,
|
||||
CC_User_Group = 258,
|
||||
CC_User_Guild = 259,
|
||||
CC_User_OOC = 260,
|
||||
CC_User_Auction = 261,
|
||||
CC_User_Shout = 262,
|
||||
CC_User_Emote = 263,
|
||||
CC_User_Spells = 264,
|
||||
CC_User_YouHitOther = 265,
|
||||
CC_User_OtherHitYou = 266,
|
||||
CC_User_YouMissOther = 267,
|
||||
CC_User_OtherMissYou = 268,
|
||||
CC_User_Duels = 269,
|
||||
CC_User_Skills = 270,
|
||||
CC_User_Disciplines = 271,
|
||||
CC_User_Default = 273,
|
||||
CC_User_MerchantOffer = 275,
|
||||
CC_User_MerchantExchange = 276,
|
||||
CC_User_YourDeath = 277,
|
||||
CC_User_OtherDeath = 278,
|
||||
CC_User_OtherHitOther = 279,
|
||||
CC_User_OtherMissOther = 280,
|
||||
CC_User_Who = 281,
|
||||
CC_User_Yell = 282,
|
||||
CC_User_NonMelee = 283,
|
||||
CC_User_SpellWornOff = 284,
|
||||
CC_User_MoneySplit = 285,
|
||||
CC_User_Loot = 286,
|
||||
CC_User_Random = 287,
|
||||
CC_User_OtherSpells = 288,
|
||||
CC_User_SpellFailure = 289,
|
||||
CC_User_ChatChannel = 290,
|
||||
CC_User_Chat1 = 291,
|
||||
CC_User_Chat2 = 292,
|
||||
CC_User_Chat3 = 293,
|
||||
CC_User_Chat4 = 294,
|
||||
CC_User_Chat5 = 295,
|
||||
CC_User_Chat6 = 296,
|
||||
CC_User_Chat7 = 297,
|
||||
CC_User_Chat8 = 298,
|
||||
CC_User_Chat9 = 299,
|
||||
CC_User_Chat10 = 300,
|
||||
CC_User_MeleeCrit = 301,
|
||||
CC_User_SpellCrit = 302,
|
||||
CC_User_TooFarAway = 303,
|
||||
CC_User_NPCRampage = 304,
|
||||
CC_User_NPCFurry = 305,
|
||||
CC_User_NPCEnrage = 306,
|
||||
CC_User_EchoSay = 307,
|
||||
CC_User_EchoTell = 308,
|
||||
CC_User_EchoGroup = 309,
|
||||
CC_User_EchoGuild = 310,
|
||||
CC_User_EchoOOC = 311,
|
||||
CC_User_EchoAuction = 312,
|
||||
CC_User_EchoShout = 313,
|
||||
CC_User_EchoEmote = 314,
|
||||
CC_User_EchoChat1 = 315,
|
||||
CC_User_EchoChat2 = 316,
|
||||
CC_User_EchoChat3 = 317,
|
||||
CC_User_EchoChat4 = 318,
|
||||
CC_User_EchoChat5 = 319,
|
||||
CC_User_EchoChat6 = 320,
|
||||
CC_User_EchoChat7 = 321,
|
||||
CC_User_EchoChat8 = 322,
|
||||
CC_User_EchoChat9 = 323,
|
||||
CC_User_EchoChat10 = 324,
|
||||
CC_User_UnusedAtThisTime = 325,
|
||||
CC_User_ItemTags = 326,
|
||||
CC_User_RaidSay = 327,
|
||||
CC_User_MyPet = 328,
|
||||
CC_User_DamageShield = 329,
|
||||
};
|
||||
|
||||
//ZoneChange_Struct->success values
|
||||
#define ZONE_ERROR_NOMSG 0
|
||||
#define ZONE_ERROR_NOTREADY -1
|
||||
#define ZONE_ERROR_VALIDPC -2
|
||||
#define ZONE_ERROR_STORYZONE -3
|
||||
#define ZONE_ERROR_NOEXPANSION -6
|
||||
#define ZONE_ERROR_NOEXPERIENCE -7
|
||||
|
||||
|
||||
typedef enum {
|
||||
FilterNone = 0,
|
||||
FilterGuildChat = 1, //0=hide, 1=show
|
||||
FilterSocials = 2, //0=hide, 1=show
|
||||
FilterGroupChat = 3, //0=hide, 1=show
|
||||
FilterShouts = 4, //0=hide, 1=show
|
||||
FilterAuctions = 5, //0=hide, 1=show
|
||||
FilterOOC = 6, //0=hide, 1=show
|
||||
FilterBadWords = 7, //0=hide, 1=show
|
||||
FilterPCSpells = 8, //0=show, 1=hide, 2=group only
|
||||
FilterNPCSpells = 9, //0=show, 1=hide
|
||||
FilterBardSongs = 10, //0=show, 1=mine only, 2=group only, 3=hide
|
||||
FilterSpellCrits = 11, //0=show, 1=mine only, 2=hide
|
||||
FilterMeleeCrits = 12, //0=show, 1=hide
|
||||
FilterSpellDamage = 13, //0=show, 1=mine only, 2=hide
|
||||
FilterMyMisses = 14, //0=hide, 1=show
|
||||
FilterOthersMiss = 15, //0=hide, 1=show
|
||||
FilterOthersHit = 16, //0=hide, 1=show
|
||||
FilterMissedMe = 17, //0=hide, 1=show
|
||||
FilterDamageShields = 18, //0=show, 1=hide
|
||||
FilterDOT = 19, //0=show, 1=hide
|
||||
FilterPetHits = 20, //0=show, 1=hide
|
||||
FilterPetMisses = 21, //0=show, 1=hide
|
||||
FilterFocusEffects = 22, //0=show, 1=hide
|
||||
FilterPetSpells = 23, //0=show, 1=hide
|
||||
FilterHealOverTime = 24, //0=show, 1=hide
|
||||
FilterUnknown25 = 25,
|
||||
FilterUnknown26 = 26,
|
||||
FilterUnknown27 = 27,
|
||||
FilterUnknown28 = 28,
|
||||
_FilterCount
|
||||
} eqFilterType;
|
||||
|
||||
typedef enum {
|
||||
FilterHide,
|
||||
FilterShow,
|
||||
FilterShowGroupOnly,
|
||||
FilterShowSelfOnly
|
||||
} eqFilterMode;
|
||||
|
||||
#define STAT_STR 0
|
||||
#define STAT_STA 1
|
||||
#define STAT_AGI 2
|
||||
#define STAT_DEX 3
|
||||
#define STAT_INT 4
|
||||
#define STAT_WIS 5
|
||||
#define STAT_CHA 6
|
||||
#define STAT_MAGIC 7
|
||||
#define STAT_COLD 8
|
||||
#define STAT_FIRE 9
|
||||
#define STAT_POISON 10
|
||||
#define STAT_DISEASE 11
|
||||
#define STAT_MANA 12
|
||||
#define STAT_HP 13
|
||||
#define STAT_AC 14
|
||||
#define STAT_ENDURANCE 15
|
||||
#define STAT_ATTACK 16
|
||||
#define STAT_HP_REGEN 17
|
||||
#define STAT_MANA_REGEN 18
|
||||
#define STAT_HASTE 19
|
||||
#define STAT_DAMAGE_SHIELD 20
|
||||
|
||||
/*
|
||||
** Recast timer types. Used as an off set to charProfileStruct timers.
|
||||
**
|
||||
** (Another orphaned enumeration...)
|
||||
*/
|
||||
enum RecastTimerTypes
|
||||
{
|
||||
RecTimer_0 = 0,
|
||||
RecTimer_1,
|
||||
RecTimer_WeaponHealClick, // 2
|
||||
RecTimer_MuramiteBaneNukeClick, // 3
|
||||
RecTimer_4,
|
||||
RecTimer_DispellClick, // 5 (also click heal orbs?)
|
||||
RecTimer_Epic, // 6
|
||||
RecTimer_OoWBPClick, // 7
|
||||
RecTimer_VishQuestClassItem, // 8
|
||||
RecTimer_HealPotion, // 9
|
||||
RecTimer_10,
|
||||
RecTimer_11,
|
||||
RecTimer_12,
|
||||
RecTimer_13,
|
||||
RecTimer_14,
|
||||
RecTimer_15,
|
||||
RecTimer_16,
|
||||
RecTimer_17,
|
||||
RecTimer_18,
|
||||
RecTimer_ModRod, // 19
|
||||
_RecTimerCount
|
||||
};
|
||||
|
||||
enum GroupUpdateAction
|
||||
{
|
||||
GUA_Joined = 0,
|
||||
GUA_Left = 1,
|
||||
GUA_LastLeft = 6,
|
||||
GUA_FullGroupInfo = 7,
|
||||
GUA_MakeLeader = 8,
|
||||
GUA_Started = 9
|
||||
};
|
||||
|
||||
static const uint8 DamageTypeSomething = 0x1C; //0x1c is something...
|
||||
static const uint8 DamageTypeFalling = 0xFC;
|
||||
static const uint8 DamageTypeSpell = 0xE7;
|
||||
static const uint8 DamageTypeUnknown = 0xFF;
|
||||
|
||||
/*
|
||||
** Skill damage types
|
||||
**
|
||||
** (indexed by 'Skill' of SkillUseTypes)
|
||||
*/
|
||||
static const uint8 SkillDamageTypes[HIGHEST_SKILL + 1] = // change to _SkillServerArraySize once activated
|
||||
{
|
||||
/*1HBlunt*/ 0,
|
||||
/*1HSlashing*/ 1,
|
||||
/*2HBlunt*/ 0,
|
||||
/*2HSlashing*/ 1,
|
||||
/*Abjuration*/ DamageTypeSpell,
|
||||
/*Alteration*/ DamageTypeSpell,
|
||||
/*ApplyPoison*/ DamageTypeUnknown,
|
||||
/*Archery*/ 7,
|
||||
/*Backstab*/ 8,
|
||||
/*BindWound*/ DamageTypeUnknown,
|
||||
/*Bash*/ 10,
|
||||
/*Block*/ DamageTypeUnknown,
|
||||
/*BrassInstruments*/ DamageTypeSpell,
|
||||
/*Channeling*/ DamageTypeUnknown,
|
||||
/*Conjuration*/ DamageTypeSpell,
|
||||
/*Defense*/ DamageTypeUnknown,
|
||||
/*Disarm*/ DamageTypeUnknown,
|
||||
/*DisarmTraps*/ DamageTypeUnknown,
|
||||
/*Divination*/ DamageTypeSpell,
|
||||
/*Dodge*/ DamageTypeUnknown,
|
||||
/*DoubleAttack*/ DamageTypeUnknown,
|
||||
/*DragonPunch*/ 21,
|
||||
/*DualWield*/ DamageTypeUnknown,
|
||||
/*EagleStrike*/ 23,
|
||||
/*Evocation*/ DamageTypeSpell,
|
||||
/*FeignDeath*/ 4,
|
||||
/*FlyingKick*/ 30,
|
||||
/*Forage*/ DamageTypeUnknown,
|
||||
/*HandtoHand*/ 4,
|
||||
/*Hide*/ DamageTypeUnknown,
|
||||
/*Kick*/ 30,
|
||||
/*Meditate*/ DamageTypeUnknown,
|
||||
/*Mend*/ DamageTypeUnknown,
|
||||
/*Offense*/ DamageTypeUnknown,
|
||||
/*Parry*/ DamageTypeUnknown,
|
||||
/*PickLock*/ DamageTypeUnknown,
|
||||
/*1HPiercing*/ 36,
|
||||
/*Riposte*/ DamageTypeUnknown,
|
||||
/*RoundKick*/ 30,
|
||||
/*SafeFall*/ DamageTypeUnknown,
|
||||
/*SsenseHeading*/ DamageTypeUnknown,
|
||||
/*Singing*/ DamageTypeSpell,
|
||||
/*Sneak*/ DamageTypeUnknown,
|
||||
/*SpecializeAbjure*/ DamageTypeUnknown,
|
||||
/*SpecializeAlteration*/ DamageTypeUnknown,
|
||||
/*SpecializeConjuration*/ DamageTypeUnknown,
|
||||
/*SpecializeDivination*/ DamageTypeUnknown,
|
||||
/*SpecializeEvocation*/ DamageTypeUnknown,
|
||||
/*PickPockets*/ DamageTypeUnknown,
|
||||
/*StringedInstruments*/ DamageTypeSpell,
|
||||
/*Swimming*/ DamageTypeUnknown,
|
||||
/*Throwing*/ 51,
|
||||
/*TigerClaw*/ 23,
|
||||
/*Tracking*/ DamageTypeUnknown,
|
||||
/*WindInstruments*/ DamageTypeSpell,
|
||||
/*Fishing*/ DamageTypeUnknown,
|
||||
/*MakePoison*/ DamageTypeUnknown,
|
||||
/*Tinkering*/ DamageTypeUnknown,
|
||||
/*Research*/ DamageTypeUnknown,
|
||||
/*Alchemy*/ DamageTypeUnknown,
|
||||
/*Baking*/ DamageTypeUnknown,
|
||||
/*Tailoring*/ DamageTypeUnknown,
|
||||
/*SenseTraps*/ DamageTypeUnknown,
|
||||
/*Blacksmithing*/ DamageTypeUnknown,
|
||||
/*Fletching*/ DamageTypeUnknown,
|
||||
/*Brewing*/ DamageTypeUnknown,
|
||||
/*AlcoholTolerance*/ DamageTypeUnknown,
|
||||
/*Begging*/ DamageTypeUnknown,
|
||||
/*JewelryMaking*/ DamageTypeUnknown,
|
||||
/*Pottery*/ DamageTypeUnknown,
|
||||
/*PercussionInstruments*/ DamageTypeSpell,
|
||||
/*Intimidation*/ DamageTypeUnknown,
|
||||
/*Berserking*/ DamageTypeUnknown,
|
||||
/*Taunt*/ DamageTypeUnknown,
|
||||
/*Frenzy*/ 74 //,
|
||||
// /*RemoveTrap*/ DamageTypeUnknown, // Needs research (set for SenseTrap value)
|
||||
// /*TripleAttack*/ DamageTypeUnknown, // Needs research (set for DoubleAttack value)
|
||||
// /*2HPiercing*/ 36 // Needs research (set for 1HPiercing value - similar to slash/blunt)
|
||||
};
|
||||
|
||||
/*
|
||||
** Material use slots
|
||||
**
|
||||
*/
|
||||
enum MaterialUseSlots : uint8
|
||||
{
|
||||
MaterialHead = 0,
|
||||
MaterialChest,
|
||||
MaterialArms,
|
||||
MaterialWrist,
|
||||
MaterialHands,
|
||||
MaterialLegs,
|
||||
MaterialFeet,
|
||||
MaterialPrimary,
|
||||
MaterialSecondary,
|
||||
_MaterialCount,
|
||||
_MaterialInvalid = 255
|
||||
};
|
||||
|
||||
/*
|
||||
// Used for worn NPC inventory tracking. NPCs don't use
|
||||
// augments, so only the basic slots need to be kept track of.
|
||||
#define MAX_WORN_INVENTORY 22
|
||||
*/
|
||||
|
||||
/*
|
||||
** Inventory Slot Equipment Enum
|
||||
** Mostly used for third-party tools to reference inventory slots
|
||||
**
|
||||
** [pre-HoT]
|
||||
** NOTE: Numbering for personal inventory goes top to bottom, then left to right
|
||||
** It's the opposite for inside bags: left to right, then top to bottom
|
||||
** Example:
|
||||
** Inventory: Containers:
|
||||
** 1 5 1 2
|
||||
** 2 6 3 4
|
||||
** 3 7 5 6
|
||||
** 4 8 7 8
|
||||
** - - 9 10
|
||||
**
|
||||
** [HoT and Higher]
|
||||
** Note: Numbering for inventory and bags goes left to right, then top to bottom
|
||||
** Example:
|
||||
** Inventory: Containers:
|
||||
** 1 2 1 2
|
||||
** 3 4 3 4
|
||||
** 5 6 5 6
|
||||
** 7 8 7 8
|
||||
** 9 10 9 10
|
||||
** - - 11 12 [Note: Additional slots are only available in RoF and higher]
|
||||
**
|
||||
*/
|
||||
|
||||
#define INVALID_INDEX -1
|
||||
#define NOT_USED 0
|
||||
#define NO_ITEM 0
|
||||
|
||||
#define DB_ITEM_CONTAINER_SIZE 255 // probably need to move to database.h
|
||||
|
||||
// yes..these are redundant... but, they help to identify and define what is actually being performed
|
||||
// plus, since they're pre-op's, they don't affect the actual binary size
|
||||
#define MAP_BEGIN 0
|
||||
#define MAIN_BEGIN 0
|
||||
#define SUB_BEGIN 0
|
||||
#define AUG_BEGIN 0
|
||||
|
||||
namespace legacy {
|
||||
// this is for perl and other legacy systems
|
||||
|
||||
typedef enum {
|
||||
SLOT_CHARM = 0,
|
||||
SLOT_EAR01 = 1,
|
||||
SLOT_HEAD = 2,
|
||||
SLOT_FACE = 3,
|
||||
SLOT_EAR02 = 4,
|
||||
SLOT_NECK = 5,
|
||||
SLOT_SHOULDER = 6,
|
||||
SLOT_ARMS = 7,
|
||||
SLOT_BACK = 8,
|
||||
SLOT_BRACER01 = 9,
|
||||
SLOT_BRACER02 = 10,
|
||||
SLOT_RANGE = 11,
|
||||
SLOT_HANDS = 12,
|
||||
SLOT_PRIMARY = 13,
|
||||
SLOT_SECONDARY = 14,
|
||||
SLOT_RING01 = 15,
|
||||
SLOT_RING02 = 16,
|
||||
SLOT_CHEST = 17,
|
||||
SLOT_LEGS = 18,
|
||||
SLOT_FEET = 19,
|
||||
SLOT_WAIST = 20,
|
||||
SLOT_POWER_SOURCE = 9999,
|
||||
SLOT_AMMO = 21,
|
||||
SLOT_GENERAL_1 = 22,
|
||||
SLOT_GENERAL_2 = 23,
|
||||
SLOT_GENERAL_3 = 24,
|
||||
SLOT_GENERAL_4 = 25,
|
||||
SLOT_GENERAL_5 = 26,
|
||||
SLOT_GENERAL_6 = 27,
|
||||
SLOT_GENERAL_7 = 28,
|
||||
SLOT_GENERAL_8 = 29,
|
||||
//SLOT_GENERAL_9 = not supported
|
||||
//SLOT_GENERAL_10 = not supported
|
||||
SLOT_CURSOR = 30,
|
||||
SLOT_CURSOR_END = (int16)0xFFFE, // I hope no one is using this...
|
||||
SLOT_TRADESKILL = 1000,
|
||||
SLOT_AUGMENT = 1001,
|
||||
SLOT_INVALID = (int16)0xFFFF,
|
||||
|
||||
SLOT_POSSESSIONS_BEGIN = 0,
|
||||
SLOT_POSSESSIONS_END = 30,
|
||||
|
||||
SLOT_EQUIPMENT_BEGIN = 0,
|
||||
SLOT_EQUIPMENT_END = 21,
|
||||
|
||||
SLOT_PERSONAL_BEGIN = 22,
|
||||
SLOT_PERSONAL_END = 29,
|
||||
SLOT_PERSONAL_BAGS_BEGIN = 251,
|
||||
SLOT_PERSONAL_BAGS_END = 330,
|
||||
|
||||
SLOT_CURSOR_BAG_BEGIN = 331,
|
||||
SLOT_CURSOR_BAG_END = 340,
|
||||
|
||||
SLOT_TRIBUTE_BEGIN = 400,
|
||||
SLOT_TRIBUTE_END = 404,
|
||||
|
||||
SLOT_BANK_BEGIN = 2000,
|
||||
SLOT_BANK_END = 2023,
|
||||
SLOT_BANK_BAGS_BEGIN = 2031,
|
||||
SLOT_BANK_BAGS_END = 2270,
|
||||
|
||||
SLOT_SHARED_BANK_BEGIN = 2500,
|
||||
SLOT_SHARED_BANK_END = 2501,
|
||||
SLOT_SHARED_BANK_BAGS_BEGIN = 2531,
|
||||
SLOT_SHARED_BANK_BAGS_END = 2550,
|
||||
|
||||
SLOT_TRADE_BEGIN = 3000,
|
||||
SLOT_TRADE_END = 3007,
|
||||
SLOT_TRADE_BAGS_BEGIN = 3031,
|
||||
SLOT_TRADE_BAGS_END = 3110,
|
||||
|
||||
SLOT_WORLD_BEGIN = 4000,
|
||||
SLOT_WORLD_END = 4009
|
||||
} InventorySlot;
|
||||
}
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
EQEMu: Everquest Server Emulator
|
||||
|
||||
Copyright (C) 2001-2014 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
*/
|
||||
|
||||
#ifndef EQ_DICTIONARY_H
|
||||
#define EQ_DICTIONARY_H
|
||||
|
||||
#include "types.h"
|
||||
#include "eq_constants.h"
|
||||
#include "clientversions.h"
|
||||
#include <string>
|
||||
#include "../common/patches/client62_constants.h"
|
||||
#include "../common/patches/titanium_constants.h"
|
||||
#include "../common/patches/sof_constants.h"
|
||||
#include "../common/patches/sod_constants.h"
|
||||
#include "../common/patches/underfoot_constants.h"
|
||||
#include "../common/patches/rof_constants.h"
|
||||
#include "../common/patches/rof2_constants.h"
|
||||
|
||||
// *** DO NOT CHANGE without a full understanding of the consequences..the server is set up to use these settings explicitly!! ***
|
||||
// *** You will cause compilation failures and corrupt your database if partial or incorrect attempts to change them are made!! ***
|
||||
|
||||
// Hard-coded values usually indicate that further research is needed and the values given are from the old (known) system
|
||||
|
||||
using namespace RoF2::maps; // server inventory maps enumeration (code and database sync'd to reference)
|
||||
using namespace RoF2::slots; // server possessions slots enumeration (code and database sync'd to reference)
|
||||
|
||||
class EmuConstants {
|
||||
// an immutable value is required to initialize arrays, etc... use this class as a repository for those
|
||||
public:
|
||||
// database
|
||||
static const EQClientVersion CHARACTER_CREATION_CLIENT = EQClientRoF; // adjust according to starting item placement and target client
|
||||
|
||||
// inventory
|
||||
static uint16 InventoryMapSize(int16 map);
|
||||
//static std::string InventoryLocationName(Location_Struct location);
|
||||
static std::string InventoryMapName(int16 map);
|
||||
static std::string InventoryMainName(int16 main);
|
||||
static std::string InventorySubName(int16 sub);
|
||||
static std::string InventoryAugName(int16 aug);
|
||||
|
||||
// these are currently hard-coded for existing inventory system..do not use in place of special client version handlers until ready
|
||||
static const uint16 MAP_POSSESSIONS_SIZE = RoF2::consts::MAP_POSSESSIONS_SIZE;
|
||||
static const uint16 MAP_BANK_SIZE = RoF2::consts::MAP_BANK_SIZE;
|
||||
static const uint16 MAP_SHARED_BANK_SIZE = RoF2::consts::MAP_SHARED_BANK_SIZE;
|
||||
static const uint16 MAP_TRADE_SIZE = RoF2::consts::MAP_TRADE_SIZE;
|
||||
static const uint16 MAP_WORLD_SIZE = RoF2::consts::MAP_WORLD_SIZE;
|
||||
static const uint16 MAP_LIMBO_SIZE = RoF2::consts::MAP_LIMBO_SIZE;
|
||||
static const uint16 MAP_TRIBUTE_SIZE = Titanium::consts::MAP_TRIBUTE_SIZE; // server is setup for 'presumed' Titanium value of 5..if Titanium::consts is changed, hard-code this to '5' until server/db is updated
|
||||
static const uint16 MAP_TROPHY_TRIBUTE_SIZE = 0;
|
||||
static const uint16 MAP_GUILD_TRIBUTE_SIZE = 0;
|
||||
static const uint16 MAP_MERCHANT_SIZE = 0;
|
||||
static const uint16 MAP_DELETED_SIZE = 0;
|
||||
static const uint16 MAP_CORPSE_SIZE = RoF2::consts::MAP_CORPSE_SIZE; // no bitmask use..limits to size of client corpse window (see EQLimits::InventoryMapSize(MapCorpse, <EQClientVersion))
|
||||
static const uint16 MAP_BAZAAR_SIZE = Titanium::consts::MAP_BAZAAR_SIZE;
|
||||
static const uint16 MAP_INSPECT_SIZE = RoF2::consts::MAP_INSPECT_SIZE;
|
||||
static const uint16 MAP_REAL_ESTATE_SIZE = 0;
|
||||
static const uint16 MAP_VIEW_MOD_PC_SIZE = NOT_USED;
|
||||
static const uint16 MAP_VIEW_MOD_BANK_SIZE = NOT_USED;
|
||||
static const uint16 MAP_VIEW_MOD_SHARED_BANK_SIZE = NOT_USED;
|
||||
static const uint16 MAP_VIEW_MOD_LIMBO_SIZE = NOT_USED;
|
||||
static const uint16 MAP_ALT_STORAGE_SIZE = 0;
|
||||
static const uint16 MAP_ARCHIVED_SIZE = 0;
|
||||
static const uint16 MAP_MAIL_SIZE = 0;
|
||||
static const uint16 MAP_GUILD_TROPHY_TRIBUTE_SIZE = 0;
|
||||
static const uint16 MAP_KRONO_SIZE = RoF::consts::MAP_KRONO_SIZE;
|
||||
static const uint16 MAP_OTHER_SIZE = 0;
|
||||
|
||||
// most of these definitions will go away with the structure-based system..this maintains compatibility for now
|
||||
// (these are mainly to assign specific values to constants used in conversions and to identify per-client ranges/offsets)
|
||||
static const int16 EQUIPMENT_BEGIN = RoF2::consts::EQUIPMENT_BEGIN;
|
||||
static const int16 EQUIPMENT_END = RoF2::consts::EQUIPMENT_END;
|
||||
static const uint16 EQUIPMENT_SIZE = RoF2::consts::EQUIPMENT_SIZE;
|
||||
|
||||
static const int16 GENERAL_BEGIN = RoF2::consts::GENERAL_BEGIN;
|
||||
static const int16 GENERAL_END = RoF2::consts::GENERAL_END;
|
||||
static const uint16 GENERAL_SIZE = RoF2::consts::GENERAL_SIZE;
|
||||
static const int16 GENERAL_BAGS_BEGIN = RoF2::consts::GENERAL_BAGS_BEGIN;
|
||||
static const int16 GENERAL_BAGS_END_OFFSET = RoF2::consts::GENERAL_BAGS_END_OFFSET;
|
||||
static const int16 GENERAL_BAGS_END = RoF2::consts::GENERAL_BAGS_END;
|
||||
|
||||
static const int16 CURSOR_BAG_BEGIN = RoF2::consts::CURSOR_BAG_BEGIN;
|
||||
static const int16 CURSOR_BAG_END_OFFSET = RoF2::consts::CURSOR_BAG_END_OFFSET;
|
||||
static const int16 CURSOR_BAG_END = RoF2::consts::CURSOR_BAG_END;
|
||||
|
||||
static const int16 BANK_BEGIN = RoF2::consts::BANK_BEGIN;
|
||||
static const int16 BANK_END = RoF2::consts::BANK_END;
|
||||
static const int16 BANK_BAGS_BEGIN = RoF2::consts::BANK_BAGS_BEGIN;
|
||||
static const int16 BANK_BAGS_END_OFFSET = RoF2::consts::BANK_BAGS_END_OFFSET;
|
||||
static const int16 BANK_BAGS_END = RoF2::consts::BANK_BAGS_END;
|
||||
|
||||
static const int16 SHARED_BANK_BEGIN = RoF2::consts::SHARED_BANK_BEGIN;
|
||||
static const int16 SHARED_BANK_END = RoF2::consts::SHARED_BANK_END;
|
||||
static const int16 SHARED_BANK_BAGS_BEGIN = RoF2::consts::SHARED_BANK_BAGS_BEGIN;
|
||||
static const int16 SHARED_BANK_BAGS_END_OFFSET = RoF2::consts::SHARED_BANK_BAGS_END_OFFSET;
|
||||
static const int16 SHARED_BANK_BAGS_END = RoF2::consts::SHARED_BANK_BAGS_END;
|
||||
|
||||
static const int16 TRADE_BEGIN = RoF2::consts::TRADE_BEGIN;
|
||||
static const int16 TRADE_END = RoF2::consts::TRADE_END;
|
||||
static const int16 TRADE_NPC_END = RoF2::consts::TRADE_NPC_END;
|
||||
static const int16 TRADE_NPC_SIZE = RoF2::consts::TRADE_NPC_SIZE;
|
||||
static const int16 TRADE_BAGS_BEGIN = RoF2::consts::TRADE_BAGS_BEGIN;
|
||||
static const int16 TRADE_BAGS_END_OFFSET = RoF2::consts::TRADE_BAGS_END_OFFSET;
|
||||
static const int16 TRADE_BAGS_END = RoF2::consts::TRADE_BAGS_END;
|
||||
|
||||
static const int16 WORLD_BEGIN = RoF2::consts::WORLD_BEGIN;
|
||||
static const int16 WORLD_END = RoF2::consts::WORLD_END;
|
||||
static const int16 WORLD_SIZE = MAP_WORLD_SIZE;
|
||||
|
||||
static const int16 TRIBUTE_BEGIN = RoF2::consts::TRIBUTE_BEGIN;
|
||||
static const int16 TRIBUTE_END = RoF2::consts::TRIBUTE_END;
|
||||
static const int16 TRIBUTE_SIZE = MAP_TRIBUTE_SIZE;
|
||||
|
||||
static const int16 CORPSE_BEGIN = RoF2::consts::CORPSE_BEGIN;
|
||||
static const int16 CORPSE_END = RoF2::consts::CORPSE_END;
|
||||
|
||||
static const int16 MATERIAL_BEGIN = Underfoot::consts::MATERIAL_BEGIN;
|
||||
static const int16 MATERIAL_END = Underfoot::consts::MATERIAL_END;
|
||||
static const int16 MATERIAL_TINT_END = Underfoot::consts::MATERIAL_TINT_END;
|
||||
static const int16 MATERIAL_SIZE = Underfoot::consts::MATERIAL_SIZE;
|
||||
|
||||
// items
|
||||
// common and container sizes will not increase until the new 'location' struct is implemented
|
||||
static const uint16 ITEM_COMMON_SIZE = Underfoot::consts::ITEM_COMMON_SIZE;
|
||||
static const uint16 ITEM_CONTAINER_SIZE = Underfoot::consts::ITEM_CONTAINER_SIZE;
|
||||
|
||||
// player profile
|
||||
//static const uint32 CLASS_BITMASK = 0; // needs value
|
||||
//static const uint32 RACE_BITMASK = 0; // needs value
|
||||
|
||||
// BANDOLIERS_COUNT sets maximum limit..active limit will need to be handled by the appropriate AA
|
||||
static const uint32 BANDOLIERS_COUNT = Titanium::consts::BANDOLIERS_COUNT; // count = number of bandolier instances
|
||||
static const uint32 BANDOLIER_SIZE = Titanium::consts::BANDOLIER_SIZE; // size = number of equipment slots in bandolier instance
|
||||
static const uint32 POTION_BELT_SIZE = Titanium::consts::POTION_BELT_SIZE;
|
||||
|
||||
// legacy-related functions
|
||||
//static int ServerToPerlSlot(int slot); // encode
|
||||
//static int PerlToServerSlot(int slot); // decode
|
||||
};
|
||||
|
||||
class EQLimits {
|
||||
// values should default to a non-beneficial value..unless value conflicts with intended operation
|
||||
//
|
||||
// EmuConstants may be used as references..but, not every reference needs to be in EmuConstants (i.e., AllowsEmptyBagInBag(), CoinHasWeight(), etc...)
|
||||
public:
|
||||
// client version validation (checks to avoid crashing zone server when accessing reference arrays)
|
||||
// use this inside of class Client (limits to actual clients)
|
||||
static bool IsValidClientVersion(uint32 version);
|
||||
static uint32 ValidateClientVersion(uint32 version);
|
||||
static EQClientVersion ValidateClientVersion(EQClientVersion version);
|
||||
|
||||
// basically..any non-client classes - do not when setting a valid client
|
||||
static bool IsValidNPCVersion(uint32 version);
|
||||
static uint32 ValidateNPCVersion(uint32 version);
|
||||
static EQClientVersion ValidateNPCVersion(EQClientVersion version);
|
||||
|
||||
// these are 'universal' - do not when setting a valid client
|
||||
static bool IsValidMobVersion(uint32 version);
|
||||
static uint32 ValidateMobVersion(uint32 version);
|
||||
static EQClientVersion ValidateMobVersion(EQClientVersion version);
|
||||
|
||||
// inventory
|
||||
static uint16 InventoryMapSize(int16 map, uint32 version);
|
||||
static uint64 PossessionsBitmask(uint32 version);
|
||||
static uint64 EquipmentBitmask(uint32 version);
|
||||
static uint64 GeneralBitmask(uint32 version);
|
||||
static uint64 CursorBitmask(uint32 version);
|
||||
|
||||
static bool AllowsEmptyBagInBag(uint32 version);
|
||||
static bool AllowsClickCastFromBag(uint32 version);
|
||||
|
||||
// items
|
||||
static uint16 ItemCommonSize(uint32 version);
|
||||
static uint16 ItemContainerSize(uint32 version);
|
||||
|
||||
// player profile
|
||||
static bool CoinHasWeight(uint32 version);
|
||||
|
||||
static uint32 BandoliersCount(uint32 version);
|
||||
static uint32 BandolierSize(uint32 version);
|
||||
|
||||
static uint32 PotionBeltSize(uint32 version);
|
||||
};
|
||||
|
||||
#endif /* EQ_LIMITS_H */
|
||||
|
||||
/*
|
||||
Working Notes:
|
||||
--------------
|
||||
|
||||
- full review of client_packet.cpp and client translators needed
|
||||
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,509 @@
|
||||
/*
|
||||
Copyright (C) 2005 Michael S. Finger
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "debug.h"
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include "eq_packet.h"
|
||||
#include "misc.h"
|
||||
#include "op_codes.h"
|
||||
#include "crc16.h"
|
||||
#include "platform.h"
|
||||
#ifndef STATIC_OPCODE
|
||||
#include "opcodemgr.h"
|
||||
#endif
|
||||
#include "packet_dump.h"
|
||||
#include "packet_functions.h"
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
EQPacket::EQPacket(EmuOpcode op, const unsigned char *buf, uint32 len)
|
||||
: BasePacket(buf, len),
|
||||
emu_opcode(op)
|
||||
{
|
||||
}
|
||||
|
||||
void EQPacket::build_raw_header_dump(char *buffer, uint16 seq) const {
|
||||
BasePacket::build_raw_header_dump(buffer, seq);
|
||||
buffer += strlen(buffer);
|
||||
|
||||
buffer += sprintf(buffer, "[EmuOpCode 0x%04x Size=%u]\n", emu_opcode, size);
|
||||
}
|
||||
|
||||
void EQPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
char buff[196];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
}
|
||||
|
||||
void EQPacket::build_header_dump(char *buffer) const {
|
||||
sprintf(buffer, "[EmuOpCode 0x%04x Size=%u]", emu_opcode, size);
|
||||
}
|
||||
|
||||
void EQPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
dIP=long2ip(dst_ip);
|
||||
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
||||
}
|
||||
if (seq != 0xffff)
|
||||
fprintf(to, "[Seq=%u] ",seq);
|
||||
|
||||
fprintf(to, "[EmuOpCode 0x%04x Size=%lu]\n",emu_opcode,(unsigned long)size);
|
||||
}
|
||||
|
||||
void EQProtocolPacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
{
|
||||
BasePacket::build_raw_header_dump(buffer, seq);
|
||||
buffer += strlen(buffer);
|
||||
|
||||
buffer += sprintf(buffer, "[ProtoOpCode 0x%04x Size=%u]\n",opcode,size);
|
||||
}
|
||||
|
||||
void EQProtocolPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
char buff[196];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
}
|
||||
|
||||
void EQProtocolPacket::build_header_dump(char *buffer) const
|
||||
{
|
||||
sprintf(buffer, "[ProtoOpCode 0x%04x Size=%u]",opcode,size);
|
||||
}
|
||||
|
||||
void EQProtocolPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
dIP=long2ip(dst_ip);
|
||||
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
||||
}
|
||||
if (seq != 0xffff)
|
||||
fprintf(to, "[Seq=%u] ",seq);
|
||||
|
||||
fprintf(to, "[ProtoOpCode 0x%04x Size=%lu]\n",opcode,(unsigned long)size);
|
||||
}
|
||||
|
||||
void EQApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
{
|
||||
BasePacket::build_raw_header_dump(buffer, seq);
|
||||
buffer += strlen(buffer);
|
||||
|
||||
#ifdef STATIC_OPCODE
|
||||
buffer += sprintf(buffer, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size);
|
||||
#else
|
||||
buffer += sprintf(buffer, "[OpCode %s Size=%u]\n",OpcodeManager::EmuToName(emu_opcode),size);
|
||||
#endif
|
||||
}
|
||||
|
||||
void EQApplicationPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
char buff[196];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
}
|
||||
|
||||
void EQApplicationPacket::build_header_dump(char *buffer) const
|
||||
{
|
||||
#ifdef STATIC_OPCODE
|
||||
sprintf(buffer, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size);
|
||||
#else
|
||||
sprintf(buffer, "[OpCode %s Size=%u]",OpcodeManager::EmuToName(emu_opcode),size);
|
||||
#endif
|
||||
}
|
||||
|
||||
void EQApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
dIP=long2ip(dst_ip);
|
||||
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
||||
}
|
||||
if (seq != 0xffff)
|
||||
fprintf(to, "[Seq=%u] ",seq);
|
||||
|
||||
#ifdef STATIC_OPCODE
|
||||
fprintf(to, "[OpCode 0x%04x Size=%u]\n", emu_opcode,size);
|
||||
#else
|
||||
fprintf(to, "[OpCode %s Size=%lu]\n",OpcodeManager::EmuToName(emu_opcode),(unsigned long)size);
|
||||
#endif
|
||||
}
|
||||
|
||||
void EQRawApplicationPacket::build_raw_header_dump(char *buffer, uint16 seq) const
|
||||
{
|
||||
BasePacket::build_raw_header_dump(buffer, seq);
|
||||
buffer += strlen(buffer);
|
||||
|
||||
#ifdef STATIC_OPCODE
|
||||
buffer += sprintf(buffer, "[OpCode 0x%04x (0x%04x) Size=%u]\n", emu_opcode, opcode,size);
|
||||
#else
|
||||
buffer += sprintf(buffer, "[OpCode %s (0x%04x) Size=%u]\n", OpcodeManager::EmuToName(emu_opcode), opcode,size);
|
||||
#endif
|
||||
}
|
||||
|
||||
void EQRawApplicationPacket::DumpRawHeader(uint16 seq, FILE *to) const
|
||||
{
|
||||
char buff[196];
|
||||
build_raw_header_dump(buff, seq);
|
||||
fprintf(to, "%s", buff);
|
||||
}
|
||||
|
||||
void EQRawApplicationPacket::build_header_dump(char *buffer) const
|
||||
{
|
||||
#ifdef STATIC_OPCODE
|
||||
sprintf(buffer, "[OpCode 0x%04x (0x%04x) Size=%u]\n", emu_opcode, opcode,size);
|
||||
#else
|
||||
sprintf(buffer, "[OpCode %s (0x%04x) Size=%u]", OpcodeManager::EmuToName(emu_opcode), opcode,size);
|
||||
#endif
|
||||
}
|
||||
|
||||
void EQRawApplicationPacket::DumpRawHeaderNoTime(uint16 seq, FILE *to) const
|
||||
{
|
||||
if (src_ip) {
|
||||
std::string sIP,dIP;;
|
||||
sIP=long2ip(src_ip);
|
||||
dIP=long2ip(dst_ip);
|
||||
fprintf(to, "[%s:%d->%s:%d] ",sIP.c_str(),src_port,dIP.c_str(),dst_port);
|
||||
}
|
||||
if (seq != 0xffff)
|
||||
fprintf(to, "[Seq=%u] ",seq);
|
||||
|
||||
#ifdef STATIC_OPCODE
|
||||
fprintf(to, "[OpCode 0x%04x (0x%04x) Size=%u]\n", emu_opcode, opcode,size);
|
||||
#else
|
||||
fprintf(to, "[OpCode %s (0x%04x) Size=%lu]\n", OpcodeManager::EmuToName(emu_opcode), opcode,(unsigned long)size);
|
||||
#endif
|
||||
}
|
||||
|
||||
uint32 EQProtocolPacket::serialize(unsigned char *dest) const
|
||||
{
|
||||
if (opcode>0xff) {
|
||||
*(uint16 *)dest=opcode;
|
||||
} else {
|
||||
*(dest)=0;
|
||||
*(dest+1)=opcode;
|
||||
}
|
||||
memcpy(dest+2,pBuffer,size);
|
||||
|
||||
return size+2;
|
||||
}
|
||||
|
||||
uint32 EQApplicationPacket::serialize(uint16 opcode, unsigned char *dest) const
|
||||
{
|
||||
uint8 OpCodeBytes = app_opcode_size;
|
||||
|
||||
if (app_opcode_size==1)
|
||||
*(unsigned char *)dest = opcode;
|
||||
else
|
||||
{
|
||||
// Application opcodes with a low order byte of 0x00 require an extra 0x00 byte inserting prior to the opcode.
|
||||
if((opcode & 0x00ff) == 0)
|
||||
{
|
||||
*(uint8 *)dest = 0;
|
||||
*(uint16 *)(dest + 1) = opcode;
|
||||
++OpCodeBytes;
|
||||
}
|
||||
else
|
||||
*(uint16 *)dest = opcode;
|
||||
}
|
||||
memcpy(dest+OpCodeBytes,pBuffer,size);
|
||||
|
||||
return size+OpCodeBytes;
|
||||
}
|
||||
|
||||
/*EQProtocolPacket::EQProtocolPacket(uint16 op, const unsigned char *buf, uint32 len)
|
||||
: BasePacket(buf, len),
|
||||
opcode(op)
|
||||
{
|
||||
|
||||
uint32 offset;
|
||||
opcode=ntohs(*(const uint16 *)buf);
|
||||
offset=2;
|
||||
|
||||
if (len-offset) {
|
||||
pBuffer= new unsigned char[len-offset];
|
||||
memcpy(pBuffer,buf+offset,len-offset);
|
||||
size=len-offset;
|
||||
} else {
|
||||
pBuffer=nullptr;
|
||||
size=0;
|
||||
}
|
||||
OpMgr=&RawOpcodeManager;
|
||||
}*/
|
||||
|
||||
bool EQProtocolPacket::combine(const EQProtocolPacket *rhs)
|
||||
{
|
||||
bool result=false;
|
||||
if (opcode==OP_Combined && size+rhs->size+5<256) {
|
||||
unsigned char *tmpbuffer=new unsigned char [size+rhs->size+3];
|
||||
memcpy(tmpbuffer,pBuffer,size);
|
||||
uint32 offset=size;
|
||||
tmpbuffer[offset++]=rhs->Size();
|
||||
offset+=rhs->serialize(tmpbuffer+offset);
|
||||
size=offset;
|
||||
delete[] pBuffer;
|
||||
pBuffer=tmpbuffer;
|
||||
result=true;
|
||||
} else if (size+rhs->size+7<256) {
|
||||
unsigned char *tmpbuffer=new unsigned char [size+rhs->size+6];
|
||||
uint32 offset=0;
|
||||
tmpbuffer[offset++]=Size();
|
||||
offset+=serialize(tmpbuffer+offset);
|
||||
tmpbuffer[offset++]=rhs->Size();
|
||||
offset+=rhs->serialize(tmpbuffer+offset);
|
||||
size=offset;
|
||||
delete[] pBuffer;
|
||||
pBuffer=tmpbuffer;
|
||||
opcode=OP_Combined;
|
||||
result=true;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
this is the code to do app-layer combining, instead of protocol layer.
|
||||
this was taken out due to complex interactions with the opcode manager,
|
||||
and will require a bit more thinking (likely moving into EQStream) to
|
||||
get running again... but might be a good thing some day.
|
||||
|
||||
bool EQApplicationPacket::combine(const EQApplicationPacket *rhs)
|
||||
{
|
||||
uint32 newsize=0, offset=0;
|
||||
unsigned char *tmpbuffer=nullptr;
|
||||
|
||||
if (opcode!=OP_AppCombined) {
|
||||
newsize=app_opcode_size+size+(size>254?3:1)+app_opcode_size+rhs->size+(rhs->size>254?3:1);
|
||||
tmpbuffer=new unsigned char [newsize];
|
||||
offset=0;
|
||||
if (size>254) {
|
||||
tmpbuffer[offset++]=0xff;
|
||||
*(uint16 *)(tmpbuffer+offset)=htons(size);
|
||||
offset+=1;
|
||||
} else {
|
||||
tmpbuffer[offset++]=size;
|
||||
}
|
||||
offset+=serialize(tmpbuffer+offset);
|
||||
} else {
|
||||
newsize=size+app_opcode_size+rhs->size+(rhs->size>254?3:1);
|
||||
tmpbuffer=new unsigned char [newsize];
|
||||
memcpy(tmpbuffer,pBuffer,size);
|
||||
offset=size;
|
||||
}
|
||||
|
||||
if (rhs->size>254) {
|
||||
tmpbuffer[offset++]=0xff;
|
||||
*(uint16 *)(tmpbuffer+offset)=htons(rhs->size);
|
||||
offset+=1;
|
||||
} else {
|
||||
tmpbuffer[offset++]=rhs->size;
|
||||
}
|
||||
offset+=rhs->serialize(tmpbuffer+offset);
|
||||
|
||||
size=offset;
|
||||
opcode=OP_AppCombined;
|
||||
|
||||
delete[] pBuffer;
|
||||
pBuffer=tmpbuffer;
|
||||
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
bool EQProtocolPacket::ValidateCRC(const unsigned char *buffer, int length, uint32 Key)
|
||||
{
|
||||
bool valid=false;
|
||||
// OP_SessionRequest, OP_SessionResponse, OP_OutOfSession are not CRC'd
|
||||
if (buffer[0]==0x00 && (buffer[1]==OP_SessionRequest || buffer[1]==OP_SessionResponse || buffer[1]==OP_OutOfSession)) {
|
||||
valid=true;
|
||||
} else {
|
||||
uint16 comp_crc=CRC16(buffer,length-2,Key);
|
||||
uint16 packet_crc=ntohs(*(const uint16 *)(buffer+length-2));
|
||||
#ifdef EQN_DEBUG
|
||||
if (packet_crc && comp_crc != packet_crc) {
|
||||
std::cout << "CRC mismatch: comp=" << std::hex << comp_crc << ", packet=" << packet_crc << std::dec << std::endl;
|
||||
}
|
||||
#endif
|
||||
valid = (!packet_crc || comp_crc == packet_crc);
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
uint32 EQProtocolPacket::Decompress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize)
|
||||
{
|
||||
uint32 newlen=0;
|
||||
uint32 flag_offset=0;
|
||||
newbuf[0]=buffer[0];
|
||||
if (buffer[0]==0x00) {
|
||||
flag_offset=2;
|
||||
newbuf[1]=buffer[1];
|
||||
} else
|
||||
flag_offset=1;
|
||||
|
||||
if (length>2 && buffer[flag_offset]==0x5a) {
|
||||
newlen=InflatePacket(buffer+flag_offset+1,length-(flag_offset+1)-2,newbuf+flag_offset,newbufsize-flag_offset)+2;
|
||||
newbuf[newlen++]=buffer[length-2];
|
||||
newbuf[newlen++]=buffer[length-1];
|
||||
} else if (length>2 && buffer[flag_offset]==0xa5) {
|
||||
memcpy(newbuf+flag_offset,buffer+flag_offset+1,length-(flag_offset+1));
|
||||
newlen=length-1;
|
||||
} else {
|
||||
memcpy(newbuf,buffer,length);
|
||||
newlen=length;
|
||||
}
|
||||
|
||||
return newlen;
|
||||
}
|
||||
|
||||
uint32 EQProtocolPacket::Compress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize) {
|
||||
uint32 flag_offset=1,newlength;
|
||||
//dump_message_column(buffer,length,"Before: ");
|
||||
newbuf[0]=buffer[0];
|
||||
if (buffer[0]==0) {
|
||||
flag_offset=2;
|
||||
newbuf[1]=buffer[1];
|
||||
}
|
||||
if (length>30) {
|
||||
newlength=DeflatePacket(buffer+flag_offset,length-flag_offset,newbuf+flag_offset+1,newbufsize);
|
||||
*(newbuf+flag_offset)=0x5a;
|
||||
newlength+=flag_offset+1;
|
||||
} else {
|
||||
memmove(newbuf+flag_offset+1,buffer+flag_offset,length-flag_offset);
|
||||
*(newbuf+flag_offset)=0xa5;
|
||||
newlength=length+1;
|
||||
}
|
||||
//dump_message_column(newbuf,length,"After: ");
|
||||
|
||||
return newlength;
|
||||
}
|
||||
|
||||
void EQProtocolPacket::ChatDecode(unsigned char *buffer, int size, int DecodeKey)
|
||||
{
|
||||
if ((size >= 2) && buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) {
|
||||
int Key=DecodeKey;
|
||||
unsigned char *test=(unsigned char *)malloc(size);
|
||||
buffer+=2;
|
||||
size-=2;
|
||||
|
||||
int i;
|
||||
for (i = 0 ; i+4 <= size ; i+=4)
|
||||
{
|
||||
int pt = (*(int*)&buffer[i])^(Key);
|
||||
Key = (*(int*)&buffer[i]);
|
||||
*(int*)&test[i]=pt;
|
||||
}
|
||||
unsigned char KC=Key&0xFF;
|
||||
for ( ; i < size ; i++)
|
||||
{
|
||||
test[i]=buffer[i]^KC;
|
||||
}
|
||||
memcpy(buffer,test,size);
|
||||
free(test);
|
||||
}
|
||||
}
|
||||
|
||||
void EQProtocolPacket::ChatEncode(unsigned char *buffer, int size, int EncodeKey)
|
||||
{
|
||||
if (buffer[1]!=0x01 && buffer[0]!=0x02 && buffer[0]!=0x1d) {
|
||||
int Key=EncodeKey;
|
||||
char *test=(char*)malloc(size);
|
||||
int i;
|
||||
buffer+=2;
|
||||
size-=2;
|
||||
for ( i = 0 ; i+4 <= size ; i+=4)
|
||||
{
|
||||
int pt = (*(int*)&buffer[i])^(Key);
|
||||
Key = pt;
|
||||
*(int*)&test[i]=pt;
|
||||
}
|
||||
unsigned char KC=Key&0xFF;
|
||||
for ( ; i < size ; i++)
|
||||
{
|
||||
test[i]=buffer[i]^KC;
|
||||
}
|
||||
memcpy(buffer,test,size);
|
||||
free(test);
|
||||
}
|
||||
}
|
||||
|
||||
EQApplicationPacket *EQApplicationPacket::Copy() const {
|
||||
return(new EQApplicationPacket(*this));
|
||||
}
|
||||
|
||||
EQRawApplicationPacket *EQProtocolPacket::MakeAppPacket() const {
|
||||
EQRawApplicationPacket *res = new EQRawApplicationPacket(opcode, pBuffer, size);
|
||||
res->copyInfo(this);
|
||||
return(res);
|
||||
}
|
||||
|
||||
EQRawApplicationPacket::EQRawApplicationPacket(uint16 opcode, const unsigned char *buf, const uint32 len)
|
||||
: EQApplicationPacket(OP_Unknown, buf, len),
|
||||
opcode(opcode)
|
||||
{
|
||||
}
|
||||
EQRawApplicationPacket::EQRawApplicationPacket(const unsigned char *buf, const uint32 len)
|
||||
: EQApplicationPacket(OP_Unknown, buf+sizeof(uint16), len-sizeof(uint16))
|
||||
{
|
||||
if(GetExecutablePlatform() != ExePlatformUCS) {
|
||||
opcode = *((const uint16 *) buf);
|
||||
if(opcode == 0x0000)
|
||||
{
|
||||
if(len >= 3)
|
||||
{
|
||||
opcode = *((const uint16 *) (buf + 1));
|
||||
const unsigned char *packet_start = (buf + 3);
|
||||
const int32 packet_length = len - 3;
|
||||
safe_delete_array(pBuffer);
|
||||
if(packet_length >= 0)
|
||||
{
|
||||
size = packet_length;
|
||||
pBuffer = new unsigned char[size];
|
||||
memcpy(pBuffer, packet_start, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
size = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
safe_delete_array(pBuffer);
|
||||
size = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
opcode = *((const uint8 *) buf);
|
||||
}
|
||||
}
|
||||
|
||||
void DumpPacket(const EQApplicationPacket* app, bool iShowInfo) {
|
||||
if (iShowInfo) {
|
||||
std::cout << "Dumping Applayer: 0x" << std::hex << std::setfill('0') << std::setw(4) << app->GetOpcode() << std::dec;
|
||||
std::cout << " size:" << app->size << std::endl;
|
||||
}
|
||||
DumpPacketHex(app->pBuffer, app->size);
|
||||
// DumpPacketAscii(app->pBuffer, app->size);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
Copyright (C) 2005 Michael S. Finger
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef _EQPACKET_H
|
||||
#define _EQPACKET_H
|
||||
|
||||
#include "base_packet.h"
|
||||
#include "eq_stream_type.h"
|
||||
#include "op_codes.h"
|
||||
#include "platform.h"
|
||||
|
||||
#ifdef STATIC_OPCODE
|
||||
typedef unsigned short EmuOpcode;
|
||||
static const EmuOpcode OP_Unknown = 0;
|
||||
#else
|
||||
#include "emu_opcodes.h"
|
||||
#endif
|
||||
|
||||
class EQStream;
|
||||
class EQStreamPair;
|
||||
|
||||
class EQPacket : public BasePacket {
|
||||
friend class EQStream;
|
||||
public:
|
||||
virtual ~EQPacket() {}
|
||||
|
||||
uint32 Size() const { return size+2; }
|
||||
|
||||
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
|
||||
virtual void build_header_dump(char *buffer) const;
|
||||
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||
|
||||
void SetOpcode(EmuOpcode op) { emu_opcode = op; }
|
||||
const EmuOpcode GetOpcode() const { return(emu_opcode); }
|
||||
// const char *GetOpcodeName() const;
|
||||
|
||||
protected:
|
||||
//this is just a cache so we dont look it up several times on Get()
|
||||
//and it is mutable so we can store the cached copy even on a const object
|
||||
EmuOpcode emu_opcode;
|
||||
|
||||
EQPacket(EmuOpcode opcode, const unsigned char *buf, const uint32 len);
|
||||
// EQPacket(const EQPacket &p) { }
|
||||
EQPacket() { emu_opcode=OP_Unknown; pBuffer=nullptr; size=0; }
|
||||
|
||||
};
|
||||
|
||||
class EQRawApplicationPacket;
|
||||
|
||||
class EQProtocolPacket : public BasePacket {
|
||||
friend class EQStream;
|
||||
friend class EQStreamPair;
|
||||
public:
|
||||
EQProtocolPacket(uint16 op, const unsigned char *buf, uint32 len) : BasePacket(buf,len), opcode(op) { acked = false; }
|
||||
// EQProtocolPacket(const unsigned char *buf, uint32 len);
|
||||
bool combine(const EQProtocolPacket *rhs);
|
||||
uint32 serialize (unsigned char *dest) const;
|
||||
EQProtocolPacket *Copy() { return new EQProtocolPacket(opcode,pBuffer,size); }
|
||||
EQRawApplicationPacket *MakeAppPacket() const;
|
||||
|
||||
bool acked;
|
||||
|
||||
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
|
||||
virtual void build_header_dump(char *buffer) const;
|
||||
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||
|
||||
protected:
|
||||
|
||||
static bool ValidateCRC(const unsigned char *buffer, int length, uint32 Key);
|
||||
static uint32 Decompress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize);
|
||||
static uint32 Compress(const unsigned char *buffer, const uint32 length, unsigned char *newbuf, uint32 newbufsize);
|
||||
static void ChatDecode(unsigned char *buffer, int size, int DecodeKey);
|
||||
static void ChatEncode(unsigned char *buffer, int size, int EncodeKey);
|
||||
|
||||
uint16 GetRawOpcode() const { return(opcode); }
|
||||
|
||||
uint32 Size() const { return size+2; }
|
||||
|
||||
//the actual raw EQ opcode
|
||||
uint16 opcode;
|
||||
};
|
||||
|
||||
class EQApplicationPacket : public EQPacket {
|
||||
friend class EQStream;
|
||||
public:
|
||||
EQApplicationPacket() : EQPacket(OP_Unknown, nullptr, 0), opcode_bypass(0)
|
||||
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
|
||||
EQApplicationPacket(const EmuOpcode op) : EQPacket(op, nullptr, 0), opcode_bypass(0)
|
||||
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
|
||||
EQApplicationPacket(const EmuOpcode op, const uint32 len) : EQPacket(op, nullptr, len), opcode_bypass(0)
|
||||
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
|
||||
EQApplicationPacket(const EmuOpcode op, const unsigned char *buf, const uint32 len) : EQPacket(op, buf, len), opcode_bypass(0)
|
||||
{ app_opcode_size = GetExecutablePlatform() == ExePlatformUCS ? 1 : 2; }
|
||||
bool combine(const EQApplicationPacket *rhs);
|
||||
uint32 serialize (uint16 opcode, unsigned char *dest) const;
|
||||
uint32 Size() const { return size+app_opcode_size; }
|
||||
|
||||
virtual EQApplicationPacket *Copy() const;
|
||||
|
||||
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
|
||||
virtual void build_header_dump(char *buffer) const;
|
||||
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||
|
||||
uint16 GetOpcodeBypass() { return opcode_bypass; }
|
||||
void SetOpcodeBypass(uint16 v) { opcode_bypass = v; }
|
||||
|
||||
protected:
|
||||
|
||||
uint8 app_opcode_size;
|
||||
uint16 opcode_bypass;
|
||||
private:
|
||||
|
||||
EQApplicationPacket(const EQApplicationPacket &p) : EQPacket(p.emu_opcode, p.pBuffer, p.size), opcode_bypass(p.opcode_bypass) { app_opcode_size = p.app_opcode_size; }
|
||||
|
||||
};
|
||||
|
||||
class EQRawApplicationPacket : public EQApplicationPacket {
|
||||
friend class EQStream;
|
||||
public:
|
||||
EQRawApplicationPacket(uint16 opcode, const unsigned char *buf, const uint32 len);
|
||||
uint16 GetRawOpcode() const { return(opcode); }
|
||||
|
||||
virtual void build_raw_header_dump(char *buffer, uint16 seq=0xffff) const;
|
||||
virtual void build_header_dump(char *buffer) const;
|
||||
virtual void DumpRawHeader(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||
virtual void DumpRawHeaderNoTime(uint16 seq=0xffff, FILE *to = stdout) const;
|
||||
|
||||
protected:
|
||||
|
||||
//the actual raw EQ opcode
|
||||
uint16 opcode;
|
||||
|
||||
EQRawApplicationPacket(const unsigned char *buf, const uint32 len);
|
||||
};
|
||||
|
||||
extern void DumpPacket(const EQApplicationPacket* app, bool iShowInfo = false);
|
||||
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,290 @@
|
||||
#ifndef _EQSTREAM_H
|
||||
#define _EQSTREAM_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <queue>
|
||||
#include <deque>
|
||||
#ifndef WIN32
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#include "eq_stream_type.h"
|
||||
#include "eq_packet.h"
|
||||
#include "eq_stream_intf.h"
|
||||
#include "mutex.h"
|
||||
#include "../common/opcodemgr.h"
|
||||
#include "../common/misc.h"
|
||||
#include "../common/condition.h"
|
||||
#include "../common/timer.h"
|
||||
|
||||
#define FLAG_COMPRESSED 0x01
|
||||
#define FLAG_ENCODED 0x04
|
||||
|
||||
#ifndef RATEBASE
|
||||
#define RATEBASE 1048576
|
||||
#endif
|
||||
|
||||
#ifndef DECAYBASE
|
||||
#define DECAYBASE 78642
|
||||
#endif
|
||||
|
||||
#ifndef RETRANSMIT_TIMEOUT_MULT
|
||||
#define RETRANSMIT_TIMEOUT_MULT 3.0
|
||||
#endif
|
||||
|
||||
#ifndef RETRANSMIT_TIMEOUT_MAX
|
||||
#define RETRANSMIT_TIMEOUT_MAX 5000
|
||||
#endif
|
||||
|
||||
#ifndef AVERAGE_DELTA_MAX
|
||||
#define AVERAGE_DELTA_MAX 2500
|
||||
#endif
|
||||
|
||||
#ifndef RETRANSMIT_ACKED_PACKETS
|
||||
#define RETRANSMIT_ACKED_PACKETS true
|
||||
#endif
|
||||
|
||||
#pragma pack(1)
|
||||
struct SessionRequest {
|
||||
uint32 UnknownA;
|
||||
uint32 Session;
|
||||
uint32 MaxLength;
|
||||
};
|
||||
|
||||
struct SessionResponse {
|
||||
uint32 Session;
|
||||
uint32 Key;
|
||||
uint8 UnknownA;
|
||||
uint8 Format;
|
||||
uint8 UnknownB;
|
||||
uint32 MaxLength;
|
||||
uint32 UnknownD;
|
||||
};
|
||||
|
||||
//Deltas are in ms, representing round trip times
|
||||
struct SessionStats {
|
||||
/*000*/ uint16 RequestID;
|
||||
/*002*/ uint32 last_local_delta;
|
||||
/*006*/ uint32 average_delta;
|
||||
/*010*/ uint32 low_delta;
|
||||
/*014*/ uint32 high_delta;
|
||||
/*018*/ uint32 last_remote_delta;
|
||||
/*022*/ uint64 packets_sent;
|
||||
/*030*/ uint64 packets_received;
|
||||
/*038*/
|
||||
};
|
||||
|
||||
#pragma pack()
|
||||
|
||||
class OpcodeManager;
|
||||
class EQStreamPair;
|
||||
class EQRawApplicationPacket;
|
||||
|
||||
class EQStream : public EQStreamInterface {
|
||||
friend class EQStreamPair; //for collector.
|
||||
protected:
|
||||
typedef enum {
|
||||
SeqPast,
|
||||
SeqInOrder,
|
||||
SeqFuture
|
||||
} SeqOrder;
|
||||
|
||||
uint32 remote_ip;
|
||||
uint16 remote_port;
|
||||
uint8 buffer[8192];
|
||||
unsigned char *oversize_buffer;
|
||||
uint32 oversize_offset,oversize_length;
|
||||
uint8 app_opcode_size;
|
||||
EQStreamType StreamType;
|
||||
bool compressed,encoded;
|
||||
uint32 retransmittimer;
|
||||
uint32 retransmittimeout;
|
||||
|
||||
//uint32 buffer_len;
|
||||
|
||||
uint32 Session, Key;
|
||||
uint16 NextInSeq;
|
||||
uint32 MaxLen;
|
||||
uint16 MaxSends;
|
||||
|
||||
uint8 active_users; //how many things are actively using this
|
||||
Mutex MInUse;
|
||||
|
||||
EQStreamState State;
|
||||
Mutex MState;
|
||||
|
||||
uint32 LastPacket;
|
||||
Mutex MVarlock;
|
||||
|
||||
// Ack sequence tracking.
|
||||
long NextAckToSend;
|
||||
long LastAckSent;
|
||||
long GetNextAckToSend();
|
||||
long GetLastAckSent();
|
||||
void AckPackets(uint16 seq);
|
||||
void SetNextAckToSend(uint32);
|
||||
void SetLastAckSent(uint32);
|
||||
|
||||
Mutex MAcks;
|
||||
|
||||
// Packets waiting to be sent (all protected by MOutboundQueue)
|
||||
std::queue<EQProtocolPacket *> NonSequencedQueue;
|
||||
std::deque<EQProtocolPacket *> SequencedQueue;
|
||||
uint16 NextOutSeq;
|
||||
uint16 SequencedBase; //the sequence number of SequencedQueue[0]
|
||||
long NextSequencedSend; //index into SequencedQueue
|
||||
Mutex MOutboundQueue;
|
||||
|
||||
//a buffer we use for compression/decompression
|
||||
unsigned char _tempBuffer[2048];
|
||||
|
||||
// Packets waiting to be processed
|
||||
std::vector<EQRawApplicationPacket *> InboundQueue;
|
||||
std::map<unsigned short,EQProtocolPacket *> PacketQueue; //not mutex protected, only accessed by caller of Process()
|
||||
Mutex MInboundQueue;
|
||||
|
||||
static uint16 MaxWindowSize;
|
||||
|
||||
int32 BytesWritten;
|
||||
|
||||
Mutex MRate;
|
||||
int32 RateThreshold;
|
||||
int32 DecayRate;
|
||||
|
||||
|
||||
OpcodeManager **OpMgr;
|
||||
|
||||
EQRawApplicationPacket *MakeApplicationPacket(EQProtocolPacket *p);
|
||||
EQRawApplicationPacket *MakeApplicationPacket(const unsigned char *buf, uint32 len);
|
||||
EQProtocolPacket *MakeProtocolPacket(const unsigned char *buf, uint32 len);
|
||||
void SendPacket(uint16 opcode, EQApplicationPacket *p);
|
||||
|
||||
void SetState(EQStreamState state);
|
||||
|
||||
void SendSessionResponse();
|
||||
void SendSessionRequest();
|
||||
void SendAck(uint16 seq);
|
||||
void SendOutOfOrderAck(uint16 seq);
|
||||
void QueuePacket(EQProtocolPacket *p);
|
||||
void SendPacket(EQProtocolPacket *p);
|
||||
void NonSequencedPush(EQProtocolPacket *p);
|
||||
void SequencedPush(EQProtocolPacket *p);
|
||||
void WritePacket(int fd,EQProtocolPacket *p);
|
||||
|
||||
|
||||
uint32 GetKey() { return Key; }
|
||||
void SetKey(uint32 k) { Key=k; }
|
||||
void SetSession(uint32 s) { Session=s; }
|
||||
|
||||
void ProcessPacket(EQProtocolPacket *p);
|
||||
|
||||
bool Stale(uint32 now, uint32 timeout=30) { return (LastPacket && (now-LastPacket) > timeout); }
|
||||
|
||||
void InboundQueuePush(EQRawApplicationPacket *p);
|
||||
EQRawApplicationPacket *PeekPacket(); //for collector.
|
||||
EQRawApplicationPacket *PopRawPacket(); //for collector.
|
||||
|
||||
void InboundQueueClear();
|
||||
void OutboundQueueClear();
|
||||
void PacketQueueClear();
|
||||
|
||||
void ProcessQueue();
|
||||
EQProtocolPacket *RemoveQueue(uint16 seq);
|
||||
|
||||
void _SendDisconnect();
|
||||
|
||||
void init();
|
||||
public:
|
||||
EQStream() { init(); remote_ip = 0; remote_port = 0; State=UNESTABLISHED; StreamType=UnknownStream; compressed=true; encoded=false; app_opcode_size=2; bytes_sent=0; bytes_recv=0; create_time=Timer::GetTimeSeconds(); }
|
||||
EQStream(sockaddr_in addr) { init(); remote_ip=addr.sin_addr.s_addr; remote_port=addr.sin_port; State=UNESTABLISHED; StreamType=UnknownStream; compressed=true; encoded=false; app_opcode_size=2; bytes_sent=0; bytes_recv=0; create_time=Timer::GetTimeSeconds(); }
|
||||
virtual ~EQStream() { RemoveData(); SetState(CLOSED); }
|
||||
void SetMaxLen(uint32 length) { MaxLen=length; }
|
||||
|
||||
//interface used by application (EQStreamInterface)
|
||||
virtual void QueuePacket(const EQApplicationPacket *p, bool ack_req=true);
|
||||
virtual void FastQueuePacket(EQApplicationPacket **p, bool ack_req=true);
|
||||
virtual EQApplicationPacket *PopPacket();
|
||||
virtual void Close();
|
||||
virtual uint32 GetRemoteIP() const { return remote_ip; }
|
||||
virtual uint16 GetRemotePort() const { return remote_port; }
|
||||
virtual void ReleaseFromUse() { MInUse.lock(); if(active_users > 0) active_users--; MInUse.unlock(); }
|
||||
virtual void RemoveData() { InboundQueueClear(); OutboundQueueClear(); PacketQueueClear(); /*if (CombinedAppPacket) delete CombinedAppPacket;*/ }
|
||||
virtual bool CheckState(EQStreamState state) { return GetState() == state; }
|
||||
virtual std::string Describe() const { return("Direct EQStream"); }
|
||||
|
||||
void SetOpcodeManager(OpcodeManager **opm) { OpMgr = opm; }
|
||||
|
||||
void CheckTimeout(uint32 now, uint32 timeout=30);
|
||||
bool HasOutgoingData();
|
||||
void Process(const unsigned char *data, const uint32 length);
|
||||
void SetLastPacketTime(uint32 t) {LastPacket=t;}
|
||||
void Write(int eq_fd);
|
||||
|
||||
//
|
||||
inline bool IsInUse() { bool flag; MInUse.lock(); flag=(active_users>0); MInUse.unlock(); return flag; }
|
||||
inline void PutInUse() { MInUse.lock(); active_users++; MInUse.unlock(); }
|
||||
|
||||
inline EQStreamState GetState() { EQStreamState s; MState.lock(); s=State; MState.unlock(); return s; }
|
||||
|
||||
static SeqOrder CompareSequence(uint16 expected_seq , uint16 seq);
|
||||
|
||||
bool CheckActive() { return GetState()==ESTABLISHED; }
|
||||
bool CheckClosed() { return GetState()==CLOSED; }
|
||||
void SetOpcodeSize(uint8 s) { app_opcode_size = s; }
|
||||
void SetStreamType(EQStreamType t);
|
||||
inline const EQStreamType GetStreamType() const { return StreamType; }
|
||||
static const char *StreamTypeString(EQStreamType t);
|
||||
|
||||
void Decay();
|
||||
void AdjustRates(uint32 average_delta);
|
||||
|
||||
uint32 bytes_sent;
|
||||
uint32 bytes_recv;
|
||||
uint32 create_time;
|
||||
|
||||
void AddBytesSent(uint32 bytes)
|
||||
{
|
||||
bytes_sent += bytes;
|
||||
}
|
||||
|
||||
void AddBytesRecv(uint32 bytes)
|
||||
{
|
||||
bytes_recv += bytes;
|
||||
}
|
||||
|
||||
virtual const uint32 GetBytesSent() const { return bytes_sent; }
|
||||
virtual const uint32 GetBytesRecieved() const { return bytes_recv; }
|
||||
virtual const uint32 GetBytesSentPerSecond() const
|
||||
{
|
||||
if((Timer::GetTimeSeconds() - create_time) == 0)
|
||||
return 0;
|
||||
return bytes_sent / (Timer::GetTimeSeconds() - create_time);
|
||||
}
|
||||
|
||||
virtual const uint32 GetBytesRecvPerSecond() const
|
||||
{
|
||||
if((Timer::GetTimeSeconds() - create_time) == 0)
|
||||
return 0;
|
||||
return bytes_recv / (Timer::GetTimeSeconds() - create_time);
|
||||
}
|
||||
|
||||
//used for dynamic stream identification
|
||||
class Signature {
|
||||
public:
|
||||
//this object could get more complicated if needed...
|
||||
uint16 ignore_eq_opcode; //0=dont ignore
|
||||
uint16 first_eq_opcode;
|
||||
uint32 first_length; //0=dont check length
|
||||
};
|
||||
typedef enum {
|
||||
MatchNotReady,
|
||||
MatchSuccessful,
|
||||
MatchFailed
|
||||
} MatchState;
|
||||
MatchState CheckSignature(const Signature *sig);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,326 @@
|
||||
#include "debug.h"
|
||||
#include "eq_stream_factory.h"
|
||||
#ifdef _WINDOWS
|
||||
#include <winsock.h>
|
||||
#include <process.h>
|
||||
#include <io.h>
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/select.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <iostream>
|
||||
#include "op_codes.h"
|
||||
#include "eq_stream.h"
|
||||
#include "logsys.h"
|
||||
|
||||
ThreadReturnType EQStreamFactoryReaderLoop(void *eqfs)
|
||||
{
|
||||
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Starting EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
|
||||
#endif
|
||||
|
||||
fs->ReaderLoop();
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Ending EQStreamFactoryReaderLoop with thread ID %d", pthread_self());
|
||||
#endif
|
||||
|
||||
THREAD_RETURN(nullptr);
|
||||
}
|
||||
|
||||
ThreadReturnType EQStreamFactoryWriterLoop(void *eqfs)
|
||||
{
|
||||
EQStreamFactory *fs=(EQStreamFactory *)eqfs;
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Starting EQStreamFactoryWriterLoop with thread ID %d", pthread_self());
|
||||
#endif
|
||||
|
||||
fs->WriterLoop();
|
||||
|
||||
#ifndef WIN32
|
||||
_log(COMMON__THREADS, "Ending EQStreamFactoryWriterLoop with thread ID %d", pthread_self());
|
||||
#endif
|
||||
|
||||
THREAD_RETURN(nullptr);
|
||||
}
|
||||
|
||||
EQStreamFactory::EQStreamFactory(EQStreamType type, int port, uint32 timeout)
|
||||
: Timeoutable(5000), stream_timeout(timeout)
|
||||
{
|
||||
StreamType=type;
|
||||
Port=port;
|
||||
sock=-1;
|
||||
}
|
||||
|
||||
void EQStreamFactory::Close()
|
||||
{
|
||||
Stop();
|
||||
|
||||
#ifdef _WINDOWS
|
||||
closesocket(sock);
|
||||
#else
|
||||
close(sock);
|
||||
#endif
|
||||
sock=-1;
|
||||
}
|
||||
|
||||
bool EQStreamFactory::Open()
|
||||
{
|
||||
struct sockaddr_in address;
|
||||
#ifndef WIN32
|
||||
pthread_t t1,t2;
|
||||
#endif
|
||||
/* Setup internet address information.
|
||||
This is used with the bind() call */
|
||||
memset((char *) &address, 0, sizeof(address));
|
||||
address.sin_family = AF_INET;
|
||||
address.sin_port = htons(Port);
|
||||
address.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
|
||||
/* Setting up UDP port for new clients */
|
||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sock < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bind(sock, (struct sockaddr *) &address, sizeof(address)) < 0) {
|
||||
close(sock);
|
||||
sock=-1;
|
||||
return false;
|
||||
}
|
||||
#ifdef _WINDOWS
|
||||
unsigned long nonblock = 1;
|
||||
ioctlsocket(sock, FIONBIO, &nonblock);
|
||||
#else
|
||||
fcntl(sock, F_SETFL, O_NONBLOCK);
|
||||
#endif
|
||||
//moved these because on windows the output was delayed and causing the console window to look bad
|
||||
//std::cout << "Starting factory Reader" << std::endl;
|
||||
//std::cout << "Starting factory Writer" << std::endl;
|
||||
#ifdef _WINDOWS
|
||||
_beginthread(EQStreamFactoryReaderLoop,0, this);
|
||||
_beginthread(EQStreamFactoryWriterLoop,0, this);
|
||||
#else
|
||||
pthread_create(&t1,nullptr,EQStreamFactoryReaderLoop,this);
|
||||
pthread_create(&t2,nullptr,EQStreamFactoryWriterLoop,this);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
EQStream *EQStreamFactory::Pop()
|
||||
{
|
||||
EQStream *s=nullptr;
|
||||
//std::cout << "Pop():Locking MNewStreams" << std::endl;
|
||||
MNewStreams.lock();
|
||||
if (NewStreams.size()) {
|
||||
s=NewStreams.front();
|
||||
NewStreams.pop();
|
||||
s->PutInUse();
|
||||
}
|
||||
MNewStreams.unlock();
|
||||
//std::cout << "Pop(): Unlocking MNewStreams" << std::endl;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
void EQStreamFactory::Push(EQStream *s)
|
||||
{
|
||||
//std::cout << "Push():Locking MNewStreams" << std::endl;
|
||||
MNewStreams.lock();
|
||||
NewStreams.push(s);
|
||||
MNewStreams.unlock();
|
||||
//std::cout << "Push(): Unlocking MNewStreams" << std::endl;
|
||||
}
|
||||
|
||||
void EQStreamFactory::ReaderLoop()
|
||||
{
|
||||
fd_set readset;
|
||||
std::map<std::pair<uint32, uint16>,EQStream *>::iterator stream_itr;
|
||||
int num;
|
||||
int length;
|
||||
unsigned char buffer[2048];
|
||||
sockaddr_in from;
|
||||
int socklen=sizeof(sockaddr_in);
|
||||
timeval sleep_time;
|
||||
//time_t now;
|
||||
|
||||
ReaderRunning=true;
|
||||
while(sock!=-1) {
|
||||
MReaderRunning.lock();
|
||||
if (!ReaderRunning)
|
||||
break;
|
||||
MReaderRunning.unlock();
|
||||
|
||||
FD_ZERO(&readset);
|
||||
FD_SET(sock,&readset);
|
||||
|
||||
sleep_time.tv_sec=30;
|
||||
sleep_time.tv_usec=0;
|
||||
if ((num=select(sock+1,&readset,nullptr,nullptr,&sleep_time))<0) {
|
||||
// What do we wanna do?
|
||||
continue;
|
||||
} else if (num==0)
|
||||
continue;
|
||||
|
||||
if(sock == -1)
|
||||
break; //somebody closed us while we were sleeping.
|
||||
|
||||
if (FD_ISSET(sock,&readset)) {
|
||||
#ifdef _WINDOWS
|
||||
if ((length=recvfrom(sock,(char*)buffer,sizeof(buffer),0,(struct sockaddr*)&from,(int *)&socklen)) < 2)
|
||||
#else
|
||||
if ((length=recvfrom(sock,buffer,2048,0,(struct sockaddr *)&from,(socklen_t *)&socklen)) < 2)
|
||||
#endif
|
||||
{
|
||||
// What do we wanna do?
|
||||
} else {
|
||||
MStreams.lock();
|
||||
stream_itr=Streams.find(std::make_pair(from.sin_addr.s_addr, from.sin_port));
|
||||
if (stream_itr == Streams.end()) {
|
||||
if (buffer[1]==OP_SessionRequest) {
|
||||
EQStream *s = new EQStream(from);
|
||||
s->SetStreamType(StreamType);
|
||||
Streams[std::make_pair(from.sin_addr.s_addr, from.sin_port)]=s;
|
||||
WriterWork.Signal();
|
||||
Push(s);
|
||||
s->AddBytesRecv(length);
|
||||
s->Process(buffer,length);
|
||||
s->SetLastPacketTime(Timer::GetCurrentTime());
|
||||
}
|
||||
MStreams.unlock();
|
||||
} else {
|
||||
EQStream *curstream = stream_itr->second;
|
||||
//dont bother processing incoming packets for closed connections
|
||||
if(curstream->CheckClosed())
|
||||
curstream = nullptr;
|
||||
else
|
||||
curstream->PutInUse();
|
||||
MStreams.unlock(); //the in use flag prevents the stream from being deleted while we are using it.
|
||||
|
||||
if(curstream) {
|
||||
curstream->AddBytesRecv(length);
|
||||
curstream->Process(buffer,length);
|
||||
curstream->SetLastPacketTime(Timer::GetCurrentTime());
|
||||
curstream->ReleaseFromUse();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EQStreamFactory::CheckTimeout()
|
||||
{
|
||||
//lock streams the entire time were checking timeouts, it should be fast.
|
||||
MStreams.lock();
|
||||
|
||||
unsigned long now=Timer::GetCurrentTime();
|
||||
std::map<std::pair<uint32, uint16>,EQStream *>::iterator stream_itr;
|
||||
|
||||
for(stream_itr=Streams.begin();stream_itr!=Streams.end();) {
|
||||
EQStream *s = stream_itr->second;
|
||||
|
||||
s->CheckTimeout(now, stream_timeout);
|
||||
|
||||
EQStreamState state = s->GetState();
|
||||
|
||||
//not part of the else so we check it right away on state change
|
||||
if (state==CLOSED) {
|
||||
if (s->IsInUse()) {
|
||||
//give it a little time for everybody to finish with it
|
||||
} else {
|
||||
//everybody is done, we can delete it now
|
||||
//std::cout << "Removing connection" << std::endl;
|
||||
std::map<std::pair<uint32, uint16>,EQStream *>::iterator temp=stream_itr;
|
||||
++stream_itr;
|
||||
//let whoever has the stream outside delete it
|
||||
delete temp->second;
|
||||
Streams.erase(temp);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
++stream_itr;
|
||||
}
|
||||
MStreams.unlock();
|
||||
}
|
||||
|
||||
void EQStreamFactory::WriterLoop()
|
||||
{
|
||||
std::map<std::pair<uint32, uint16>,EQStream *>::iterator stream_itr;
|
||||
bool havework=true;
|
||||
std::vector<EQStream *> wants_write;
|
||||
std::vector<EQStream *>::iterator cur,end;
|
||||
bool decay=false;
|
||||
uint32 stream_count;
|
||||
|
||||
Timer DecayTimer(20);
|
||||
|
||||
WriterRunning=true;
|
||||
DecayTimer.Enable();
|
||||
while(sock!=-1) {
|
||||
//if (!havework) {
|
||||
//WriterWork.Wait();
|
||||
//}
|
||||
MWriterRunning.lock();
|
||||
if (!WriterRunning)
|
||||
break;
|
||||
MWriterRunning.unlock();
|
||||
|
||||
havework = false;
|
||||
wants_write.clear();
|
||||
|
||||
decay=DecayTimer.Check();
|
||||
|
||||
//copy streams into a seperate list so we dont have to keep
|
||||
//MStreams locked while we are writting
|
||||
MStreams.lock();
|
||||
for(stream_itr=Streams.begin();stream_itr!=Streams.end();++stream_itr) {
|
||||
// If it's time to decay the bytes sent, then let's do it before we try to write
|
||||
if (decay)
|
||||
stream_itr->second->Decay();
|
||||
|
||||
//bullshit checking, to see if this is really happening, GDB seems to think so...
|
||||
if(stream_itr->second == nullptr) {
|
||||
fprintf(stderr, "ERROR: nullptr Stream encountered in EQStreamFactory::WriterLoop for: %i", stream_itr->first.first, stream_itr->first.second);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stream_itr->second->HasOutgoingData()) {
|
||||
havework=true;
|
||||
stream_itr->second->PutInUse();
|
||||
wants_write.push_back(stream_itr->second);
|
||||
}
|
||||
}
|
||||
MStreams.unlock();
|
||||
|
||||
//do the actual writes
|
||||
cur = wants_write.begin();
|
||||
end = wants_write.end();
|
||||
for(; cur != end; ++cur) {
|
||||
(*cur)->Write(sock);
|
||||
(*cur)->ReleaseFromUse();
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
|
||||
MStreams.lock();
|
||||
stream_count=Streams.size();
|
||||
MStreams.unlock();
|
||||
if (!stream_count) {
|
||||
//std::cout << "No streams, waiting on condition" << std::endl;
|
||||
WriterWork.Wait();
|
||||
//std::cout << "Awake from condition, must have a stream now" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
#ifndef _EQSTREAMFACTORY_H
|
||||
|
||||
#define _EQSTREAMFACTORY_H
|
||||
|
||||
#include <queue>
|
||||
#include <map>
|
||||
#include "../common/eq_stream.h"
|
||||
#include "../common/condition.h"
|
||||
#include "../common/timeoutmgr.h"
|
||||
#include "../common/opcodemgr.h"
|
||||
#include "../common/timer.h"
|
||||
|
||||
class EQStreamFactory : private Timeoutable {
|
||||
private:
|
||||
int sock;
|
||||
int Port;
|
||||
|
||||
bool ReaderRunning;
|
||||
Mutex MReaderRunning;
|
||||
bool WriterRunning;
|
||||
Mutex MWriterRunning;
|
||||
|
||||
Condition WriterWork;
|
||||
|
||||
EQStreamType StreamType;
|
||||
|
||||
std::queue<EQStream *> NewStreams;
|
||||
Mutex MNewStreams;
|
||||
|
||||
std::map<std::pair<uint32, uint16>,EQStream *> Streams;
|
||||
Mutex MStreams;
|
||||
|
||||
virtual void CheckTimeout();
|
||||
|
||||
Timer *DecayTimer;
|
||||
|
||||
uint32 stream_timeout;
|
||||
|
||||
public:
|
||||
EQStreamFactory(EQStreamType type, uint32 timeout = 135000) : Timeoutable(5000), stream_timeout(timeout) { ReaderRunning=false; WriterRunning=false; StreamType=type; sock=-1; }
|
||||
EQStreamFactory(EQStreamType type, int port, uint32 timeout = 135000);
|
||||
|
||||
EQStream *Pop();
|
||||
void Push(EQStream *s);
|
||||
|
||||
bool Open();
|
||||
bool Open(unsigned long port) { Port=port; return Open(); }
|
||||
bool IsOpen() { return sock!=-1; }
|
||||
void Close();
|
||||
void ReaderLoop();
|
||||
void WriterLoop();
|
||||
void Stop() { StopReader(); StopWriter(); }
|
||||
void StopReader() { MReaderRunning.lock(); ReaderRunning=false; MReaderRunning.unlock(); }
|
||||
void StopWriter() { MWriterRunning.lock(); WriterRunning=false; MWriterRunning.unlock(); WriterWork.Signal(); }
|
||||
void SignalWriter() { WriterWork.Signal(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,163 @@
|
||||
#include "debug.h"
|
||||
#include "eq_stream_ident.h"
|
||||
#include "eq_stream_proxy.h"
|
||||
#include "logsys.h"
|
||||
|
||||
EQStreamIdentifier::~EQStreamIdentifier() {
|
||||
while(!m_identified.empty()) {
|
||||
m_identified.front()->ReleaseFromUse();
|
||||
m_identified.pop();
|
||||
}
|
||||
std::vector<Record *>::iterator cur, end;
|
||||
cur = m_streams.begin();
|
||||
end = m_streams.end();
|
||||
for(; cur != end; ++cur) {
|
||||
Record *r = *cur;
|
||||
r->stream->ReleaseFromUse();
|
||||
delete r;
|
||||
}
|
||||
std::vector<Patch *>::iterator curp, endp;
|
||||
curp = m_patches.begin();
|
||||
endp = m_patches.end();
|
||||
for(; curp != endp; ++curp) {
|
||||
delete *curp;
|
||||
}
|
||||
}
|
||||
|
||||
void EQStreamIdentifier::RegisterPatch(const EQStream::Signature &sig, const char *name, OpcodeManager ** opcodes, const StructStrategy *structs) {
|
||||
Patch *p = new Patch;
|
||||
p->signature = sig;
|
||||
p->name = name;
|
||||
p->opcodes = opcodes;
|
||||
p->structs = structs;
|
||||
m_patches.push_back(p);
|
||||
}
|
||||
|
||||
void EQStreamIdentifier::Process() {
|
||||
std::vector<Record *>::iterator cur;
|
||||
std::vector<Patch *>::iterator curp, endp;
|
||||
|
||||
//foreach pending stream.
|
||||
cur = m_streams.begin();
|
||||
while(cur != m_streams.end()) {
|
||||
Record *r = *cur;
|
||||
|
||||
//first see if this stream has expired
|
||||
if(r->expire.Check(false)) {
|
||||
//this stream has failed to match any pattern in our timeframe.
|
||||
_log(NET__IDENTIFY, "Unable to identify stream from %s:%d before timeout.", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()));
|
||||
r->stream->ReleaseFromUse();
|
||||
delete r;
|
||||
cur = m_streams.erase(cur);
|
||||
continue;
|
||||
}
|
||||
|
||||
//then make sure the stream is still active
|
||||
//if stream hasn't finished initializing then continue;
|
||||
if(r->stream->GetState() == UNESTABLISHED)
|
||||
{
|
||||
++cur;
|
||||
continue;
|
||||
}
|
||||
if(r->stream->GetState() != ESTABLISHED) {
|
||||
//the stream closed before it was identified.
|
||||
_log(NET__IDENTIFY, "Unable to identify stream from %s:%d before it closed.", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()));
|
||||
switch(r->stream->GetState())
|
||||
{
|
||||
case ESTABLISHED:
|
||||
_log(NET__IDENTIFY, "Stream state was Established");
|
||||
break;
|
||||
case CLOSING:
|
||||
_log(NET__IDENTIFY, "Stream state was Closing");
|
||||
break;
|
||||
case DISCONNECTING:
|
||||
_log(NET__IDENTIFY, "Stream state was Disconnecting");
|
||||
break;
|
||||
case CLOSED:
|
||||
_log(NET__IDENTIFY, "Stream state was Closed");
|
||||
break;
|
||||
default:
|
||||
_log(NET__IDENTIFY, "Stream state was Unestablished or unknown");
|
||||
break;
|
||||
}
|
||||
r->stream->ReleaseFromUse();
|
||||
delete r;
|
||||
cur = m_streams.erase(cur);
|
||||
continue;
|
||||
}
|
||||
|
||||
//not expired, check against all patch signatures
|
||||
|
||||
bool found_one = false; //"we found a matching patch for this stream"
|
||||
bool all_ready = true; //"all signatures were ready to check the stream"
|
||||
|
||||
//foreach possbile patch...
|
||||
curp = m_patches.begin();
|
||||
endp = m_patches.end();
|
||||
for(; !found_one && curp != endp; ++curp) {
|
||||
Patch *p = *curp;
|
||||
|
||||
//ask the stream to see if it matches the supplied signature
|
||||
EQStream::MatchState res = r->stream->CheckSignature(&p->signature);
|
||||
switch(res) {
|
||||
case EQStream::MatchNotReady:
|
||||
//the stream has not received enough packets to compare with this signature
|
||||
// _log(NET__IDENT_TRACE, "%s:%d: Tried patch %s, but stream is not ready for it.", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()), p->name.c_str());
|
||||
all_ready = false;
|
||||
break;
|
||||
case EQStream::MatchSuccessful: {
|
||||
//yay, a match.
|
||||
|
||||
_log(NET__IDENTIFY, "Identified stream %s:%d with signature %s", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()), p->name.c_str());
|
||||
|
||||
//might want to do something less-specific here... some day..
|
||||
EQStreamInterface *s = new EQStreamProxy(r->stream, p->structs, p->opcodes);
|
||||
m_identified.push(s);
|
||||
|
||||
found_one = true;
|
||||
break;
|
||||
}
|
||||
case EQStream::MatchFailed:
|
||||
//do nothing...
|
||||
_log(NET__IDENT_TRACE, "%s:%d: Tried patch %s, and it did not match.", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()), p->name.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//if we checked all patches and did not find a match.
|
||||
if(all_ready && !found_one) {
|
||||
//the stream cannot be identified.
|
||||
_log(NET__IDENTIFY, "Unable to identify stream from %s:%d, no match found.", long2ip(r->stream->GetRemoteIP()).c_str(), ntohs(r->stream->GetRemotePort()));
|
||||
r->stream->ReleaseFromUse();
|
||||
}
|
||||
|
||||
//if we found a match, or were not able to identify it
|
||||
if(found_one || all_ready) {
|
||||
//cannot print ip/port here. r->stream is invalid.
|
||||
delete r;
|
||||
cur = m_streams.erase(cur);
|
||||
} else {
|
||||
++cur;
|
||||
}
|
||||
} //end foreach stream
|
||||
}
|
||||
|
||||
void EQStreamIdentifier::AddStream(EQStream *&eqs) {
|
||||
m_streams.push_back(new Record(eqs));
|
||||
eqs = nullptr;
|
||||
}
|
||||
|
||||
EQStreamInterface *EQStreamIdentifier::PopIdentified() {
|
||||
if(m_identified.empty())
|
||||
return(nullptr);
|
||||
EQStreamInterface *res = m_identified.front();
|
||||
m_identified.pop();
|
||||
return(res);
|
||||
}
|
||||
|
||||
EQStreamIdentifier::Record::Record(EQStream *s)
|
||||
: stream(s),
|
||||
expire(STREAM_IDENT_WAIT_MS)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#ifndef EQSTREAMIDENT_H_
|
||||
#define EQSTREAMIDENT_H_
|
||||
|
||||
#include "eq_stream.h"
|
||||
#include "timer.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <queue>
|
||||
|
||||
#define STREAM_IDENT_WAIT_MS 10000
|
||||
|
||||
class OpcodeManager;
|
||||
class StructStrategy;
|
||||
|
||||
class EQStreamIdentifier {
|
||||
public:
|
||||
~EQStreamIdentifier();
|
||||
|
||||
//registration interface.
|
||||
void RegisterPatch(const EQStream::Signature &sig, const char *name, OpcodeManager ** opcodes, const StructStrategy *structs);
|
||||
|
||||
//main processing interface
|
||||
void Process();
|
||||
void AddStream(EQStream *& eqs);
|
||||
EQStreamInterface *PopIdentified();
|
||||
|
||||
protected:
|
||||
|
||||
//registered patches..
|
||||
class Patch {
|
||||
public:
|
||||
std::string name;
|
||||
EQStream::Signature signature;
|
||||
OpcodeManager ** opcodes;
|
||||
const StructStrategy *structs;
|
||||
};
|
||||
std::vector<Patch *> m_patches; //we own these objects.
|
||||
|
||||
//pending streams..
|
||||
class Record {
|
||||
public:
|
||||
Record(EQStream *s);
|
||||
EQStream *stream; //we own this
|
||||
Timer expire;
|
||||
};
|
||||
std::vector<Record *> m_streams; //we own these objects, and the streams contained in them.
|
||||
std::queue<EQStreamInterface *> m_identified; //we own these objects
|
||||
};
|
||||
|
||||
#endif /*EQSTREAMIDENT_H_*/
|
||||
@@ -0,0 +1,41 @@
|
||||
#ifndef EQSTREAMINTF_H_
|
||||
#define EQSTREAMINTF_H_
|
||||
|
||||
//this is the only part of an EQStream that is seen by the application.
|
||||
|
||||
#include <string>
|
||||
#include "clientversions.h"
|
||||
|
||||
typedef enum {
|
||||
ESTABLISHED,
|
||||
CLOSING, //waiting for pending data to flush.
|
||||
DISCONNECTING, //have sent disconnect, waiting for their disconnect reply.
|
||||
CLOSED, //received a disconnect from remote side.
|
||||
UNESTABLISHED
|
||||
} EQStreamState;
|
||||
|
||||
class EQApplicationPacket;
|
||||
|
||||
class EQStreamInterface {
|
||||
public:
|
||||
virtual ~EQStreamInterface() {}
|
||||
|
||||
virtual void QueuePacket(const EQApplicationPacket *p, bool ack_req=true) = 0;
|
||||
virtual void FastQueuePacket(EQApplicationPacket **p, bool ack_req=true) = 0;
|
||||
virtual EQApplicationPacket *PopPacket() = 0;
|
||||
virtual void Close() = 0;
|
||||
virtual void ReleaseFromUse() = 0;
|
||||
virtual void RemoveData() = 0;
|
||||
virtual uint32 GetRemoteIP() const = 0;
|
||||
virtual uint16 GetRemotePort() const = 0;
|
||||
virtual bool CheckState(EQStreamState state) = 0;
|
||||
virtual std::string Describe() const = 0;
|
||||
|
||||
virtual const uint32 GetBytesSent() const { return 0; }
|
||||
virtual const uint32 GetBytesRecieved() const { return 0; }
|
||||
virtual const uint32 GetBytesSentPerSecond() const { return 0; }
|
||||
virtual const uint32 GetBytesRecvPerSecond() const { return 0; }
|
||||
virtual const EQClientVersion ClientVersion() const { return EQClientUnknown; }
|
||||
};
|
||||
|
||||
#endif /*EQSTREAMINTF_H_*/
|
||||
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
Copyright (C) 2005 EQEmulator Team
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef _EQSTREAM_LOCATOR_H
|
||||
#define _EQSTREAM_LOCATOR_H
|
||||
|
||||
/*
|
||||
This did not turn out nearly as nice as I hoped.
|
||||
*/
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
class EQStreamInfo {
|
||||
public:
|
||||
EQStreamInfo() {}
|
||||
EQStreamInfo(uint32 isrc_ip, uint32 idst_ip, uint16 isrc_port, uint16 idst_port) {
|
||||
src_ip = isrc_ip;
|
||||
dst_ip = idst_ip;
|
||||
src_port = isrc_port;
|
||||
dst_port = idst_port;
|
||||
}
|
||||
void invert(EQStreamInfo &r) const {
|
||||
r.src_ip = dst_ip;
|
||||
r.dst_ip = src_ip;
|
||||
r.src_port = dst_port;
|
||||
r.dst_port = src_port;
|
||||
}
|
||||
uint32 src_ip;
|
||||
uint32 dst_ip;
|
||||
uint16 src_port;
|
||||
uint16 dst_port;
|
||||
};
|
||||
|
||||
inline bool operator<(const EQStreamInfo &l, const EQStreamInfo &r) {
|
||||
/*printf("Less than called with:\n");
|
||||
printf("0x%.8x:%d -> 0x%.8x:%d < \n", l.src_ip, l.src_port, l.dst_ip, l.dst_port);
|
||||
printf("0x%.8x:%d -> 0x%.8x:%d ", r.src_ip, r.src_port, r.dst_ip, r.dst_port);
|
||||
|
||||
bool res;
|
||||
if(l.src_ip != r.src_ip)
|
||||
res = (l.src_ip < r.src_ip);
|
||||
else if(l.dst_ip != r.dst_ip)
|
||||
res = (l.dst_ip < r.dst_ip);
|
||||
else if(l.src_port != r.src_port)
|
||||
res = (l.src_port < r.src_port);
|
||||
else
|
||||
res = (l.dst_port < r.dst_port);
|
||||
if(res)
|
||||
printf(": True\n");
|
||||
else
|
||||
printf(": False\n");*/
|
||||
|
||||
|
||||
if(l.src_ip != r.src_ip)
|
||||
return(l.src_ip < r.src_ip);
|
||||
if(l.dst_ip != r.dst_ip)
|
||||
return(l.dst_ip < r.dst_ip);
|
||||
if(l.src_port != r.src_port)
|
||||
return(l.src_port < r.src_port);
|
||||
return(l.dst_port < r.dst_port);
|
||||
|
||||
/* //so, this turned out uglier than I had hoped
|
||||
if(l.src_ip < r.src_ip)
|
||||
return(true);
|
||||
if(l.src_ip > r.src_ip)
|
||||
return(false);
|
||||
if(l.dst_ip < r.dst_ip)
|
||||
return(true);
|
||||
if(l.dst_ip > r.dst_ip)
|
||||
return(false);
|
||||
if(l.src_port < r.src_port)
|
||||
return(true);
|
||||
if(l.src_port > r.src_port)
|
||||
return(false);
|
||||
return(l.dst_port < r.dst_port);*/
|
||||
}
|
||||
|
||||
inline bool operator==(const EQStreamInfo &l, const EQStreamInfo &r) {
|
||||
// if(l.src_ip == r.dest_ip) {
|
||||
// //maybe swapped
|
||||
// return(l.src_port == r.dst_port && l.dst_ip == r.src_ip && l.dst_port == r.src_port);
|
||||
// }
|
||||
return(l.src_ip == r.src_ip && l.src_port == r.src_port && l.dst_ip == r.dst_ip && l.dst_port == r.dst_port);
|
||||
}
|
||||
|
||||
//Forces the pointer T thing so we can return nullptr
|
||||
template <class T>
|
||||
class EQStreamLocator {
|
||||
protected:
|
||||
typedef typename std::map<const EQStreamInfo, T *>::iterator iterator;
|
||||
public:
|
||||
|
||||
void Clear() {
|
||||
streams.clear();
|
||||
}
|
||||
|
||||
void AddStream(const EQStreamInfo &i, T *o) {
|
||||
//do we care to check if it exists?
|
||||
|
||||
//add this stream, and its inverse
|
||||
streams[i] = o;
|
||||
EQStreamInfo inv;
|
||||
i.invert(inv);
|
||||
streams[inv] = o;
|
||||
}
|
||||
|
||||
//deletes this stream, and its inverse
|
||||
void RemoveStream(const EQStreamInfo &i) {
|
||||
iterator res;
|
||||
res = streams.find(i);
|
||||
if(res != streams.end())
|
||||
streams.erase(res);
|
||||
|
||||
EQStreamInfo inv;
|
||||
i.invert(inv);
|
||||
res = streams.find(inv);
|
||||
if(res != streams.end())
|
||||
streams.erase(res);
|
||||
}
|
||||
|
||||
//removes every occurance of this stream from the list
|
||||
void RemoveStream(T *it) {
|
||||
iterator cur, end;
|
||||
cur = streams.begin();
|
||||
end = streams.end();
|
||||
for(; cur != end; ++cur) {
|
||||
if(cur->second == it) {
|
||||
streams.erase(cur);
|
||||
//lazy recursive delete for now, since we have to redo
|
||||
//our iterators anyways
|
||||
RemoveStream(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
T *GetStream(const EQStreamInfo &i) {
|
||||
iterator res;
|
||||
res = streams.find(i);
|
||||
//possibly optimization would be to store streams.end(), since it
|
||||
//may not be a constant time operation in theory, and update our
|
||||
//stored copy only on insert or delete
|
||||
if(res == streams.end())
|
||||
return(nullptr);
|
||||
return(res->second);
|
||||
}
|
||||
|
||||
//allow people to iterate over the const struct
|
||||
// typedef map<const EQStreamInfo, T *>::const_iterator iterator;
|
||||
// inline iterator begin() const { return(streams.begin()); }
|
||||
// inline iterator end() const { return(streams.end()); }
|
||||
|
||||
protected:
|
||||
std::map<const EQStreamInfo, T *> streams;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,106 @@
|
||||
|
||||
#include "debug.h"
|
||||
#include "eq_stream_proxy.h"
|
||||
#include "eq_stream.h"
|
||||
#include "struct_strategy.h"
|
||||
|
||||
|
||||
EQStreamProxy::EQStreamProxy(EQStream *&stream, const StructStrategy *structs, OpcodeManager **opcodes)
|
||||
: m_stream(stream),
|
||||
m_structs(structs),
|
||||
m_opcodes(opcodes)
|
||||
{
|
||||
stream = nullptr; //take the stream.
|
||||
m_stream->SetOpcodeManager(m_opcodes);
|
||||
}
|
||||
|
||||
EQStreamProxy::~EQStreamProxy() {
|
||||
//delete m_stream; //released by the stream factory.
|
||||
}
|
||||
|
||||
std::string EQStreamProxy::Describe() const {
|
||||
return(m_structs->Describe());
|
||||
}
|
||||
|
||||
const EQClientVersion EQStreamProxy::ClientVersion() const
|
||||
{
|
||||
return m_structs->ClientVersion();
|
||||
}
|
||||
|
||||
void EQStreamProxy::QueuePacket(const EQApplicationPacket *p, bool ack_req) {
|
||||
if(p == nullptr)
|
||||
return;
|
||||
|
||||
EQApplicationPacket *newp = p->Copy();
|
||||
FastQueuePacket(&newp, ack_req);
|
||||
}
|
||||
|
||||
void EQStreamProxy::FastQueuePacket(EQApplicationPacket **p, bool ack_req) {
|
||||
if(p == nullptr || *p == nullptr)
|
||||
return;
|
||||
m_structs->Encode(p, m_stream, ack_req);
|
||||
}
|
||||
|
||||
EQApplicationPacket *EQStreamProxy::PopPacket() {
|
||||
EQApplicationPacket *pack = m_stream->PopPacket();
|
||||
if(pack == nullptr)
|
||||
return(nullptr);
|
||||
|
||||
//pass this packet through the struct strategy.
|
||||
m_structs->Decode(pack);
|
||||
return(pack);
|
||||
}
|
||||
|
||||
void EQStreamProxy::Close() {
|
||||
m_stream->Close();
|
||||
}
|
||||
|
||||
uint32 EQStreamProxy::GetRemoteIP() const {
|
||||
return(m_stream->GetRemoteIP());
|
||||
}
|
||||
|
||||
uint16 EQStreamProxy::GetRemotePort() const {
|
||||
return(m_stream->GetRemotePort());
|
||||
}
|
||||
|
||||
const uint32 EQStreamProxy::GetBytesSent() const
|
||||
{
|
||||
return(m_stream->GetBytesSent());
|
||||
}
|
||||
|
||||
const uint32 EQStreamProxy::GetBytesRecieved() const
|
||||
{
|
||||
return(m_stream->GetBytesRecieved());
|
||||
}
|
||||
|
||||
const uint32 EQStreamProxy::GetBytesSentPerSecond() const
|
||||
{
|
||||
return(m_stream->GetBytesSentPerSecond());
|
||||
}
|
||||
|
||||
const uint32 EQStreamProxy::GetBytesRecvPerSecond() const
|
||||
{
|
||||
return(m_stream->GetBytesRecvPerSecond());
|
||||
}
|
||||
|
||||
void EQStreamProxy::ReleaseFromUse() {
|
||||
m_stream->ReleaseFromUse();
|
||||
|
||||
//this is so ugly, but I cant think of a better way to deal with
|
||||
//it right now...
|
||||
if(!m_stream->IsInUse()) {
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
void EQStreamProxy::RemoveData() {
|
||||
m_stream->RemoveData();
|
||||
}
|
||||
|
||||
bool EQStreamProxy::CheckState(EQStreamState state) {
|
||||
if(m_stream)
|
||||
return(m_stream->CheckState(state));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef EQSTREAMPROXY_H_
|
||||
#define EQSTREAMPROXY_H_
|
||||
|
||||
|
||||
#include "types.h"
|
||||
#include "eq_stream_intf.h"
|
||||
|
||||
class EQStream;
|
||||
class StructStrategy;
|
||||
class OpcodeManager;
|
||||
class EQApplicationPacket;
|
||||
|
||||
class EQStreamProxy : public EQStreamInterface {
|
||||
public:
|
||||
//takes ownership of the stream.
|
||||
EQStreamProxy(EQStream *&stream, const StructStrategy *structs, OpcodeManager **opcodes);
|
||||
virtual ~EQStreamProxy();
|
||||
|
||||
//EQStreamInterface:
|
||||
virtual void QueuePacket(const EQApplicationPacket *p, bool ack_req=true);
|
||||
virtual void FastQueuePacket(EQApplicationPacket **p, bool ack_req=true);
|
||||
virtual EQApplicationPacket *PopPacket();
|
||||
virtual void Close();
|
||||
virtual uint32 GetRemoteIP() const;
|
||||
virtual uint16 GetRemotePort() const;
|
||||
virtual void ReleaseFromUse();
|
||||
virtual void RemoveData();
|
||||
virtual bool CheckState(EQStreamState state);
|
||||
virtual std::string Describe() const;
|
||||
virtual const EQClientVersion ClientVersion() const;
|
||||
|
||||
virtual const uint32 GetBytesSent() const;
|
||||
virtual const uint32 GetBytesRecieved() const;
|
||||
virtual const uint32 GetBytesSentPerSecond() const;
|
||||
virtual const uint32 GetBytesRecvPerSecond() const;
|
||||
|
||||
protected:
|
||||
EQStream *const m_stream; //we own this stream object.
|
||||
const StructStrategy *const m_structs; //we do not own this object.
|
||||
//this is a pointer to a pointer to make it less likely that a packet will
|
||||
//reference an invalid opcode manager when they are being reloaded.
|
||||
OpcodeManager **const m_opcodes; //we do not own this object.
|
||||
};
|
||||
|
||||
#endif /*EQSTREAMPROXY_H_*/
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef _EQSTREAMTYPE_H
|
||||
#define _EQSTREAMTYPE_H
|
||||
|
||||
typedef enum {
|
||||
UnknownStream=0,
|
||||
LoginStream,
|
||||
WorldStream,
|
||||
ZoneStream,
|
||||
ChatOrMailStream,
|
||||
ChatStream,
|
||||
MailStream
|
||||
} EQStreamType;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,75 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "debug.h"
|
||||
#include "eqdb.h"
|
||||
#include "database.h"
|
||||
#include <mysql.h>
|
||||
#include <cstring>
|
||||
|
||||
EQDB EQDB::s_EQDB;
|
||||
|
||||
EQDB::EQDB() {
|
||||
}
|
||||
|
||||
unsigned int EQDB::field_count() {
|
||||
return mysql_field_count(mysql_ref);
|
||||
}
|
||||
|
||||
unsigned long EQDB::affected_rows() {
|
||||
return mysql_affected_rows(mysql_ref);
|
||||
}
|
||||
|
||||
unsigned long EQDB::insert_id() {
|
||||
return mysql_insert_id(mysql_ref);
|
||||
}
|
||||
|
||||
unsigned int EQDB::get_errno() {
|
||||
return mysql_errno(mysql_ref);
|
||||
}
|
||||
|
||||
Const_char * EQDB::error() {
|
||||
return mysql_error(mysql_ref);
|
||||
}
|
||||
|
||||
EQDBRes * EQDB::query(Const_char *q) {
|
||||
if (mysql_real_query(mysql_ref,q,strlen(q))==0) {
|
||||
if (mysql_field_count(mysql_ref)) {
|
||||
MYSQL_RES *r=mysql_store_result(mysql_ref);
|
||||
return new EQDBRes(r);
|
||||
} else {
|
||||
//no result, give them back a 'true but empty' result set
|
||||
return(new EQDBRes(nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//NOT THREAD SAFE!
|
||||
Const_char *EQDB::escape_string(Const_char *from) {
|
||||
int len = strlen(from);
|
||||
char *res = new char[len*2+1];
|
||||
|
||||
mysql_real_escape_string(mysql_ref,res,from,len);
|
||||
|
||||
res[len*2] = '\0';
|
||||
m_escapeBuffer = res;
|
||||
delete[] res;
|
||||
return(m_escapeBuffer.c_str());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef EQDB_H_
|
||||
#define EQDB_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "types.h"
|
||||
#include "eqdb_res.h"
|
||||
#include <mysql.h>
|
||||
|
||||
//this is the main object exported to perl.
|
||||
class EQDB {
|
||||
EQDB();
|
||||
public:
|
||||
static EQDB *Singleton() { return(&s_EQDB); }
|
||||
|
||||
static void SetMySQL(MYSQL *m) { s_EQDB.mysql_ref=m; }
|
||||
|
||||
//BEGIN PERL EXPORT
|
||||
//NOTE: you must have a space after the * of a return value
|
||||
|
||||
unsigned int field_count();
|
||||
unsigned long affected_rows();
|
||||
unsigned long insert_id();
|
||||
unsigned int get_errno();
|
||||
Const_char * error();
|
||||
EQDBRes * query(Const_char *q);
|
||||
Const_char * escape_string(Const_char *from); //NOT THREAD SAFE! (m_escapeBuffer)
|
||||
//END PERL EXPORT
|
||||
|
||||
private:
|
||||
std::string m_escapeBuffer;
|
||||
static EQDB s_EQDB;
|
||||
MYSQL *mysql_ref;
|
||||
};
|
||||
|
||||
#endif /*EQDB_H_*/
|
||||
@@ -0,0 +1,52 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "debug.h"
|
||||
#include "eqdb_res.h"
|
||||
#include <mysql.h>
|
||||
|
||||
std::vector<std::string> EQDBRes::fetch_row_array() {
|
||||
std::vector<std::string> array;
|
||||
if(res == nullptr)
|
||||
return(array);
|
||||
|
||||
int count=mysql_num_fields(res);
|
||||
MYSQL_ROW row=mysql_fetch_row(res);
|
||||
for (int i=0;i<count;i++)
|
||||
array.push_back(row[i]);
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
std::map<std::string,std::string> EQDBRes::fetch_row_hash() {
|
||||
std::map<std::string,std::string> rowhash;
|
||||
if(res == nullptr)
|
||||
return(rowhash);
|
||||
|
||||
MYSQL_FIELD *fields;
|
||||
MYSQL_ROW row;
|
||||
unsigned long num_fields,i;
|
||||
|
||||
if (res && (num_fields=mysql_num_fields(res)) && (row = mysql_fetch_row(res))!=nullptr && (fields = mysql_fetch_fields(res))!=nullptr) {
|
||||
for(i=0;i<num_fields;i++) {
|
||||
rowhash[fields[i].name]=(row[i] ? row[i] : "");
|
||||
}
|
||||
}
|
||||
|
||||
return rowhash;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef EQDBRes_H_
|
||||
#define EQDBRes_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "types.h"
|
||||
#include "database.h"
|
||||
#include <mysql.h>
|
||||
|
||||
//this is the main object exported to perl.
|
||||
class EQDBRes {
|
||||
public:
|
||||
EQDBRes(MYSQL_RES *r) { res=r; }
|
||||
~EQDBRes() { finish(); }
|
||||
|
||||
//BEGIN PERL EXPORT
|
||||
unsigned long num_rows() { return (res) ? mysql_num_rows(res) : 0; }
|
||||
unsigned long num_fields() { return (res) ? mysql_num_fields(res) : 0; }
|
||||
void DESTROY() { }
|
||||
void finish() { if (res) mysql_free_result(res); res=nullptr; };
|
||||
std::vector<std::string> fetch_row_array();
|
||||
std::map<std::string,std::string> fetch_row_hash();
|
||||
unsigned long * fetch_lengths() { return (res) ? mysql_fetch_lengths(res) : 0; }
|
||||
//END PERL EXPORT
|
||||
|
||||
private:
|
||||
MYSQL_RES *res;
|
||||
};
|
||||
|
||||
#endif /*EQDBRes_H_*/
|
||||
@@ -0,0 +1,448 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#include "../common/debug.h"
|
||||
#include "eqemu_config.h"
|
||||
#include "misc_functions.h"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
std::string EQEmuConfig::ConfigFile = "eqemu_config.xml";
|
||||
EQEmuConfig *EQEmuConfig::_config = nullptr;
|
||||
|
||||
void EQEmuConfig::do_world(TiXmlElement *ele) {
|
||||
const char *text;
|
||||
TiXmlElement * sub_ele;;
|
||||
|
||||
text= ParseTextBlock(ele,"shortname");
|
||||
if (text)
|
||||
ShortName=text;
|
||||
|
||||
text = ParseTextBlock(ele,"longname");
|
||||
if (text)
|
||||
LongName=text;
|
||||
|
||||
text = ParseTextBlock(ele,"address",true);
|
||||
if (text)
|
||||
WorldAddress=text;
|
||||
|
||||
text = ParseTextBlock(ele,"localaddress",true);
|
||||
if (text)
|
||||
LocalAddress=text;
|
||||
|
||||
text = ParseTextBlock(ele,"maxclients",true);
|
||||
if (text)
|
||||
MaxClients=atoi(text);
|
||||
|
||||
// Get the <key> element
|
||||
text = ParseTextBlock(ele,"key",true);
|
||||
if (text)
|
||||
SharedKey=text;
|
||||
|
||||
// Get the <loginserver> element
|
||||
sub_ele = ele->FirstChildElement("loginserver");
|
||||
if (sub_ele) {
|
||||
text=ParseTextBlock(sub_ele,"host",true);
|
||||
if (text)
|
||||
LoginHost=text;
|
||||
|
||||
text=ParseTextBlock(sub_ele,"port",true);
|
||||
if (text)
|
||||
LoginPort=atoi(text);
|
||||
|
||||
text=ParseTextBlock(sub_ele,"account",true);
|
||||
if (text)
|
||||
LoginAccount=text;
|
||||
|
||||
text=ParseTextBlock(sub_ele,"password",true);
|
||||
if (text)
|
||||
LoginPassword=text;
|
||||
} else {
|
||||
char str[32];
|
||||
do {
|
||||
sprintf(str, "loginserver%i", ++LoginCount);
|
||||
sub_ele = ele->FirstChildElement(str);
|
||||
if (sub_ele) {
|
||||
LoginConfig* loginconfig = new LoginConfig;
|
||||
text=ParseTextBlock(sub_ele,"host",true);
|
||||
if (text)
|
||||
loginconfig->LoginHost=text;
|
||||
|
||||
text=ParseTextBlock(sub_ele,"port",true);
|
||||
if (text)
|
||||
loginconfig->LoginPort=atoi(text);
|
||||
|
||||
text=ParseTextBlock(sub_ele,"account",true);
|
||||
if (text)
|
||||
loginconfig->LoginAccount=text;
|
||||
|
||||
text=ParseTextBlock(sub_ele,"password",true);
|
||||
if (text)
|
||||
loginconfig->LoginPassword=text;
|
||||
loginlist.Insert(loginconfig);
|
||||
}
|
||||
} while(sub_ele);
|
||||
}
|
||||
|
||||
// Check for locked
|
||||
sub_ele = ele->FirstChildElement("locked");
|
||||
if (sub_ele != nullptr)
|
||||
Locked=true;
|
||||
|
||||
// Get the <tcp> element
|
||||
sub_ele = ele->FirstChildElement("tcp");
|
||||
if(sub_ele != nullptr) {
|
||||
|
||||
text = sub_ele->Attribute("ip");
|
||||
if (text)
|
||||
WorldIP=text;
|
||||
|
||||
text = sub_ele->Attribute("port");
|
||||
if (text)
|
||||
WorldTCPPort=atoi(text);
|
||||
|
||||
text = sub_ele->Attribute("telnet");
|
||||
if (text && !strcasecmp(text,"enabled"))
|
||||
TelnetEnabled=true;
|
||||
|
||||
}
|
||||
|
||||
// Get the <http> element
|
||||
sub_ele = ele->FirstChildElement("http");
|
||||
if(sub_ele != nullptr) {
|
||||
|
||||
// text = sub_ele->Attribute("ip");
|
||||
// if (text)
|
||||
// WorldIP=text;
|
||||
|
||||
text = sub_ele->Attribute("mimefile");
|
||||
if (text)
|
||||
WorldHTTPMimeFile=text;
|
||||
|
||||
text = sub_ele->Attribute("port");
|
||||
if (text)
|
||||
WorldHTTPPort=atoi(text);
|
||||
|
||||
text = sub_ele->Attribute("enabled");
|
||||
if (text && !strcasecmp(text,"true"))
|
||||
WorldHTTPEnabled=true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void EQEmuConfig::do_chatserver(TiXmlElement *ele) {
|
||||
const char *text;
|
||||
|
||||
text=ParseTextBlock(ele,"host",true);
|
||||
if (text)
|
||||
ChatHost=text;
|
||||
|
||||
text=ParseTextBlock(ele,"port",true);
|
||||
if (text)
|
||||
ChatPort=atoi(text);
|
||||
}
|
||||
|
||||
void EQEmuConfig::do_mailserver(TiXmlElement *ele) {
|
||||
const char *text;
|
||||
|
||||
text=ParseTextBlock(ele,"host",true);
|
||||
if (text)
|
||||
MailHost=text;
|
||||
|
||||
text=ParseTextBlock(ele,"port",true);
|
||||
if (text)
|
||||
MailPort=atoi(text);
|
||||
}
|
||||
|
||||
void EQEmuConfig::do_database(TiXmlElement *ele) {
|
||||
const char *text;
|
||||
|
||||
text=ParseTextBlock(ele,"host",true);
|
||||
if (text)
|
||||
DatabaseHost=text;
|
||||
|
||||
text=ParseTextBlock(ele,"port",true);
|
||||
if (text)
|
||||
DatabasePort=atoi(text);
|
||||
|
||||
text=ParseTextBlock(ele,"username",true);
|
||||
if (text)
|
||||
DatabaseUsername=text;
|
||||
|
||||
text=ParseTextBlock(ele,"password",true);
|
||||
if (text)
|
||||
DatabasePassword=text;
|
||||
|
||||
text=ParseTextBlock(ele,"db",true);
|
||||
if (text)
|
||||
DatabaseDB=text;
|
||||
}
|
||||
|
||||
|
||||
void EQEmuConfig::do_qsdatabase(TiXmlElement *ele) {
|
||||
const char *text;
|
||||
|
||||
text=ParseTextBlock(ele,"host",true);
|
||||
if (text)
|
||||
QSDatabaseHost=text;
|
||||
|
||||
text=ParseTextBlock(ele,"port",true);
|
||||
if (text)
|
||||
QSDatabasePort=atoi(text);
|
||||
|
||||
text=ParseTextBlock(ele,"username",true);
|
||||
if (text)
|
||||
QSDatabaseUsername=text;
|
||||
|
||||
text=ParseTextBlock(ele,"password",true);
|
||||
if (text)
|
||||
QSDatabasePassword=text;
|
||||
|
||||
text=ParseTextBlock(ele,"db",true);
|
||||
if (text)
|
||||
QSDatabaseDB=text;
|
||||
}
|
||||
|
||||
void EQEmuConfig::do_zones(TiXmlElement *ele) {
|
||||
const char *text;
|
||||
TiXmlElement *sub_ele;
|
||||
// TiXmlNode *node,*sub_node;
|
||||
|
||||
text=ParseTextBlock(ele,"defaultstatus",true);
|
||||
if (text)
|
||||
DefaultStatus=atoi(text);
|
||||
|
||||
// Get the <ports> element
|
||||
sub_ele = ele->FirstChildElement("ports");
|
||||
if(sub_ele != nullptr) {
|
||||
|
||||
text = sub_ele->Attribute("low");
|
||||
if (text)
|
||||
ZonePortLow=atoi(text);;
|
||||
|
||||
text = sub_ele->Attribute("high");
|
||||
if (text)
|
||||
ZonePortHigh=atoi(text);
|
||||
}
|
||||
}
|
||||
|
||||
void EQEmuConfig::do_files(TiXmlElement *ele) {
|
||||
const char *text;
|
||||
|
||||
text=ParseTextBlock(ele,"spells",true);
|
||||
if (text)
|
||||
SpellsFile=text;
|
||||
|
||||
text=ParseTextBlock(ele,"opcodes",true);
|
||||
if (text)
|
||||
OpCodesFile=text;
|
||||
|
||||
text=ParseTextBlock(ele,"logsettings",true);
|
||||
if (text)
|
||||
LogSettingsFile=text;
|
||||
|
||||
text=ParseTextBlock(ele,"eqtime",true);
|
||||
if (text)
|
||||
EQTimeFile=text;
|
||||
}
|
||||
|
||||
void EQEmuConfig::do_directories(TiXmlElement *ele) {
|
||||
const char *text;
|
||||
|
||||
text=ParseTextBlock(ele,"maps",true);
|
||||
if (text)
|
||||
MapDir=text;
|
||||
|
||||
text=ParseTextBlock(ele,"quests",true);
|
||||
if (text)
|
||||
QuestDir=text;
|
||||
|
||||
text=ParseTextBlock(ele,"plugins",true);
|
||||
if (text)
|
||||
PluginDir=text;
|
||||
|
||||
}
|
||||
|
||||
void EQEmuConfig::do_launcher(TiXmlElement *ele) {
|
||||
const char *text;
|
||||
TiXmlElement *sub_ele;
|
||||
|
||||
text=ParseTextBlock(ele,"logprefix",true);
|
||||
if (text)
|
||||
LogPrefix = text;
|
||||
|
||||
text=ParseTextBlock(ele,"logsuffix",true);
|
||||
if (text)
|
||||
LogSuffix = text;
|
||||
|
||||
// Get the <exe> element
|
||||
text = ParseTextBlock(ele,"exe",true);
|
||||
if (text)
|
||||
ZoneExe = text;
|
||||
|
||||
// Get the <timers> element
|
||||
sub_ele = ele->FirstChildElement("timers");
|
||||
if(sub_ele != nullptr) {
|
||||
text = sub_ele->Attribute("restart");
|
||||
if (text)
|
||||
RestartWait = atoi(text);
|
||||
|
||||
text = sub_ele->Attribute("reterminate");
|
||||
if (text)
|
||||
TerminateWait = atoi(text);
|
||||
|
||||
text = sub_ele->Attribute("initial");
|
||||
if (text)
|
||||
InitialBootWait = atoi(text);
|
||||
|
||||
text = sub_ele->Attribute("interval");
|
||||
if (text)
|
||||
ZoneBootInterval = atoi(text);
|
||||
}
|
||||
}
|
||||
|
||||
std::string EQEmuConfig::GetByName(const std::string &var_name) const {
|
||||
if(var_name == "ShortName")
|
||||
return(ShortName);
|
||||
if(var_name == "LongName")
|
||||
return(LongName);
|
||||
if(var_name == "WorldAddress")
|
||||
return(WorldAddress);
|
||||
if(var_name == "LoginHost")
|
||||
return(LoginHost);
|
||||
if(var_name == "LoginAccount")
|
||||
return(LoginAccount);
|
||||
if(var_name == "LoginPassword")
|
||||
return(LoginPassword);
|
||||
if(var_name == "LoginPort")
|
||||
return(itoa(LoginPort));
|
||||
if(var_name == "Locked")
|
||||
return(Locked?"true":"false");
|
||||
if(var_name == "WorldTCPPort")
|
||||
return(itoa(WorldTCPPort));
|
||||
if(var_name == "WorldIP")
|
||||
return(WorldIP);
|
||||
if(var_name == "TelnetEnabled")
|
||||
return(TelnetEnabled?"true":"false");
|
||||
if(var_name == "WorldHTTPPort")
|
||||
return(itoa(WorldHTTPPort));
|
||||
if(var_name == "WorldHTTPMimeFile")
|
||||
return(WorldHTTPMimeFile);
|
||||
if(var_name == "WorldHTTPEnabled")
|
||||
return(WorldHTTPEnabled?"true":"false");
|
||||
if(var_name == "ChatHost")
|
||||
return(ChatHost);
|
||||
if(var_name == "ChatPort")
|
||||
return(itoa(ChatPort));
|
||||
if(var_name == "MailHost")
|
||||
return(MailHost);
|
||||
if(var_name == "MailPort")
|
||||
return(itoa(MailPort));
|
||||
if(var_name == "DatabaseHost")
|
||||
return(DatabaseHost);
|
||||
if(var_name == "DatabaseUsername")
|
||||
return(DatabaseUsername);
|
||||
if(var_name == "DatabasePassword")
|
||||
return(DatabasePassword);
|
||||
if(var_name == "DatabaseDB")
|
||||
return(DatabaseDB);
|
||||
if(var_name == "DatabasePort")
|
||||
return(itoa(DatabasePort));
|
||||
if(var_name == "QSDatabaseHost")
|
||||
return(QSDatabaseHost);
|
||||
if(var_name == "QSDatabaseUsername")
|
||||
return(QSDatabaseUsername);
|
||||
if(var_name == "QSDatabasePassword")
|
||||
return(QSDatabasePassword);
|
||||
if(var_name == "QSDatabaseDB")
|
||||
return(QSDatabaseDB);
|
||||
if(var_name == "QSDatabasePort")
|
||||
return(itoa(QSDatabasePort));
|
||||
if(var_name == "SpellsFile")
|
||||
return(SpellsFile);
|
||||
if(var_name == "OpCodesFile")
|
||||
return(OpCodesFile);
|
||||
if(var_name == "EQTimeFile")
|
||||
return(EQTimeFile);
|
||||
if(var_name == "LogSettingsFile")
|
||||
return(LogSettingsFile);
|
||||
if(var_name == "MapDir")
|
||||
return(MapDir);
|
||||
if(var_name == "QuestDir")
|
||||
return(QuestDir);
|
||||
if(var_name == "PluginDir")
|
||||
return(PluginDir);
|
||||
if(var_name == "LogPrefix")
|
||||
return(LogPrefix);
|
||||
if(var_name == "LogSuffix")
|
||||
return(LogSuffix);
|
||||
if(var_name == "ZoneExe")
|
||||
return(ZoneExe);
|
||||
if(var_name == "ZonePortLow")
|
||||
return(itoa(ZonePortLow));
|
||||
if(var_name == "ZonePortHigh")
|
||||
return(itoa(ZonePortHigh));
|
||||
if(var_name == "DefaultStatus")
|
||||
return(itoa(DefaultStatus));
|
||||
// if(var_name == "DynamicCount")
|
||||
// return(itoa(DynamicCount));
|
||||
return("");
|
||||
}
|
||||
|
||||
void EQEmuConfig::Dump() const
|
||||
{
|
||||
std::cout << "ShortName = " << ShortName << std::endl;
|
||||
std::cout << "LongName = " << LongName << std::endl;
|
||||
std::cout << "WorldAddress = " << WorldAddress << std::endl;
|
||||
std::cout << "LoginHost = " << LoginHost << std::endl;
|
||||
std::cout << "LoginAccount = " << LoginAccount << std::endl;
|
||||
std::cout << "LoginPassword = " << LoginPassword << std::endl;
|
||||
std::cout << "LoginPort = " << LoginPort << std::endl;
|
||||
std::cout << "Locked = " << Locked << std::endl;
|
||||
std::cout << "WorldTCPPort = " << WorldTCPPort << std::endl;
|
||||
std::cout << "WorldIP = " << WorldIP << std::endl;
|
||||
std::cout << "TelnetEnabled = " << TelnetEnabled << std::endl;
|
||||
std::cout << "WorldHTTPPort = " << WorldHTTPPort << std::endl;
|
||||
std::cout << "WorldHTTPMimeFile = " << WorldHTTPMimeFile << std::endl;
|
||||
std::cout << "WorldHTTPEnabled = " << WorldHTTPEnabled << std::endl;
|
||||
std::cout << "ChatHost = " << ChatHost << std::endl;
|
||||
std::cout << "ChatPort = " << ChatPort << std::endl;
|
||||
std::cout << "MailHost = " << MailHost << std::endl;
|
||||
std::cout << "MailPort = " << MailPort << std::endl;
|
||||
std::cout << "DatabaseHost = " << DatabaseHost << std::endl;
|
||||
std::cout << "DatabaseUsername = " << DatabaseUsername << std::endl;
|
||||
std::cout << "DatabasePassword = " << DatabasePassword << std::endl;
|
||||
std::cout << "DatabaseDB = " << DatabaseDB << std::endl;
|
||||
std::cout << "DatabasePort = " << DatabasePort << std::endl;
|
||||
std::cout << "QSDatabaseHost = " << QSDatabaseHost << std::endl;
|
||||
std::cout << "QSDatabaseUsername = " << QSDatabaseUsername << std::endl;
|
||||
std::cout << "QSDatabasePassword = " << QSDatabasePassword << std::endl;
|
||||
std::cout << "QSDatabaseDB = " << QSDatabaseDB << std::endl;
|
||||
std::cout << "QSDatabasePort = " << QSDatabasePort << std::endl;
|
||||
std::cout << "SpellsFile = " << SpellsFile << std::endl;
|
||||
std::cout << "OpCodesFile = " << OpCodesFile << std::endl;
|
||||
std::cout << "EQTimeFile = " << EQTimeFile << std::endl;
|
||||
std::cout << "LogSettingsFile = " << LogSettingsFile << std::endl;
|
||||
std::cout << "MapDir = " << MapDir << std::endl;
|
||||
std::cout << "QuestDir = " << QuestDir << std::endl;
|
||||
std::cout << "PluginDir = " << PluginDir << std::endl;
|
||||
std::cout << "ZonePortLow = " << ZonePortLow << std::endl;
|
||||
std::cout << "ZonePortHigh = " << ZonePortHigh << std::endl;
|
||||
std::cout << "DefaultStatus = " << (int)DefaultStatus << std::endl;
|
||||
// std::cout << "DynamicCount = " << DynamicCount << std::endl;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
/* EQEMu: Everquest Server Emulator
|
||||
Copyright (C) 2001-2006 EQEMu Development Team (http://eqemulator.net)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY except by those people which sell it, which
|
||||
are required to give you total support for your newly bought product;
|
||||
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef __EQEmuConfig_H
|
||||
#define __EQEmuConfig_H
|
||||
|
||||
#include "xml_parser.h"
|
||||
#include "linked_list.h"
|
||||
|
||||
struct LoginConfig {
|
||||
std::string LoginHost;
|
||||
std::string LoginAccount;
|
||||
std::string LoginPassword;
|
||||
uint16 LoginPort;
|
||||
};
|
||||
|
||||
class EQEmuConfig : public XMLParser {
|
||||
public:
|
||||
virtual std::string GetByName(const std::string &var_name) const;
|
||||
|
||||
// From <world/>
|
||||
std::string ShortName;
|
||||
std::string LongName;
|
||||
std::string WorldAddress;
|
||||
std::string LocalAddress;
|
||||
std::string LoginHost;
|
||||
std::string LoginAccount;
|
||||
std::string LoginPassword;
|
||||
uint16 LoginPort;
|
||||
uint32 LoginCount;
|
||||
LinkedList<LoginConfig*> loginlist;
|
||||
bool Locked;
|
||||
uint16 WorldTCPPort;
|
||||
std::string WorldIP;
|
||||
bool TelnetEnabled;
|
||||
int32 MaxClients;
|
||||
bool WorldHTTPEnabled;
|
||||
uint16 WorldHTTPPort;
|
||||
std::string WorldHTTPMimeFile;
|
||||
std::string SharedKey;
|
||||
|
||||
// From <chatserver/>
|
||||
std::string ChatHost;
|
||||
uint16 ChatPort;
|
||||
|
||||
// From <mailserver/>
|
||||
std::string MailHost;
|
||||
uint16 MailPort;
|
||||
|
||||
// From <database/>
|
||||
std::string DatabaseHost;
|
||||
std::string DatabaseUsername;
|
||||
std::string DatabasePassword;
|
||||
std::string DatabaseDB;
|
||||
uint16 DatabasePort;
|
||||
|
||||
// From <qsdatabase> // QueryServ
|
||||
std::string QSDatabaseHost;
|
||||
std::string QSDatabaseUsername;
|
||||
std::string QSDatabasePassword;
|
||||
std::string QSDatabaseDB;
|
||||
uint16 QSDatabasePort;
|
||||
|
||||
// From <files/>
|
||||
std::string SpellsFile;
|
||||
std::string OpCodesFile;
|
||||
std::string EQTimeFile;
|
||||
std::string LogSettingsFile;
|
||||
|
||||
// From <directories/>
|
||||
std::string MapDir;
|
||||
std::string QuestDir;
|
||||
std::string PluginDir;
|
||||
|
||||
// From <launcher/>
|
||||
std::string LogPrefix;
|
||||
std::string LogSuffix;
|
||||
std::string ZoneExe;
|
||||
uint32 RestartWait;
|
||||
uint32 TerminateWait;
|
||||
uint32 InitialBootWait;
|
||||
uint32 ZoneBootInterval;
|
||||
|
||||
// From <zones/>
|
||||
uint16 ZonePortLow;
|
||||
uint16 ZonePortHigh;
|
||||
uint8 DefaultStatus;
|
||||
|
||||
// uint16 DynamicCount;
|
||||
|
||||
// map<string,uint16> StaticZones;
|
||||
|
||||
protected:
|
||||
|
||||
static EQEmuConfig *_config;
|
||||
|
||||
static std::string ConfigFile;
|
||||
|
||||
#define ELEMENT(name) \
|
||||
void do_##name(TiXmlElement *ele);
|
||||
#include "eqemu_config_elements.h"
|
||||
|
||||
|
||||
EQEmuConfig() {
|
||||
// import the needed handler prototypes
|
||||
#define ELEMENT(name) \
|
||||
Handlers[#name]=(ElementHandler)&EQEmuConfig::do_##name;
|
||||
#include "eqemu_config_elements.h"
|
||||
|
||||
// Set sane defaults
|
||||
|
||||
// Login server
|
||||
LoginHost="eqemulator.net";
|
||||
LoginPort=5998;
|
||||
|
||||
// World
|
||||
Locked=false;
|
||||
WorldTCPPort=9000;
|
||||
TelnetEnabled=false;
|
||||
WorldHTTPEnabled=false;
|
||||
WorldHTTPPort=9080;
|
||||
WorldHTTPMimeFile="mime.types";
|
||||
SharedKey = ""; //blank disables authentication
|
||||
|
||||
// Mail
|
||||
ChatHost="eqchat.eqemulator.net";
|
||||
ChatPort=7778;
|
||||
|
||||
// Mail
|
||||
MailHost="eqmail.eqemulator.net";
|
||||
MailPort=7779;
|
||||
|
||||
// Mysql
|
||||
DatabaseHost="localhost";
|
||||
DatabasePort=3306;
|
||||
DatabaseUsername="eq";
|
||||
DatabasePassword="eq";
|
||||
DatabaseDB="eq";
|
||||
|
||||
// QueryServ Database
|
||||
QSDatabaseHost="localhost";
|
||||
QSDatabasePort=3306;
|
||||
QSDatabaseUsername="eq";
|
||||
QSDatabasePassword="eq";
|
||||
QSDatabaseDB="eq";
|
||||
|
||||
// Files
|
||||
SpellsFile="spells_us.txt";
|
||||
OpCodesFile="opcodes.conf";
|
||||
EQTimeFile="eqtime.cfg";
|
||||
LogSettingsFile="log.ini";
|
||||
|
||||
// Dirs
|
||||
MapDir="Maps";
|
||||
QuestDir="quests";
|
||||
PluginDir="plugins";
|
||||
|
||||
// Launcher
|
||||
LogPrefix = "logs/zone-";
|
||||
LogSuffix = ".log";
|
||||
RestartWait = 10000; //milliseconds
|
||||
TerminateWait = 10000; //milliseconds
|
||||
InitialBootWait = 20000; //milliseconds
|
||||
ZoneBootInterval = 2000; //milliseconds
|
||||
#ifdef WIN32
|
||||
ZoneExe = "zone.exe";
|
||||
#else
|
||||
ZoneExe = "./zone";
|
||||
#endif
|
||||
|
||||
// Zones
|
||||
ZonePortLow=7000;
|
||||
ZonePortHigh=7999;
|
||||
DefaultStatus=0;
|
||||
|
||||
// For where zones need to connect to.
|
||||
WorldIP="127.0.0.1";
|
||||
|
||||
// Dynamics to start
|
||||
//DynamicCount=5;
|
||||
|
||||
MaxClients=-1;
|
||||
|
||||
LoginCount=0;
|
||||
|
||||
}
|
||||
virtual ~EQEmuConfig() {}
|
||||
|
||||
public:
|
||||
|
||||
// Produce a const singleton
|
||||
static const EQEmuConfig *get() {
|
||||
if (_config == nullptr)
|
||||
LoadConfig();
|
||||
return(_config);
|
||||
}
|
||||
|
||||
// Allow the use to set the conf file to be used.
|
||||
static void SetConfigFile(std::string file) { EQEmuConfig::ConfigFile = file; }
|
||||
|
||||
// Load the config
|
||||
static bool LoadConfig() {
|
||||
if (_config != nullptr)
|
||||
delete _config;
|
||||
_config=new EQEmuConfig;
|
||||
|
||||
return _config->ParseFile(EQEmuConfig::ConfigFile.c_str(),"server");
|
||||
}
|
||||
|
||||
void Dump() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user