Compare commits
2391
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
842410e773 | ||
|
|
da3223bf41 | ||
|
|
292273002b | ||
|
|
1fa24557e3 | ||
|
|
38edc91857 | ||
|
|
faec98dc2c | ||
|
|
5eb6a120af | ||
|
|
510f82d908 | ||
|
|
b2d11a55de | ||
|
|
a5fc8c041e | ||
|
|
e47e196d81 | ||
|
|
c98574c426 | ||
|
|
3240285ed2 | ||
|
|
b41188c7c9 | ||
|
|
e7ac9b013d | ||
|
|
8ba0672cd9 | ||
|
|
b34de51b8c | ||
|
|
ce7dccfffb | ||
|
|
ae0585df42 | ||
|
|
2ed5b865e3 | ||
|
|
b9c639620c | ||
|
|
c8d4fab7d9 | ||
|
|
6eb5f8fa38 | ||
|
|
82cd96aef6 | ||
|
|
3723860af3 | ||
|
|
3069350df4 | ||
|
|
3523db0314 | ||
|
|
f2f10bc196 | ||
|
|
97801196df | ||
|
|
7b013d5097 | ||
|
|
42237ddc03 | ||
|
|
6182c33318 | ||
|
|
421c39bb6a | ||
|
|
809392d1dc | ||
|
|
73fd660ff4 | ||
|
|
36339c22ca | ||
|
|
65d0d1380e | ||
|
|
d75d410100 | ||
|
|
4ab75cc19c | ||
|
|
f7fd4fe4a7 | ||
|
|
bea10f0fb1 | ||
|
|
e078b2b542 | ||
|
|
0205f5988d | ||
|
|
b1ac6f9a80 | ||
|
|
001ea29ee8 | ||
|
|
704f64f467 | ||
|
|
65ce00763a | ||
|
|
8033a8e134 | ||
|
|
7d3f8117a0 | ||
|
|
35d2a648cf | ||
|
|
02c56a6a42 | ||
|
|
17eb8c2652 | ||
|
|
f3f696f16e | ||
|
|
42ce2ce4d5 | ||
|
|
f4a047d3d1 | ||
|
|
a36a449983 | ||
|
|
df6d637e13 | ||
|
|
a6a181a4e4 | ||
|
|
61dea382c9 | ||
|
|
8c0aa36bbd | ||
|
|
7b2eaa5a6e | ||
|
|
a99a7a3d54 | ||
|
|
f158621572 | ||
|
|
97861312a2 | ||
|
|
f63ee4d937 | ||
|
|
e4e49e0623 | ||
|
|
261dd2c126 | ||
|
|
b68a60976c | ||
|
|
6156b61949 | ||
|
|
d22e6ae8da | ||
|
|
5a00b8c9d4 | ||
|
|
be74c9f23e | ||
|
|
bf0f9986f4 | ||
|
|
84c633c4da | ||
|
|
83521ba442 | ||
|
|
1033441f22 | ||
|
|
9faf4aaa85 | ||
|
|
3407d52723 | ||
|
|
d2eedc0e31 | ||
|
|
2c8fe40610 | ||
|
|
8bc615f29b | ||
|
|
e851097670 | ||
|
|
cfa6193bb8 | ||
|
|
bc69fc9f8e | ||
|
|
1a59e55723 | ||
|
|
38e88b5dcc | ||
|
|
ce2e55c40d | ||
|
|
19d21bc2d3 | ||
|
|
29594aeb0b | ||
|
|
470fda6af4 | ||
|
|
cdedec7606 | ||
|
|
a2d2875fc9 | ||
|
|
f881c5e343 | ||
|
|
e90c1db855 | ||
|
|
c7fb295eab | ||
|
|
d49ed86a1d | ||
|
|
da192501d1 | ||
|
|
d7d969774e | ||
|
|
575aa6ab4a | ||
|
|
0732992c4f | ||
|
|
bd1bde7def | ||
|
|
d9128d874b | ||
|
|
35f8289ef7 | ||
|
|
c9465bc4e1 | ||
|
|
cd5f7a61c2 | ||
|
|
fc47482dd3 | ||
|
|
aba1ecf738 | ||
|
|
3db7e85dff | ||
|
|
119d4b83c9 | ||
|
|
18975ff48f | ||
|
|
0cdcc3b08d | ||
|
|
5497e0dcf2 | ||
|
|
3070a1c26f | ||
|
|
0cc33d4bad | ||
|
|
731b9689bd | ||
|
|
c5dd056c84 | ||
|
|
e1f7d25603 | ||
|
|
1ed87af40c | ||
|
|
f5cea78b45 | ||
|
|
87a325f68e | ||
|
|
0cca99ea86 | ||
|
|
be89b25d96 | ||
|
|
434cb93dce | ||
|
|
46458cdbfe | ||
|
|
518f1f6f51 | ||
|
|
2c782ef842 | ||
|
|
e6886ba565 | ||
|
|
98236c5fca | ||
|
|
0002aa228c | ||
|
|
0e017393d5 | ||
|
|
be192f9807 | ||
|
|
6cec5c95aa | ||
|
|
1df5897c1a | ||
|
|
b8e7d0e373 | ||
|
|
a06f902ee1 | ||
|
|
e87291362b | ||
|
|
483cd9f5a8 | ||
|
|
05878c1e83 | ||
|
|
e4bdde6475 | ||
|
|
7c5da6a658 | ||
|
|
3fd0fc0a5c | ||
|
|
047dd0dec1 | ||
|
|
5acd8c77c9 | ||
|
|
468760c902 | ||
|
|
e70cddfe3e | ||
|
|
890c7119fe | ||
|
|
fba9d713b7 | ||
|
|
5288927964 | ||
|
|
07735c1fe2 | ||
|
|
6739b0c280 | ||
|
|
b1189479ed | ||
|
|
87d668afce | ||
|
|
707a6f5a00 | ||
|
|
f51522d2c9 | ||
|
|
c11164c4d9 | ||
|
|
9569066b6e | ||
|
|
c6038c76a6 | ||
|
|
3258ad0781 | ||
|
|
f0cb2ed5c2 | ||
|
|
5d28ea6162 | ||
|
|
af4bb473e7 | ||
|
|
94adc98ef5 | ||
|
|
7f2528d0fa | ||
|
|
817696358b | ||
|
|
81ebd8cf8d | ||
|
|
1bc536fdfa | ||
|
|
80ca6f8cd4 | ||
|
|
feaeb6a0ea | ||
|
|
a3fb4dfe5e | ||
|
|
337b755f34 | ||
|
|
a3f0b99d67 | ||
|
|
4f7b26f73b | ||
|
|
067ee97d99 | ||
|
|
98079197a0 | ||
|
|
c3a8b0e127 | ||
|
|
5d0a208e34 | ||
|
|
92db2a1987 | ||
|
|
16dc3daa8a | ||
|
|
d5cc622227 | ||
|
|
59ecab555b | ||
|
|
b697537378 | ||
|
|
eb323b7fa5 | ||
|
|
a327a80fcd | ||
|
|
6bb0b3aaa6 | ||
|
|
e359863e10 | ||
|
|
6162312fb7 | ||
|
|
0ecab49059 | ||
|
|
acaa301eda | ||
|
|
8d3bec0ca0 | ||
|
|
1b32e25d20 | ||
|
|
0c9a476851 | ||
|
|
ce8125b896 | ||
|
|
155cdc318c | ||
|
|
b492426a79 | ||
|
|
2b5554a21d | ||
|
|
2e395c6787 | ||
|
|
c8a9ae2f81 | ||
|
|
61d7e53cca | ||
|
|
465a3ff10b | ||
|
|
617ee1c98e | ||
|
|
a5a8e03d2d | ||
|
|
0d299402b9 | ||
|
|
eddc83054c | ||
|
|
ea1e3ac8d6 | ||
|
|
86fde36542 | ||
|
|
29386a72f6 | ||
|
|
8907569dd8 | ||
|
|
22d740ef61 | ||
|
|
6baf01ac3b | ||
|
|
c310db4b95 | ||
|
|
733e33e82a | ||
|
|
6e6f6e7479 | ||
|
|
865dd3ecd6 | ||
|
|
69f694d47c | ||
|
|
1819f491b5 | ||
|
|
c4d5235217 | ||
|
|
6439769d50 | ||
|
|
0c900be7fc | ||
|
|
bc8d02c998 | ||
|
|
1fc841713e | ||
|
|
84f67fcd2d | ||
|
|
eb3b4d9822 | ||
|
|
a401d97b09 | ||
|
|
74e9cdd709 | ||
|
|
2ae0d05a23 | ||
|
|
22cc68808c | ||
|
|
9952f62a33 | ||
|
|
f382c3fb5b | ||
|
|
4374cb2168 | ||
|
|
98831a8667 | ||
|
|
66d3f5e60e | ||
|
|
0ccf21ecb6 | ||
|
|
c9ee066a1d | ||
|
|
42c5444a10 | ||
|
|
e4fda1bd78 | ||
|
|
e55747a9e4 | ||
|
|
351917be35 | ||
|
|
063734607f | ||
|
|
19dce02a9c | ||
|
|
e56a1ac2ef | ||
|
|
9b6e36f6cd | ||
|
|
5615db767f | ||
|
|
0242508c19 | ||
|
|
512e7c37c1 | ||
|
|
5c1a5e35b9 | ||
|
|
392f0a92c7 | ||
|
|
92fb9f62dd | ||
|
|
e978992ba2 | ||
|
|
8c8dcdbe66 | ||
|
|
4afbf9d573 | ||
|
|
6f0fde48f3 | ||
|
|
20642a8518 | ||
|
|
64a8c20243 | ||
|
|
f9929ef9ac | ||
|
|
381198137f | ||
|
|
53e3331f0b | ||
|
|
ec7aadc431 | ||
|
|
7e784d5453 | ||
|
|
6d13a70b99 | ||
|
|
7f4c5512a9 | ||
|
|
b0cf46521b | ||
|
|
ecf33e313f | ||
|
|
3b9d03e015 | ||
|
|
cf1c95e42e | ||
|
|
4d1e265a5c | ||
|
|
34a204be59 | ||
|
|
ed2bb90ca5 | ||
|
|
c7410e3a35 | ||
|
|
f7e51b6110 | ||
|
|
2a25025d2e | ||
|
|
a35e22c76e | ||
|
|
30da01763d | ||
|
|
f896c4a24d | ||
|
|
5e3dc6c6c4 | ||
|
|
7cb61fe7c3 | ||
|
|
7fc48b8efe | ||
|
|
87653bf780 | ||
|
|
d5e05fae59 | ||
|
|
221732682b | ||
|
|
a7e206a24e | ||
|
|
b71d3c0174 | ||
|
|
75f4fdac40 | ||
|
|
636a3d7b37 | ||
|
|
e24d494467 | ||
|
|
63b0586c0f | ||
|
|
1e85181f0a | ||
|
|
950f949a51 | ||
|
|
6faaefdc69 | ||
|
|
f1721409c9 | ||
|
|
c730598960 | ||
|
|
5d468dd2c0 | ||
|
|
2382453d50 | ||
|
|
3b9c74ce96 | ||
|
|
6cd5bf87d8 | ||
|
|
25faf18760 | ||
|
|
f6737a4760 | ||
|
|
b5e077c6f7 | ||
|
|
2a3964a861 | ||
|
|
9a03d1227f | ||
|
|
60d7f605cb | ||
|
|
8fc2f39d37 | ||
|
|
03ac4d728d | ||
|
|
755fa4d5f3 | ||
|
|
24679be81a | ||
|
|
cb0f8f0eaa | ||
|
|
a8c91db585 | ||
|
|
74f1f8f6bb | ||
|
|
a44cfe134a | ||
|
|
57bdd9fdb0 | ||
|
|
d8d1a06ee4 | ||
|
|
3cd6ce9bb0 | ||
|
|
52211de8e9 | ||
|
|
4004471d8d | ||
|
|
d2296e463b | ||
|
|
f586bc2f07 | ||
|
|
699f876473 | ||
|
|
0fcbe934ff | ||
|
|
bd157080dc | ||
|
|
f086c0a638 | ||
|
|
c30f033022 | ||
|
|
a16ba7ca7b | ||
|
|
932010e63c | ||
|
|
34ddf6d2c8 | ||
|
|
29bff12b23 | ||
|
|
2be15ff629 | ||
|
|
34e9605519 | ||
|
|
6c3486d732 | ||
|
|
1d8e90cdda | ||
|
|
600f493e69 | ||
|
|
8acb60947c | ||
|
|
6b6dbc6c06 | ||
|
|
0a6fa1052a | ||
|
|
3bc55e6890 | ||
|
|
80dfa1cc77 | ||
|
|
b9f85c8e74 | ||
|
|
1fbe066328 | ||
|
|
4e15a92984 | ||
|
|
4e6d66b721 | ||
|
|
dd3409bb9b | ||
|
|
96727a7610 | ||
|
|
4cc214e1a6 | ||
|
|
b7feeef350 | ||
|
|
b18c8cbfd6 | ||
|
|
ae789148b1 | ||
|
|
ef9d2fda9d | ||
|
|
09bde65dfc | ||
|
|
02e85b3d98 | ||
|
|
fccf275194 | ||
|
|
5edfa79543 | ||
|
|
b6d98c762c | ||
|
|
d42a8c7c1e | ||
|
|
11d3cf94f7 | ||
|
|
0e4b1ca4cf | ||
|
|
1bcc5b8a44 | ||
|
|
7df2f8e045 | ||
|
|
9f3584a056 | ||
|
|
4e73713fab | ||
|
|
e07c120cab | ||
|
|
e3734803f0 | ||
|
|
7c757ac119 | ||
|
|
c5425def7f | ||
|
|
e60c672485 | ||
|
|
908ffdb523 | ||
|
|
d56dc62e03 | ||
|
|
f08f1ef0d6 | ||
|
|
5cb2d68fd7 | ||
|
|
96d0959db1 | ||
|
|
5a6b2c8ebf | ||
|
|
343f64f6b7 | ||
|
|
f9ad35badf | ||
|
|
60b6a8dfb0 | ||
|
|
00f3970036 | ||
|
|
7d78c141e7 | ||
|
|
123ad7aab1 | ||
|
|
ee51162c3f | ||
|
|
af93d819c6 | ||
|
|
d426d1f04f | ||
|
|
6cac489fce | ||
|
|
5c507cc35c | ||
|
|
dbec0b165c | ||
|
|
4e8b66bf99 | ||
|
|
8dcbe14ea0 | ||
|
|
06dcb991e8 | ||
|
|
e262064fd8 | ||
|
|
a80b9c5c0f | ||
|
|
638aae0040 | ||
|
|
35ac74c7a7 | ||
|
|
7bb9da2a26 | ||
|
|
b5b9b8388c | ||
|
|
e7e92d4e40 | ||
|
|
33e869a4e5 | ||
|
|
0bc9aa46e6 | ||
|
|
80ad76a563 | ||
|
|
7e29f22f8f | ||
|
|
a9eb3a0d45 | ||
|
|
ab6b45b81c | ||
|
|
385eae892c | ||
|
|
5f309f45f8 | ||
|
|
a2e5e2a442 | ||
|
|
b42e5ac922 | ||
|
|
544204654d | ||
|
|
5c971fd51b | ||
|
|
6507d947cc | ||
|
|
30415e299e | ||
|
|
8eeea2aba1 | ||
|
|
bb1431cd3b | ||
|
|
a2aec9b42e | ||
|
|
ef74b51c8b | ||
|
|
e74aa099bc | ||
|
|
8140cb2d6b | ||
|
|
d981e252d2 | ||
|
|
e6a04abc9e | ||
|
|
c90477a720 | ||
|
|
11c8084ccd | ||
|
|
7747beb4cf | ||
|
|
9fa7421122 | ||
|
|
f2ca671d1f | ||
|
|
d4da21b07f | ||
|
|
4b2d8b53fa | ||
|
|
7bfd5e521e | ||
|
|
060c832f89 | ||
|
|
8c9fd3746b | ||
|
|
314184beea | ||
|
|
17462cbe5a | ||
|
|
ae4e043c3e | ||
|
|
6def79ff23 | ||
|
|
1ba7024a3a | ||
|
|
44aaaf8b10 | ||
|
|
62754333cd | ||
|
|
8938a29904 | ||
|
|
2c6ef5825f | ||
|
|
b090aa36bf | ||
|
|
cb1dae5aab | ||
|
|
c9e824632f | ||
|
|
0436fb0ab3 | ||
|
|
767c5cf468 | ||
|
|
f01ad5317a | ||
|
|
fac3138ff5 | ||
|
|
ab9e86910c | ||
|
|
e88e9342ef | ||
|
|
e3a01b0e1a | ||
|
|
07d928dbad | ||
|
|
a402b3cceb | ||
|
|
99dbe06d8a | ||
|
|
29694ec13b | ||
|
|
1e8db957bf | ||
|
|
0656696251 | ||
|
|
af04c964fe | ||
|
|
bc81361319 | ||
|
|
853bcf703a | ||
|
|
c81248004a | ||
|
|
79787cb868 | ||
|
|
20aae06f12 | ||
|
|
a20eb08dc6 | ||
|
|
8d60a46358 | ||
|
|
4c376cbcb7 | ||
|
|
d83c498a8f | ||
|
|
531b053096 | ||
|
|
0dafe04899 | ||
|
|
7170a8f11c | ||
|
|
2ef874dbc9 | ||
|
|
cb8541548b | ||
|
|
46e3de8d24 | ||
|
|
5addaffa56 | ||
|
|
f40ae82df4 | ||
|
|
6ebf04b75d | ||
|
|
e93dd7af3f | ||
|
|
4dc2383fe3 | ||
|
|
5f827089d3 | ||
|
|
8a7f8c5cbd | ||
|
|
dae8aba554 | ||
|
|
b9029dedff | ||
|
|
1a375bcc17 | ||
|
|
eaccec3e4a | ||
|
|
5fff988a8f | ||
|
|
1a1bb54c4f | ||
|
|
97f2fc9d7f | ||
|
|
2e1235a585 | ||
|
|
426c1a090f | ||
|
|
50b4ad4e11 | ||
|
|
a330d0a1bf | ||
|
|
4e6774befb | ||
|
|
b1b993989a | ||
|
|
2e59202ea4 | ||
|
|
4a6d29c9e2 | ||
|
|
e746fdf1fb | ||
|
|
cac7793f15 | ||
|
|
e0c95674c8 | ||
|
|
bc42cef765 | ||
|
|
680a198fa2 | ||
|
|
38f7be7664 | ||
|
|
94f5b5d06c | ||
|
|
f66a904c31 | ||
|
|
8e0039aaec | ||
|
|
dd1e5997f3 | ||
|
|
bc6e920213 | ||
|
|
a28c3cac9b | ||
|
|
6670b93cc6 | ||
|
|
8826663186 | ||
|
|
c5087d7a39 | ||
|
|
5ba9816377 | ||
|
|
4eecc80b9a | ||
|
|
008fbf78a5 | ||
|
|
48150e0c7a | ||
|
|
d8fd60b562 | ||
|
|
178658912e | ||
|
|
5539484f92 | ||
|
|
a9a1939f75 | ||
|
|
850f96b986 | ||
|
|
693e584dcd | ||
|
|
397b70add0 | ||
|
|
a0eb6a9550 | ||
|
|
6bd49ff415 | ||
|
|
43cdc65708 | ||
|
|
cd6886319c | ||
|
|
6e839a95c6 | ||
|
|
2dcee81f22 | ||
|
|
a253d35bcd | ||
|
|
02e9d214b4 | ||
|
|
30a2160839 | ||
|
|
d57d7e7401 | ||
|
|
1f5b735dbd | ||
|
|
d5a26adc49 | ||
|
|
221d34f809 | ||
|
|
8922ed0c5d | ||
|
|
27b1817b10 | ||
|
|
3a488f7041 | ||
|
|
8f7a1641fc | ||
|
|
b0799d3336 | ||
|
|
2130c60fd9 | ||
|
|
ecb707e38d | ||
|
|
7e94bfb307 | ||
|
|
51bba0b894 | ||
|
|
775d4f04f2 | ||
|
|
4320d7b17a | ||
|
|
174bf307a2 | ||
|
|
f8349e846a | ||
|
|
ef7d3abefd | ||
|
|
b77e8c50ac | ||
|
|
0d6179299c | ||
|
|
515df38b72 | ||
|
|
c5e69900f9 | ||
|
|
2d5bc4007f | ||
|
|
3a315e88c2 | ||
|
|
6c5a3fdaf2 | ||
|
|
02f188899e | ||
|
|
aab8c6ac9f | ||
|
|
5d391fda07 | ||
|
|
8538233985 | ||
|
|
3b4a343274 | ||
|
|
f90b7ade76 | ||
|
|
83a29cf82b | ||
|
|
89bd4d7329 | ||
|
|
ed662dc8cf | ||
|
|
6574dd8273 | ||
|
|
63f8ea89ca | ||
|
|
34c8220e5d | ||
|
|
3595525f12 | ||
|
|
4989666d72 | ||
|
|
f7fda0023c | ||
|
|
13be211e9a | ||
|
|
f6b39720ec | ||
|
|
764e38a58f | ||
|
|
e34e9b9869 | ||
|
|
721f348684 | ||
|
|
9ddcd335af | ||
|
|
eda9a42ee2 | ||
|
|
22a964d89a | ||
|
|
855ece1d3b | ||
|
|
568da23c96 | ||
|
|
4015f9c1c9 | ||
|
|
21740d9a26 | ||
|
|
05aa3fd39d | ||
|
|
b1c8ad8412 | ||
|
|
3100e23b87 | ||
|
|
da3e868df5 | ||
|
|
63e0e2bc82 | ||
|
|
a35ecde538 | ||
|
|
81ad870def | ||
|
|
24f1c89b96 | ||
|
|
a761194917 | ||
|
|
9321229321 | ||
|
|
e5ebd65176 | ||
|
|
5f7b22d2a4 | ||
|
|
52da989762 | ||
|
|
625c7a98f2 | ||
|
|
278998f7d0 | ||
|
|
c29e185d2a | ||
|
|
5c66a78763 | ||
|
|
5e3a189642 | ||
|
|
7b89f5fab3 | ||
|
|
b0e7407552 | ||
|
|
407c24cb14 | ||
|
|
65cb76e2f6 | ||
|
|
678ad74bf4 | ||
|
|
12e20eecf7 | ||
|
|
a5ae01a2f4 | ||
|
|
614c7d8332 | ||
|
|
9121472061 | ||
|
|
54fd778830 | ||
|
|
37c2a83523 | ||
|
|
28a5d4b342 | ||
|
|
0dcfdf3d7e | ||
|
|
0f7f9dad97 | ||
|
|
4276301499 | ||
|
|
d41ffaad7e | ||
|
|
5c0ae11a46 | ||
|
|
7424deefb9 | ||
|
|
c92354debb | ||
|
|
50eca8e60c | ||
|
|
c570150318 | ||
|
|
3bafc1e2f4 | ||
|
|
e28bf30b7d | ||
|
|
7becdc48d3 | ||
|
|
7a3d4e70bf | ||
|
|
6e73aba250 | ||
|
|
5797411b2b | ||
|
|
d2c4257c36 | ||
|
|
b057580a62 | ||
|
|
a1ad9e1acf | ||
|
|
a877a4475b | ||
|
|
441259e36a | ||
|
|
ab8bbbd118 | ||
|
|
39d604ae6c | ||
|
|
a7cb35c2af | ||
|
|
ff558b32e5 | ||
|
|
6b588fff61 | ||
|
|
3f3f1b8914 | ||
|
|
05e48ef866 | ||
|
|
6e1f095186 | ||
|
|
852703ccca | ||
|
|
01203a5a44 | ||
|
|
96ae65a96c | ||
|
|
9df93b0708 | ||
|
|
f307e44b79 | ||
|
|
dc8a22a76a | ||
|
|
8579e873ca | ||
|
|
addfb3c8a1 | ||
|
|
358bcca3a2 | ||
|
|
b209279589 | ||
|
|
5479084039 | ||
|
|
95ab60c4eb | ||
|
|
2111e90540 | ||
|
|
dc9c52bfd6 | ||
|
|
f5461df28c | ||
|
|
e5afdb4181 | ||
|
|
250dc1b206 | ||
|
|
f5f26e2dfe | ||
|
|
f7c54e9027 | ||
|
|
1ce828b6c8 | ||
|
|
c471e41dc7 | ||
|
|
afc9310704 | ||
|
|
bf898dd45f | ||
|
|
7d6eb2bd81 | ||
|
|
547ac5b026 | ||
|
|
7328ce657b | ||
|
|
14c9ac8fdb | ||
|
|
93cd78a6c5 | ||
|
|
b62f332611 | ||
|
|
47f135534d | ||
|
|
bb095097a2 | ||
|
|
c873e1aafb | ||
|
|
455bb14589 | ||
|
|
e786ff54f7 | ||
|
|
af3c10b173 | ||
|
|
351ac171d2 | ||
|
|
96c74651db | ||
|
|
329d587214 | ||
|
|
4e3df76358 | ||
|
|
161084e6f8 | ||
|
|
b38c9824fe | ||
|
|
4e4c2a7bb0 | ||
|
|
1c30b88069 | ||
|
|
31f6c0cb18 | ||
|
|
9cb693d8a3 | ||
|
|
896e92264f | ||
|
|
f32b210ec9 | ||
|
|
8f7ecf66a4 | ||
|
|
581068c09b | ||
|
|
0f5f1a814e | ||
|
|
18f9d65938 | ||
|
|
589fc96bc9 | ||
|
|
5787fca029 | ||
|
|
09ea982bbd | ||
|
|
e3569edb65 | ||
|
|
3db7116620 | ||
|
|
83672a6ce0 | ||
|
|
90fec5c6df | ||
|
|
257535daf2 | ||
|
|
eb0878be2b | ||
|
|
f229badbfc | ||
|
|
9a6866d14a | ||
|
|
8991b557ab | ||
|
|
be60a55aa3 | ||
|
|
10795fbed5 | ||
|
|
9d7e720f33 | ||
|
|
7605940994 | ||
|
|
94ff26bdf1 | ||
|
|
2a06680252 | ||
|
|
38a069b97a | ||
|
|
4b58b9f673 | ||
|
|
ffc23a1a1e | ||
|
|
cab60f7385 | ||
|
|
92ce0fe814 | ||
|
|
79d594aca3 | ||
|
|
a343410793 | ||
|
|
3332da3489 | ||
|
|
1a65b308d1 | ||
|
|
f9309c83d2 | ||
|
|
636161e183 | ||
|
|
897878f8ae | ||
|
|
7650cee459 | ||
|
|
30c764e4b3 | ||
|
|
dc92335fbe | ||
|
|
8c625ca87d | ||
|
|
536750b428 | ||
|
|
11e7bb10f1 | ||
|
|
f7cd28cfd3 | ||
|
|
83c7bdf872 | ||
|
|
97383028e5 | ||
|
|
4a6d263dad | ||
|
|
549e881ba4 | ||
|
|
c72ea03a86 | ||
|
|
9fed0724f7 | ||
|
|
ed96da1afc | ||
|
|
da3146e294 | ||
|
|
5aa0cdfd45 | ||
|
|
0be7813398 | ||
|
|
de84f47503 | ||
|
|
115e3d4392 | ||
|
|
9f101ce67f | ||
|
|
9295bc4fbb | ||
|
|
9e083ec668 | ||
|
|
68c8857410 | ||
|
|
9323d1094f | ||
|
|
dc2967b2e7 | ||
|
|
6d85c09e69 | ||
|
|
6a8177145d | ||
|
|
baf686c6c4 | ||
|
|
34c5eed867 | ||
|
|
59840685a4 | ||
|
|
c4e33cab8c | ||
|
|
bf0741e48a | ||
|
|
51b5bbac0d | ||
|
|
03699a4a9e | ||
|
|
57a38636fc | ||
|
|
a5f99c57e1 | ||
|
|
1b0c7bc1b8 | ||
|
|
d84fd76070 | ||
|
|
677697a168 | ||
|
|
0fd4fa7066 | ||
|
|
0932d78d26 | ||
|
|
106f807b68 | ||
|
|
c3e6428ff7 | ||
|
|
78cb89938d | ||
|
|
f503139fae | ||
|
|
5ea096e61e | ||
|
|
f4ff2ad45a | ||
|
|
4fb57dc4e3 | ||
|
|
b8c5303b05 | ||
|
|
3c79701208 | ||
|
|
e82f88dfa9 | ||
|
|
296deb95e6 | ||
|
|
c6917296d3 | ||
|
|
b3672916de | ||
|
|
7c3cb49dfa | ||
|
|
b383302128 | ||
|
|
32d951e312 | ||
|
|
f8f5a18d67 | ||
|
|
2d241316c7 | ||
|
|
6a2ac9800b | ||
|
|
39aa75436e | ||
|
|
f708842e09 | ||
|
|
86af9601bd | ||
|
|
5b7c9c5845 | ||
|
|
7f2fdf3fe1 | ||
|
|
70c9a6528a | ||
|
|
54364d213d | ||
|
|
4d6b9895d3 | ||
|
|
f927455778 | ||
|
|
6928d21bcf | ||
|
|
38eecd5ece | ||
|
|
5aedb73aae | ||
|
|
387b85406e | ||
|
|
823b55c22a | ||
|
|
fdfb8837d1 | ||
|
|
d7c359c412 | ||
|
|
82c51dbe75 | ||
|
|
77259acf9e | ||
|
|
7816379aae | ||
|
|
d192527707 | ||
|
|
b0563a493c | ||
|
|
c38d45b9e7 | ||
|
|
f603b7aec3 | ||
|
|
a9d3cf4574 | ||
|
|
3b2fa89926 | ||
|
|
0d956b229f | ||
|
|
d73f4e7eca | ||
|
|
2778b132f0 | ||
|
|
1eae765dc3 | ||
|
|
267eb90da5 | ||
|
|
8075ce8371 | ||
|
|
d01c72f79b | ||
|
|
8f73e5e5a1 | ||
|
|
62142197c1 | ||
|
|
ff43e60831 | ||
|
|
6b9037790a | ||
|
|
babc6abc64 | ||
|
|
66d932c79f | ||
|
|
7be2f50a98 | ||
|
|
499f7160a4 | ||
|
|
7aca0cc77f | ||
|
|
c874703136 | ||
|
|
e6129ab2d9 | ||
|
|
4a43ac1bdd | ||
|
|
6b7fd8c3dc | ||
|
|
845c20ad93 | ||
|
|
47c050d5b6 | ||
|
|
1fbe5e1daa | ||
|
|
2b1cc43355 | ||
|
|
62cb6a0458 | ||
|
|
ca1dcc9bed | ||
|
|
5a72644486 | ||
|
|
e552466886 | ||
|
|
65043baf5d | ||
|
|
46c54f829c | ||
|
|
4dd5ab7576 | ||
|
|
ee27a48714 | ||
|
|
e5342afe2a | ||
|
|
3c30f7b971 | ||
|
|
99c39b1d57 | ||
|
|
ae485c3115 | ||
|
|
6c2be9bdcc | ||
|
|
1a11d92fd9 | ||
|
|
52c4d08e15 | ||
|
|
6ea1e39ee4 | ||
|
|
f9633a5f6f | ||
|
|
5bc48b2ab3 | ||
|
|
70b6e96f95 | ||
|
|
91a1fd074b | ||
|
|
a615c139e6 | ||
|
|
978fa6b252 | ||
|
|
24f90449ad | ||
|
|
ba8753836e | ||
|
|
e59fd9de96 | ||
|
|
6c4079cb94 | ||
|
|
c2b806563e | ||
|
|
15d912df38 | ||
|
|
a191a907e9 | ||
|
|
0caa349f6a | ||
|
|
1cd0efad41 | ||
|
|
9d49bbfaf0 | ||
|
|
3eb2cd2971 | ||
|
|
8e7d41ec02 | ||
|
|
94ea925152 | ||
|
|
18d93ff677 | ||
|
|
d48cf93a94 | ||
|
|
104b6b878a | ||
|
|
90b68f095f | ||
|
|
6a4364d404 | ||
|
|
5e819f6596 | ||
|
|
eef96da641 | ||
|
|
c38b392fdf | ||
|
|
e0d9dfb68e | ||
|
|
589d6df75d | ||
|
|
6fd9d1ce11 | ||
|
|
ef36604666 | ||
|
|
db56b14637 | ||
|
|
b14c18ee64 | ||
|
|
2c94ab3b1c | ||
|
|
f12b3a2e13 | ||
|
|
ea3f55f030 | ||
|
|
6e2c5a66b3 | ||
|
|
0bed34e0c7 | ||
|
|
f0d8a70b38 | ||
|
|
9acf2b5cda | ||
|
|
d49b92603a | ||
|
|
aa01a22416 | ||
|
|
50e43a9f98 | ||
|
|
ed325c7208 | ||
|
|
aac2c4a080 | ||
|
|
785c6aa1cf | ||
|
|
1b86c8564d | ||
|
|
031f80f6e1 | ||
|
|
6f21138489 | ||
|
|
7bab9cc344 | ||
|
|
510bd261f8 | ||
|
|
c5619f887d | ||
|
|
bb25b03884 | ||
|
|
9bbbf60268 | ||
|
|
37355f9c57 | ||
|
|
af76f757b5 | ||
|
|
b7650b11d6 | ||
|
|
a0d06b3209 | ||
|
|
c52edbd863 | ||
|
|
7355e34946 | ||
|
|
5fa25e70ad | ||
|
|
b8ae4e617b | ||
|
|
353ced0e41 | ||
|
|
ed9f214256 | ||
|
|
939bdaf669 | ||
|
|
2d2ba818e7 | ||
|
|
2653a450fc | ||
|
|
a065773b6d | ||
|
|
4e0ae0cb5e | ||
|
|
611bad4036 | ||
|
|
4a4b9ce7f0 | ||
|
|
100f1e56ca | ||
|
|
69ae224938 | ||
|
|
287628bfee | ||
|
|
f27dc2f4f4 | ||
|
|
1282f13442 | ||
|
|
47514c7708 | ||
|
|
b364bf8b06 | ||
|
|
dea3ef70a2 | ||
|
|
1cc7d37189 | ||
|
|
3164af7e34 | ||
|
|
4c8103a4e1 | ||
|
|
2ebbf2774b | ||
|
|
15450a6d0c | ||
|
|
832519ab64 | ||
|
|
4e2806c951 | ||
|
|
7e0dd1fd41 | ||
|
|
2d971a9fb7 | ||
|
|
3b386379dd | ||
|
|
7b887ee9f6 | ||
|
|
67f0e4be60 | ||
|
|
80acff8d7d | ||
|
|
d5d4d78023 | ||
|
|
5d94f0bea8 | ||
|
|
e5ddbd9886 | ||
|
|
d525b466ec | ||
|
|
333227fad8 | ||
|
|
288a781555 | ||
|
|
979e410efc | ||
|
|
75fa198321 | ||
|
|
49669f6585 | ||
|
|
acf8782786 | ||
|
|
6d2e0aa684 | ||
|
|
032a30f676 | ||
|
|
c9f574c27b | ||
|
|
b725196a26 | ||
|
|
301bafa3f5 | ||
|
|
7a3e4054c7 | ||
|
|
7d7253c9cc | ||
|
|
c2df49ee33 | ||
|
|
a253e175bb | ||
|
|
15023777f4 | ||
|
|
ff018a9a5d | ||
|
|
f76cb94511 | ||
|
|
87cc42d348 | ||
|
|
5177cfdf97 | ||
|
|
13621a1274 | ||
|
|
bc89e54f6d | ||
|
|
5ed2f79217 | ||
|
|
3696a4cd9e | ||
|
|
8259bd316a | ||
|
|
6717f45469 | ||
|
|
44615b7ade | ||
|
|
f3200b2232 | ||
|
|
881cbcd45d | ||
|
|
30a4032067 | ||
|
|
5597fc56d3 | ||
|
|
adcc0efda6 | ||
|
|
d044b13ce4 | ||
|
|
d42c304a55 | ||
|
|
d876f04baf | ||
|
|
593552f8d6 | ||
|
|
25462071df | ||
|
|
1d98c3a782 | ||
|
|
7f239bb931 | ||
|
|
23efe26655 | ||
|
|
ece447182f | ||
|
|
6465bd83a4 | ||
|
|
e941c1acea | ||
|
|
ecad8f25a8 | ||
|
|
48c3a9f2fa | ||
|
|
d59edc5d0a | ||
|
|
17440fc4be | ||
|
|
bff8585411 | ||
|
|
6a307bfcee | ||
|
|
604942f0e7 | ||
|
|
22eeb2f3a5 | ||
|
|
cc6059a4b7 | ||
|
|
91480b6b91 | ||
|
|
4a8e0799bd | ||
|
|
bcd5e40842 | ||
|
|
9fb6430313 | ||
|
|
68e45f3583 | ||
|
|
a1ed47be87 | ||
|
|
ded3867605 | ||
|
|
2b6833f65d | ||
|
|
4d38f11367 | ||
|
|
a3dd25f354 | ||
|
|
4b0e73ca5a | ||
|
|
cd37354634 | ||
|
|
8a5d0a58e4 | ||
|
|
1a71f4fbde | ||
|
|
1534f8749b | ||
|
|
4ea85a9291 | ||
|
|
739c07ca9b | ||
|
|
452338dc11 | ||
|
|
b6a6387f16 | ||
|
|
4a8c869b7e | ||
|
|
c052eb3969 | ||
|
|
48ed38a8c1 | ||
|
|
fba71ed24d | ||
|
|
625650c160 | ||
|
|
9f4c6c61d9 | ||
|
|
9d978f5581 | ||
|
|
664b352559 | ||
|
|
cfa4998ac1 | ||
|
|
5efe6d0a42 | ||
|
|
e34fbcce0d | ||
|
|
8746b2fd7f | ||
|
|
4328627326 | ||
|
|
fc6925fa0a | ||
|
|
b5de3eb588 | ||
|
|
26422fd425 | ||
|
|
cd1a296e4f | ||
|
|
3ddf9f8a0d | ||
|
|
82df6087af | ||
|
|
bef8562de5 | ||
|
|
1000d419fc | ||
|
|
2a9deb6a64 | ||
|
|
351e406f85 | ||
|
|
d6e518838f | ||
|
|
9e39f18230 | ||
|
|
3dd1e5a318 | ||
|
|
23e1c0b71e | ||
|
|
a1436cd205 | ||
|
|
0d320b7922 | ||
|
|
b2a0d0e4da | ||
|
|
273f058da9 | ||
|
|
c6f751bb67 | ||
|
|
00b7ac5a39 | ||
|
|
c0686dc4f9 | ||
|
|
7ab3a3cfd9 | ||
|
|
c3102c7e9f | ||
|
|
77f4ddf2c2 | ||
|
|
06d327e76c | ||
|
|
2e28b036f8 | ||
|
|
024ae2b9ed | ||
|
|
8a4295d699 | ||
|
|
f05e39afe1 | ||
|
|
3b1fb85bb8 | ||
|
|
a405f85eee | ||
|
|
78511afa4c | ||
|
|
c37c4f830f | ||
|
|
4fe2ae780b | ||
|
|
e02e6bcb4f | ||
|
|
c7392aeded | ||
|
|
14247af323 | ||
|
|
32cb00a4c6 | ||
|
|
d93f6984cc | ||
|
|
207584818f | ||
|
|
7a42d6b564 | ||
|
|
94b3ca08a2 | ||
|
|
ab5f00b65b | ||
|
|
b8fd7db58d | ||
|
|
22635d8d35 | ||
|
|
fb9b284bcf | ||
|
|
5293815bf6 | ||
|
|
5868ffd04e | ||
|
|
8ce99e0540 | ||
|
|
efb02755bc | ||
|
|
fcafd0784c | ||
|
|
199802150b | ||
|
|
e47c1a840a | ||
|
|
14227c04b8 | ||
|
|
cf0a49881e | ||
|
|
527a998740 | ||
|
|
352f078b07 | ||
|
|
4f3c3175e6 | ||
|
|
81dc80fbd1 | ||
|
|
28036966a6 | ||
|
|
2164f5191e | ||
|
|
216ba8b4e9 | ||
|
|
9c55eed549 | ||
|
|
f9ce25a7fe | ||
|
|
7e418933e7 | ||
|
|
05b3fc0fb9 | ||
|
|
d7990596f9 | ||
|
|
86f974f242 | ||
|
|
6addc5c8dd | ||
|
|
15a7faeafd | ||
|
|
626963fc49 | ||
|
|
2e72fc115d | ||
|
|
26462f2848 | ||
|
|
9cd2a74271 | ||
|
|
e1648ba8f9 | ||
|
|
dae6d13f06 | ||
|
|
ccf1d7abbd | ||
|
|
b92381505a | ||
|
|
5ba6b1426b | ||
|
|
fc7453a6c7 | ||
|
|
ae00144e84 | ||
|
|
59baaf1123 | ||
|
|
e2eac382c0 | ||
|
|
dd81d7c78f | ||
|
|
e3f4d239f1 | ||
|
|
8f0527487f | ||
|
|
318b36cdcf | ||
|
|
f4b9dfb2e7 | ||
|
|
2e11d3400e | ||
|
|
364cd094d9 | ||
|
|
2af7600057 | ||
|
|
8031e42bda | ||
|
|
7f9ceaac06 | ||
|
|
ae0a03d438 | ||
|
|
d105ce778d | ||
|
|
653e9325fc | ||
|
|
5d7d7c122e | ||
|
|
45fb26d282 | ||
|
|
c501c837d0 | ||
|
|
590f71436f | ||
|
|
b7e252dfd6 | ||
|
|
a2246af121 | ||
|
|
3e454db2d8 | ||
|
|
b88e0d7875 | ||
|
|
821251b176 | ||
|
|
1b3599c189 | ||
|
|
5e7596dea6 | ||
|
|
ab7519530e | ||
|
|
faa10f52a8 | ||
|
|
53df09fbb7 | ||
|
|
c8f3035cb0 | ||
|
|
f465985370 | ||
|
|
470486ba7e | ||
|
|
9a4fe1c475 | ||
|
|
dd61223c0b | ||
|
|
c196082988 | ||
|
|
9e58476631 | ||
|
|
4bebdc18a2 | ||
|
|
a01529b210 | ||
|
|
0b35c84bf0 | ||
|
|
846a99e57f | ||
|
|
c28f957fb3 | ||
|
|
f0aec6b0b6 | ||
|
|
d79c5e0dfa | ||
|
|
cb8d92edeb | ||
|
|
db9925493a | ||
|
|
1b795a70b0 | ||
|
|
ccfd2ffe38 | ||
|
|
c1d235a59c | ||
|
|
b5320a4f8a | ||
|
|
a1271ec3a8 | ||
|
|
a659896f8a | ||
|
|
a4e169aa8f | ||
|
|
7dd733cf46 | ||
|
|
6eb319f46e | ||
|
|
3add38f665 | ||
|
|
34e91fbd81 | ||
|
|
a9ca1a2fd6 | ||
|
|
a21c7564c1 | ||
|
|
1ca4517f46 | ||
|
|
22b43e3869 | ||
|
|
fc14e37d0f | ||
|
|
7ed329c11f | ||
|
|
6ad6abd319 | ||
|
|
bece74491d | ||
|
|
990a02dbe0 | ||
|
|
75193e9ee9 | ||
|
|
a5b22498ce | ||
|
|
398522712e | ||
|
|
caf0914289 | ||
|
|
17700e45b0 | ||
|
|
ba8b42ef1b | ||
|
|
144fb907f1 | ||
|
|
e7c6b23439 | ||
|
|
a65c215217 | ||
|
|
7e3b1c395b | ||
|
|
3511d2a44d | ||
|
|
beaf812909 | ||
|
|
7068c3e865 | ||
|
|
255b9323cc | ||
|
|
d14c94c353 | ||
|
|
11abe77eed | ||
|
|
7d8dfb09d8 | ||
|
|
3baa703256 | ||
|
|
2b3159f418 | ||
|
|
72acca4b9e | ||
|
|
32d12ea4a6 | ||
|
|
e4862dade8 | ||
|
|
ed908b6545 | ||
|
|
a81b52a787 | ||
|
|
52cdbb4fc1 | ||
|
|
d0bf26135c | ||
|
|
4f2bb62ff9 | ||
|
|
28f1ea82b6 | ||
|
|
aaac0b9eb2 | ||
|
|
daee19d502 | ||
|
|
70145dfd74 | ||
|
|
c09b32010f | ||
|
|
85a1d3e78a | ||
|
|
a9c9da1066 | ||
|
|
2860f31cb0 | ||
|
|
54cf1337c1 | ||
|
|
dcde5927b1 | ||
|
|
c458d1e600 | ||
|
|
aae7161273 | ||
|
|
6287774d69 | ||
|
|
dc4d597fb9 | ||
|
|
9ceb1af4fe | ||
|
|
b9b6832a11 | ||
|
|
53c63def07 | ||
|
|
4f70185aef | ||
|
|
6fcb411fe4 | ||
|
|
9cc518e408 | ||
|
|
ddebc2a075 | ||
|
|
fe6abb0c48 | ||
|
|
90e66cbeef | ||
|
|
487e01e4ed | ||
|
|
25b3d8f354 | ||
|
|
d430bd2f5c | ||
|
|
e2767a3c80 | ||
|
|
7f552e4d75 | ||
|
|
cbcda61135 | ||
|
|
2904c87b62 | ||
|
|
cfdedce362 | ||
|
|
467d57059a | ||
|
|
c993712438 | ||
|
|
a69d18ae1c | ||
|
|
95dae67d5b | ||
|
|
f6a64da672 | ||
|
|
11b23a6d07 | ||
|
|
82f1c5a20b | ||
|
|
7e080d259e | ||
|
|
1ab6ab1e5c | ||
|
|
b0e7bab980 | ||
|
|
9b8d28de56 | ||
|
|
5611ec54a2 | ||
|
|
6c7e29cbdb | ||
|
|
118d6dc9b1 | ||
|
|
08fe840bfd | ||
|
|
4637cf9221 | ||
|
|
4fd68939d3 | ||
|
|
be6a930e82 | ||
|
|
956f264b85 | ||
|
|
0a91b1f5b1 | ||
|
|
a17b47a2dc | ||
|
|
2a8c390498 | ||
|
|
41ffe975fd | ||
|
|
5ac3390656 | ||
|
|
f9faf9e48c | ||
|
|
e57dce76e1 | ||
|
|
64a6972757 | ||
|
|
1293d15f72 | ||
|
|
12fca79006 | ||
|
|
55b8371fa8 | ||
|
|
a8080c0bbb | ||
|
|
8c61fdc99d | ||
|
|
9374620b8b | ||
|
|
5a35760215 | ||
|
|
6b257de75a | ||
|
|
40356fc9db | ||
|
|
de108cca44 | ||
|
|
5f5a6b3a16 | ||
|
|
29b1926432 | ||
|
|
e0a154faa0 | ||
|
|
1706fdfed9 | ||
|
|
945df342d8 | ||
|
|
bfb11c7712 | ||
|
|
fa7d8757dc | ||
|
|
3c7978153b | ||
|
|
7cb3d4d8ff | ||
|
|
870e118150 | ||
|
|
e27f8fba1a | ||
|
|
ce1a4dcac0 | ||
|
|
057a5790e2 | ||
|
|
87858ef264 | ||
|
|
98fea02eaa | ||
|
|
1de6dbacad | ||
|
|
64ab3a08b5 | ||
|
|
4007ec8cf8 | ||
|
|
c33bf330a0 | ||
|
|
830c3f36d3 | ||
|
|
a5583882f4 | ||
|
|
6896ef739d | ||
|
|
c87afde1bd | ||
|
|
51cea0e04e | ||
|
|
89732f7935 | ||
|
|
8589a091dd | ||
|
|
d9bf0a816e | ||
|
|
38ba9b4561 | ||
|
|
8e6ca1ce09 | ||
|
|
d685f30847 | ||
|
|
43cdf20fd3 | ||
|
|
7507672895 | ||
|
|
95afe72307 | ||
|
|
539adcb8a2 | ||
|
|
3a1bb177fc | ||
|
|
f156d48f45 | ||
|
|
404e96ad45 | ||
|
|
90ddc16a4b | ||
|
|
c3b25e54f8 | ||
|
|
b6a2f72e95 | ||
|
|
6085afbaae | ||
|
|
2658636377 | ||
|
|
4bab834716 | ||
|
|
8f6f881937 | ||
|
|
8807939a14 | ||
|
|
27b69559a3 | ||
|
|
373fb4f776 | ||
|
|
8c88614c2e | ||
|
|
858a0ba17d | ||
|
|
5cf6a0c875 | ||
|
|
a5c213ae7d | ||
|
|
23a1c5f952 | ||
|
|
5aaea4c2c5 | ||
|
|
ab303e7394 | ||
|
|
4f54df65e9 | ||
|
|
36f9a8ed7a | ||
|
|
2ccaa376ba | ||
|
|
65bf85fcbe | ||
|
|
30f061e818 | ||
|
|
22e3d2d198 | ||
|
|
687db96b38 | ||
|
|
588e88c7ee | ||
|
|
65a8f3cbf8 | ||
|
|
82e6d00cea | ||
|
|
bbdecceb4b | ||
|
|
f67e4ce610 | ||
|
|
f289799c57 | ||
|
|
aac279322b | ||
|
|
5d234bb9d6 | ||
|
|
7e898ee530 | ||
|
|
54565c92f7 | ||
|
|
4e996a116d | ||
|
|
8c8af88cee | ||
|
|
8a36d0486b | ||
|
|
1f3b14367d | ||
|
|
79ba2835f6 | ||
|
|
3d461ecea1 | ||
|
|
b4d34ef062 | ||
|
|
a341a0e85c | ||
|
|
d8f0484327 | ||
|
|
b68405b651 | ||
|
|
453e9da7c5 | ||
|
|
0e7a3b0173 | ||
|
|
7eef3948b1 | ||
|
|
e609a33e6d | ||
|
|
41a9889cdd | ||
|
|
3de269946c | ||
|
|
9fa4ed8bac | ||
|
|
22033c21f2 | ||
|
|
d705f6a2e1 | ||
|
|
3d19bfd57e | ||
|
|
ea6cf26929 | ||
|
|
68c00b8ae7 | ||
|
|
9af507a322 | ||
|
|
5f9d571e12 | ||
|
|
f7d3e44b19 | ||
|
|
a01e9e510c | ||
|
|
3eb297bee1 | ||
|
|
8627c0cbfc | ||
|
|
cbb5c6d740 | ||
|
|
955a29a4aa | ||
|
|
1d9ea142c4 | ||
|
|
cb83a307ec | ||
|
|
902cae595b | ||
|
|
b7b422f046 | ||
|
|
01c6bb8c6f | ||
|
|
aeb52d4f45 | ||
|
|
41bf281f1d | ||
|
|
11aab699a5 | ||
|
|
1924da3527 | ||
|
|
2e6d02ad52 | ||
|
|
e4047c3f87 | ||
|
|
fa1d4ec5d6 | ||
|
|
bcfdef0171 | ||
|
|
60320cd845 | ||
|
|
8840ce905d | ||
|
|
fd87cb6b23 | ||
|
|
29d1187434 | ||
|
|
fdac8a1677 | ||
|
|
44c744b8fd | ||
|
|
7f71f43c2e | ||
|
|
16d7e39b57 | ||
|
|
9a6900a0ba | ||
|
|
e762c2ee56 | ||
|
|
c31eaa01a3 | ||
|
|
338fdb37f6 | ||
|
|
79970ca5fa | ||
|
|
bcae547365 | ||
|
|
f7434cdae1 | ||
|
|
b9fd586f2f | ||
|
|
e6e54813bb | ||
|
|
328fa3b430 | ||
|
|
78a2dec19e | ||
|
|
f413ea7f4b | ||
|
|
2f0272f864 | ||
|
|
a984e23bf6 | ||
|
|
2acf5f85cd | ||
|
|
fc1da58040 | ||
|
|
b3a89b70b5 | ||
|
|
8753e58d7f | ||
|
|
ae0ece411e | ||
|
|
b7be7eb44e | ||
|
|
946150c8a2 | ||
|
|
9ebea1cdac | ||
|
|
27b4f9538a | ||
|
|
4ce13e9cbd | ||
|
|
7006533409 | ||
|
|
001503c85f | ||
|
|
1831449e81 | ||
|
|
cd530679bd | ||
|
|
1351df4260 | ||
|
|
de42dfc783 | ||
|
|
ed42d2feea | ||
|
|
0a81a28b07 | ||
|
|
c0ec537f29 | ||
|
|
ba81b5b2a5 | ||
|
|
3671a69b9d | ||
|
|
6a77e04a8e | ||
|
|
8401ca3269 | ||
|
|
a36dafb906 | ||
|
|
e880471296 | ||
|
|
e987cf6bfc | ||
|
|
7bb78e53c6 | ||
|
|
99f7ee0588 | ||
|
|
705ad3bcfc | ||
|
|
2febfae906 | ||
|
|
2db2af9343 | ||
|
|
8e813109a2 | ||
|
|
8a6889663d | ||
|
|
aee82c9be4 | ||
|
|
a5d364be49 | ||
|
|
3f21fa4b39 | ||
|
|
0961e5dde3 | ||
|
|
89c4be525b | ||
|
|
1135f9024a | ||
|
|
9924a28acf | ||
|
|
8ad5862461 | ||
|
|
b67da15b5b | ||
|
|
c1888c2d05 | ||
|
|
9d932b47fd | ||
|
|
25af750af0 | ||
|
|
08238a8036 | ||
|
|
61f46845bd | ||
|
|
9aec0b23dd | ||
|
|
86363dd3ec | ||
|
|
23feb54f6a | ||
|
|
55e463426d | ||
|
|
0743b757f6 | ||
|
|
af9852a68f | ||
|
|
113a4a55c6 | ||
|
|
5e4a69def6 | ||
|
|
6e79114dee | ||
|
|
04055c411e | ||
|
|
90b3df1181 | ||
|
|
9e27a867dd | ||
|
|
7239f1d00a | ||
|
|
613838626e | ||
|
|
5118ea621d | ||
|
|
ea8fdd8fbb | ||
|
|
f9ec1484f8 | ||
|
|
c7f413f1b0 | ||
|
|
3fd7b29d64 | ||
|
|
a0f060f000 | ||
|
|
fd399b9b4b | ||
|
|
ad3588d0aa | ||
|
|
d9312799c3 | ||
|
|
cb39030cce | ||
|
|
0aa11374d8 | ||
|
|
0b7d99f03d | ||
|
|
47d22a3051 | ||
|
|
600f7e2342 | ||
|
|
fbe377a53d | ||
|
|
8a7262afd5 | ||
|
|
02fcf37088 | ||
|
|
ec455394b4 | ||
|
|
ee501058fb | ||
|
|
b74573fa12 | ||
|
|
d3d16a93cf | ||
|
|
71788e2325 | ||
|
|
70d81430f8 | ||
|
|
19db7aef46 | ||
|
|
151834a948 | ||
|
|
ec9af8feb6 | ||
|
|
3e201dd521 | ||
|
|
152a86f6f4 | ||
|
|
93da058dbd | ||
|
|
7885d62f03 | ||
|
|
c4487b74ee | ||
|
|
90cefa9daf | ||
|
|
f3994ce6dc | ||
|
|
2f82ef5ec6 | ||
|
|
e2ac0a085e | ||
|
|
6290834e2b | ||
|
|
efa98f6b7f | ||
|
|
87b0a8533f | ||
|
|
7a4a0271ef | ||
|
|
990b45a273 | ||
|
|
1ff7b72bb0 | ||
|
|
7907a07686 | ||
|
|
4a8068d1c4 | ||
|
|
6a4500733d | ||
|
|
482a2f2eb5 | ||
|
|
e74b5807a9 | ||
|
|
371e9f2f93 | ||
|
|
20b7592fcd | ||
|
|
9158d3734e | ||
|
|
6f9776e3f4 | ||
|
|
d5ff829952 | ||
|
|
7fda6e412a | ||
|
|
273cab1bbf | ||
|
|
c097bdc9ce | ||
|
|
da69ae0371 | ||
|
|
72ddd865d1 | ||
|
|
1dd84e3ed3 | ||
|
|
fdb80bd9cf | ||
|
|
549fea4b0a | ||
|
|
0c08b72b5e | ||
|
|
227e324aa9 | ||
|
|
aae39da235 | ||
|
|
cff585f2a1 | ||
|
|
ec7f1727e5 | ||
|
|
098a693c1a | ||
|
|
215599b90f | ||
|
|
47eb7d60e5 | ||
|
|
2deaa666f3 | ||
|
|
47dd2870d9 | ||
|
|
999f37800c | ||
|
|
a54ee12ade | ||
|
|
07ba8df977 | ||
|
|
27e812461f | ||
|
|
29d4ea3245 | ||
|
|
f70a3ea297 | ||
|
|
237db0504c | ||
|
|
015b9e92b6 | ||
|
|
ab53e580db | ||
|
|
ecbedb7b11 | ||
|
|
5b9ae5917b | ||
|
|
f3c454084a | ||
|
|
94383d995d | ||
|
|
51a6b9ce30 | ||
|
|
a25e3755db | ||
|
|
0707f14c7a | ||
|
|
4b52a7e531 | ||
|
|
f2751815be | ||
|
|
988d023e89 | ||
|
|
f06bdc9121 | ||
|
|
a7f5fb7a08 | ||
|
|
61e958e679 | ||
|
|
919a1e7bb9 | ||
|
|
56585fc32a | ||
|
|
57229aac91 | ||
|
|
3cccfc15da | ||
|
|
7008a566a8 | ||
|
|
100ddd6724 | ||
|
|
2c8614c639 | ||
|
|
a34555c45d | ||
|
|
adba0560d7 | ||
|
|
1b30e78db3 | ||
|
|
cb7eeef014 | ||
|
|
fc9aa50f3c | ||
|
|
f268fddc3c | ||
|
|
3152e7f43f | ||
|
|
a2ceb8f7d5 | ||
|
|
9db8c4af3e | ||
|
|
34dedcaab1 | ||
|
|
58c00f4487 | ||
|
|
f425236bac | ||
|
|
023a3ca056 | ||
|
|
34a0cb170e | ||
|
|
5e4ee1b849 | ||
|
|
f668b3fe6c | ||
|
|
f12924458f | ||
|
|
857f5fcced | ||
|
|
4eb1e8a4b0 | ||
|
|
0f96a28cca | ||
|
|
4d8e76202d | ||
|
|
e356758743 | ||
|
|
4e654704dc | ||
|
|
1790033458 | ||
|
|
e3d7a047bd | ||
|
|
a67c54a67c | ||
|
|
b9f7f20046 | ||
|
|
c42f73b66c | ||
|
|
5a2bc4479d | ||
|
|
31928e6282 | ||
|
|
9b3b2eb23e | ||
|
|
e127a55b0a | ||
|
|
b7223932d2 | ||
|
|
542bb59978 | ||
|
|
f91d659c6f | ||
|
|
7451257578 | ||
|
|
d8835a426f | ||
|
|
5edc46c994 | ||
|
|
57c6e09fcf | ||
|
|
626ee9ac65 | ||
|
|
59191486b6 | ||
|
|
f645ca0daf | ||
|
|
20c9815619 | ||
|
|
98e8f70424 | ||
|
|
6d9f46e983 | ||
|
|
d9fb0ba64e | ||
|
|
e8734ccf28 | ||
|
|
11b4320204 | ||
|
|
fb2117137e | ||
|
|
730a9a4a40 | ||
|
|
40f2512317 | ||
|
|
6dc602ad7c | ||
|
|
b5876bdd33 | ||
|
|
29a5daab98 | ||
|
|
ed46ca3328 | ||
|
|
e6ec89d145 | ||
|
|
b196d3e3c0 | ||
|
|
ebb5607bd4 | ||
|
|
416abd81a1 | ||
|
|
c536a43914 | ||
|
|
283bdad552 | ||
|
|
0c8e6e2918 | ||
|
|
8924a9744e | ||
|
|
5815e49d93 | ||
|
|
70bc24218f | ||
|
|
4f4903a05e | ||
|
|
f7bb423f06 | ||
|
|
19bcc8417d | ||
|
|
b65de29c92 | ||
|
|
7bd1ed2339 | ||
|
|
a7c7e72004 | ||
|
|
df59fd5b0e | ||
|
|
0d80d3c57c | ||
|
|
060f63e9db | ||
|
|
e243de0538 | ||
|
|
11253eae1c | ||
|
|
c81e1865e0 | ||
|
|
39d9f4da3f | ||
|
|
6d5dd40875 | ||
|
|
051e7cf320 | ||
|
|
37210c9ef1 | ||
|
|
3215e25318 | ||
|
|
9d72f0b335 | ||
|
|
803c6b0a82 | ||
|
|
4b04b8d51e | ||
|
|
b239430247 | ||
|
|
700ec92a9a | ||
|
|
272655f340 | ||
|
|
7c3bcc9c25 | ||
|
|
1ff13c59cf | ||
|
|
936bdc47f0 | ||
|
|
9008705b9d | ||
|
|
886c358e91 | ||
|
|
76f33d2742 | ||
|
|
5703c323d6 | ||
|
|
40434f54aa | ||
|
|
b9e9e15647 | ||
|
|
7fbc9869bd | ||
|
|
148943dad6 | ||
|
|
90ca9d7a47 | ||
|
|
a0e6f33828 | ||
|
|
52e3b580f3 | ||
|
|
1c0a5b0420 | ||
|
|
f9448e30c9 | ||
|
|
2f5257fcb5 | ||
|
|
5a50c28afd | ||
|
|
3c24ce4d7b | ||
|
|
441bb0483a | ||
|
|
05c7bd4be9 | ||
|
|
3dc9c23b65 | ||
|
|
e0e9e87326 | ||
|
|
52c7ef0f6f | ||
|
|
7ada5f957e | ||
|
|
d3cc797f0f | ||
|
|
8f4f0f61ea | ||
|
|
edb820eae8 | ||
|
|
497b51814d | ||
|
|
311203b5cf | ||
|
|
7dc4d49b86 | ||
|
|
4cba1925fd | ||
|
|
23fafbd47d | ||
|
|
7fbcb81916 | ||
|
|
2812f227b7 | ||
|
|
ce07a44fb0 | ||
|
|
23f9a1a524 | ||
|
|
c81466bb33 | ||
|
|
26b056d2c4 | ||
|
|
bd9fd43b76 | ||
|
|
184ad9083c | ||
|
|
8e7093ba2b | ||
|
|
eb3e7fcc32 | ||
|
|
c5a81d7c6f | ||
|
|
f42e9ff812 | ||
|
|
dc791f1fbe | ||
|
|
bbd3d3f4b6 | ||
|
|
8370112aa4 | ||
|
|
5e51ca0f80 | ||
|
|
7821c34a7b | ||
|
|
272d3c4b9e | ||
|
|
dd9d60e1d7 | ||
|
|
3219abcd1f | ||
|
|
5733bb5b08 | ||
|
|
75484c02a0 | ||
|
|
3e1ba143bf | ||
|
|
d3ea10a600 | ||
|
|
818e1e4e18 | ||
|
|
126ce99cd9 | ||
|
|
0d787e24ce | ||
|
|
c11ac4c25e | ||
|
|
ef147860c2 | ||
|
|
0e80ffef55 | ||
|
|
eb8996699e | ||
|
|
cf4f500eda | ||
|
|
fec2fa3bf0 | ||
|
|
a4d06e1077 | ||
|
|
5f9aaadacb | ||
|
|
a802fe3a8b | ||
|
|
6ab0c35837 | ||
|
|
b81b6cd1c6 | ||
|
|
c3e5d62bf6 | ||
|
|
e2b399b8d3 | ||
|
|
ce25a44e00 | ||
|
|
72edc74e8b | ||
|
|
cf07ecef46 | ||
|
|
c8caf7c860 | ||
|
|
3b3b1d6342 | ||
|
|
04161da5a0 | ||
|
|
cce6fde4ea | ||
|
|
b8e9aabd67 | ||
|
|
625f225448 | ||
|
|
e8eb9970a6 | ||
|
|
ed5771a861 | ||
|
|
2c03498986 | ||
|
|
de675be862 | ||
|
|
c109ea2cb6 | ||
|
|
c1f8ebf65c | ||
|
|
c6323512ef | ||
|
|
0387c45995 | ||
|
|
2ea3d9023b | ||
|
|
248d776a23 | ||
|
|
637941a978 | ||
|
|
1f4be9798e | ||
|
|
c849616003 | ||
|
|
d674414cf0 | ||
|
|
cb3f6df111 | ||
|
|
59623695af | ||
|
|
87e9dee78b | ||
|
|
62edc5f4c0 | ||
|
|
903315747d | ||
|
|
485ade2610 | ||
|
|
9e4fff3362 | ||
|
|
7cc911ae58 | ||
|
|
82ff7d5af7 | ||
|
|
c4c6efb140 | ||
|
|
f078ea1f8a | ||
|
|
ab1b915a3c | ||
|
|
709149fbed | ||
|
|
e57a076dc8 | ||
|
|
c21b3a36fc | ||
|
|
f765c8d436 | ||
|
|
ae44a6540a | ||
|
|
f27dbaf716 | ||
|
|
717ad38d06 | ||
|
|
60f06d1414 | ||
|
|
a579136a3d | ||
|
|
2f3d523ac0 | ||
|
|
df5c53fa4a | ||
|
|
46c069dbbe | ||
|
|
bda9defc0f | ||
|
|
8817b4277d | ||
|
|
4346e963e5 | ||
|
|
9bbcae1648 | ||
|
|
fc504737c5 | ||
|
|
1a09f2b6df | ||
|
|
44d34d0e5d | ||
|
|
56339ed43a | ||
|
|
393ab89c34 | ||
|
|
38fd55a05d | ||
|
|
e0e946afac | ||
|
|
4d3c89c065 | ||
|
|
a7b1a9a5fa | ||
|
|
529d7e2659 | ||
|
|
4be998c4dc | ||
|
|
261a4bb81b | ||
|
|
beba03292a | ||
|
|
6042518691 | ||
|
|
02a9db8e50 | ||
|
|
d0dda098a2 | ||
|
|
195a836999 | ||
|
|
366c3c0e16 | ||
|
|
a4b45aea9b | ||
|
|
fa65b62a04 | ||
|
|
71439b30ab | ||
|
|
e585e34670 | ||
|
|
2f2f057b47 | ||
|
|
7e4bfce892 | ||
|
|
6c5ab80418 | ||
|
|
121124e362 | ||
|
|
f4adf33b4e | ||
|
|
6fe4175fd2 | ||
|
|
8627fe1fa8 | ||
|
|
9310cfd164 | ||
|
|
722c0eb32b | ||
|
|
66a3811049 | ||
|
|
c3fcc44718 | ||
|
|
8b6e040581 | ||
|
|
88a47ff681 | ||
|
|
d0843ab997 | ||
|
|
c1396de2fc | ||
|
|
0810c4b217 | ||
|
|
632c7d05dd | ||
|
|
dcc192ee0d | ||
|
|
9b1678bd18 | ||
|
|
5f19fc036d | ||
|
|
5eec2e7d6d | ||
|
|
3195dec436 | ||
|
|
15f4a05122 | ||
|
|
e559e6ffa8 | ||
|
|
23290b35a7 | ||
|
|
2b3da56fb5 | ||
|
|
370710c0ff | ||
|
|
4fc7eb8a6b | ||
|
|
38c01714d7 | ||
|
|
0e1a34a4d7 | ||
|
|
d5d7e8c9cf | ||
|
|
76d681761d | ||
|
|
3807edbeb8 | ||
|
|
d9216cc599 | ||
|
|
d551338510 | ||
|
|
8a7dfdbc11 | ||
|
|
1a7b708df8 | ||
|
|
168b779786 | ||
|
|
c853050265 | ||
|
|
c614d19af0 | ||
|
|
8b4f27a038 | ||
|
|
48eee4db9b | ||
|
|
c66d14605a | ||
|
|
ac8a7ecad7 | ||
|
|
292df5010f | ||
|
|
5f3f9e869e | ||
|
|
e748d49343 | ||
|
|
c085444a03 | ||
|
|
c982cc9991 | ||
|
|
249be7ad56 | ||
|
|
6268abe2c3 | ||
|
|
6aa776eab7 | ||
|
|
c86a6abdc5 | ||
|
|
0e4edd4419 | ||
|
|
2a6b37dc81 | ||
|
|
485975fd99 | ||
|
|
c36f80b93d | ||
|
|
08cadcdda6 | ||
|
|
d473b0441d | ||
|
|
189369fcf3 | ||
|
|
a01a63cb71 | ||
|
|
10a95cfdce | ||
|
|
653dd36020 | ||
|
|
28bf744a18 | ||
|
|
e7d9795fc1 | ||
|
|
2adae27557 | ||
|
|
3430962cbe | ||
|
|
0aaa659e29 | ||
|
|
9ef8cc7064 | ||
|
|
44bacdc067 | ||
|
|
7d2c0bd962 | ||
|
|
bb39c54f17 | ||
|
|
8f8c00c66d | ||
|
|
5b3b17799f | ||
|
|
3a59baab2c | ||
|
|
fc947c68f7 | ||
|
|
cfd116b93b | ||
|
|
afc88694fd | ||
|
|
274e7bd329 | ||
|
|
8777d0d0da | ||
|
|
8ce41407dd | ||
|
|
bcd80d3e84 | ||
|
|
cfa09f22c1 | ||
|
|
cec5bfe7b2 | ||
|
|
f1a907c298 | ||
|
|
f6d7fd4949 | ||
|
|
2bd91dd93b | ||
|
|
2b13f28cfc | ||
|
|
3c264d78bb | ||
|
|
82b7485001 | ||
|
|
c6c034f90a | ||
|
|
cb9f2b9144 | ||
|
|
6909f7f23c | ||
|
|
f59df243ea | ||
|
|
d9839bab68 | ||
|
|
fe16e8e47c | ||
|
|
fd961f4712 | ||
|
|
b548ba7b58 | ||
|
|
df672dd8ce | ||
|
|
c54b54ded0 | ||
|
|
5757b729ac | ||
|
|
b048dc7b10 | ||
|
|
b63bfdc72a | ||
|
|
fa93426f6a | ||
|
|
86f0a77e73 | ||
|
|
13a783d441 | ||
|
|
e08697ad54 | ||
|
|
67ba703b84 | ||
|
|
d85568b54b | ||
|
|
67c8ee4ce3 | ||
|
|
69984f472f | ||
|
|
2ab7c08da9 | ||
|
|
4e275eea97 | ||
|
|
4f1705e001 | ||
|
|
5d55ff23bd | ||
|
|
2ed044804d | ||
|
|
32ba03538b | ||
|
|
23feee0e00 | ||
|
|
401aa038f8 | ||
|
|
38e1c2f1f3 | ||
|
|
9e4d396d5e | ||
|
|
5c5d43137d | ||
|
|
bdfdab1d3a | ||
|
|
9366882ac4 | ||
|
|
0f9e5234fe | ||
|
|
3d5c9f0e21 | ||
|
|
a2dac43833 | ||
|
|
28346c99f2 | ||
|
|
23d55dd9d5 | ||
|
|
2c886943a0 | ||
|
|
9d805ea9fb | ||
|
|
e992c33f35 | ||
|
|
ecbcc7ba16 | ||
|
|
6503e92d66 | ||
|
|
207f643d3a | ||
|
|
ec01ca72a0 | ||
|
|
5ecd906905 | ||
|
|
e78fe93e92 | ||
|
|
9d2bee261c | ||
|
|
c261bb0b2e | ||
|
|
204ca3aca5 | ||
|
|
a158205f30 | ||
|
|
3786a2756b | ||
|
|
457266d249 | ||
|
|
9ba1363d86 | ||
|
|
2d40af31a2 | ||
|
|
c87b3c0859 | ||
|
|
e30b57cb4a | ||
|
|
569a53182c | ||
|
|
ee2a408d44 | ||
|
|
e030bb4451 | ||
|
|
9e3ed67185 | ||
|
|
d1768b7089 | ||
|
|
55647cc18e | ||
|
|
9ebd4ad627 | ||
|
|
d6476728f9 | ||
|
|
1e1b23dc31 | ||
|
|
5cdf35d687 | ||
|
|
229769ed22 | ||
|
|
4dd641287d | ||
|
|
199d1b8eeb | ||
|
|
31cd5c7863 | ||
|
|
a95527a72c | ||
|
|
4f0c06d068 | ||
|
|
af4573e7af | ||
|
|
620cb405b1 | ||
|
|
a08a693bf3 | ||
|
|
8a726a8fbb | ||
|
|
ff692f6040 | ||
|
|
246c32a202 | ||
|
|
f81786cea0 | ||
|
|
bcfef75c5d | ||
|
|
0a14d3f50c | ||
|
|
17c4649651 | ||
|
|
4c895a78c6 | ||
|
|
152807b977 | ||
|
|
45f5ac64e1 | ||
|
|
b438a5b39e | ||
|
|
b705de0143 | ||
|
|
f589298879 | ||
|
|
7d153cf9f9 | ||
|
|
86b04e36b5 | ||
|
|
33d13ff81c | ||
|
|
dcbc85b2cf | ||
|
|
5123527c66 | ||
|
|
c4e7b8a795 | ||
|
|
41297b96d0 | ||
|
|
d30cab04c3 | ||
|
|
3ab31eba7b | ||
|
|
e7aa159896 | ||
|
|
4db1280c59 | ||
|
|
5893737321 | ||
|
|
c85cc5cbf7 | ||
|
|
705b5d3f5f | ||
|
|
8a978dc71f | ||
|
|
c32683225f | ||
|
|
01941d5504 | ||
|
|
8fb97a6152 | ||
|
|
801da2db37 | ||
|
|
52147ca75f | ||
|
|
2f3a3942b5 | ||
|
|
ed57a2f3d8 | ||
|
|
3ab4e4f24e | ||
|
|
1336d9cf5e | ||
|
|
1b706bcbcf | ||
|
|
1a5714c3ca | ||
|
|
e0a83ff7b2 | ||
|
|
93bec920cf | ||
|
|
8d8c9aa55b | ||
|
|
668839d1cb | ||
|
|
a410aefd6d | ||
|
|
c6a7e86762 | ||
|
|
f960c64dc6 | ||
|
|
80838af4a2 | ||
|
|
7564c09aff | ||
|
|
60ac7e23d0 | ||
|
|
c383f1dc43 | ||
|
|
f107ff9cd2 | ||
|
|
25a8209ffc | ||
|
|
3c0b89b80f | ||
|
|
11c40e385e | ||
|
|
d0574dbe28 | ||
|
|
b4011f3e8b | ||
|
|
0f9b9d0a24 | ||
|
|
c0d4dfa6ed | ||
|
|
a4821f9389 | ||
|
|
14e0a9a487 | ||
|
|
b17c7adcd5 | ||
|
|
a70722eb25 | ||
|
|
13ecd11543 | ||
|
|
ba0bf5668d | ||
|
|
338b4ed5d9 | ||
|
|
a4f5c802a9 | ||
|
|
8bc3d5d93c | ||
|
|
850a73d718 | ||
|
|
74802ce96e | ||
|
|
952ee53383 | ||
|
|
1804dce9d9 | ||
|
|
4231adaedf | ||
|
|
9e0dbfcf68 | ||
|
|
5139eef183 | ||
|
|
974e18292a | ||
|
|
3291e3a38f | ||
|
|
4db57b84b5 | ||
|
|
c2ba31e341 | ||
|
|
cb6024e334 | ||
|
|
12239fe852 | ||
|
|
a88070d063 | ||
|
|
9f8a40f482 | ||
|
|
d4babee202 | ||
|
|
7cfadb4584 | ||
|
|
fc2fe79fe7 | ||
|
|
2abb8e6335 | ||
|
|
cb4b710885 | ||
|
|
869777e9c4 | ||
|
|
eab5e78150 | ||
|
|
0344c3d56f | ||
|
|
43f4a2f7b7 | ||
|
|
0022b750b5 | ||
|
|
d49714bb10 | ||
|
|
fd48f4adfd | ||
|
|
7f97e67931 | ||
|
|
11bf32f6f1 | ||
|
|
55dee2d847 | ||
|
|
ae78acf97a | ||
|
|
fda0978225 | ||
|
|
227323c96d | ||
|
|
51344262c6 | ||
|
|
4152e05dcd | ||
|
|
5574acda3d | ||
|
|
75a93314a2 | ||
|
|
91b2ab8be1 | ||
|
|
8fc689c89a | ||
|
|
b3efc36487 | ||
|
|
71cb002bc1 | ||
|
|
78dcb8a0f3 | ||
|
|
9d6cbfe0cc | ||
|
|
7ab3d76c9f | ||
|
|
6686badc93 | ||
|
|
1b47b68cc7 | ||
|
|
b70873e046 | ||
|
|
f7c6fc9d1f | ||
|
|
f57dbeb60f | ||
|
|
397c45457a | ||
|
|
909598920b | ||
|
|
dac3d1c988 | ||
|
|
9164730b07 | ||
|
|
64f9aedebc | ||
|
|
5694a759ce | ||
|
|
ffedae66f4 | ||
|
|
a480bf0014 | ||
|
|
2432540d6e | ||
|
|
16eeaf625f | ||
|
|
f421278166 | ||
|
|
03e0c7317d | ||
|
|
fee99f3629 | ||
|
|
35c81365be | ||
|
|
8ff1a9daf3 | ||
|
|
6c6ed241d3 | ||
|
|
b84114bc8e | ||
|
|
1748a411e1 | ||
|
|
aa99eb803b | ||
|
|
47eabfb7fb | ||
|
|
a6ab14f28e | ||
|
|
a42cfed39c | ||
|
|
88c4618230 | ||
|
|
de58944140 | ||
|
|
7341bd184e | ||
|
|
7a8bf78f39 | ||
|
|
7268987461 | ||
|
|
ce56680fff | ||
|
|
ea7d5ad8f1 | ||
|
|
91302da050 | ||
|
|
d49c72cf8b | ||
|
|
c11036a7b9 | ||
|
|
5dd4037c02 | ||
|
|
176a8182e8 | ||
|
|
debbaea384 | ||
|
|
756255999f | ||
|
|
35e4374e2e | ||
|
|
7b56dd5c8a | ||
|
|
53f9bb0402 | ||
|
|
885117fb66 | ||
|
|
d12d7625aa | ||
|
|
7399991181 | ||
|
|
e62654acba | ||
|
|
7d795b523e | ||
|
|
38817bdd2c | ||
|
|
4b8a581c9a | ||
|
|
8b0a10ad1d | ||
|
|
7fc993e079 | ||
|
|
d846d91b0b | ||
|
|
660d6201ab | ||
|
|
2ab3498ab0 | ||
|
|
f7f4ea4243 | ||
|
|
637471ef29 | ||
|
|
f06a3605d2 | ||
|
|
f523d6a74d | ||
|
|
ff8cbf97c4 | ||
|
|
a947dfa9d5 | ||
|
|
28870d2ae5 | ||
|
|
cc3b86ea80 | ||
|
|
ae8efdddcb | ||
|
|
7f24f137d6 | ||
|
|
eaea3c927d | ||
|
|
72475d6770 | ||
|
|
8bb6f0e5c6 | ||
|
|
0b990e46ab | ||
|
|
1d313e3120 | ||
|
|
561004c4bf | ||
|
|
6f1eefbdbe | ||
|
|
23ac0b4637 | ||
|
|
a008a3f804 | ||
|
|
c81e7e3410 | ||
|
|
d459ebee41 | ||
|
|
ea684d5933 | ||
|
|
a730cfe9b5 | ||
|
|
c9b6b7b212 | ||
|
|
d72a9150a1 | ||
|
|
bfaedba9ed | ||
|
|
0c5cbe536f | ||
|
|
175f9afa68 | ||
|
|
8216097b2c | ||
|
|
adbdcd6b1d | ||
|
|
ac4f594063 | ||
|
|
2d53547e03 | ||
|
|
7c775aee2e | ||
|
|
b1ae2a178f | ||
|
|
fa2dc5b20a | ||
|
|
dd8fa985c1 | ||
|
|
81926ceae2 | ||
|
|
d3da389f9f | ||
|
|
782eee3c58 | ||
|
|
d0d0ea5051 | ||
|
|
3509f963ee | ||
|
|
98cbef547a | ||
|
|
90d3841ab2 | ||
|
|
3f2ad5ccb0 | ||
|
|
6f8ffd55a7 | ||
|
|
96703c247c | ||
|
|
c39565ddb1 | ||
|
|
70390ff1f7 | ||
|
|
924b7621ac | ||
|
|
715a51d01f | ||
|
|
a1afa23bc4 | ||
|
|
b53947ccc3 | ||
|
|
b43da7b7f0 | ||
|
|
fdc3c0791e | ||
|
|
04827466b0 | ||
|
|
afbcdc8a20 | ||
|
|
b5ae5defcf | ||
|
|
1f351c50d5 | ||
|
|
9a37b94f4d | ||
|
|
acf6dcac86 | ||
|
|
fcec0ee7c7 | ||
|
|
b9b0ec865c | ||
|
|
fcaa5361c8 | ||
|
|
33588b65ce | ||
|
|
c09c65e4c7 | ||
|
|
11ea385169 | ||
|
|
3a0310e832 | ||
|
|
31ab1ced06 | ||
|
|
b2c61a341a | ||
|
|
4c9321f02a | ||
|
|
d2005bd42a | ||
|
|
8817de8a55 | ||
|
|
97dbc7ff07 | ||
|
|
9c104ef310 | ||
|
|
7f0ff04ccf | ||
|
|
5502fbbdc1 | ||
|
|
deedc1aaa6 | ||
|
|
37af05c456 | ||
|
|
8c35d79576 | ||
|
|
6572989993 | ||
|
|
8eed58a467 | ||
|
|
2e77155b4e | ||
|
|
8b8edf6e70 | ||
|
|
f0aa177bf8 | ||
|
|
e163204643 | ||
|
|
50d7d7eedb | ||
|
|
ec05036a2d | ||
|
|
b8223d1b98 | ||
|
|
781c5129a9 | ||
|
|
111dd7eb68 | ||
|
|
21f5400d9c | ||
|
|
8cf3e227ea | ||
|
|
8c95919b32 | ||
|
|
b406c3d03d | ||
|
|
c70e87d582 | ||
|
|
57ba8fd09b | ||
|
|
3cf3f6c3f8 | ||
|
|
499f7b3929 | ||
|
|
e58415f94a | ||
|
|
38d2c3690a | ||
|
|
4212fb88c8 | ||
|
|
f769e1a00c | ||
|
|
1f9b898702 | ||
|
|
2f71cb4cd7 | ||
|
|
b8d2be9a0d | ||
|
|
b2d8dde3a5 | ||
|
|
0ee4885056 | ||
|
|
45bac7feb0 | ||
|
|
892b8c05b1 | ||
|
|
7d64ade621 | ||
|
|
45c43f4aee | ||
|
|
1b47aa10ca | ||
|
|
bcd88b4437 | ||
|
|
10d778e344 | ||
|
|
0100ebadb9 | ||
|
|
20b5f76572 | ||
|
|
62ed3973b5 | ||
|
|
5f7e800444 | ||
|
|
b52b5f46f0 | ||
|
|
3386a3af80 | ||
|
|
9099516906 | ||
|
|
f235f97d95 | ||
|
|
4bd4d8d4a5 | ||
|
|
284fab7254 | ||
|
|
f772c88eed | ||
|
|
58d94c2827 | ||
|
|
7e8d4b89ca | ||
|
|
70be2941fe | ||
|
|
9ffbac4f4e | ||
|
|
684b59a921 | ||
|
|
e8765c5d3d | ||
|
|
d179240c45 | ||
|
|
ac530a4ce0 | ||
|
|
589482736f | ||
|
|
3d2bd070ad | ||
|
|
c4a58b1c95 | ||
|
|
b9579a53ce | ||
|
|
94c439e533 | ||
|
|
a327a788c1 | ||
|
|
a541acb2bc | ||
|
|
63d1fa2d8e | ||
|
|
e4ee52e1ac | ||
|
|
c0729ff5e2 | ||
|
|
c2d37cdff5 | ||
|
|
0f00a2db08 | ||
|
|
67e74581cc | ||
|
|
eb9f496cd8 | ||
|
|
0203d2c811 | ||
|
|
6bc2d20177 | ||
|
|
350eb462ca | ||
|
|
591aea54b6 | ||
|
|
00ad38f5b7 | ||
|
|
261e135845 | ||
|
|
f50d8317f6 | ||
|
|
3558418ed7 | ||
|
|
fca927884b | ||
|
|
10c62dc0c0 | ||
|
|
7e9b22cb6e | ||
|
|
c427dfbea7 | ||
|
|
e88039d4e0 | ||
|
|
84a59c6fb7 | ||
|
|
19be28cc2e | ||
|
|
c116a731f1 | ||
|
|
cf9dd08c45 | ||
|
|
a88b447327 | ||
|
|
52514a96bd | ||
|
|
5ffb4d9845 | ||
|
|
0bb2dc32af | ||
|
|
213e7ced8c | ||
|
|
380479cadd | ||
|
|
04c23383b1 | ||
|
|
90ff154598 | ||
|
|
840b432ce0 | ||
|
|
e1b6e09cd3 | ||
|
|
ad8373925a | ||
|
|
2292515315 | ||
|
|
d9ce8249cb | ||
|
|
b3bb37323d | ||
|
|
c6b5675262 | ||
|
|
43bca4dcc2 | ||
|
|
dbbc30368d | ||
|
|
5f651f7fde | ||
|
|
eadfec75a4 | ||
|
|
e2aab2ab10 | ||
|
|
8705aea634 | ||
|
|
3040708d4e | ||
|
|
2382902fe4 | ||
|
|
ee0575bbb0 | ||
|
|
aff2551942 | ||
|
|
18b54b9064 | ||
|
|
d1af9b5fd1 | ||
|
|
e3349116cb | ||
|
|
c70f16c65a | ||
|
|
37d9867c06 | ||
|
|
cddae6f456 | ||
|
|
ff27484527 | ||
|
|
324d52bf2b | ||
|
|
9f648879e5 | ||
|
|
a7c41f6ac2 | ||
|
|
fbb6e88d0d | ||
|
|
49383e7391 | ||
|
|
f715952128 | ||
|
|
2516654d2e | ||
|
|
8dbcfde314 | ||
|
|
4218674e7c | ||
|
|
89119880b5 | ||
|
|
42956c0a10 | ||
|
|
e0e2c00d12 | ||
|
|
691d891794 | ||
|
|
df6dfec728 | ||
|
|
dfa36b7735 | ||
|
|
c28426a09f | ||
|
|
8567246772 | ||
|
|
a9961d3bb4 | ||
|
|
bded4f9142 | ||
|
|
491036a1e6 | ||
|
|
3e012e7f79 | ||
|
|
3929ff1f27 | ||
|
|
56d768f546 | ||
|
|
4ec992474e | ||
|
|
822501b8a1 | ||
|
|
bf3ff460b3 | ||
|
|
ff9ae0782e | ||
|
|
66defdfc27 | ||
|
|
3e65d308a8 | ||
|
|
a88d0da1af | ||
|
|
aa38226337 | ||
|
|
5961ed2e4a | ||
|
|
4dd9131847 | ||
|
|
6d1a2b0d86 | ||
|
|
cdaf54dfe0 | ||
|
|
7f0edd441e | ||
|
|
4a9dffd3e1 | ||
|
|
f69f4eb85f | ||
|
|
84782a40df | ||
|
|
047c143879 | ||
|
|
a7c9aff568 | ||
|
|
fe6d44bbd5 | ||
|
|
489b7f1d33 | ||
|
|
ad9de71ac9 | ||
|
|
3edaac9bd7 | ||
|
|
9247a8ab00 | ||
|
|
7b71ff2643 | ||
|
|
97e88640ca | ||
|
|
e1b89a3008 | ||
|
|
6dff44da54 | ||
|
|
7fddf5abf4 | ||
|
|
6c17f247df | ||
|
|
9b2e77711a | ||
|
|
0b131d6864 | ||
|
|
abb8d8447f | ||
|
|
7edc1f8a6d | ||
|
|
a0dd8cbc97 | ||
|
|
4f15715993 | ||
|
|
679b2863fa | ||
|
|
13f6e2d4d0 | ||
|
|
4311dc3270 | ||
|
|
01f4b204c9 | ||
|
|
f40bfbf762 | ||
|
|
ccf5aa6b54 | ||
|
|
032dde7be9 | ||
|
|
2d5b71c832 | ||
|
|
8272151d78 | ||
|
|
1b79252947 | ||
|
|
bc4d6b7104 | ||
|
|
46839b9752 | ||
|
|
f27c33cd18 | ||
|
|
d2e01da287 | ||
|
|
3ef2bdcb8d | ||
|
|
cd304dc800 | ||
|
|
901890e36d |
@@ -0,0 +1,12 @@
|
|||||||
|
# GitHub views all .h files as C, let's assume it's C++
|
||||||
|
*.h linguist-language=c++
|
||||||
|
|
||||||
|
# Internal tools overriding
|
||||||
|
tools/* linguist-vendored
|
||||||
|
editor/* linguist-vendored
|
||||||
|
|
||||||
|
# Third-party overriding
|
||||||
|
extensions/curl/curl-src/* linguist-vendored
|
||||||
|
extensions/geoip/GeoIP.c linguist-vendored
|
||||||
|
extensions/geoip/GeoIP.h linguist-vendored
|
||||||
|
extensions/sqlite/sqlite-source/* linguist-vendored
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
# Contributing to SourceMod
|
||||||
|
|
||||||
|
## Issue reports
|
||||||
|
|
||||||
|
Please consider the following guidelines when reporting an issue.
|
||||||
|
|
||||||
|
#### Not for general support
|
||||||
|
This is not the right place to get help with using or installing SourceMod, or for issues with specific, third-party SourceMod plugins or extensions.
|
||||||
|
|
||||||
|
For help with SourceMod, please consult the [AlliedModders forums](https://forums.alliedmods.net/forumdisplay.php?f=52). Similarly, for assistance with, or to report issues with, third-party SourceMod plugins or extensions, you should post in the existing thread for that plugin or extension on the [AlliedModders forums](https://forums.alliedmods.net/forumdisplay.php?f=52).
|
||||||
|
|
||||||
|
#### Details, details, details
|
||||||
|
Provide as much detail as possible when reporting an issue.
|
||||||
|
|
||||||
|
For bugs or other undesired behavior, answers to the following questions are a great start:
|
||||||
|
* What is the issue?
|
||||||
|
* What behavior are you expecting instead?
|
||||||
|
* On what operating system is the game server running?
|
||||||
|
* What game is the game server running?
|
||||||
|
* What exact version (full x.y.z.a version number) of Metamod:Source and SourceMod are installed on the game server?
|
||||||
|
* What is the specific, shortest path to reproducing this issue? If this issue can be reproduced with plugin code, please try to shorten it to the minimum required to trigger the problem.
|
||||||
|
|
||||||
|
If this is a feature request, the following are helpful. Generally, not all will apply, but whatever you can answer ahead of time will shorten back and forth conversation.
|
||||||
|
* What is your end goal, or what are you trying to accomplish?
|
||||||
|
* Why is this necessary, or what benefit do you see with it?
|
||||||
|
* Will this be useful to others?
|
||||||
|
|
||||||
|
#### Issues with security implications
|
||||||
|
Please report any security bugs to [[email protected]](mailto:[email protected]) rather than to this public issue tracker.
|
||||||
|
|
||||||
|
#### We're only human
|
||||||
|
Please keep in mind that we maintain this project in our spare time, at no cost. There is no SLA, and you are not owed a response or a fix.
|
||||||
|
|
||||||
|
#### Conduct
|
||||||
|
Please refer to the [AlliedModders forum rules.](https://forums.alliedmods.net/misc.php?do=showrules)
|
||||||
|
|
||||||
|
## Pull Requests
|
||||||
|
|
||||||
|
Firstly, thank you for considering contributing changes to the project!
|
||||||
|
|
||||||
|
However, if this is anything more than a small fix such as a gamedata update, a glaring code flaw, or a simple typo in a file like this one, please file an issue first so that it can be discussed, unless you have already spoken to multiple members of the development team about it on IRC or the AlliedModders forums.
|
||||||
|
|
||||||
|
We don't like to have to reject pull requests, so we want to avoid those scenarios. We wouldn't want you to feel like you wasted your time writing something only for us to shoot it down.
|
||||||
|
|
||||||
|
#### Rejection
|
||||||
|
*Copied from Phabricator's [Contributing Code guidelines](https://secure.phabricator.com/book/phabcontrib/article/contributing_code/#rejecting-patches), as we largely feel the same way about this.*
|
||||||
|
|
||||||
|
> If you send us a patch without coordinating it with us first, it will probably be immediately rejected, or sit in limbo for a long time and eventually be rejected. The reasons we do this vary from patch to patch, but some of the most common reasons are:
|
||||||
|
>
|
||||||
|
> **Unjustifiable Costs**: We support code in the upstream forever. Support is enormously expensive and takes up a huge amount of our time. The cost to support a change over its lifetime is often 10x or 100x or 1000x greater than the cost to write the first version of it. Many uncoordinated patches we receive are "white elephants", which would cost much more to maintain than the value they provide.
|
||||||
|
>
|
||||||
|
> As an author, it may look like you're giving us free work and we're rejecting it as too expensive, but this viewpoint doesn't align with the reality of a large project which is actively supported by a small, experienced team. Writing code is cheap; maintaining it is expensive.
|
||||||
|
>
|
||||||
|
> By coordinating with us first, you can make sure the patch is something we consider valuable enough to put long-term support resources behind, and that you're building it in a way that we're comfortable taking over.
|
||||||
|
>
|
||||||
|
> **Not a Good Fit**: Many patches aren't good fits for the upstream: they implement features we simply don't want. You can find more information in Contributing Feature Requests. Coordinating with us first helps make sure we're on the same page and interested in a feature.
|
||||||
|
>
|
||||||
|
> The most common type of patch along these lines is a patch which adds new configuration options. We consider additional configuration options to have an exceptionally high lifetime support cost and are very unlikely to accept them. Coordinate with us first.
|
||||||
|
>
|
||||||
|
> **Not a Priority**: If you send us a patch against something which isn't a priority, we probably won't have time to look at it. We don't give special treatment to low-priority issues just because there's code written: we'd still be spending time on something lower-priority when we could be spending it on something higher-priority instead.
|
||||||
|
>
|
||||||
|
> If you coordinate with us first, you can make sure your patch is in an area of the codebase that we can prioritize.
|
||||||
|
>
|
||||||
|
> **Overly Ambitious Patches**: Sometimes we'll get huge patches from new contributors. These can have a lot of fundamental problems and require a huge amount of our time to review and correct. If you're interested in contributing, you'll have more success if you start small and learn as you go.
|
||||||
|
>
|
||||||
|
> We can help you break a large change into smaller pieces and learn how the codebase works as you proceed through the implementation, but only if you coordinate with us first.
|
||||||
|
>
|
||||||
|
> **Generality**: We often receive several feature requests which ask for similar features, and can come up with a general approach which covers all of the use cases. If you send us a patch for your use case only, the approach may be too specific. When a cleaner and more general approach is available, we usually prefer to pursue it.
|
||||||
|
>
|
||||||
|
> By coordinating with us first, we can make you aware of similar use cases and opportunities to generalize an approach. These changes are often small, but can have a big impact on how useful a piece of code is.
|
||||||
|
>
|
||||||
|
> **Infrastructure and Sequencing**: Sometimes patches are written against a piece of infrastructure with major planned changes. We don't want to accept these because they'll make the infrastructure changes more difficult to implement.
|
||||||
|
>
|
||||||
|
> Coordinate with us first to make sure a change doesn't need to wait on other pieces of infrastructure. We can help you identify technical blockers and possibly guide you through resolving them if you're interested.
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||||
|
patreon: # Replace with a single Patreon username
|
||||||
|
open_collective: # Replace with a single Open Collective username
|
||||||
|
ko_fi: # Replace with a single Ko-fi username
|
||||||
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
|
custom: https://www.sourcemod.net/donate.php
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
name: Bug Report
|
||||||
|
description: Create a report to help us improve
|
||||||
|
title: "[Bug]: "
|
||||||
|
labels: ["Bug"]
|
||||||
|
body:
|
||||||
|
- type: markdown
|
||||||
|
attributes:
|
||||||
|
value: |
|
||||||
|
Thanks for taking the time to fill out this bug report! Please make sure you provide all the requested information to help us address the issue efficiently.
|
||||||
|
|
||||||
|
- type: checkboxes
|
||||||
|
id: prerequisites
|
||||||
|
attributes:
|
||||||
|
label: Prerequisites
|
||||||
|
description: Please confirm these before submitting your issue
|
||||||
|
options:
|
||||||
|
- label: I have checked that my issue doesn't exist yet in the [issue tracker](https://github.com/alliedmodders/sourcemod/issues)
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: os-version
|
||||||
|
attributes:
|
||||||
|
label: Operating System and Version
|
||||||
|
description: What operating system and version are you using?
|
||||||
|
placeholder: "e.g., Windows 10 21H2, Ubuntu 22.04"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: game-version
|
||||||
|
attributes:
|
||||||
|
label: Game / AppID and Version
|
||||||
|
description: Which game and version are you using?
|
||||||
|
placeholder: "e.g., CS:GO (730) version 1.38.2.5"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: sourcemod-version
|
||||||
|
attributes:
|
||||||
|
label: SourceMod Version
|
||||||
|
description: On which version of SourceMod did you first observe this?
|
||||||
|
placeholder: "e.g., 1.11.0.6936"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: metamod-version
|
||||||
|
attributes:
|
||||||
|
label: Metamod:Source Version
|
||||||
|
description: On which version of Metamod:Source did you first observe this?
|
||||||
|
placeholder: "e.g., 1.11.0-git1145"
|
||||||
|
|
||||||
|
- type: checkboxes
|
||||||
|
id: version-checks
|
||||||
|
attributes:
|
||||||
|
label: Version Verification
|
||||||
|
description: Please confirm you've tested with the latest versions
|
||||||
|
options:
|
||||||
|
- label: I have updated SourceMod to the [latest version](https://www.sourcemod.net/downloads.php) and the issue persists
|
||||||
|
- label: I have updated SourceMod to the [latest snapshot](https://www.sourcemod.net/downloads.php?branch=dev) and the issue persists
|
||||||
|
- label: I have updated Metamod:Source to the [latest snapshot](https://sourcemm.net/downloads.php?branch=dev) and the issue persists
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: sourcemod-version-latest
|
||||||
|
attributes:
|
||||||
|
label: Updated SourceMod Version
|
||||||
|
description: If you updated SourceMod to the latest version to confirm the issue persisted, which version was that?
|
||||||
|
placeholder: "e.g., 1.11.0.6936"
|
||||||
|
|
||||||
|
- type: input
|
||||||
|
id: metamod-version-latest
|
||||||
|
attributes:
|
||||||
|
label: Updated Metamod:Source Version
|
||||||
|
description: If you updated Metamod:Source to the latest version to confirm the issue persisted, which version was that?
|
||||||
|
placeholder: "e.g., 1.11.0-git1145"
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: description
|
||||||
|
attributes:
|
||||||
|
label: Description
|
||||||
|
description: Please provide a clear and concise description of the bug
|
||||||
|
placeholder: What happened? What did you expect to happen?
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: reproduction
|
||||||
|
attributes:
|
||||||
|
label: Steps to Reproduce
|
||||||
|
description: Please provide the code or steps needed to reproduce the issue
|
||||||
|
placeholder: |
|
||||||
|
*If possible, please include the smallest possible test-case to reproduce the issue.*
|
||||||
|
|
||||||
|
*Also, please make it clear whether or not you can consistently reproduce this issue with the provided description*
|
||||||
|
|
||||||
|
1. First step...
|
||||||
|
2. Second step...
|
||||||
|
3. ...
|
||||||
|
|
||||||
|
```sourcepawn
|
||||||
|
// Add your code here if applicable
|
||||||
|
```
|
||||||
|
|
||||||
|
- type: textarea
|
||||||
|
id: logs
|
||||||
|
attributes:
|
||||||
|
label: Relevant Log Output
|
||||||
|
description: |
|
||||||
|
Please provide any relevant log output. This will be automatically formatted into code, so no need for backticks.
|
||||||
|
Include:
|
||||||
|
- Game output
|
||||||
|
- Library logs
|
||||||
|
- Kernel logs
|
||||||
|
- Minidump or dump analyze output (in case of crashes)
|
||||||
|
render: shell
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: Get Help on Discord
|
||||||
|
url: https://discord.gg/HUc67zN
|
||||||
|
about: For general help or assistance, join the AlliedModders Discord or Forums instead of filing a bug
|
||||||
|
- name: Get Help on the Forums
|
||||||
|
url: https://forums.alliedmods.net
|
||||||
|
about: For general help or assistance, join the AlliedModders Discord or Forums instead of filing a bug
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: Feature Request
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Help us help you
|
||||||
|
- [ ] I have checked that my issue [doesn't exist yet](https://github.com/alliedmodders/sourcemod/issues).
|
||||||
|
|
||||||
|
## Is your feature request related to a problem? Please describe.
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
## Describe the solution you'd like
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
## Describe alternatives you've considered
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
## Additional context
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
# Check for updates to GitHub Actions every week
|
||||||
|
interval: "weekly"
|
||||||
@@ -0,0 +1,249 @@
|
|||||||
|
name: Build Release
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- '[0-9]+.[0-9]+-dev'
|
||||||
|
env:
|
||||||
|
ARCH: x86,x86_64
|
||||||
|
DUMP_SYMS_VERSION: '2.3.7'
|
||||||
|
# Used for caching
|
||||||
|
# TODO: Handle this better so that we don't have to update this in lockstep with checkout-deps
|
||||||
|
MARIADB_CONNECTOR_C_VERSION: '3.4.9'
|
||||||
|
MARIADB_CONNECTOR_C_RELEASE: '3.4.9-sm.5'
|
||||||
|
MMSOURCE_VERSION: '1.12'
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- platform: windows
|
||||||
|
os: windows-latest
|
||||||
|
os_short: win
|
||||||
|
- platform: linux
|
||||||
|
os: ubuntu-latest
|
||||||
|
os_short: linux
|
||||||
|
container_image: ghcr.io/alliedmodders/build-containers/debian11-clang22:latest
|
||||||
|
fail-fast: false
|
||||||
|
name: ${{ matrix.platform }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
container:
|
||||||
|
image: ${{ matrix.container_image }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout SourceMod
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
path: sourcemod
|
||||||
|
fetch-depth: 0
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Install Windows dependencies
|
||||||
|
if: startsWith(matrix.os, 'windows')
|
||||||
|
shell: pwsh
|
||||||
|
run: |
|
||||||
|
# Add DIA SDK bin directory to PATH for dump_syms
|
||||||
|
# vswhere.exe is pre-installed on GitHub Windows runners
|
||||||
|
$vsRoot = & vswhere -latest -property installationPath
|
||||||
|
$diaDir = Join-Path $vsRoot 'DIA SDK\bin'
|
||||||
|
$diaDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||||
|
|
||||||
|
$toolsDir = New-Item -Path '_tools' -ItemType Directory -Force
|
||||||
|
$toolsDir.FullName | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||||
|
Push-Location $toolsDir
|
||||||
|
$dumpsymsUrl = "https://github.com/mozilla/dump_syms/releases/download/v${{ env.DUMP_SYMS_VERSION }}/dump_syms-x86_64-pc-windows-msvc.zip"
|
||||||
|
curl -sSL -o dump_syms.zip $dumpsymsUrl
|
||||||
|
Expand-Archive -Path dump_syms.zip -DestinationPath .
|
||||||
|
Remove-Item dump_syms.zip
|
||||||
|
# Flatten if extracted into a subdirectory
|
||||||
|
Get-ChildItem -Recurse -Filter 'dump_syms.exe' | Move-Item -Destination . -ErrorAction SilentlyContinue
|
||||||
|
Pop-Location
|
||||||
|
|
||||||
|
# Largely a workaround for issue where github.workspace doesn't match $GITHUB_WORKSPACE
|
||||||
|
# in containerized jobs. See https://github.com/actions/runner/issues/2058
|
||||||
|
- name: Resolve paths
|
||||||
|
id: path_helper
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "dependencies=$GITHUB_WORKSPACE/dependencies" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Generate SDK list
|
||||||
|
id: sdk_list
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
sdk_list=()
|
||||||
|
for file in sourcemod/hl2sdk-manifests/manifests/*.json; do
|
||||||
|
sdk=$(basename "$file" .json)
|
||||||
|
if [[ $sdk == "mock" ]]; then
|
||||||
|
# We don't need to ship a build for the mock SDK
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
platform=$(jq -r '.platforms.${{ matrix.platform }}' "$file")
|
||||||
|
if [[ -z $platform || $platform == "null" || ${#platform[@]} -eq 0 ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
source2=$(jq -r '.source2' "$file")
|
||||||
|
if [[ $source2 == "null" || $source2 == "true" ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
sdk_list+=("$sdk")
|
||||||
|
done
|
||||||
|
echo "sdk_list=$(printf '%s\n' "${sdk_list[@]}" | jq --raw-input . | jq --slurp --compact-output .)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Cache dependencies
|
||||||
|
uses: actions/cache@v6
|
||||||
|
env:
|
||||||
|
cache-name: hl2sdk-mariadb-connector-c-mmsource
|
||||||
|
with:
|
||||||
|
path: ${{ steps.path_helper.outputs.dependencies }}
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-mariadb${{ env.MARIADB_CONNECTOR_C_RELEASE }}-mmsource${{ env.MMSOURCE_VERSION }}-${{ join(fromJson(steps.sdk_list.outputs.sdk_list), '') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-build-${{ env.cache-name }}-mariadb${{ env.MARIADB_CONNECTOR_C_RELEASE }}-mmsource${{ env.MMSOURCE_VERSION }}-
|
||||||
|
${{ runner.os }}-build-${{ env.cache-name }}-mariadb${{ env.MARIADB_CONNECTOR_C_RELEASE }}-
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
MAXMIND_LICENSE_KEY: ${{ secrets.MAXMIND_LICENSE_KEY }}
|
||||||
|
run: |
|
||||||
|
mkdir -p '${{ steps.path_helper.outputs.dependencies }}'
|
||||||
|
cd '${{ steps.path_helper.outputs.dependencies }}'
|
||||||
|
|
||||||
|
# Satisfy checkout-deps requirement for a "sourcemod" folder.
|
||||||
|
mkdir -p sourcemod
|
||||||
|
../sourcemod/tools/checkout-deps.sh -s ${{ join(fromJson(steps.sdk_list.outputs.sdk_list), ',') }}
|
||||||
|
|
||||||
|
if [ -z "$MAXMIND_LICENSE_KEY" ]; then
|
||||||
|
echo "::error::MAXMIND_LICENSE_KEY secret is not configured."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
geotmpdir=$(mktemp -d)
|
||||||
|
geotar="$geotmpdir/GeoLite2-City.tar.gz"
|
||||||
|
curl -fsSL "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=$MAXMIND_LICENSE_KEY&suffix=tar.gz" -o "$geotar"
|
||||||
|
tar -xzf "$geotar" -C "$geotmpdir"
|
||||||
|
geommdb=$(find "$geotmpdir" -type f -name 'GeoLite2-City.mmdb' | head -n 1)
|
||||||
|
if [ -z "$geommdb" ]; then
|
||||||
|
echo "::error::GeoLite2-City.mmdb not found in downloaded MaxMind archive."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
cp "$geommdb" '${{ steps.path_helper.outputs.dependencies }}/GeoLite2-City.mmdb'
|
||||||
|
rm -rf "$geotmpdir"
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
working-directory: sourcemod
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
BREAKPAD_SYMBOL_SERVER: ${{ vars.BREAKPAD_SYMBOL_SERVER }}
|
||||||
|
BREAKPAD_SYMBOL_SERVER_TOKEN: ${{ secrets.BREAKPAD_SYMBOL_SERVER_TOKEN }}
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
python3 ../configure.py \
|
||||||
|
--enable-optimize \
|
||||||
|
--breakpad-dump \
|
||||||
|
--symbol-files \
|
||||||
|
--sdks=${{ join(fromJson(steps.sdk_list.outputs.sdk_list), ',') }} \
|
||||||
|
--targets=${{ env.ARCH }} \
|
||||||
|
'--mms-path=${{ steps.path_helper.outputs.dependencies }}/mmsource-${{ env.MMSOURCE_VERSION }}' \
|
||||||
|
'--hl2sdk-root=${{ steps.path_helper.outputs.dependencies }}' \
|
||||||
|
'--mariadb-path=${{ steps.path_helper.outputs.dependencies }}/mariadb-connector-c-${{ env.MARIADB_CONNECTOR_C_VERSION }}-x86' \
|
||||||
|
'--mariadb64-path=${{ steps.path_helper.outputs.dependencies }}/mariadb-connector-c-${{ env.MARIADB_CONNECTOR_C_VERSION }}-x86_64'
|
||||||
|
ambuild
|
||||||
|
|
||||||
|
mkdir -p package/addons/sourcemod/configs/geoip
|
||||||
|
cp '${{ steps.path_helper.outputs.dependencies }}/GeoLite2-City.mmdb' package/addons/sourcemod/configs/geoip/GeoLite2-City.mmdb
|
||||||
|
|
||||||
|
- name: Package
|
||||||
|
id: package
|
||||||
|
working-directory: sourcemod/build/package
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
version_base=$(cat ../../product.version)
|
||||||
|
version_base=${version_base%-dev} # Ex. 1.12.0
|
||||||
|
version_rev=$(git rev-list --count HEAD)
|
||||||
|
version="${version_base}.${version_rev}"
|
||||||
|
expanded_version="${version_base}-git${version_rev}"
|
||||||
|
|
||||||
|
if [ "${{ matrix.platform}}" == "windows" ]; then
|
||||||
|
filename="sourcemod-${expanded_version}-${{ matrix.platform }}.zip"
|
||||||
|
7z a "$filename" addons cfg
|
||||||
|
content_type="application/zip"
|
||||||
|
else
|
||||||
|
filename="sourcemod-${expanded_version}-${{ matrix.platform }}.tar.gz"
|
||||||
|
tar zcf "$filename" addons cfg
|
||||||
|
content_type="application/gzip"
|
||||||
|
fi
|
||||||
|
echo "version=$version" >> $GITHUB_OUTPUT
|
||||||
|
echo "expanded_version=$expanded_version" >> $GITHUB_OUTPUT
|
||||||
|
echo "filename=$filename" >> $GITHUB_OUTPUT
|
||||||
|
echo "content_type=$content_type" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: ncipollo/[email protected]
|
||||||
|
with:
|
||||||
|
# Windows and Linux packages will need to upload to the same release
|
||||||
|
allowUpdates: true
|
||||||
|
replacesArtifacts: false
|
||||||
|
omitBodyDuringUpdate: true
|
||||||
|
omitDraftDuringUpdate: true
|
||||||
|
omitNameDuringUpdate: true
|
||||||
|
omitPrereleaseDuringUpdate: true
|
||||||
|
|
||||||
|
# This gets overly large and meaningless with our existing release patterns
|
||||||
|
omitBody: true
|
||||||
|
|
||||||
|
artifacts: sourcemod/build/package/${{ steps.package.outputs.filename }}
|
||||||
|
artifactContentType: ${{ steps.package.outputs.content_type }}
|
||||||
|
artifactErrorsFailBuild: true
|
||||||
|
|
||||||
|
tag: ${{ steps.package.outputs.version }}
|
||||||
|
commit: ${{ github.sha }}
|
||||||
|
generateReleaseNotes: true
|
||||||
|
|
||||||
|
draft: false
|
||||||
|
prerelease: ${{ github.ref == 'refs/heads/master' }}
|
||||||
|
makeLatest: ${{ github.ref != 'refs/heads/master' }}
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Output PDBs
|
||||||
|
if: startsWith(matrix.os, 'windows')
|
||||||
|
shell: pwsh
|
||||||
|
id: output_pdbs
|
||||||
|
working-directory: sourcemod/build
|
||||||
|
run: |
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
$buildDir = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'sourcemod/build'
|
||||||
|
$outDir = Join-Path -Path $env:GITHUB_WORKSPACE -ChildPath 'pdbs'
|
||||||
|
New-Item -ItemType Directory -Force -Path $outDir | Out-Null
|
||||||
|
|
||||||
|
Get-Content -LiteralPath (Join-Path -Path $buildDir -ChildPath 'pdblog.txt') |
|
||||||
|
ForEach-Object -Process {
|
||||||
|
$fullPdbPathInfo = (Get-Item -Path (Join-Path -Path $buildDir -ChildPath $_))
|
||||||
|
$baseName = $fullPdbPathInfo.BaseName
|
||||||
|
$dir = $fullPdbPathInfo.DirectoryName
|
||||||
|
|
||||||
|
$relDir = [System.IO.Path]::GetRelativePath($buildDir, $dir)
|
||||||
|
$destDir = Join-Path $outDir $relDir
|
||||||
|
New-Item -ItemType Directory -Force -Path $destDir | Out-Null
|
||||||
|
|
||||||
|
'.pdb', '.exe', '.dll' | ForEach-Object -Process {
|
||||||
|
$binPath = Join-Path $dir ($baseName + $_)
|
||||||
|
if (Test-Path $binPath) {
|
||||||
|
Copy-Item -Path $binPath -Destination $destDir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- name: Upload PDBs
|
||||||
|
if: startsWith(matrix.os, 'windows')
|
||||||
|
id: upload_pdbs
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: pdbs
|
||||||
|
path: pdbs/*
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
name: Build and Push spcomp Container
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- '[0-9]+.[0-9]+-dev'
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: ${{ github.ref != 'refs/heads/master' && !contains(github.ref, '-dev') }}
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: ghcr.io
|
||||||
|
IMAGE_NAME: ${{ github.repository }}-spcomp
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Log in to the Container registry
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
uses: docker/login-action@v4
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract metadata (tags, labels) for Docker
|
||||||
|
id: meta
|
||||||
|
uses: docker/metadata-action@v6
|
||||||
|
with:
|
||||||
|
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
|
tags: |
|
||||||
|
type=ref,event=branch
|
||||||
|
type=ref,event=pr
|
||||||
|
type=semver,pattern={{version}}
|
||||||
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v7
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
file: ./containers/Containerfile.spcomp
|
||||||
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
name: hl2sdk-mock tests
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- '[0-9]+.[0-9]+-dev'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- '[0-9]+.[0-9]+-dev'
|
||||||
|
jobs:
|
||||||
|
mock:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ghcr.io/alliedmodders/build-containers/debian11-clang22:latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
name: Clone sourcemod
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
path: sourcemod
|
||||||
|
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
name: Clone metamod-source
|
||||||
|
with:
|
||||||
|
repository: alliedmodders/metamod-source
|
||||||
|
ref: 1.12-dev
|
||||||
|
submodules: recursive
|
||||||
|
path: metamod-source
|
||||||
|
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
name: Clone hl2sdk-mock
|
||||||
|
with:
|
||||||
|
repository: alliedmodders/hl2sdk-mock
|
||||||
|
submodules: recursive
|
||||||
|
path: hl2sdk-mock
|
||||||
|
|
||||||
|
- name: Build MetaMod:Source
|
||||||
|
working-directory: metamod-source
|
||||||
|
run: |
|
||||||
|
python3 configure.py --enable-optimize --sdks=mock --targets=x86,x86_64
|
||||||
|
ambuild objdir
|
||||||
|
|
||||||
|
- name: Build SourceMod
|
||||||
|
working-directory: sourcemod
|
||||||
|
run: |
|
||||||
|
python3 configure.py --no-mysql --enable-optimize --sdks=mock --targets=x86,x86_64
|
||||||
|
ambuild objdir
|
||||||
|
|
||||||
|
- name: Build hl2sdk-mock
|
||||||
|
working-directory: hl2sdk-mock
|
||||||
|
run: |
|
||||||
|
python3 configure.py --enable-optimize --targets=x86,x86_64
|
||||||
|
ambuild objdir
|
||||||
|
|
||||||
|
- name: Setup gamedir
|
||||||
|
working-directory: hl2sdk-mock
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir ../gamedir
|
||||||
|
./build_gamedir.sh ../gamedir ../metamod-source/objdir/package
|
||||||
|
./build_gamedir.sh ../gamedir ../sourcemod/objdir/package
|
||||||
|
|
||||||
|
- name: Compile testsuite
|
||||||
|
working-directory: hl2sdk-mock
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir ../gamedir/addons/sourcemod/plugins/optional
|
||||||
|
|
||||||
|
for f in ../sourcemod/plugins/testsuite/mock/*.sp; do
|
||||||
|
echo "Compiling $(basename $f)"
|
||||||
|
../gamedir/addons/sourcemod/scripting/spcomp64 -i ../gamedir/addons/sourcemod/scripting/include -o "../gamedir/addons/sourcemod/plugins/optional/$(basename $f .sp).smx" -E "$f"
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
working-directory: hl2sdk-mock
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
for arch in x86 x86_64; do
|
||||||
|
echo "==================================="
|
||||||
|
echo "Testing $arch..."
|
||||||
|
echo "==================================="
|
||||||
|
for f in ../gamedir/addons/sourcemod/plugins/optional/*.smx; do
|
||||||
|
echo "==================================="
|
||||||
|
echo "Running $(basename $f)..."
|
||||||
|
echo "==================================="
|
||||||
|
timeout 60 ./objdir/dist/$arch/srcds -game_dir ../gamedir +map de_thunder -command "sm plugins load optional/$(basename $f)" -run -run-ticks 20 |
|
||||||
|
{
|
||||||
|
failed=0
|
||||||
|
succeeded=0
|
||||||
|
while IFS= read -r line; do
|
||||||
|
echo "$line"
|
||||||
|
if [[ "$line" == *"FAIL"* || "$line" == *"Exception reported"* ]]; then
|
||||||
|
failed=1
|
||||||
|
fi
|
||||||
|
if [[ "$line" == *" OK"* ]]; then
|
||||||
|
succeeded=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ "$failed" = "1" ] || [ "$succeeded" = "0" ]; then
|
||||||
|
echo "$(basename $f) failed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
done
|
||||||
|
done
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
name: PR Checks
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- '[0-9]+.[0-9]+-dev'
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- platform: windows
|
||||||
|
os: windows-latest
|
||||||
|
os_short: win
|
||||||
|
- platform: linux
|
||||||
|
os: ubuntu-latest
|
||||||
|
os_short: linux
|
||||||
|
container_image: ghcr.io/alliedmodders/build-containers/debian11-clang22:latest
|
||||||
|
fail-fast: false
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
container:
|
||||||
|
image: ${{ matrix.container_image }}
|
||||||
|
name: ${{ matrix.os_short }}
|
||||||
|
env:
|
||||||
|
SDKS: '["episode1","css","tf2","l4d2","csgo","dods"]'
|
||||||
|
ARCH: x86,x86_64
|
||||||
|
MARIADB_CONNECTOR_C_VERSION: '3.4.9'
|
||||||
|
MARIADB_CONNECTOR_C_RELEASE: '3.4.9-sm.5'
|
||||||
|
MMSOURCE_VERSION: '1.12'
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
path: sourcemod
|
||||||
|
|
||||||
|
# Largely a workaround for issue where github.workspace doesn't match $GITHUB_WORKSPACE
|
||||||
|
# in containerized jobs. See https://github.com/actions/runner/issues/2058
|
||||||
|
- name: Resolve paths
|
||||||
|
id: path_helper
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "dependencies=$GITHUB_WORKSPACE/dependencies" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Cache dependencies
|
||||||
|
uses: actions/cache@v6
|
||||||
|
env:
|
||||||
|
cache-name: hl2sdk-mariadb-connector-c-mmsource
|
||||||
|
with:
|
||||||
|
path: ${{ steps.path_helper.outputs.dependencies }}
|
||||||
|
key: ${{ runner.os }}-build-${{ env.cache-name }}-mariadb${{ env.MARIADB_CONNECTOR_C_RELEASE }}-mmsource${{ env.MMSOURCE_VERSION }}-${{ join(fromJSON(env.SDKS), '') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-build-${{ env.cache-name }}-mariadb${{ env.MARIADB_CONNECTOR_C_RELEASE }}-mmsource${{ env.MMSOURCE_VERSION }}-
|
||||||
|
${{ runner.os }}-build-${{ env.cache-name }}-mariadb${{ env.MARIADB_CONNECTOR_C_RELEASE }}-
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir -p '${{ steps.path_helper.outputs.dependencies }}'
|
||||||
|
cd '${{ steps.path_helper.outputs.dependencies }}'
|
||||||
|
|
||||||
|
# Satisfy checkout-deps requirement for a "sourcemod" folder.
|
||||||
|
mkdir -p sourcemod
|
||||||
|
../sourcemod/tools/checkout-deps.sh -s ${{ join(fromJSON(env.SDKS), ',') }}
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
working-directory: sourcemod
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
python3 ../configure.py \
|
||||||
|
--enable-optimize \
|
||||||
|
--sdks=${{ join(fromJSON(env.SDKS), ',') }} \
|
||||||
|
--targets=${{ env.ARCH }} \
|
||||||
|
'--mms-path=${{ steps.path_helper.outputs.dependencies }}/mmsource-${{ env.MMSOURCE_VERSION }}' \
|
||||||
|
'--hl2sdk-root=${{ steps.path_helper.outputs.dependencies }}' \
|
||||||
|
'--mariadb-path=${{ steps.path_helper.outputs.dependencies }}/mariadb-connector-c-${{ env.MARIADB_CONNECTOR_C_VERSION }}-x86' \
|
||||||
|
'--mariadb64-path=${{ steps.path_helper.outputs.dependencies }}/mariadb-connector-c-${{ env.MARIADB_CONNECTOR_C_VERSION }}-x86_64'
|
||||||
|
ambuild
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
name: SourcePawn scripting
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- '[0-9]+.[0-9]+-dev'
|
||||||
|
paths:
|
||||||
|
- 'plugins/include/*'
|
||||||
|
- 'sourcepawn/**'
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: '53 05 01 */3 *' # Artifacts expire every 3 months
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest]
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
os_short: linux
|
||||||
|
- os: windows-latest
|
||||||
|
os_short: win
|
||||||
|
fail-fast: false
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
env:
|
||||||
|
ARCH: x86,x86_64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
# Setup Python for AMBuild
|
||||||
|
- uses: actions/setup-python@v7
|
||||||
|
name: Setup Python 3.12
|
||||||
|
with:
|
||||||
|
python-version: 3.12
|
||||||
|
- name: Install AMBuild
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip setuptools wheel
|
||||||
|
pip install git+https://github.com/alliedmodders/ambuild
|
||||||
|
|
||||||
|
- name: Install Linux dependencies
|
||||||
|
if: startsWith(runner.os, 'Linux')
|
||||||
|
run: |
|
||||||
|
sudo dpkg --add-architecture i386
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y --no-install-recommends \
|
||||||
|
gcc-multilib g++-multilib libstdc++6 lib32stdc++6 \
|
||||||
|
libc6-dev libc6-dev-i386 linux-libc-dev \
|
||||||
|
linux-libc-dev:i386 lib32z1-dev ${{ matrix.compiler_cc }}
|
||||||
|
|
||||||
|
- name: Select clang compiler
|
||||||
|
if: startsWith(runner.os, 'Linux')
|
||||||
|
run: |
|
||||||
|
echo "CC=clang" >> $GITHUB_ENV
|
||||||
|
echo "CXX=clang++" >> $GITHUB_ENV
|
||||||
|
clang --version
|
||||||
|
clang++ --version
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
python ../configure.py --enable-optimize --scripting-only --targets=${{ env.ARCH }}
|
||||||
|
ambuild
|
||||||
|
echo "SM_VERSION=$(cat ../product.version)" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Archive tooling
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: sourcemod-tooling-${{ env.SM_VERSION }}-${{ matrix.os_short }}
|
||||||
|
path: build/package
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
# srcdslab only (not in alliedmodders/sourcemod): build the patched 1.13-<rev> branches
|
||||||
|
# (upstream SourceMod at <rev> plus our x86_64 DHooks/BinTools fixes) and publish them as a
|
||||||
|
# GitHub release. build-release.yml only runs on master and X.Y-dev and needs secrets this
|
||||||
|
# fork does not have (MAXMIND_LICENSE_KEY, breakpad symbol server), so it is left untouched
|
||||||
|
# to keep upstream merges clean.
|
||||||
|
name: srcdslab build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '1.13-[0-9]+'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- '1.13-[0-9]+'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
ARCH: x86,x86_64
|
||||||
|
# NiDE only runs CS:S on Linux (checked on 2026-11-13), so only that SDK is built.
|
||||||
|
SDKS: css
|
||||||
|
MARIADB_CONNECTOR_C_VERSION: '3.4.9'
|
||||||
|
MARIADB_CONNECTOR_C_RELEASE: '3.4.9-sm.5'
|
||||||
|
# srcdslab MM:S 1.12-dev carries the Linux x86_64 SourceHook work (srcdslab/metamod-source#4)
|
||||||
|
# that the x86_64 DHooks needs (x64JitWriter::leave). checkout-deps.sh keeps an existing
|
||||||
|
# mmsource-1.12 folder and pulls from its own origin, so it stays on this repository.
|
||||||
|
MMSOURCE_REPO: https://github.com/srcdslab/metamod-source
|
||||||
|
MMSOURCE_BRANCH: 1.12-dev
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: linux
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ghcr.io/alliedmodders/build-containers/debian11-clang22:latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout SourceMod
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
path: sourcemod
|
||||||
|
fetch-depth: 0
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
mkdir -p "$GITHUB_WORKSPACE/dependencies"
|
||||||
|
cd "$GITHUB_WORKSPACE/dependencies"
|
||||||
|
# Satisfy checkout-deps requirement for a "sourcemod" folder.
|
||||||
|
mkdir -p sourcemod
|
||||||
|
git clone --recursive -b "$MMSOURCE_BRANCH" "$MMSOURCE_REPO" mmsource-1.12
|
||||||
|
../sourcemod/tools/checkout-deps.sh -s "$SDKS"
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
working-directory: sourcemod
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
deps="$GITHUB_WORKSPACE/dependencies"
|
||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
python3 ../configure.py \
|
||||||
|
--enable-optimize \
|
||||||
|
--sdks="$SDKS" \
|
||||||
|
--targets="$ARCH" \
|
||||||
|
--mms-path="$deps/mmsource-1.12" \
|
||||||
|
--hl2sdk-root="$deps" \
|
||||||
|
--mariadb-path="$deps/mariadb-connector-c-$MARIADB_CONNECTOR_C_VERSION-x86" \
|
||||||
|
--mariadb64-path="$deps/mariadb-connector-c-$MARIADB_CONNECTOR_C_VERSION-x86_64"
|
||||||
|
ambuild
|
||||||
|
|
||||||
|
- name: Package
|
||||||
|
id: package
|
||||||
|
working-directory: sourcemod/build/package
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
version_base=$(cat ../../product.version)
|
||||||
|
version_base=${version_base%-dev}
|
||||||
|
version_rev=$(git rev-list --count HEAD)
|
||||||
|
version="${version_base}.${version_rev}"
|
||||||
|
filename="sourcemod-${version_base}-git${version_rev}-srcdslab-linux.tar.gz"
|
||||||
|
# Fail early if the x86_64 DHooks or BinTools did not build.
|
||||||
|
for ext in dhooks bintools; do
|
||||||
|
test -f "addons/sourcemod/extensions/x64/$ext.ext.so"
|
||||||
|
done
|
||||||
|
tar zcf "$filename" addons cfg
|
||||||
|
echo "version=$version" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "filename=$filename" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Upload package
|
||||||
|
uses: actions/upload-artifact@v7
|
||||||
|
with:
|
||||||
|
name: sourcemod-${{ steps.package.outputs.version }}-linux
|
||||||
|
path: sourcemod/build/package/${{ steps.package.outputs.filename }}
|
||||||
|
|
||||||
|
- name: Create release
|
||||||
|
if: github.event_name == 'push'
|
||||||
|
uses: ncipollo/[email protected]
|
||||||
|
with:
|
||||||
|
allowUpdates: true
|
||||||
|
replacesArtifacts: true
|
||||||
|
artifacts: sourcemod/build/package/${{ steps.package.outputs.filename }}
|
||||||
|
artifactContentType: application/gzip
|
||||||
|
artifactErrorsFailBuild: true
|
||||||
|
tag: ${{ steps.package.outputs.version }}-srcdslab
|
||||||
|
name: SourceMod ${{ steps.package.outputs.version }} (srcdslab ${{ github.ref_name }})
|
||||||
|
body: |
|
||||||
|
SourceMod built from the srcdslab `${{ github.ref_name }}` branch: upstream SourceMod plus the srcdslab x86_64 DHooks and BinTools fixes, against srcdslab/metamod-source `${{ env.MMSOURCE_BRANCH }}`.
|
||||||
|
CS:S only, Linux x86 and x86_64. No GeoLite2 database is included.
|
||||||
|
commit: ${{ github.sha }}
|
||||||
|
makeLatest: true
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
name: Update translation project
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
paths:
|
||||||
|
- 'translations/**'
|
||||||
|
workflow_dispatch:
|
||||||
|
jobs:
|
||||||
|
update_translations:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
with:
|
||||||
|
submodules: recursive
|
||||||
|
|
||||||
|
- uses: actions/setup-python@v7
|
||||||
|
name: Setup Python 3.10
|
||||||
|
with:
|
||||||
|
python-version: "3.10"
|
||||||
|
|
||||||
|
- name: Install Python dependencies
|
||||||
|
working-directory: tools/language_check
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade -r requirements.txt
|
||||||
|
|
||||||
|
- name: Generate token
|
||||||
|
id: generate_token
|
||||||
|
uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a
|
||||||
|
with:
|
||||||
|
app_id: ${{ secrets.APP_ID }}
|
||||||
|
private_key: ${{ secrets.APP_PEM }}
|
||||||
|
|
||||||
|
- name: Update translation project
|
||||||
|
working-directory: tools/language_check
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||||
|
ORGANIZATION: alliedmodders
|
||||||
|
PROJECT_NUMBER: 1
|
||||||
|
run: |
|
||||||
|
python ./compare_translation_phrases.py
|
||||||
|
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
name: Sanity check translation phrases
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
paths:
|
||||||
|
- 'translations/**'
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
paths:
|
||||||
|
- 'translations/**'
|
||||||
|
workflow_dispatch:
|
||||||
|
jobs:
|
||||||
|
check_translations:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
|
- uses: actions/setup-python@v7
|
||||||
|
name: Setup Python 3.10
|
||||||
|
with:
|
||||||
|
python-version: "3.10"
|
||||||
|
|
||||||
|
- name: Check translation phrases syntax
|
||||||
|
working-directory: tools/language_check
|
||||||
|
run: |
|
||||||
|
python ./sanity_check.py
|
||||||
|
|
||||||
+7
-1
@@ -28,10 +28,16 @@ LIB-Debug/
|
|||||||
[Tt]humbs.db
|
[Tt]humbs.db
|
||||||
|
|
||||||
# AMBuild build directories
|
# AMBuild build directories
|
||||||
build/
|
|
||||||
obj-*/
|
obj-*/
|
||||||
*~
|
*~
|
||||||
*.rej
|
*.rej
|
||||||
*.orig
|
*.orig
|
||||||
*.smx
|
*.smx
|
||||||
*.swp
|
*.swp
|
||||||
|
*.gdb_history
|
||||||
|
objdir
|
||||||
|
# Not standardized, but common name for build directories
|
||||||
|
/build*/
|
||||||
|
|
||||||
|
.vs/*
|
||||||
|
.vscode/*
|
||||||
|
|||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
[submodule "public/amtl"]
|
||||||
|
path = public/amtl
|
||||||
|
url = https://github.com/alliedmodders/amtl
|
||||||
|
shallow = true
|
||||||
|
[submodule "sourcepawn"]
|
||||||
|
path = sourcepawn
|
||||||
|
url = https://github.com/alliedmodders/sourcepawn
|
||||||
|
shallow = true
|
||||||
|
[submodule "hl2sdk-manifests"]
|
||||||
|
path = hl2sdk-manifests
|
||||||
|
url = https://github.com/alliedmodders/hl2sdk-manifests.git
|
||||||
|
[submodule "public/safetyhook"]
|
||||||
|
path = public/safetyhook
|
||||||
|
url = https://github.com/alliedmodders/safetyhook
|
||||||
+82
-7
@@ -1,11 +1,86 @@
|
|||||||
|
git:
|
||||||
|
depth: 3
|
||||||
|
|
||||||
language: cpp
|
language: cpp
|
||||||
compiler:
|
os: linux
|
||||||
- clang
|
dist: xenial
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
fast_finish: true
|
||||||
|
include:
|
||||||
|
- os: linux
|
||||||
|
dist: trusty
|
||||||
|
language: cpp
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
packages: ['clang-3.8', 'lib32stdc++6', 'lib32z1-dev', 'libc6-dev-i386', 'linux-libc-dev:i386', 'g++-4.9-multilib', 'python3-pip']
|
||||||
|
env:
|
||||||
|
- MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8"
|
||||||
|
- SDKS=episode1,css,tf2,l4d2,csgo
|
||||||
|
- MODE=optimize
|
||||||
|
- ARCH=x86,x86_64
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
dist: trusty
|
||||||
|
language: cpp
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
sources:
|
||||||
|
- ubuntu-toolchain-r-test
|
||||||
|
packages: ['clang-3.4', 'lib32stdc++6', 'lib32z1-dev', 'libc6-dev-i386', 'linux-libc-dev:i386', 'g++-4.9-multilib', 'python3-pip']
|
||||||
|
env:
|
||||||
|
- MATRIX_EVAL="CC=clang && CXX=clang++"
|
||||||
|
- SDKS=episode1,css,tf2,l4d2,csgo
|
||||||
|
- MODE=optimize
|
||||||
|
- ARCH=x86,x86_64
|
||||||
|
|
||||||
|
- os: osx
|
||||||
|
osx_image: xcode7.2
|
||||||
|
language: cpp
|
||||||
|
env:
|
||||||
|
- MATRIX_EVAL="CC=clang && CXX=clang++"
|
||||||
|
- SDKS=episode1,css,tf2,l4d2,csgo
|
||||||
|
- MODE=optimize
|
||||||
|
- ARCH=x86_64,x86
|
||||||
|
|
||||||
|
# # This is a faster test for the latest g++.
|
||||||
|
# - os: linux
|
||||||
|
# dist: bionic
|
||||||
|
# sudo: false
|
||||||
|
# language: cpp
|
||||||
|
# addons:
|
||||||
|
# apt:
|
||||||
|
# packages: ['lib32stdc++6', 'lib32z1-dev', 'libc6-dev-i386', 'linux-libc-dev:i386', 'g++-multilib', 'g++']
|
||||||
|
# cache:
|
||||||
|
# directories: ['../mysql-5.0']
|
||||||
|
# env:
|
||||||
|
# - MATRIX_EVAL="CC=gcc && CXX=g++"
|
||||||
|
# - SDKS=csgo
|
||||||
|
# # GCC currently fails in opt builds trying to inline stuff in sqlite3.c.
|
||||||
|
# - MODE=debug
|
||||||
|
|
||||||
|
# This is a faster test for the latest clang.
|
||||||
|
- os: linux
|
||||||
|
dist: bionic
|
||||||
|
language: cpp
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages: ['lib32stdc++6', 'lib32z1-dev', 'libc6-dev-i386', 'linux-libc-dev:i386', 'g++-multilib', 'clang']
|
||||||
|
env:
|
||||||
|
- MATRIX_EVAL="CC=clang && CXX=clang++"
|
||||||
|
- SDKS=csgo
|
||||||
|
- MODE=optimize
|
||||||
|
- ARCH=x86
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- sudo apt-get update -qq
|
- CHECKOUT_DIR=$PWD && cd .. && $CHECKOUT_DIR/tools/checkout-deps.sh -s ${SDKS} && cd $CHECKOUT_DIR
|
||||||
- sudo apt-get install -y g++-multilib libc6-dev-i386 lib32stdc++6 lib32z1-dev
|
|
||||||
- CHECKOUT_DIR=$PWD && cd .. && $CHECKOUT_DIR/tools/checkout-deps.sh && cd $CHECKOUT_DIR
|
|
||||||
script:
|
script:
|
||||||
- mkdir build && cd build
|
- mkdir build && cd build
|
||||||
- python ../configure.py --enable-optimize --sdks=episode1,tf2,l4d2,csgo,dota
|
- PATH="~/.local/bin:$PATH"
|
||||||
- ambuild
|
- eval "${MATRIX_EVAL}"
|
||||||
|
- eval "${CC} --version"
|
||||||
|
- eval "${CXX} --version"
|
||||||
|
- python3 ../configure.py --enable-${MODE} --sdks=${SDKS} --targets=${ARCH}
|
||||||
|
- ambuild
|
||||||
|
|||||||
+578
-372
File diff suppressed because it is too large
Load Diff
@@ -6,12 +6,23 @@ General
|
|||||||
- [SourceMod website](http://www.sourcemod.net): Source Engine scripting and server administration
|
- [SourceMod website](http://www.sourcemod.net): Source Engine scripting and server administration
|
||||||
- [Forum](https://forums.alliedmods.net/forumdisplay.php?f=52): Discussion forum including plugin/extension development
|
- [Forum](https://forums.alliedmods.net/forumdisplay.php?f=52): Discussion forum including plugin/extension development
|
||||||
- [General documentation](https://wiki.alliedmods.net/Category:SourceMod_Documentation): Miscellaneous information about SourceMod
|
- [General documentation](https://wiki.alliedmods.net/Category:SourceMod_Documentation): Miscellaneous information about SourceMod
|
||||||
- [Latest release](http://www.sourcemod.net/downloads.php): The latest stable SourceMod release
|
- [Stable builds](http://www.sourcemod.net/downloads.php?branch=stable): The latest stable SourceMod releases
|
||||||
- [Build snapshots](http://www.sourcemod.net/snapshots.php): Builds of recent development versions
|
- [Dev builds](http://www.sourcemod.net/downloads.php?branch=dev): Builds of recent development versions
|
||||||
|
|
||||||
Development
|
Development
|
||||||
-----------
|
-----------
|
||||||
- [Issue tracker](https://bugs.alliedmods.net): Issues that require back and forth communication
|
- [Issue tracker](https://github.com/alliedmodders/sourcemod/issues): Issues that require back and forth communication
|
||||||
- [Building SourceMod](https://wiki.alliedmods.net/Building_SourceMod): Instructions on how to build SourceMod itself using [AMBuild](https://github.com/alliedmodders/ambuild)
|
- [Building SourceMod](https://wiki.alliedmods.net/Building_SourceMod): Instructions on how to build SourceMod itself using [AMBuild](https://github.com/alliedmodders/ambuild)
|
||||||
- [SourcePawn scripting](https://wiki.alliedmods.net/Category:SourceMod_Scripting): SourcePawn examples and introduction to the language
|
- [SourcePawn scripting](https://wiki.alliedmods.net/Category:SourceMod_Scripting): SourcePawn examples and introduction to the language
|
||||||
|
- [SourceMod plugin API](https://sm.alliedmods.net/new-api): Online SourceMod plugin API reference generated from the include files
|
||||||
- [SourceMod extension development](https://wiki.alliedmods.net/Category:SourceMod_Development): C++ examples and introduction to various extension interfaces
|
- [SourceMod extension development](https://wiki.alliedmods.net/Category:SourceMod_Development): C++ examples and introduction to various extension interfaces
|
||||||
|
- [Translation project](https://github.com/orgs/alliedmodders/projects/1): Help [translate SourceMod](https://wiki.alliedmods.net/Translations_(SourceMod_Scripting)) into your language
|
||||||
|
|
||||||
|
Contact
|
||||||
|
-------
|
||||||
|
- Connect with us on [GameSurge](https://gamesurge.net) IRC in #sourcemod
|
||||||
|
- Alternatively feel free to join our [Discord](https://discord.gg/HgZctSS) server
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
SourceMod is licensed under the GNU General Public License version 3. Special exceptions are outlined in the LICENSE.txt file inside of the licenses folder.
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
version: 1.0.{build}
|
||||||
|
image: Visual Studio 2015
|
||||||
|
clone_folder: c:/projects/sourcemod
|
||||||
|
clone_depth: 1
|
||||||
|
install:
|
||||||
|
- cmd: set PATH=C:\Python38;C:\Python38\Scripts;%PATH%
|
||||||
|
- cmd: git submodule update --init --recursive
|
||||||
|
- cmd: git pull --recurse-submodules
|
||||||
|
- cmd: cd ..
|
||||||
|
- ps: sourcemod/tools/checkout-deps.ps1 -SDKs episode1,css,tf2,l4d2,csgo
|
||||||
|
- cmd: cd sourcemod
|
||||||
|
build_script:
|
||||||
|
- cmd: call "%VS140COMNTOOLS%/vsvars32.bat"
|
||||||
|
- cmd: mkdir build
|
||||||
|
- cmd: cd build
|
||||||
|
- cmd: python.exe ../configure.py --enable-optimize --no-mysql --sdks=episode1,css,tf2,l4d2,csgo
|
||||||
|
- cmd: ambuild
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
// vim: set ts=4 sw=4 tw=99 noet:
|
||||||
|
// =============================================================================
|
||||||
|
// SourceMod
|
||||||
|
// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved.
|
||||||
|
// =============================================================================
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
// Free Software Foundation.
|
||||||
|
//
|
||||||
|
// 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
// code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
// by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
// all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
// this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
// or <http://www.sourcemod.net/license.php>.
|
||||||
|
#ifndef _INCLUDE_SOURCEMOD_BRIDGE_API_H_
|
||||||
|
#define _INCLUDE_SOURCEMOD_BRIDGE_API_H_
|
||||||
|
|
||||||
|
#include <bridge/include/CoreProvider.h>
|
||||||
|
#include <bridge/include/LogicProvider.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
namespace SourceMod {
|
||||||
|
|
||||||
|
// Add 1 to the RHS of this expression to bump the intercom file
|
||||||
|
// This is to prevent mismatching core/logic binaries
|
||||||
|
static const uint32_t SM_LOGIC_MAGIC = 0x0F47C0DE - 58;
|
||||||
|
|
||||||
|
} // namespace SourceMod
|
||||||
|
|
||||||
|
typedef void (*LogicInitFunction)(SourceMod::CoreProvider *core, SourceMod::sm_logic_t *logic);
|
||||||
|
typedef LogicInitFunction (*LogicLoadFunction)(uint32_t magic);
|
||||||
|
typedef SourceMod::ITextParsers *(*GetITextParsers)();
|
||||||
|
|
||||||
|
#endif // _INCLUDE_SOURCEMOD_BRIDGE_API_H_
|
||||||
@@ -0,0 +1,135 @@
|
|||||||
|
// vim: set ts=4 sw=4 tw=99 noet:
|
||||||
|
// =============================================================================
|
||||||
|
// SourceMod
|
||||||
|
// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved.
|
||||||
|
// =============================================================================
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
// Free Software Foundation.
|
||||||
|
//
|
||||||
|
// 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
// code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
// by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
// all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
// this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
// or <http://www.sourcemod.net/license.php>.
|
||||||
|
#ifndef _INCLUDE_SOURCEMOD_CORE_PROVIDER_API_H_
|
||||||
|
#define _INCLUDE_SOURCEMOD_CORE_PROVIDER_API_H_
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <IAdminSystem.h>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
// SDK types.
|
||||||
|
#if defined(SM_LOGIC)
|
||||||
|
class ConCommandBase {};
|
||||||
|
class ConVar : public ConCommandBase {};
|
||||||
|
#else
|
||||||
|
class ConCommandBase;
|
||||||
|
class ConVar;
|
||||||
|
#endif
|
||||||
|
class KeyValues;
|
||||||
|
|
||||||
|
struct ServerGlobals
|
||||||
|
{
|
||||||
|
const double *universalTime;
|
||||||
|
float *interval_per_tick;
|
||||||
|
float *frametime;
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace SourceMod {
|
||||||
|
|
||||||
|
class ISourceMod;
|
||||||
|
class IVEngineServerBridge;
|
||||||
|
class IFileSystemBridge;
|
||||||
|
class ITimerSystem;
|
||||||
|
class IPlayerManager;
|
||||||
|
class IGameHelpers;
|
||||||
|
class IMenuManager;
|
||||||
|
struct DatabaseInfo;
|
||||||
|
class IPlayerInfoBridge;
|
||||||
|
class ICommandArgs;
|
||||||
|
|
||||||
|
typedef std::function<bool(int client, const ICommandArgs*)> CommandFunc;
|
||||||
|
|
||||||
|
class CoreProvider
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/* Objects */
|
||||||
|
ISourceMod *sm;
|
||||||
|
IVEngineServerBridge *engine;
|
||||||
|
IFileSystemBridge *filesystem;
|
||||||
|
IPlayerInfoBridge *playerInfo;
|
||||||
|
ITimerSystem *timersys;
|
||||||
|
IPlayerManager *playerhelpers;
|
||||||
|
IGameHelpers *gamehelpers;
|
||||||
|
IMenuManager *menus;
|
||||||
|
SourcePawn::ISourcePawnEngine **spe1;
|
||||||
|
SourcePawn::ISourcePawnEngine2 **spe2;
|
||||||
|
SourcePawn::ISourcePawnEnvironment **spe_env;
|
||||||
|
const char *gamesuffix;
|
||||||
|
/* Data */
|
||||||
|
ServerGlobals *serverGlobals;
|
||||||
|
SMGlobalClass * listeners;
|
||||||
|
|
||||||
|
// ConVar functions.
|
||||||
|
virtual ConVar *FindConVar(const char *name) = 0;
|
||||||
|
virtual const char *GetCvarString(ConVar *cvar) = 0;
|
||||||
|
virtual bool GetCvarBool(ConVar* cvar) = 0;
|
||||||
|
|
||||||
|
// Command functions.
|
||||||
|
virtual void DefineCommand(const char *cmd, const char *help, const CommandFunc &callback) = 0;
|
||||||
|
|
||||||
|
// Game description functions.
|
||||||
|
virtual bool GetGameName(char *buffer, size_t maxlength) = 0;
|
||||||
|
virtual const char *GetGameDescription() = 0;
|
||||||
|
virtual const char *GetSourceEngineName() = 0;
|
||||||
|
virtual bool SymbolsAreHidden() = 0;
|
||||||
|
|
||||||
|
// Game state and helper functions.
|
||||||
|
virtual bool IsMapLoading() = 0;
|
||||||
|
virtual bool IsMapRunning() = 0;
|
||||||
|
virtual int MaxClients() = 0;
|
||||||
|
virtual bool DescribePlayer(int entRef, const char **namep, const char **authp, int *useridp) = 0;
|
||||||
|
virtual void LogToGame(const char *message) = 0;
|
||||||
|
virtual void ConPrint(const char *message) = 0;
|
||||||
|
virtual void ConsolePrint(const char *fmt, ...) = 0;
|
||||||
|
virtual void ConsolePrintVa(const char *fmt, va_list ap) = 0;
|
||||||
|
|
||||||
|
virtual void FormatSourceBinaryName(const char *basename, char *buffer, size_t maxlength) = 0;
|
||||||
|
|
||||||
|
// Game engine helper functions.
|
||||||
|
virtual bool IsClientConVarQueryingSupported() = 0;
|
||||||
|
virtual int QueryClientConVar(int client, const char *cvar) = 0;
|
||||||
|
|
||||||
|
// Metamod:Source functions.
|
||||||
|
virtual int LoadMMSPlugin(const char *file, bool *ok, char *error, size_t maxlength) = 0;
|
||||||
|
virtual void UnloadMMSPlugin(int id) = 0;
|
||||||
|
|
||||||
|
const char * (*GetCoreConfigValue)(const char*);
|
||||||
|
void (*DoGlobalPluginLoads)();
|
||||||
|
bool (*AreConfigsExecuted)();
|
||||||
|
void (*ExecuteConfigs)(IPluginContext *ctx);
|
||||||
|
void (*GetDBInfoFromKeyValues)(KeyValues *, DatabaseInfo *);
|
||||||
|
int (*GetActivityFlags)();
|
||||||
|
int (*GetImmunityMode)();
|
||||||
|
void (*UpdateAdminCmdFlags)(const char *cmd, OverrideType type, FlagBits bits, bool remove);
|
||||||
|
bool (*LookForCommandAdminFlags)(const char *cmd, FlagBits *pFlags);
|
||||||
|
int (*GetGlobalTarget)();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace SourceMod
|
||||||
|
|
||||||
|
#endif // _INCLUDE_SOURCEMOD_CORE_PROVIDER_API_H_
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
// vim: set ts=4 sw=4 tw=99 noet:
|
||||||
|
// =============================================================================
|
||||||
|
// SourceMod
|
||||||
|
// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved.
|
||||||
|
// =============================================================================
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
// Free Software Foundation.
|
||||||
|
//
|
||||||
|
// 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
// code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
// by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
// all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
// this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
// or <http://www.sourcemod.net/license.php>.
|
||||||
|
#ifndef _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_IEXTBRIDGE_H_
|
||||||
|
#define _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_IEXTBRIDGE_H_
|
||||||
|
|
||||||
|
#include <sp_vm_api.h>
|
||||||
|
#include <IExtensionSys.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
struct edict_t;
|
||||||
|
|
||||||
|
namespace SourceMod {
|
||||||
|
|
||||||
|
using namespace SourcePawn;
|
||||||
|
class SMPlugin;
|
||||||
|
|
||||||
|
class IExtensionSys : public IExtensionManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual IExtension *LoadAutoExtension(const char *name, bool bErrorOnMissing=true) = 0;
|
||||||
|
virtual void TryAutoload() = 0;
|
||||||
|
virtual void Shutdown() = 0;
|
||||||
|
virtual IExtension *FindExtensionByFile(const char *name) = 0;
|
||||||
|
virtual bool LibraryExists(const char *name) = 0;
|
||||||
|
virtual void CallOnCoreMapStart(edict_t *edictList, int edictCount, int maxClients) = 0;
|
||||||
|
virtual IExtension *GetExtensionFromIdent(IdentityToken_t *token) = 0;
|
||||||
|
virtual void BindChildPlugin(IExtension *ext, SMPlugin *plugin) = 0;
|
||||||
|
virtual void AddRawDependency(IExtension *myself, IdentityToken_t *token, void *iface) = 0;
|
||||||
|
virtual const std::vector<IExtension *> *ListExtensions() = 0;
|
||||||
|
virtual void FreeExtensionList(const std::vector<IExtension *> *list) = 0;
|
||||||
|
virtual void CallOnCoreMapEnd() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AutoExtensionList
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AutoExtensionList(IExtensionSys *extensions)
|
||||||
|
: extensions_(extensions), list_(extensions_->ListExtensions())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
~AutoExtensionList()
|
||||||
|
{
|
||||||
|
extensions_->FreeExtensionList(list_);
|
||||||
|
}
|
||||||
|
const std::vector<IExtension *> *operator ->()
|
||||||
|
{
|
||||||
|
return list_;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
IExtensionSys *extensions_;
|
||||||
|
const std::vector<IExtension *> *list_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace SourceMod
|
||||||
|
|
||||||
|
#endif // _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_IEXTBRIDGE_H_
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
// vim: set ts=4 sw=4 tw=99 noet:
|
||||||
|
// =============================================================================
|
||||||
|
// SourceMod
|
||||||
|
// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved.
|
||||||
|
// =============================================================================
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
// Free Software Foundation.
|
||||||
|
//
|
||||||
|
// 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
// code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
// by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
// all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
// this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
// or <http://www.sourcemod.net/license.php>.
|
||||||
|
#ifndef _INCLUDE_SOURCEMOD_BRIDGE_IFILESYSTEM_H_
|
||||||
|
#define _INCLUDE_SOURCEMOD_BRIDGE_IFILESYSTEM_H_
|
||||||
|
|
||||||
|
typedef void * FileHandle_t;
|
||||||
|
typedef int FileFindHandle_t;
|
||||||
|
|
||||||
|
namespace SourceMod {
|
||||||
|
|
||||||
|
typedef void *AsyncControl_t;
|
||||||
|
|
||||||
|
enum AsyncStatus
|
||||||
|
{
|
||||||
|
AsyncStatus_FileOpenError = -1,
|
||||||
|
AsyncStatus_Ok = 0,
|
||||||
|
AsyncStatus_Pending,
|
||||||
|
AsyncStatus_InProgress,
|
||||||
|
AsyncStatus_Aborted,
|
||||||
|
AsyncStatus_Unserviced,
|
||||||
|
};
|
||||||
|
|
||||||
|
class IFileSystemBridge
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual const char *FindFirstEx(const char *pWildCard, const char *pPathID, FileFindHandle_t *pHandle) = 0;
|
||||||
|
virtual const char *FindNext(FileFindHandle_t handle) = 0;
|
||||||
|
virtual bool FindIsDirectory(FileFindHandle_t handle) = 0;
|
||||||
|
virtual void FindClose(FileFindHandle_t handle) = 0;
|
||||||
|
virtual FileHandle_t Open(const char *pFileName, const char *pOptions, const char *pathID = 0) = 0;
|
||||||
|
virtual void Close(FileHandle_t file) = 0;
|
||||||
|
virtual char *ReadLine(char *pOutput, int maxChars, FileHandle_t file) = 0;
|
||||||
|
virtual bool EndOfFile(FileHandle_t file) = 0;
|
||||||
|
virtual bool FileExists(const char *pFileName, const char *pPathID = 0) = 0;
|
||||||
|
virtual unsigned int Size(FileHandle_t file) = 0;
|
||||||
|
virtual unsigned int Size(const char *pFileName, const char *pPathID = 0) = 0;
|
||||||
|
virtual int Read(void* pOutput, int size, FileHandle_t file) = 0;
|
||||||
|
virtual int Write(void const* pInput, int size, FileHandle_t file) = 0;
|
||||||
|
virtual void Seek(FileHandle_t file, int post, int seekType) = 0;
|
||||||
|
virtual unsigned int Tell(FileHandle_t file) = 0;
|
||||||
|
virtual int FPrint(FileHandle_t file, const char *pData) = 0;
|
||||||
|
virtual void Flush(FileHandle_t file) = 0;
|
||||||
|
virtual bool IsOk(FileHandle_t file) = 0;
|
||||||
|
virtual void RemoveFile(const char *pRelativePath, const char *pathID = 0) = 0;
|
||||||
|
virtual void RenameFile(char const *pOldPath, char const *pNewPath, const char *pathID = 0) = 0;
|
||||||
|
virtual bool IsDirectory(const char *pFileName, const char *pathID = 0) = 0;
|
||||||
|
virtual void CreateDirHierarchy(const char *path, const char *pathID = 0) = 0;
|
||||||
|
virtual int GetSearchPath(const char* pathID, bool bGetPackFiles, char* pPath, int nMaxLen) = 0;
|
||||||
|
virtual const char * GetGameBinArchSubdirectory() = 0;
|
||||||
|
virtual bool SupportsAsync() = 0;
|
||||||
|
virtual int AsyncRead(const char *filename, const char *pathID, AsyncControl_t *control) = 0;
|
||||||
|
virtual int AsyncWrite(const char *filename, const void *data, int size, bool append,
|
||||||
|
AsyncControl_t *control) = 0;
|
||||||
|
virtual int AsyncStatus(AsyncControl_t control) = 0;
|
||||||
|
virtual int AsyncGetResult(AsyncControl_t control, void **data, int *size) = 0;
|
||||||
|
virtual void AsyncAbort(AsyncControl_t control) = 0;
|
||||||
|
virtual void AsyncRelease(AsyncControl_t control) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace SourceMod
|
||||||
|
|
||||||
|
#endif // _INCLUDE_SOURCEMOD_BRIDGE_IFILESYSTEM_H_
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
// vim: set ts=4 sw=4 tw=99 noet:
|
||||||
|
// =============================================================================
|
||||||
|
// SourceMod
|
||||||
|
// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved.
|
||||||
|
// =============================================================================
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
// Free Software Foundation.
|
||||||
|
//
|
||||||
|
// 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
// code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
// by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
// all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
// this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
// or <http://www.sourcemod.net/license.php>.
|
||||||
|
#ifndef _INCLUDE_SOURCEMOD_BRIDGE_LOGGER_H_
|
||||||
|
#define _INCLUDE_SOURCEMOD_BRIDGE_LOGGER_H_
|
||||||
|
|
||||||
|
namespace SourceMod {
|
||||||
|
|
||||||
|
class ILogger
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void LogMessage(const char *msg, ...) = 0;
|
||||||
|
virtual void LogError(const char *msg, ...) = 0;
|
||||||
|
virtual void LogFatal(const char *msg, ...) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace SourceMod
|
||||||
|
|
||||||
|
#endif // _INCLUDE_SOURCEMOD_BRIDGE_LOGGER_H_
|
||||||
|
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// vim: set ts=4 sw=4 tw=99 noet:
|
||||||
|
// =============================================================================
|
||||||
|
// SourceMod
|
||||||
|
// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved.
|
||||||
|
// =============================================================================
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
// Free Software Foundation.
|
||||||
|
//
|
||||||
|
// 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
// code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
// by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
// all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
// this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
// or <http://www.sourcemod.net/license.php>.
|
||||||
|
#ifndef _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_IPLAYERINFO_H_
|
||||||
|
#define _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_IPLAYERINFO_H_
|
||||||
|
|
||||||
|
class IPlayerInfo;
|
||||||
|
|
||||||
|
namespace SourceMod {
|
||||||
|
|
||||||
|
class IPlayerInfoBridge
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual bool IsObserver(IPlayerInfo *pInfo) = 0;
|
||||||
|
virtual int GetTeamIndex(IPlayerInfo *pInfo) = 0;
|
||||||
|
virtual int GetFragCount(IPlayerInfo *pInfo) = 0;
|
||||||
|
virtual int GetDeathCount(IPlayerInfo *pInfo) = 0;
|
||||||
|
virtual int GetArmorValue(IPlayerInfo *pInfo) = 0;
|
||||||
|
virtual void GetAbsOrigin(IPlayerInfo *pInfo, float *x, float *y, float *z) = 0;
|
||||||
|
virtual void GetAbsAngles(IPlayerInfo *pInfo, float *x, float *y, float *z) = 0;
|
||||||
|
virtual void GetPlayerMins(IPlayerInfo *pInfo, float *x, float *y, float *z) = 0;
|
||||||
|
virtual void GetPlayerMaxs(IPlayerInfo *pInfo, float *x, float *y, float *z) = 0;
|
||||||
|
virtual const char *GetWeaponName(IPlayerInfo *pInfo) = 0;
|
||||||
|
virtual const char *GetModelName(IPlayerInfo *pInfo) = 0;
|
||||||
|
virtual int GetHealth(IPlayerInfo *pInfo) = 0;
|
||||||
|
virtual void ChangeTeam(IPlayerInfo *pInfo, int iTeamNum) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace SourceMod
|
||||||
|
|
||||||
|
#endif // _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_IPLAYERINFO_H_
|
||||||
|
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
// vim: set ts=4 sw=4 tw=99 noet:
|
||||||
|
// =============================================================================
|
||||||
|
// SourceMod
|
||||||
|
// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved.
|
||||||
|
// =============================================================================
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
// Free Software Foundation.
|
||||||
|
//
|
||||||
|
// 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
// code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
// by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
// all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
// this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
// or <http://www.sourcemod.net/license.php>.
|
||||||
|
#ifndef _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_IPROVIDERCALLBACK_H_
|
||||||
|
#define _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_IPROVIDERCALLBACK_H_
|
||||||
|
|
||||||
|
namespace SourceMod {
|
||||||
|
|
||||||
|
// Global callbacks provided to Core.
|
||||||
|
class IProviderCallbacks
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// Called when a log message is printed. Return true to supercede.
|
||||||
|
virtual bool OnLogPrint(const char *msg) = 0;
|
||||||
|
|
||||||
|
// Called each frame tick.
|
||||||
|
virtual void OnThink(bool simulating) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace SourceMod
|
||||||
|
|
||||||
|
#endif // _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_IPROVIDERCALLBACK_H_
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
// vim: set ts=4 sw=4 tw=99 noet:
|
||||||
|
// =============================================================================
|
||||||
|
// SourceMod
|
||||||
|
// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved.
|
||||||
|
// =============================================================================
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
// Free Software Foundation.
|
||||||
|
//
|
||||||
|
// 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
// code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
// by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
// all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
// this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
// or <http://www.sourcemod.net/license.php>.
|
||||||
|
#ifndef _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_ISCRIPTMANAGER_H_
|
||||||
|
#define _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_ISCRIPTMANAGER_H_
|
||||||
|
|
||||||
|
#include <sp_vm_api.h>
|
||||||
|
#include <IPluginSys.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace SourceMod {
|
||||||
|
|
||||||
|
using namespace SourcePawn;
|
||||||
|
|
||||||
|
class IChangeableForward;
|
||||||
|
|
||||||
|
enum LibraryAction
|
||||||
|
{
|
||||||
|
LibraryAction_Removed,
|
||||||
|
LibraryAction_Added
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AutoConfig
|
||||||
|
{
|
||||||
|
std::string autocfg;
|
||||||
|
std::string folder;
|
||||||
|
bool create;
|
||||||
|
};
|
||||||
|
|
||||||
|
class SMPlugin : public IPlugin
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual size_t GetConfigCount() = 0;
|
||||||
|
virtual AutoConfig *GetConfig(size_t i) = 0;
|
||||||
|
virtual void AddLibrary(const char *name) = 0;
|
||||||
|
virtual void AddConfig(bool create, const char *cfg, const char *folder) = 0;
|
||||||
|
virtual void EvictWithError(PluginStatus status, const char *fmt, ...) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IScriptManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void LoadAll(const char *config_path, const char *plugins_path) = 0;
|
||||||
|
virtual void RefreshAll() = 0;
|
||||||
|
virtual void Shutdown() = 0;
|
||||||
|
virtual IdentityToken_t *GetIdentity() = 0;
|
||||||
|
virtual void SyncMaxClients(int maxClients) = 0;
|
||||||
|
virtual void AddPluginsListener(IPluginsListener *listener) = 0;
|
||||||
|
virtual void RemovePluginsListener(IPluginsListener *listener) = 0;
|
||||||
|
virtual IPluginIterator *GetPluginIterator() = 0;
|
||||||
|
virtual void OnLibraryAction(const char *name, LibraryAction action) = 0;
|
||||||
|
virtual bool LibraryExists(const char *name) = 0;
|
||||||
|
virtual SMPlugin *FindPluginByOrder(unsigned num) = 0;
|
||||||
|
virtual SMPlugin *FindPluginByIdentity(IdentityToken_t *ident) = 0;
|
||||||
|
virtual SMPlugin *FindPluginByContext(IPluginContext *ctx) = 0;
|
||||||
|
virtual SMPlugin *FindPluginByConsoleArg(const char *text) = 0;
|
||||||
|
virtual SMPlugin *FindPluginByHandle(Handle_t hndl, HandleError *errp) = 0;
|
||||||
|
virtual bool UnloadPlugin(IPlugin *plugin) = 0;
|
||||||
|
virtual const std::vector<SMPlugin *> *ListPlugins() = 0;
|
||||||
|
virtual void FreePluginList(const std::vector<SMPlugin *> *list) = 0;
|
||||||
|
virtual void AddFunctionsToForward(const char *name, IChangeableForward *fwd) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class AutoPluginList
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AutoPluginList(IScriptManager *scripts)
|
||||||
|
: scripts_(scripts), list_(scripts->ListPlugins())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
~AutoPluginList()
|
||||||
|
{
|
||||||
|
scripts_->FreePluginList(list_);
|
||||||
|
}
|
||||||
|
const std::vector<SMPlugin *> *operator ->()
|
||||||
|
{
|
||||||
|
return list_;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
IScriptManager *scripts_;
|
||||||
|
const std::vector<SMPlugin *> *list_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace SourceMod
|
||||||
|
|
||||||
|
#endif // _INCLUDE_SOURCEMOD_BRIDGE_INCLUDE_ISCRIPTMANAGER_H_
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
// vim: set ts=4 sw=4 tw=99 noet:
|
||||||
|
// =============================================================================
|
||||||
|
// SourceMod
|
||||||
|
// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved.
|
||||||
|
// =============================================================================
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
// Free Software Foundation.
|
||||||
|
//
|
||||||
|
// 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
// code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
// by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
// all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
// this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
// or <http://www.sourcemod.net/license.php>.
|
||||||
|
#ifndef _INCLUDE_SOURCEMOD_BRIDGE_IVENGINESERVER_H_
|
||||||
|
#define _INCLUDE_SOURCEMOD_BRIDGE_IVENGINESERVER_H_
|
||||||
|
|
||||||
|
struct edict_t;
|
||||||
|
|
||||||
|
namespace SourceMod {
|
||||||
|
|
||||||
|
class IVEngineServerBridge
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual bool IsDedicatedServer() = 0;
|
||||||
|
virtual void InsertServerCommand(const char *cmd) = 0;
|
||||||
|
virtual void ServerCommand(const char *cmd) = 0;
|
||||||
|
virtual void ServerExecute() = 0;
|
||||||
|
virtual const char *GetClientConVarValue(int clientIndex, const char *name) = 0;
|
||||||
|
virtual void ClientCommand(edict_t *pEdict, const char *szCommand) = 0;
|
||||||
|
virtual void FakeClientCommand(edict_t *pEdict, const char *szCommand) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace SourceMod
|
||||||
|
|
||||||
|
#endif // _INCLUDE_SOURCEMOD_BRIDGE_IVENGINESERVER_H_
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
// vim: set ts=4 sw=4 tw=99 noet:
|
||||||
|
// =============================================================================
|
||||||
|
// SourceMod
|
||||||
|
// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved.
|
||||||
|
// =============================================================================
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
// Free Software Foundation.
|
||||||
|
//
|
||||||
|
// 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
// code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
// by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
// all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
// this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
// or <http://www.sourcemod.net/license.php>.
|
||||||
|
#ifndef _INCLUDE_SOURCEMOD_LOGIC_PROVIDER_API_H_
|
||||||
|
#define _INCLUDE_SOURCEMOD_LOGIC_PROVIDER_API_H_
|
||||||
|
|
||||||
|
#include <sp_vm_api.h>
|
||||||
|
|
||||||
|
class SMGlobalClass;
|
||||||
|
|
||||||
|
namespace SourceMod {
|
||||||
|
|
||||||
|
using namespace SourcePawn;
|
||||||
|
|
||||||
|
class CoreProvider;
|
||||||
|
class IThreader;
|
||||||
|
class ITranslator;
|
||||||
|
class IGameConfig;
|
||||||
|
class IScriptManager;
|
||||||
|
class IShareSys;
|
||||||
|
class IHandleSys;
|
||||||
|
class ICommandArgs;
|
||||||
|
class IForwardManager;
|
||||||
|
class IAdminSystem;
|
||||||
|
class IRootConsole;
|
||||||
|
class IProviderCallbacks;
|
||||||
|
class IExtensionSys;
|
||||||
|
class ITextParsers;
|
||||||
|
class ILogger;
|
||||||
|
class ICellArray;
|
||||||
|
|
||||||
|
class IEntityLumpWriter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void Reset() = 0;
|
||||||
|
virtual bool AppendEntity() = 0;
|
||||||
|
virtual bool AppendPair(const char *key, const char *value) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct sm_logic_t
|
||||||
|
{
|
||||||
|
SMGlobalClass *head;
|
||||||
|
IThreader *threader;
|
||||||
|
ITranslator *translator;
|
||||||
|
const char *(*stristr)(const char *, const char *);
|
||||||
|
size_t (*atcprintf)(char *, size_t, const char *, IPluginContext *, const cell_t *, int *);
|
||||||
|
bool (*CoreTranslate)(char *, size_t, const char *, unsigned int, size_t *, ...);
|
||||||
|
void (*AddCorePhraseFile)(const char *filename);
|
||||||
|
unsigned int (*ReplaceAll)(char*, size_t, const char *, const char *, bool);
|
||||||
|
char *(*ReplaceEx)(char *, size_t, const char *, size_t, const char *, size_t, bool);
|
||||||
|
size_t (*DecodeHexString)(unsigned char *, size_t, const char *);
|
||||||
|
IGameConfig * (*GetCoreGameConfig)();
|
||||||
|
IDebugListener *debugger;
|
||||||
|
void (*GenerateError)(IPluginContext *, cell_t, int, const char *, ...);
|
||||||
|
void (*AddNatives)(sp_nativeinfo_t *natives);
|
||||||
|
void (*RegisterProfiler)(IProfilingTool *tool);
|
||||||
|
ICellArray * (*CreateCellArray)(size_t blocksize);
|
||||||
|
void (*FreeCellArray)(ICellArray *arr);
|
||||||
|
void (*SetEntityLumpWritable)(bool writable);
|
||||||
|
bool (*ParseEntityLumpString)(const char *entityString, int &status, size_t &position);
|
||||||
|
const char * (*GetEntityLumpString)();
|
||||||
|
IEntityLumpWriter *(*GetEntityLumpWriter)();
|
||||||
|
bool (*CopyEntityLump)(IEntityLumpWriter *writer);
|
||||||
|
void (*Shutdown)();
|
||||||
|
void (*SetJitEnabled)(bool enabled);
|
||||||
|
void (*SetDebugMetadataFlags)(int flags);
|
||||||
|
IScriptManager *scripts;
|
||||||
|
IShareSys *sharesys;
|
||||||
|
IExtensionSys *extsys;
|
||||||
|
IHandleSys *handlesys;
|
||||||
|
IForwardManager *forwardsys;
|
||||||
|
IAdminSystem *adminsys;
|
||||||
|
IdentityToken_t *core_ident;
|
||||||
|
ILogger *logger;
|
||||||
|
IRootConsole *rootmenu;
|
||||||
|
IProviderCallbacks *callbacks;
|
||||||
|
float sentinel;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace SourceMod
|
||||||
|
|
||||||
|
#endif // _INCLUDE_SOURCEMOD_LOGIC_PROVIDER_API_H_
|
||||||
|
|
||||||
@@ -65,6 +65,10 @@ sm_flood_time 0.75
|
|||||||
// no reserved slot access (spectator players are selected first) is kicked to make room. Thus, the reserved
|
// no reserved slot access (spectator players are selected first) is kicked to make room. Thus, the reserved
|
||||||
// slots always remains free. The only situation where the reserved slot(s) can become properly occupied is
|
// slots always remains free. The only situation where the reserved slot(s) can become properly occupied is
|
||||||
// if the server is full with reserve slot access clients.
|
// if the server is full with reserve slot access clients.
|
||||||
|
// 2 : The same as sm_reserve_type 1 except once a certain number of admins have been reached, the reserve slot
|
||||||
|
// stops kicking people and anyone can join to fill the server. You can use this to simulate having a large
|
||||||
|
// number of reserved slots with sm_reserve_type 0 but with only need to have 1 slot unavailable when there are
|
||||||
|
// less admins connected.
|
||||||
// --
|
// --
|
||||||
// Requires: reservedslots.smx
|
// Requires: reservedslots.smx
|
||||||
// Default: 0
|
// Default: 0
|
||||||
@@ -93,7 +97,7 @@ sm_hide_slots 0
|
|||||||
// Default: 1
|
// Default: 1
|
||||||
sm_chat_mode 1
|
sm_chat_mode 1
|
||||||
|
|
||||||
// Specifies whether or not "timeleft" will automaticly be triggered every
|
// Specifies whether or not "timeleft" will automatically be triggered every
|
||||||
// x seconds. Valid values are 0 (Disabled) to 1800 seconds.
|
// x seconds. Valid values are 0 (Disabled) to 1800 seconds.
|
||||||
// --
|
// --
|
||||||
// Requires: basetriggers.smx
|
// Requires: basetriggers.smx
|
||||||
@@ -105,8 +109,8 @@ sm_timeleft_interval 0
|
|||||||
// 1 (Enabled)
|
// 1 (Enabled)
|
||||||
// --
|
// --
|
||||||
// Requires: basetriggers.smx
|
// Requires: basetriggers.smx
|
||||||
// Default: 1
|
// Default: 0
|
||||||
sm_trigger_show 1
|
sm_trigger_show 0
|
||||||
|
|
||||||
// Specifies whether or not to display vote progress to clients in the
|
// Specifies whether or not to display vote progress to clients in the
|
||||||
// "hint" box (near the bottom of the screen in most games).
|
// "hint" box (near the bottom of the screen in most games).
|
||||||
|
|||||||
+53
-22
@@ -21,6 +21,15 @@
|
|||||||
*/
|
*/
|
||||||
"LogMode" "daily"
|
"LogMode" "daily"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This option determines the time format SourceMod logging should use.
|
||||||
|
*
|
||||||
|
* "default" - Uses SourceMod's default time format. (%m/%d/%Y - %H:%M:%S)
|
||||||
|
* You can specify any time format you want. See https://cplusplus.com/reference/ctime/strftime/ for a list of format parameters.
|
||||||
|
* Example: "%d/%m/%Y - %H:%M:%S"
|
||||||
|
*/
|
||||||
|
"LogTimeFormat" "default"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Language that multilingual enabled plugins and extensions will use to print messages.
|
* Language that multilingual enabled plugins and extensions will use to print messages.
|
||||||
* Only languages listed in languages.cfg are valid.
|
* Only languages listed in languages.cfg are valid.
|
||||||
@@ -30,12 +39,12 @@
|
|||||||
"ServerLang" "en"
|
"ServerLang" "en"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String to use as the public chat trigger. Set an empty string to disable.
|
* List of characters to use for public chat triggers. Set an empty list to disable.
|
||||||
*/
|
*/
|
||||||
"PublicChatTrigger" "!"
|
"PublicChatTrigger" "!"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String to use as the silent chat trigger. Set an empty string to disable.
|
* List of characters to use for silent chat triggers. Set an empty list to disable.
|
||||||
*/
|
*/
|
||||||
"SilentChatTrigger" "/"
|
"SilentChatTrigger" "/"
|
||||||
|
|
||||||
@@ -44,7 +53,7 @@
|
|||||||
* but it does not evaluate to an actual command, it will be displayed
|
* but it does not evaluate to an actual command, it will be displayed
|
||||||
* publicly. This setting allows you to suppress accidental typings.
|
* publicly. This setting allows you to suppress accidental typings.
|
||||||
*
|
*
|
||||||
* The default value is "no". A value of "yes" will supress.
|
* The default value is "no". A value of "yes" will suppress.
|
||||||
*/
|
*/
|
||||||
"SilentFailSuppress" "no"
|
"SilentFailSuppress" "no"
|
||||||
|
|
||||||
@@ -53,24 +62,6 @@
|
|||||||
* passwords to work, for security reasons.
|
* passwords to work, for security reasons.
|
||||||
*/
|
*/
|
||||||
"PassInfoVar" "_password"
|
"PassInfoVar" "_password"
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies the sound that gets played when an item is selected from a menu.
|
|
||||||
*/
|
|
||||||
"MenuItemSound" "buttons/button14.wav"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies the sound that gets played when an "Exit" button is selected
|
|
||||||
* from a menu.
|
|
||||||
*/
|
|
||||||
"MenuExitSound" "buttons/combine_button7.wav"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies the sound that gets played when an "Exit Back" button is selected
|
|
||||||
* from a menu. This is the special "Back" button that is intended to roll back
|
|
||||||
* to a previous menu.
|
|
||||||
*/
|
|
||||||
"MenuExitBackSound" "buttons/combine_button7.wav"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables or disables whether SourceMod reads a client's cl_language cvar to set
|
* Enables or disables whether SourceMod reads a client's cl_language cvar to set
|
||||||
@@ -126,11 +117,51 @@
|
|||||||
*/
|
*/
|
||||||
"BlockBadPlugins" "yes"
|
"BlockBadPlugins" "yes"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controls how plugin unloads handle outstanding threaded database operations.
|
||||||
|
*
|
||||||
|
* "discard" - Immediately discard the plugin's outstanding database operations.
|
||||||
|
* This is the default and keeps the server responsive.
|
||||||
|
* "wait" - Wait for outstanding operations and run their callbacks before unload.
|
||||||
|
* Warning: This can stall the server.
|
||||||
|
*/
|
||||||
|
"DatabasePluginUnload" "discard"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If a plugin takes too long to execute, hanging or freezing the game server in the process,
|
* If a plugin takes too long to execute, hanging or freezing the game server in the process,
|
||||||
* SourceMod will attempt to terminate that plugin after the specified timeout length has
|
* SourceMod will attempt to terminate that plugin after the specified timeout length has
|
||||||
* passed. You can disable this feature by setting the value to "0".
|
* passed. You can disable this feature by setting the value to "0".
|
||||||
*/
|
*/
|
||||||
"SlowScriptTimeout" "8"
|
"SlowScriptTimeout" "8"
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* Per "http://blog.counter-strike.net/index.php/server_guidelines/", certain plugin
|
||||||
|
* functionality will trigger all of the game server owner's Game Server Login Tokens
|
||||||
|
* (GSLTs) to get banned when executed on a Counter-Strike: Global Offensive game server.
|
||||||
|
*
|
||||||
|
* Enabling this option will block plugins from using functionality that is known to cause this.
|
||||||
|
* This option only has any effect on CS:GO. Note that this does NOT guarantee that you cannot
|
||||||
|
* receive a ban.
|
||||||
|
*
|
||||||
|
* Disable this option at your own risk.
|
||||||
|
*/
|
||||||
|
"FollowCSGOServerGuidelines" "yes"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controls whether the SourcePawn runtime will generate additional metadata about
|
||||||
|
* JIT-compiled functions for performance profiling or debugging purposes.
|
||||||
|
*
|
||||||
|
* "none" - Don't generate any additional JIT metadata
|
||||||
|
* "default" - Generate basic perf metadata (on Linux) and delete it automatically on quit
|
||||||
|
* "perf" - Generate basic perf metadata (Linux only - function names)
|
||||||
|
* "jitdump" - Generate extended perf metadata (Linux only - function names, bytecode, and source information)
|
||||||
|
*/
|
||||||
|
"JITMetadata" "default"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup the SourcePawn VM to enable extensions to use a debugging API to step through
|
||||||
|
* plugins line by line. This heavily decreases server performance and should NEVER be
|
||||||
|
* used on a production server, but ONLY during plugin development.
|
||||||
|
*/
|
||||||
|
"EnableLineDebugging" "no"
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
"pass" ""
|
"pass" ""
|
||||||
//"timeout" "0"
|
//"timeout" "0"
|
||||||
//"port" "0"
|
//"port" "0"
|
||||||
|
//"schema" "public" // PostgreSQL only
|
||||||
}
|
}
|
||||||
|
|
||||||
"storage-local"
|
"storage-local"
|
||||||
|
|||||||
Binary file not shown.
+35
-1
@@ -1,4 +1,38 @@
|
|||||||
"Languages"
|
"Languages"
|
||||||
{
|
{
|
||||||
"en" "English"
|
"ar" "Arabic" // Arabic
|
||||||
|
"bg" "Bulgarian" // Bulgarian
|
||||||
|
"chi" "SChinese" // Chinese (Simplified)
|
||||||
|
"cze" "Czech" // Czech
|
||||||
|
"da" "Danish" // Danish
|
||||||
|
"de" "German" // German
|
||||||
|
"el" "Greek" // Greek
|
||||||
|
"en" "English" // English
|
||||||
|
"es" "Spanish" // Spanish
|
||||||
|
"fi" "Finnish" // Finnish
|
||||||
|
"fr" "French" // French
|
||||||
|
"he" "Hebrew" // Hebrew
|
||||||
|
"hu" "Hungarian" // Hungarian
|
||||||
|
"it" "Italian" // Italian
|
||||||
|
"jp" "Japanese" // Japanese
|
||||||
|
"ko" "Korean" // Korean
|
||||||
|
"ko" "KoreanA" // Korean (https://bugs.alliedmods.net/show_bug.cgi?id=4667)
|
||||||
|
"las" "LatAm" // Latin American Spanish
|
||||||
|
"lt" "Lithuanian" // Lithuanian
|
||||||
|
"lv" "Latvian" // Latvian
|
||||||
|
"nl" "Dutch" // Dutch
|
||||||
|
"no" "Norwegian" // Norwegian
|
||||||
|
"pl" "Polish" // Polish
|
||||||
|
"pt" "Brazilian" // Brazilian Portuguese
|
||||||
|
"pt_p" "Portuguese" // Portuguese
|
||||||
|
"ro" "Romanian" // Romanian
|
||||||
|
"ru" "Russian" // Russian
|
||||||
|
"sk" "Slovak" // Slovak
|
||||||
|
"sv" "Swedish" // Swedish
|
||||||
|
"th" "Thai" // Thai
|
||||||
|
"tr" "Turkish" // Turkish
|
||||||
|
"ua" "Ukrainian" // Ukrainian
|
||||||
|
"vi" "Vietnamese" // Vietnamese
|
||||||
|
"zho" "TChinese" // Chinese (Traditional)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS sm_cookies
|
||||||
|
(
|
||||||
|
id serial,
|
||||||
|
name varchar(30) NOT NULL UNIQUE,
|
||||||
|
description varchar(255),
|
||||||
|
access INTEGER,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS sm_cookie_cache
|
||||||
|
(
|
||||||
|
player varchar(65) NOT NULL,
|
||||||
|
cookie_id int NOT NULL,
|
||||||
|
value varchar(100),
|
||||||
|
timestamp int NOT NULL,
|
||||||
|
PRIMARY KEY (player, cookie_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE OR REPLACE LANGUAGE plpgsql;
|
||||||
|
|
||||||
|
CREATE OR REPLACE FUNCTION add_or_update_cookie(in_player VARCHAR(65), in_cookie INT, in_value VARCHAR(100), in_time INT) RETURNS VOID AS
|
||||||
|
$$
|
||||||
|
BEGIN
|
||||||
|
LOOP
|
||||||
|
-- first try to update the it.
|
||||||
|
UPDATE sm_cookie_cache SET value = in_value, timestamp = in_time WHERE player = in_player AND cookie_id = in_cookie;
|
||||||
|
IF found THEN
|
||||||
|
RETURN;
|
||||||
|
END IF;
|
||||||
|
-- not there, so try to insert.
|
||||||
|
-- if someone else inserts the same key concurrently, we could get a unique-key failure.
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO sm_cookie_cache (player, cookie_id, value, timestamp) VALUES (in_player, in_cookie, in_value, in_time);
|
||||||
|
RETURN;
|
||||||
|
EXCEPTION WHEN unique_violation THEN
|
||||||
|
-- do nothing... loop again, and we'll update.
|
||||||
|
END;
|
||||||
|
END LOOP;
|
||||||
|
END;
|
||||||
|
$$
|
||||||
|
LANGUAGE plpgsql;
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS sm_admins (
|
||||||
|
id serial,
|
||||||
|
authtype varchar(6) NOT NULL,
|
||||||
|
CHECK (authtype in ('steam', 'name', 'ip')),
|
||||||
|
identity varchar(65) NOT NULL,
|
||||||
|
password varchar(65),
|
||||||
|
flags varchar(30) NOT NULL,
|
||||||
|
name varchar(65) NOT NULL,
|
||||||
|
immunity int NOT NULL,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS sm_groups (
|
||||||
|
id serial,
|
||||||
|
flags varchar(30) NOT NULL,
|
||||||
|
name varchar(120) NOT NULL,
|
||||||
|
immunity_level int NOT NULL,
|
||||||
|
PRIMARY KEY (id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS sm_group_immunity (
|
||||||
|
group_id int NOT NULL,
|
||||||
|
other_id int NOT NULL,
|
||||||
|
FOREIGN KEY (group_id) REFERENCES sm_groups(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (other_id) REFERENCES sm_groups(id) ON DELETE CASCADE,
|
||||||
|
PRIMARY KEY (group_id, other_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS sm_group_overrides (
|
||||||
|
group_id int NOT NULL,
|
||||||
|
FOREIGN KEY (group_id) REFERENCES sm_groups(id) ON DELETE CASCADE,
|
||||||
|
type varchar(10) NOT NULL,
|
||||||
|
CHECK (type in ('command', 'group')),
|
||||||
|
name varchar(32) NOT NULL,
|
||||||
|
access varchar(5) NOT NULL,
|
||||||
|
CHECK (access in ('allow', 'deny')),
|
||||||
|
PRIMARY KEY (group_id, type, name)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS sm_overrides (
|
||||||
|
type varchar(10) NOT NULL,
|
||||||
|
CHECK (type in ('command', 'group')),
|
||||||
|
name varchar(32) NOT NULL,
|
||||||
|
flags varchar(30) NOT NULL,
|
||||||
|
PRIMARY KEY (type,name)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS sm_admins_groups (
|
||||||
|
admin_id int NOT NULL,
|
||||||
|
group_id int NOT NULL,
|
||||||
|
FOREIGN KEY (admin_id) REFERENCES sm_admins(id) ON DELETE CASCADE,
|
||||||
|
FOREIGN KEY (group_id) REFERENCES sm_groups(id) ON DELETE CASCADE,
|
||||||
|
inherit_order int NOT NULL,
|
||||||
|
PRIMARY KEY (admin_id, group_id)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- side note, this is pgsql module, sm_config will not exist if the above stuff exists... and it's being left to the admin
|
||||||
|
-- to figure out if it exists.
|
||||||
|
CREATE TABLE IF NOT EXISTS sm_config (
|
||||||
|
cfg_key varchar(32) NOT NULL,
|
||||||
|
cfg_value varchar(255) NOT NULL,
|
||||||
|
PRIMARY KEY (cfg_key)
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO sm_config (cfg_key, cfg_value) VALUES ('admin_version', '1.0.0.1409') ON CONFLICT (cfg_key) DO UPDATE SET cfg_value = EXCLUDED.cfg_value;
|
||||||
+39
-26
@@ -1,36 +1,49 @@
|
|||||||
# vim: set ts=2 sw=2 tw=99 noet:
|
# vim: set ts=2 sw=2 tw=99 noet:
|
||||||
import sys
|
import sys
|
||||||
try:
|
try:
|
||||||
from ambuild2 import run
|
from ambuild2 import run, util
|
||||||
except:
|
except:
|
||||||
try:
|
try:
|
||||||
import ambuild
|
import ambuild
|
||||||
sys.stderr.write('It looks like you have AMBuild 1 installed, but this project uses AMBuild 2.\n')
|
sys.stderr.write('It looks like you have AMBuild 1 installed, but this project uses AMBuild 2.\n')
|
||||||
sys.stderr.write('Upgrade to the latest version of AMBuild to continue.\n')
|
sys.stderr.write('Upgrade to the latest version of AMBuild to continue.\n')
|
||||||
except:
|
except:
|
||||||
sys.stderr.write('AMBuild must be installed to build this project.\n')
|
sys.stderr.write('AMBuild must be installed to build this project.\n')
|
||||||
sys.stderr.write('http://www.alliedmods.net/ambuild\n')
|
sys.stderr.write('http://www.alliedmods.net/ambuild\n')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
run = run.PrepareBuild(sourcePath=sys.path[0])
|
# Hack to show a decent upgrade message, which wasn't done until 2.2.
|
||||||
run.default_build_folder = 'obj-' + run.target_platform
|
ambuild_version = getattr(run, 'CURRENT_API', '2.1')
|
||||||
run.options.add_option('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None,
|
if ambuild_version.startswith('2.1'):
|
||||||
help='Root search folder for HL2SDKs')
|
sys.stderr.write("AMBuild 2.2 or higher is required; please update\n")
|
||||||
run.options.add_option('--mysql-path', type=str, dest='mysql_path', default=None,
|
sys.exit(1)
|
||||||
help='Path to MySQL 5')
|
|
||||||
run.options.add_option('--mms-path', type=str, dest='mms_path', default=None,
|
parser = run.BuildParser(sourcePath=sys.path[0], api='2.2')
|
||||||
|
parser.options.add_argument('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None,
|
||||||
|
help='Root search folder for HL2SDKs')
|
||||||
|
parser.options.add_argument('--mariadb-path', type=str, dest='mariadb_path', default=None,
|
||||||
|
help='Path to x86 MariaDB Connector/C')
|
||||||
|
parser.options.add_argument('--mariadb64-path', type=str, dest='mariadb64_path', default=None,
|
||||||
|
help='Path to x86_64 MariaDB Connector/C')
|
||||||
|
parser.options.add_argument('--mms-path', type=str, dest='mms_path', default=None,
|
||||||
help='Path to Metamod:Source')
|
help='Path to Metamod:Source')
|
||||||
run.options.add_option('--enable-debug', action='store_const', const='1', dest='debug',
|
parser.options.add_argument('--enable-debug', action='store_const', const='1', dest='debug',
|
||||||
help='Enable debugging symbols')
|
help='Enable debugging symbols')
|
||||||
run.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt',
|
parser.options.add_argument('--enable-optimize', action='store_const', const='1', dest='opt',
|
||||||
help='Enable optimization')
|
help='Enable optimization')
|
||||||
run.options.add_option('--no-mysql', action='store_false', default=True, dest='hasMySql',
|
parser.options.add_argument('--no-mysql', action='store_false', default=True, dest='hasMySql',
|
||||||
help='Disable building MySQL extension')
|
help='Disable building MySQL extension')
|
||||||
run.options.add_option('-s', '--sdks', default='all', dest='sdks',
|
parser.options.add_argument('-s', '--sdks', default='present', dest='sdks',
|
||||||
help='Build against specified SDKs; valid args are "all", "present", or '
|
help='Build against specified SDKs; valid args are "none", "all", "present",'
|
||||||
'comma-delimited list of engine names (default: %default)')
|
' or comma-delimited list of engine names')
|
||||||
run.options.add_option('--breakpad-dump', action='store_true', dest='breakpad_dump',
|
parser.options.add_argument('--breakpad-dump', action='store_true', dest='breakpad_dump',
|
||||||
default=False, help='Dump and upload breakpad symbols')
|
default=False, help='Dump and upload breakpad symbols')
|
||||||
run.options.add_option('--disable-auto-versioning', action='store_true', dest='disable_auto_versioning',
|
parser.options.add_argument('--disable-auto-versioning', action='store_true', dest='disable_auto_versioning',
|
||||||
default=False, help='Disable the auto versioning script')
|
default=False, help='Disable the auto versioning script')
|
||||||
run.Configure()
|
parser.options.add_argument('--targets', type=str, dest='targets', default=None,
|
||||||
|
help="Override the target architecture (use commas to separate multiple targets).")
|
||||||
|
parser.options.add_argument('--scripting-only', action='store_true', dest='scripting_only', default=False,
|
||||||
|
help="Only build and package the files required for scripting in SourcePawn.")
|
||||||
|
parser.options.add_argument('--enable-asan', action='store_true', dest='enable_asan',
|
||||||
|
default=False, help='Enable ASAN (clang only)')
|
||||||
|
parser.Configure()
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Build stage - use the same image as sourcemod CI builds
|
||||||
|
FROM ghcr.io/alliedmodders/build-containers/debian11:latest AS builder
|
||||||
|
|
||||||
|
COPY sourcepawn/ /build/sourcepawn/
|
||||||
|
|
||||||
|
WORKDIR /build/sourcepawn
|
||||||
|
RUN mkdir build && cd build && \
|
||||||
|
python3 ../configure.py --enable-optimize --targets=x86_64 && \
|
||||||
|
ambuild
|
||||||
|
|
||||||
|
# Runtime stage
|
||||||
|
FROM debian:bullseye-slim
|
||||||
|
|
||||||
|
# AMBuild names the per-target output folder <platform>-<arch>; since this stage
|
||||||
|
# always builds linux/x86_64, that's deterministically "linux-x86_64".
|
||||||
|
COPY --from=builder --chmod=0755 /build/sourcepawn/build/spcomp/linux-x86_64/spcomp /usr/local/bin/spcomp
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/spcomp"]
|
||||||
+95
-52
@@ -1,7 +1,8 @@
|
|||||||
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
||||||
import os
|
import os
|
||||||
|
|
||||||
project = SM.HL2Project(builder, 'sourcemod')
|
project = builder.LibraryProject('sourcemod')
|
||||||
|
|
||||||
project.sources += [
|
project.sources += [
|
||||||
'MenuStyle_Valve.cpp',
|
'MenuStyle_Valve.cpp',
|
||||||
'logic_bridge.cpp',
|
'logic_bridge.cpp',
|
||||||
@@ -9,7 +10,6 @@ project.sources += [
|
|||||||
'sm_stringutil.cpp',
|
'sm_stringutil.cpp',
|
||||||
'MenuVoting.cpp',
|
'MenuVoting.cpp',
|
||||||
'smn_events.cpp',
|
'smn_events.cpp',
|
||||||
'CDataPack.cpp',
|
|
||||||
'frame_hooks.cpp',
|
'frame_hooks.cpp',
|
||||||
'smn_nextmap.cpp',
|
'smn_nextmap.cpp',
|
||||||
'sourcemm_api.cpp',
|
'sourcemm_api.cpp',
|
||||||
@@ -21,7 +21,6 @@ project.sources += [
|
|||||||
'NextMap.cpp',
|
'NextMap.cpp',
|
||||||
'ConCmdManager.cpp',
|
'ConCmdManager.cpp',
|
||||||
'ConVarManager.cpp',
|
'ConVarManager.cpp',
|
||||||
'LibrarySys.cpp',
|
|
||||||
'PlayerManager.cpp',
|
'PlayerManager.cpp',
|
||||||
'TimerSys.cpp',
|
'TimerSys.cpp',
|
||||||
'CoreConfig.cpp',
|
'CoreConfig.cpp',
|
||||||
@@ -38,81 +37,125 @@ project.sources += [
|
|||||||
'EventManager.cpp',
|
'EventManager.cpp',
|
||||||
'MenuStyle_Radio.cpp',
|
'MenuStyle_Radio.cpp',
|
||||||
'sm_autonatives.cpp',
|
'sm_autonatives.cpp',
|
||||||
'sm_srvcmds.cpp',
|
|
||||||
'ConsoleDetours.cpp',
|
'ConsoleDetours.cpp',
|
||||||
'vprof_tool.cpp',
|
|
||||||
'smn_commandline.cpp',
|
'smn_commandline.cpp',
|
||||||
|
'GameHooks.cpp',
|
||||||
]
|
]
|
||||||
|
|
||||||
for sdk_name in SM.sdks:
|
# SDK name to shipping gamedir, mostly
|
||||||
sdk = SM.sdks[sdk_name]
|
pb_gamedir_map = {
|
||||||
binary_name = 'sourcemod.' + sdk.ext
|
'csgo': 'csgo',
|
||||||
|
'blade': 'berimbau',
|
||||||
|
'mcv': 'vietnam',
|
||||||
|
'outbreak': 'terror'
|
||||||
|
}
|
||||||
|
|
||||||
|
# SDK name to source code gamedir
|
||||||
|
pb_gamesrcdir_map = {
|
||||||
|
'csgo': 'cstrike15',
|
||||||
|
'blade': 'berimbau',
|
||||||
|
'mcv': 'vietnam',
|
||||||
|
'outbreak': 'terror',
|
||||||
|
}
|
||||||
|
|
||||||
|
for sdk_target in SM.sdk_targets:
|
||||||
|
sdk = sdk_target.sdk
|
||||||
|
cxx = sdk_target.cxx
|
||||||
|
|
||||||
|
binary_name = 'sourcemod.' + sdk['extension']
|
||||||
|
needs_protobuf = sdk['name'] in ['csgo', 'blade', 'mcv', 'outbreak']
|
||||||
|
|
||||||
|
binary = SM.HL2Config(project, builder, cxx, binary_name, sdk)
|
||||||
|
SM.ConfigureForExtension(builder, binary.compiler)
|
||||||
|
|
||||||
binary = SM.HL2Config(project, binary_name, sdk)
|
|
||||||
compiler = binary.compiler
|
compiler = binary.compiler
|
||||||
|
compiler.cxxincludes += [
|
||||||
|
builder.sourcePath
|
||||||
|
]
|
||||||
|
|
||||||
if sdk.name == 'csgo':
|
if needs_protobuf:
|
||||||
compiler.cxxincludes += [
|
compiler.cxxincludes += [
|
||||||
os.path.join(sdk.path, 'common', 'protobuf-2.5.0', 'src'),
|
os.path.join(sdk['path'], 'public', 'engine', 'protobuf'),
|
||||||
os.path.join(sdk.path, 'public', 'engine', 'protobuf'),
|
os.path.join(sdk['path'], 'public', 'game', 'shared', pb_gamedir_map[sdk['name']], 'protobuf')
|
||||||
os.path.join(sdk.path, 'public', 'game', 'shared', 'csgo', 'protobuf')
|
|
||||||
]
|
]
|
||||||
elif sdk.name == 'dota':
|
if sdk['name'] == 'outbreak':
|
||||||
|
compiler.cxxincludes += [
|
||||||
|
# Outbreak has "base" usermessages split from the game-specific ones
|
||||||
|
os.path.join(sdk['path'], 'public', 'game', 'shared', 'protobuf')
|
||||||
|
]
|
||||||
|
protobuf_version = "2.5.0"
|
||||||
|
if sdk['name'] == 'mcv':
|
||||||
|
protobuf_version = "3.2.0"
|
||||||
|
elif sdk['name'] == 'outbreak':
|
||||||
|
protobuf_version = "3.17.3"
|
||||||
compiler.cxxincludes += [
|
compiler.cxxincludes += [
|
||||||
os.path.join(sdk.path, 'common', 'protobuf-2.5.0', 'src'),
|
os.path.join(sdk['path'], 'common', 'protobuf-' + protobuf_version, 'src')
|
||||||
os.path.join(sdk.path, 'public', 'engine', 'protobuf'),
|
|
||||||
os.path.join(sdk.path, 'public', 'game', 'shared', 'protobuf'),
|
|
||||||
os.path.join(sdk.path, 'public', 'game', 'shared', 'dota', 'protobuf')
|
|
||||||
]
|
]
|
||||||
|
|
||||||
if builder.target_platform == 'linux':
|
if compiler.like('msvc'):
|
||||||
|
compiler.defines += ['_ALLOW_KEYWORD_MACROS']
|
||||||
|
if cxx.target.platform == 'linux':
|
||||||
compiler.postlink += ['-lpthread', '-lrt']
|
compiler.postlink += ['-lpthread', '-lrt']
|
||||||
|
|
||||||
if sdk.name == 'csgo' or sdk.name == 'dota':
|
if needs_protobuf:
|
||||||
if builder.target_platform == 'linux':
|
if compiler.target.platform == 'linux':
|
||||||
lib_path = os.path.join(sdk.path, 'lib', 'linux32', 'release', 'libprotobuf.a')
|
if compiler.target.arch == 'x86':
|
||||||
elif builder.target_platform == 'mac':
|
lib_path = os.path.join(sdk['path'], 'lib', 'linux32', 'release', 'libprotobuf.a')
|
||||||
lib_path = os.path.join(sdk.path, 'lib', 'osx32', 'release', 'libprotobuf.a')
|
elif compiler.target.arch == 'x86_64':
|
||||||
elif builder.target_platform == 'windows':
|
lib_path = os.path.join(sdk['path'], 'lib', 'linux64', 'release', 'libprotobuf.a')
|
||||||
|
compiler.linkflags += ['-Wl,--exclude-libs=libprotobuf.a']
|
||||||
|
elif compiler.target.platform == 'mac':
|
||||||
|
if compiler.target.arch == 'x86':
|
||||||
|
lib_path = os.path.join(sdk['path'], 'lib', 'osx32', 'release', 'libprotobuf.a')
|
||||||
|
elif compiler.target.arch == 'x86_64':
|
||||||
|
lib_path = os.path.join(sdk['path'], 'lib', 'osx64', 'release', 'libprotobuf.a')
|
||||||
|
elif compiler.target.platform == 'windows':
|
||||||
msvc_ver = compiler.version
|
msvc_ver = compiler.version
|
||||||
vs_year = ''
|
vs_year = ''
|
||||||
if msvc_ver == 1800:
|
platform = ''
|
||||||
vs_year = '2013'
|
if compiler.target.arch == 'x86':
|
||||||
elif msvc_ver == 1700:
|
platform = 'win32'
|
||||||
vs_year = '2012'
|
elif compiler.target.arch == 'x86_64':
|
||||||
elif msvc_ver == 1600:
|
platform = 'win64'
|
||||||
vs_year = '2010'
|
|
||||||
|
if 1900 <= msvc_ver < 2000:
|
||||||
|
vs_year = '2015'
|
||||||
else:
|
else:
|
||||||
raise Exception('Cannot find libprotobuf for MSVC version "' + compiler.version + '"')
|
raise Exception('Cannot find libprotobuf for MSVC version "' + str(compiler.version) + '"')
|
||||||
|
|
||||||
if 'DEBUG' in compiler.defines:
|
if 'DEBUG' in compiler.defines:
|
||||||
lib_path = os.path.join(sdk.path, 'lib', 'win32', 'debug', 'vs' + vs_year, 'libprotobuf.lib')
|
lib_path = os.path.join(sdk['path'], 'lib', platform, 'debug', 'vs' + vs_year, 'libprotobuf.lib')
|
||||||
else:
|
else:
|
||||||
lib_path = os.path.join(sdk.path, 'lib', 'win32', 'release', 'vs' + vs_year, 'libprotobuf.lib')
|
lib_path = os.path.join(sdk['path'], 'lib', platform, 'release', 'vs' + vs_year, 'libprotobuf.lib')
|
||||||
compiler.linkflags.insert(0, binary.Dep(lib_path))
|
compiler.linkflags.insert(0, lib_path)
|
||||||
|
|
||||||
if sdk.name in ['csgo', 'dota']:
|
if needs_protobuf:
|
||||||
binary.sources += ['smn_protobuf.cpp']
|
binary.sources += ['smn_protobuf.cpp']
|
||||||
else:
|
else:
|
||||||
binary.sources += ['smn_bitbuffer.cpp']
|
binary.sources += ['smn_bitbuffer.cpp']
|
||||||
|
|
||||||
if sdk.name == 'csgo':
|
if sdk['name'] != 'blade':
|
||||||
binary.sources += [
|
binary.sources += [
|
||||||
os.path.join(sdk.path, 'public', 'engine', 'protobuf', 'netmessages.pb.cc'),
|
'vprof_tool.cpp',
|
||||||
os.path.join(sdk.path, 'public', 'game', 'shared', 'csgo', 'protobuf', 'cstrike15_usermessages.pb.cc'),
|
|
||||||
os.path.join(sdk.path, 'public', 'game', 'shared', 'csgo', 'protobuf', 'cstrike15_usermessage_helpers.cpp'),
|
|
||||||
]
|
]
|
||||||
elif sdk.name == 'dota':
|
|
||||||
|
if needs_protobuf:
|
||||||
binary.sources += [
|
binary.sources += [
|
||||||
os.path.join(sdk.path, 'public', 'engine', 'protobuf', 'networkbasetypes.pb.cc'),
|
os.path.join(sdk['path'], 'public', 'engine', 'protobuf', 'netmessages.pb.cc'),
|
||||||
os.path.join(sdk.path, 'public', 'engine', 'protobuf', 'netmessages.pb.cc'),
|
os.path.join(sdk['path'], 'public', 'game', 'shared', pb_gamedir_map[sdk['name']], 'protobuf', pb_gamesrcdir_map[sdk['name']] + '_usermessages.pb.cc'),
|
||||||
os.path.join(sdk.path, 'public', 'engine', 'protobuf', 'network_connection.pb.cc'),
|
os.path.join(sdk['path'], 'public', 'game', 'shared', pb_gamedir_map[sdk['name']], 'protobuf', pb_gamesrcdir_map[sdk['name']] + '_usermessage_helpers.cpp'),
|
||||||
os.path.join(sdk.path, 'public', 'game', 'shared', 'protobuf', 'ai_activity.pb.cc'),
|
|
||||||
os.path.join(sdk.path, 'public', 'game', 'shared', 'protobuf', 'usermessages.pb.cc'),
|
|
||||||
os.path.join(sdk.path, 'public', 'game', 'shared', 'dota', 'protobuf', 'dota_commonmessages.pb.cc'),
|
|
||||||
os.path.join(sdk.path, 'public', 'game', 'shared', 'dota', 'protobuf', 'dota_usermessages.pb.cc'),
|
|
||||||
os.path.join(sdk.path, 'public', 'game', 'shared', 'dota', 'protobuf', 'dota_usermessage_helpers.cpp'),
|
|
||||||
]
|
]
|
||||||
|
if sdk['name'] == 'mcv':
|
||||||
|
binary.sources += [
|
||||||
|
os.path.join(sdk['path'], 'public', 'game', 'shared', pb_gamedir_map[sdk['name']], 'protobuf', pb_gamesrcdir_map[sdk['name']] + '_gcmessages.pb.cc'),
|
||||||
|
os.path.join(sdk['path'], 'public', 'engine', 'protobuf', 'engine_gcmessages.pb.cc'),
|
||||||
|
]
|
||||||
|
if sdk['name'] == 'outbreak':
|
||||||
|
binary.sources += [
|
||||||
|
os.path.join(sdk['path'], 'public', 'engine', 'protobuf', 'network_connection.pb.cc'),
|
||||||
|
os.path.join(sdk['path'], 'public', 'game', 'shared', 'protobuf', 'base_usermessages.pb.cc'),
|
||||||
|
os.path.join(sdk['path'], 'public', 'game', 'shared', 'protobuf', 'base_usermessage_helpers.cpp'),
|
||||||
|
]
|
||||||
|
|
||||||
SM.binaries += builder.Add(project)
|
SM.binaries += builder.Add(project)
|
||||||
|
|
||||||
|
|||||||
@@ -1,333 +0,0 @@
|
|||||||
/**
|
|
||||||
* vim: set ts=4 :
|
|
||||||
* =============================================================================
|
|
||||||
* SourceMod
|
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
|
||||||
* =============================================================================
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
|
||||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
||||||
* Free Software Foundation.
|
|
||||||
*
|
|
||||||
* 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
||||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
||||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
||||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
||||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
||||||
* this exception to all derivative works. AlliedModders LLC defines further
|
|
||||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
||||||
* or <http://www.sourcemod.net/license.php>.
|
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "CDataPack.h"
|
|
||||||
|
|
||||||
#define DATAPACK_INITIAL_SIZE 512
|
|
||||||
|
|
||||||
CDataPack::CDataPack()
|
|
||||||
{
|
|
||||||
m_pBase = (char *)malloc(DATAPACK_INITIAL_SIZE);
|
|
||||||
m_capacity = DATAPACK_INITIAL_SIZE;
|
|
||||||
Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
CDataPack::~CDataPack()
|
|
||||||
{
|
|
||||||
free(m_pBase);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDataPack::Initialize()
|
|
||||||
{
|
|
||||||
m_curptr = m_pBase;
|
|
||||||
m_size = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDataPack::CheckSize(size_t typesize)
|
|
||||||
{
|
|
||||||
if (m_curptr - m_pBase + typesize <= m_capacity)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t pos = m_curptr - m_pBase;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
m_capacity *= 2;
|
|
||||||
m_pBase = (char *)realloc(m_pBase, m_capacity);
|
|
||||||
m_curptr = m_pBase + pos;
|
|
||||||
} while (m_curptr - m_pBase + typesize > m_capacity);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDataPack::ResetSize()
|
|
||||||
{
|
|
||||||
m_size = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t CDataPack::CreateMemory(size_t size, void **addr)
|
|
||||||
{
|
|
||||||
CheckSize(sizeof(char) + sizeof(size_t) + size);
|
|
||||||
size_t pos = m_curptr - m_pBase;
|
|
||||||
|
|
||||||
*(char *)m_curptr = Raw;
|
|
||||||
m_curptr += sizeof(char);
|
|
||||||
|
|
||||||
*(size_t *)m_curptr = size;
|
|
||||||
m_curptr += sizeof(size_t);
|
|
||||||
|
|
||||||
if (addr)
|
|
||||||
{
|
|
||||||
*addr = m_curptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_curptr += size;
|
|
||||||
m_size += sizeof(char) + sizeof(size_t) + size;
|
|
||||||
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDataPack::PackCell(cell_t cell)
|
|
||||||
{
|
|
||||||
CheckSize(sizeof(char) + sizeof(size_t) + sizeof(cell_t));
|
|
||||||
|
|
||||||
*(char *)m_curptr = Cell;
|
|
||||||
m_curptr += sizeof(char);
|
|
||||||
|
|
||||||
*(size_t *)m_curptr = sizeof(cell_t);
|
|
||||||
m_curptr += sizeof(size_t);
|
|
||||||
|
|
||||||
*(cell_t *)m_curptr = cell;
|
|
||||||
m_curptr += sizeof(cell_t);
|
|
||||||
|
|
||||||
m_size += sizeof(char) + sizeof(size_t) + sizeof(cell_t);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDataPack::PackFloat(float val)
|
|
||||||
{
|
|
||||||
CheckSize(sizeof(char) + sizeof(size_t) + sizeof(float));
|
|
||||||
|
|
||||||
*(char *)m_curptr = Float;
|
|
||||||
m_curptr += sizeof(char);
|
|
||||||
|
|
||||||
*(size_t *)m_curptr = sizeof(float);
|
|
||||||
m_curptr += sizeof(size_t);
|
|
||||||
|
|
||||||
*(float *)m_curptr = val;
|
|
||||||
m_curptr += sizeof(float);
|
|
||||||
|
|
||||||
m_size += sizeof(char) + sizeof(size_t) + sizeof(float);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDataPack::PackString(const char *string)
|
|
||||||
{
|
|
||||||
size_t len = strlen(string);
|
|
||||||
size_t maxsize = sizeof(char) + sizeof(size_t) + len + 1;
|
|
||||||
CheckSize(maxsize);
|
|
||||||
|
|
||||||
*(char *)m_curptr = String;
|
|
||||||
m_curptr += sizeof(char);
|
|
||||||
|
|
||||||
// Pack the string length first for buffer overrun checking.
|
|
||||||
*(size_t *)m_curptr = len;
|
|
||||||
m_curptr += sizeof(size_t);
|
|
||||||
|
|
||||||
// Now pack the string.
|
|
||||||
memcpy(m_curptr, string, len);
|
|
||||||
m_curptr[len] = '\0';
|
|
||||||
m_curptr += len + 1;
|
|
||||||
|
|
||||||
m_size += maxsize;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDataPack::Reset() const
|
|
||||||
{
|
|
||||||
m_curptr = m_pBase;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t CDataPack::GetPosition() const
|
|
||||||
{
|
|
||||||
return static_cast<size_t>(m_curptr - m_pBase);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CDataPack::SetPosition(size_t pos) const
|
|
||||||
{
|
|
||||||
if (pos > m_size-1)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
m_curptr = m_pBase + pos;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
cell_t CDataPack::ReadCell() const
|
|
||||||
{
|
|
||||||
if (!IsReadable(sizeof(char) + sizeof(size_t) + sizeof(cell_t)))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (*reinterpret_cast<char *>(m_curptr) != Cell)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
m_curptr += sizeof(char);
|
|
||||||
|
|
||||||
if (*reinterpret_cast<size_t *>(m_curptr) != sizeof(cell_t))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_curptr += sizeof(size_t);
|
|
||||||
|
|
||||||
cell_t val = *reinterpret_cast<cell_t *>(m_curptr);
|
|
||||||
m_curptr += sizeof(cell_t);
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
float CDataPack::ReadFloat() const
|
|
||||||
{
|
|
||||||
if (!IsReadable(sizeof(char) + sizeof(size_t) + sizeof(float)))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (*reinterpret_cast<char *>(m_curptr) != Float)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
m_curptr += sizeof(char);
|
|
||||||
|
|
||||||
if (*reinterpret_cast<size_t *>(m_curptr) != sizeof(float))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_curptr += sizeof(size_t);
|
|
||||||
|
|
||||||
float val = *reinterpret_cast<float *>(m_curptr);
|
|
||||||
m_curptr += sizeof(float);
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CDataPack::IsReadable(size_t bytes) const
|
|
||||||
{
|
|
||||||
return (bytes + (m_curptr - m_pBase) > m_size) ? false : true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *CDataPack::ReadString(size_t *len) const
|
|
||||||
{
|
|
||||||
if (!IsReadable(sizeof(char) + sizeof(size_t)))
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (*reinterpret_cast<char *>(m_curptr) != String)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
m_curptr += sizeof(char);
|
|
||||||
|
|
||||||
size_t real_len = *(size_t *)m_curptr;
|
|
||||||
|
|
||||||
m_curptr += sizeof(size_t);
|
|
||||||
char *str = (char *)m_curptr;
|
|
||||||
|
|
||||||
if ((strlen(str) != real_len) || !(IsReadable(real_len+1)))
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (len)
|
|
||||||
{
|
|
||||||
*len = real_len;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_curptr += real_len + 1;
|
|
||||||
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *CDataPack::GetMemory() const
|
|
||||||
{
|
|
||||||
return m_curptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *CDataPack::ReadMemory(size_t *size) const
|
|
||||||
{
|
|
||||||
if (!IsReadable(sizeof(size_t)))
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if (*reinterpret_cast<char *>(m_curptr) != Raw)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
m_curptr += sizeof(char);
|
|
||||||
|
|
||||||
size_t bytecount = *(size_t *)m_curptr;
|
|
||||||
m_curptr += sizeof(size_t);
|
|
||||||
|
|
||||||
if (!IsReadable(bytecount))
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *ptr = m_curptr;
|
|
||||||
|
|
||||||
if (size)
|
|
||||||
{
|
|
||||||
*size = bytecount;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_curptr += bytecount;
|
|
||||||
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CDataPack::PackFunction(cell_t function)
|
|
||||||
{
|
|
||||||
CheckSize(sizeof(char) + sizeof(size_t) + sizeof(cell_t));
|
|
||||||
|
|
||||||
*(char *)m_curptr = Function;
|
|
||||||
m_curptr += sizeof(char);
|
|
||||||
|
|
||||||
*(size_t *)m_curptr = sizeof(cell_t);
|
|
||||||
m_curptr += sizeof(size_t);
|
|
||||||
|
|
||||||
*(cell_t *)m_curptr = function;
|
|
||||||
m_curptr += sizeof(cell_t);
|
|
||||||
|
|
||||||
m_size += sizeof(char) + sizeof(size_t) + sizeof(cell_t);
|
|
||||||
}
|
|
||||||
|
|
||||||
cell_t CDataPack::ReadFunction() const
|
|
||||||
{
|
|
||||||
if (!IsReadable(sizeof(char) + sizeof(size_t) + sizeof(cell_t)))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (*reinterpret_cast<char *>(m_curptr) != Function)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
m_curptr += sizeof(char);
|
|
||||||
|
|
||||||
if (*reinterpret_cast<size_t *>(m_curptr) != sizeof(cell_t))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_curptr += sizeof(size_t);
|
|
||||||
|
|
||||||
cell_t val = *reinterpret_cast<cell_t *>(m_curptr);
|
|
||||||
m_curptr += sizeof(cell_t);
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
@@ -44,11 +44,7 @@ public: //IRecipientFilter
|
|||||||
bool IsReliable() const;
|
bool IsReliable() const;
|
||||||
bool IsInitMessage() const;
|
bool IsInitMessage() const;
|
||||||
int GetRecipientCount() const;
|
int GetRecipientCount() const;
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
|
||||||
CEntityIndex GetRecipientIndex(int slot) const;
|
|
||||||
#else
|
|
||||||
int GetRecipientIndex(int slot) const;
|
int GetRecipientIndex(int slot) const;
|
||||||
#endif
|
|
||||||
public:
|
public:
|
||||||
void Initialize(const cell_t *ptr, size_t count);
|
void Initialize(const cell_t *ptr, size_t count);
|
||||||
void SetToReliable(bool isreliable);
|
void SetToReliable(bool isreliable);
|
||||||
@@ -83,11 +79,7 @@ inline int CellRecipientFilter::GetRecipientCount() const
|
|||||||
return m_Size;
|
return m_Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
|
||||||
inline CEntityIndex CellRecipientFilter::GetRecipientIndex(int slot) const
|
|
||||||
#else
|
|
||||||
inline int CellRecipientFilter::GetRecipientIndex(int slot) const
|
inline int CellRecipientFilter::GetRecipientIndex(int slot) const
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
if ((slot < 0) || (slot >= GetRecipientCount()))
|
if ((slot < 0) || (slot >= GetRecipientCount()))
|
||||||
@@ -99,11 +91,7 @@ inline int CellRecipientFilter::GetRecipientIndex(int slot) const
|
|||||||
ret = static_cast<int>(m_Players[slot]);
|
ret = static_cast<int>(m_Players[slot]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
|
||||||
return CEntityIndex(ret);
|
|
||||||
#else
|
|
||||||
return ret;
|
return ret;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void CellRecipientFilter::SetToInit(bool isinitmsg)
|
inline void CellRecipientFilter::SetToInit(bool isinitmsg)
|
||||||
|
|||||||
+116
-164
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod
|
* SourceMod
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
* This program is free software; you can redistribute it and/or modify it under
|
* This program is free software; you can redistribute it and/or modify it under
|
||||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
* Free Software Foundation.
|
* Free Software Foundation.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* 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
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
@@ -29,6 +29,8 @@
|
|||||||
* Version: $Id$
|
* Version: $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include <ITextParsers.h>
|
#include <ITextParsers.h>
|
||||||
#include "ChatTriggers.h"
|
#include "ChatTriggers.h"
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
@@ -37,32 +39,18 @@
|
|||||||
#include "HalfLife2.h"
|
#include "HalfLife2.h"
|
||||||
#include "logic_bridge.h"
|
#include "logic_bridge.h"
|
||||||
#include "sourcemod.h"
|
#include "sourcemod.h"
|
||||||
|
#include "provider.h"
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
#include <bridge/include/ILogger.h>
|
||||||
SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommandContext &, const CCommand &);
|
#include <amtl/am-string.h>
|
||||||
#elif SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
|
|
||||||
#elif SOURCE_ENGINE == SE_DARKMESSIAH
|
|
||||||
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
|
||||||
#else
|
|
||||||
# if SH_IMPL_VERSION >= 4
|
|
||||||
extern int __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
|
||||||
# else
|
|
||||||
extern bool __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
|
||||||
# endif
|
|
||||||
extern bool __SourceHook_FHRemoveConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ChatTriggers g_ChatTriggers;
|
ChatTriggers g_ChatTriggers;
|
||||||
bool g_bSupressSilentFails = false;
|
bool g_bSupressSilentFails = false;
|
||||||
|
|
||||||
ChatTriggers::ChatTriggers() : m_pSayCmd(NULL), m_bWillProcessInPost(false),
|
ChatTriggers::ChatTriggers() : m_bWillProcessInPost(false),
|
||||||
m_ReplyTo(SM_REPLY_CONSOLE), m_ArgSBackup(NULL)
|
m_ReplyTo(SM_REPLY_CONSOLE), m_ArgSBackup(NULL)
|
||||||
{
|
{
|
||||||
m_PubTrigger = sm_strdup("!");
|
m_PubTrigger = "!";
|
||||||
m_PrivTrigger = sm_strdup("/");
|
m_PrivTrigger = "/";
|
||||||
m_PubTriggerSize = 1;
|
|
||||||
m_PrivTriggerSize = 1;
|
|
||||||
m_bIsChatTrigger = false;
|
m_bIsChatTrigger = false;
|
||||||
m_bPluginIgnored = true;
|
m_bPluginIgnored = true;
|
||||||
#if SOURCE_ENGINE == SE_EPISODEONE
|
#if SOURCE_ENGINE == SE_EPISODEONE
|
||||||
@@ -72,32 +60,47 @@ ChatTriggers::ChatTriggers() : m_pSayCmd(NULL), m_bWillProcessInPost(false),
|
|||||||
|
|
||||||
ChatTriggers::~ChatTriggers()
|
ChatTriggers::~ChatTriggers()
|
||||||
{
|
{
|
||||||
delete [] m_PubTrigger;
|
|
||||||
m_PubTrigger = NULL;
|
|
||||||
delete [] m_PrivTrigger;
|
|
||||||
m_PrivTrigger = NULL;
|
|
||||||
delete [] m_ArgSBackup;
|
delete [] m_ArgSBackup;
|
||||||
m_ArgSBackup = NULL;
|
m_ArgSBackup = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigResult ChatTriggers::OnSourceModConfigChanged(const char *key,
|
void ChatTriggers::SetChatTrigger(ChatTriggerType type, const char *value)
|
||||||
const char *value,
|
{
|
||||||
|
std::unique_ptr<char[]> filtered(new char[strlen(value) + 1]);
|
||||||
|
|
||||||
|
const char *src = value;
|
||||||
|
char *dest = filtered.get();
|
||||||
|
char c;
|
||||||
|
while ((c = *src++) != '\0') {
|
||||||
|
if (c <= ' ' || c == '"' || c == '\'' || (c >= '0' && c <= '9') || c == ';' || (c >= 'A' && c <= 'Z') || c == '\\' || (c >= 'a' && c <= 'z') || c >= 0x7F) {
|
||||||
|
logger->LogError("Ignoring %s chat trigger character '%c', not in valid set: %s", (type == ChatTrigger_Private ? "silent" : "public"), c, "!#$%&()*+,-./:<=>?@[]^_`{|}~");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
*dest++ = c;
|
||||||
|
}
|
||||||
|
*dest = '\0';
|
||||||
|
|
||||||
|
if (type == ChatTrigger_Private) {
|
||||||
|
m_PrivTrigger = filtered.get();
|
||||||
|
} else {
|
||||||
|
m_PubTrigger = filtered.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigResult ChatTriggers::OnSourceModConfigChanged(const char *key,
|
||||||
|
const char *value,
|
||||||
ConfigSource source,
|
ConfigSource source,
|
||||||
char *error,
|
char *error,
|
||||||
size_t maxlength)
|
size_t maxlength)
|
||||||
{
|
{
|
||||||
if (strcmp(key, "PublicChatTrigger") == 0)
|
if (strcmp(key, "PublicChatTrigger") == 0)
|
||||||
{
|
{
|
||||||
delete [] m_PubTrigger;
|
SetChatTrigger(ChatTrigger_Public, value);
|
||||||
m_PubTrigger = sm_strdup(value);
|
|
||||||
m_PubTriggerSize = strlen(m_PubTrigger);
|
|
||||||
return ConfigResult_Accept;
|
return ConfigResult_Accept;
|
||||||
}
|
}
|
||||||
else if (strcmp(key, "SilentChatTrigger") == 0)
|
else if (strcmp(key, "SilentChatTrigger") == 0)
|
||||||
{
|
{
|
||||||
delete [] m_PrivTrigger;
|
SetChatTrigger(ChatTrigger_Private, value);
|
||||||
m_PrivTrigger = sm_strdup(value);
|
|
||||||
m_PrivTriggerSize = strlen(m_PrivTrigger);
|
|
||||||
return ConfigResult_Accept;
|
return ConfigResult_Accept;
|
||||||
}
|
}
|
||||||
else if (strcmp(key, "SilentFailSuppress") == 0)
|
else if (strcmp(key, "SilentFailSuppress") == 0)
|
||||||
@@ -124,70 +127,43 @@ void ChatTriggers::OnSourceModAllInitialized_Post()
|
|||||||
|
|
||||||
void ChatTriggers::OnSourceModGameInitialized()
|
void ChatTriggers::OnSourceModGameInitialized()
|
||||||
{
|
{
|
||||||
m_pSayCmd = FindCommand("say");
|
ConCommand *say_team = FindCommand("say_team");
|
||||||
m_pSayTeamCmd = FindCommand("say_team");
|
|
||||||
|
|
||||||
if (m_pSayCmd)
|
CommandHook::Callback pre_hook = [this] (int client, const ICommandArgs *args) -> bool {
|
||||||
{
|
return this->OnSayCommand_Pre(client, args);
|
||||||
SH_ADD_HOOK(ConCommand, Dispatch, m_pSayCmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Pre), false);
|
};
|
||||||
SH_ADD_HOOK(ConCommand, Dispatch, m_pSayCmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Post), true);
|
CommandHook::Callback post_hook = [this] (int client, const ICommandArgs *args) -> bool {
|
||||||
|
return this->OnSayCommand_Post(client, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (ConCommand *say = FindCommand("say")) {
|
||||||
|
hooks_.push_back(sCoreProviderImpl.AddCommandHook(say, pre_hook));
|
||||||
|
hooks_.push_back(sCoreProviderImpl.AddPostCommandHook(say, post_hook));
|
||||||
}
|
}
|
||||||
if (m_pSayTeamCmd)
|
if (ConCommand *say_team = FindCommand("say_team")) {
|
||||||
{
|
hooks_.push_back(sCoreProviderImpl.AddCommandHook(say_team, pre_hook));
|
||||||
SH_ADD_HOOK(ConCommand, Dispatch, m_pSayTeamCmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Pre), false);
|
hooks_.push_back(sCoreProviderImpl.AddPostCommandHook(say_team, post_hook));
|
||||||
SH_ADD_HOOK(ConCommand, Dispatch, m_pSayTeamCmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Post), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_EPISODEONE
|
#if SOURCE_ENGINE == SE_EPISODEONE
|
||||||
m_bIsINS = (strcmp(g_SourceMod.GetGameFolderName(), "insurgency") == 0);
|
m_bIsINS = (strcmp(g_SourceMod.GetGameFolderName(), "insurgency") == 0);
|
||||||
|
if (m_bIsINS) {
|
||||||
if (m_bIsINS)
|
if (ConCommand *say2 = FindCommand("say2")) {
|
||||||
{
|
hooks_.push_back(sCoreProviderImpl.AddCommandHook(say2, pre_hook));
|
||||||
m_pSay2Cmd = FindCommand("say2");
|
hooks_.push_back(sCoreProviderImpl.AddPostCommandHook(say2, post_hook));
|
||||||
if (m_pSay2Cmd)
|
|
||||||
{
|
|
||||||
SH_ADD_HOOK(ConCommand, Dispatch, m_pSay2Cmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Pre), false);
|
|
||||||
SH_ADD_HOOK(ConCommand, Dispatch, m_pSay2Cmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Post), true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif SOURCE_ENGINE == SE_NUCLEARDAWN
|
#elif SOURCE_ENGINE == SE_NUCLEARDAWN
|
||||||
m_pSaySquadCmd = FindCommand("say_squad");
|
if (ConCommand *say_squad = FindCommand("say_squad")) {
|
||||||
|
hooks_.push_back(sCoreProviderImpl.AddCommandHook(say_squad, pre_hook));
|
||||||
if (m_pSaySquadCmd)
|
hooks_.push_back(sCoreProviderImpl.AddPostCommandHook(say_squad, post_hook));
|
||||||
{
|
|
||||||
SH_ADD_HOOK(ConCommand, Dispatch, m_pSaySquadCmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Pre), false);
|
|
||||||
SH_ADD_HOOK(ConCommand, Dispatch, m_pSaySquadCmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Post), true);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatTriggers::OnSourceModShutdown()
|
void ChatTriggers::OnSourceModShutdown()
|
||||||
{
|
{
|
||||||
if (m_pSayCmd)
|
hooks_.clear();
|
||||||
{
|
|
||||||
SH_REMOVE_HOOK(ConCommand, Dispatch, m_pSayCmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Post), true);
|
|
||||||
SH_REMOVE_HOOK(ConCommand, Dispatch, m_pSayCmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Pre), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_pSayTeamCmd)
|
|
||||||
{
|
|
||||||
SH_REMOVE_HOOK(ConCommand, Dispatch, m_pSayTeamCmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Post), true);
|
|
||||||
SH_REMOVE_HOOK(ConCommand, Dispatch, m_pSayTeamCmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Pre), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_EPISODEONE
|
|
||||||
if (m_bIsINS && m_pSay2Cmd)
|
|
||||||
{
|
|
||||||
SH_REMOVE_HOOK(ConCommand, Dispatch, m_pSay2Cmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Pre), false);
|
|
||||||
SH_REMOVE_HOOK(ConCommand, Dispatch, m_pSay2Cmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Post), true);
|
|
||||||
}
|
|
||||||
#elif SOURCE_ENGINE == SE_NUCLEARDAWN
|
|
||||||
if (m_pSaySquadCmd)
|
|
||||||
{
|
|
||||||
SH_REMOVE_HOOK(ConCommand, Dispatch, m_pSaySquadCmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Pre), false);
|
|
||||||
SH_REMOVE_HOOK(ConCommand, Dispatch, m_pSaySquadCmd, SH_MEMBER(this, &ChatTriggers::OnSayCommand_Post), true);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
forwardsys->ReleaseForward(m_pShouldFloodBlock);
|
forwardsys->ReleaseForward(m_pShouldFloodBlock);
|
||||||
forwardsys->ReleaseForward(m_pDidFloodBlock);
|
forwardsys->ReleaseForward(m_pDidFloodBlock);
|
||||||
@@ -195,32 +171,20 @@ void ChatTriggers::OnSourceModShutdown()
|
|||||||
forwardsys->ReleaseForward(m_pOnClientSayCmd_Post);
|
forwardsys->ReleaseForward(m_pOnClientSayCmd_Post);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
bool ChatTriggers::OnSayCommand_Pre(int client, const ICommandArgs *command)
|
||||||
void ChatTriggers::OnSayCommand_Pre(const CCommandContext &context, const CCommand &command)
|
|
||||||
{
|
{
|
||||||
#elif SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
void ChatTriggers::OnSayCommand_Pre(const CCommand &command)
|
|
||||||
{
|
|
||||||
#else
|
|
||||||
void ChatTriggers::OnSayCommand_Pre()
|
|
||||||
{
|
|
||||||
CCommand command;
|
|
||||||
#endif
|
|
||||||
int client = g_ConCmds.GetCommandClient();
|
|
||||||
m_bIsChatTrigger = false;
|
m_bIsChatTrigger = false;
|
||||||
m_bWasFloodedMessage = false;
|
m_bWasFloodedMessage = false;
|
||||||
m_bPluginIgnored = true;
|
m_bPluginIgnored = true;
|
||||||
|
|
||||||
const char *args = command.ArgS();
|
const char *args = command->ArgS();
|
||||||
|
|
||||||
if (!args)
|
if (!args)
|
||||||
{
|
return false;
|
||||||
RETURN_META(MRES_IGNORED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Save these off for post hook as the command data returned from the engine in older engine versions
|
/* Save these off for post hook as the command data returned from the engine in older engine versions
|
||||||
* can be NULL, despite the data still being there and valid. */
|
* can be NULL, despite the data still being there and valid. */
|
||||||
m_Arg0Backup = command.Arg(0);
|
m_Arg0Backup = command->Arg(0);
|
||||||
size_t len = strlen(args);
|
size_t len = strlen(args);
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_EPISODEONE
|
#if SOURCE_ENGINE == SE_EPISODEONE
|
||||||
@@ -233,9 +197,7 @@ void ChatTriggers::OnSayCommand_Pre()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
{
|
return true;
|
||||||
RETURN_META(MRES_SUPERCEDE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -246,16 +208,14 @@ void ChatTriggers::OnSayCommand_Pre()
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
#if SOURCE_ENGINE == SE_EPISODEONE
|
#if SOURCE_ENGINE == SE_EPISODEONE
|
||||||
!m_bIsINS &&
|
!m_bIsINS &&
|
||||||
#endif
|
#endif
|
||||||
client != 0 && args[0] == '"' && args[len-1] == '"')
|
client != 0 && args[0] == '"' && args[len-1] == '"')
|
||||||
{
|
{
|
||||||
/* The server normally won't display empty say commands, but in this case it does.
|
/* The server normally won't display empty say commands, but in this case it does.
|
||||||
* I don't think it's desired so let's block it. */
|
* I don't think it's desired so let's block it. */
|
||||||
if (len <= 2)
|
if (len <= 2)
|
||||||
{
|
return true;
|
||||||
RETURN_META(MRES_SUPERCEDE);
|
|
||||||
}
|
|
||||||
|
|
||||||
args++;
|
args++;
|
||||||
len--;
|
len--;
|
||||||
@@ -284,20 +244,16 @@ void ChatTriggers::OnSayCommand_Pre()
|
|||||||
if (client == 0)
|
if (client == 0)
|
||||||
{
|
{
|
||||||
if (CallOnClientSayCommand(client) >= Pl_Handled)
|
if (CallOnClientSayCommand(client) >= Pl_Handled)
|
||||||
{
|
return true;
|
||||||
RETURN_META(MRES_SUPERCEDE);
|
|
||||||
}
|
|
||||||
|
|
||||||
RETURN_META(MRES_IGNORED);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
||||||
|
|
||||||
/* We guarantee the client is connected */
|
/* We guarantee the client is connected */
|
||||||
if (!pPlayer || !pPlayer->IsConnected())
|
if (!pPlayer || !pPlayer->IsConnected())
|
||||||
{
|
return false;
|
||||||
RETURN_META(MRES_IGNORED);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if we need to block this message from being sent */
|
/* Check if we need to block this message from being sent */
|
||||||
if (ClientIsFlooding(client))
|
if (ClientIsFlooding(client))
|
||||||
@@ -305,33 +261,32 @@ void ChatTriggers::OnSayCommand_Pre()
|
|||||||
char buffer[128];
|
char buffer[128];
|
||||||
|
|
||||||
if (!logicore.CoreTranslate(buffer, sizeof(buffer), "%T", 2, NULL, "Flooding the server", &client))
|
if (!logicore.CoreTranslate(buffer, sizeof(buffer), "%T", 2, NULL, "Flooding the server", &client))
|
||||||
UTIL_Format(buffer, sizeof(buffer), "You are flooding the server!");
|
ke::SafeSprintf(buffer, sizeof(buffer), "You are flooding the server!");
|
||||||
|
|
||||||
/* :TODO: we should probably kick people who spam too much. */
|
/* :TODO: we should probably kick people who spam too much. */
|
||||||
|
|
||||||
char fullbuffer[192];
|
char fullbuffer[192];
|
||||||
UTIL_Format(fullbuffer, sizeof(fullbuffer), "[SM] %s", buffer);
|
ke::SafeSprintf(fullbuffer, sizeof(fullbuffer), "[SM] %s", buffer);
|
||||||
g_HL2.TextMsg(client, HUD_PRINTTALK, fullbuffer);
|
g_HL2.TextMsg(client, HUD_PRINTTALK, fullbuffer);
|
||||||
|
|
||||||
m_bWasFloodedMessage = true;
|
m_bWasFloodedMessage = true;
|
||||||
|
return true;
|
||||||
RETURN_META(MRES_SUPERCEDE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_trigger = false;
|
bool is_trigger = false;
|
||||||
bool is_silent = false;
|
bool is_silent = false;
|
||||||
|
|
||||||
/* Check for either trigger */
|
// Prefer the silent trigger in case of clashes.
|
||||||
if (m_PubTriggerSize && strncmp(m_ArgSBackup, m_PubTrigger, m_PubTriggerSize) == 0)
|
if (strchr(m_PrivTrigger.c_str(), m_ArgSBackup[0])) {
|
||||||
{
|
|
||||||
is_trigger = true;
|
|
||||||
args = &m_ArgSBackup[m_PubTriggerSize];
|
|
||||||
}
|
|
||||||
else if (m_PrivTriggerSize && strncmp(m_ArgSBackup, m_PrivTrigger, m_PrivTriggerSize) == 0)
|
|
||||||
{
|
|
||||||
is_trigger = true;
|
is_trigger = true;
|
||||||
is_silent = true;
|
is_silent = true;
|
||||||
args = &m_ArgSBackup[m_PrivTriggerSize];
|
} else if (strchr(m_PubTrigger.c_str(), m_ArgSBackup[0])) {
|
||||||
|
is_trigger = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_trigger) {
|
||||||
|
// Bump the args past the chat trigger - we only support single-character triggers now.
|
||||||
|
args = &m_ArgSBackup[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -348,29 +303,17 @@ void ChatTriggers::OnSayCommand_Pre()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_silent && (m_bIsChatTrigger || (g_bSupressSilentFails && pPlayer->GetAdminId() != INVALID_ADMIN_ID)))
|
if (is_silent && (m_bIsChatTrigger || (g_bSupressSilentFails && pPlayer->GetAdminId() != INVALID_ADMIN_ID)))
|
||||||
{
|
return true;
|
||||||
RETURN_META(MRES_SUPERCEDE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CallOnClientSayCommand(client) >= Pl_Handled)
|
if (CallOnClientSayCommand(client) >= Pl_Handled)
|
||||||
{
|
return true;
|
||||||
RETURN_META(MRES_SUPERCEDE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Otherwise, let the command continue */
|
/* Otherwise, let the command continue */
|
||||||
RETURN_META(MRES_IGNORED);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
bool ChatTriggers::OnSayCommand_Post(int client, const ICommandArgs *command)
|
||||||
void ChatTriggers::OnSayCommand_Post(const CCommandContext &context, const CCommand &command)
|
|
||||||
#elif SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
void ChatTriggers::OnSayCommand_Post(const CCommand &command)
|
|
||||||
#else
|
|
||||||
void ChatTriggers::OnSayCommand_Post()
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
int client = g_ConCmds.GetCommandClient();
|
|
||||||
|
|
||||||
if (m_bWillProcessInPost)
|
if (m_bWillProcessInPost)
|
||||||
{
|
{
|
||||||
/* Reset this for re-entrancy */
|
/* Reset this for re-entrancy */
|
||||||
@@ -378,11 +321,7 @@ void ChatTriggers::OnSayCommand_Post()
|
|||||||
|
|
||||||
/* Execute the cached command */
|
/* Execute the cached command */
|
||||||
unsigned int old = SetReplyTo(SM_REPLY_CHAT);
|
unsigned int old = SetReplyTo(SM_REPLY_CHAT);
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
|
||||||
engine->ClientCommand(client, "%s", m_ToExecute);
|
|
||||||
#else
|
|
||||||
serverpluginhelpers->ClientCommand(PEntityOfEntIndex(client), m_ToExecute);
|
serverpluginhelpers->ClientCommand(PEntityOfEntIndex(client), m_ToExecute);
|
||||||
#endif
|
|
||||||
SetReplyTo(old);
|
SetReplyTo(old);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,16 +335,17 @@ void ChatTriggers::OnSayCommand_Post()
|
|||||||
|
|
||||||
m_bIsChatTrigger = false;
|
m_bIsChatTrigger = false;
|
||||||
m_bWasFloodedMessage = false;
|
m_bWasFloodedMessage = false;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChatTriggers::PreProcessTrigger(edict_t *pEdict, const char *args)
|
bool ChatTriggers::PreProcessTrigger(edict_t *pEdict, const char *args)
|
||||||
{
|
{
|
||||||
/* Extract a command. This is kind of sloppy. */
|
/* Extract a command. This is kind of sloppy. */
|
||||||
char cmd_buf[64];
|
char cmd_buf[64];
|
||||||
size_t cmd_len = 0;
|
size_t cmd_len = 0;
|
||||||
const char *inptr = args;
|
const char *inptr = args;
|
||||||
while (*inptr != '\0'
|
while (*inptr != '\0'
|
||||||
&& !textparsers->IsWhitespace(inptr)
|
&& !textparsers->IsWhitespace(inptr)
|
||||||
&& *inptr != '"'
|
&& *inptr != '"'
|
||||||
&& cmd_len < sizeof(cmd_buf) - 1)
|
&& cmd_len < sizeof(cmd_buf) - 1)
|
||||||
{
|
{
|
||||||
@@ -423,17 +363,17 @@ bool ChatTriggers::PreProcessTrigger(edict_t *pEdict, const char *args)
|
|||||||
if (!g_ConCmds.LookForSourceModCommand(cmd_buf))
|
if (!g_ConCmds.LookForSourceModCommand(cmd_buf))
|
||||||
{
|
{
|
||||||
/* Check if we had an "sm_" prefix */
|
/* Check if we had an "sm_" prefix */
|
||||||
if (strncmp(cmd_buf, "sm_", 3) == 0)
|
if (strncasecmp(cmd_buf, "sm_", 3) == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now, prepend. Don't worry about the buffers. This will
|
/* Now, prepend. Don't worry about the buffers. This will
|
||||||
* work because the sizes are limited from earlier.
|
* work because the sizes are limited from earlier.
|
||||||
*/
|
*/
|
||||||
char new_buf[80];
|
char new_buf[80];
|
||||||
strcpy(new_buf, "sm_");
|
strcpy(new_buf, "sm_");
|
||||||
strncopy(&new_buf[3], cmd_buf, sizeof(new_buf)-3);
|
ke::SafeStrcpy(&new_buf[3], sizeof(new_buf)-3, cmd_buf);
|
||||||
|
|
||||||
/* Recheck */
|
/* Recheck */
|
||||||
if (!g_ConCmds.LookForSourceModCommand(new_buf))
|
if (!g_ConCmds.LookForSourceModCommand(new_buf))
|
||||||
@@ -447,17 +387,9 @@ bool ChatTriggers::PreProcessTrigger(edict_t *pEdict, const char *args)
|
|||||||
/* See if we need to do extra string manipulation */
|
/* See if we need to do extra string manipulation */
|
||||||
if (prepended)
|
if (prepended)
|
||||||
{
|
{
|
||||||
size_t len;
|
ke::SafeSprintf(m_ToExecute, sizeof(m_ToExecute), "sm_%s", args);
|
||||||
|
|
||||||
/* Check if we need to prepend sm_ */
|
|
||||||
if (prepended)
|
|
||||||
{
|
|
||||||
len = UTIL_Format(m_ToExecute, sizeof(m_ToExecute), "sm_%s", args);
|
|
||||||
} else {
|
|
||||||
len = strncopy(m_ToExecute, args, sizeof(m_ToExecute));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
strncopy(m_ToExecute, args, sizeof(m_ToExecute));
|
ke::SafeStrcpy(m_ToExecute, sizeof(m_ToExecute), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -529,3 +461,23 @@ bool ChatTriggers::WasFloodedMessage()
|
|||||||
{
|
{
|
||||||
return m_bWasFloodedMessage;
|
return m_bWasFloodedMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *ChatTriggers::GetPublicChatTrigger()
|
||||||
|
{
|
||||||
|
if (!m_PubTrigger.length())
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_PubTrigger.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *ChatTriggers::GetPrivateChatTrigger()
|
||||||
|
{
|
||||||
|
if (!m_PrivTrigger.length())
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_PrivTrigger.c_str();
|
||||||
|
}
|
||||||
|
|||||||
+19
-26
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod
|
* SourceMod
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
* This program is free software; you can redistribute it and/or modify it under
|
* This program is free software; you can redistribute it and/or modify it under
|
||||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
* Free Software Foundation.
|
* Free Software Foundation.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
* 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
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
@@ -34,9 +34,11 @@
|
|||||||
|
|
||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
|
#include "GameHooks.h"
|
||||||
#include <IGameHelpers.h>
|
#include <IGameHelpers.h>
|
||||||
#include <compat_wrappers.h>
|
#include <compat_wrappers.h>
|
||||||
#include <IForwardSys.h>
|
#include <IForwardSys.h>
|
||||||
|
#include <amtl/am-string.h>
|
||||||
|
|
||||||
class ChatTriggers : public SMGlobalClass
|
class ChatTriggers : public SMGlobalClass
|
||||||
{
|
{
|
||||||
@@ -48,43 +50,34 @@ public: //SMGlobalClass
|
|||||||
void OnSourceModAllInitialized_Post();
|
void OnSourceModAllInitialized_Post();
|
||||||
void OnSourceModGameInitialized();
|
void OnSourceModGameInitialized();
|
||||||
void OnSourceModShutdown();
|
void OnSourceModShutdown();
|
||||||
ConfigResult OnSourceModConfigChanged(const char *key,
|
ConfigResult OnSourceModConfigChanged(const char *key,
|
||||||
const char *value,
|
const char *value,
|
||||||
ConfigSource source,
|
ConfigSource source,
|
||||||
char *error,
|
char *error,
|
||||||
size_t maxlength);
|
size_t maxlength);
|
||||||
private: //ConCommand
|
private: //ConCommand
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
bool OnSayCommand_Pre(int client, const ICommandArgs *args);
|
||||||
void OnSayCommand_Pre(const CCommandContext &, const CCommand &command);
|
bool OnSayCommand_Post(int client, const ICommandArgs *args);
|
||||||
void OnSayCommand_Post(const CCommandContext &, const CCommand &command);
|
|
||||||
#elif SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
void OnSayCommand_Pre(const CCommand &command);
|
|
||||||
void OnSayCommand_Post(const CCommand &command);
|
|
||||||
#else
|
|
||||||
void OnSayCommand_Pre();
|
|
||||||
void OnSayCommand_Post();
|
|
||||||
#endif
|
|
||||||
public:
|
public:
|
||||||
unsigned int GetReplyTo();
|
unsigned int GetReplyTo();
|
||||||
unsigned int SetReplyTo(unsigned int reply);
|
unsigned int SetReplyTo(unsigned int reply);
|
||||||
bool IsChatTrigger();
|
bool IsChatTrigger();
|
||||||
bool WasFloodedMessage();
|
bool WasFloodedMessage();
|
||||||
|
const char *GetPublicChatTrigger();
|
||||||
|
const char *GetPrivateChatTrigger();
|
||||||
private:
|
private:
|
||||||
|
enum ChatTriggerType {
|
||||||
|
ChatTrigger_Public,
|
||||||
|
ChatTrigger_Private,
|
||||||
|
};
|
||||||
|
void SetChatTrigger(ChatTriggerType type, const char *value);
|
||||||
bool PreProcessTrigger(edict_t *pEdict, const char *args);
|
bool PreProcessTrigger(edict_t *pEdict, const char *args);
|
||||||
bool ClientIsFlooding(int client);
|
bool ClientIsFlooding(int client);
|
||||||
cell_t CallOnClientSayCommand(int client);
|
cell_t CallOnClientSayCommand(int client);
|
||||||
private:
|
private:
|
||||||
ConCommand *m_pSayCmd;
|
std::vector<ke::RefPtr<CommandHook>> hooks_;
|
||||||
ConCommand *m_pSayTeamCmd;
|
std::string m_PubTrigger;
|
||||||
#if SOURCE_ENGINE == SE_EPISODEONE
|
std::string m_PrivTrigger;
|
||||||
ConCommand *m_pSay2Cmd;
|
|
||||||
#elif SOURCE_ENGINE == SE_NUCLEARDAWN
|
|
||||||
ConCommand *m_pSaySquadCmd;
|
|
||||||
#endif
|
|
||||||
char *m_PubTrigger;
|
|
||||||
size_t m_PubTriggerSize;
|
|
||||||
char *m_PrivTrigger;
|
|
||||||
size_t m_PrivTriggerSize;
|
|
||||||
bool m_bWillProcessInPost;
|
bool m_bWillProcessInPost;
|
||||||
bool m_bIsChatTrigger;
|
bool m_bIsChatTrigger;
|
||||||
bool m_bWasFloodedMessage;
|
bool m_bWasFloodedMessage;
|
||||||
|
|||||||
+88
-142
@@ -30,33 +30,26 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ConCmdManager.h"
|
#include "ConCmdManager.h"
|
||||||
#include "sm_srvcmds.h"
|
|
||||||
#include "sm_stringutil.h"
|
#include <bridge/include/IScriptManager.h>
|
||||||
#include "PlayerManager.h"
|
|
||||||
#include "HalfLife2.h"
|
|
||||||
#include "ChatTriggers.h"
|
#include "ChatTriggers.h"
|
||||||
|
#include "HalfLife2.h"
|
||||||
|
#include "PlayerManager.h"
|
||||||
|
#include "command_args.h"
|
||||||
#include "logic_bridge.h"
|
#include "logic_bridge.h"
|
||||||
|
#include "provider.h"
|
||||||
|
#include "sm_stringutil.h"
|
||||||
|
#include "sourcemod.h"
|
||||||
|
|
||||||
using namespace ke;
|
using namespace ke;
|
||||||
|
|
||||||
ConCmdManager g_ConCmds;
|
ConCmdManager g_ConCmds;
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
typedef std::list<CmdHook *> PluginHookList;
|
||||||
SH_DECL_HOOK2_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommandContext &, const CCommand &);
|
|
||||||
#elif SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
SH_DECL_HOOK1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
|
|
||||||
#else
|
|
||||||
SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SH_DECL_HOOK1_void(IServerGameClients, SetCommandClient, SH_NOATTRIB, false, int);
|
|
||||||
|
|
||||||
typedef ke::LinkedList<CmdHook *> PluginHookList;
|
|
||||||
void RegisterInPlugin(CmdHook *hook);
|
void RegisterInPlugin(CmdHook *hook);
|
||||||
|
|
||||||
ConCmdManager::ConCmdManager()
|
ConCmdManager::ConCmdManager()
|
||||||
{
|
{
|
||||||
m_CmdClient = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConCmdManager::~ConCmdManager()
|
ConCmdManager::~ConCmdManager()
|
||||||
@@ -66,19 +59,16 @@ ConCmdManager::~ConCmdManager()
|
|||||||
void ConCmdManager::OnSourceModAllInitialized()
|
void ConCmdManager::OnSourceModAllInitialized()
|
||||||
{
|
{
|
||||||
scripts->AddPluginsListener(this);
|
scripts->AddPluginsListener(this);
|
||||||
g_RootMenu.AddRootConsoleCommand("cmds", "List console commands", this);
|
rootmenu->AddRootConsoleCommand3("cmds", "List console commands", this);
|
||||||
SH_ADD_HOOK(IServerGameClients, SetCommandClient, serverClients, SH_MEMBER(this, &ConCmdManager::SetCommandClient), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConCmdManager::OnSourceModShutdown()
|
void ConCmdManager::OnSourceModShutdown()
|
||||||
{
|
{
|
||||||
scripts->RemovePluginsListener(this);
|
scripts->RemovePluginsListener(this);
|
||||||
/* All commands should already be removed by the time we're done */
|
rootmenu->RemoveRootConsoleCommand("cmds", this);
|
||||||
SH_REMOVE_HOOK(IServerGameClients, SetCommandClient, serverClients, SH_MEMBER(this, &ConCmdManager::SetCommandClient), false);
|
|
||||||
g_RootMenu.RemoveRootConsoleCommand("cmds", this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConCmdManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name, bool is_read_safe)
|
void ConCmdManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name)
|
||||||
{
|
{
|
||||||
/* Whoa, first get its information struct */
|
/* Whoa, first get its information struct */
|
||||||
ConCmdInfo *pInfo;
|
ConCmdInfo *pInfo;
|
||||||
@@ -86,18 +76,18 @@ void ConCmdManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *na
|
|||||||
if (!m_Cmds.retrieve(name, &pInfo))
|
if (!m_Cmds.retrieve(name, &pInfo))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CmdHookList::iterator iter = pInfo->hooks.begin();
|
auto iter = pInfo->hooks.begin();
|
||||||
while (iter != pInfo->hooks.end())
|
while (iter != pInfo->hooks.end())
|
||||||
{
|
{
|
||||||
CmdHook *hook = *iter;
|
CmdHook *hook = *iter;
|
||||||
|
|
||||||
IPluginContext *pContext = hook->pf->GetParentContext();
|
IPluginContext *pContext = hook->pf->GetParentContext();
|
||||||
IPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext());
|
IPlugin *pPlugin = scripts->FindPluginByContext(pContext);
|
||||||
|
|
||||||
// The list is guaranteed to exist.
|
// The list is guaranteed to exist.
|
||||||
PluginHookList *list;
|
PluginHookList *list;
|
||||||
pPlugin->GetProperty("CommandList", (void **)&list, false);
|
pPlugin->GetProperty("CommandList", (void **)&list, false);
|
||||||
for (PluginHookList::iterator hiter = list->begin(); hiter != list->end(); hiter++)
|
for (auto hiter = list->begin(); hiter != list->end(); hiter++)
|
||||||
{
|
{
|
||||||
if (*hiter == hook)
|
if (*hiter == hook)
|
||||||
{
|
{
|
||||||
@@ -113,7 +103,7 @@ void ConCmdManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *na
|
|||||||
delete hook;
|
delete hook;
|
||||||
}
|
}
|
||||||
|
|
||||||
RemoveConCmd(pInfo, name, is_read_safe, false);
|
RemoveConCmd(pInfo, name, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConCmdManager::OnPluginDestroyed(IPlugin *plugin)
|
void ConCmdManager::OnPluginDestroyed(IPlugin *plugin)
|
||||||
@@ -122,7 +112,7 @@ void ConCmdManager::OnPluginDestroyed(IPlugin *plugin)
|
|||||||
if (!plugin->GetProperty("CommandList", (void **)&pList, true))
|
if (!plugin->GetProperty("CommandList", (void **)&pList, true))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PluginHookList::iterator iter = pList->begin();
|
auto iter = pList->begin();
|
||||||
while (iter != pList->end())
|
while (iter != pList->end())
|
||||||
{
|
{
|
||||||
CmdHook *hook = *iter;
|
CmdHook *hook = *iter;
|
||||||
@@ -131,8 +121,13 @@ void ConCmdManager::OnPluginDestroyed(IPlugin *plugin)
|
|||||||
if (hook->admin)
|
if (hook->admin)
|
||||||
hook->admin->group->hooks.remove(hook);
|
hook->admin->group->hooks.remove(hook);
|
||||||
|
|
||||||
if (hook->info->hooks.empty())
|
if (hook->info->hooks.empty()) {
|
||||||
RemoveConCmd(hook->info, hook->info->pCmd->GetName(), true, true);
|
RemoveConCmd(hook->info, hook->info->pCmd->GetName(), true);
|
||||||
|
}
|
||||||
|
else { // update plugin reference to next hook in line
|
||||||
|
auto next = *hook->info->hooks.begin();
|
||||||
|
next->info->pPlugin = next->plugin;
|
||||||
|
}
|
||||||
|
|
||||||
iter = pList->erase(iter);
|
iter = pList->erase(iter);
|
||||||
delete hook;
|
delete hook;
|
||||||
@@ -141,28 +136,13 @@ void ConCmdManager::OnPluginDestroyed(IPlugin *plugin)
|
|||||||
delete pList;
|
delete pList;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
void CommandCallback(DISPATCH_ARGS)
|
||||||
void CommandCallback(const CCommandContext &context, const CCommand &command)
|
|
||||||
{
|
{
|
||||||
#elif SOURCE_ENGINE >= SE_ORANGEBOX
|
DISPATCH_PROLOGUE;
|
||||||
void CommandCallback(const CCommand &command)
|
EngineArgs args(command);
|
||||||
{
|
|
||||||
#else
|
|
||||||
void CommandCallback()
|
|
||||||
{
|
|
||||||
CCommand command;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_HL2.PushCommandStack(&command);
|
AutoEnterCommand autoEnterCommand(&args);
|
||||||
|
g_ConCmds.InternalDispatch(sCoreProviderImpl.CommandClient(), &args);
|
||||||
g_ConCmds.InternalDispatch(command);
|
|
||||||
|
|
||||||
g_HL2.PopCommandStack();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConCmdManager::SetCommandClient(int client)
|
|
||||||
{
|
|
||||||
m_CmdClient = client + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConCmdInfo *ConCmdManager::FindInTrie(const char *name)
|
ConCmdInfo *ConCmdManager::FindInTrie(const char *name)
|
||||||
@@ -173,41 +153,24 @@ ConCmdInfo *ConCmdManager::FindInTrie(const char *name)
|
|||||||
return pInfo;
|
return pInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConCmdList::iterator ConCmdManager::FindInList(const char *cmd)
|
|
||||||
{
|
|
||||||
List<ConCmdInfo *>::iterator iter = m_CmdList.begin();
|
|
||||||
|
|
||||||
while (iter != m_CmdList.end())
|
|
||||||
{
|
|
||||||
if (strcasecmp((*iter)->pCmd->GetName(), cmd) == 0)
|
|
||||||
break;
|
|
||||||
iter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return iter;
|
|
||||||
}
|
|
||||||
|
|
||||||
ResultType ConCmdManager::DispatchClientCommand(int client, const char *cmd, int args, ResultType type)
|
ResultType ConCmdManager::DispatchClientCommand(int client, const char *cmd, int args, ResultType type)
|
||||||
{
|
{
|
||||||
ConCmdInfo *pInfo;
|
ConCmdInfo *pInfo = FindInTrie(cmd);
|
||||||
|
|
||||||
if ((pInfo = FindInTrie(cmd)) == NULL)
|
if (pInfo == NULL)
|
||||||
{
|
{
|
||||||
ConCmdList::iterator item = FindInList(cmd);
|
return type;
|
||||||
if (item == m_CmdList.end())
|
|
||||||
return type;
|
|
||||||
pInfo = *item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cell_t result = type;
|
cell_t result = type;
|
||||||
for (CmdHookList::iterator iter = pInfo->hooks.begin(); iter != pInfo->hooks.end(); iter++)
|
for (auto iter = pInfo->hooks.begin(); iter != pInfo->hooks.end(); iter++)
|
||||||
{
|
{
|
||||||
CmdHook *hook = *iter;
|
CmdHook *hook = *iter;
|
||||||
|
|
||||||
if (hook->type == CmdHook::Server || !hook->pf->IsRunnable())
|
if (hook->type == CmdHook::Server || !hook->pf->IsRunnable())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (hook->admin && !CheckAccess(client, cmd, hook->admin))
|
if (hook->admin && !CheckAccess(client, cmd, hook->admin.get()))
|
||||||
{
|
{
|
||||||
if (result < Pl_Handled)
|
if (result < Pl_Handled)
|
||||||
result = Pl_Handled;
|
result = Pl_Handled;
|
||||||
@@ -218,6 +181,7 @@ ResultType ConCmdManager::DispatchClientCommand(int client, const char *cmd, int
|
|||||||
hook->pf->PushCell(args);
|
hook->pf->PushCell(args);
|
||||||
|
|
||||||
cell_t tempres = result;
|
cell_t tempres = result;
|
||||||
|
|
||||||
if (hook->pf->Execute(&tempres) == SP_ERROR_NONE)
|
if (hook->pf->Execute(&tempres) == SP_ERROR_NONE)
|
||||||
{
|
{
|
||||||
if (tempres > result)
|
if (tempres > result)
|
||||||
@@ -230,15 +194,13 @@ ResultType ConCmdManager::DispatchClientCommand(int client, const char *cmd, int
|
|||||||
return (ResultType)result;
|
return (ResultType)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConCmdManager::InternalDispatch(const CCommand &command)
|
bool ConCmdManager::InternalDispatch(int client, const ICommandArgs *args)
|
||||||
{
|
{
|
||||||
int client = m_CmdClient;
|
|
||||||
|
|
||||||
if (client)
|
if (client)
|
||||||
{
|
{
|
||||||
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
||||||
if (!pPlayer || !pPlayer->IsConnected())
|
if (!pPlayer || !pPlayer->IsConnected())
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -252,17 +214,7 @@ void ConCmdManager::InternalDispatch(const CCommand &command)
|
|||||||
ConCmdInfo *pInfo = FindInTrie(cmd);
|
ConCmdInfo *pInfo = FindInTrie(cmd);
|
||||||
if (pInfo == NULL)
|
if (pInfo == NULL)
|
||||||
{
|
{
|
||||||
/* Unfortunately, we now have to do a slow lookup because Valve made client commands
|
return false;
|
||||||
* case-insensitive. We can't even use our sortedness.
|
|
||||||
*/
|
|
||||||
if (client == 0 && !engine->IsDedicatedServer())
|
|
||||||
return;
|
|
||||||
|
|
||||||
ConCmdList::iterator item = FindInList(cmd);
|
|
||||||
if (item == m_CmdList.end())
|
|
||||||
return;
|
|
||||||
|
|
||||||
pInfo = *item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is a hack to prevent say triggers from firing on messages that were
|
/* This is a hack to prevent say triggers from firing on messages that were
|
||||||
@@ -270,10 +222,10 @@ void ConCmdManager::InternalDispatch(const CCommand &command)
|
|||||||
* "nicer" when we expose explicit say hooks.
|
* "nicer" when we expose explicit say hooks.
|
||||||
*/
|
*/
|
||||||
if (g_ChatTriggers.WasFloodedMessage())
|
if (g_ChatTriggers.WasFloodedMessage())
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
cell_t result = Pl_Continue;
|
cell_t result = Pl_Continue;
|
||||||
int args = command.ArgC() - 1;
|
int argc = args->ArgC() - 1;
|
||||||
|
|
||||||
// On a listen server, sometimes the server host's client index can be set
|
// On a listen server, sometimes the server host's client index can be set
|
||||||
// as 0. So index 1 is passed to the command callback to correct this
|
// as 0. So index 1 is passed to the command callback to correct this
|
||||||
@@ -283,7 +235,7 @@ void ConCmdManager::InternalDispatch(const CCommand &command)
|
|||||||
: client;
|
: client;
|
||||||
int dedicatedClient = engine->IsDedicatedServer() ? 0 : g_Players.ListenClient();
|
int dedicatedClient = engine->IsDedicatedServer() ? 0 : g_Players.ListenClient();
|
||||||
|
|
||||||
for (CmdHookList::iterator iter = pInfo->hooks.begin(); iter != pInfo->hooks.end(); iter++)
|
for (auto iter = pInfo->hooks.begin(); iter != pInfo->hooks.end(); iter++)
|
||||||
{
|
{
|
||||||
CmdHook *hook = *iter;
|
CmdHook *hook = *iter;
|
||||||
|
|
||||||
@@ -298,7 +250,7 @@ void ConCmdManager::InternalDispatch(const CCommand &command)
|
|||||||
} else {
|
} else {
|
||||||
// Check admin rights if needed. realClient isn't needed since we
|
// Check admin rights if needed. realClient isn't needed since we
|
||||||
// should bypass admin checks if client == 0 anyway.
|
// should bypass admin checks if client == 0 anyway.
|
||||||
if (client && hook->admin && !CheckAccess(client, cmd, hook->admin))
|
if (client && hook->admin && !CheckAccess(client, cmd, hook->admin.get()))
|
||||||
{
|
{
|
||||||
if (result < Pl_Handled)
|
if (result < Pl_Handled)
|
||||||
result = Pl_Handled;
|
result = Pl_Handled;
|
||||||
@@ -309,7 +261,7 @@ void ConCmdManager::InternalDispatch(const CCommand &command)
|
|||||||
hook->pf->PushCell(realClient);
|
hook->pf->PushCell(realClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
hook->pf->PushCell(args);
|
hook->pf->PushCell(argc);
|
||||||
|
|
||||||
cell_t tempres = result;
|
cell_t tempres = result;
|
||||||
if (hook->pf->Execute(&tempres) == SP_ERROR_NONE)
|
if (hook->pf->Execute(&tempres) == SP_ERROR_NONE)
|
||||||
@@ -322,11 +274,9 @@ void ConCmdManager::InternalDispatch(const CCommand &command)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (result >= Pl_Handled)
|
if (result >= Pl_Handled)
|
||||||
{
|
return !pInfo->sourceMod;
|
||||||
if (!pInfo->sourceMod)
|
|
||||||
RETURN_META(MRES_SUPERCEDE);
|
return false;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin)
|
bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin)
|
||||||
@@ -346,20 +296,20 @@ bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmi
|
|||||||
char buffer[128];
|
char buffer[128];
|
||||||
if (!logicore.CoreTranslate(buffer, sizeof(buffer), "%T", 2, NULL, "No Access", &client))
|
if (!logicore.CoreTranslate(buffer, sizeof(buffer), "%T", 2, NULL, "No Access", &client))
|
||||||
{
|
{
|
||||||
UTIL_Format(buffer, sizeof(buffer), "You do not have access to this command");
|
ke::SafeStrcpy(buffer, sizeof(buffer), "You do not have access to this command");
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int replyto = g_ChatTriggers.GetReplyTo();
|
unsigned int replyto = g_ChatTriggers.GetReplyTo();
|
||||||
if (replyto == SM_REPLY_CONSOLE)
|
if (replyto == SM_REPLY_CONSOLE)
|
||||||
{
|
{
|
||||||
char fullbuffer[192];
|
char fullbuffer[192];
|
||||||
UTIL_Format(fullbuffer, sizeof(fullbuffer), "[SM] %s.\n", buffer);
|
ke::SafeSprintf(fullbuffer, sizeof(fullbuffer), "[SM] %s.\n", buffer);
|
||||||
pPlayer->PrintToConsole(fullbuffer);
|
pPlayer->PrintToConsole(fullbuffer);
|
||||||
}
|
}
|
||||||
else if (replyto == SM_REPLY_CHAT)
|
else if (replyto == SM_REPLY_CHAT)
|
||||||
{
|
{
|
||||||
char fullbuffer[192];
|
char fullbuffer[192];
|
||||||
UTIL_Format(fullbuffer, sizeof(fullbuffer), "[SM] %s.", buffer);
|
ke::SafeSprintf(fullbuffer, sizeof(fullbuffer), "[SM] %s.", buffer);
|
||||||
g_HL2.TextMsg(client, HUD_PRINTTALK, fullbuffer);
|
g_HL2.TextMsg(client, HUD_PRINTTALK, fullbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,9 +321,10 @@ bool ConCmdManager::AddAdminCommand(IPluginFunction *pFunction,
|
|||||||
const char *group,
|
const char *group,
|
||||||
int adminflags,
|
int adminflags,
|
||||||
const char *description,
|
const char *description,
|
||||||
int flags)
|
int flags,
|
||||||
|
IPlugin *pPlugin)
|
||||||
{
|
{
|
||||||
ConCmdInfo *pInfo = AddOrFindCommand(name, description, flags);
|
ConCmdInfo *pInfo = AddOrFindCommand(name, description, flags, pPlugin);
|
||||||
|
|
||||||
if (!pInfo)
|
if (!pInfo)
|
||||||
return false;
|
return false;
|
||||||
@@ -385,10 +336,10 @@ bool ConCmdManager::AddAdminCommand(IPluginFunction *pFunction,
|
|||||||
return false;
|
return false;
|
||||||
i->value = new CommandGroup();
|
i->value = new CommandGroup();
|
||||||
}
|
}
|
||||||
Ref<CommandGroup> cmdgroup = i->value;
|
RefPtr<CommandGroup> cmdgroup = i->value;
|
||||||
|
|
||||||
CmdHook *pHook = new CmdHook(CmdHook::Client, pInfo, pFunction, description);
|
CmdHook *pHook = new CmdHook(CmdHook::Client, pInfo, pFunction, description, pPlugin);
|
||||||
pHook->admin = new AdminCmdInfo(cmdgroup, adminflags);
|
pHook->admin = std::make_unique<AdminCmdInfo>(cmdgroup, adminflags);
|
||||||
|
|
||||||
/* First get the command group override, if any */
|
/* First get the command group override, if any */
|
||||||
bool override = adminsys->GetCommandOverride(group,
|
bool override = adminsys->GetCommandOverride(group,
|
||||||
@@ -408,7 +359,7 @@ bool ConCmdManager::AddAdminCommand(IPluginFunction *pFunction,
|
|||||||
pHook->admin->eflags = pHook->admin->flags;
|
pHook->admin->eflags = pHook->admin->flags;
|
||||||
pInfo->eflags = pHook->admin->eflags;
|
pInfo->eflags = pHook->admin->eflags;
|
||||||
|
|
||||||
cmdgroup->hooks.append(pHook);
|
cmdgroup->hooks.push_back(pHook);
|
||||||
pInfo->hooks.append(pHook);
|
pInfo->hooks.append(pHook);
|
||||||
RegisterInPlugin(pHook);
|
RegisterInPlugin(pHook);
|
||||||
return true;
|
return true;
|
||||||
@@ -417,15 +368,16 @@ bool ConCmdManager::AddAdminCommand(IPluginFunction *pFunction,
|
|||||||
bool ConCmdManager::AddServerCommand(IPluginFunction *pFunction,
|
bool ConCmdManager::AddServerCommand(IPluginFunction *pFunction,
|
||||||
const char *name,
|
const char *name,
|
||||||
const char *description,
|
const char *description,
|
||||||
int flags)
|
int flags,
|
||||||
|
IPlugin *pPlugin)
|
||||||
|
|
||||||
{
|
{
|
||||||
ConCmdInfo *pInfo = AddOrFindCommand(name, description, flags);
|
ConCmdInfo *pInfo = AddOrFindCommand(name, description, flags, pPlugin);
|
||||||
|
|
||||||
if (!pInfo)
|
if (!pInfo)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CmdHook *pHook = new CmdHook(CmdHook::Server, pInfo, pFunction, description);
|
CmdHook *pHook = new CmdHook(CmdHook::Server, pInfo, pFunction, description, pPlugin);
|
||||||
|
|
||||||
pInfo->hooks.append(pHook);
|
pInfo->hooks.append(pHook);
|
||||||
RegisterInPlugin(pHook);
|
RegisterInPlugin(pHook);
|
||||||
@@ -446,24 +398,24 @@ void RegisterInPlugin(CmdHook *hook)
|
|||||||
const char *orig = hook->info->pCmd->GetName();
|
const char *orig = hook->info->pCmd->GetName();
|
||||||
|
|
||||||
/* Insert this into the help list, SORTED alphabetically. */
|
/* Insert this into the help list, SORTED alphabetically. */
|
||||||
PluginHookList::iterator iter = pList->begin();
|
auto iter = pList->begin();
|
||||||
while (iter != pList->end())
|
while (iter != pList->end())
|
||||||
{
|
{
|
||||||
const char *cmd = (*iter)->info->pCmd->GetName();
|
const char *cmd = (*iter)->info->pCmd->GetName();
|
||||||
if (strcmp(orig, cmd) < 0)
|
if (strcmp(orig, cmd) < 0)
|
||||||
{
|
{
|
||||||
pList->insertBefore(iter, hook);
|
pList->emplace(iter, hook);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
pList->append(hook);
|
pList->emplace_back(hook);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConCmdManager::AddToCmdList(ConCmdInfo *info)
|
void ConCmdManager::AddToCmdList(ConCmdInfo *info)
|
||||||
{
|
{
|
||||||
List<ConCmdInfo *>::iterator iter = m_CmdList.begin();
|
auto iter = m_CmdList.begin();
|
||||||
ConCmdInfo *pInfo;
|
ConCmdInfo *pInfo;
|
||||||
bool inserted = false;
|
bool inserted = false;
|
||||||
const char *orig = NULL;
|
const char *orig = NULL;
|
||||||
@@ -499,7 +451,7 @@ void ConCmdManager::UpdateAdminCmdFlags(const char *cmd, OverrideType type, Flag
|
|||||||
if (!m_Cmds.retrieve(cmd, &pInfo))
|
if (!m_Cmds.retrieve(cmd, &pInfo))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (CmdHookList::iterator iter = pInfo->hooks.begin(); iter != pInfo->hooks.end(); iter++)
|
for (auto iter = pInfo->hooks.begin(); iter != pInfo->hooks.end(); iter++)
|
||||||
{
|
{
|
||||||
if (!iter->admin)
|
if (!iter->admin)
|
||||||
continue;
|
continue;
|
||||||
@@ -517,12 +469,12 @@ void ConCmdManager::UpdateAdminCmdFlags(const char *cmd, OverrideType type, Flag
|
|||||||
if (!r.found())
|
if (!r.found())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Ref<CommandGroup> group(r->value);
|
RefPtr<CommandGroup> group(r->value);
|
||||||
|
|
||||||
for (PluginHookList::iterator iter = group->hooks.begin(); iter != group->hooks.end(); iter++)
|
for (auto iter = group->hooks.begin(); iter != group->hooks.end(); iter++)
|
||||||
{
|
{
|
||||||
CmdHook *hook = *iter;
|
CmdHook *hook = *iter;
|
||||||
if (remove)
|
if (!remove)
|
||||||
hook->admin->eflags = bits;
|
hook->admin->eflags = bits;
|
||||||
else
|
else
|
||||||
hook->admin->eflags = hook->admin->flags;
|
hook->admin->eflags = hook->admin->flags;
|
||||||
@@ -531,7 +483,7 @@ void ConCmdManager::UpdateAdminCmdFlags(const char *cmd, OverrideType type, Flag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConCmdManager::RemoveConCmd(ConCmdInfo *info, const char *name, bool is_read_safe, bool untrack)
|
void ConCmdManager::RemoveConCmd(ConCmdInfo *info, const char *name, bool untrack)
|
||||||
{
|
{
|
||||||
/* Remove from the trie */
|
/* Remove from the trie */
|
||||||
m_Cmds.remove(name);
|
m_Cmds.remove(name);
|
||||||
@@ -554,15 +506,8 @@ void ConCmdManager::RemoveConCmd(ConCmdInfo *info, const char *name, bool is_rea
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (is_read_safe)
|
|
||||||
{
|
|
||||||
/* Remove the external hook */
|
|
||||||
SH_REMOVE_HOOK(ConCommand, Dispatch, info->pCmd, SH_STATIC(CommandCallback), false);
|
|
||||||
}
|
|
||||||
if (untrack)
|
if (untrack)
|
||||||
{
|
|
||||||
UntrackConCommandBase(info->pCmd, this);
|
UntrackConCommandBase(info->pCmd, this);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -591,15 +536,11 @@ bool ConCmdManager::LookForCommandAdminFlags(const char *cmd, FlagBits *pFlags)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConCmdInfo *ConCmdManager::AddOrFindCommand(const char *name, const char *description, int flags)
|
ConCmdInfo *ConCmdManager::AddOrFindCommand(const char *name, const char *description, int flags, IPlugin *pPlugin)
|
||||||
{
|
{
|
||||||
ConCmdInfo *pInfo;
|
ConCmdInfo *pInfo;
|
||||||
if (!m_Cmds.retrieve(name, &pInfo))
|
if (!m_Cmds.retrieve(name, &pInfo))
|
||||||
{
|
{
|
||||||
ConCmdList::iterator item = FindInList(name);
|
|
||||||
if (item != m_CmdList.end())
|
|
||||||
return *item;
|
|
||||||
|
|
||||||
pInfo = new ConCmdInfo();
|
pInfo = new ConCmdInfo();
|
||||||
/* Find the commandopan */
|
/* Find the commandopan */
|
||||||
ConCommand *pCmd = FindCommand(name);
|
ConCommand *pCmd = FindCommand(name);
|
||||||
@@ -616,12 +557,17 @@ ConCmdInfo *ConCmdManager::AddOrFindCommand(const char *name, const char *descri
|
|||||||
char *new_name = sm_strdup(name);
|
char *new_name = sm_strdup(name);
|
||||||
char *new_help = sm_strdup(description);
|
char *new_help = sm_strdup(description);
|
||||||
pCmd = new ConCommand(new_name, CommandCallback, new_help, flags);
|
pCmd = new ConCommand(new_name, CommandCallback, new_help, flags);
|
||||||
|
pInfo->pPlugin = pPlugin;
|
||||||
pInfo->sourceMod = true;
|
pInfo->sourceMod = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TrackConCommandBase(pCmd, this);
|
TrackConCommandBase(pCmd, this);
|
||||||
SH_ADD_HOOK(ConCommand, Dispatch, pCmd, SH_STATIC(CommandCallback), false);
|
CommandHook::Callback callback = [this] (int client, const ICommandArgs *args) -> bool {
|
||||||
|
AutoEnterCommand autoEnterCommand(args);
|
||||||
|
return this->InternalDispatch(client, args);
|
||||||
|
};
|
||||||
|
pInfo->sh_hook = sCoreProviderImpl.AddCommandHook(pCmd, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->pCmd = pCmd;
|
pInfo->pCmd = pCmd;
|
||||||
@@ -633,17 +579,17 @@ ConCmdInfo *ConCmdManager::AddOrFindCommand(const char *name, const char *descri
|
|||||||
return pInfo;
|
return pInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConCmdManager::OnRootConsoleCommand(const char *cmdname, const CCommand &command)
|
void ConCmdManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs *command)
|
||||||
{
|
{
|
||||||
if (command.ArgC() >= 3)
|
if (command->ArgC() >= 3)
|
||||||
{
|
{
|
||||||
const char *text = command.Arg(2);
|
const char *text = command->Arg(2);
|
||||||
|
|
||||||
IPlugin *pPlugin = scripts->FindPluginByConsoleArg(text);
|
IPlugin *pPlugin = scripts->FindPluginByConsoleArg(text);
|
||||||
|
|
||||||
if (!pPlugin)
|
if (!pPlugin)
|
||||||
{
|
{
|
||||||
g_RootMenu.ConsolePrint("[SM] Plugin \"%s\" was not found.", text);
|
UTIL_ConsolePrint("[SM] Plugin \"%s\" was not found.", text);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -653,21 +599,21 @@ void ConCmdManager::OnRootConsoleCommand(const char *cmdname, const CCommand &co
|
|||||||
PluginHookList *pList;
|
PluginHookList *pList;
|
||||||
if (!pPlugin->GetProperty("CommandList", (void **)&pList))
|
if (!pPlugin->GetProperty("CommandList", (void **)&pList))
|
||||||
{
|
{
|
||||||
g_RootMenu.ConsolePrint("[SM] No commands found for: %s", plname);
|
UTIL_ConsolePrint("[SM] No commands found for: %s", plname);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pList->empty())
|
if (pList->empty())
|
||||||
{
|
{
|
||||||
g_RootMenu.ConsolePrint("[SM] No commands found for: %s", plname);
|
UTIL_ConsolePrint("[SM] No commands found for: %s", plname);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *type = NULL;
|
const char *type = NULL;
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *help;
|
const char *help;
|
||||||
g_RootMenu.ConsolePrint("[SM] Listing commands for: %s", plname);
|
UTIL_ConsolePrint("[SM] Listing commands for: %s", plname);
|
||||||
g_RootMenu.ConsolePrint(" %-17.16s %-8.7s %s", "[Name]", "[Type]", "[Help]");
|
UTIL_ConsolePrint(" %-17.16s %-8.7s %s", "[Name]", "[Type]", "[Help]");
|
||||||
for (PluginHookList::iterator iter = pList->begin(); iter != pList->end(); iter++)
|
for (auto iter = pList->begin(); iter != pList->end(); iter++)
|
||||||
{
|
{
|
||||||
CmdHook *hook = *iter;
|
CmdHook *hook = *iter;
|
||||||
if (hook->type == CmdHook::Server)
|
if (hook->type == CmdHook::Server)
|
||||||
@@ -677,14 +623,14 @@ void ConCmdManager::OnRootConsoleCommand(const char *cmdname, const CCommand &co
|
|||||||
|
|
||||||
name = hook->info->pCmd->GetName();
|
name = hook->info->pCmd->GetName();
|
||||||
if (hook->helptext.length())
|
if (hook->helptext.length())
|
||||||
help = hook->helptext.chars();
|
help = hook->helptext.c_str();
|
||||||
else
|
else
|
||||||
help = hook->info->pCmd->GetHelpText();
|
help = hook->info->pCmd->GetHelpText();
|
||||||
g_RootMenu.ConsolePrint(" %-17.16s %-12.11s %s", name, type, help);
|
UTIL_ConsolePrint(" %-17.16s %-12.11s %s", name, type, help);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_RootMenu.ConsolePrint("[SM] Usage: sm cmds <plugin #>");
|
UTIL_ConsolePrint("[SM] Usage: sm cmds <plugin #>");
|
||||||
}
|
}
|
||||||
|
|||||||
+57
-45
@@ -32,39 +32,42 @@
|
|||||||
#ifndef _INCLUDE_SOURCEMOD_CONCMDMANAGER_H_
|
#ifndef _INCLUDE_SOURCEMOD_CONCMDMANAGER_H_
|
||||||
#define _INCLUDE_SOURCEMOD_CONCMDMANAGER_H_
|
#define _INCLUDE_SOURCEMOD_CONCMDMANAGER_H_
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <am-inlinelist.h>
|
||||||
|
#include <am-refcounting.h>
|
||||||
|
#include <am-utility.h>
|
||||||
|
#include <sm_hashmap.h>
|
||||||
|
|
||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
#include <IForwardSys.h>
|
#include <IForwardSys.h>
|
||||||
#include <sh_list.h>
|
#include <list>
|
||||||
#include <sh_string.h>
|
#include <string>
|
||||||
#include <IRootConsoleMenu.h>
|
#include <IRootConsoleMenu.h>
|
||||||
#include <IAdminSystem.h>
|
#include <IAdminSystem.h>
|
||||||
#include "concmd_cleaner.h"
|
#include "concmd_cleaner.h"
|
||||||
#include <sm_stringhashmap.h>
|
#include "GameHooks.h"
|
||||||
#include <am-utility.h>
|
#include <sm_namehashset.h>
|
||||||
#include <am-inlinelist.h>
|
|
||||||
#include <am-linkedlist.h>
|
|
||||||
#include <am-refcounting.h>
|
|
||||||
|
|
||||||
using namespace SourceHook;
|
|
||||||
|
|
||||||
struct CmdHook;
|
struct CmdHook;
|
||||||
struct ConCmdInfo;
|
struct ConCmdInfo;
|
||||||
|
|
||||||
struct CommandGroup : public ke::Refcounted<CommandGroup>
|
struct CommandGroup : public ke::Refcounted<CommandGroup>
|
||||||
{
|
{
|
||||||
ke::LinkedList<CmdHook *> hooks;
|
std::list<CmdHook *> hooks;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct AdminCmdInfo
|
struct AdminCmdInfo
|
||||||
{
|
{
|
||||||
AdminCmdInfo(const ke::Ref<CommandGroup> &group, FlagBits flags)
|
AdminCmdInfo(const ke::RefPtr<CommandGroup> &group, FlagBits flags)
|
||||||
: group(group),
|
: group(group),
|
||||||
flags(flags),
|
flags(flags),
|
||||||
eflags(0)
|
eflags(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
ke::Ref<CommandGroup> group;
|
ke::RefPtr<CommandGroup> group;
|
||||||
FlagBits flags; /* default flags */
|
FlagBits flags; /* default flags */
|
||||||
FlagBits eflags; /* effective flags */
|
FlagBits eflags; /* effective flags */
|
||||||
};
|
};
|
||||||
@@ -76,10 +79,11 @@ struct CmdHook : public ke::InlineListNode<CmdHook>
|
|||||||
Client
|
Client
|
||||||
};
|
};
|
||||||
|
|
||||||
CmdHook(Type type, ConCmdInfo *cmd, IPluginFunction *fun, const char *description)
|
CmdHook(Type type, ConCmdInfo *cmd, IPluginFunction *fun, const char *description, IPlugin *plugin)
|
||||||
: type(type),
|
: type(type),
|
||||||
info(cmd),
|
info(cmd),
|
||||||
pf(fun),
|
pf(fun),
|
||||||
|
plugin(plugin),
|
||||||
helptext(description)
|
helptext(description)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -87,8 +91,9 @@ struct CmdHook : public ke::InlineListNode<CmdHook>
|
|||||||
Type type;
|
Type type;
|
||||||
ConCmdInfo *info;
|
ConCmdInfo *info;
|
||||||
IPluginFunction *pf; /* function hook */
|
IPluginFunction *pf; /* function hook */
|
||||||
ke::AString helptext; /* help text */
|
IPlugin *plugin; /* owning plugin */
|
||||||
ke::AutoPtr<AdminCmdInfo> admin; /* admin requirements, if any */
|
std::string helptext; /* help text */
|
||||||
|
std::unique_ptr<AdminCmdInfo> admin; /* admin requirements, if any */
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef ke::InlineList<CmdHook> CmdHookList;
|
typedef ke::InlineList<CmdHook> CmdHookList;
|
||||||
@@ -97,17 +102,40 @@ struct ConCmdInfo
|
|||||||
{
|
{
|
||||||
ConCmdInfo()
|
ConCmdInfo()
|
||||||
{
|
{
|
||||||
|
pPlugin = nullptr;
|
||||||
sourceMod = false;
|
sourceMod = false;
|
||||||
pCmd = NULL;
|
pCmd = nullptr;
|
||||||
eflags = 0;
|
eflags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool sourceMod; /**< Determines whether or not concmd was created by a SourceMod plugin */
|
bool sourceMod; /**< Determines whether or not concmd was created by a SourceMod plugin */
|
||||||
ConCommand *pCmd; /**< Pointer to the command itself */
|
ConCommand *pCmd; /**< Pointer to the command itself */
|
||||||
CmdHookList hooks; /**< Hook list */
|
CmdHookList hooks; /**< Hook list */
|
||||||
FlagBits eflags; /**< Effective admin flags */
|
FlagBits eflags; /**< Effective admin flags */
|
||||||
|
ke::RefPtr<CommandHook> sh_hook; /**< SourceHook hook, if any. */
|
||||||
|
IPlugin *pPlugin; /**< Owning plugin handle. */
|
||||||
|
|
||||||
|
struct ConCmdPolicy
|
||||||
|
{
|
||||||
|
static inline bool matches(const char *name, ConCmdInfo *info)
|
||||||
|
{
|
||||||
|
const char *conCmdChars = info->pCmd->GetName();
|
||||||
|
|
||||||
|
std::string concmdName = ke::Lowercase(conCmdChars);
|
||||||
|
std::string input = ke::Lowercase(name);
|
||||||
|
|
||||||
|
return concmdName == input;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t hash(const detail::CharsAndLength &key)
|
||||||
|
{
|
||||||
|
std::string lower = ke::Lowercase(key.c_str());
|
||||||
|
return detail::CharsAndLength(lower.c_str()).hash();
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef List<ConCmdInfo *> ConCmdList;
|
typedef std::list<ConCmdInfo *> ConCmdList;
|
||||||
|
|
||||||
class ConCmdManager :
|
class ConCmdManager :
|
||||||
public SMGlobalClass,
|
public SMGlobalClass,
|
||||||
@@ -115,13 +143,7 @@ class ConCmdManager :
|
|||||||
public IPluginsListener,
|
public IPluginsListener,
|
||||||
public IConCommandTracker
|
public IConCommandTracker
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
friend void CommandCallback(DISPATCH_ARGS);
|
||||||
friend void CommandCallback(const CCommandContext &context, const CCommand &command);
|
|
||||||
#elif SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
friend void CommandCallback(const CCommand &command);
|
|
||||||
#else
|
|
||||||
friend void CommandCallback();
|
|
||||||
#endif
|
|
||||||
public:
|
public:
|
||||||
ConCmdManager();
|
ConCmdManager();
|
||||||
~ConCmdManager();
|
~ConCmdManager();
|
||||||
@@ -131,51 +153,41 @@ public: //SMGlobalClass
|
|||||||
public: //IPluginsListener
|
public: //IPluginsListener
|
||||||
void OnPluginDestroyed(IPlugin *plugin);
|
void OnPluginDestroyed(IPlugin *plugin);
|
||||||
public: //IRootConsoleCommand
|
public: //IRootConsoleCommand
|
||||||
void OnRootConsoleCommand(const char *cmdname, const CCommand &command);
|
void OnRootConsoleCommand(const char *cmdname, const ICommandArgs *command) override;
|
||||||
public: //IConCommandTracker
|
public: //IConCommandTracker
|
||||||
void OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name, bool is_read_safe);
|
void OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name) override;
|
||||||
public:
|
public:
|
||||||
bool AddServerCommand(IPluginFunction *pFunction, const char *name, const char *description, int flags);
|
bool AddServerCommand(IPluginFunction *pFunction, const char *name, const char *description, int flags, IPlugin *pPlugin);
|
||||||
bool AddAdminCommand(IPluginFunction *pFunction,
|
bool AddAdminCommand(IPluginFunction *pFunction,
|
||||||
const char *name,
|
const char *name,
|
||||||
const char *group,
|
const char *group,
|
||||||
int adminflags,
|
int adminflags,
|
||||||
const char *description,
|
const char *description,
|
||||||
int flags);
|
int flags,
|
||||||
|
IPlugin *pPlugin);
|
||||||
ResultType DispatchClientCommand(int client, const char *cmd, int args, ResultType type);
|
ResultType DispatchClientCommand(int client, const char *cmd, int args, ResultType type);
|
||||||
void UpdateAdminCmdFlags(const char *cmd, OverrideType type, FlagBits bits, bool remove);
|
void UpdateAdminCmdFlags(const char *cmd, OverrideType type, FlagBits bits, bool remove);
|
||||||
bool LookForSourceModCommand(const char *cmd);
|
bool LookForSourceModCommand(const char *cmd);
|
||||||
bool LookForCommandAdminFlags(const char *cmd, FlagBits *pFlags);
|
bool LookForCommandAdminFlags(const char *cmd, FlagBits *pFlags);
|
||||||
private:
|
private:
|
||||||
void InternalDispatch(const CCommand &command);
|
bool InternalDispatch(int client, const ICommandArgs *args);
|
||||||
ResultType RunAdminCommand(ConCmdInfo *pInfo, int client, int args);
|
ResultType RunAdminCommand(ConCmdInfo *pInfo, int client, int args);
|
||||||
ConCmdInfo *AddOrFindCommand(const char *name, const char *description, int flags);
|
ConCmdInfo *AddOrFindCommand(const char *name, const char *description, int flags, IPlugin *pPlugin);
|
||||||
void SetCommandClient(int client);
|
|
||||||
void AddToCmdList(ConCmdInfo *info);
|
void AddToCmdList(ConCmdInfo *info);
|
||||||
void RemoveConCmd(ConCmdInfo *info, const char *cmd, bool is_read_safe, bool untrack);
|
void RemoveConCmd(ConCmdInfo *info, const char *cmd, bool untrack);
|
||||||
bool CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin);
|
bool CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin);
|
||||||
|
|
||||||
// Case insensitive
|
|
||||||
ConCmdList::iterator FindInList(const char *name);
|
|
||||||
|
|
||||||
// Case sensitive
|
|
||||||
ConCmdInfo *FindInTrie(const char *name);
|
ConCmdInfo *FindInTrie(const char *name);
|
||||||
public:
|
public:
|
||||||
inline int GetCommandClient()
|
inline const std::list<ConCmdInfo *> & GetCommandList()
|
||||||
{
|
|
||||||
return m_CmdClient;
|
|
||||||
}
|
|
||||||
inline const List<ConCmdInfo *> & GetCommandList()
|
|
||||||
{
|
{
|
||||||
return m_CmdList;
|
return m_CmdList;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
typedef StringHashMap<ke::Ref<CommandGroup> > GroupMap;
|
typedef StringHashMap<ke::RefPtr<CommandGroup> > GroupMap;
|
||||||
|
|
||||||
StringHashMap<ConCmdInfo *> m_Cmds; /* command lookup */
|
NameHashSet<ConCmdInfo *, ConCmdInfo::ConCmdPolicy> m_Cmds; /* command lookup */
|
||||||
GroupMap m_CmdGrps; /* command group map */
|
GroupMap m_CmdGrps; /* command group map */
|
||||||
ConCmdList m_CmdList; /* command list */
|
ConCmdList m_CmdList; /* command list */
|
||||||
int m_CmdClient; /* current client */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ConCmdManager g_ConCmds;
|
extern ConCmdManager g_ConCmds;
|
||||||
|
|||||||
+91
-179
@@ -29,31 +29,23 @@
|
|||||||
|
|
||||||
#include "ConVarManager.h"
|
#include "ConVarManager.h"
|
||||||
#include "HalfLife2.h"
|
#include "HalfLife2.h"
|
||||||
#include "sm_srvcmds.h"
|
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
#include <sh_vector.h>
|
#include <vector>
|
||||||
#include <sm_namehashset.h>
|
#include <sm_namehashset.h>
|
||||||
#include "logic_bridge.h"
|
#include "logic_bridge.h"
|
||||||
|
#include "sourcemod.h"
|
||||||
|
#include "provider.h"
|
||||||
|
#include <bridge/include/IScriptManager.h>
|
||||||
|
|
||||||
ConVarManager g_ConVarManager;
|
ConVarManager g_ConVarManager;
|
||||||
|
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
SH_DECL_HOOK3_void(ICvar, CallGlobalChangeCallbacks, SH_NOATTRIB, false, ConVar *, const char *, float);
|
|
||||||
#else
|
|
||||||
SH_DECL_HOOK2_void(ICvar, CallGlobalChangeCallback, SH_NOATTRIB, false, ConVar *, const char *);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
|
||||||
SH_DECL_HOOK5_void(IServerGameDLL, OnQueryCvarValueFinished, SH_NOATTRIB, 0, QueryCvarCookie_t, CEntityIndex, EQueryCvarValueStatus, const char *, const char *);
|
|
||||||
SH_DECL_HOOK5_void(IServerPluginCallbacks, OnQueryCvarValueFinished, SH_NOATTRIB, 0, QueryCvarCookie_t, CEntityIndex, EQueryCvarValueStatus, const char *, const char *);
|
|
||||||
#elif SOURCE_ENGINE != SE_DARKMESSIAH
|
|
||||||
SH_DECL_HOOK5_void(IServerGameDLL, OnQueryCvarValueFinished, SH_NOATTRIB, 0, QueryCvarCookie_t, edict_t *, EQueryCvarValueStatus, const char *, const char *);
|
|
||||||
SH_DECL_HOOK5_void(IServerPluginCallbacks, OnQueryCvarValueFinished, SH_NOATTRIB, 0, QueryCvarCookie_t, edict_t *, EQueryCvarValueStatus, const char *, const char *);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const ParamType CONVARCHANGE_PARAMS[] = {Param_Cell, Param_String, Param_String};
|
const ParamType CONVARCHANGE_PARAMS[] = {Param_Cell, Param_String, Param_String};
|
||||||
typedef List<const ConVar *> ConVarList;
|
typedef std::list<const ConVar *> ConVarList;
|
||||||
NameHashSet<ConVarInfo *> convar_cache;
|
NameHashSet<ConVarInfo *, ConVarInfo::ConVarPolicy> convar_cache;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
eQueryCvarValueStatus_Cancelled = -1,
|
||||||
|
};
|
||||||
|
|
||||||
class ConVarReentrancyGuard
|
class ConVarReentrancyGuard
|
||||||
{
|
{
|
||||||
@@ -89,7 +81,7 @@ public:
|
|||||||
|
|
||||||
ConVarReentrancyGuard *ConVarReentrancyGuard::chain = NULL;
|
ConVarReentrancyGuard *ConVarReentrancyGuard::chain = NULL;
|
||||||
|
|
||||||
ConVarManager::ConVarManager() : m_ConVarType(0), m_bIsDLLQueryHooked(false), m_bIsVSPQueryHooked(false)
|
ConVarManager::ConVarManager() : m_ConVarType(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,34 +104,17 @@ void ConVarManager::OnSourceModStartup(bool late)
|
|||||||
|
|
||||||
void ConVarManager::OnSourceModAllInitialized()
|
void ConVarManager::OnSourceModAllInitialized()
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Episode 2 has this function by default, but the older versions do not.
|
|
||||||
*/
|
|
||||||
#if SOURCE_ENGINE == SE_EPISODEONE
|
|
||||||
if (g_SMAPI->GetGameDLLVersion() >= 6)
|
|
||||||
{
|
|
||||||
SH_ADD_HOOK(IServerGameDLL, OnQueryCvarValueFinished, gamedll, SH_MEMBER(this, &ConVarManager::OnQueryCvarValueFinished), false);
|
|
||||||
m_bIsDLLQueryHooked = true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_Players.AddClientListener(this);
|
g_Players.AddClientListener(this);
|
||||||
|
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
SH_ADD_HOOK(ICvar, CallGlobalChangeCallbacks, icvar, SH_STATIC(OnConVarChanged), false);
|
|
||||||
#else
|
|
||||||
SH_ADD_HOOK(ICvar, CallGlobalChangeCallback, icvar, SH_STATIC(OnConVarChanged), false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
scripts->AddPluginsListener(this);
|
scripts->AddPluginsListener(this);
|
||||||
|
|
||||||
/* Add the 'convars' option to the 'sm' console command */
|
/* Add the 'convars' option to the 'sm' console command */
|
||||||
g_RootMenu.AddRootConsoleCommand("cvars", "View convars created by a plugin", this);
|
rootmenu->AddRootConsoleCommand3("cvars", "View convars created by a plugin", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConVarManager::OnSourceModShutdown()
|
void ConVarManager::OnSourceModShutdown()
|
||||||
{
|
{
|
||||||
List<ConVarInfo *>::iterator iter = m_ConVars.begin();
|
auto iter = m_ConVars.begin();
|
||||||
HandleSecurity sec(NULL, g_pCoreIdent);
|
HandleSecurity sec(NULL, g_pCoreIdent);
|
||||||
|
|
||||||
/* Iterate list of ConVarInfo structures, remove every one of them */
|
/* Iterate list of ConVarInfo structures, remove every one of them */
|
||||||
@@ -180,32 +155,10 @@ void ConVarManager::OnSourceModShutdown()
|
|||||||
}
|
}
|
||||||
convar_cache.clear();
|
convar_cache.clear();
|
||||||
|
|
||||||
#if SOURCE_ENGINE != SE_DARKMESSIAH
|
|
||||||
/* Unhook things */
|
|
||||||
if (m_bIsDLLQueryHooked)
|
|
||||||
{
|
|
||||||
SH_REMOVE_HOOK(IServerGameDLL, OnQueryCvarValueFinished, gamedll, SH_MEMBER(this, &ConVarManager::OnQueryCvarValueFinished), false);
|
|
||||||
m_bIsDLLQueryHooked = false;
|
|
||||||
}
|
|
||||||
else if (m_bIsVSPQueryHooked)
|
|
||||||
{
|
|
||||||
#if SOURCE_ENGINE != SE_DOTA
|
|
||||||
SH_REMOVE_HOOK(IServerPluginCallbacks, OnQueryCvarValueFinished, vsp_interface, SH_MEMBER(this, &ConVarManager::OnQueryCvarValueFinished), false);
|
|
||||||
#endif
|
|
||||||
m_bIsVSPQueryHooked = false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
g_Players.RemoveClientListener(this);
|
g_Players.RemoveClientListener(this);
|
||||||
|
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
SH_REMOVE_HOOK(ICvar, CallGlobalChangeCallbacks, icvar, SH_STATIC(OnConVarChanged), false);
|
|
||||||
#else
|
|
||||||
SH_REMOVE_HOOK(ICvar, CallGlobalChangeCallback, icvar, SH_STATIC(OnConVarChanged), false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Remove the 'convars' option from the 'sm' console command */
|
/* Remove the 'convars' option from the 'sm' console command */
|
||||||
g_RootMenu.RemoveRootConsoleCommand("cvars", this);
|
rootmenu->RemoveRootConsoleCommand("cvars", this);
|
||||||
|
|
||||||
scripts->RemovePluginsListener(this);
|
scripts->RemovePluginsListener(this);
|
||||||
|
|
||||||
@@ -213,45 +166,12 @@ void ConVarManager::OnSourceModShutdown()
|
|||||||
handlesys->RemoveType(m_ConVarType, g_pCoreIdent);
|
handlesys->RemoveType(m_ConVarType, g_pCoreIdent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Orange Box will never use this.
|
|
||||||
*/
|
|
||||||
void ConVarManager::OnSourceModVSPReceived()
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Don't bother if the DLL is already hooked.
|
|
||||||
*/
|
|
||||||
if (m_bIsDLLQueryHooked)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* For later MM:S versions, use the updated API, since it's cleaner. */
|
|
||||||
#if defined METAMOD_PLAPI_VERSION || PLAPI_VERSION >= 11
|
|
||||||
int engine = g_SMAPI->GetSourceEngineBuild();
|
|
||||||
if (engine == SOURCE_ENGINE_ORIGINAL || vsp_version < 2)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (g_HL2.IsOriginalEngine() || vsp_version < 2)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if SOURCE_ENGINE != SE_DARKMESSIAH && SOURCE_ENGINE != SE_DOTA
|
|
||||||
SH_ADD_HOOK(IServerPluginCallbacks, OnQueryCvarValueFinished, vsp_interface, SH_MEMBER(this, &ConVarManager::OnQueryCvarValueFinished), false);
|
|
||||||
m_bIsVSPQueryHooked = true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool convar_cache_lookup(const char *name, ConVarInfo **pVar)
|
bool convar_cache_lookup(const char *name, ConVarInfo **pVar)
|
||||||
{
|
{
|
||||||
return convar_cache.retrieve(name, pVar);
|
return convar_cache.retrieve(name, pVar);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConVarManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name, bool is_read_safe)
|
void ConVarManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name)
|
||||||
{
|
{
|
||||||
/* Only check convars that have not been created by SourceMod's core */
|
/* Only check convars that have not been created by SourceMod's core */
|
||||||
ConVarInfo *pInfo;
|
ConVarInfo *pInfo;
|
||||||
@@ -290,18 +210,27 @@ void ConVarManager::OnUnlinkConCommandBase(ConCommandBase *pBase, const char *na
|
|||||||
void ConVarManager::OnPluginUnloaded(IPlugin *plugin)
|
void ConVarManager::OnPluginUnloaded(IPlugin *plugin)
|
||||||
{
|
{
|
||||||
ConVarList *pConVarList;
|
ConVarList *pConVarList;
|
||||||
List<ConVarQuery>::iterator iter;
|
|
||||||
|
|
||||||
/* If plugin has a convar list, free its memory */
|
/* If plugin has a convar list, free its memory */
|
||||||
if (plugin->GetProperty("ConVarList", (void **)&pConVarList, true))
|
if (plugin->GetProperty("ConVarList", (void **)&pConVarList, true))
|
||||||
{
|
{
|
||||||
delete pConVarList;
|
delete pConVarList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Clear any references to this plugin as the convar creator */
|
||||||
|
for (auto iter = m_ConVars.begin(); iter != m_ConVars.end(); ++iter)
|
||||||
|
{
|
||||||
|
ConVarInfo *pInfo = (*iter);
|
||||||
|
|
||||||
|
if (pInfo->pPlugin == plugin)
|
||||||
|
{
|
||||||
|
pInfo->pPlugin = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const IPluginRuntime * pRuntime = plugin->GetRuntime();
|
const IPluginRuntime * pRuntime = plugin->GetRuntime();
|
||||||
|
|
||||||
/* Remove convar queries for this plugin that haven't returned results yet */
|
/* Remove convar queries for this plugin that haven't returned results yet */
|
||||||
for (iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end();)
|
for (auto iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end();)
|
||||||
{
|
{
|
||||||
ConVarQuery &query = (*iter);
|
ConVarQuery &query = (*iter);
|
||||||
if (query.pCallback->GetParentRuntime() == pRuntime)
|
if (query.pCallback->GetParentRuntime() == pRuntime)
|
||||||
@@ -317,11 +246,24 @@ void ConVarManager::OnPluginUnloaded(IPlugin *plugin)
|
|||||||
void ConVarManager::OnClientDisconnected(int client)
|
void ConVarManager::OnClientDisconnected(int client)
|
||||||
{
|
{
|
||||||
/* Remove convar queries for this client that haven't returned results yet */
|
/* Remove convar queries for this client that haven't returned results yet */
|
||||||
for (List<ConVarQuery>::iterator iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end();)
|
for (auto iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end();)
|
||||||
{
|
{
|
||||||
ConVarQuery &query = (*iter);
|
ConVarQuery &query = (*iter);
|
||||||
if (query.client == client)
|
if (query.client == client)
|
||||||
{
|
{
|
||||||
|
IPluginFunction *pCallback = query.pCallback;
|
||||||
|
if (pCallback)
|
||||||
|
{
|
||||||
|
cell_t ret;
|
||||||
|
|
||||||
|
pCallback->PushCell(query.cookie);
|
||||||
|
pCallback->PushCell(client);
|
||||||
|
pCallback->PushCell(eQueryCvarValueStatus_Cancelled);
|
||||||
|
pCallback->PushString("");
|
||||||
|
pCallback->PushString("");
|
||||||
|
pCallback->PushCell(query.value);
|
||||||
|
pCallback->Execute(&ret);
|
||||||
|
}
|
||||||
iter = m_ConVarQueries.erase(iter);
|
iter = m_ConVarQueries.erase(iter);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -340,19 +282,19 @@ bool ConVarManager::GetHandleApproxSize(HandleType_t type, void *object, unsigne
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConVarManager::OnRootConsoleCommand(const char *cmdname, const CCommand &command)
|
void ConVarManager::OnRootConsoleCommand(const char *cmdname, const ICommandArgs *command)
|
||||||
{
|
{
|
||||||
int argcount = command.ArgC();
|
int argcount = command->ArgC();
|
||||||
if (argcount >= 3)
|
if (argcount >= 3)
|
||||||
{
|
{
|
||||||
bool wantReset = false;
|
bool wantReset = false;
|
||||||
|
|
||||||
/* Get plugin index that was passed */
|
/* Get plugin index that was passed */
|
||||||
const char *arg = command.Arg(2);
|
const char *arg = command->Arg(2);
|
||||||
if (argcount >= 4 && strcmp(arg, "reset") == 0)
|
if (argcount >= 4 && strcmp(arg, "reset") == 0)
|
||||||
{
|
{
|
||||||
wantReset = true;
|
wantReset = true;
|
||||||
arg = command.Arg(3);
|
arg = command->Arg(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get plugin object */
|
/* Get plugin object */
|
||||||
@@ -360,7 +302,7 @@ void ConVarManager::OnRootConsoleCommand(const char *cmdname, const CCommand &co
|
|||||||
|
|
||||||
if (!plugin)
|
if (!plugin)
|
||||||
{
|
{
|
||||||
g_RootMenu.ConsolePrint("[SM] Plugin \"%s\" was not found.", arg);
|
UTIL_ConsolePrint("[SM] Plugin \"%s\" was not found.", arg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,28 +311,27 @@ void ConVarManager::OnRootConsoleCommand(const char *cmdname, const CCommand &co
|
|||||||
const char *plname = IS_STR_FILLED(plinfo->name) ? plinfo->name : plugin->GetFilename();
|
const char *plname = IS_STR_FILLED(plinfo->name) ? plinfo->name : plugin->GetFilename();
|
||||||
|
|
||||||
ConVarList *pConVarList;
|
ConVarList *pConVarList;
|
||||||
ConVarList::iterator iter;
|
|
||||||
|
|
||||||
/* If no convar list... */
|
/* If no convar list... */
|
||||||
if (!plugin->GetProperty("ConVarList", (void **)&pConVarList))
|
if (!plugin->GetProperty("ConVarList", (void **)&pConVarList))
|
||||||
{
|
{
|
||||||
g_RootMenu.ConsolePrint("[SM] No convars found for: %s", plname);
|
UTIL_ConsolePrint("[SM] No convars found for: %s", plname);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!wantReset)
|
if (!wantReset)
|
||||||
{
|
{
|
||||||
g_RootMenu.ConsolePrint("[SM] Listing %d convars for: %s", pConVarList->size(), plname);
|
UTIL_ConsolePrint("[SM] Listing %d convars for: %s", pConVarList->size(), plname);
|
||||||
g_RootMenu.ConsolePrint(" %-32.31s %s", "[Name]", "[Value]");
|
UTIL_ConsolePrint(" %-32.31s %s", "[Name]", "[Value]");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Iterate convar list and display/reset each one */
|
/* Iterate convar list and display/reset each one */
|
||||||
for (iter = pConVarList->begin(); iter != pConVarList->end(); iter++)
|
for (auto iter = pConVarList->begin(); iter != pConVarList->end(); iter++)
|
||||||
{
|
{
|
||||||
/*const */ConVar *pConVar = const_cast<ConVar *>(*iter);
|
/*const */ConVar *pConVar = const_cast<ConVar *>(*iter);
|
||||||
if (!wantReset)
|
if (!wantReset)
|
||||||
{
|
{
|
||||||
g_RootMenu.ConsolePrint(" %-32.31s %s", pConVar->GetName(), pConVar->GetString());
|
UTIL_ConsolePrint(" %-32.31s %s", pConVar->GetName(), pConVar->GetString());
|
||||||
} else {
|
} else {
|
||||||
pConVar->Revert();
|
pConVar->Revert();
|
||||||
}
|
}
|
||||||
@@ -398,14 +339,14 @@ void ConVarManager::OnRootConsoleCommand(const char *cmdname, const CCommand &co
|
|||||||
|
|
||||||
if (wantReset)
|
if (wantReset)
|
||||||
{
|
{
|
||||||
g_RootMenu.ConsolePrint("[SM] Reset %d convars for: %s", pConVarList->size(), plname);
|
UTIL_ConsolePrint("[SM] Reset %d convars for: %s", pConVarList->size(), plname);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Display usage of subcommand */
|
/* Display usage of subcommand */
|
||||||
g_RootMenu.ConsolePrint("[SM] Usage: sm cvars [reset] <plugin #>");
|
UTIL_ConsolePrint("[SM] Usage: sm cvars [reset] <plugin #>");
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle_t ConVarManager::CreateConVar(IPluginContext *pContext, const char *name, const char *defaultVal, const char *description, int flags, bool hasMin, float min, bool hasMax, float max)
|
Handle_t ConVarManager::CreateConVar(IPluginContext *pContext, const char *name, const char *defaultVal, const char *description, int flags, bool hasMin, float min, bool hasMax, float max)
|
||||||
@@ -414,6 +355,8 @@ Handle_t ConVarManager::CreateConVar(IPluginContext *pContext, const char *name,
|
|||||||
ConVarInfo *pInfo = NULL;
|
ConVarInfo *pInfo = NULL;
|
||||||
Handle_t hndl = 0;
|
Handle_t hndl = 0;
|
||||||
|
|
||||||
|
IPlugin *plugin = scripts->FindPluginByContext(pContext);
|
||||||
|
|
||||||
/* Find out if the convar exists already */
|
/* Find out if the convar exists already */
|
||||||
pConVar = icvar->FindVar(name);
|
pConVar = icvar->FindVar(name);
|
||||||
|
|
||||||
@@ -421,11 +364,16 @@ Handle_t ConVarManager::CreateConVar(IPluginContext *pContext, const char *name,
|
|||||||
if (pConVar)
|
if (pConVar)
|
||||||
{
|
{
|
||||||
/* Add convar to plugin's list */
|
/* Add convar to plugin's list */
|
||||||
AddConVarToPluginList(pContext, pConVar);
|
AddConVarToPluginList(plugin, pConVar);
|
||||||
|
|
||||||
/* First find out if we already have a handle to it */
|
/* First find out if we already have a handle to it */
|
||||||
if (convar_cache_lookup(name, &pInfo))
|
if (convar_cache_lookup(name, &pInfo))
|
||||||
{
|
{
|
||||||
|
/* If the convar doesn't have an owning plugin, but SM created it, adopt it */
|
||||||
|
if (pInfo->sourceMod && pInfo->pPlugin == nullptr) {
|
||||||
|
pInfo->pPlugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
return pInfo->handle;
|
return pInfo->handle;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -466,6 +414,7 @@ Handle_t ConVarManager::CreateConVar(IPluginContext *pContext, const char *name,
|
|||||||
pInfo->handle = hndl;
|
pInfo->handle = hndl;
|
||||||
pInfo->sourceMod = true;
|
pInfo->sourceMod = true;
|
||||||
pInfo->pChangeForward = NULL;
|
pInfo->pChangeForward = NULL;
|
||||||
|
pInfo->pPlugin = plugin;
|
||||||
|
|
||||||
/* Create a handle from the new convar */
|
/* Create a handle from the new convar */
|
||||||
hndl = handlesys->CreateHandle(m_ConVarType, pInfo, NULL, g_pCoreIdent, NULL);
|
hndl = handlesys->CreateHandle(m_ConVarType, pInfo, NULL, g_pCoreIdent, NULL);
|
||||||
@@ -482,7 +431,7 @@ Handle_t ConVarManager::CreateConVar(IPluginContext *pContext, const char *name,
|
|||||||
pInfo->pVar = pConVar;
|
pInfo->pVar = pConVar;
|
||||||
|
|
||||||
/* Add convar to plugin's list */
|
/* Add convar to plugin's list */
|
||||||
AddConVarToPluginList(pContext, pConVar);
|
AddConVarToPluginList(plugin, pConVar);
|
||||||
|
|
||||||
/* Insert struct into caches */
|
/* Insert struct into caches */
|
||||||
m_ConVars.push_back(pInfo);
|
m_ConVars.push_back(pInfo);
|
||||||
@@ -625,62 +574,37 @@ void ConVarManager::UnhookConVarChange(ConVar *pConVar, IPluginFunction *pFuncti
|
|||||||
|
|
||||||
QueryCvarCookie_t ConVarManager::QueryClientConVar(edict_t *pPlayer, const char *name, IPluginFunction *pCallback, Handle_t hndl)
|
QueryCvarCookie_t ConVarManager::QueryClientConVar(edict_t *pPlayer, const char *name, IPluginFunction *pCallback, Handle_t hndl)
|
||||||
{
|
{
|
||||||
QueryCvarCookie_t cookie = 0;
|
QueryCvarCookie_t cookie = sCoreProviderImpl.QueryClientConVar(IndexOfEdict(pPlayer), name);
|
||||||
|
|
||||||
#if SOURCE_ENGINE != SE_DARKMESSIAH
|
|
||||||
/* Call StartQueryCvarValue() in either the IVEngineServer or IServerPluginHelpers depending on situation */
|
|
||||||
if (m_bIsDLLQueryHooked)
|
|
||||||
{
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
|
||||||
cookie = engine->StartQueryCvarValue(CEntityIndex(IndexOfEdict(pPlayer)), name);
|
|
||||||
#else
|
|
||||||
cookie = engine->StartQueryCvarValue(pPlayer, name);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#if SOURCE_ENGINE != SE_DOTA
|
|
||||||
else if (m_bIsVSPQueryHooked)
|
|
||||||
{
|
|
||||||
cookie = serverpluginhelpers->StartQueryCvarValue(pPlayer, name);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return InvalidQueryCvarCookie;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pCallback != NULL)
|
if (pCallback != NULL)
|
||||||
{
|
{
|
||||||
ConVarQuery query = { cookie, pCallback, (cell_t) hndl, IndexOfEdict(pPlayer) };
|
ConVarQuery query = { cookie, pCallback, (cell_t) hndl, IndexOfEdict(pPlayer) };
|
||||||
m_ConVarQueries.push_back(query);
|
m_ConVarQueries.push_back(query);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return cookie;
|
return cookie;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConVarManager::AddConVarToPluginList(IPluginContext *pContext, const ConVar *pConVar)
|
void ConVarManager::AddConVarToPluginList(IPlugin *plugin, const ConVar *pConVar)
|
||||||
{
|
{
|
||||||
ConVarList *pConVarList;
|
ConVarList *pConVarList;
|
||||||
ConVarList::iterator iter;
|
|
||||||
bool inserted = false;
|
bool inserted = false;
|
||||||
const char *orig = pConVar->GetName();
|
const char *orig = pConVar->GetName();
|
||||||
|
|
||||||
IPlugin *plugin = scripts->FindPluginByContext(pContext->GetContext());
|
|
||||||
|
|
||||||
/* Check plugin for an existing convar list */
|
/* Check plugin for an existing convar list */
|
||||||
if (!plugin->GetProperty("ConVarList", (void **)&pConVarList))
|
if (!plugin->GetProperty("ConVarList", (void **)&pConVarList))
|
||||||
{
|
{
|
||||||
pConVarList = new ConVarList();
|
pConVarList = new ConVarList();
|
||||||
plugin->SetProperty("ConVarList", pConVarList);
|
plugin->SetProperty("ConVarList", pConVarList);
|
||||||
}
|
}
|
||||||
else if (pConVarList->find(pConVar) != pConVarList->end())
|
else if (std::find(pConVarList->begin(), pConVarList->end(), pConVar) != pConVarList->end())
|
||||||
{
|
{
|
||||||
/* If convar is already in list, then don't add it */
|
/* If convar is already in list, then don't add it */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Insert convar into list which is sorted alphabetically */
|
/* Insert convar into list which is sorted alphabetically */
|
||||||
for (iter = pConVarList->begin(); iter != pConVarList->end(); iter++)
|
for (auto iter = pConVarList->begin(); iter != pConVarList->end(); iter++)
|
||||||
{
|
{
|
||||||
if (strcmp(orig, (*iter)->GetName()) < 0)
|
if (strcmp(orig, (*iter)->GetName()) < 0)
|
||||||
{
|
{
|
||||||
@@ -696,11 +620,7 @@ void ConVarManager::AddConVarToPluginList(IPluginContext *pContext, const ConVar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
void ConVarManager::OnConVarChanged(ConVar *pConVar, const char *oldValue, float flOldValue)
|
void ConVarManager::OnConVarChanged(ConVar *pConVar, const char *oldValue, float flOldValue)
|
||||||
#else
|
|
||||||
void ConVarManager::OnConVarChanged(ConVar *pConVar, const char *oldValue)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
/* If the values are the same, exit early in order to not trigger callbacks */
|
/* If the values are the same, exit early in order to not trigger callbacks */
|
||||||
if (strcmp(pConVar->GetString(), oldValue) == 0)
|
if (strcmp(pConVar->GetString(), oldValue) == 0)
|
||||||
@@ -720,54 +640,45 @@ void ConVarManager::OnConVarChanged(ConVar *pConVar, const char *oldValue)
|
|||||||
|
|
||||||
if (pInfo->changeListeners.size() != 0)
|
if (pInfo->changeListeners.size() != 0)
|
||||||
{
|
{
|
||||||
for (List<IConVarChangeListener *>::iterator i = pInfo->changeListeners.begin();
|
for (auto i = pInfo->changeListeners.begin(); i != pInfo->changeListeners.end(); i++)
|
||||||
i != pInfo->changeListeners.end();
|
|
||||||
i++)
|
|
||||||
{
|
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
(*i)->OnConVarChanged(pConVar, oldValue, flOldValue);
|
(*i)->OnConVarChanged(pConVar, oldValue, flOldValue);
|
||||||
#else
|
|
||||||
(*i)->OnConVarChanged(pConVar, oldValue, atof(oldValue));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pForward != NULL)
|
if (pForward != NULL)
|
||||||
{
|
{
|
||||||
ConVarReentrancyGuard guard(pConVar);
|
ConVarReentrancyGuard guard(pConVar);
|
||||||
|
|
||||||
|
/* Copy the new value to a local buffer so it survives reentrant
|
||||||
|
* ChangeStringValue calls that may delete[] + reallocate m_pszString
|
||||||
|
* while the forward is still iterating plugin callbacks. */
|
||||||
|
char newValue[512];
|
||||||
|
ke::SafeStrcpy(newValue, sizeof(newValue), pConVar->GetString());
|
||||||
|
|
||||||
/* Now call forwards in plugins that have hooked this */
|
/* Now call forwards in plugins that have hooked this */
|
||||||
pForward->PushCell(pInfo->handle);
|
pForward->PushCell(pInfo->handle);
|
||||||
pForward->PushString(oldValue);
|
pForward->PushString(oldValue);
|
||||||
pForward->PushString(pConVar->GetString());
|
pForward->PushString(newValue);
|
||||||
pForward->Execute(NULL);
|
pForward->Execute(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConVarManager::IsQueryingSupported()
|
bool ConVarManager::IsQueryingSupported()
|
||||||
{
|
{
|
||||||
return (m_bIsDLLQueryHooked || m_bIsVSPQueryHooked);
|
return sCoreProviderImpl.IsClientConVarQueryingSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE != SE_DARKMESSIAH
|
#if SOURCE_ENGINE != SE_DARKMESSIAH
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
void ConVarManager::OnClientQueryFinished(QueryCvarCookie_t cookie,
|
||||||
void ConVarManager::OnQueryCvarValueFinished(QueryCvarCookie_t cookie, CEntityIndex player, EQueryCvarValueStatus result, const char *cvarName, const char *cvarValue)
|
int client,
|
||||||
#else
|
EQueryCvarValueStatus result,
|
||||||
void ConVarManager::OnQueryCvarValueFinished(QueryCvarCookie_t cookie, edict_t *pPlayer, EQueryCvarValueStatus result, const char *cvarName, const char *cvarValue)
|
const char *cvarName,
|
||||||
#endif // SE_DOTA
|
const char *cvarValue)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE == SE_CSGO
|
|
||||||
if (g_Players.HandleConVarQuery(cookie, pPlayer, result, cvarName, cvarValue))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
IPluginFunction *pCallback = NULL;
|
IPluginFunction *pCallback = NULL;
|
||||||
cell_t value = 0;
|
cell_t value = 0;
|
||||||
List<ConVarQuery>::iterator iter;
|
|
||||||
|
|
||||||
for (iter = m_ConVarQueries.begin(); iter != m_ConVarQueries.end(); iter++)
|
auto iter = m_ConVarQueries.begin();
|
||||||
|
for (; iter != m_ConVarQueries.end(); iter++)
|
||||||
{
|
{
|
||||||
ConVarQuery &query = (*iter);
|
ConVarQuery &query = (*iter);
|
||||||
if (query.cookie == cookie)
|
if (query.cookie == cookie)
|
||||||
@@ -778,16 +689,12 @@ void ConVarManager::OnQueryCvarValueFinished(QueryCvarCookie_t cookie, edict_t *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pCallback)
|
if (pCallback && iter != m_ConVarQueries.end())
|
||||||
{
|
{
|
||||||
cell_t ret;
|
cell_t ret;
|
||||||
|
|
||||||
pCallback->PushCell(cookie);
|
pCallback->PushCell(cookie);
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
pCallback->PushCell(client);
|
||||||
pCallback->PushCell(player.Get());
|
|
||||||
#else
|
|
||||||
pCallback->PushCell(IndexOfEdict(pPlayer));
|
|
||||||
#endif
|
|
||||||
pCallback->PushCell(result);
|
pCallback->PushCell(result);
|
||||||
pCallback->PushString(cvarName);
|
pCallback->PushString(cvarName);
|
||||||
|
|
||||||
@@ -808,7 +715,7 @@ void ConVarManager::OnQueryCvarValueFinished(QueryCvarCookie_t cookie, edict_t *
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HandleError ConVarManager::ReadConVarHandle(Handle_t hndl, ConVar **pVar)
|
HandleError ConVarManager::ReadConVarHandle(Handle_t hndl, ConVar **pVar, IPlugin **ppPlugin)
|
||||||
{
|
{
|
||||||
ConVarInfo *pInfo;
|
ConVarInfo *pInfo;
|
||||||
HandleError error;
|
HandleError error;
|
||||||
@@ -823,5 +730,10 @@ HandleError ConVarManager::ReadConVarHandle(Handle_t hndl, ConVar **pVar)
|
|||||||
*pVar = pInfo->pVar;
|
*pVar = pInfo->pVar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ppPlugin)
|
||||||
|
{
|
||||||
|
*ppPlugin = pInfo->pPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|||||||
+38
-41
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
#include <sh_list.h>
|
#include <list>
|
||||||
#include <IPluginSys.h>
|
#include <IPluginSys.h>
|
||||||
#include <IForwardSys.h>
|
#include <IForwardSys.h>
|
||||||
#include <IHandleSys.h>
|
#include <IHandleSys.h>
|
||||||
@@ -43,13 +43,7 @@
|
|||||||
#include <compat_wrappers.h>
|
#include <compat_wrappers.h>
|
||||||
#include "concmd_cleaner.h"
|
#include "concmd_cleaner.h"
|
||||||
#include "PlayerManager.h"
|
#include "PlayerManager.h"
|
||||||
|
#include <sm_hashmap.h>
|
||||||
#if SOURCE_ENGINE == SE_DARKMESSIAH
|
|
||||||
class EQueryCvarValueStatus;
|
|
||||||
typedef int QueryCvarCookie_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace SourceHook;
|
|
||||||
|
|
||||||
class IConVarChangeListener
|
class IConVarChangeListener
|
||||||
{
|
{
|
||||||
@@ -66,12 +60,27 @@ struct ConVarInfo
|
|||||||
bool sourceMod; /**< Determines whether or not convar was created by a SourceMod plugin */
|
bool sourceMod; /**< Determines whether or not convar was created by a SourceMod plugin */
|
||||||
IChangeableForward *pChangeForward; /**< Forward associated with convar */
|
IChangeableForward *pChangeForward; /**< Forward associated with convar */
|
||||||
ConVar *pVar; /**< The actual convar */
|
ConVar *pVar; /**< The actual convar */
|
||||||
List<IConVarChangeListener *> changeListeners;
|
IPlugin *pPlugin; /**< Originally owning plugin */
|
||||||
|
std::list<IConVarChangeListener *> changeListeners;
|
||||||
|
|
||||||
static inline bool matches(const char *name, const ConVarInfo *info)
|
struct ConVarPolicy
|
||||||
{
|
{
|
||||||
return strcmp(name, info->pVar->GetName()) == 0;
|
static inline bool matches(const char *name, ConVarInfo *info)
|
||||||
}
|
{
|
||||||
|
const char *conVarChars = info->pVar->GetName();
|
||||||
|
|
||||||
|
std::string convarName = ke::Lowercase(conVarChars);
|
||||||
|
std::string input = ke::Lowercase(name);
|
||||||
|
|
||||||
|
return convarName == input;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t hash(const detail::CharsAndLength &key)
|
||||||
|
{
|
||||||
|
std::string lower = ke::Lowercase(key.c_str());
|
||||||
|
return detail::CharsAndLength(lower.c_str()).hash();
|
||||||
|
}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -100,16 +109,15 @@ public: // SMGlobalClass
|
|||||||
void OnSourceModStartup(bool late);
|
void OnSourceModStartup(bool late);
|
||||||
void OnSourceModAllInitialized();
|
void OnSourceModAllInitialized();
|
||||||
void OnSourceModShutdown();
|
void OnSourceModShutdown();
|
||||||
void OnSourceModVSPReceived();
|
|
||||||
public: // IHandleTypeDispatch
|
public: // IHandleTypeDispatch
|
||||||
void OnHandleDestroy(HandleType_t type, void *object);
|
void OnHandleDestroy(HandleType_t type, void *object);
|
||||||
bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize);
|
bool GetHandleApproxSize(HandleType_t type, void *object, unsigned int *pSize);
|
||||||
public: // IPluginsListener
|
public: // IPluginsListener
|
||||||
void OnPluginUnloaded(IPlugin *plugin);
|
void OnPluginUnloaded(IPlugin *plugin);
|
||||||
public: //IRootConsoleCommand
|
public: //IRootConsoleCommand
|
||||||
void OnRootConsoleCommand(const char *cmdname, const CCommand &command);
|
void OnRootConsoleCommand(const char *cmdname, const ICommandArgs *command) override;
|
||||||
public: //IConCommandTracker
|
public: //IConCommandTracker
|
||||||
void OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name, bool is_read_safe);
|
void OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name) override;
|
||||||
public: //IClientListener
|
public: //IClientListener
|
||||||
void OnClientDisconnected(int client);
|
void OnClientDisconnected(int client);
|
||||||
public:
|
public:
|
||||||
@@ -145,39 +153,28 @@ public:
|
|||||||
|
|
||||||
bool IsQueryingSupported();
|
bool IsQueryingSupported();
|
||||||
|
|
||||||
HandleError ReadConVarHandle(Handle_t hndl, ConVar **pVar);
|
HandleError ReadConVarHandle(Handle_t hndl, ConVar **pVar, IPlugin **ppPlugin = nullptr);
|
||||||
|
|
||||||
|
// Called via game hooks.
|
||||||
|
void OnConVarChanged(ConVar *pConVar, const char *oldValue, float flOldValue);
|
||||||
|
#if SOURCE_ENGINE != SE_DARKMESSIAH
|
||||||
|
void OnClientQueryFinished(
|
||||||
|
QueryCvarCookie_t cookie,
|
||||||
|
int client,
|
||||||
|
EQueryCvarValueStatus result,
|
||||||
|
const char *cvarName,
|
||||||
|
const char *cvarValue);
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Adds a convar to a plugin's list.
|
* Adds a convar to a plugin's list.
|
||||||
*/
|
*/
|
||||||
static void AddConVarToPluginList(IPluginContext *pContext, const ConVar *pConVar);
|
static void AddConVarToPluginList(IPlugin *plugin, const ConVar *pConVar);
|
||||||
|
|
||||||
/**
|
|
||||||
* Static callback that Valve's ConVar object executes when the convar's value changes.
|
|
||||||
*/
|
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
static void OnConVarChanged(ConVar *pConVar, const char *oldValue, float flOldValue);
|
|
||||||
#else
|
|
||||||
static void OnConVarChanged(ConVar *pConVar, const char *oldValue);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback for when StartQueryCvarValue() has finished.
|
|
||||||
*/
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
|
||||||
void OnQueryCvarValueFinished(QueryCvarCookie_t cookie, CEntityIndex player, EQueryCvarValueStatus result,
|
|
||||||
const char *cvarName, const char *cvarValue);
|
|
||||||
#elif SOURCE_ENGINE != SE_DARKMESSIAH
|
|
||||||
void OnQueryCvarValueFinished(QueryCvarCookie_t cookie, edict_t *pPlayer, EQueryCvarValueStatus result,
|
|
||||||
const char *cvarName, const char *cvarValue);
|
|
||||||
#endif
|
|
||||||
private:
|
private:
|
||||||
HandleType_t m_ConVarType;
|
HandleType_t m_ConVarType;
|
||||||
List<ConVarInfo *> m_ConVars;
|
std::list<ConVarInfo *> m_ConVars;
|
||||||
List<ConVarQuery> m_ConVarQueries;
|
std::list<ConVarQuery> m_ConVarQueries;
|
||||||
bool m_bIsDLLQueryHooked;
|
|
||||||
bool m_bIsVSPQueryHooked;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ConVarManager g_ConVarManager;
|
extern ConVarManager g_ConVarManager;
|
||||||
|
|||||||
+26
-356
@@ -50,7 +50,10 @@
|
|||||||
#include "HalfLife2.h"
|
#include "HalfLife2.h"
|
||||||
#include "ConCommandBaseIterator.h"
|
#include "ConCommandBaseIterator.h"
|
||||||
#include "logic_bridge.h"
|
#include "logic_bridge.h"
|
||||||
|
#include "command_args.h"
|
||||||
|
#include "provider.h"
|
||||||
#include <am-utility.h>
|
#include <am-utility.h>
|
||||||
|
#include <bridge/include/ILogger.h>
|
||||||
|
|
||||||
#if defined PLATFORM_POSIX
|
#if defined PLATFORM_POSIX
|
||||||
# include <dlfcn.h>
|
# include <dlfcn.h>
|
||||||
@@ -59,26 +62,12 @@
|
|||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SH_IMPL_VERSION >= 5
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
# if SOURCE_ENGINE == SE_DOTA
|
|
||||||
SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommandContext &, const CCommand &);
|
|
||||||
# elif SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
|
SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
|
||||||
# else
|
|
||||||
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
|
||||||
# endif
|
|
||||||
#else
|
#else
|
||||||
# if SH_IMPL_VERSION >= 4
|
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
||||||
extern int __SourceHook_FHVPAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>,bool);
|
|
||||||
extern int __SourceHook_FHAddConCommandDispatch(void *, bool, class fastdelegate::FastDelegate0<void>);
|
|
||||||
# else
|
|
||||||
extern bool __SourceHook_FHAddConCommandDispatch(void *, bool, class fastdelegate::FastDelegate0<void>);
|
|
||||||
# endif
|
|
||||||
extern bool __SourceHook_FHRemoveConCommandDispatch(void *, bool, class fastdelegate::FastDelegate0<void>);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SH_IMPL_VERSION >= 4
|
|
||||||
|
|
||||||
class GenericCommandHooker : public IConCommandLinkListener
|
class GenericCommandHooker : public IConCommandLinkListener
|
||||||
{
|
{
|
||||||
struct HackInfo
|
struct HackInfo
|
||||||
@@ -87,7 +76,7 @@ class GenericCommandHooker : public IConCommandLinkListener
|
|||||||
int hook;
|
int hook;
|
||||||
unsigned int refcount;
|
unsigned int refcount;
|
||||||
};
|
};
|
||||||
CVector<HackInfo> vtables;
|
std::vector<HackInfo> vtables;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
SourceHook::MemFuncInfo dispatch;
|
SourceHook::MemFuncInfo dispatch;
|
||||||
|
|
||||||
@@ -134,18 +123,16 @@ class GenericCommandHooker : public IConCommandLinkListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# if SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
void Dispatch(const CCommandContext &context, const CCommand& args)
|
|
||||||
# elif SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
void Dispatch(const CCommand& args)
|
void Dispatch(const CCommand& args)
|
||||||
# else
|
#else
|
||||||
void Dispatch()
|
void Dispatch()
|
||||||
# endif
|
#endif
|
||||||
{
|
{
|
||||||
cell_t res = ConsoleDetours::Dispatch(META_IFACEPTR(ConCommand)
|
cell_t res = ConsoleDetours::Dispatch(META_IFACEPTR(ConCommand)
|
||||||
# if SOURCE_ENGINE >= SE_ORANGEBOX
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
, args
|
, args
|
||||||
# endif
|
#endif
|
||||||
);
|
);
|
||||||
if (res >= Pl_Handled)
|
if (res >= Pl_Handled)
|
||||||
RETURN_META(MRES_SUPERCEDE);
|
RETURN_META(MRES_SUPERCEDE);
|
||||||
@@ -157,7 +144,7 @@ class GenericCommandHooker : public IConCommandLinkListener
|
|||||||
vtables[i].refcount = 0;
|
vtables[i].refcount = 0;
|
||||||
for (ConCommandBaseIterator iter; iter.IsValid(); iter.Next())
|
for (ConCommandBaseIterator iter; iter.IsValid(); iter.Next())
|
||||||
MakeHookable(iter.Get());
|
MakeHookable(iter.Get());
|
||||||
CVector<HackInfo>::iterator iter = vtables.begin();
|
auto iter = vtables.begin();
|
||||||
while (iter != vtables.end())
|
while (iter != vtables.end())
|
||||||
{
|
{
|
||||||
if ((*iter).refcount)
|
if ((*iter).refcount)
|
||||||
@@ -204,7 +191,7 @@ class GenericCommandHooker : public IConCommandLinkListener
|
|||||||
if (vtables[index].refcount == 0)
|
if (vtables[index].refcount == 0)
|
||||||
{
|
{
|
||||||
SH_REMOVE_HOOK_ID(vtables[index].hook);
|
SH_REMOVE_HOOK_ID(vtables[index].hook);
|
||||||
vtables.erase(vtables.iterAt(index));
|
vtables.erase(vtables.begin() + index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,308 +249,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* END DVP HOOK VERSION
|
|
||||||
*/
|
|
||||||
|
|
||||||
#else /* SH_IMPL_VERSION >= 4 */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BEGIN ENGINE DETOUR VERSION
|
|
||||||
*/
|
|
||||||
|
|
||||||
# include <jit/jit_helpers.h>
|
|
||||||
# include <jit/x86/x86_macros.h>
|
|
||||||
|
|
||||||
class GenericCommandHooker
|
|
||||||
{
|
|
||||||
struct Patch
|
|
||||||
{
|
|
||||||
Patch() : applied(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool applied;
|
|
||||||
void *base;
|
|
||||||
unsigned char search[16];
|
|
||||||
size_t search_len;
|
|
||||||
size_t offset;
|
|
||||||
size_t saveat;
|
|
||||||
int regparam;
|
|
||||||
void *detour;
|
|
||||||
};
|
|
||||||
|
|
||||||
Patch ces;
|
|
||||||
Patch cgc;
|
|
||||||
|
|
||||||
public:
|
|
||||||
static void DelayedActivation(void *inparam)
|
|
||||||
{
|
|
||||||
GenericCommandHooker *cdtrs = reinterpret_cast<GenericCommandHooker*>(inparam);
|
|
||||||
/* Safe to re-enter because the frame queue is lock+swapped. */
|
|
||||||
if ((!cdtrs->ces.applied || !cdtrs->cgc.applied) &&
|
|
||||||
g_HL2.PeekCommandStack() != NULL)
|
|
||||||
{
|
|
||||||
g_SourceMod.AddFrameAction(GenericCommandHooker::DelayedActivation, cdtrs);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cdtrs->ces.applied)
|
|
||||||
cdtrs->ApplyPatch(&cdtrs->ces);
|
|
||||||
if (!cdtrs->cgc.applied)
|
|
||||||
cdtrs->ApplyPatch(&cdtrs->cgc);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Enable()
|
|
||||||
{
|
|
||||||
const char *platform = NULL;
|
|
||||||
# if defined(PLATFORM_WINDOWS)
|
|
||||||
platform = "Windows";
|
|
||||||
# else
|
|
||||||
void *addrInBase = (void *)g_SMAPI->GetEngineFactory(false);
|
|
||||||
Dl_info info;
|
|
||||||
if (!dladdr(addrInBase, &info))
|
|
||||||
{
|
|
||||||
g_Logger.LogError("Command filter could not find engine name");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (strstr(info.dli_fname, "engine_i486"))
|
|
||||||
{
|
|
||||||
platform = "Linux_486";
|
|
||||||
}
|
|
||||||
else if (strstr(info.dli_fname, "engine_i686"))
|
|
||||||
{
|
|
||||||
platform = "Linux_686";
|
|
||||||
}
|
|
||||||
else if (strstr(info.dli_fname, "engine_amd"))
|
|
||||||
{
|
|
||||||
platform = "Linux_AMD";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_Logger.LogError("Command filter could not determine engine (%s)", info.dli_fname);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
|
|
||||||
if (!PrepPatch("Cmd_ExecuteString", "CES", platform, &ces))
|
|
||||||
return false;
|
|
||||||
if (!PrepPatch("CGameClient::ExecuteString", "CGC", platform, &cgc))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (g_HL2.PeekCommandStack() != NULL)
|
|
||||||
{
|
|
||||||
g_SourceMod.AddFrameAction(GenericCommandHooker::DelayedActivation, this);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ApplyPatch(&ces);
|
|
||||||
ApplyPatch(&cgc);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Disable()
|
|
||||||
{
|
|
||||||
UndoPatch(&ces);
|
|
||||||
UndoPatch(&cgc);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
# if !defined PLATFORM_WINDOWS
|
|
||||||
# define PAGE_READWRITE PROT_READ|PROT_WRITE
|
|
||||||
# define PAGE_EXECUTE_READ PROT_READ|PROT_EXEC
|
|
||||||
|
|
||||||
static inline uintptr_t AddrToPage(uintptr_t address)
|
|
||||||
{
|
|
||||||
return (address & ~(uintptr_t(sysconf(_SC_PAGE_SIZE) - 1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
# endif
|
|
||||||
|
|
||||||
void Protect(void *addr, size_t length, int prot)
|
|
||||||
{
|
|
||||||
# if defined PLATFORM_WINDOWS
|
|
||||||
DWORD ignore;
|
|
||||||
VirtualProtect(addr, length, prot, &ignore);
|
|
||||||
# else
|
|
||||||
uintptr_t startPage = AddrToPage(uintptr_t(addr));
|
|
||||||
length += (uintptr_t(addr) - startPage);
|
|
||||||
mprotect((void*)startPage, length, prot);
|
|
||||||
# endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void UndoPatch(Patch *patch)
|
|
||||||
{
|
|
||||||
if (!patch->applied || patch->detour == NULL)
|
|
||||||
return;
|
|
||||||
|
|
||||||
g_pSourcePawn->FreePageMemory(patch->detour);
|
|
||||||
|
|
||||||
unsigned char *source = (unsigned char *)patch->base + patch->offset;
|
|
||||||
Protect(source, patch->search_len, PAGE_READWRITE);
|
|
||||||
for (size_t i = 0; i < patch->search_len; i++)
|
|
||||||
source[i] = patch->search[i];
|
|
||||||
Protect(source, patch->search_len, PAGE_EXECUTE_READ);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ApplyPatch(Patch *patch)
|
|
||||||
{
|
|
||||||
assert(!patch->applied);
|
|
||||||
|
|
||||||
size_t length = 0;
|
|
||||||
void *callback = (void*)&ConsoleDetours::Dispatch;
|
|
||||||
|
|
||||||
/* Bogus assignment to make compiler is doing the right thing. */
|
|
||||||
patch->detour = callback;
|
|
||||||
|
|
||||||
/* Assemgle the detour. */
|
|
||||||
JitWriter writer;
|
|
||||||
writer.outbase = NULL;
|
|
||||||
writer.outptr = NULL;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
/* Need a specific register, or value on stack? */
|
|
||||||
if (patch->regparam != -1)
|
|
||||||
IA32_Push_Reg(&writer, patch->regparam);
|
|
||||||
/* Call real function. */
|
|
||||||
IA32_Write_Jump32_Abs(&writer, IA32_Call_Imm32(&writer, 0), callback);
|
|
||||||
/* Restore stack. */
|
|
||||||
if (patch->regparam != -1)
|
|
||||||
IA32_Pop_Reg(&writer, patch->regparam);
|
|
||||||
/* Copy any saved bytes */
|
|
||||||
if (patch->saveat)
|
|
||||||
{
|
|
||||||
for (size_t i = patch->saveat; i < patch->search_len; i++)
|
|
||||||
{
|
|
||||||
writer.write_ubyte(patch->search[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Jump back to the caller. */
|
|
||||||
unsigned char *target = (unsigned char *)patch->base + patch->offset + patch->search_len;
|
|
||||||
IA32_Jump_Imm32_Abs(&writer, target);
|
|
||||||
/* Assemble, if we can. */
|
|
||||||
if (writer.outbase == NULL)
|
|
||||||
{
|
|
||||||
length = writer.outptr - writer.outbase;
|
|
||||||
patch->detour = g_pSourcePawn->AllocatePageMemory(length);
|
|
||||||
if (patch->detour == NULL)
|
|
||||||
{
|
|
||||||
g_Logger.LogError("Ran out of memory!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
g_pSourcePawn->SetReadWrite(patch->detour);
|
|
||||||
writer.outbase = (jitcode_t)patch->detour;
|
|
||||||
writer.outptr = writer.outbase;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while (true);
|
|
||||||
|
|
||||||
g_pSourcePawn->SetReadExecute(patch->detour);
|
|
||||||
|
|
||||||
unsigned char *source = (unsigned char *)patch->base + patch->offset;
|
|
||||||
Protect(source, 6, PAGE_READWRITE);
|
|
||||||
source[0] = 0xFF;
|
|
||||||
source[1] = 0x25;
|
|
||||||
*(void **)&source[2] = &patch->detour;
|
|
||||||
Protect(source, 6, PAGE_EXECUTE_READ);
|
|
||||||
|
|
||||||
patch->applied = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool PrepPatch(const char *signature, const char *name, const char *platform, Patch *patch)
|
|
||||||
{
|
|
||||||
/* Get the base address of the function. */
|
|
||||||
if (!g_pGameConf->GetMemSig(signature, &patch->base) || patch->base == NULL)
|
|
||||||
{
|
|
||||||
g_Logger.LogError("Command filter could not find signature: %s", signature);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *value;
|
|
||||||
char keyname[255];
|
|
||||||
|
|
||||||
/* Get the verification bytes that will be written over. */
|
|
||||||
UTIL_Format(keyname, sizeof(keyname), "%s_Patch_%s", name, platform);
|
|
||||||
if ((value = g_pGameConf->GetKeyValue(keyname)) == NULL)
|
|
||||||
{
|
|
||||||
g_Logger.LogError("Command filter could not find key: %s", keyname);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
patch->search_len = UTIL_DecodeHexString(patch->search, sizeof(patch->search), value);
|
|
||||||
if (patch->search_len < 6)
|
|
||||||
{
|
|
||||||
g_Logger.LogError("Error decoding %s value, or not long enough", keyname);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the offset into the function. */
|
|
||||||
UTIL_Format(keyname, sizeof(keyname), "%s_Offset_%s", name, platform);
|
|
||||||
if ((value = g_pGameConf->GetKeyValue(keyname)) == NULL)
|
|
||||||
{
|
|
||||||
g_Logger.LogError("Command filter could not find key: %s", keyname);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
patch->offset = atoi(value);
|
|
||||||
if (patch->offset > 20000)
|
|
||||||
{
|
|
||||||
g_Logger.LogError("Command filter %s value is bogus", keyname);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the number of bytes to save from what was written over. */
|
|
||||||
patch->saveat = 0;
|
|
||||||
UTIL_Format(keyname, sizeof(keyname), "%s_Save_%s", name, platform);
|
|
||||||
if ((value = g_pGameConf->GetKeyValue(keyname)) != NULL)
|
|
||||||
{
|
|
||||||
patch->saveat = atoi(value);
|
|
||||||
if (patch->saveat >= patch->search_len)
|
|
||||||
{
|
|
||||||
g_Logger.LogError("Command filter %s value is too large", keyname);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get register for parameter, if any. */
|
|
||||||
patch->regparam = -1;
|
|
||||||
UTIL_Format(keyname, sizeof(keyname), "%s_Reg_%s", name, platform);
|
|
||||||
if ((value = g_pGameConf->GetKeyValue(keyname)) != NULL)
|
|
||||||
{
|
|
||||||
patch->regparam = atoi(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Everything loaded from gamedata, make sure the patch will succeed. */
|
|
||||||
unsigned char *address = (unsigned char *)patch->base + patch->offset;
|
|
||||||
for (size_t i = 0; i < patch->search_len; i++)
|
|
||||||
{
|
|
||||||
if (address[i] != patch->search[i])
|
|
||||||
{
|
|
||||||
g_Logger.LogError("Command filter %s has changed (byte %x is not %x sub-offset %d)",
|
|
||||||
name, address[i], patch->search[i], i);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool dummy_hook_set = false;
|
|
||||||
void DummyHook()
|
|
||||||
{
|
|
||||||
if (dummy_hook_set)
|
|
||||||
{
|
|
||||||
dummy_hook_set = false;
|
|
||||||
RETURN_META(MRES_SUPERCEDE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BEGIN THE ACTUALLY GENERIC CODE.
|
* BEGIN THE ACTUALLY GENERIC CODE.
|
||||||
*/
|
*/
|
||||||
@@ -622,13 +307,13 @@ bool ConsoleDetours::AddListener(IPluginFunction *fun, const char *command)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ke::AutoArray<char> str(UTIL_ToLowerCase(command));
|
std::unique_ptr<char[]> str(UTIL_ToLowerCase(command));
|
||||||
IChangeableForward *forward;
|
IChangeableForward *forward;
|
||||||
if (!m_Listeners.retrieve(str, &forward))
|
if (!m_Listeners.retrieve(str.get(), &forward))
|
||||||
{
|
{
|
||||||
forward = forwardsys->CreateForwardEx(NULL, ET_Hook, 3, NULL, Param_Cell,
|
forward = forwardsys->CreateForwardEx(NULL, ET_Hook, 3, NULL, Param_Cell,
|
||||||
Param_String, Param_Cell);
|
Param_String, Param_Cell);
|
||||||
m_Listeners.insert(str, forward);
|
m_Listeners.insert(str.get(), forward);
|
||||||
}
|
}
|
||||||
forward->AddFunction(fun);
|
forward->AddFunction(fun);
|
||||||
}
|
}
|
||||||
@@ -644,18 +329,18 @@ bool ConsoleDetours::RemoveListener(IPluginFunction *fun, const char *command)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ke::AutoArray<char> str(UTIL_ToLowerCase(command));
|
std::unique_ptr<char[]> str(UTIL_ToLowerCase(command));
|
||||||
IChangeableForward *forward;
|
IChangeableForward *forward;
|
||||||
if (!m_Listeners.retrieve(str, &forward))
|
if (!m_Listeners.retrieve(str.get(), &forward))
|
||||||
return false;
|
return false;
|
||||||
return forward->RemoveFunction(fun);
|
return forward->RemoveFunction(fun);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cell_t ConsoleDetours::InternalDispatch(int client, const CCommand& args)
|
cell_t ConsoleDetours::InternalDispatch(int client, const ICommandArgs *args)
|
||||||
{
|
{
|
||||||
char name[255];
|
char name[255];
|
||||||
const char *realname = args.Arg(0);
|
const char *realname = args->Arg(0);
|
||||||
size_t len = strlen(realname);
|
size_t len = strlen(realname);
|
||||||
|
|
||||||
// Disallow command strings that are too long, for now.
|
// Disallow command strings that are too long, for now.
|
||||||
@@ -674,7 +359,7 @@ cell_t ConsoleDetours::InternalDispatch(int client, const CCommand& args)
|
|||||||
cell_t result = Pl_Continue;
|
cell_t result = Pl_Continue;
|
||||||
m_pForward->PushCell(client);
|
m_pForward->PushCell(client);
|
||||||
m_pForward->PushString(name);
|
m_pForward->PushString(name);
|
||||||
m_pForward->PushCell(args.ArgC() - 1);
|
m_pForward->PushCell(args->ArgC() - 1);
|
||||||
m_pForward->Execute(&result, NULL);
|
m_pForward->Execute(&result, NULL);
|
||||||
|
|
||||||
/* Don't let plugins block this. */
|
/* Don't let plugins block this. */
|
||||||
@@ -693,7 +378,7 @@ cell_t ConsoleDetours::InternalDispatch(int client, const CCommand& args)
|
|||||||
cell_t result2 = Pl_Continue;
|
cell_t result2 = Pl_Continue;
|
||||||
forward->PushCell(client);
|
forward->PushCell(client);
|
||||||
forward->PushString(name);
|
forward->PushString(name);
|
||||||
forward->PushCell(args.ArgC() - 1);
|
forward->PushCell(args->ArgC() - 1);
|
||||||
forward->Execute(&result2, NULL);
|
forward->Execute(&result2, NULL);
|
||||||
|
|
||||||
if (result2 > result)
|
if (result2 > result)
|
||||||
@@ -713,27 +398,12 @@ cell_t ConsoleDetours::Dispatch(ConCommand *pBase)
|
|||||||
{
|
{
|
||||||
CCommand args;
|
CCommand args;
|
||||||
#endif
|
#endif
|
||||||
g_HL2.PushCommandStack(&args);
|
EngineArgs cargs(args);
|
||||||
cell_t res = g_ConsoleDetours.InternalDispatch(g_ConCmds.GetCommandClient(), args);
|
cell_t res;
|
||||||
g_HL2.PopCommandStack();
|
|
||||||
|
|
||||||
#if SH_IMPL_VERSION < 4
|
|
||||||
if (res >= Pl_Handled)
|
|
||||||
{
|
{
|
||||||
/* See bug 4020 - we can't optimize this because looking at the vtable
|
AutoEnterCommand autoEnterCommand(&cargs);
|
||||||
* is probably more expensive, since there's no SH_GET_ORIG_VFNPTR_ENTRY.
|
res = g_ConsoleDetours.InternalDispatch(sCoreProviderImpl.CommandClient(), &cargs);
|
||||||
*/
|
|
||||||
SH_ADD_HOOK(ConCommand, Dispatch, pBase, SH_STATIC(DummyHook), false);
|
|
||||||
dummy_hook_set = true;
|
|
||||||
pBase->Dispatch();
|
|
||||||
SH_REMOVE_HOOK(ConCommand, Dispatch, pBase, SH_STATIC(DummyHook), false);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Make sure the command gets invoked. See bug 4019 on making this better. */
|
|
||||||
pBase->Dispatch();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,11 @@
|
|||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
#include <IForwardSys.h>
|
#include <IForwardSys.h>
|
||||||
#include <sm_stringhashmap.h>
|
#include <sm_hashmap.h>
|
||||||
|
|
||||||
|
namespace SourceMod {
|
||||||
|
class ICommandArgs;
|
||||||
|
} // namespace SourceMod
|
||||||
|
|
||||||
class ConsoleDetours :
|
class ConsoleDetours :
|
||||||
public SMGlobalClass,
|
public SMGlobalClass,
|
||||||
@@ -54,7 +58,7 @@ public:
|
|||||||
bool AddListener(IPluginFunction *fun, const char *command);
|
bool AddListener(IPluginFunction *fun, const char *command);
|
||||||
bool RemoveListener(IPluginFunction *fun, const char *command);
|
bool RemoveListener(IPluginFunction *fun, const char *command);
|
||||||
private:
|
private:
|
||||||
cell_t InternalDispatch(int client, const CCommand& args);
|
cell_t InternalDispatch(int client, const SourceMod::ICommandArgs *args);
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
static cell_t Dispatch(ConCommand *pBase, const CCommand& args);
|
static cell_t Dispatch(ConCommand *pBase, const CCommand& args);
|
||||||
#else
|
#else
|
||||||
|
|||||||
+390
-129
@@ -33,13 +33,18 @@
|
|||||||
#include "CoreConfig.h"
|
#include "CoreConfig.h"
|
||||||
#include "sourcemod.h"
|
#include "sourcemod.h"
|
||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
#include "sm_srvcmds.h"
|
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
#include "LibrarySys.h"
|
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "frame_hooks.h"
|
#include "frame_hooks.h"
|
||||||
#include "logic_bridge.h"
|
#include "logic_bridge.h"
|
||||||
|
#include "compat_wrappers.h"
|
||||||
#include <sourcemod_version.h>
|
#include <sourcemod_version.h>
|
||||||
|
#include <amtl/os/am-path.h>
|
||||||
|
#include <amtl/os/am-fsutil.h>
|
||||||
|
#include <list>
|
||||||
|
#include <IForwardSys.h>
|
||||||
|
#include <bridge/include/IScriptManager.h>
|
||||||
|
#include <bridge/include/ILogger.h>
|
||||||
|
|
||||||
#ifdef PLATFORM_WINDOWS
|
#ifdef PLATFORM_WINDOWS
|
||||||
ConVar sm_corecfgfile("sm_corecfgfile", "addons\\sourcemod\\configs\\core.cfg", 0, "SourceMod core configuration file");
|
ConVar sm_corecfgfile("sm_corecfgfile", "addons\\sourcemod\\configs\\core.cfg", 0, "SourceMod core configuration file");
|
||||||
@@ -60,22 +65,11 @@ ConVar *g_ServerCfgFile = NULL;
|
|||||||
|
|
||||||
void CheckAndFinalizeConfigs();
|
void CheckAndFinalizeConfigs();
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommandContext &, const CCommand &);
|
|
||||||
void Hook_ExecDispatchPre(const CCommandContext &context, const CCommand &cmd)
|
|
||||||
#elif SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
|
SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
|
||||||
void Hook_ExecDispatchPre(const CCommand &cmd)
|
void Hook_ExecDispatchPre(const CCommand &cmd)
|
||||||
#elif SOURCE_ENGINE == SE_DARKMESSIAH
|
|
||||||
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
|
||||||
void Hook_ExecDispatchPre()
|
|
||||||
#else
|
#else
|
||||||
# if SH_IMPL_VERSION >= 4
|
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
||||||
extern int __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
|
||||||
# else
|
|
||||||
extern bool __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
|
||||||
# endif
|
|
||||||
extern bool __SourceHook_FHRemoveConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
|
||||||
void Hook_ExecDispatchPre()
|
void Hook_ExecDispatchPre()
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
@@ -91,9 +85,7 @@ void Hook_ExecDispatchPre()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
void Hook_ExecDispatchPost(const CCommandContext &context, const CCommand &cmd)
|
|
||||||
#elif SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
void Hook_ExecDispatchPost(const CCommand &cmd)
|
void Hook_ExecDispatchPost(const CCommand &cmd)
|
||||||
#else
|
#else
|
||||||
void Hook_ExecDispatchPost()
|
void Hook_ExecDispatchPost()
|
||||||
@@ -117,7 +109,7 @@ void CheckAndFinalizeConfigs()
|
|||||||
|
|
||||||
void CoreConfig::OnSourceModAllInitialized()
|
void CoreConfig::OnSourceModAllInitialized()
|
||||||
{
|
{
|
||||||
g_RootMenu.AddRootConsoleCommand("config", "Set core configuration options", this);
|
rootmenu->AddRootConsoleCommand3("config", "Set core configuration options", this);
|
||||||
g_pOnServerCfg = forwardsys->CreateForward("OnServerCfg", ET_Ignore, 0, NULL);
|
g_pOnServerCfg = forwardsys->CreateForward("OnServerCfg", ET_Ignore, 0, NULL);
|
||||||
g_pOnConfigsExecuted = forwardsys->CreateForward("OnConfigsExecuted", ET_Ignore, 0, NULL);
|
g_pOnConfigsExecuted = forwardsys->CreateForward("OnConfigsExecuted", ET_Ignore, 0, NULL);
|
||||||
g_pOnAutoConfigsBuffered = forwardsys->CreateForward("OnAutoConfigsBuffered", ET_Ignore, 0, NULL);
|
g_pOnAutoConfigsBuffered = forwardsys->CreateForward("OnAutoConfigsBuffered", ET_Ignore, 0, NULL);
|
||||||
@@ -133,7 +125,7 @@ CoreConfig::~CoreConfig()
|
|||||||
|
|
||||||
void CoreConfig::OnSourceModShutdown()
|
void CoreConfig::OnSourceModShutdown()
|
||||||
{
|
{
|
||||||
g_RootMenu.RemoveRootConsoleCommand("config", this);
|
rootmenu->RemoveRootConsoleCommand("config", this);
|
||||||
forwardsys->ReleaseForward(g_pOnServerCfg);
|
forwardsys->ReleaseForward(g_pOnServerCfg);
|
||||||
forwardsys->ReleaseForward(g_pOnConfigsExecuted);
|
forwardsys->ReleaseForward(g_pOnConfigsExecuted);
|
||||||
forwardsys->ReleaseForward(g_pOnAutoConfigsBuffered);
|
forwardsys->ReleaseForward(g_pOnAutoConfigsBuffered);
|
||||||
@@ -183,44 +175,45 @@ void CoreConfig::OnSourceModLevelChange(const char *mapName)
|
|||||||
g_bGotTrigger = false;
|
g_bGotTrigger = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoreConfig::OnRootConsoleCommand(const char *cmdname, const CCommand &command)
|
void CoreConfig::OnRootConsoleCommand(const char *cmdname, const ICommandArgs *command)
|
||||||
{
|
{
|
||||||
int argcount = command.ArgC();
|
int argcount = command->ArgC();
|
||||||
if (argcount >= 4)
|
if (argcount >= 4)
|
||||||
{
|
{
|
||||||
const char *option = command.Arg(2);
|
const char *option = command->Arg(2);
|
||||||
const char *value = command.Arg(3);
|
const char *value = command->Arg(3);
|
||||||
|
|
||||||
char error[255];
|
char error[255];
|
||||||
|
|
||||||
ConfigResult res = SetConfigOption(option, value, ConfigSource_Console, error, sizeof(error));
|
ConfigResult res = SetConfigOption(option, value, ConfigSource_Console, error, sizeof(error));
|
||||||
|
|
||||||
if (res == ConfigResult_Reject)
|
if (res == ConfigResult_Reject)
|
||||||
{
|
{
|
||||||
g_RootMenu.ConsolePrint("[SM] Could not set config option \"%s\" to \"%s\". (%s)", option, value, error);
|
UTIL_ConsolePrint("[SM] Could not set config option \"%s\" to \"%s\". (%s)", option, value, error);
|
||||||
} else if (res == ConfigResult_Ignore) {
|
|
||||||
g_RootMenu.ConsolePrint("[SM] No such config option \"%s\" exists.", option);
|
|
||||||
} else {
|
} else {
|
||||||
g_RootMenu.ConsolePrint("[SM] Config option \"%s\" successfully set to \"%s\".", option, value);
|
if (res == ConfigResult_Ignore) {
|
||||||
|
UTIL_ConsolePrint("[SM] WARNING: Config option \"%s\" is not registered.", option);
|
||||||
|
}
|
||||||
|
|
||||||
|
UTIL_ConsolePrint("[SM] Config option \"%s\" set to \"%s\".", option, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else if (argcount >= 3) {
|
} else if (argcount >= 3) {
|
||||||
const char *option = command.Arg(2);
|
const char *option = command->Arg(2);
|
||||||
|
|
||||||
const char *value = GetCoreConfigValue(option);
|
const char *value = GetCoreConfigValue(option);
|
||||||
|
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
{
|
{
|
||||||
g_RootMenu.ConsolePrint("[SM] No such config option \"%s\" exists.", option);
|
UTIL_ConsolePrint("[SM] No such config option \"%s\" exists.", option);
|
||||||
} else {
|
} else {
|
||||||
g_RootMenu.ConsolePrint("[SM] Config option \"%s\" is set to \"%s\".", option, value);
|
UTIL_ConsolePrint("[SM] Config option \"%s\" is set to \"%s\".", option, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_RootMenu.ConsolePrint("[SM] Usage: sm config <option> [value]");
|
UTIL_ConsolePrint("[SM] Usage: sm config <option> [value]");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoreConfig::Initialize()
|
void CoreConfig::Initialize()
|
||||||
@@ -237,7 +230,7 @@ void CoreConfig::Initialize()
|
|||||||
*/
|
*/
|
||||||
if (corecfg)
|
if (corecfg)
|
||||||
{
|
{
|
||||||
g_LibSys.PathFormat(filePath, sizeof(filePath), "%s/%s", g_SourceMod.GetGamePath(), corecfg);
|
ke::path::Format(filePath, sizeof(filePath), "%s/%s", g_SourceMod.GetGamePath(), corecfg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -246,11 +239,11 @@ void CoreConfig::Initialize()
|
|||||||
/* Format path to config file */
|
/* Format path to config file */
|
||||||
if (basepath)
|
if (basepath)
|
||||||
{
|
{
|
||||||
g_LibSys.PathFormat(filePath, sizeof(filePath), "%s/%s/%s", g_SourceMod.GetGamePath(), basepath, "configs/core.cfg");
|
ke::path::Format(filePath, sizeof(filePath), "%s/%s/%s", g_SourceMod.GetGamePath(), basepath, "configs/core.cfg");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_LibSys.PathFormat(filePath, sizeof(filePath), "%s/%s", g_SourceMod.GetGamePath(), sm_corecfgfile.GetDefault());
|
ke::path::Format(filePath, sizeof(filePath), "%s/%s", g_SourceMod.GetGamePath(), sm_corecfgfile.GetDefault());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,7 +275,7 @@ SMCResult CoreConfig::ReadSMC_KeyValue(const SMCStates *states, const char *key,
|
|||||||
|
|
||||||
ConfigResult CoreConfig::SetConfigOption(const char *option, const char *value, ConfigSource source, char *error, size_t maxlength)
|
ConfigResult CoreConfig::SetConfigOption(const char *option, const char *value, ConfigSource source, char *error, size_t maxlength)
|
||||||
{
|
{
|
||||||
ConfigResult result;
|
ConfigResult result = ConfigResult_Ignore;
|
||||||
|
|
||||||
/* Notify! */
|
/* Notify! */
|
||||||
SMGlobalClass *pBase = SMGlobalClass::head;
|
SMGlobalClass *pBase = SMGlobalClass::head;
|
||||||
@@ -290,23 +283,23 @@ ConfigResult CoreConfig::SetConfigOption(const char *option, const char *value,
|
|||||||
{
|
{
|
||||||
if ((result = pBase->OnSourceModConfigChanged(option, value, source, error, maxlength)) != ConfigResult_Ignore)
|
if ((result = pBase->OnSourceModConfigChanged(option, value, source, error, maxlength)) != ConfigResult_Ignore)
|
||||||
{
|
{
|
||||||
return result;
|
break;
|
||||||
}
|
}
|
||||||
pBase = pBase->m_pGlobalClassNext;
|
pBase = pBase->m_pGlobalClassNext;
|
||||||
}
|
}
|
||||||
|
|
||||||
ke::AString vstr(value);
|
std::string vstr(value);
|
||||||
m_KeyValues.replace(option, ke::Move(vstr));
|
m_KeyValues.replace(option, std::move(vstr));
|
||||||
|
|
||||||
return ConfigResult_Ignore;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *CoreConfig::GetCoreConfigValue(const char *key)
|
const char *CoreConfig::GetCoreConfigValue(const char *key)
|
||||||
{
|
{
|
||||||
StringHashMap<ke::AString>::Result r = m_KeyValues.find(key);
|
StringHashMap<std::string>::Result r = m_KeyValues.find(key);
|
||||||
if (!r.found())
|
if (!r.found())
|
||||||
return NULL;
|
return NULL;
|
||||||
return r->value.chars();
|
return r->value.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SM_AreConfigsExecuted()
|
bool SM_AreConfigsExecuted()
|
||||||
@@ -323,6 +316,284 @@ inline bool IsPathSepChar(char c)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SM_ParseConfig(FILE *fp, ke::HashMap<std::string, std::string, StringPolicy> &cvars_list)
|
||||||
|
{
|
||||||
|
char line[4096];
|
||||||
|
char cvar_name[256];
|
||||||
|
|
||||||
|
while (fgets(line, sizeof(line), fp))
|
||||||
|
{
|
||||||
|
char *ptr = line;
|
||||||
|
|
||||||
|
// Ignore whitespaces and tabs
|
||||||
|
while (*ptr == ' ' || *ptr == '\t')
|
||||||
|
{
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore empty lines if found
|
||||||
|
if (*ptr == '\0' || *ptr == '\n' || *ptr == '\r')
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ignore comments
|
||||||
|
if (*ptr == '/' && *(ptr + 1) == '/')
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t i = 0;
|
||||||
|
while (*ptr != '\0' && *ptr != '\n' && *ptr != '\r' && *ptr != ' ' && *ptr != '\t' && i < (sizeof(cvar_name) - 1))
|
||||||
|
{
|
||||||
|
cvar_name[i++] = *ptr++;
|
||||||
|
}
|
||||||
|
|
||||||
|
cvar_name[i] = '\0';
|
||||||
|
|
||||||
|
if (!i)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto p = cvars_list.findForAdd(cvar_name);
|
||||||
|
if (p.found())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove spaces and tabs before the value
|
||||||
|
while (*ptr == ' ' || *ptr == '\t')
|
||||||
|
{
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *value_start = ptr;
|
||||||
|
char *value_end = value_start + strlen(value_start);
|
||||||
|
|
||||||
|
while (value_end > value_start &&
|
||||||
|
(*(value_end - 1) == '\n' ||
|
||||||
|
*(value_end - 1) == '\r' ||
|
||||||
|
*(value_end - 1) == ' ' ||
|
||||||
|
*(value_end - 1) == '\t' ||
|
||||||
|
*(value_end - 1) == '"'))
|
||||||
|
{
|
||||||
|
value_end--;
|
||||||
|
}
|
||||||
|
|
||||||
|
*value_end = '\0';
|
||||||
|
|
||||||
|
if (*value_start == '"')
|
||||||
|
{
|
||||||
|
value_start++;
|
||||||
|
}
|
||||||
|
|
||||||
|
cvars_list.add(p, cvar_name, value_start);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool SM_CvarExistsInConfig(ke::HashMap<std::string, std::string, StringPolicy> &cvars, const char *cvar_name)
|
||||||
|
{
|
||||||
|
return cvars.find(cvar_name).found();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SM_CvarExistsInPlugin(std::list<const ConVar *> &convars, const char *cvar_name)
|
||||||
|
{
|
||||||
|
for (auto iter = convars.begin(); iter != convars.end(); iter++)
|
||||||
|
{
|
||||||
|
const ConVar *cvar = (*iter);
|
||||||
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
|
if (cvar->IsFlagSet(FCVAR_DONTRECORD))
|
||||||
|
#else
|
||||||
|
if (cvar->IsBitSet(FCVAR_DONTRECORD))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcasecmp(cvar_name, cvar->GetName()) == 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SM_ConfigCheckRegeneration(
|
||||||
|
const char *file,
|
||||||
|
ke::HashMap<std::string, std::string, StringPolicy> &existing_cvars,
|
||||||
|
std::list<const ConVar *> &convars)
|
||||||
|
{
|
||||||
|
FILE *fp = fopen(file, "rt");
|
||||||
|
if (!fp)
|
||||||
|
{
|
||||||
|
logger->LogError("Failed to read config for checking regeneration, make sure the directory has read permission.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
SM_ParseConfig(fp, existing_cvars);
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
/* #1. Check if the plugin's cvar list has a cvar that doesn't exist in the config file. */
|
||||||
|
for (auto iter = convars.begin(); iter != convars.end(); iter++)
|
||||||
|
{
|
||||||
|
const ConVar *cvar = (*iter);
|
||||||
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
|
if (cvar->IsFlagSet(FCVAR_DONTRECORD))
|
||||||
|
#else
|
||||||
|
if (cvar->IsBitSet(FCVAR_DONTRECORD))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SM_CvarExistsInConfig(existing_cvars, cvar->GetName()))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* #2. Check if the config file has a cvar that doesn't exist in the plugin's cvar list. */
|
||||||
|
for (auto it = existing_cvars.iter(); !it.empty(); it.next())
|
||||||
|
{
|
||||||
|
if (!SM_CvarExistsInPlugin(convars, it->key.c_str()))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void SM_ExecuteConfigFile(const char *file)
|
||||||
|
{
|
||||||
|
char cmd[255];
|
||||||
|
ke::SafeSprintf(cmd, sizeof(cmd), "exec %s\n", file);
|
||||||
|
engine->ServerCommand(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SM_GenerateConfigFile(
|
||||||
|
IPlugin *pl,
|
||||||
|
const char *file,
|
||||||
|
std::list<const ConVar *> &convars,
|
||||||
|
bool needs_regeneration = false,
|
||||||
|
ke::HashMap<std::string, std::string, StringPolicy> *existing_cvars = NULL)
|
||||||
|
{
|
||||||
|
FILE *fp = NULL;
|
||||||
|
char tmp_file[PLATFORM_MAX_PATH];
|
||||||
|
if (!needs_regeneration)
|
||||||
|
{
|
||||||
|
fp = fopen(file, "wt");
|
||||||
|
if (!fp)
|
||||||
|
{
|
||||||
|
logger->LogError("Failed to auto generate config for %s, make sure the directory has write permission.", pl->GetFilename());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Create a .tmp file with the new contents of the new config file and then override it to the existing file */
|
||||||
|
ke::path::Format(tmp_file, sizeof(tmp_file), "%s.tmp", file);
|
||||||
|
fp = fopen(tmp_file, "wt");
|
||||||
|
if (!fp)
|
||||||
|
{
|
||||||
|
logger->LogError("Failed to create temp config file for %s, make sure the directory has write permission.", pl->GetFilename());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(fp, "// This file was auto-generated by SourceMod (v%s)\n", SOURCEMOD_VERSION);
|
||||||
|
fprintf(fp, "// ConVars for plugin \"%s\"\n", pl->GetFilename());
|
||||||
|
fprintf(fp, "\n\n");
|
||||||
|
|
||||||
|
float x;
|
||||||
|
for (auto iter = convars.begin(); iter != convars.end(); iter++)
|
||||||
|
{
|
||||||
|
const ConVar *cvar = (*iter);
|
||||||
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
|
if (cvar->IsFlagSet(FCVAR_DONTRECORD))
|
||||||
|
#else
|
||||||
|
if (cvar->IsBitSet(FCVAR_DONTRECORD))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
char descr[255];
|
||||||
|
char *dptr = descr;
|
||||||
|
|
||||||
|
/* Print comments until there is no more */
|
||||||
|
ke::SafeStrcpy(descr, sizeof(descr), cvar->GetHelpText());
|
||||||
|
while (*dptr != '\0')
|
||||||
|
{
|
||||||
|
/* Find the next line */
|
||||||
|
char *next_ptr = dptr;
|
||||||
|
while (*next_ptr != '\0')
|
||||||
|
{
|
||||||
|
if (*next_ptr == '\n')
|
||||||
|
{
|
||||||
|
*next_ptr = '\0';
|
||||||
|
next_ptr++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
next_ptr++;
|
||||||
|
}
|
||||||
|
fprintf(fp, "// %s\n", dptr);
|
||||||
|
dptr = next_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(fp, "// -\n");
|
||||||
|
fprintf(fp, "// Default: \"%s\"\n", cvar->GetDefault());
|
||||||
|
if (cvar->GetMin(x))
|
||||||
|
{
|
||||||
|
fprintf(fp, "// Minimum: \"%02f\"\n", x);
|
||||||
|
}
|
||||||
|
if (cvar->GetMax(x))
|
||||||
|
{
|
||||||
|
fprintf(fp, "// Maximum: \"%02f\"\n", x);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *value = cvar->GetDefault();
|
||||||
|
|
||||||
|
if (needs_regeneration && existing_cvars)
|
||||||
|
{
|
||||||
|
auto p = existing_cvars->find(cvar->GetName());
|
||||||
|
if (p.found())
|
||||||
|
{
|
||||||
|
value = p->value.c_str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(fp, "%s \"%s\"\n", cvar->GetName(), value);
|
||||||
|
fprintf(fp, "\n");
|
||||||
|
}
|
||||||
|
fprintf(fp, "\n");
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
if (needs_regeneration)
|
||||||
|
{
|
||||||
|
#ifdef PLATFORM_WINDOWS
|
||||||
|
if (!MoveFileEx(tmp_file, file, MOVEFILE_REPLACE_EXISTING))
|
||||||
|
#else
|
||||||
|
if (rename(tmp_file, file) != 0)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
/* Replacing the temp config file with the existing one failed, remove it and notify the user about it */
|
||||||
|
logger->LogError("Failed to replace temp config file for %s, make sure the directory has write permission.", pl->GetFilename());
|
||||||
|
if (remove(tmp_file) != 0)
|
||||||
|
{
|
||||||
|
logger->LogError("Failed to remove temp config file for %s.", pl->GetFilename());
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool SM_ExecuteConfig(IPlugin *pl, AutoConfig *cfg, bool can_create)
|
bool SM_ExecuteConfig(IPlugin *pl, AutoConfig *cfg, bool can_create)
|
||||||
{
|
{
|
||||||
bool will_create = false;
|
bool will_create = false;
|
||||||
@@ -341,12 +612,12 @@ bool SM_ExecuteConfig(IPlugin *pl, AutoConfig *cfg, bool can_create)
|
|||||||
|
|
||||||
g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "cfg/%s", folder);
|
g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "cfg/%s", folder);
|
||||||
|
|
||||||
if (!g_LibSys.IsPathDirectory(path))
|
if (!ke::file::IsDirectory(path))
|
||||||
{
|
{
|
||||||
char *cur_ptr = path;
|
char *cur_ptr = path;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
g_LibSys.PathFormat(path, sizeof(path), "%s", folder);
|
ke::path::Format(path, sizeof(path), "%s", folder);
|
||||||
len = g_SourceMod.BuildPath(Path_Game, build, sizeof(build), "cfg");
|
len = g_SourceMod.BuildPath(Path_Game, build, sizeof(build), "cfg");
|
||||||
|
|
||||||
do
|
do
|
||||||
@@ -367,14 +638,12 @@ bool SM_ExecuteConfig(IPlugin *pl, AutoConfig *cfg, bool can_create)
|
|||||||
{
|
{
|
||||||
next_ptr = NULL;
|
next_ptr = NULL;
|
||||||
}
|
}
|
||||||
len += g_LibSys.PathFormat(&build[len],
|
len += ke::path::Format(&build[len],
|
||||||
sizeof(build)-len,
|
sizeof(build)-len,
|
||||||
"/%s",
|
"/%s",
|
||||||
cur_ptr);
|
cur_ptr);
|
||||||
if (!g_LibSys.CreateFolder(build))
|
if (!ke::file::CreateDirectory(build))
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
cur_ptr = next_ptr;
|
cur_ptr = next_ptr;
|
||||||
} while (cur_ptr);
|
} while (cur_ptr);
|
||||||
}
|
}
|
||||||
@@ -386,13 +655,13 @@ bool SM_ExecuteConfig(IPlugin *pl, AutoConfig *cfg, bool can_create)
|
|||||||
|
|
||||||
if (cfg->folder.size())
|
if (cfg->folder.size())
|
||||||
{
|
{
|
||||||
g_LibSys.PathFormat(local,
|
ke::path::Format(local,
|
||||||
sizeof(local),
|
sizeof(local),
|
||||||
"%s/%s.cfg",
|
"%s/%s.cfg",
|
||||||
cfg->folder.c_str(),
|
cfg->folder.c_str(),
|
||||||
cfg->autocfg.c_str());
|
cfg->autocfg.c_str());
|
||||||
} else {
|
} else {
|
||||||
g_LibSys.PathFormat(local,
|
ke::path::Format(local,
|
||||||
sizeof(local),
|
sizeof(local),
|
||||||
"%s.cfg",
|
"%s.cfg",
|
||||||
cfg->autocfg.c_str());
|
cfg->autocfg.c_str());
|
||||||
@@ -400,88 +669,63 @@ bool SM_ExecuteConfig(IPlugin *pl, AutoConfig *cfg, bool can_create)
|
|||||||
|
|
||||||
g_SourceMod.BuildPath(Path_Game, file, sizeof(file), "cfg/%s", local);
|
g_SourceMod.BuildPath(Path_Game, file, sizeof(file), "cfg/%s", local);
|
||||||
|
|
||||||
bool file_exists = g_LibSys.IsPathFile(file);
|
bool file_exists = ke::file::IsFile(file);
|
||||||
if (!file_exists && will_create)
|
|
||||||
|
if (!will_create)
|
||||||
{
|
{
|
||||||
List<const ConVar *> *convars = NULL;
|
if (file_exists)
|
||||||
if (pl->GetProperty("ConVarList", (void **)&convars, false) && convars)
|
|
||||||
{
|
{
|
||||||
/* Attempt to create it */
|
SM_ExecuteConfigFile(local);
|
||||||
FILE *fp = fopen(file, "wt");
|
|
||||||
if (fp)
|
|
||||||
{
|
|
||||||
fprintf(fp, "// This file was auto-generated by SourceMod (v%s)\n", SOURCEMOD_VERSION);
|
|
||||||
fprintf(fp, "// ConVars for plugin \"%s\"\n", pl->GetFilename());
|
|
||||||
fprintf(fp, "\n\n");
|
|
||||||
|
|
||||||
List<const ConVar *>::iterator iter;
|
|
||||||
float x;
|
|
||||||
for (iter = convars->begin(); iter != convars->end(); iter++)
|
|
||||||
{
|
|
||||||
const ConVar *cvar = (*iter);
|
|
||||||
|
|
||||||
if ((cvar->GetFlags() & FCVAR_DONTRECORD) == FCVAR_DONTRECORD)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
char descr[255];
|
|
||||||
char *dptr = descr;
|
|
||||||
|
|
||||||
/* Print comments until there is no more */
|
|
||||||
strncopy(descr, cvar->GetHelpText(), sizeof(descr));
|
|
||||||
while (*dptr != '\0')
|
|
||||||
{
|
|
||||||
/* Find the next line */
|
|
||||||
char *next_ptr = dptr;
|
|
||||||
while (*next_ptr != '\0')
|
|
||||||
{
|
|
||||||
if (*next_ptr == '\n')
|
|
||||||
{
|
|
||||||
*next_ptr = '\0';
|
|
||||||
next_ptr++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
next_ptr++;
|
|
||||||
}
|
|
||||||
fprintf(fp, "// %s\n", dptr);
|
|
||||||
dptr = next_ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(fp, "// -\n");
|
|
||||||
fprintf(fp, "// Default: \"%s\"\n", cvar->GetDefault());
|
|
||||||
if (cvar->GetMin(x))
|
|
||||||
{
|
|
||||||
fprintf(fp, "// Minimum: \"%02f\"\n", x);
|
|
||||||
}
|
|
||||||
if (cvar->GetMax(x))
|
|
||||||
{
|
|
||||||
fprintf(fp, "// Maximum: \"%02f\"\n", x);
|
|
||||||
}
|
|
||||||
fprintf(fp, "%s \"%s\"\n", cvar->GetName(), cvar->GetDefault());
|
|
||||||
fprintf(fp, "\n");
|
|
||||||
}
|
|
||||||
fprintf(fp, "\n");
|
|
||||||
|
|
||||||
file_exists = true;
|
|
||||||
can_create = false;
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
logger->LogError("Failed to auto generate config for %s, make sure the directory has write permission.", pl->GetFilename());
|
|
||||||
return can_create;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return can_create;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists)
|
std::list<const ConVar *> *convars = NULL;
|
||||||
|
if (!pl->GetProperty("ConVarList", (void **)&convars, false) || !convars)
|
||||||
{
|
{
|
||||||
char cmd[255];
|
if (file_exists)
|
||||||
UTIL_Format(cmd, sizeof(cmd), "exec %s\n", local);
|
{
|
||||||
engine->ServerCommand(cmd);
|
SM_ExecuteConfigFile(local);
|
||||||
|
}
|
||||||
|
|
||||||
|
return can_create;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!file_exists)
|
||||||
|
{
|
||||||
|
/* If file doesn't exist, then automatically generate the config file and execute it. */
|
||||||
|
/* If sourcemod somehow failed to generate the config file, then stop. */
|
||||||
|
if (!SM_GenerateConfigFile(pl, file, *convars))
|
||||||
|
{
|
||||||
|
return can_create;
|
||||||
|
}
|
||||||
|
|
||||||
|
SM_ExecuteConfigFile(local);
|
||||||
|
can_create = false;
|
||||||
|
return can_create;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now if the file exists, read the content of it to see if we need to regenerate it or not. */
|
||||||
|
ke::HashMap<std::string, std::string, StringPolicy> existing_cvars;
|
||||||
|
existing_cvars.init();
|
||||||
|
if (!SM_ConfigCheckRegeneration(file, existing_cvars, *convars))
|
||||||
|
{
|
||||||
|
SM_ExecuteConfigFile(local);
|
||||||
|
return can_create;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* File exists and misses cvars between the config file and the plugin's convars list
|
||||||
|
* Create a temporary config file with the new contents and then override it to the existing file.
|
||||||
|
* If sourcemod somehow failed to override the new contents to the existing config file, then execute the existing config file.
|
||||||
|
*/
|
||||||
|
can_create = false;
|
||||||
|
if (!SM_GenerateConfigFile(pl, file, *convars, true, &existing_cvars))
|
||||||
|
{
|
||||||
|
logger->LogError("An error occurred while regenerating config file for %s, executing the existing file instead.", pl->GetFilename());
|
||||||
|
}
|
||||||
|
|
||||||
|
SM_ExecuteConfigFile(local);
|
||||||
return can_create;
|
return can_create;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -518,7 +762,7 @@ void SM_ConfigsExecuted_Plugin(unsigned int serial)
|
|||||||
|
|
||||||
void SM_ExecuteForPlugin(IPluginContext *ctx)
|
void SM_ExecuteForPlugin(IPluginContext *ctx)
|
||||||
{
|
{
|
||||||
SMPlugin *plugin = scripts->FindPluginByContext(ctx->GetContext());
|
SMPlugin *plugin = scripts->FindPluginByContext(ctx);
|
||||||
|
|
||||||
unsigned int num = plugin->GetConfigCount();
|
unsigned int num = plugin->GetConfigCount();
|
||||||
if (!num)
|
if (!num)
|
||||||
@@ -533,7 +777,7 @@ void SM_ExecuteForPlugin(IPluginContext *ctx)
|
|||||||
can_create = SM_ExecuteConfig(plugin, plugin->GetConfig(i), can_create);
|
can_create = SM_ExecuteConfig(plugin, plugin->GetConfig(i), can_create);
|
||||||
}
|
}
|
||||||
char cmd[255];
|
char cmd[255];
|
||||||
UTIL_Format(cmd, sizeof(cmd), "sm internal 2 %d\n", plugin->GetSerial());
|
ke::SafeSprintf(cmd, sizeof(cmd), "sm_internal 2 %d\n", plugin->GetSerial());
|
||||||
engine->ServerCommand(cmd);
|
engine->ServerCommand(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -580,7 +824,24 @@ void SM_InternalCmdTrigger()
|
|||||||
{
|
{
|
||||||
/* Order is important here. We need to buffer things before we send the command out. */
|
/* Order is important here. We need to buffer things before we send the command out. */
|
||||||
g_pOnAutoConfigsBuffered->Execute(NULL);
|
g_pOnAutoConfigsBuffered->Execute(NULL);
|
||||||
engine->ServerCommand("sm internal 1\n");
|
engine->ServerCommand("sm_internal 1\n");
|
||||||
g_PendingInternalPush = false;
|
g_PendingInternalPush = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CON_COMMAND(sm_internal, "")
|
||||||
|
{
|
||||||
|
#if SOURCE_ENGINE <= SE_DARKMESSIAH
|
||||||
|
CCommand args;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (args.ArgC() < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const char *arg = args.Arg(1);
|
||||||
|
if (strcmp(arg, "1") == 0) {
|
||||||
|
SM_ConfigsExecuted_Global();
|
||||||
|
} else if (strcmp(arg, "2") == 0) {
|
||||||
|
if (args.ArgC() >= 3)
|
||||||
|
SM_ConfigsExecuted_Plugin(atoi(args.Arg(2)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+16
-3
@@ -36,7 +36,7 @@
|
|||||||
#include <ITextParsers.h>
|
#include <ITextParsers.h>
|
||||||
#include <IRootConsoleMenu.h>
|
#include <IRootConsoleMenu.h>
|
||||||
#include <am-string.h>
|
#include <am-string.h>
|
||||||
#include <sm_stringhashmap.h>
|
#include <sm_hashmap.h>
|
||||||
|
|
||||||
using namespace SourceMod;
|
using namespace SourceMod;
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ public: // SMGlobalClass
|
|||||||
public: // ITextListener_SMC
|
public: // ITextListener_SMC
|
||||||
SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value);
|
SMCResult ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value);
|
||||||
public: // IRootConsoleCommand
|
public: // IRootConsoleCommand
|
||||||
void OnRootConsoleCommand(const char *cmdname, const CCommand &command);
|
void OnRootConsoleCommand(const char *cmdname, const ICommandArgs *command) override;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Initializes CoreConfig by reading from core.cfg file
|
* Initializes CoreConfig by reading from core.cfg file
|
||||||
@@ -68,7 +68,20 @@ private:
|
|||||||
*/
|
*/
|
||||||
ConfigResult SetConfigOption(const char *option, const char *value, ConfigSource, char *Error, size_t maxlength);
|
ConfigResult SetConfigOption(const char *option, const char *value, ConfigSource, char *Error, size_t maxlength);
|
||||||
private:
|
private:
|
||||||
StringHashMap<ke::AString> m_KeyValues;
|
StringHashMap<std::string> m_KeyValues;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct StringPolicy
|
||||||
|
{
|
||||||
|
static inline uint32_t hash(const std::string &key)
|
||||||
|
{
|
||||||
|
std::string lower = ke::Lowercase(key.c_str());
|
||||||
|
return ke::FastHashCharSequence(lower.c_str(), lower.length());
|
||||||
|
}
|
||||||
|
static inline bool matches(const char *find, const std::string &key)
|
||||||
|
{
|
||||||
|
return strcasecmp(find, key.c_str()) == 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern bool SM_AreConfigsExecuted();
|
extern bool SM_AreConfigsExecuted();
|
||||||
|
|||||||
@@ -1,199 +0,0 @@
|
|||||||
/**
|
|
||||||
* vim: set ts=4 :
|
|
||||||
* =============================================================================
|
|
||||||
* SourceMod
|
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
|
||||||
* =============================================================================
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
|
||||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
||||||
* Free Software Foundation.
|
|
||||||
*
|
|
||||||
* 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
||||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
||||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
||||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
||||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
||||||
* this exception to all derivative works. AlliedModders LLC defines further
|
|
||||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
||||||
* or <http://www.sourcemod.net/license.php>.
|
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "sm_globals.h"
|
|
||||||
#include "sourcemm_api.h"
|
|
||||||
#include "Tlhelp32.h"
|
|
||||||
#include "LibrarySys.h"
|
|
||||||
#include "minidump.h"
|
|
||||||
#include "sm_stringutil.h"
|
|
||||||
|
|
||||||
bool HookImportAddrTable(BYTE *base, const char *func, DWORD hookfunc, char *err, size_t maxlength)
|
|
||||||
{
|
|
||||||
IMAGE_DOS_HEADER *dos = (IMAGE_DOS_HEADER *)base;
|
|
||||||
if (dos->e_magic != IMAGE_DOS_SIGNATURE)
|
|
||||||
{
|
|
||||||
UTIL_Format(err, maxlength, "%s", "Could not detect valid DOS signature");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
IMAGE_NT_HEADERS *nt = (IMAGE_NT_HEADERS *)(base + dos->e_lfanew);
|
|
||||||
if (nt->Signature != IMAGE_NT_SIGNATURE)
|
|
||||||
{
|
|
||||||
UTIL_Format(err, maxlength, "%s", "Could not detect valid NT signature");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
IMAGE_IMPORT_DESCRIPTOR *desc =
|
|
||||||
(IMAGE_IMPORT_DESCRIPTOR *)
|
|
||||||
(base + nt->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
|
|
||||||
if (base == (BYTE *)desc)
|
|
||||||
{
|
|
||||||
UTIL_Format(err, maxlength, "%s", "Could not find IAT");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool entryFound = false;
|
|
||||||
while (desc->Name)
|
|
||||||
{
|
|
||||||
if (desc->FirstThunk != 0)
|
|
||||||
{
|
|
||||||
IMAGE_THUNK_DATA *data = (IMAGE_THUNK_DATA *)(base + desc->OriginalFirstThunk);
|
|
||||||
DWORD *iat = (DWORD *)(base + desc->FirstThunk);
|
|
||||||
while (data->u1.Function)
|
|
||||||
{
|
|
||||||
if ((data->u1.Ordinal & IMAGE_ORDINAL_FLAG32) != IMAGE_ORDINAL_FLAG32)
|
|
||||||
{
|
|
||||||
IMAGE_IMPORT_BY_NAME *import = (IMAGE_IMPORT_BY_NAME *)(base + data->u1.AddressOfData);
|
|
||||||
if (strcmp((char *)import->Name, func) == 0)
|
|
||||||
{
|
|
||||||
DWORD oldprot, oldprot2;
|
|
||||||
VirtualProtect(iat, 4, PAGE_READWRITE, &oldprot);
|
|
||||||
*iat = hookfunc;
|
|
||||||
VirtualProtect(iat, 4, oldprot, &oldprot2);
|
|
||||||
entryFound = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
data++;
|
|
||||||
iat++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
desc++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!entryFound)
|
|
||||||
{
|
|
||||||
UTIL_Format(err, maxlength, "Could not find IAT entry for %s", func);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL
|
|
||||||
WINAPI
|
|
||||||
MiniDumpWriteDump2(
|
|
||||||
IN HANDLE hProcess,
|
|
||||||
IN DWORD ProcessId,
|
|
||||||
IN HANDLE hFile,
|
|
||||||
IN MINIDUMP_TYPE DumpType,
|
|
||||||
IN CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, OPTIONAL
|
|
||||||
IN CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, OPTIONAL
|
|
||||||
IN CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam OPTIONAL
|
|
||||||
)
|
|
||||||
{
|
|
||||||
DumpType = (MINIDUMP_TYPE)((int)DumpType|MiniDumpWithFullMemory|MiniDumpWithHandleData);
|
|
||||||
return MiniDumpWriteDump(hProcess, ProcessId, hFile, DumpType, ExceptionParam, UserStreamParam, CallbackParam);
|
|
||||||
}
|
|
||||||
|
|
||||||
FARPROC WINAPI GetProcAddress2(HMODULE hModule, LPCSTR lpProcName)
|
|
||||||
{
|
|
||||||
if (strcmp(lpProcName, "MiniDumpWriteDump") == 0)
|
|
||||||
{
|
|
||||||
return (FARPROC)MiniDumpWriteDump2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return GetProcAddress(hModule, lpProcName);
|
|
||||||
}
|
|
||||||
|
|
||||||
HMODULE WINAPI LoadLibraryEx2(LPCTSTR lpFileName, HANDLE hFile, DWORD dwFlags)
|
|
||||||
{
|
|
||||||
HMODULE lib = LoadLibraryEx(lpFileName, hFile, dwFlags);
|
|
||||||
|
|
||||||
/* Steam.dll seems to get loaded using an abs path, thus the use of stristr() */
|
|
||||||
if (stristr(lpFileName, "steam.dll"))
|
|
||||||
{
|
|
||||||
char err[64];
|
|
||||||
if (!HookImportAddrTable((BYTE *)lib, "GetProcAddress", (DWORD)GetProcAddress2, err, sizeof(err)))
|
|
||||||
{
|
|
||||||
Error("[SM] %s in steam.dll\n", err);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return lib;
|
|
||||||
}
|
|
||||||
|
|
||||||
class CrazyWindowsDebugger : public SMGlobalClass
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
void OnSourceModAllInitialized()
|
|
||||||
{
|
|
||||||
HANDLE hModuleList = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId());
|
|
||||||
MODULEENTRY32 me32;
|
|
||||||
BYTE *engine = NULL;
|
|
||||||
BYTE *steam = NULL;
|
|
||||||
char err[64];
|
|
||||||
|
|
||||||
me32.dwSize = sizeof(MODULEENTRY32);
|
|
||||||
|
|
||||||
if (!Module32First(hModuleList, &me32))
|
|
||||||
{
|
|
||||||
Error("Could not initialize crazy debugger!");
|
|
||||||
}
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (strcasecmp(me32.szModule, "engine.dll") == 0)
|
|
||||||
{
|
|
||||||
engine = me32.modBaseAddr;
|
|
||||||
}
|
|
||||||
else if (strcasecmp(me32.szModule, "steam.dll") == 0)
|
|
||||||
{
|
|
||||||
steam = me32.modBaseAddr;
|
|
||||||
}
|
|
||||||
} while (Module32Next(hModuleList, &me32));
|
|
||||||
|
|
||||||
CloseHandle(hModuleList);
|
|
||||||
|
|
||||||
/* This really should not happen, but ... */
|
|
||||||
if (!engine)
|
|
||||||
{
|
|
||||||
Error("[SM] Could not find engine.dll\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Steam.dll isn't loaded yet */
|
|
||||||
if (!steam)
|
|
||||||
{
|
|
||||||
if (!HookImportAddrTable(engine, "LoadLibraryExA", (DWORD)LoadLibraryEx2, err, sizeof(err)))
|
|
||||||
{
|
|
||||||
Error("[SM] %s in engine.dll)\n", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!HookImportAddrTable(steam, "GetProcAddress", (DWORD)GetProcAddress2, err, sizeof(err)))
|
|
||||||
{
|
|
||||||
Error("[SM] %s in steam.dll)\n", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} s_CrazyDebugger;
|
|
||||||
+24
-17
@@ -31,14 +31,17 @@
|
|||||||
|
|
||||||
#include "EventManager.h"
|
#include "EventManager.h"
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
|
#include "PlayerManager.h"
|
||||||
|
|
||||||
#include "logic_bridge.h"
|
#include "logic_bridge.h"
|
||||||
|
#include <bridge/include/IScriptManager.h>
|
||||||
|
|
||||||
EventManager g_EventManager;
|
EventManager g_EventManager;
|
||||||
|
|
||||||
SH_DECL_HOOK2(IGameEventManager2, FireEvent, SH_NOATTRIB, 0, bool, IGameEvent *, bool);
|
SH_DECL_HOOK2(IGameEventManager2, FireEvent, SH_NOATTRIB, 0, bool, IGameEvent *, bool);
|
||||||
|
|
||||||
const ParamType GAMEEVENT_PARAMS[] = {Param_Cell, Param_String, Param_Cell};
|
const ParamType GAMEEVENT_PARAMS[] = {Param_Cell, Param_String, Param_Cell};
|
||||||
typedef List<EventHook *> EventHookList;
|
typedef std::list<EventHook *> EventHookList;
|
||||||
|
|
||||||
class EventForwardFilter : public IForwardFilter
|
class EventForwardFilter : public IForwardFilter
|
||||||
{
|
{
|
||||||
@@ -61,13 +64,10 @@ EventManager::EventManager() : m_EventType(0)
|
|||||||
EventManager::~EventManager()
|
EventManager::~EventManager()
|
||||||
{
|
{
|
||||||
/* Free memory used by EventInfo structs if any */
|
/* Free memory used by EventInfo structs if any */
|
||||||
CStack<EventInfo *>::iterator iter;
|
while (!m_FreeEvents.empty()) {
|
||||||
for (iter = m_FreeEvents.begin(); iter != m_FreeEvents.end(); iter++)
|
delete m_FreeEvents.top();
|
||||||
{
|
m_FreeEvents.pop();
|
||||||
delete (*iter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_FreeEvents.popall();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventManager::OnSourceModAllInitialized()
|
void EventManager::OnSourceModAllInitialized()
|
||||||
@@ -155,7 +155,7 @@ void EventManager::FireGameEvent(IGameEvent *pEvent)
|
|||||||
Just need to add ourselves as a listener to make our hook on IGameEventManager2::FireEvent work */
|
Just need to add ourselves as a listener to make our hook on IGameEventManager2::FireEvent work */
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE >= SE_LEFT4DEAD && SOURCE_ENGINE != SE_DOTA
|
#if SOURCE_ENGINE >= SE_LEFT4DEAD
|
||||||
int EventManager::GetEventDebugID()
|
int EventManager::GetEventDebugID()
|
||||||
{
|
{
|
||||||
return EVENT_DEBUG_ID_INIT;
|
return EVENT_DEBUG_ID_INIT;
|
||||||
@@ -181,7 +181,7 @@ EventHookError EventManager::HookEvent(const char *name, IPluginFunction *pFunct
|
|||||||
if (!m_EventHooks.retrieve(name, &pHook))
|
if (!m_EventHooks.retrieve(name, &pHook))
|
||||||
{
|
{
|
||||||
EventHookList *pHookList;
|
EventHookList *pHookList;
|
||||||
IPlugin *plugin = scripts->FindPluginByContext(pFunction->GetParentContext()->GetContext());
|
IPlugin *plugin = scripts->FindPluginByContext(pFunction->GetParentContext());
|
||||||
|
|
||||||
/* Check plugin for an existing EventHook list */
|
/* Check plugin for an existing EventHook list */
|
||||||
if (!plugin->GetProperty("EventHooks", (void **)&pHookList))
|
if (!plugin->GetProperty("EventHooks", (void **)&pHookList))
|
||||||
@@ -294,7 +294,7 @@ EventHookError EventManager::UnhookEvent(const char *name, IPluginFunction *pFun
|
|||||||
/* If reference count is now 0, free hook structure */
|
/* If reference count is now 0, free hook structure */
|
||||||
|
|
||||||
EventHookList *pHookList;
|
EventHookList *pHookList;
|
||||||
IPlugin *plugin = scripts->FindPluginByContext(pFunction->GetParentContext()->GetContext());
|
IPlugin *plugin = scripts->FindPluginByContext(pFunction->GetParentContext());
|
||||||
|
|
||||||
/* Get plugin's event hook list */
|
/* Get plugin's event hook list */
|
||||||
if (!plugin->GetProperty("EventHooks", (void**)&pHookList))
|
if (!plugin->GetProperty("EventHooks", (void**)&pHookList))
|
||||||
@@ -303,7 +303,7 @@ EventHookError EventManager::UnhookEvent(const char *name, IPluginFunction *pFun
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure the event was actually being hooked */
|
/* Make sure the event was actually being hooked */
|
||||||
if (pHookList->find(pHook) == pHookList->end())
|
if (std::find(pHookList->begin(), pHookList->end(), pHook) == pHookList->end())
|
||||||
{
|
{
|
||||||
return EventHookErr_NotActive;
|
return EventHookErr_NotActive;
|
||||||
}
|
}
|
||||||
@@ -332,7 +332,7 @@ EventInfo *EventManager::CreateEvent(IPluginContext *pContext, const char *name,
|
|||||||
{
|
{
|
||||||
pInfo = new EventInfo();
|
pInfo = new EventInfo();
|
||||||
} else {
|
} else {
|
||||||
pInfo = m_FreeEvents.front();
|
pInfo = m_FreeEvents.top();
|
||||||
m_FreeEvents.pop();
|
m_FreeEvents.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,6 +359,13 @@ void EventManager::FireEvent(EventInfo *pInfo, bool bDontBroadcast)
|
|||||||
m_FreeEvents.push(pInfo);
|
m_FreeEvents.push(pInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EventManager::FireEventToClient(EventInfo *pInfo, IClient *pClient)
|
||||||
|
{
|
||||||
|
// The IClient vtable is +sizeof(void *) from the IGameEventListener2 (CBaseClient) vtable due to multiple inheritance.
|
||||||
|
IGameEventListener2 *pGameClient = (IGameEventListener2 *)((intptr_t)pClient - sizeof(void *));
|
||||||
|
pGameClient->FireGameEvent(pInfo->pEvent);
|
||||||
|
}
|
||||||
|
|
||||||
void EventManager::CancelCreatedEvent(EventInfo *pInfo)
|
void EventManager::CancelCreatedEvent(EventInfo *pInfo)
|
||||||
{
|
{
|
||||||
/* Free event from IGameEventManager2 */
|
/* Free event from IGameEventManager2 */
|
||||||
@@ -423,7 +430,7 @@ bool EventManager::OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast)
|
|||||||
m_EventCopies.push(gameevents->DuplicateEvent(pEvent));
|
m_EventCopies.push(gameevents->DuplicateEvent(pEvent));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res)
|
if (res >= Pl_Handled)
|
||||||
{
|
{
|
||||||
gameevents->FreeEvent(pEvent);
|
gameevents->FreeEvent(pEvent);
|
||||||
RETURN_META_VALUE(MRES_SUPERCEDE, false);
|
RETURN_META_VALUE(MRES_SUPERCEDE, false);
|
||||||
@@ -454,7 +461,7 @@ bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast)
|
|||||||
RETURN_META_VALUE(MRES_IGNORED, false);
|
RETURN_META_VALUE(MRES_IGNORED, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
pHook = m_EventStack.front();
|
pHook = m_EventStack.top();
|
||||||
|
|
||||||
if (pHook != NULL)
|
if (pHook != NULL)
|
||||||
{
|
{
|
||||||
@@ -465,7 +472,7 @@ bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast)
|
|||||||
if (pHook->postCopy)
|
if (pHook->postCopy)
|
||||||
{
|
{
|
||||||
info.bDontBroadcast = bDontBroadcast;
|
info.bDontBroadcast = bDontBroadcast;
|
||||||
info.pEvent = m_EventCopies.front();
|
info.pEvent = m_EventCopies.top();
|
||||||
info.pOwner = NULL;
|
info.pOwner = NULL;
|
||||||
hndl = handlesys->CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL);
|
hndl = handlesys->CreateHandle(m_EventType, &info, NULL, g_pCoreIdent, NULL);
|
||||||
|
|
||||||
@@ -474,7 +481,7 @@ bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast)
|
|||||||
pForward->PushCell(BAD_HANDLE);
|
pForward->PushCell(BAD_HANDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
pForward->PushString(pHook->name.chars());
|
pForward->PushString(pHook->name.c_str());
|
||||||
pForward->PushCell(bDontBroadcast);
|
pForward->PushCell(bDontBroadcast);
|
||||||
pForward->Execute(NULL);
|
pForward->Execute(NULL);
|
||||||
|
|
||||||
@@ -495,7 +502,7 @@ bool EventManager::OnFireEvent_Post(IGameEvent *pEvent, bool bDontBroadcast)
|
|||||||
{
|
{
|
||||||
assert(pHook->pPostHook == NULL);
|
assert(pHook->pPostHook == NULL);
|
||||||
assert(pHook->pPreHook == NULL);
|
assert(pHook->pPreHook == NULL);
|
||||||
m_EventHooks.remove(pHook->name.chars());
|
m_EventHooks.remove(pHook->name.c_str());
|
||||||
delete pHook;
|
delete pHook;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-9
@@ -35,13 +35,13 @@
|
|||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
#include <sm_namehashset.h>
|
#include <sm_namehashset.h>
|
||||||
#include <sh_list.h>
|
#include <list>
|
||||||
#include <sh_stack.h>
|
#include <stack>
|
||||||
#include <IHandleSys.h>
|
#include <IHandleSys.h>
|
||||||
#include <IForwardSys.h>
|
#include <IForwardSys.h>
|
||||||
#include <IPluginSys.h>
|
#include <IPluginSys.h>
|
||||||
|
|
||||||
using namespace SourceHook;
|
class IClient;
|
||||||
|
|
||||||
struct EventInfo
|
struct EventInfo
|
||||||
{
|
{
|
||||||
@@ -69,11 +69,15 @@ struct EventHook
|
|||||||
IChangeableForward *pPostHook;
|
IChangeableForward *pPostHook;
|
||||||
bool postCopy;
|
bool postCopy;
|
||||||
unsigned int refCount;
|
unsigned int refCount;
|
||||||
ke::AString name;
|
std::string name;
|
||||||
|
|
||||||
static inline bool matches(const char *name, const EventHook *hook)
|
static inline bool matches(const char *name, const EventHook *hook)
|
||||||
{
|
{
|
||||||
return strcmp(name, hook->name.chars()) == 0;
|
return strcmp(name, hook->name.c_str()) == 0;
|
||||||
|
}
|
||||||
|
static inline uint32_t hash(const detail::CharsAndLength &key)
|
||||||
|
{
|
||||||
|
return key.hash();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -110,7 +114,7 @@ public: // IPluginsListener
|
|||||||
void OnPluginUnloaded(IPlugin *plugin);
|
void OnPluginUnloaded(IPlugin *plugin);
|
||||||
public: // IGameEventListener2
|
public: // IGameEventListener2
|
||||||
void FireGameEvent(IGameEvent *pEvent);
|
void FireGameEvent(IGameEvent *pEvent);
|
||||||
#if SOURCE_ENGINE >= SE_LEFT4DEAD && SOURCE_ENGINE != SE_DOTA
|
#if SOURCE_ENGINE >= SE_LEFT4DEAD
|
||||||
int GetEventDebugID();
|
int GetEventDebugID();
|
||||||
#endif
|
#endif
|
||||||
public:
|
public:
|
||||||
@@ -126,6 +130,7 @@ public:
|
|||||||
EventHookError UnhookEvent(const char *name, IPluginFunction *pFunction, EventHookMode mode=EventHookMode_Post);
|
EventHookError UnhookEvent(const char *name, IPluginFunction *pFunction, EventHookMode mode=EventHookMode_Post);
|
||||||
EventInfo *CreateEvent(IPluginContext *pContext, const char *name, bool force=false);
|
EventInfo *CreateEvent(IPluginContext *pContext, const char *name, bool force=false);
|
||||||
void FireEvent(EventInfo *pInfo, bool bDontBroadcast=false);
|
void FireEvent(EventInfo *pInfo, bool bDontBroadcast=false);
|
||||||
|
void FireEventToClient(EventInfo *pInfo, IClient *pClient);
|
||||||
void CancelCreatedEvent(EventInfo *pInfo);
|
void CancelCreatedEvent(EventInfo *pInfo);
|
||||||
private: // IGameEventManager2 hooks
|
private: // IGameEventManager2 hooks
|
||||||
bool OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast);
|
bool OnFireEvent(IGameEvent *pEvent, bool bDontBroadcast);
|
||||||
@@ -133,9 +138,9 @@ private: // IGameEventManager2 hooks
|
|||||||
private:
|
private:
|
||||||
HandleType_t m_EventType;
|
HandleType_t m_EventType;
|
||||||
NameHashSet<EventHook *> m_EventHooks;
|
NameHashSet<EventHook *> m_EventHooks;
|
||||||
CStack<EventInfo *> m_FreeEvents;
|
std::stack<EventInfo *> m_FreeEvents;
|
||||||
CStack<EventHook *> m_EventStack;
|
std::stack<EventHook *> m_EventStack;
|
||||||
CStack<IGameEvent *> m_EventCopies;
|
std::stack<IGameEvent *> m_EventCopies;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern EventManager g_EventManager;
|
extern EventManager g_EventManager;
|
||||||
|
|||||||
@@ -0,0 +1,171 @@
|
|||||||
|
// vim: set ts=4 sw=4 tw=99 noet :
|
||||||
|
// =============================================================================
|
||||||
|
// SourceMod
|
||||||
|
// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved.
|
||||||
|
// =============================================================================
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
// Free Software Foundation.
|
||||||
|
//
|
||||||
|
// 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
// code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
// by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
// all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
// this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
// or <http://www.sourcemod.net/license.php>.
|
||||||
|
#include "GameHooks.h"
|
||||||
|
#include "sourcemod.h"
|
||||||
|
#include "ConVarManager.h"
|
||||||
|
#include "command_args.h"
|
||||||
|
#include "provider.h"
|
||||||
|
|
||||||
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
|
SH_DECL_HOOK3_void(ICvar, CallGlobalChangeCallbacks, SH_NOATTRIB, false, ConVar *, const char *, float);
|
||||||
|
#else
|
||||||
|
SH_DECL_HOOK2_void(ICvar, CallGlobalChangeCallback, SH_NOATTRIB, false, ConVar *, const char *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SOURCE_ENGINE != SE_DARKMESSIAH
|
||||||
|
SH_DECL_HOOK5_void(IServerGameDLL, OnQueryCvarValueFinished, SH_NOATTRIB, 0, QueryCvarCookie_t, edict_t *, EQueryCvarValueStatus, const char *, const char *);
|
||||||
|
SH_DECL_HOOK5_void(IServerPluginCallbacks, OnQueryCvarValueFinished, SH_NOATTRIB, 0, QueryCvarCookie_t, edict_t *, EQueryCvarValueStatus, const char *, const char *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
|
SH_DECL_HOOK1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
|
||||||
|
#else
|
||||||
|
SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SH_DECL_HOOK1_void(IServerGameClients, SetCommandClient, SH_NOATTRIB, false, int);
|
||||||
|
|
||||||
|
GameHooks::GameHooks()
|
||||||
|
: client_cvar_query_mode_(ClientCvarQueryMode::Unavailable),
|
||||||
|
last_command_client_(-1)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameHooks::Start()
|
||||||
|
{
|
||||||
|
// Hook ICvar::CallGlobalChangeCallbacks.
|
||||||
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
|
hooks_ += SH_ADD_HOOK(ICvar, CallGlobalChangeCallbacks, icvar, SH_STATIC(OnConVarChanged), false);
|
||||||
|
#else
|
||||||
|
hooks_ += SH_ADD_HOOK(ICvar, CallGlobalChangeCallback, icvar, SH_STATIC(OnConVarChanged), false);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Episode 2 has this function by default, but the older versions do not.
|
||||||
|
#if SOURCE_ENGINE == SE_EPISODEONE
|
||||||
|
if (g_SMAPI->GetGameDLLVersion() >= 6) {
|
||||||
|
hooks_ += SH_ADD_HOOK(IServerGameDLL, OnQueryCvarValueFinished, gamedll, SH_MEMBER(this, &GameHooks::OnQueryCvarValueFinished), false);
|
||||||
|
client_cvar_query_mode_ = ClientCvarQueryMode::DLL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
hooks_ += SH_ADD_HOOK(IServerGameClients, SetCommandClient, serverClients, SH_MEMBER(this, &GameHooks::SetCommandClient), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameHooks::OnVSPReceived()
|
||||||
|
{
|
||||||
|
if (client_cvar_query_mode_ != ClientCvarQueryMode::Unavailable)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (g_SMAPI->GetSourceEngineBuild() == SOURCE_ENGINE_ORIGINAL || vsp_version < 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
#if SOURCE_ENGINE != SE_DARKMESSIAH
|
||||||
|
hooks_ += SH_ADD_HOOK(IServerPluginCallbacks, OnQueryCvarValueFinished, vsp_interface, SH_MEMBER(this, &GameHooks::OnQueryCvarValueFinished), false);
|
||||||
|
client_cvar_query_mode_ = ClientCvarQueryMode::VSP;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameHooks::Shutdown()
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < hooks_.size(); i++)
|
||||||
|
SH_REMOVE_HOOK_ID(hooks_[i]);
|
||||||
|
hooks_.clear();
|
||||||
|
|
||||||
|
client_cvar_query_mode_ = ClientCvarQueryMode::Unavailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
|
void GameHooks::OnConVarChanged(ConVar *pConVar, const char *oldValue, float flOldValue)
|
||||||
|
#else
|
||||||
|
void GameHooks::OnConVarChanged(ConVar *pConVar, const char *oldValue)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
#if SOURCE_ENGINE < SE_ORANGEBOX
|
||||||
|
float flOldValue = atof(oldValue);
|
||||||
|
#endif
|
||||||
|
g_ConVarManager.OnConVarChanged(pConVar, oldValue, flOldValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if SOURCE_ENGINE != SE_DARKMESSIAH
|
||||||
|
void GameHooks::OnQueryCvarValueFinished(QueryCvarCookie_t cookie, edict_t *pPlayer, EQueryCvarValueStatus result,
|
||||||
|
const char *cvarName, const char *cvarValue){
|
||||||
|
int client = IndexOfEdict(pPlayer);
|
||||||
|
|
||||||
|
# if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
|
if (g_Players.HandleConVarQuery(cookie, client, result, cvarName, cvarValue))
|
||||||
|
return;
|
||||||
|
# endif
|
||||||
|
g_ConVarManager.OnClientQueryFinished(cookie, client, result, cvarName, cvarValue);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ke::RefPtr<CommandHook>
|
||||||
|
GameHooks::AddCommandHook(ConCommand *cmd, const CommandHook::Callback &callback)
|
||||||
|
{
|
||||||
|
return new CommandHook(cmd, callback, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
ke::RefPtr<CommandHook>
|
||||||
|
GameHooks::AddPostCommandHook(ConCommand *cmd, const CommandHook::Callback &callback)
|
||||||
|
{
|
||||||
|
return new CommandHook(cmd, callback, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameHooks::SetCommandClient(int client)
|
||||||
|
{
|
||||||
|
last_command_client_ = client + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandHook::CommandHook(ConCommand *cmd, const Callback &callback, bool post)
|
||||||
|
: hook_id_(0),
|
||||||
|
callback_(callback)
|
||||||
|
{
|
||||||
|
hook_id_ = SH_ADD_HOOK(ConCommand, Dispatch, cmd, SH_MEMBER(this, &CommandHook::Dispatch), post);
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandHook::~CommandHook()
|
||||||
|
{
|
||||||
|
if (hook_id_)
|
||||||
|
SH_REMOVE_HOOK_ID(hook_id_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandHook::Dispatch(DISPATCH_ARGS)
|
||||||
|
{
|
||||||
|
DISPATCH_PROLOGUE;
|
||||||
|
EngineArgs args(command);
|
||||||
|
|
||||||
|
AddRef();
|
||||||
|
bool rval = callback_(sCoreProviderImpl.CommandClient(), &args);
|
||||||
|
Release();
|
||||||
|
if (rval)
|
||||||
|
RETURN_META(MRES_SUPERCEDE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandHook::Zap()
|
||||||
|
{
|
||||||
|
hook_id_ = 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
// vim: set ts=4 sw=4 tw=99 noet :
|
||||||
|
// =============================================================================
|
||||||
|
// SourceMod
|
||||||
|
// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved.
|
||||||
|
// =============================================================================
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
// Free Software Foundation.
|
||||||
|
//
|
||||||
|
// 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
// code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
// by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
// all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
// this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
// or <http://www.sourcemod.net/license.php>.
|
||||||
|
#ifndef _INCLUDE_SOURCEMOD_PROVIDER_GAME_HOOKS_H_
|
||||||
|
#define _INCLUDE_SOURCEMOD_PROVIDER_GAME_HOOKS_H_
|
||||||
|
|
||||||
|
// Needed for CEntityIndex, edict_t, etc.
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <eiface.h>
|
||||||
|
#include <iserverplugin.h>
|
||||||
|
#include <amtl/am-refcounting.h>
|
||||||
|
#include <amtl/am-vector.h>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
class ConVar;
|
||||||
|
class CCommand;
|
||||||
|
struct CCommandContext;
|
||||||
|
|
||||||
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
|
# define DISPATCH_ARGS const CCommand &command
|
||||||
|
# define DISPATCH_PROLOGUE
|
||||||
|
#else
|
||||||
|
# define DISPATCH_ARGS
|
||||||
|
# define DISPATCH_PROLOGUE CCommand command
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace SourceMod {
|
||||||
|
|
||||||
|
// Describes the mechanism in which client cvar queries are implemented.
|
||||||
|
enum class ClientCvarQueryMode {
|
||||||
|
Unavailable,
|
||||||
|
DLL,
|
||||||
|
VSP
|
||||||
|
};
|
||||||
|
|
||||||
|
class ICommandArgs;
|
||||||
|
|
||||||
|
class CommandHook : public ke::Refcounted<CommandHook>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// return false to RETURN_META(MRES_IGNORED), or true to SUPERCEDE.
|
||||||
|
typedef std::function<bool(int, const ICommandArgs *)> Callback;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CommandHook(ConCommand *cmd, const Callback &callback, bool post);
|
||||||
|
~CommandHook();
|
||||||
|
void Dispatch(DISPATCH_ARGS);
|
||||||
|
void Zap();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int hook_id_;
|
||||||
|
Callback callback_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class GameHooks
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GameHooks();
|
||||||
|
|
||||||
|
void Start();
|
||||||
|
void Shutdown();
|
||||||
|
void OnVSPReceived();
|
||||||
|
|
||||||
|
ClientCvarQueryMode GetClientCvarQueryMode() const {
|
||||||
|
return client_cvar_query_mode_;
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
ke::RefPtr<CommandHook> AddCommandHook(ConCommand *cmd, const CommandHook::Callback &callback);
|
||||||
|
ke::RefPtr<CommandHook> AddPostCommandHook(ConCommand *cmd, const CommandHook::Callback &callback);
|
||||||
|
|
||||||
|
int CommandClient() const {
|
||||||
|
return last_command_client_;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Static callback that Valve's ConVar object executes when the convar's value changes.
|
||||||
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
|
static void OnConVarChanged(ConVar *pConVar, const char *oldValue, float flOldValue);
|
||||||
|
#else
|
||||||
|
static void OnConVarChanged(ConVar *pConVar, const char *oldValue);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Callback for when StartQueryCvarValue() has finished.
|
||||||
|
#if SOURCE_ENGINE != SE_DARKMESSIAH
|
||||||
|
void OnQueryCvarValueFinished(QueryCvarCookie_t cookie, edict_t *pPlayer, EQueryCvarValueStatus result,
|
||||||
|
const char *cvarName, const char *cvarValue);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void SetCommandClient(int client);
|
||||||
|
|
||||||
|
private:
|
||||||
|
class HookList : public std::vector<int>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HookList &operator += (int hook_id) {
|
||||||
|
this->push_back(hook_id);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
HookList hooks_;
|
||||||
|
|
||||||
|
ClientCvarQueryMode client_cvar_query_mode_;
|
||||||
|
int last_command_client_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace SourceMod
|
||||||
|
|
||||||
|
#endif // _INCLUDE_SOURCEMOD_PROVIDER_GAME_HOOKS_H_
|
||||||
+690
-191
File diff suppressed because it is too large
Load Diff
+134
-29
@@ -2,7 +2,7 @@
|
|||||||
* vim: set ts=4 sw=4 tw=99 noet :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod
|
* SourceMod
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
* Copyright (C) 2004-2016 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
* This program is free software; you can redistribute it and/or modify it under
|
||||||
@@ -32,12 +32,12 @@
|
|||||||
#ifndef _INCLUDE_SOURCEMOD_CHALFLIFE2_H_
|
#ifndef _INCLUDE_SOURCEMOD_CHALFLIFE2_H_
|
||||||
#define _INCLUDE_SOURCEMOD_CHALFLIFE2_H_
|
#define _INCLUDE_SOURCEMOD_CHALFLIFE2_H_
|
||||||
|
|
||||||
#include <sh_list.h>
|
#include <list>
|
||||||
#include <sh_string.h>
|
#include <string>
|
||||||
#include <sh_tinyhash.h>
|
|
||||||
#include <am-utility.h>
|
#include <am-utility.h>
|
||||||
|
#include <am-hashset.h>
|
||||||
#include <am-hashmap.h>
|
#include <am-hashmap.h>
|
||||||
#include <sm_stringhashmap.h>
|
#include <sm_hashmap.h>
|
||||||
#include <sm_namehashset.h>
|
#include <sm_namehashset.h>
|
||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
#include "sm_queue.h"
|
#include "sm_queue.h"
|
||||||
@@ -47,62 +47,118 @@
|
|||||||
#include <datamap.h>
|
#include <datamap.h>
|
||||||
#include <ihandleentity.h>
|
#include <ihandleentity.h>
|
||||||
#include <tier0/icommandline.h>
|
#include <tier0/icommandline.h>
|
||||||
#if SOURCE_ENGINE >= SE_PORTAL2
|
|
||||||
#include <string_t.h>
|
#include <string_t.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
class CCommand;
|
namespace SourceMod {
|
||||||
|
class ICommandArgs;
|
||||||
|
} // namespace SourceMod
|
||||||
|
|
||||||
using namespace SourceHook;
|
|
||||||
using namespace SourceMod;
|
using namespace SourceMod;
|
||||||
|
|
||||||
|
static const int ENTREF_MASK = (1 << 31);
|
||||||
|
|
||||||
#define HUD_PRINTTALK 3
|
#define HUD_PRINTTALK 3
|
||||||
#define HUD_PRINTCENTER 4
|
#define HUD_PRINTCENTER 4
|
||||||
|
|
||||||
|
#if defined _WIN32
|
||||||
|
#define SOURCE_BIN_PREFIX ""
|
||||||
|
#define SOURCE_BIN_SUFFIX ""
|
||||||
|
#define SOURCE_BIN_EXT ".dll"
|
||||||
|
#elif defined __APPLE__
|
||||||
|
#define SOURCE_BIN_PREFIX ""
|
||||||
|
#define SOURCE_BIN_SUFFIX ""
|
||||||
|
#define SOURCE_BIN_EXT ".dylib"
|
||||||
|
#elif defined __linux__
|
||||||
|
#if SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_TF2 \
|
||||||
|
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_LEFT4DEAD2 || SOURCE_ENGINE == SE_NUCLEARDAWN \
|
||||||
|
|| SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_INSURGENCY || SOURCE_ENGINE == SE_DOI
|
||||||
|
#define SOURCE_BIN_PREFIX "lib"
|
||||||
|
#define SOURCE_BIN_SUFFIX "_srv"
|
||||||
|
#elif SOURCE_ENGINE >= SE_LEFT4DEAD || SOURCE_ENGINE == SE_PVKII
|
||||||
|
#define SOURCE_BIN_PREFIX "lib"
|
||||||
|
#define SOURCE_BIN_SUFFIX ""
|
||||||
|
#else
|
||||||
|
#define SOURCE_BIN_PREFIX ""
|
||||||
|
#define SOURCE_BIN_SUFFIX "_i486"
|
||||||
|
#endif
|
||||||
|
#define SOURCE_BIN_EXT ".so"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define FORMAT_SOURCE_BIN_NAME(basename) \
|
||||||
|
(SOURCE_BIN_PREFIX basename SOURCE_BIN_SUFFIX SOURCE_BIN_EXT)
|
||||||
|
|
||||||
struct DataTableInfo
|
struct DataTableInfo
|
||||||
{
|
{
|
||||||
struct SendPropPolicy
|
struct SendPropInfo
|
||||||
{
|
{
|
||||||
static inline bool matches(const char *name, const sm_sendprop_info_t &info)
|
static inline bool matches(const char *name, const SendPropInfo &info)
|
||||||
{
|
{
|
||||||
return strcmp(name, info.prop->GetName()) == 0;
|
return strcmp(name, info.name.c_str()) == 0;
|
||||||
}
|
}
|
||||||
|
static inline uint32_t hash(const detail::CharsAndLength &key)
|
||||||
|
{
|
||||||
|
return key.hash();
|
||||||
|
}
|
||||||
|
|
||||||
|
SendPropInfo()
|
||||||
|
: name(), info{nullptr, 0}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string name;
|
||||||
|
sm_sendprop_info_t info;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline bool matches(const char *name, const DataTableInfo *info)
|
static inline bool matches(const char *name, const DataTableInfo *info)
|
||||||
{
|
{
|
||||||
return strcmp(name, info->sc->GetName()) == 0;
|
return strcmp(name, info->sc->GetName()) == 0;
|
||||||
}
|
}
|
||||||
|
static inline uint32_t hash(const detail::CharsAndLength &key)
|
||||||
|
{
|
||||||
|
return key.hash();
|
||||||
|
}
|
||||||
|
|
||||||
DataTableInfo(ServerClass *sc)
|
DataTableInfo(ServerClass *sc)
|
||||||
: sc(sc)
|
: sc(sc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerClass *sc;
|
ServerClass *sc;
|
||||||
NameHashSet<sm_sendprop_info_t, SendPropPolicy> lookup;
|
NameHashSet<SendPropInfo> lookup;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DataMapCachePolicy
|
struct DataMapCacheInfo
|
||||||
{
|
{
|
||||||
static inline bool matches(const char *name, const sm_datatable_info_t &info)
|
static inline bool matches(const char *name, const DataMapCacheInfo &info)
|
||||||
{
|
{
|
||||||
return strcmp(name, info.prop->fieldName) == 0;
|
return strcmp(name, info.name.c_str()) == 0;
|
||||||
}
|
}
|
||||||
|
static inline uint32_t hash(const detail::CharsAndLength &key)
|
||||||
|
{
|
||||||
|
return key.hash();
|
||||||
|
}
|
||||||
|
|
||||||
|
DataMapCacheInfo()
|
||||||
|
: name(), info{nullptr, 0}
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string name;
|
||||||
|
sm_datatable_info_t info;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef NameHashSet<sm_datatable_info_t, DataMapCachePolicy> DataMapCache;
|
typedef NameHashSet<DataMapCacheInfo> DataMapCache;
|
||||||
|
|
||||||
struct DelayedFakeCliCmd
|
struct DelayedFakeCliCmd
|
||||||
{
|
{
|
||||||
String cmd;
|
std::string cmd;
|
||||||
int client;
|
int client;
|
||||||
int userid;
|
int userid;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CachedCommandInfo
|
struct CachedCommandInfo
|
||||||
{
|
{
|
||||||
const CCommand *args;
|
const ICommandArgs *args;
|
||||||
#if SOURCE_ENGINE <= SE_DARKMESSIAH
|
#if SOURCE_ENGINE <= SE_DARKMESSIAH
|
||||||
char cmd[300];
|
char cmd[300];
|
||||||
#endif
|
#endif
|
||||||
@@ -123,16 +179,33 @@ public:
|
|||||||
int m_SerialNumber;
|
int m_SerialNumber;
|
||||||
CEntInfo *m_pPrev;
|
CEntInfo *m_pPrev;
|
||||||
CEntInfo *m_pNext;
|
CEntInfo *m_pNext;
|
||||||
#if (SOURCE_ENGINE >= SE_PORTAL2) && (SOURCE_ENGINE != SE_DOTA)
|
#if SOURCE_ENGINE >= SE_PORTAL2
|
||||||
string_t m_iName;
|
string_t m_iName;
|
||||||
string_t m_iClassName;
|
string_t m_iClassName;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Corresponds to TF2's eFindMapResult in eiface.h
|
||||||
|
// Not yet in other games, but eventually in others on same branch.
|
||||||
|
enum class SMFindMapResult : cell_t {
|
||||||
|
Found,
|
||||||
|
NotFound,
|
||||||
|
FuzzyMatch,
|
||||||
|
NonCanonical,
|
||||||
|
PossiblyAvailable
|
||||||
|
};
|
||||||
|
|
||||||
|
#if SOURCE_ENGINE >= SE_LEFT4DEAD && defined PLATFORM_WINDOWS
|
||||||
|
template< class T, class I = int >
|
||||||
|
class CUtlMemoryGlobalMalloc;
|
||||||
|
class CUtlString;
|
||||||
|
#endif
|
||||||
|
|
||||||
class CHalfLife2 :
|
class CHalfLife2 :
|
||||||
public SMGlobalClass,
|
public SMGlobalClass,
|
||||||
public IGameHelpers
|
public IGameHelpers
|
||||||
{
|
{
|
||||||
|
friend class AutoEnterCommand;
|
||||||
public:
|
public:
|
||||||
CHalfLife2();
|
CHalfLife2();
|
||||||
~CHalfLife2();
|
~CHalfLife2();
|
||||||
@@ -141,11 +214,14 @@ public:
|
|||||||
void OnSourceModAllInitialized();
|
void OnSourceModAllInitialized();
|
||||||
void OnSourceModAllInitialized_Post();
|
void OnSourceModAllInitialized_Post();
|
||||||
/*void OnSourceModAllShutdown();*/
|
/*void OnSourceModAllShutdown();*/
|
||||||
|
ConfigResult OnSourceModConfigChanged(const char *key, const char *value,
|
||||||
|
ConfigSource source, char *error, size_t maxlength) override;
|
||||||
public: //IGameHelpers
|
public: //IGameHelpers
|
||||||
SendProp *FindInSendTable(const char *classname, const char *offset);
|
SendProp *FindInSendTable(const char *classname, const char *offset);
|
||||||
bool FindSendPropInfo(const char *classname, const char *offset, sm_sendprop_info_t *info);
|
bool FindSendPropInfo(const char *classname, const char *offset, sm_sendprop_info_t *info);
|
||||||
datamap_t *GetDataMap(CBaseEntity *pEntity);
|
datamap_t *GetDataMap(CBaseEntity *pEntity);
|
||||||
ServerClass *FindServerClass(const char *classname);
|
ServerClass *FindServerClass(const char *classname);
|
||||||
|
ServerClass *FindEntityServerClass(CBaseEntity *pEntity);
|
||||||
typedescription_t *FindInDataMap(datamap_t *pMap, const char *offset);
|
typedescription_t *FindInDataMap(datamap_t *pMap, const char *offset);
|
||||||
bool FindDataMapInfo(datamap_t *pMap, const char *offset, sm_datatable_info_t *pDataTable);
|
bool FindDataMapInfo(datamap_t *pMap, const char *offset, sm_datatable_info_t *pDataTable);
|
||||||
void SetEdictStateChanged(edict_t *pEdict, unsigned short offset);
|
void SetEdictStateChanged(edict_t *pEdict, unsigned short offset);
|
||||||
@@ -174,20 +250,28 @@ public: //IGameHelpers
|
|||||||
const char *GetEntityClassname(edict_t *pEdict);
|
const char *GetEntityClassname(edict_t *pEdict);
|
||||||
const char *GetEntityClassname(CBaseEntity *pEntity);
|
const char *GetEntityClassname(CBaseEntity *pEntity);
|
||||||
bool IsMapValid(const char *map);
|
bool IsMapValid(const char *map);
|
||||||
|
SMFindMapResult FindMap(char *pMapName, size_t nMapNameMax);
|
||||||
|
SMFindMapResult FindMap(const char *pMapName, char *pFoundMap = NULL, size_t nMapNameMax = 0);
|
||||||
|
#if SOURCE_ENGINE >= SE_LEFT4DEAD && defined PLATFORM_WINDOWS && SOURCE_ENGINE != SE_MOCK
|
||||||
|
void FreeUtlVectorUtlString(CUtlVector<CUtlString, CUtlMemoryGlobalMalloc<CUtlString>> &vec);
|
||||||
|
#endif
|
||||||
|
bool GetMapDisplayName(const char *pMapName, char *pDisplayname, size_t nMapNameMax);
|
||||||
|
string_t AllocPooledString(const char *pszValue);
|
||||||
|
bool GetServerSteam3Id(char *pszOut, size_t len) const override;
|
||||||
|
uint64_t GetServerSteamId64() const override;
|
||||||
|
void RemoveDataTableCache(datamap_t *pMap = nullptr);
|
||||||
|
bool RemoveSendPropCache(const char *classname = nullptr);
|
||||||
public:
|
public:
|
||||||
void AddToFakeCliCmdQueue(int client, int userid, const char *cmd);
|
void AddToFakeCliCmdQueue(int client, int userid, const char *cmd);
|
||||||
void ProcessFakeCliCmdQueue();
|
void ProcessFakeCliCmdQueue();
|
||||||
public:
|
public:
|
||||||
void PushCommandStack(const CCommand *cmd);
|
const ICommandArgs *PeekCommandStack();
|
||||||
void PopCommandStack();
|
|
||||||
const CCommand *PeekCommandStack();
|
|
||||||
const char *CurrentCommandName();
|
const char *CurrentCommandName();
|
||||||
void AddDelayedKick(int client, int userid, const char *msg);
|
void AddDelayedKick(int client, int userid, const char *msg);
|
||||||
void ProcessDelayedKicks();
|
void ProcessDelayedKicks();
|
||||||
#if !defined METAMOD_PLAPI_VERSION || PLAPI_VERSION < 11
|
|
||||||
bool IsOriginalEngine();
|
|
||||||
#endif
|
|
||||||
private:
|
private:
|
||||||
|
void PushCommandStack(const ICommandArgs *cmd);
|
||||||
|
void PopCommandStack();
|
||||||
DataTableInfo *_FindServerClass(const char *classname);
|
DataTableInfo *_FindServerClass(const char *classname);
|
||||||
private:
|
private:
|
||||||
void InitLogicalEntData();
|
void InitLogicalEntData();
|
||||||
@@ -202,14 +286,35 @@ private:
|
|||||||
int m_SayTextMsg;
|
int m_SayTextMsg;
|
||||||
int m_VGUIMenu;
|
int m_VGUIMenu;
|
||||||
Queue<DelayedFakeCliCmd *> m_CmdQueue;
|
Queue<DelayedFakeCliCmd *> m_CmdQueue;
|
||||||
CStack<DelayedFakeCliCmd *> m_FreeCmds;
|
std::stack<DelayedFakeCliCmd *> m_FreeCmds;
|
||||||
CStack<CachedCommandInfo> m_CommandStack;
|
std::stack<CachedCommandInfo> m_CommandStack;
|
||||||
Queue<DelayedKickInfo> m_DelayedKicks;
|
Queue<DelayedKickInfo> m_DelayedKicks;
|
||||||
void *m_pGetCommandLine;
|
void *m_pGetCommandLine;
|
||||||
|
#if SOURCE_ENGINE == SE_CSGO
|
||||||
|
public:
|
||||||
|
bool CanSetCSGOEntProp(const char *pszPropName)
|
||||||
|
{
|
||||||
|
return !m_bFollowCSGOServerGuidelines || !m_CSGOBadList.has(pszPropName);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
ke::HashSet<std::string, detail::StringHashMapPolicy> m_CSGOBadList;
|
||||||
|
bool m_bFollowCSGOServerGuidelines = true;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CHalfLife2 g_HL2;
|
extern CHalfLife2 g_HL2;
|
||||||
|
|
||||||
bool IndexToAThings(cell_t, CBaseEntity **pEntData, edict_t **pEdictData);
|
bool IndexToAThings(cell_t, CBaseEntity **pEntData, edict_t **pEdictData);
|
||||||
|
|
||||||
|
class AutoEnterCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AutoEnterCommand(const ICommandArgs *args) {
|
||||||
|
g_HL2.PushCommandStack(args);
|
||||||
|
}
|
||||||
|
~AutoEnterCommand() {
|
||||||
|
g_HL2.PopCommandStack();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
#endif //_INCLUDE_SOURCEMOD_CHALFLIFE2_H_
|
#endif //_INCLUDE_SOURCEMOD_CHALFLIFE2_H_
|
||||||
|
|||||||
+2
-2
@@ -34,10 +34,10 @@
|
|||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "LibrarySys.h"
|
|
||||||
#include "TimerSys.h"
|
#include "TimerSys.h"
|
||||||
#include "logic_bridge.h"
|
#include "logic_bridge.h"
|
||||||
#include <sourcemod_version.h>
|
#include <sourcemod_version.h>
|
||||||
|
#include <bridge/include/IProviderCallbacks.h>
|
||||||
|
|
||||||
bool g_in_game_log_hook = false;
|
bool g_in_game_log_hook = false;
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ SH_DECL_HOOK1_void(IVEngineServer, LogPrint, SH_NOATTRIB, false, const char *);
|
|||||||
static void HookLogPrint(const char *message)
|
static void HookLogPrint(const char *message)
|
||||||
{
|
{
|
||||||
g_in_game_log_hook = true;
|
g_in_game_log_hook = true;
|
||||||
bool stopped = logicore.OnLogPrint(message);
|
bool stopped = logicore.callbacks->OnLogPrint(message);
|
||||||
g_in_game_log_hook = false;
|
g_in_game_log_hook = false;
|
||||||
|
|
||||||
if (stopped)
|
if (stopped)
|
||||||
|
|||||||
-216
@@ -1,216 +0,0 @@
|
|||||||
# (C)2004-2008 SourceMod Development Team
|
|
||||||
# Makefile written by David "BAILOPAN" Anderson
|
|
||||||
|
|
||||||
SMSDK = ..
|
|
||||||
HL2SDK_ORIG = ../../hl2sdk
|
|
||||||
HL2SDK_OB = ../../hl2sdk-ob
|
|
||||||
HL2SDK_CSS = ../../hl2sdk-css
|
|
||||||
HL2SDK_OB_VALVE = ../../hl2sdk-ob-valve
|
|
||||||
HL2SDK_L4D = ../../hl2sdk-l4d
|
|
||||||
HL2SDK_L4D2 = ../../hl2sdk-l4d2
|
|
||||||
HL2SDK_CSGO = ../../hl2sdk-csgo
|
|
||||||
MMSOURCE = ../../mmsource-central
|
|
||||||
|
|
||||||
#####################################
|
|
||||||
### EDIT BELOW FOR OTHER PROJECTS ###
|
|
||||||
#####################################
|
|
||||||
|
|
||||||
OBJECTS = AdminCache.cpp CDataPack.cpp ConCmdManager.cpp ConVarManager.cpp CoreConfig.cpp \
|
|
||||||
Database.cpp DebugReporter.cpp EventManager.cpp HalfLife2.cpp Logger.cpp \
|
|
||||||
PlayerManager.cpp TimerSys.cpp UserMessages.cpp \
|
|
||||||
sm_autonatives.cpp sm_srvcmds.cpp sm_stringutil.cpp sm_trie.cpp \
|
|
||||||
sourcemm_api.cpp sourcemod.cpp MenuStyle_Base.cpp MenuStyle_Valve.cpp MenuManager.cpp \
|
|
||||||
MenuStyle_Radio.cpp ChatTriggers.cpp ADTFactory.cpp MenuVoting.cpp \
|
|
||||||
frame_hooks.cpp concmd_cleaner.cpp NextMap.cpp \
|
|
||||||
NativeOwner.cpp logic_bridge.cpp ConsoleDetours.cpp
|
|
||||||
OBJECTS += smn_bitbuffer.cpp smn_console.cpp smn_core.cpp \
|
|
||||||
smn_database.cpp smn_entities.cpp smn_events.cpp \
|
|
||||||
smn_fakenatives.cpp smn_filesystem.cpp smn_halflife.cpp \
|
|
||||||
smn_keyvalues.cpp smn_player.cpp \
|
|
||||||
smn_usermsgs.cpp smn_menus.cpp smn_vector.cpp \
|
|
||||||
smn_hudtext.cpp smn_nextmap.cpp
|
|
||||||
OBJECTS += ExtensionSys.cpp \
|
|
||||||
ForwardSys.cpp \
|
|
||||||
HandleSys.cpp \
|
|
||||||
LibrarySys.cpp \
|
|
||||||
PluginInfoDatabase.cpp \
|
|
||||||
PluginSys.cpp \
|
|
||||||
ShareSys.cpp \
|
|
||||||
NativeInvoker.cpp
|
|
||||||
|
|
||||||
##############################################
|
|
||||||
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
|
|
||||||
##############################################
|
|
||||||
|
|
||||||
C_OPT_FLAGS = -DNDEBUG -O3 -funroll-loops -pipe -fno-strict-aliasing
|
|
||||||
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
|
|
||||||
C_GCC4_FLAGS = -fvisibility=hidden
|
|
||||||
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
|
|
||||||
CPP = gcc
|
|
||||||
|
|
||||||
override ENGSET = false
|
|
||||||
|
|
||||||
ifneq (,$(filter original orangebox css orangeboxvalve left4dead left4dead2 csgo,$(ENGINE)))
|
|
||||||
override ENGSET = true
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq "$(ENGINE)" "original"
|
|
||||||
HL2SDK = $(HL2SDK_ORIG)
|
|
||||||
HL2LIB = $(HL2SDK)/linux_sdk
|
|
||||||
CFLAGS += -DSOURCE_ENGINE=1
|
|
||||||
METAMOD = $(MMSOURCE)/core-legacy
|
|
||||||
INCLUDE += -I$(HL2SDK)/public/dlls
|
|
||||||
BINARY = sourcemod.1.ep1.so
|
|
||||||
endif
|
|
||||||
ifeq "$(ENGINE)" "orangebox"
|
|
||||||
HL2SDK = $(HL2SDK_OB)
|
|
||||||
HL2LIB = $(HL2SDK)/lib/linux
|
|
||||||
CFLAGS += -DSOURCE_ENGINE=3
|
|
||||||
METAMOD = $(MMSOURCE)/core
|
|
||||||
INCLUDE += -I$(HL2SDK)/public/game/server
|
|
||||||
BINARY = sourcemod.2.ep2.so
|
|
||||||
endif
|
|
||||||
ifeq "$(ENGINE)" "css"
|
|
||||||
HL2SDK = $(HL2SDK_CSS)
|
|
||||||
HL2LIB = $(HL2SDK)/lib/linux
|
|
||||||
CFLAGS += -DSOURCE_ENGINE=6
|
|
||||||
METAMOD = $(MMSOURCE)/core
|
|
||||||
INCLUDE += -I$(HL2SDK)/public/game/server
|
|
||||||
BINARY = sourcemod.2.css.so
|
|
||||||
endif
|
|
||||||
ifeq "$(ENGINE)" "orangeboxvalve"
|
|
||||||
HL2SDK = $(HL2SDK_OB_VALVE)
|
|
||||||
HL2LIB = $(HL2SDK)/lib/linux
|
|
||||||
CFLAGS += -DSOURCE_ENGINE=7
|
|
||||||
METAMOD = $(MMSOURCE)/core
|
|
||||||
INCLUDE += -I$(HL2SDK)/public/game/server
|
|
||||||
BINARY = sourcemod.2.ep2v.so
|
|
||||||
endif
|
|
||||||
ifeq "$(ENGINE)" "left4dead"
|
|
||||||
HL2SDK = $(HL2SDK_L4D)
|
|
||||||
HL2LIB = $(HL2SDK)/lib/linux
|
|
||||||
CFLAGS += -DSOURCE_ENGINE=8
|
|
||||||
METAMOD = $(MMSOURCE)/core
|
|
||||||
INCLUDE += -I$(HL2SDK)/public/game/server
|
|
||||||
BINARY = sourcemod.2.l4d.so
|
|
||||||
endif
|
|
||||||
ifeq "$(ENGINE)" "left4dead2"
|
|
||||||
HL2SDK = $(HL2SDK_L4D2)
|
|
||||||
HL2LIB = $(HL2SDK)/lib/linux
|
|
||||||
CFLAGS += -DSOURCE_ENGINE=9
|
|
||||||
METAMOD = $(MMSOURCE)/core
|
|
||||||
INCLUDE += -I$(HL2SDK)/public/game/server
|
|
||||||
BINARY = sourcemod.2.l4d2.so
|
|
||||||
endif
|
|
||||||
ifeq "$(ENGINE)" "csgo"
|
|
||||||
HL2SDK = $(HL2SDK_CSGO)
|
|
||||||
HL2LIB = $(HL2SDK)/lib/linux
|
|
||||||
CFLAGS += -DSOURCE_ENGINE=12
|
|
||||||
METAMOD = $(MMSOURCE)/core
|
|
||||||
INCLUDE += -I$(HL2SDK)/public/game/server
|
|
||||||
BINARY = sourcemod.2.csgo.so
|
|
||||||
endif
|
|
||||||
|
|
||||||
HL2PUB = $(HL2SDK)/public
|
|
||||||
|
|
||||||
OS := $(shell uname -s)
|
|
||||||
|
|
||||||
ifeq "$(OS)" "Darwin"
|
|
||||||
LIB_EXT = dylib
|
|
||||||
HL2LIB = $(HL2SDK)/lib/mac
|
|
||||||
else
|
|
||||||
LIB_EXT = so
|
|
||||||
ifeq "$(ENGINE)" "original"
|
|
||||||
HL2LIB = $(HL2SDK)/linux_sdk
|
|
||||||
else
|
|
||||||
HL2LIB = $(HL2SDK)/lib/linux
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifneq (,$(filter original orangebox left4dead,$(ENGINE)))
|
|
||||||
LIB_SUFFIX = _i486.$(LIB_EXT)
|
|
||||||
else
|
|
||||||
LIB_PREFIX = lib
|
|
||||||
ifneq (,$(filter orangeboxvalve css,$(ENGINE)))
|
|
||||||
ifneq "$(OS)" "Darwin"
|
|
||||||
LIB_SUFFIX = _srv.$(LIB_EXT)
|
|
||||||
else
|
|
||||||
LIB_SUFFIX = .$(LIB_EXT)
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
LIB_SUFFIX = .$(LIB_EXT)
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
CFLAGS += -DSE_EPISODEONE=1 -DSE_DARKMESSIAH=2 -DSE_ORANGEBOX=3 -DSE_BLOODYGOODTIME=4 -DSE_EYE=5 \
|
|
||||||
-DSE_CSS=6 -DSE_ORANGEBOXVALVE=7 -DSE_LEFT4DEAD=8 -DSE_LEFT4DEAD2=9 -DSE_ALIENSWARM=10 \
|
|
||||||
-DSE_PORTAL2=11 -DSE_CSGO=12
|
|
||||||
|
|
||||||
LINK += $(HL2LIB)/tier1_i486.a $(HL2LIB)/mathlib_i486.a $(LIB_PREFIX)vstdlib$(LIB_SUFFIX) \
|
|
||||||
$(LIB_PREFIX)tier0$(LIB_SUFFIX) -static-libgcc
|
|
||||||
|
|
||||||
ifeq "$(ENGINE)" "csgo"
|
|
||||||
LINK += $(HL2LIB)/interfaces_i486.a
|
|
||||||
endif
|
|
||||||
|
|
||||||
INCLUDE += -I. -I.. -I$(HL2PUB) -I$(HL2PUB)/engine -I$(HL2PUB)/mathlib -I$(HL2PUB)/vstdlib \
|
|
||||||
-I$(HL2PUB)/tier0 -I$(HL2PUB)/tier1 -I$(METAMOD) -I$(METAMOD)/sourcehook \
|
|
||||||
-I$(SMSDK)/public -I$(SMSDK)/public/sourcepawn
|
|
||||||
|
|
||||||
CFLAGS += -D_LINUX -DPOSIX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \
|
|
||||||
-D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror \
|
|
||||||
-Wno-uninitialized -Wno-unused -Wno-switch -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H \
|
|
||||||
-DSM_DEFAULT_THREADER -m32 -DCOMPILER_GCC
|
|
||||||
CPPFLAGS += -Wno-non-virtual-dtor -Wno-overloaded-virtual -fno-threadsafe-statics -fno-exceptions -fno-rtti
|
|
||||||
|
|
||||||
################################################
|
|
||||||
### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
|
|
||||||
################################################
|
|
||||||
|
|
||||||
ifeq "$(DEBUG)" "true"
|
|
||||||
BIN_DIR = Debug.$(ENGINE)
|
|
||||||
CFLAGS += $(C_DEBUG_FLAGS)
|
|
||||||
else
|
|
||||||
BIN_DIR = Release.$(ENGINE)
|
|
||||||
CFLAGS += $(C_OPT_FLAGS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
|
|
||||||
ifeq "$(GCC_VERSION)" "4"
|
|
||||||
CFLAGS += $(C_GCC4_FLAGS)
|
|
||||||
CPPFLAGS += $(CPP_GCC4_FLAGS)
|
|
||||||
endif
|
|
||||||
|
|
||||||
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
|
|
||||||
OBJ_LINUX := $(OBJ_LINUX:%.c=$(BIN_DIR)/%.o)
|
|
||||||
|
|
||||||
$(BIN_DIR)/%.o: %.cpp
|
|
||||||
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
|
|
||||||
|
|
||||||
$(BIN_DIR)/%.o: %.c
|
|
||||||
$(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $<
|
|
||||||
|
|
||||||
all: check
|
|
||||||
mkdir -p $(BIN_DIR)
|
|
||||||
ln -sf $(HL2LIB)/$(LIB_PREFIX)vstdlib$(LIB_SUFFIX)
|
|
||||||
ln -sf $(HL2LIB)/$(LIB_PREFIX)tier0$(LIB_SUFFIX)
|
|
||||||
$(MAKE) -f Makefile sourcemod
|
|
||||||
|
|
||||||
check:
|
|
||||||
if [ "$(ENGSET)" = "false" ]; then \
|
|
||||||
echo "You must supply one of the following values for ENGINE:"; \
|
|
||||||
echo "csgo, left4dead2, left4dead, orangeboxvalve, css, orangebox, or original"; \
|
|
||||||
exit 1; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
sourcemod: check $(OBJ_LINUX)
|
|
||||||
$(CPP) $(INCLUDE) $(OBJ_LINUX) $(LINK) -m32 -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
|
|
||||||
|
|
||||||
debug:
|
|
||||||
$(MAKE) -f Makefile all DEBUG=true
|
|
||||||
|
|
||||||
default: all
|
|
||||||
|
|
||||||
clean: check
|
|
||||||
rm -rf $(BIN_DIR)/*.o
|
|
||||||
rm -rf $(BIN_DIR)/$(BINARY)
|
|
||||||
+38
-35
@@ -38,6 +38,7 @@
|
|||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
#include "PlayerManager.h"
|
#include "PlayerManager.h"
|
||||||
#include "MenuStyle_Valve.h"
|
#include "MenuStyle_Valve.h"
|
||||||
|
#include <IGameConfigs.h>
|
||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
#include "logic_bridge.h"
|
#include "logic_bridge.h"
|
||||||
|
|
||||||
@@ -68,6 +69,29 @@ void MenuManager::OnSourceModAllInitialized()
|
|||||||
m_StyleType = handlesys->CreateType("IMenuStyle", this, 0, NULL, &access, g_pCoreIdent, NULL);
|
m_StyleType = handlesys->CreateType("IMenuStyle", this, 0, NULL, &access, g_pCoreIdent, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MenuManager::OnSourceModAllInitialized_Post()
|
||||||
|
{
|
||||||
|
const char* pTmp;
|
||||||
|
|
||||||
|
pTmp = g_pGameConf->GetKeyValue("MenuItemSound");
|
||||||
|
if (nullptr != pTmp)
|
||||||
|
{
|
||||||
|
m_SelectSound = pTmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
pTmp = g_pGameConf->GetKeyValue("MenuExitSound");
|
||||||
|
if (nullptr != pTmp)
|
||||||
|
{
|
||||||
|
m_ExitSound = pTmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
pTmp = g_pGameConf->GetKeyValue("MenuExitBackSound");
|
||||||
|
if (nullptr != pTmp)
|
||||||
|
{
|
||||||
|
m_ExitBackSound = pTmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MenuManager::OnSourceModAllShutdown()
|
void MenuManager::OnSourceModAllShutdown()
|
||||||
{
|
{
|
||||||
handlesys->RemoveType(m_MenuType, g_pCoreIdent);
|
handlesys->RemoveType(m_MenuType, g_pCoreIdent);
|
||||||
@@ -308,7 +332,7 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord
|
|||||||
{
|
{
|
||||||
ItemDrawInfo &dr = drawItems[foundItems].draw;
|
ItemDrawInfo &dr = drawItems[foundItems].draw;
|
||||||
/* Is the item valid? */
|
/* Is the item valid? */
|
||||||
if (menu->GetItemInfo(i, &dr) != NULL)
|
if (menu->GetItemInfo(i, &dr, client) != NULL)
|
||||||
{
|
{
|
||||||
/* Ask the user to change the style, if necessary */
|
/* Ask the user to change the style, if necessary */
|
||||||
mh->OnMenuDrawItem(menu, client, i, dr.style);
|
mh->OnMenuDrawItem(menu, client, i, dr.style);
|
||||||
@@ -398,7 +422,7 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord
|
|||||||
}
|
}
|
||||||
while (++lastItem < totalItems)
|
while (++lastItem < totalItems)
|
||||||
{
|
{
|
||||||
if (menu->GetItemInfo(lastItem, &dr) != NULL)
|
if (menu->GetItemInfo(lastItem, &dr, client) != NULL)
|
||||||
{
|
{
|
||||||
mh->OnMenuDrawItem(menu, client, lastItem, dr.style);
|
mh->OnMenuDrawItem(menu, client, lastItem, dr.style);
|
||||||
if (IsSlotItem(panel, dr.style))
|
if (IsSlotItem(panel, dr.style))
|
||||||
@@ -420,7 +444,7 @@ IMenuPanel *MenuManager::RenderMenu(int client, menu_states_t &md, ItemOrder ord
|
|||||||
lastItem--;
|
lastItem--;
|
||||||
while (lastItem != 0)
|
while (lastItem != 0)
|
||||||
{
|
{
|
||||||
if (menu->GetItemInfo(lastItem, &dr) != NULL)
|
if (menu->GetItemInfo(lastItem, &dr, client) != NULL)
|
||||||
{
|
{
|
||||||
mh->OnMenuDrawItem(menu, client, lastItem, dr.style);
|
mh->OnMenuDrawItem(menu, client, lastItem, dr.style);
|
||||||
if (IsSlotItem(panel, dr.style))
|
if (IsSlotItem(panel, dr.style))
|
||||||
@@ -446,7 +470,7 @@ skip_search:
|
|||||||
char text[50];
|
char text[50];
|
||||||
if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "No Vote", &client))
|
if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "No Vote", &client))
|
||||||
{
|
{
|
||||||
UTIL_Format(text, sizeof(text), "No Vote");
|
ke::SafeStrcpy(text, sizeof(text), "No Vote");
|
||||||
}
|
}
|
||||||
ItemDrawInfo dr(text, 0);
|
ItemDrawInfo dr(text, 0);
|
||||||
position = panel->DrawItem(dr);
|
position = panel->DrawItem(dr);
|
||||||
@@ -570,7 +594,7 @@ skip_search:
|
|||||||
/* If there are no control options,
|
/* If there are no control options,
|
||||||
* Instead just pad with invisible slots.
|
* Instead just pad with invisible slots.
|
||||||
*/
|
*/
|
||||||
if (!displayPrev && !displayPrev)
|
if (!displayNext && !displayPrev)
|
||||||
{
|
{
|
||||||
padItem.style = ITEMDRAW_NOTEXT;
|
padItem.style = ITEMDRAW_NOTEXT;
|
||||||
}
|
}
|
||||||
@@ -606,7 +630,7 @@ skip_search:
|
|||||||
{
|
{
|
||||||
if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Back", &client))
|
if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Back", &client))
|
||||||
{
|
{
|
||||||
UTIL_Format(text, sizeof(text), "Back");
|
ke::SafeStrcpy(text, sizeof(text), "Back");
|
||||||
}
|
}
|
||||||
dr.style = ITEMDRAW_CONTROL;
|
dr.style = ITEMDRAW_CONTROL;
|
||||||
position = panel->DrawItem(dr);
|
position = panel->DrawItem(dr);
|
||||||
@@ -616,7 +640,7 @@ skip_search:
|
|||||||
{
|
{
|
||||||
if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Previous", &client))
|
if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Previous", &client))
|
||||||
{
|
{
|
||||||
UTIL_Format(text, sizeof(text), "Previous");
|
ke::SafeStrcpy(text, sizeof(text), "Previous");
|
||||||
}
|
}
|
||||||
dr.style = (displayPrev ? 0 : ITEMDRAW_DISABLED)|ITEMDRAW_CONTROL;
|
dr.style = (displayPrev ? 0 : ITEMDRAW_DISABLED)|ITEMDRAW_CONTROL;
|
||||||
position = panel->DrawItem(dr);
|
position = panel->DrawItem(dr);
|
||||||
@@ -637,7 +661,7 @@ skip_search:
|
|||||||
{
|
{
|
||||||
if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Next", &client))
|
if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Next", &client))
|
||||||
{
|
{
|
||||||
UTIL_Format(text, sizeof(text), "Next");
|
ke::SafeStrcpy(text, sizeof(text), "Next");
|
||||||
}
|
}
|
||||||
dr.style = (displayNext ? 0 : ITEMDRAW_DISABLED)|ITEMDRAW_CONTROL;
|
dr.style = (displayNext ? 0 : ITEMDRAW_DISABLED)|ITEMDRAW_CONTROL;
|
||||||
position = panel->DrawItem(dr);
|
position = panel->DrawItem(dr);
|
||||||
@@ -668,7 +692,7 @@ skip_search:
|
|||||||
{
|
{
|
||||||
if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Exit", &client))
|
if (!logicore.CoreTranslate(text, sizeof(text), "%T", 2, NULL, "Exit", &client))
|
||||||
{
|
{
|
||||||
UTIL_Format(text, sizeof(text), "Exit");
|
ke::SafeStrcpy(text, sizeof(text), "Exit");
|
||||||
}
|
}
|
||||||
dr.style = ITEMDRAW_CONTROL;
|
dr.style = ITEMDRAW_CONTROL;
|
||||||
position = panel->DrawItem(dr);
|
position = panel->DrawItem(dr);
|
||||||
@@ -699,30 +723,9 @@ bool MenuManager::MenuSoundsEnabled()
|
|||||||
return (sm_menu_sounds.GetInt() != 0);
|
return (sm_menu_sounds.GetInt() != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigResult MenuManager::OnSourceModConfigChanged(const char *key,
|
std::string *MenuManager::GetMenuSound(ItemSelection sel)
|
||||||
const char *value,
|
|
||||||
ConfigSource source,
|
|
||||||
char *error,
|
|
||||||
size_t maxlength)
|
|
||||||
{
|
{
|
||||||
if (strcmp(key, "MenuItemSound") == 0)
|
std::string *sound = nullptr;
|
||||||
{
|
|
||||||
m_SelectSound.assign(value);
|
|
||||||
return ConfigResult_Accept;
|
|
||||||
} else if (strcmp(key, "MenuExitBackSound") == 0) {
|
|
||||||
m_ExitBackSound.assign(value);
|
|
||||||
return ConfigResult_Accept;
|
|
||||||
} else if (strcmp(key, "MenuExitSound") == 0) {
|
|
||||||
m_ExitSound.assign(value);
|
|
||||||
return ConfigResult_Accept;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ConfigResult_Ignore;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *MenuManager::GetMenuSound(ItemSelection sel)
|
|
||||||
{
|
|
||||||
const char *sound = NULL;
|
|
||||||
|
|
||||||
switch (sel)
|
switch (sel)
|
||||||
{
|
{
|
||||||
@@ -732,7 +735,7 @@ const char *MenuManager::GetMenuSound(ItemSelection sel)
|
|||||||
{
|
{
|
||||||
if (m_SelectSound.size() > 0)
|
if (m_SelectSound.size() > 0)
|
||||||
{
|
{
|
||||||
sound = m_SelectSound.c_str();
|
sound = &m_SelectSound;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -740,7 +743,7 @@ const char *MenuManager::GetMenuSound(ItemSelection sel)
|
|||||||
{
|
{
|
||||||
if (m_ExitBackSound.size() > 0)
|
if (m_ExitBackSound.size() > 0)
|
||||||
{
|
{
|
||||||
sound = m_ExitBackSound.c_str();
|
sound = &m_ExitBackSound;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -748,7 +751,7 @@ const char *MenuManager::GetMenuSound(ItemSelection sel)
|
|||||||
{
|
{
|
||||||
if (m_ExitSound.size() > 0)
|
if (m_ExitSound.size() > 0)
|
||||||
{
|
{
|
||||||
sound = m_ExitSound.c_str();
|
sound = &m_ExitSound;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-15
@@ -33,14 +33,13 @@
|
|||||||
#define _INCLUDE_SOURCEMOD_MENUMANAGER_H_
|
#define _INCLUDE_SOURCEMOD_MENUMANAGER_H_
|
||||||
|
|
||||||
#include <IMenuManager.h>
|
#include <IMenuManager.h>
|
||||||
#include <sh_vector.h>
|
#include <vector>
|
||||||
#include <sh_stack.h>
|
#include <stack>
|
||||||
#include <sh_list.h>
|
#include <list>
|
||||||
#include <sh_string.h>
|
|
||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using namespace SourceMod;
|
using namespace SourceMod;
|
||||||
using namespace SourceHook;
|
|
||||||
|
|
||||||
class MenuManager :
|
class MenuManager :
|
||||||
public IMenuManager,
|
public IMenuManager,
|
||||||
@@ -55,12 +54,8 @@ public:
|
|||||||
MenuManager();
|
MenuManager();
|
||||||
public: //SMGlobalClass
|
public: //SMGlobalClass
|
||||||
void OnSourceModAllInitialized();
|
void OnSourceModAllInitialized();
|
||||||
|
void OnSourceModAllInitialized_Post();
|
||||||
void OnSourceModAllShutdown();
|
void OnSourceModAllShutdown();
|
||||||
ConfigResult OnSourceModConfigChanged(const char *key,
|
|
||||||
const char *value,
|
|
||||||
ConfigSource source,
|
|
||||||
char *error,
|
|
||||||
size_t maxlength);
|
|
||||||
void OnSourceModLevelChange(const char *mapName);
|
void OnSourceModLevelChange(const char *mapName);
|
||||||
public: //IMenuManager
|
public: //IMenuManager
|
||||||
virtual const char *GetInterfaceName()
|
virtual const char *GetInterfaceName()
|
||||||
@@ -99,19 +94,19 @@ public:
|
|||||||
HandleError ReadStyleHandle(Handle_t handle, IMenuStyle **style);
|
HandleError ReadStyleHandle(Handle_t handle, IMenuStyle **style);
|
||||||
public:
|
public:
|
||||||
bool MenuSoundsEnabled();
|
bool MenuSoundsEnabled();
|
||||||
const char *GetMenuSound(ItemSelection sel);
|
std::string *GetMenuSound(ItemSelection sel);
|
||||||
protected:
|
protected:
|
||||||
Handle_t CreateMenuHandle(IBaseMenu *menu, IdentityToken_t *pOwner);
|
Handle_t CreateMenuHandle(IBaseMenu *menu, IdentityToken_t *pOwner);
|
||||||
Handle_t CreateStyleHandle(IMenuStyle *style);
|
Handle_t CreateStyleHandle(IMenuStyle *style);
|
||||||
private:
|
private:
|
||||||
int m_ShowMenu;
|
int m_ShowMenu;
|
||||||
IMenuStyle *m_pDefaultStyle;
|
IMenuStyle *m_pDefaultStyle;
|
||||||
CVector<IMenuStyle *> m_Styles;
|
std::vector<IMenuStyle *> m_Styles;
|
||||||
HandleType_t m_StyleType;
|
HandleType_t m_StyleType;
|
||||||
HandleType_t m_MenuType;
|
HandleType_t m_MenuType;
|
||||||
String m_SelectSound;
|
std::string m_SelectSound = "";
|
||||||
String m_ExitBackSound;
|
std::string m_ExitBackSound = "";
|
||||||
String m_ExitSound;
|
std::string m_ExitSound = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
extern MenuManager g_Menus;
|
extern MenuManager g_Menus;
|
||||||
|
|||||||
+115
-48
@@ -36,7 +36,7 @@
|
|||||||
#include "MenuManager.h"
|
#include "MenuManager.h"
|
||||||
#include "CellRecipientFilter.h"
|
#include "CellRecipientFilter.h"
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
#include "Logger.h"
|
#include <bridge/include/ILogger.h>
|
||||||
#endif
|
#endif
|
||||||
#include "logic_bridge.h"
|
#include "logic_bridge.h"
|
||||||
#include "AutoHandleRooter.h"
|
#include "AutoHandleRooter.h"
|
||||||
@@ -59,7 +59,7 @@ Handle_t BaseMenuStyle::GetHandle()
|
|||||||
void BaseMenuStyle::AddClientToWatch(int client)
|
void BaseMenuStyle::AddClientToWatch(int client)
|
||||||
{
|
{
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] AddClientToWatch(%d)", client);
|
logger->LogMessage("[SM_MENU] AddClientToWatch(%d)", client);
|
||||||
#endif
|
#endif
|
||||||
m_WatchList.push_back(client);
|
m_WatchList.push_back(client);
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ void BaseMenuStyle::AddClientToWatch(int client)
|
|||||||
void BaseMenuStyle::RemoveClientFromWatch(int client)
|
void BaseMenuStyle::RemoveClientFromWatch(int client)
|
||||||
{
|
{
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] RemoveClientFromWatch(%d)", client);
|
logger->LogMessage("[SM_MENU] RemoveClientFromWatch(%d)", client);
|
||||||
#endif
|
#endif
|
||||||
m_WatchList.remove(client);
|
m_WatchList.remove(client);
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ void BaseMenuStyle::RemoveClientFromWatch(int client)
|
|||||||
void BaseMenuStyle::_CancelClientMenu(int client, MenuCancelReason reason, bool bAutoIgnore/* =false */)
|
void BaseMenuStyle::_CancelClientMenu(int client, MenuCancelReason reason, bool bAutoIgnore/* =false */)
|
||||||
{
|
{
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] _CancelClientMenu() (client %d) (bAutoIgnore %d) (reason %d)", client, bAutoIgnore, reason);
|
logger->LogMessage("[SM_MENU] _CancelClientMenu() (client %d) (bAutoIgnore %d) (reason %d)", client, bAutoIgnore, reason);
|
||||||
#endif
|
#endif
|
||||||
CBaseMenuPlayer *player = GetMenuPlayer(client);
|
CBaseMenuPlayer *player = GetMenuPlayer(client);
|
||||||
menu_states_t &states = player->states;
|
menu_states_t &states = player->states;
|
||||||
@@ -97,6 +97,9 @@ void BaseMenuStyle::_CancelClientMenu(int client, MenuCancelReason reason, bool
|
|||||||
RemoveClientFromWatch(client);
|
RemoveClientFromWatch(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Handle_t hndl = menu ? menu->GetHandle() : BAD_HANDLE;
|
||||||
|
AutoHandleRooter ahr(hndl);
|
||||||
|
|
||||||
/* Fire callbacks */
|
/* Fire callbacks */
|
||||||
mh->OnMenuCancel(menu, client, reason);
|
mh->OnMenuCancel(menu, client, reason);
|
||||||
|
|
||||||
@@ -115,7 +118,7 @@ void BaseMenuStyle::_CancelClientMenu(int client, MenuCancelReason reason, bool
|
|||||||
void BaseMenuStyle::CancelMenu(CBaseMenu *menu)
|
void BaseMenuStyle::CancelMenu(CBaseMenu *menu)
|
||||||
{
|
{
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] CancelMenu() (menu %p)", menu);
|
logger->LogMessage("[SM_MENU] CancelMenu() (menu %p)", menu);
|
||||||
#endif
|
#endif
|
||||||
int maxClients = g_Players.GetMaxClients();
|
int maxClients = g_Players.GetMaxClients();
|
||||||
for (int i=1; i<=maxClients; i++)
|
for (int i=1; i<=maxClients; i++)
|
||||||
@@ -135,7 +138,7 @@ void BaseMenuStyle::CancelMenu(CBaseMenu *menu)
|
|||||||
bool BaseMenuStyle::CancelClientMenu(int client, bool autoIgnore)
|
bool BaseMenuStyle::CancelClientMenu(int client, bool autoIgnore)
|
||||||
{
|
{
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] CancelClientMenu() (client %d) (bAutoIgnore %d)", client, autoIgnore);
|
logger->LogMessage("[SM_MENU] CancelClientMenu() (client %d) (bAutoIgnore %d)", client, autoIgnore);
|
||||||
#endif
|
#endif
|
||||||
if (client < 1 || client > g_Players.MaxClients())
|
if (client < 1 || client > g_Players.MaxClients())
|
||||||
{
|
{
|
||||||
@@ -191,7 +194,7 @@ MenuSource BaseMenuStyle::GetClientMenu(int client, void **object)
|
|||||||
void BaseMenuStyle::OnClientDisconnected(int client)
|
void BaseMenuStyle::OnClientDisconnected(int client)
|
||||||
{
|
{
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] OnClientDisconnected(%d)", client);
|
logger->LogMessage("[SM_MENU] OnClientDisconnected(%d)", client);
|
||||||
#endif
|
#endif
|
||||||
CBaseMenuPlayer *player = GetMenuPlayer(client);
|
CBaseMenuPlayer *player = GetMenuPlayer(client);
|
||||||
if (!player->bInMenu)
|
if (!player->bInMenu)
|
||||||
@@ -214,7 +217,7 @@ void BaseMenuStyle::ProcessWatchList()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("BaseMenuStyle::ProcessWatchList(%d,%d,%d,%d,%d,%p)",
|
logger->LogMessage("BaseMenuStyle::ProcessWatchList(%d,%d,%d,%d,%d,%p)",
|
||||||
m_WatchList.m_Size,
|
m_WatchList.m_Size,
|
||||||
m_WatchList.m_FirstLink,
|
m_WatchList.m_FirstLink,
|
||||||
m_WatchList.m_FreeNodes,
|
m_WatchList.m_FreeNodes,
|
||||||
@@ -232,7 +235,7 @@ void BaseMenuStyle::ProcessWatchList()
|
|||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
if (total)
|
if (total)
|
||||||
{
|
{
|
||||||
g_Logger.LogMessage("[SM_MENU] ProcessWatchList() found %d clients", total);
|
logger->LogMessage("[SM_MENU] ProcessWatchList() found %d clients", total);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -244,7 +247,7 @@ void BaseMenuStyle::ProcessWatchList()
|
|||||||
client = do_lookup[i];
|
client = do_lookup[i];
|
||||||
player = GetMenuPlayer(client);
|
player = GetMenuPlayer(client);
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] ProcessWatchList() (client %d) (bInMenu %d) (menuHoldTime %d) (curTime %f) (menuStartTime %f)",
|
logger->LogMessage("[SM_MENU] ProcessWatchList() (client %d) (bInMenu %d) (menuHoldTime %d) (curTime %f) (menuStartTime %f)",
|
||||||
client,
|
client,
|
||||||
player->bInMenu,
|
player->bInMenu,
|
||||||
player->menuHoldTime,
|
player->menuHoldTime,
|
||||||
@@ -254,7 +257,7 @@ void BaseMenuStyle::ProcessWatchList()
|
|||||||
if (!player->bInMenu || !player->menuHoldTime)
|
if (!player->bInMenu || !player->menuHoldTime)
|
||||||
{
|
{
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] ProcessWatchList() removing client %d", client);
|
logger->LogMessage("[SM_MENU] ProcessWatchList() removing client %d", client);
|
||||||
#endif
|
#endif
|
||||||
m_WatchList.remove(client);
|
m_WatchList.remove(client);
|
||||||
continue;
|
continue;
|
||||||
@@ -269,7 +272,7 @@ void BaseMenuStyle::ProcessWatchList()
|
|||||||
void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
|
void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
|
||||||
{
|
{
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] ClientPressedKey() (client %d) (key_press %d)", client, key_press);
|
logger->LogMessage("[SM_MENU] ClientPressedKey() (client %d) (key_press %d)", client, key_press);
|
||||||
#endif
|
#endif
|
||||||
CBaseMenuPlayer *player = GetMenuPlayer(client);
|
CBaseMenuPlayer *player = GetMenuPlayer(client);
|
||||||
|
|
||||||
@@ -311,9 +314,9 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
|
|||||||
clients[0] = client;
|
clients[0] = client;
|
||||||
filter.Initialize(clients, 1);
|
filter.Initialize(clients, 1);
|
||||||
|
|
||||||
const char *sound = g_Menus.GetMenuSound(type);
|
std::string *sound = g_Menus.GetMenuSound(type);
|
||||||
|
|
||||||
if (sound != NULL)
|
if (nullptr != sound && !sound->empty())
|
||||||
{
|
{
|
||||||
edict_t *pEdict = PEntityOfEntIndex(client);
|
edict_t *pEdict = PEntityOfEntIndex(client);
|
||||||
if (pEdict)
|
if (pEdict)
|
||||||
@@ -327,10 +330,10 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
|
|||||||
client,
|
client,
|
||||||
CHAN_AUTO,
|
CHAN_AUTO,
|
||||||
#if SOURCE_ENGINE >= SE_PORTAL2
|
#if SOURCE_ENGINE >= SE_PORTAL2
|
||||||
sound,
|
sound->c_str(),
|
||||||
-1,
|
-1,
|
||||||
#endif
|
#endif
|
||||||
sound,
|
sound->c_str(),
|
||||||
VOL_NORM,
|
VOL_NORM,
|
||||||
ATTN_NORM,
|
ATTN_NORM,
|
||||||
#if SOURCE_ENGINE >= SE_PORTAL2
|
#if SOURCE_ENGINE >= SE_PORTAL2
|
||||||
@@ -338,7 +341,8 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
|
|||||||
#endif
|
#endif
|
||||||
0,
|
0,
|
||||||
PITCH_NORM,
|
PITCH_NORM,
|
||||||
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_TF2
|
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS \
|
||||||
|
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_PVKII
|
||||||
0,
|
0,
|
||||||
#endif
|
#endif
|
||||||
&pos);
|
&pos);
|
||||||
@@ -411,14 +415,14 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
|
|||||||
bool BaseMenuStyle::DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time)
|
bool BaseMenuStyle::DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time)
|
||||||
{
|
{
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] DoClientMenu() (client %d) (panel %p) (mh %p) (time %d)",
|
logger->LogMessage("[SM_MENU] DoClientMenu() (client %d) (panel %p) (mh %p) (time %d)",
|
||||||
client,
|
client,
|
||||||
menu,
|
menu,
|
||||||
mh,
|
mh,
|
||||||
time);
|
time);
|
||||||
#endif
|
#endif
|
||||||
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
||||||
if (!pPlayer || pPlayer->IsFakeClient() || !pPlayer->IsInGame())
|
if (!pPlayer || !pPlayer->IsInGame())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -474,7 +478,7 @@ bool BaseMenuStyle::DoClientMenu(int client,
|
|||||||
unsigned int time)
|
unsigned int time)
|
||||||
{
|
{
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] DoClientMenu() (client %d) (menu %p) (mh %p) (time %d)",
|
logger->LogMessage("[SM_MENU] DoClientMenu() (client %d) (menu %p) (mh %p) (time %d)",
|
||||||
client,
|
client,
|
||||||
menu,
|
menu,
|
||||||
mh,
|
mh,
|
||||||
@@ -486,7 +490,7 @@ bool BaseMenuStyle::DoClientMenu(int client,
|
|||||||
if (!pPlayer || pPlayer->IsFakeClient() || !pPlayer->IsInGame())
|
if (!pPlayer || pPlayer->IsFakeClient() || !pPlayer->IsInGame())
|
||||||
{
|
{
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] DoClientMenu(): Failed to display to client %d", client);
|
logger->LogMessage("[SM_MENU] DoClientMenu(): Failed to display to client %d", client);
|
||||||
#endif
|
#endif
|
||||||
mh->OnMenuCancel(menu, client, MenuCancel_NoDisplay);
|
mh->OnMenuCancel(menu, client, MenuCancel_NoDisplay);
|
||||||
mh->OnMenuEnd(menu, MenuEnd_Cancelled);
|
mh->OnMenuEnd(menu, MenuEnd_Cancelled);
|
||||||
@@ -497,7 +501,7 @@ bool BaseMenuStyle::DoClientMenu(int client,
|
|||||||
if (player->bAutoIgnore)
|
if (player->bAutoIgnore)
|
||||||
{
|
{
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] DoClientMenu(): Client %d is autoIgnoring", client);
|
logger->LogMessage("[SM_MENU] DoClientMenu(): Client %d is autoIgnoring", client);
|
||||||
#endif
|
#endif
|
||||||
mh->OnMenuCancel(menu, client, MenuCancel_NoDisplay);
|
mh->OnMenuCancel(menu, client, MenuCancel_NoDisplay);
|
||||||
mh->OnMenuEnd(menu, MenuEnd_Cancelled);
|
mh->OnMenuEnd(menu, MenuEnd_Cancelled);
|
||||||
@@ -516,7 +520,7 @@ bool BaseMenuStyle::DoClientMenu(int client,
|
|||||||
if (player->bInMenu)
|
if (player->bInMenu)
|
||||||
{
|
{
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] DoClientMenu(): Cancelling old menu to client %d", client);
|
logger->LogMessage("[SM_MENU] DoClientMenu(): Cancelling old menu to client %d", client);
|
||||||
#endif
|
#endif
|
||||||
_CancelClientMenu(client, MenuCancel_Interrupted, true);
|
_CancelClientMenu(client, MenuCancel_Interrupted, true);
|
||||||
}
|
}
|
||||||
@@ -531,7 +535,7 @@ bool BaseMenuStyle::DoClientMenu(int client,
|
|||||||
if (!display)
|
if (!display)
|
||||||
{
|
{
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] DoClientMenu(): Failed to render to client %d", client);
|
logger->LogMessage("[SM_MENU] DoClientMenu(): Failed to render to client %d", client);
|
||||||
#endif
|
#endif
|
||||||
player->bAutoIgnore = false;
|
player->bAutoIgnore = false;
|
||||||
player->bInMenu = false;
|
player->bInMenu = false;
|
||||||
@@ -561,7 +565,7 @@ bool BaseMenuStyle::DoClientMenu(int client,
|
|||||||
player->bAutoIgnore = false;
|
player->bAutoIgnore = false;
|
||||||
|
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] DoClientMenu() finished successfully (client %d)", client);
|
logger->LogMessage("[SM_MENU] DoClientMenu() finished successfully (client %d)", client);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -570,17 +574,19 @@ bool BaseMenuStyle::DoClientMenu(int client,
|
|||||||
bool BaseMenuStyle::RedoClientMenu(int client, ItemOrder order)
|
bool BaseMenuStyle::RedoClientMenu(int client, ItemOrder order)
|
||||||
{
|
{
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] RedoClientMenu() (client %d) (order %d)", client, order);
|
logger->LogMessage("[SM_MENU] RedoClientMenu() (client %d) (order %d)", client, order);
|
||||||
#endif
|
#endif
|
||||||
CBaseMenuPlayer *player = GetMenuPlayer(client);
|
CBaseMenuPlayer *player = GetMenuPlayer(client);
|
||||||
menu_states_t &states = player->states;
|
menu_states_t &states = player->states;
|
||||||
|
|
||||||
|
AutoHandleRooter ahr(states.menu ? states.menu->GetHandle() : BAD_HANDLE);
|
||||||
|
|
||||||
player->bAutoIgnore = true;
|
player->bAutoIgnore = true;
|
||||||
IMenuPanel *display = g_Menus.RenderMenu(client, states, order);
|
IMenuPanel *display = g_Menus.RenderMenu(client, states, order);
|
||||||
if (!display)
|
if (!display)
|
||||||
{
|
{
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] RedoClientMenu(): Failed to render menu");
|
logger->LogMessage("[SM_MENU] RedoClientMenu(): Failed to render menu");
|
||||||
#endif
|
#endif
|
||||||
if (player->menuHoldTime)
|
if (player->menuHoldTime)
|
||||||
{
|
{
|
||||||
@@ -597,7 +603,7 @@ bool BaseMenuStyle::RedoClientMenu(int client, ItemOrder order)
|
|||||||
player->bAutoIgnore = false;
|
player->bAutoIgnore = false;
|
||||||
|
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] RedoClientMenu(): Succeeded to client %d", client);
|
logger->LogMessage("[SM_MENU] RedoClientMenu(): Succeeded to client %d", client);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -627,49 +633,49 @@ Handle_t CBaseMenu::GetHandle()
|
|||||||
bool CBaseMenu::AppendItem(const char *info, const ItemDrawInfo &draw)
|
bool CBaseMenu::AppendItem(const char *info, const ItemDrawInfo &draw)
|
||||||
{
|
{
|
||||||
if (m_Pagination == (unsigned)MENU_NO_PAGINATION
|
if (m_Pagination == (unsigned)MENU_NO_PAGINATION
|
||||||
&& m_items.length() >= m_pStyle->GetMaxPageItems())
|
&& m_items.size() >= m_pStyle->GetMaxPageItems())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CItem item;
|
CItem item(m_items.size());
|
||||||
|
|
||||||
item.info = info;
|
item.info = info;
|
||||||
if (draw.display)
|
if (draw.display)
|
||||||
item.display = new ke::AString(draw.display);
|
item.display = std::make_unique<std::string>(draw.display);
|
||||||
item.style = draw.style;
|
item.style = draw.style;
|
||||||
|
|
||||||
m_items.append(ke::Move(item));
|
m_items.push_back(std::move(item));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBaseMenu::InsertItem(unsigned int position, const char *info, const ItemDrawInfo &draw)
|
bool CBaseMenu::InsertItem(unsigned int position, const char *info, const ItemDrawInfo &draw)
|
||||||
{
|
{
|
||||||
if (m_Pagination == (unsigned)MENU_NO_PAGINATION &&
|
if (m_Pagination == (unsigned)MENU_NO_PAGINATION &&
|
||||||
m_items.length() >= m_pStyle->GetMaxPageItems())
|
m_items.size() >= m_pStyle->GetMaxPageItems())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (position >= m_items.length())
|
if (position >= m_items.size())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
CItem item;
|
CItem item(position);
|
||||||
item.info = info;
|
item.info = info;
|
||||||
if (draw.display)
|
if (draw.display)
|
||||||
item.display = new ke::AString(draw.display);
|
item.display = std::make_unique<std::string>(draw.display);
|
||||||
item.style = draw.style;
|
item.style = draw.style;
|
||||||
|
|
||||||
m_items.insert(position, ke::Move(item));
|
m_items.emplace(m_items.begin() + position, std::move(item));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBaseMenu::RemoveItem(unsigned int position)
|
bool CBaseMenu::RemoveItem(unsigned int position)
|
||||||
{
|
{
|
||||||
if (position >= m_items.length())
|
if (position >= m_items.size())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_items.remove(position);
|
m_items.erase(m_items.begin() + position);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -678,23 +684,84 @@ void CBaseMenu::RemoveAllItems()
|
|||||||
m_items.clear();
|
m_items.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *CBaseMenu::GetItemInfo(unsigned int position, ItemDrawInfo *draw/* =NULL */)
|
const char *CBaseMenu::GetItemInfo(unsigned int position, ItemDrawInfo *draw/* =NULL */, int client/* =0 */)
|
||||||
{
|
{
|
||||||
if (position >= m_items.length())
|
if (position >= m_items.size())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (client > 0 && position < m_RandomMaps[client].size())
|
||||||
|
{
|
||||||
|
position = m_RandomMaps[client][position];
|
||||||
|
}
|
||||||
|
|
||||||
if (draw)
|
if (draw)
|
||||||
{
|
{
|
||||||
draw->display = m_items[position].display->chars();
|
draw->display = m_items[position].display->c_str();
|
||||||
draw->style = m_items[position].style;
|
draw->style = m_items[position].style;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_items[position].info.chars();
|
return m_items[position].info.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CBaseMenu::ShufflePerClient(int start, int stop)
|
||||||
|
{
|
||||||
|
// limit map len to 255 items since it's using uint8
|
||||||
|
int length = MIN(GetItemCount(), 255);
|
||||||
|
if (stop >= 0)
|
||||||
|
length = MIN(length, stop);
|
||||||
|
|
||||||
|
for (int i = 1; i <= SM_MAXPLAYERS; i++)
|
||||||
|
{
|
||||||
|
// populate per-client map ...
|
||||||
|
m_RandomMaps[i].resize(length);
|
||||||
|
for (int j = 0; j < length; j++)
|
||||||
|
m_RandomMaps[i][j] = j;
|
||||||
|
|
||||||
|
// ... and random shuffle it
|
||||||
|
for (int j = length - 1; j > start; j--)
|
||||||
|
{
|
||||||
|
int x = rand() % (j - start + 1) + start;
|
||||||
|
uint8_t tmp = m_RandomMaps[i][x];
|
||||||
|
m_RandomMaps[i][x] = m_RandomMaps[i][j];
|
||||||
|
m_RandomMaps[i][j] = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CBaseMenu::SetClientMapping(int client, int *array, int length)
|
||||||
|
{
|
||||||
|
length = MIN(length, 255);
|
||||||
|
m_RandomMaps[client].resize(length);
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
m_RandomMaps[client][i] = array[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CBaseMenu::IsPerClientShuffled()
|
||||||
|
{
|
||||||
|
for (int i = 1; i <= SM_MAXPLAYERS; i++)
|
||||||
|
{
|
||||||
|
if(m_RandomMaps[i].size() > 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int CBaseMenu::GetRealItemIndex(int client, unsigned int position)
|
||||||
|
{
|
||||||
|
if (client > 0 && position < m_RandomMaps[client].size())
|
||||||
|
{
|
||||||
|
position = m_RandomMaps[client][position];
|
||||||
|
return m_items[position].index;
|
||||||
|
}
|
||||||
|
|
||||||
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int CBaseMenu::GetItemCount()
|
unsigned int CBaseMenu::GetItemCount()
|
||||||
{
|
{
|
||||||
return m_items.length();
|
return m_items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CBaseMenu::SetPagination(unsigned int itemsPerPage)
|
bool CBaseMenu::SetPagination(unsigned int itemsPerPage)
|
||||||
@@ -732,7 +799,7 @@ void CBaseMenu::SetDefaultTitle(const char *message)
|
|||||||
|
|
||||||
const char *CBaseMenu::GetDefaultTitle()
|
const char *CBaseMenu::GetDefaultTitle()
|
||||||
{
|
{
|
||||||
return m_Title.chars();
|
return m_Title.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBaseMenu::Cancel()
|
void CBaseMenu::Cancel()
|
||||||
@@ -743,7 +810,7 @@ void CBaseMenu::Cancel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] CBaseMenu::Cancel(%p) (m_bShouldDelete %d)",
|
logger->LogMessage("[SM_MENU] CBaseMenu::Cancel(%p) (m_bShouldDelete %d)",
|
||||||
this,
|
this,
|
||||||
m_bShouldDelete);
|
m_bShouldDelete);
|
||||||
#endif
|
#endif
|
||||||
@@ -767,7 +834,7 @@ void CBaseMenu::Destroy(bool releaseHandle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] CBaseMenu::Destroy(%p) (release %d) (m_bCancelling %d) (m_bShouldDelete %d)",
|
logger->LogMessage("[SM_MENU] CBaseMenu::Destroy(%p) (release %d) (m_bCancelling %d) (m_bShouldDelete %d)",
|
||||||
this,
|
this,
|
||||||
releaseHandle,
|
releaseHandle,
|
||||||
m_bCancelling,
|
m_bCancelling,
|
||||||
@@ -824,5 +891,5 @@ IMenuHandler *CBaseMenu::GetHandler()
|
|||||||
|
|
||||||
unsigned int CBaseMenu::GetBaseMemUsage()
|
unsigned int CBaseMenu::GetBaseMemUsage()
|
||||||
{
|
{
|
||||||
return m_Title.length() + (m_items.length() * sizeof(CItem));
|
return m_Title.size() + (m_items.size() * sizeof(CItem));
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-18
@@ -32,6 +32,9 @@
|
|||||||
#ifndef _INCLUDE_MENUSTYLE_BASE_H
|
#ifndef _INCLUDE_MENUSTYLE_BASE_H
|
||||||
#define _INCLUDE_MENUSTYLE_BASE_H
|
#define _INCLUDE_MENUSTYLE_BASE_H
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
#include <IMenuManager.h>
|
#include <IMenuManager.h>
|
||||||
#include <IPlayerHelpers.h>
|
#include <IPlayerHelpers.h>
|
||||||
#include <am-string.h>
|
#include <am-string.h>
|
||||||
@@ -43,36 +46,40 @@ using namespace SourceMod;
|
|||||||
class CItem
|
class CItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CItem()
|
CItem(unsigned int index)
|
||||||
{
|
{
|
||||||
|
this->index = index;
|
||||||
style = 0;
|
style = 0;
|
||||||
access = 0;
|
access = 0;
|
||||||
}
|
}
|
||||||
CItem(ke::Moveable<CItem> other)
|
CItem(CItem &&other)
|
||||||
: info(ke::Move(other->info)),
|
: info(std::move(other.info)),
|
||||||
display(ke::Move(other->display))
|
display(std::move(other.display))
|
||||||
{
|
{
|
||||||
style = other->style;
|
index = other.index;
|
||||||
access = other->access;
|
style = other.style;
|
||||||
|
access = other.access;
|
||||||
}
|
}
|
||||||
CItem & operator =(ke::Moveable<CItem> other)
|
CItem & operator =(CItem &&other)
|
||||||
{
|
{
|
||||||
info = ke::Move(other->info);
|
index = other.index;
|
||||||
display = ke::Move(other->display);
|
info = std::move(other.info);
|
||||||
style = other->style;
|
display = std::move(other.display);
|
||||||
access = other->access;
|
style = other.style;
|
||||||
|
access = other.access;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ke::AString info;
|
unsigned int index;
|
||||||
ke::AutoPtr<ke::AString> display;
|
std::string info;
|
||||||
|
std::unique_ptr<std::string> display;
|
||||||
unsigned int style;
|
unsigned int style;
|
||||||
unsigned int access;
|
unsigned int access;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CItem(const CItem &other) KE_DELETE;
|
CItem(const CItem &other) = delete;
|
||||||
CItem &operator =(const CItem &other) KE_DELETE;
|
CItem &operator =(const CItem &other) = delete;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CBaseMenuPlayer
|
class CBaseMenuPlayer
|
||||||
@@ -137,7 +144,7 @@ public:
|
|||||||
virtual bool InsertItem(unsigned int position, const char *info, const ItemDrawInfo &draw);
|
virtual bool InsertItem(unsigned int position, const char *info, const ItemDrawInfo &draw);
|
||||||
virtual bool RemoveItem(unsigned int position);
|
virtual bool RemoveItem(unsigned int position);
|
||||||
virtual void RemoveAllItems();
|
virtual void RemoveAllItems();
|
||||||
virtual const char *GetItemInfo(unsigned int position, ItemDrawInfo *draw=NULL);
|
virtual const char *GetItemInfo(unsigned int position, ItemDrawInfo *draw=NULL, int client=0);
|
||||||
virtual unsigned int GetItemCount();
|
virtual unsigned int GetItemCount();
|
||||||
virtual bool SetPagination(unsigned int itemsPerPage);
|
virtual bool SetPagination(unsigned int itemsPerPage);
|
||||||
virtual unsigned int GetPagination();
|
virtual unsigned int GetPagination();
|
||||||
@@ -151,14 +158,18 @@ public:
|
|||||||
virtual unsigned int GetMenuOptionFlags();
|
virtual unsigned int GetMenuOptionFlags();
|
||||||
virtual void SetMenuOptionFlags(unsigned int flags);
|
virtual void SetMenuOptionFlags(unsigned int flags);
|
||||||
virtual IMenuHandler *GetHandler();
|
virtual IMenuHandler *GetHandler();
|
||||||
|
virtual void ShufflePerClient(int start, int stop);
|
||||||
|
virtual void SetClientMapping(int client, int *array, int length);
|
||||||
|
virtual bool IsPerClientShuffled();
|
||||||
|
virtual unsigned int GetRealItemIndex(int client, unsigned int position);
|
||||||
unsigned int GetBaseMemUsage();
|
unsigned int GetBaseMemUsage();
|
||||||
private:
|
private:
|
||||||
void InternalDelete();
|
void InternalDelete();
|
||||||
protected:
|
protected:
|
||||||
ke::AString m_Title;
|
std::string m_Title;
|
||||||
IMenuStyle *m_pStyle;
|
IMenuStyle *m_pStyle;
|
||||||
unsigned int m_Pagination;
|
unsigned int m_Pagination;
|
||||||
ke::Vector<CItem> m_items;
|
std::vector<CItem> m_items;
|
||||||
bool m_bShouldDelete;
|
bool m_bShouldDelete;
|
||||||
bool m_bCancelling;
|
bool m_bCancelling;
|
||||||
IdentityToken_t *m_pOwner;
|
IdentityToken_t *m_pOwner;
|
||||||
@@ -167,6 +178,7 @@ protected:
|
|||||||
Handle_t m_hHandle;
|
Handle_t m_hHandle;
|
||||||
IMenuHandler *m_pHandler;
|
IMenuHandler *m_pHandler;
|
||||||
unsigned int m_nFlags;
|
unsigned int m_nFlags;
|
||||||
|
std::vector<uint8_t> m_RandomMaps[SM_MAXPLAYERS+1];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //_INCLUDE_MENUSTYLE_BASE_H
|
#endif //_INCLUDE_MENUSTYLE_BASE_H
|
||||||
|
|||||||
+48
-23
@@ -35,7 +35,7 @@
|
|||||||
#include <IGameConfigs.h>
|
#include <IGameConfigs.h>
|
||||||
#include "PlayerManager.h"
|
#include "PlayerManager.h"
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
#include "Logger.h"
|
#include <bridge/include/ILogger.h>
|
||||||
#endif
|
#endif
|
||||||
#include "logic_bridge.h"
|
#include "logic_bridge.h"
|
||||||
|
|
||||||
@@ -45,6 +45,12 @@
|
|||||||
|
|
||||||
#if SOURCE_ENGINE == SE_CSGO
|
#if SOURCE_ENGINE == SE_CSGO
|
||||||
#include <game/shared/csgo/protobuf/cstrike15_usermessages.pb.h>
|
#include <game/shared/csgo/protobuf/cstrike15_usermessages.pb.h>
|
||||||
|
#elif SOURCE_ENGINE == SE_BLADE
|
||||||
|
#include <game/shared/berimbau/protobuf/berimbau_usermessages.pb.h>
|
||||||
|
#elif SOURCE_ENGINE == SE_MCV
|
||||||
|
#include <game/shared/vietnam/protobuf/vietnam_usermessages.pb.h>
|
||||||
|
#elif SOURCE_ENGINE == SE_OUTBREAK
|
||||||
|
#include <game/shared/protobuf/base_usermessages.pb.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern const char *g_RadioNumTable[];
|
extern const char *g_RadioNumTable[];
|
||||||
@@ -59,7 +65,7 @@ unsigned int g_RadioMenuTimeout = 0;
|
|||||||
#define MAX_MENUSLOT_KEYS 10
|
#define MAX_MENUSLOT_KEYS 10
|
||||||
|
|
||||||
static unsigned int s_RadioMaxPageItems = MAX_MENUSLOT_KEYS;
|
static unsigned int s_RadioMaxPageItems = MAX_MENUSLOT_KEYS;
|
||||||
|
static bool s_RadioClosesOnInvalidSlot = false;
|
||||||
|
|
||||||
CRadioStyle::CRadioStyle()
|
CRadioStyle::CRadioStyle()
|
||||||
{
|
{
|
||||||
@@ -83,6 +89,10 @@ void CRadioStyle::OnSourceModLevelChange(const char *mapName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_bRadioInit = true;
|
g_bRadioInit = true;
|
||||||
|
|
||||||
|
// Always register the style. Use IsSupported() to check for validity before use.
|
||||||
|
g_Menus.AddStyle(this);
|
||||||
|
|
||||||
const char *msg = g_pGameConf->GetKeyValue("HudRadioMenuMsg");
|
const char *msg = g_pGameConf->GetKeyValue("HudRadioMenuMsg");
|
||||||
if (!msg || msg[0] == '\0')
|
if (!msg || msg[0] == '\0')
|
||||||
{
|
{
|
||||||
@@ -118,7 +128,12 @@ void CRadioStyle::OnSourceModLevelChange(const char *mapName)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_Menus.AddStyle(this);
|
const char *closes = g_pGameConf->GetKeyValue("RadioMenuClosesOnInvalidSlot");
|
||||||
|
if (closes != nullptr && strcmp(closes, "yes") == 0)
|
||||||
|
{
|
||||||
|
s_RadioClosesOnInvalidSlot = true;
|
||||||
|
}
|
||||||
|
|
||||||
g_Menus.SetDefaultStyle(this);
|
g_Menus.SetDefaultStyle(this);
|
||||||
|
|
||||||
g_UserMsgs.HookUserMessage(g_ShowMenuId, this, false);
|
g_UserMsgs.HookUserMessage(g_ShowMenuId, this, false);
|
||||||
@@ -131,18 +146,14 @@ void CRadioStyle::OnSourceModShutdown()
|
|||||||
|
|
||||||
while (!m_FreeDisplays.empty())
|
while (!m_FreeDisplays.empty())
|
||||||
{
|
{
|
||||||
delete m_FreeDisplays.front();
|
delete m_FreeDisplays.top();
|
||||||
m_FreeDisplays.pop();
|
m_FreeDisplays.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CRadioStyle::IsSupported()
|
bool CRadioStyle::IsSupported()
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
return (g_ShowMenuId != -1);
|
return (g_ShowMenuId != -1);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CRadioStyle::OnClientCommand(int client, const char *cmdname, const CCommand &cmd)
|
bool CRadioStyle::OnClientCommand(int client, const char *cmdname, const CCommand &cmd)
|
||||||
@@ -173,11 +184,12 @@ void CRadioStyle::OnUserMessage(int msg_id, protobuf::Message &msg, IRecipientFi
|
|||||||
void CRadioStyle::OnUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFilter)
|
void CRadioStyle::OnUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFilter)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE != SE_DOTA
|
|
||||||
int count = pFilter->GetRecipientCount();
|
int count = pFilter->GetRecipientCount();
|
||||||
|
|
||||||
#ifdef USE_PROTOBUF_USERMESSAGES
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
|
||||||
int c = ((CCSUsrMsg_ShowMenu &)msg).display_time();
|
int c = ((CCSUsrMsg_ShowMenu &)msg).display_time();
|
||||||
|
#elif SOURCE_ENGINE == SE_OUTBREAK
|
||||||
|
int c = ((CUsrMsg_ShowMenu &)msg).display_time();
|
||||||
#else
|
#else
|
||||||
bf_read br(bf->GetBasePointer(), 3);
|
bf_read br(bf->GetBasePointer(), 3);
|
||||||
|
|
||||||
@@ -191,7 +203,6 @@ void CRadioStyle::OnUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFil
|
|||||||
{
|
{
|
||||||
g_last_clients[g_last_client_count++] = pFilter->GetRecipientIndex(i);
|
g_last_clients[g_last_client_count++] = pFilter->GetRecipientIndex(i);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRadioStyle::OnUserMessageSent(int msg_id)
|
void CRadioStyle::OnUserMessageSent(int msg_id)
|
||||||
@@ -200,7 +211,7 @@ void CRadioStyle::OnUserMessageSent(int msg_id)
|
|||||||
{
|
{
|
||||||
int client = g_last_clients[i];
|
int client = g_last_clients[i];
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] CRadioStyle got ShowMenu (client %d) (bInMenu %d)",
|
logger->LogMessage("[SM_MENU] CRadioStyle got ShowMenu (client %d) (bInMenu %d)",
|
||||||
client,
|
client,
|
||||||
m_players[client].bInExternMenu);
|
m_players[client].bInExternMenu);
|
||||||
#endif
|
#endif
|
||||||
@@ -254,7 +265,7 @@ CRadioDisplay *CRadioStyle::MakeRadioDisplay(CRadioMenu *menu)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
display = m_FreeDisplays.front();
|
display = m_FreeDisplays.top();
|
||||||
m_FreeDisplays.pop();
|
m_FreeDisplays.pop();
|
||||||
display->Reset();
|
display->Reset();
|
||||||
}
|
}
|
||||||
@@ -453,7 +464,7 @@ void CRadioMenuPlayer::Radio_Init(int keys, const char *title, const char *text)
|
|||||||
{
|
{
|
||||||
if (title[0] != '\0')
|
if (title[0] != '\0')
|
||||||
{
|
{
|
||||||
display_len = UTIL_Format(display_pkt,
|
display_len = ke::SafeSprintf(display_pkt,
|
||||||
sizeof(display_pkt),
|
sizeof(display_pkt),
|
||||||
"%s\n%s",
|
"%s\n%s",
|
||||||
title,
|
title,
|
||||||
@@ -461,17 +472,24 @@ void CRadioMenuPlayer::Radio_Init(int keys, const char *title, const char *text)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
display_len = UTIL_Format(display_pkt,
|
display_len = ke::SafeStrcpy(display_pkt,
|
||||||
sizeof(display_pkt),
|
sizeof(display_pkt),
|
||||||
"%s",
|
|
||||||
text);
|
text);
|
||||||
}
|
}
|
||||||
display_keys = keys;
|
|
||||||
|
// Some games have implemented CHudMenu::SelectMenuItem to close the menu
|
||||||
|
// even if an invalid slot has been selected, which causes us a problem as
|
||||||
|
// we'll never get any notification from the client and we'll keep the menu
|
||||||
|
// alive on our end indefinitely. For these games, pretend that every slot
|
||||||
|
// is valid for selection so we're guaranteed to get a menuselect command.
|
||||||
|
// We don't want to do this for every game as the common SelectMenuItem
|
||||||
|
// implementation ignores invalid selections and keeps the menu open, which
|
||||||
|
// is a much nicer user experience.
|
||||||
|
display_keys = s_RadioClosesOnInvalidSlot ? 0x7ff : keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CRadioMenuPlayer::Radio_Refresh()
|
void CRadioMenuPlayer::Radio_Refresh()
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE != SE_DOTA
|
|
||||||
cell_t players[1] = { (cell_t)m_index };
|
cell_t players[1] = { (cell_t)m_index };
|
||||||
char *ptr = display_pkt;
|
char *ptr = display_pkt;
|
||||||
char save = 0;
|
char save = 0;
|
||||||
@@ -488,10 +506,17 @@ void CRadioMenuPlayer::Radio_Refresh()
|
|||||||
time = menuHoldTime - (unsigned int)(gpGlobals->curtime - menuStartTime);
|
time = menuHoldTime - (unsigned int)(gpGlobals->curtime - menuStartTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_PROTOBUF_USERMESSAGES
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
// If or when we need to support multiple games per engine with this, we can switch to reflection
|
|
||||||
// TODO: find what happens past 240 on CS:GO
|
// TODO: find what happens past 240 on CS:GO
|
||||||
CCSUsrMsg_ShowMenu *msg = (CCSUsrMsg_ShowMenu *)g_UserMsgs.StartProtobufMessage(g_ShowMenuId, players, 1, USERMSG_BLOCKHOOKS);
|
#if SOURCE_ENGINE == SE_OUTBREAK
|
||||||
|
CUsrMsg_ShowMenu *msg = (CUsrMsg_ShowMenu *)g_UserMsgs.StartProtobufMessage(g_ShowMenuId, players, 1, USERMSG_BLOCKHOOKS);
|
||||||
|
#else
|
||||||
|
CCSUsrMsg_ShowMenu *msg = (CCSUsrMsg_ShowMenu *)g_UserMsgs.StartProtobufMessage(g_ShowMenuId, players, 1, USERMSG_BLOCKHOOKS);
|
||||||
|
#endif
|
||||||
|
if (!msg)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
msg->set_bits_valid_slots(display_keys);
|
msg->set_bits_valid_slots(display_keys);
|
||||||
msg->set_display_time(time);
|
msg->set_display_time(time);
|
||||||
msg->set_menu_string(ptr);
|
msg->set_menu_string(ptr);
|
||||||
@@ -525,7 +550,6 @@ void CRadioMenuPlayer::Radio_Refresh()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
display_last_refresh = gpGlobals->curtime;
|
display_last_refresh = gpGlobals->curtime;
|
||||||
#endif // !DOTA
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int CRadioDisplay::GetAmountRemaining()
|
int CRadioDisplay::GetAmountRemaining()
|
||||||
@@ -583,7 +607,7 @@ bool CRadioMenu::DisplayAtItem(int client,
|
|||||||
IMenuHandler *alt_handler)
|
IMenuHandler *alt_handler)
|
||||||
{
|
{
|
||||||
#if defined MENU_DEBUG
|
#if defined MENU_DEBUG
|
||||||
g_Logger.LogMessage("[SM_MENU] CRadioMenu::Display(%p) (client %d) (time %d)",
|
logger->LogMessage("[SM_MENU] CRadioMenu::Display(%p) (client %d) (time %d)",
|
||||||
this,
|
this,
|
||||||
client,
|
client,
|
||||||
time);
|
time);
|
||||||
@@ -593,6 +617,7 @@ bool CRadioMenu::DisplayAtItem(int client,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AutoHandleRooter ahr(this->GetHandle());
|
||||||
return g_RadioMenuStyle.DoClientMenu(client,
|
return g_RadioMenuStyle.DoClientMenu(client,
|
||||||
this,
|
this,
|
||||||
start_item,
|
start_item,
|
||||||
|
|||||||
@@ -39,8 +39,11 @@
|
|||||||
#include <IPlayerHelpers.h>
|
#include <IPlayerHelpers.h>
|
||||||
#include "UserMessages.h"
|
#include "UserMessages.h"
|
||||||
#include "sm_fastlink.h"
|
#include "sm_fastlink.h"
|
||||||
#include <sh_stack.h>
|
#include <stack>
|
||||||
|
#include <string>
|
||||||
#include <compat_wrappers.h>
|
#include <compat_wrappers.h>
|
||||||
|
#include "logic/common_logic.h"
|
||||||
|
#include "AutoHandleRooter.h"
|
||||||
|
|
||||||
using namespace SourceMod;
|
using namespace SourceMod;
|
||||||
|
|
||||||
@@ -103,7 +106,7 @@ public:
|
|||||||
CRadioMenuPlayer *GetRadioMenuPlayer(int client);
|
CRadioMenuPlayer *GetRadioMenuPlayer(int client);
|
||||||
private:
|
private:
|
||||||
CRadioMenuPlayer *m_players;
|
CRadioMenuPlayer *m_players;
|
||||||
CStack<CRadioDisplay *> m_FreeDisplays;
|
std::stack<CRadioDisplay *> m_FreeDisplays;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CRadioDisplay : public IMenuPanel
|
class CRadioDisplay : public IMenuPanel
|
||||||
@@ -130,8 +133,8 @@ public: //IMenuPanel
|
|||||||
unsigned int GetApproxMemUsage();
|
unsigned int GetApproxMemUsage();
|
||||||
bool DirectSet(const char *str);
|
bool DirectSet(const char *str);
|
||||||
private:
|
private:
|
||||||
String m_BufferText;
|
std::string m_BufferText;
|
||||||
String m_Title;
|
std::string m_Title;
|
||||||
unsigned int m_NextPos;
|
unsigned int m_NextPos;
|
||||||
int keys;
|
int keys;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod
|
* SourceMod
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||||
@@ -40,7 +40,7 @@ SH_DECL_HOOK4_void(IServerPluginHelpers, CreateMessage, SH_NOATTRIB, false, edic
|
|||||||
ValveMenuStyle g_ValveMenuStyle;
|
ValveMenuStyle g_ValveMenuStyle;
|
||||||
extern const char *g_OptionNumTable[];
|
extern const char *g_OptionNumTable[];
|
||||||
extern const char *g_OptionCmdTable[];
|
extern const char *g_OptionCmdTable[];
|
||||||
CallClass<IServerPluginHelpers> *g_pSPHCC = NULL;
|
SourceHook::CallClass<IServerPluginHelpers> *g_pSPHCC = NULL;
|
||||||
|
|
||||||
ValveMenuStyle::ValveMenuStyle() : m_players(new CValveMenuPlayer[256+1])
|
ValveMenuStyle::ValveMenuStyle() : m_players(new CValveMenuPlayer[256+1])
|
||||||
{
|
{
|
||||||
@@ -65,20 +65,16 @@ bool ValveMenuStyle::OnClientCommand(int client, const char *cmdname, const CCom
|
|||||||
|
|
||||||
void ValveMenuStyle::OnSourceModAllInitialized()
|
void ValveMenuStyle::OnSourceModAllInitialized()
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE != SE_DOTA
|
|
||||||
g_Players.AddClientListener(this);
|
g_Players.AddClientListener(this);
|
||||||
SH_ADD_HOOK(IServerPluginHelpers, CreateMessage, serverpluginhelpers, SH_MEMBER(this, &ValveMenuStyle::HookCreateMessage), false);
|
SH_ADD_HOOK(IServerPluginHelpers, CreateMessage, serverpluginhelpers, SH_MEMBER(this, &ValveMenuStyle::HookCreateMessage), false);
|
||||||
g_pSPHCC = SH_GET_CALLCLASS(serverpluginhelpers);
|
g_pSPHCC = SH_GET_CALLCLASS(serverpluginhelpers);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValveMenuStyle::OnSourceModShutdown()
|
void ValveMenuStyle::OnSourceModShutdown()
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE != SE_DOTA
|
|
||||||
SH_RELEASE_CALLCLASS(g_pSPHCC);
|
SH_RELEASE_CALLCLASS(g_pSPHCC);
|
||||||
SH_REMOVE_HOOK(IServerPluginHelpers, CreateMessage, serverpluginhelpers, SH_MEMBER(this, &ValveMenuStyle::HookCreateMessage), false);
|
SH_REMOVE_HOOK(IServerPluginHelpers, CreateMessage, serverpluginhelpers, SH_MEMBER(this, &ValveMenuStyle::HookCreateMessage), false);
|
||||||
g_Players.RemoveClientListener(this);
|
g_Players.RemoveClientListener(this);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ValveMenuStyle::HookCreateMessage(edict_t *pEdict,
|
void ValveMenuStyle::HookCreateMessage(edict_t *pEdict,
|
||||||
@@ -297,7 +293,7 @@ unsigned int CValveMenuDisplay::DrawItem(const ItemDrawInfo &item)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char buffer[255];
|
char buffer[255];
|
||||||
UTIL_Format(buffer, sizeof(buffer), "%d. %s", m_NextPos, item.display);
|
ke::SafeSprintf(buffer, sizeof(buffer), "%d. %s", m_NextPos, item.display);
|
||||||
|
|
||||||
KeyValues *ki = m_pKv->FindKey(g_OptionNumTable[m_NextPos], true);
|
KeyValues *ki = m_pKv->FindKey(g_OptionNumTable[m_NextPos], true);
|
||||||
ki->SetString("command", g_OptionCmdTable[m_NextPos]);
|
ki->SetString("command", g_OptionCmdTable[m_NextPos]);
|
||||||
@@ -382,7 +378,7 @@ bool CValveMenu::SetExtOption(MenuOption option, const void *valuePtr)
|
|||||||
{
|
{
|
||||||
if (option == MenuOption_IntroMessage)
|
if (option == MenuOption_IntroMessage)
|
||||||
{
|
{
|
||||||
strncopy(m_IntroMsg, (const char *)valuePtr, sizeof(m_IntroMsg));
|
ke::SafeStrcpy(m_IntroMsg, sizeof(m_IntroMsg), (const char *)valuePtr);
|
||||||
return true;
|
return true;
|
||||||
} else if (option == MenuOption_IntroColor) {
|
} else if (option == MenuOption_IntroColor) {
|
||||||
unsigned int *array = (unsigned int *)valuePtr;
|
unsigned int *array = (unsigned int *)valuePtr;
|
||||||
@@ -408,6 +404,7 @@ bool CValveMenu::DisplayAtItem(int client,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AutoHandleRooter ahr(this->GetHandle());
|
||||||
return g_ValveMenuStyle.DoClientMenu(client, this, start_item, alt_handler ? alt_handler : m_pHandler, time);
|
return g_ValveMenuStyle.DoClientMenu(client, this, start_item, alt_handler ? alt_handler : m_pHandler, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,8 @@
|
|||||||
#include "KeyValues.h"
|
#include "KeyValues.h"
|
||||||
#include "sm_fastlink.h"
|
#include "sm_fastlink.h"
|
||||||
#include <compat_wrappers.h>
|
#include <compat_wrappers.h>
|
||||||
|
#include "logic/common_logic.h"
|
||||||
|
#include "AutoHandleRooter.h"
|
||||||
|
|
||||||
using namespace SourceMod;
|
using namespace SourceMod;
|
||||||
|
|
||||||
|
|||||||
+30
-5
@@ -41,6 +41,7 @@
|
|||||||
#include <const.h>
|
#include <const.h>
|
||||||
#include <ITranslator.h>
|
#include <ITranslator.h>
|
||||||
#include "logic_bridge.h"
|
#include "logic_bridge.h"
|
||||||
|
#include "AutoHandleRooter.h"
|
||||||
|
|
||||||
float g_next_vote = 0.0f;
|
float g_next_vote = 0.0f;
|
||||||
|
|
||||||
@@ -171,6 +172,12 @@ void VoteMenuHandler::OnClientDisconnected(int client)
|
|||||||
assert((unsigned)item < m_Items);
|
assert((unsigned)item < m_Items);
|
||||||
assert(m_Votes[item] > 0);
|
assert(m_Votes[item] > 0);
|
||||||
m_Votes[item]--;
|
m_Votes[item]--;
|
||||||
|
|
||||||
|
if (sm_vote_hintbox.GetBool())
|
||||||
|
{
|
||||||
|
BuildVoteLeaders();
|
||||||
|
DrawHintProgress();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
m_ClientVotes[client] = VOTE_NOT_VOTING;
|
m_ClientVotes[client] = VOTE_NOT_VOTING;
|
||||||
}
|
}
|
||||||
@@ -273,6 +280,12 @@ bool VoteMenuHandler::RedrawToClient(int client, bool revotes)
|
|||||||
m_ClientVotes[client] = VOTE_PENDING;
|
m_ClientVotes[client] = VOTE_PENDING;
|
||||||
m_Revoting[client] = true;
|
m_Revoting[client] = true;
|
||||||
m_NumVotes--;
|
m_NumVotes--;
|
||||||
|
|
||||||
|
if (sm_vote_hintbox.GetBool())
|
||||||
|
{
|
||||||
|
BuildVoteLeaders();
|
||||||
|
DrawHintProgress();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_nMenuTime == MENU_TIME_FOREVER)
|
if (m_nMenuTime == MENU_TIME_FOREVER)
|
||||||
@@ -351,7 +364,14 @@ void VoteMenuHandler::StartVoting()
|
|||||||
|
|
||||||
m_bStarted = true;
|
m_bStarted = true;
|
||||||
|
|
||||||
m_pHandler->OnMenuVoteStart(m_pCurMenu);
|
IBaseMenu *menu = m_pCurMenu;
|
||||||
|
AutoHandleRooter ahr(menu->GetHandle());
|
||||||
|
m_pHandler->OnMenuVoteStart(menu);
|
||||||
|
|
||||||
|
if (!m_bStarted)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_displayTimer = g_Timers.CreateTimer(this, 1.0, NULL, TIMER_FLAG_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
m_displayTimer = g_Timers.CreateTimer(this, 1.0, NULL, TIMER_FLAG_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
|
||||||
|
|
||||||
@@ -414,6 +434,7 @@ void VoteMenuHandler::EndVoting()
|
|||||||
IBaseMenu *menu = m_pCurMenu;
|
IBaseMenu *menu = m_pCurMenu;
|
||||||
IMenuHandler *handler = m_pHandler;
|
IMenuHandler *handler = m_pHandler;
|
||||||
InternalReset();
|
InternalReset();
|
||||||
|
AutoHandleRooter ahr(menu ? menu->GetHandle() : BAD_HANDLE);
|
||||||
handler->OnMenuVoteCancel(menu, VoteCancel_Generic);
|
handler->OnMenuVoteCancel(menu, VoteCancel_Generic);
|
||||||
handler->OnMenuEnd(menu, MenuEnd_VotingCancelled);
|
handler->OnMenuEnd(menu, MenuEnd_VotingCancelled);
|
||||||
return;
|
return;
|
||||||
@@ -443,6 +464,7 @@ void VoteMenuHandler::EndVoting()
|
|||||||
IBaseMenu *menu = m_pCurMenu;
|
IBaseMenu *menu = m_pCurMenu;
|
||||||
IMenuHandler *handler = m_pHandler;
|
IMenuHandler *handler = m_pHandler;
|
||||||
InternalReset();
|
InternalReset();
|
||||||
|
AutoHandleRooter ahr(menu ? menu->GetHandle() : BAD_HANDLE);
|
||||||
handler->OnMenuVoteCancel(menu, VoteCancel_NoVotes);
|
handler->OnMenuVoteCancel(menu, VoteCancel_NoVotes);
|
||||||
handler->OnMenuEnd(menu, MenuEnd_VotingCancelled);
|
handler->OnMenuEnd(menu, MenuEnd_VotingCancelled);
|
||||||
return;
|
return;
|
||||||
@@ -474,6 +496,7 @@ void VoteMenuHandler::EndVoting()
|
|||||||
InternalReset();
|
InternalReset();
|
||||||
|
|
||||||
/* Send vote info */
|
/* Send vote info */
|
||||||
|
AutoHandleRooter ahr(menu ? menu->GetHandle() : BAD_HANDLE);
|
||||||
handler->OnMenuVoteResults(menu, &vote);
|
handler->OnMenuVoteResults(menu, &vote);
|
||||||
handler->OnMenuEnd(menu, MenuEnd_VotingDone);
|
handler->OnMenuEnd(menu, MenuEnd_VotingDone);
|
||||||
}
|
}
|
||||||
@@ -514,15 +537,16 @@ void VoteMenuHandler::OnMenuSelect(IBaseMenu *menu, int client, unsigned int ite
|
|||||||
/* Check by our item count, NOT the vote array size */
|
/* Check by our item count, NOT the vote array size */
|
||||||
if (item < m_Items)
|
if (item < m_Items)
|
||||||
{
|
{
|
||||||
m_ClientVotes[client] = item;
|
unsigned int index = menu->GetRealItemIndex(client, item);
|
||||||
m_Votes[item]++;
|
m_ClientVotes[client] = index;
|
||||||
|
m_Votes[index]++;
|
||||||
m_NumVotes++;
|
m_NumVotes++;
|
||||||
|
|
||||||
if (sm_vote_chat.GetBool() || sm_vote_console.GetBool() || sm_vote_client_console.GetBool())
|
if (sm_vote_chat.GetBool() || sm_vote_console.GetBool() || sm_vote_client_console.GetBool())
|
||||||
{
|
{
|
||||||
static char buffer[1024];
|
static char buffer[1024];
|
||||||
ItemDrawInfo dr;
|
ItemDrawInfo dr;
|
||||||
menu->GetItemInfo(item, &dr);
|
menu->GetItemInfo(item, &dr, client);
|
||||||
|
|
||||||
if (sm_vote_console.GetBool())
|
if (sm_vote_console.GetBool())
|
||||||
{
|
{
|
||||||
@@ -560,7 +584,7 @@ void VoteMenuHandler::OnMenuSelect(IBaseMenu *menu, int client, unsigned int ite
|
|||||||
|
|
||||||
if (sm_vote_client_console.GetBool())
|
if (sm_vote_client_console.GetBool())
|
||||||
{
|
{
|
||||||
ClientConsolePrint(pPlayer->GetEdict(), buffer);
|
ClientConsolePrint(pPlayer->GetEdict(), "%s", buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -649,6 +673,7 @@ void VoteMenuHandler::BuildVoteLeaders()
|
|||||||
{
|
{
|
||||||
if (m_NumVotes == 0 || !sm_vote_hintbox.GetBool())
|
if (m_NumVotes == 0 || !sm_vote_hintbox.GetBool())
|
||||||
{
|
{
|
||||||
|
m_leaderList[0] = '\0';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -34,11 +34,10 @@
|
|||||||
|
|
||||||
#include <IMenuManager.h>
|
#include <IMenuManager.h>
|
||||||
#include <IPlayerHelpers.h>
|
#include <IPlayerHelpers.h>
|
||||||
#include <sh_vector.h>
|
#include <vector>
|
||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
#include <TimerSys.h>
|
#include <TimerSys.h>
|
||||||
|
|
||||||
using namespace SourceHook;
|
|
||||||
using namespace SourceMod;
|
using namespace SourceMod;
|
||||||
|
|
||||||
class VoteMenuHandler :
|
class VoteMenuHandler :
|
||||||
@@ -97,7 +96,7 @@ private:
|
|||||||
unsigned int m_Clients;
|
unsigned int m_Clients;
|
||||||
unsigned int m_TotalClients;
|
unsigned int m_TotalClients;
|
||||||
unsigned int m_Items;
|
unsigned int m_Items;
|
||||||
CVector<unsigned int> m_Votes;
|
std::vector<unsigned int> m_Votes;
|
||||||
IBaseMenu *m_pCurMenu;
|
IBaseMenu *m_pCurMenu;
|
||||||
bool m_bStarted;
|
bool m_bStarted;
|
||||||
bool m_bCancelled;
|
bool m_bCancelled;
|
||||||
|
|||||||
+46
-42
@@ -35,8 +35,10 @@
|
|||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
#include "sourcehook.h"
|
#include "sourcehook.h"
|
||||||
#include "sm_srvcmds.h"
|
|
||||||
#include "logic_bridge.h"
|
#include "logic_bridge.h"
|
||||||
|
#include "compat_wrappers.h"
|
||||||
|
#include <time.h>
|
||||||
|
#include <bridge/include/ILogger.h>
|
||||||
|
|
||||||
NextMapManager g_NextMap;
|
NextMapManager g_NextMap;
|
||||||
|
|
||||||
@@ -46,34 +48,22 @@ SH_DECL_HOOK2_void(IVEngineServer, ChangeLevel, SH_NOATTRIB, 0, const char *, co
|
|||||||
SH_DECL_HOOK4_void(IVEngineServer, ChangeLevel, SH_NOATTRIB, 0, const char *, const char *, const char *, bool);
|
SH_DECL_HOOK4_void(IVEngineServer, ChangeLevel, SH_NOATTRIB, 0, const char *, const char *, const char *, bool);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
SH_DECL_EXTERN2_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommandContext &, const CCommand &);
|
|
||||||
#elif SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
|
SH_DECL_EXTERN1_void(ConCommand, Dispatch, SH_NOATTRIB, false, const CCommand &);
|
||||||
#elif SOURCE_ENGINE == SE_DARKMESSIAH
|
|
||||||
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
|
||||||
#else
|
#else
|
||||||
# if SH_IMPL_VERSION >= 4
|
SH_DECL_EXTERN0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
|
||||||
extern int __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
|
||||||
# else
|
|
||||||
extern bool __SourceHook_FHAddConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
|
||||||
#endif
|
|
||||||
extern bool __SourceHook_FHRemoveConCommandDispatch(void *,bool,class fastdelegate::FastDelegate0<void>);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ConCommand *changeLevelCmd = NULL;
|
ConCommand *changeLevelCmd = NULL;
|
||||||
|
|
||||||
ConVar sm_nextmap("sm_nextmap", "", FCVAR_NOTIFY);
|
ConVar sm_nextmap("sm_nextmap", "", FCVAR_NOTIFY);
|
||||||
|
ConVar sm_maphistory_size("sm_maphistory_size", "20");
|
||||||
|
|
||||||
bool g_forcedChange = false;
|
bool g_forcedChange = false;
|
||||||
|
|
||||||
void NextMapManager::OnSourceModAllInitialized_Post()
|
void NextMapManager::OnSourceModAllInitialized_Post()
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
SH_ADD_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false);
|
SH_ADD_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false);
|
||||||
#else
|
|
||||||
SH_ADD_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ConCommand *pCmd = FindCommand("changelevel");
|
ConCommand *pCmd = FindCommand("changelevel");
|
||||||
if (pCmd != NULL)
|
if (pCmd != NULL)
|
||||||
@@ -85,19 +75,14 @@ void NextMapManager::OnSourceModAllInitialized_Post()
|
|||||||
|
|
||||||
void NextMapManager::OnSourceModShutdown()
|
void NextMapManager::OnSourceModShutdown()
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
SH_REMOVE_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false);
|
SH_REMOVE_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false);
|
||||||
#else
|
|
||||||
SH_REMOVE_HOOK(IVEngineServer, ChangeLevel, engine, SH_MEMBER(this, &NextMapManager::HookChangeLevel), false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (changeLevelCmd != NULL)
|
if (changeLevelCmd != NULL)
|
||||||
{
|
{
|
||||||
SH_REMOVE_HOOK(ConCommand, Dispatch, changeLevelCmd, SH_STATIC(CmdChangeLevelCallback), false);
|
SH_REMOVE_HOOK(ConCommand, Dispatch, changeLevelCmd, SH_STATIC(CmdChangeLevelCallback), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceHook::List<MapChangeData *>::iterator iter;
|
auto iter = m_mapHistory.begin();
|
||||||
iter = m_mapHistory.begin();
|
|
||||||
|
|
||||||
while (iter != m_mapHistory.end())
|
while (iter != m_mapHistory.end())
|
||||||
{
|
{
|
||||||
@@ -123,6 +108,8 @@ bool NextMapManager::SetNextMap(const char *map)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char g_nextMap[PLATFORM_MAX_PATH];
|
||||||
|
|
||||||
#if SOURCE_ENGINE != SE_DARKMESSIAH
|
#if SOURCE_ENGINE != SE_DARKMESSIAH
|
||||||
void NextMapManager::HookChangeLevel(const char *map, const char *unknown)
|
void NextMapManager::HookChangeLevel(const char *map, const char *unknown)
|
||||||
#else
|
#else
|
||||||
@@ -136,16 +123,24 @@ void NextMapManager::HookChangeLevel(const char *map, const char *unknown, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char *newmap = sm_nextmap.GetString();
|
const char *newmap = sm_nextmap.GetString();
|
||||||
|
if (newmap[0] != '\0') {
|
||||||
|
ke::SafeStrcpy(g_nextMap, sizeof(g_nextMap), newmap);
|
||||||
|
newmap = g_nextMap;
|
||||||
|
|
||||||
if (newmap[0] == 0 || !g_HL2.IsMapValid(newmap))
|
// Clear the value so that if the map load fails later we don't get stuck in a loop.
|
||||||
|
// This might cause us to go off-cycle for a map, but nextmap will get us back on track.
|
||||||
|
sm_nextmap.SetValue("");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newmap[0] == '\0' || !g_HL2.IsMapValid(newmap))
|
||||||
{
|
{
|
||||||
RETURN_META(MRES_IGNORED);
|
RETURN_META(MRES_IGNORED);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger->LogMessage("[SM] Changed map to \"%s\"", newmap);
|
logger->LogMessage("[SM] Changed map to \"%s\"", newmap);
|
||||||
|
|
||||||
UTIL_Format(m_tempChangeInfo.m_mapName, sizeof(m_tempChangeInfo.m_mapName), newmap);
|
ke::SafeStrcpy(m_tempChangeInfo.m_mapName, sizeof(m_tempChangeInfo.m_mapName), newmap);
|
||||||
UTIL_Format(m_tempChangeInfo.m_changeReason, sizeof(m_tempChangeInfo.m_changeReason), "Normal level change");
|
ke::SafeStrcpy(m_tempChangeInfo.m_changeReason, sizeof(m_tempChangeInfo.m_changeReason), "Normal level change");
|
||||||
|
|
||||||
#if SOURCE_ENGINE != SE_DARKMESSIAH
|
#if SOURCE_ENGINE != SE_DARKMESSIAH
|
||||||
RETURN_META_NEWPARAMS(MRES_IGNORED, &IVEngineServer::ChangeLevel, (newmap, unknown));
|
RETURN_META_NEWPARAMS(MRES_IGNORED, &IVEngineServer::ChangeLevel, (newmap, unknown));
|
||||||
@@ -156,6 +151,15 @@ void NextMapManager::HookChangeLevel(const char *map, const char *unknown, const
|
|||||||
|
|
||||||
void NextMapManager::OnSourceModLevelChange( const char *mapName )
|
void NextMapManager::OnSourceModLevelChange( const char *mapName )
|
||||||
{
|
{
|
||||||
|
// If we were controlling the map change, reset sm_nextmap to be the name of the map we successfully changed to.
|
||||||
|
// This maintains an old API contract on the plugin side. We use the real map name even if it was different from
|
||||||
|
// the expected map name as if the expected map failed to load we let the game take over instead, but the nextmap
|
||||||
|
// plugin compares the sm_nextmap value to the current map to decide if it should advance the mapcycle.
|
||||||
|
if (g_nextMap[0] != '\0') {
|
||||||
|
sm_nextmap.SetValue(mapName);
|
||||||
|
g_nextMap[0] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
/* Skip the first 'mapchange' when the server starts up */
|
/* Skip the first 'mapchange' when the server starts up */
|
||||||
if (m_tempChangeInfo.startTime != 0)
|
if (m_tempChangeInfo.startTime != 0)
|
||||||
{
|
{
|
||||||
@@ -168,33 +172,36 @@ void NextMapManager::OnSourceModLevelChange( const char *mapName )
|
|||||||
{
|
{
|
||||||
/* Something intercepted the mapchange */
|
/* Something intercepted the mapchange */
|
||||||
char newReason[255];
|
char newReason[255];
|
||||||
UTIL_Format(newReason, sizeof(newReason), "%s (Map overridden)", m_tempChangeInfo.m_changeReason);
|
ke::SafeSprintf(newReason, sizeof(newReason), "%s (Map overridden)", m_tempChangeInfo.m_changeReason);
|
||||||
m_mapHistory.push_back(new MapChangeData(lastMap, newReason, m_tempChangeInfo.startTime));
|
m_mapHistory.push_back(new MapChangeData(lastMap, newReason, m_tempChangeInfo.startTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Should this be customizable? */
|
int historydiff = sm_maphistory_size.GetInt();
|
||||||
if (m_mapHistory.size() > 20)
|
if (historydiff > 0)
|
||||||
{
|
{
|
||||||
SourceHook::List<MapChangeData *>::iterator iter;
|
historydiff -= m_mapHistory.size();
|
||||||
iter = m_mapHistory.begin();
|
} else if (historydiff < 0)
|
||||||
|
{
|
||||||
|
historydiff = (m_mapHistory.size() * -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto iter = m_mapHistory.begin(); historydiff++ < 0; iter = m_mapHistory.erase(iter))
|
||||||
|
{
|
||||||
delete (MapChangeData *)*iter;
|
delete (MapChangeData *)*iter;
|
||||||
|
|
||||||
m_mapHistory.erase(iter);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_tempChangeInfo.m_mapName[0] ='\0';
|
m_tempChangeInfo.m_mapName[0] ='\0';
|
||||||
m_tempChangeInfo.m_changeReason[0] = '\0';
|
m_tempChangeInfo.m_changeReason[0] = '\0';
|
||||||
m_tempChangeInfo.startTime = time(NULL);
|
m_tempChangeInfo.startTime = time(NULL);
|
||||||
UTIL_Format(lastMap, sizeof(lastMap), "%s", mapName);
|
ke::SafeStrcpy(lastMap, sizeof(lastMap), mapName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NextMapManager::ForceChangeLevel( const char *mapName, const char* changeReason )
|
void NextMapManager::ForceChangeLevel( const char *mapName, const char* changeReason )
|
||||||
{
|
{
|
||||||
/* Store the mapname and reason */
|
/* Store the mapname and reason */
|
||||||
UTIL_Format(m_tempChangeInfo.m_mapName, sizeof(m_tempChangeInfo.m_mapName), "%s", mapName);
|
ke::SafeStrcpy(m_tempChangeInfo.m_mapName, sizeof(m_tempChangeInfo.m_mapName), mapName);
|
||||||
UTIL_Format(m_tempChangeInfo.m_changeReason, sizeof(m_tempChangeInfo.m_changeReason), "%s", changeReason);
|
ke::SafeStrcpy(m_tempChangeInfo.m_changeReason, sizeof(m_tempChangeInfo.m_changeReason), changeReason);
|
||||||
|
|
||||||
/* Change level and skip our hook */
|
/* Change level and skip our hook */
|
||||||
g_forcedChange = true;
|
g_forcedChange = true;
|
||||||
@@ -205,13 +212,10 @@ void NextMapManager::ForceChangeLevel( const char *mapName, const char* changeRe
|
|||||||
NextMapManager::NextMapManager()
|
NextMapManager::NextMapManager()
|
||||||
{
|
{
|
||||||
m_tempChangeInfo = MapChangeData();
|
m_tempChangeInfo = MapChangeData();
|
||||||
m_mapHistory = SourceHook::List<MapChangeData *>();
|
m_mapHistory = std::list<MapChangeData *>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
void CmdChangeLevelCallback(const CCommandContext &context, const CCommand &command)
|
|
||||||
{
|
|
||||||
#elif SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
void CmdChangeLevelCallback(const CCommand &command)
|
void CmdChangeLevelCallback(const CCommand &command)
|
||||||
{
|
{
|
||||||
#else
|
#else
|
||||||
@@ -227,7 +231,7 @@ void CmdChangeLevelCallback()
|
|||||||
|
|
||||||
if (g_NextMap.m_tempChangeInfo.m_mapName[0] == '\0')
|
if (g_NextMap.m_tempChangeInfo.m_mapName[0] == '\0')
|
||||||
{
|
{
|
||||||
UTIL_Format(g_NextMap.m_tempChangeInfo.m_mapName, sizeof(g_NextMap.m_tempChangeInfo.m_mapName), command.Arg(1));
|
ke::SafeStrcpy(g_NextMap.m_tempChangeInfo.m_mapName, sizeof(g_NextMap.m_tempChangeInfo.m_mapName), command.Arg(1));
|
||||||
UTIL_Format(g_NextMap.m_tempChangeInfo.m_changeReason, sizeof(g_NextMap.m_tempChangeInfo.m_changeReason), "changelevel Command");
|
ke::SafeStrcpy(g_NextMap.m_tempChangeInfo.m_changeReason, sizeof(g_NextMap.m_tempChangeInfo.m_changeReason), "changelevel Command");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-12
@@ -33,16 +33,17 @@
|
|||||||
#define _INCLUDE_SOURCEMOD_NEXTMAP_H_
|
#define _INCLUDE_SOURCEMOD_NEXTMAP_H_
|
||||||
|
|
||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
#include "eiface.h"
|
#include <eiface.h>
|
||||||
#include "sh_list.h"
|
#include <list>
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
|
#include <amtl/am-string.h>
|
||||||
|
|
||||||
struct MapChangeData
|
struct MapChangeData
|
||||||
{
|
{
|
||||||
MapChangeData(const char *mapName, const char *changeReason, time_t time)
|
MapChangeData(const char *mapName, const char *changeReason, time_t time)
|
||||||
{
|
{
|
||||||
UTIL_Format(m_mapName, sizeof(m_mapName), mapName);
|
ke::SafeStrcpy(m_mapName, sizeof(m_mapName), mapName);
|
||||||
UTIL_Format(m_changeReason, sizeof(m_changeReason), changeReason);
|
ke::SafeStrcpy(m_changeReason, sizeof(m_changeReason), changeReason);
|
||||||
startTime = time;
|
startTime = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,9 +59,7 @@ struct MapChangeData
|
|||||||
time_t startTime;
|
time_t startTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
void CmdChangeLevelCallback(const CCommandContext &context, const CCommand &command);
|
|
||||||
#elif SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
void CmdChangeLevelCallback(const CCommand &command);
|
void CmdChangeLevelCallback(const CCommand &command);
|
||||||
#else
|
#else
|
||||||
void CmdChangeLevelCallback();
|
void CmdChangeLevelCallback();
|
||||||
@@ -71,9 +70,7 @@ class NextMapManager : public SMGlobalClass
|
|||||||
public:
|
public:
|
||||||
NextMapManager();
|
NextMapManager();
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
friend void CmdChangeLevelCallback(const CCommandContext &context, const CCommand &command);
|
|
||||||
#elif SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
friend void CmdChangeLevelCallback(const CCommand &command);
|
friend void CmdChangeLevelCallback(const CCommand &command);
|
||||||
#else
|
#else
|
||||||
friend void CmdChangeLevelCallback();
|
friend void CmdChangeLevelCallback();
|
||||||
@@ -95,11 +92,11 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SourceHook::List<MapChangeData *> m_mapHistory;
|
std::list<MapChangeData *> m_mapHistory;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MapChangeData m_tempChangeInfo;
|
MapChangeData m_tempChangeInfo;
|
||||||
char lastMap[32];
|
char lastMap[PLATFORM_MAX_PATH];
|
||||||
};
|
};
|
||||||
|
|
||||||
extern NextMapManager g_NextMap;
|
extern NextMapManager g_NextMap;
|
||||||
|
|||||||
+605
-443
File diff suppressed because it is too large
Load Diff
+72
-51
@@ -1,8 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sts=8 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod
|
* SourceMod
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
* Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved.
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
* This program is free software; you can redistribute it and/or modify it under
|
||||||
@@ -38,15 +38,17 @@
|
|||||||
#include <IForwardSys.h>
|
#include <IForwardSys.h>
|
||||||
#include <IPlayerHelpers.h>
|
#include <IPlayerHelpers.h>
|
||||||
#include <IAdminSystem.h>
|
#include <IAdminSystem.h>
|
||||||
#include <sh_string.h>
|
#include <ITranslator.h>
|
||||||
#include <sh_list.h>
|
#include <string>
|
||||||
#include <sh_vector.h>
|
#include <list>
|
||||||
|
#include <vector>
|
||||||
#include <am-string.h>
|
#include <am-string.h>
|
||||||
|
#include <am-deque.h>
|
||||||
#include "ConVarManager.h"
|
#include "ConVarManager.h"
|
||||||
|
|
||||||
#include <steam/steamclientpublic.h>
|
#include <steam/steamclientpublic.h>
|
||||||
|
|
||||||
using namespace SourceHook;
|
class IClient;
|
||||||
|
|
||||||
#define PLAYER_LIFE_UNKNOWN 0
|
#define PLAYER_LIFE_UNKNOWN 0
|
||||||
#define PLAYER_LIFE_ALIVE 1
|
#define PLAYER_LIFE_ALIVE 1
|
||||||
@@ -92,6 +94,7 @@ public:
|
|||||||
bool IsInKickQueue();
|
bool IsInKickQueue();
|
||||||
IPlayerInfo *GetPlayerInfo();
|
IPlayerInfo *GetPlayerInfo();
|
||||||
unsigned int GetLanguageId();
|
unsigned int GetLanguageId();
|
||||||
|
unsigned int GetOriginalLanguageId();
|
||||||
void SetLanguageId(unsigned int id);
|
void SetLanguageId(unsigned int id);
|
||||||
int GetUserId();
|
int GetUserId();
|
||||||
bool RunAdminCacheChecks();
|
bool RunAdminCacheChecks();
|
||||||
@@ -104,6 +107,9 @@ public:
|
|||||||
void DoBasicAdminChecks();
|
void DoBasicAdminChecks();
|
||||||
void MarkAsBeingKicked();
|
void MarkAsBeingKicked();
|
||||||
int GetLifeState();
|
int GetLifeState();
|
||||||
|
|
||||||
|
// This can be NULL for fakeclients due to limitations in our impl
|
||||||
|
IClient *GetIClient() const;
|
||||||
private:
|
private:
|
||||||
void Initialize(const char *name, const char *ip, edict_t *pEntity);
|
void Initialize(const char *name, const char *ip, edict_t *pEntity);
|
||||||
void Connect();
|
void Connect();
|
||||||
@@ -115,34 +121,40 @@ private:
|
|||||||
void Authorize_Post();
|
void Authorize_Post();
|
||||||
void DoPostConnectAuthorization();
|
void DoPostConnectAuthorization();
|
||||||
bool IsAuthStringValidated();
|
bool IsAuthStringValidated();
|
||||||
|
bool SetEngineString();
|
||||||
|
bool SetCSteamID();
|
||||||
|
void ClearNetchannelQueue(void);
|
||||||
private:
|
private:
|
||||||
bool m_IsConnected;
|
bool m_IsConnected = false;
|
||||||
bool m_IsInGame;
|
bool m_IsInGame = false;
|
||||||
bool m_IsAuthorized;
|
bool m_IsAuthorized = false;
|
||||||
bool m_bIsInKickQueue;
|
bool m_bIsInKickQueue = false;
|
||||||
String m_Name;
|
std::string m_Name;
|
||||||
String m_Ip;
|
std::string m_Ip;
|
||||||
String m_IpNoPort;
|
std::string m_IpNoPort;
|
||||||
ke::AString m_AuthID;
|
std::string m_AuthID;
|
||||||
ke::AString m_Steam2Id;
|
std::string m_Steam2Id;
|
||||||
ke::AString m_Steam3Id;
|
std::string m_Steam3Id;
|
||||||
AdminId m_Admin;
|
AdminId m_Admin = INVALID_ADMIN_ID;
|
||||||
bool m_TempAdmin;
|
bool m_TempAdmin = false;
|
||||||
edict_t *m_pEdict;
|
edict_t *m_pEdict = nullptr;
|
||||||
IPlayerInfo *m_Info;
|
IPlayerInfo *m_Info = nullptr;
|
||||||
String m_LastPassword;
|
IClient *m_pIClient = nullptr;
|
||||||
bool m_bAdminCheckSignalled;
|
std::string m_LastPassword;
|
||||||
|
bool m_bAdminCheckSignalled = false;
|
||||||
int m_iIndex;
|
int m_iIndex;
|
||||||
unsigned int m_LangId;
|
unsigned int m_LangId = SOURCEMOD_LANGUAGE_ENGLISH;
|
||||||
int m_UserId;
|
unsigned int m_OriginalLangId = SOURCEMOD_LANGUAGE_ENGLISH;
|
||||||
bool m_bFakeClient;
|
int m_UserId = -1;
|
||||||
bool m_bIsSourceTV;
|
bool m_bFakeClient = false;
|
||||||
bool m_bIsReplay;
|
bool m_bIsSourceTV = false;
|
||||||
|
bool m_bIsReplay = false;
|
||||||
serial_t m_Serial;
|
serial_t m_Serial;
|
||||||
CSteamID m_SteamId;
|
CSteamID m_SteamId;
|
||||||
#if SOURCE_ENGINE == SE_CSGO
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
QueryCvarCookie_t m_LanguageCookie;
|
QueryCvarCookie_t m_LanguageCookie = InvalidQueryCvarCookie;
|
||||||
#endif
|
#endif
|
||||||
|
std::deque<std::string> m_PrintfBuffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PlayerManager :
|
class PlayerManager :
|
||||||
@@ -154,6 +166,7 @@ public:
|
|||||||
PlayerManager();
|
PlayerManager();
|
||||||
~PlayerManager();
|
~PlayerManager();
|
||||||
public: //SMGlobalClass
|
public: //SMGlobalClass
|
||||||
|
void OnSourceModStartup(bool late) override;
|
||||||
void OnSourceModAllInitialized();
|
void OnSourceModAllInitialized();
|
||||||
void OnSourceModShutdown();
|
void OnSourceModShutdown();
|
||||||
void OnSourceModLevelEnd();
|
void OnSourceModLevelEnd();
|
||||||
@@ -163,16 +176,6 @@ public:
|
|||||||
CPlayer *GetPlayerByIndex(int client) const;
|
CPlayer *GetPlayerByIndex(int client) const;
|
||||||
void RunAuthChecks();
|
void RunAuthChecks();
|
||||||
public:
|
public:
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
|
||||||
bool OnClientConnect(CEntityIndex index, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
|
|
||||||
bool OnClientConnect_Post(CEntityIndex index, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
|
|
||||||
void OnClientPutInServer(CEntityIndex index, char const *playername);
|
|
||||||
void OnClientDisconnect(CEntityIndex index, int reason);
|
|
||||||
void OnClientDisconnect_Post(CEntityIndex index, int reason);
|
|
||||||
void OnClientCommand(CEntityIndex index, const CCommand &args);
|
|
||||||
void OnClientSettingsChanged(CEntityIndex index);
|
|
||||||
//void OnClientSettingsChanged_Pre(CEntityIndex client);
|
|
||||||
#else
|
|
||||||
bool OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
|
bool OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
|
||||||
bool OnClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
|
bool OnClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
|
||||||
void OnClientPutInServer(edict_t *pEntity, char const *playername);
|
void OnClientPutInServer(edict_t *pEntity, char const *playername);
|
||||||
@@ -180,13 +183,26 @@ public:
|
|||||||
void OnClientDisconnect_Post(edict_t *pEntity);
|
void OnClientDisconnect_Post(edict_t *pEntity);
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
void OnClientCommand(edict_t *pEntity, const CCommand &args);
|
void OnClientCommand(edict_t *pEntity, const CCommand &args);
|
||||||
|
#if SOURCE_ENGINE >= SE_EYE
|
||||||
|
void OnClientCommandKeyValues(edict_t *pEntity, KeyValues *pCommand);
|
||||||
|
void OnClientCommandKeyValues_Post(edict_t *pEntity, KeyValues *pCommand);
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
void OnClientCommand(edict_t *pEntity);
|
void OnClientCommand(edict_t *pEntity);
|
||||||
#endif
|
#endif
|
||||||
void OnClientSettingsChanged(edict_t *pEntity);
|
void OnClientSettingsChanged(edict_t *pEntity);
|
||||||
//void OnClientSettingsChanged_Pre(edict_t *pEntity);
|
//void OnClientSettingsChanged_Pre(edict_t *pEntity);
|
||||||
|
#if SOURCE_ENGINE >= SE_ORANGEBOX && SOURCE_ENGINE != SE_MOCK
|
||||||
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
|
void OnNetworkIDValidated(const char *pszUserName, const char *pszNetworkID, CSteamID steamID);
|
||||||
|
#else
|
||||||
|
void OnNetworkIDValidated(const char *pszUserName, const char *pszNetworkID);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
void OnClientLanguageChanged(int client, unsigned int language);
|
||||||
void OnServerHibernationUpdate(bool bHibernating);
|
void OnServerHibernationUpdate(bool bHibernating);
|
||||||
|
void OnClientPrintf(edict_t *pEdict, const char *szMsg);
|
||||||
|
void OnPrintfFrameAction(unsigned int serial);
|
||||||
public: //IPlayerManager
|
public: //IPlayerManager
|
||||||
void AddClientListener(IClientListener *listener);
|
void AddClientListener(IClientListener *listener);
|
||||||
void RemoveClientListener(IClientListener *listener);
|
void RemoveClientListener(IClientListener *listener);
|
||||||
@@ -223,26 +239,29 @@ public:
|
|||||||
unsigned int GetReplyTo();
|
unsigned int GetReplyTo();
|
||||||
unsigned int SetReplyTo(unsigned int reply);
|
unsigned int SetReplyTo(unsigned int reply);
|
||||||
void MaxPlayersChanged(int newvalue = -1);
|
void MaxPlayersChanged(int newvalue = -1);
|
||||||
#if SOURCE_ENGINE == SE_CSGO
|
inline bool InClientCommandKeyValuesHook()
|
||||||
bool HandleConVarQuery(QueryCvarCookie_t cookie, edict_t *pPlayer, EQueryCvarValueStatus result, const char *cvarName, const char *cvarValue);
|
{
|
||||||
|
return m_bInCCKVHook;
|
||||||
|
}
|
||||||
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
|
bool HandleConVarQuery(QueryCvarCookie_t cookie, int client, EQueryCvarValueStatus result, const char *cvarName, const char *cvarValue);
|
||||||
#endif
|
#endif
|
||||||
private:
|
private:
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
|
||||||
void OnServerActivate();
|
|
||||||
#else
|
|
||||||
void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
|
void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
|
||||||
#endif
|
|
||||||
void InvalidatePlayer(CPlayer *pPlayer);
|
void InvalidatePlayer(CPlayer *pPlayer);
|
||||||
private:
|
private:
|
||||||
List<IClientListener *> m_hooks;
|
std::list<IClientListener *> m_hooks;
|
||||||
IForward *m_clconnect;
|
IForward *m_clconnect;
|
||||||
IForward *m_clconnect_post;
|
IForward *m_clconnect_post;
|
||||||
IForward *m_cldisconnect;
|
IForward *m_cldisconnect;
|
||||||
IForward *m_cldisconnect_post;
|
IForward *m_cldisconnect_post;
|
||||||
IForward *m_clputinserver;
|
IForward *m_clputinserver;
|
||||||
IForward *m_clcommand;
|
IForward *m_clcommand;
|
||||||
|
IForward *m_clcommandkv;
|
||||||
|
IForward *m_clcommandkv_post;
|
||||||
IForward *m_clinfochanged;
|
IForward *m_clinfochanged;
|
||||||
IForward *m_clauth;
|
IForward *m_clauth;
|
||||||
|
IForward *m_cllang;
|
||||||
IForward *m_onActivate;
|
IForward *m_onActivate;
|
||||||
IForward *m_onActivate2;
|
IForward *m_onActivate2;
|
||||||
CPlayer *m_Players;
|
CPlayer *m_Players;
|
||||||
@@ -250,9 +269,9 @@ private:
|
|||||||
int m_maxClients;
|
int m_maxClients;
|
||||||
int m_PlayerCount;
|
int m_PlayerCount;
|
||||||
int m_PlayersSinceActive;
|
int m_PlayersSinceActive;
|
||||||
bool m_FirstPass;
|
bool m_bServerActivated;
|
||||||
unsigned int *m_AuthQueue;
|
unsigned int *m_AuthQueue;
|
||||||
String m_PassInfoVar;
|
std::string m_PassInfoVar;
|
||||||
bool m_QueryLang;
|
bool m_QueryLang;
|
||||||
bool m_bAuthstringValidation; // are we validating admins with steam before authorizing?
|
bool m_bAuthstringValidation; // are we validating admins with steam before authorizing?
|
||||||
bool m_bIsListenServer;
|
bool m_bIsListenServer;
|
||||||
@@ -261,11 +280,13 @@ private:
|
|||||||
bool m_bIsReplayActive;
|
bool m_bIsReplayActive;
|
||||||
int m_SourceTVUserId;
|
int m_SourceTVUserId;
|
||||||
int m_ReplayUserId;
|
int m_ReplayUserId;
|
||||||
|
bool m_bInCCKVHook;
|
||||||
|
private:
|
||||||
|
static const int NETMSG_TYPE_BITS = 5; // SVC_Print overhead for netmsg type
|
||||||
|
static const int SVC_Print_BufferSize = 2048 - 1; // -1 for terminating \0
|
||||||
};
|
};
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
void CmdMaxplayersCallback(const CCommandContext &context, const CCommand &command);
|
|
||||||
#elif SOURCE_ENGINE >= SE_ORANGEBOX
|
|
||||||
void CmdMaxplayersCallback(const CCommand &command);
|
void CmdMaxplayersCallback(const CCommand &command);
|
||||||
#else
|
#else
|
||||||
void CmdMaxplayersCallback();
|
void CmdMaxplayersCallback();
|
||||||
|
|||||||
+95
-69
@@ -36,12 +36,12 @@
|
|||||||
#include "ConVarManager.h"
|
#include "ConVarManager.h"
|
||||||
#include "logic_bridge.h"
|
#include "logic_bridge.h"
|
||||||
|
|
||||||
#define TIMER_MIN_ACCURACY 0.1
|
#define TIMER_MIN_ACCURACY 0.1
|
||||||
|
|
||||||
TimerSystem g_Timers;
|
TimerSystem g_Timers;
|
||||||
double g_fUniversalTime = 0.0f;
|
double g_fUniversalTime = 0.0f;
|
||||||
float g_fGameStartTime = 0.0f; /* Game game start time, non-universal */
|
float g_fGameStartTime = 0.0f; /* Game game start time, non-universal */
|
||||||
double g_fTimerThink = 0.0f; /* Timer's next think time */
|
double g_fTimerThink = 0.0f; /* Timer's next think time */
|
||||||
const double *g_pUniversalTime = &g_fUniversalTime;
|
const double *g_pUniversalTime = &g_fUniversalTime;
|
||||||
ConVar *mp_timelimit = NULL;
|
ConVar *mp_timelimit = NULL;
|
||||||
int g_TimeLeftMode = 0;
|
int g_TimeLeftMode = 0;
|
||||||
@@ -69,6 +69,13 @@ class DefaultMapTimer :
|
|||||||
public IConVarChangeListener
|
public IConVarChangeListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
#if SOURCE_ENGINE == SE_BMS
|
||||||
|
static constexpr int kMapTimeScaleFactor = 60;
|
||||||
|
#else
|
||||||
|
static constexpr int kMapTimeScaleFactor = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
DefaultMapTimer()
|
DefaultMapTimer()
|
||||||
{
|
{
|
||||||
m_bInUse = false;
|
m_bInUse = false;
|
||||||
@@ -81,7 +88,7 @@ public:
|
|||||||
|
|
||||||
int GetMapTimeLimit()
|
int GetMapTimeLimit()
|
||||||
{
|
{
|
||||||
return mp_timelimit->GetInt();
|
return (mp_timelimit->GetInt() / kMapTimeScaleFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetMapTimerStatus(bool enabled)
|
void SetMapTimerStatus(bool enabled)
|
||||||
@@ -105,7 +112,7 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
extra_time /= 60;
|
extra_time /= (60 / kMapTimeScaleFactor);
|
||||||
|
|
||||||
mp_timelimit->SetValue(mp_timelimit->GetInt() + extra_time);
|
mp_timelimit->SetValue(mp_timelimit->GetInt() + extra_time);
|
||||||
}
|
}
|
||||||
@@ -139,9 +146,10 @@ private:
|
|||||||
*/
|
*/
|
||||||
inline double CalcNextThink(double last, float interval)
|
inline double CalcNextThink(double last, float interval)
|
||||||
{
|
{
|
||||||
if (g_fUniversalTime - last - interval <= TIMER_MIN_ACCURACY)
|
const double next = last + interval;
|
||||||
|
if (g_fUniversalTime - next <= TIMER_MIN_ACCURACY)
|
||||||
{
|
{
|
||||||
return last + interval;
|
return next;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -149,7 +157,7 @@ inline double CalcNextThink(double last, float interval)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ITimer::Initialize(ITimedEvent *pCallbacks, float fInterval, float fToExec, void *pData, int flags)
|
void ITimer::Initialize(ITimedEvent *pCallbacks, float fInterval, double fToExec, void *pData, int flags)
|
||||||
{
|
{
|
||||||
m_Listener = pCallbacks;
|
m_Listener = pCallbacks;
|
||||||
m_Interval = fInterval;
|
m_Interval = fInterval;
|
||||||
@@ -170,12 +178,11 @@ TimerSystem::TimerSystem()
|
|||||||
|
|
||||||
TimerSystem::~TimerSystem()
|
TimerSystem::~TimerSystem()
|
||||||
{
|
{
|
||||||
CStack<ITimer *>::iterator iter;
|
while (!m_FreeTimers.empty())
|
||||||
for (iter=m_FreeTimers.begin(); iter!=m_FreeTimers.end(); iter++)
|
|
||||||
{
|
{
|
||||||
delete (*iter);
|
delete m_FreeTimers.top();
|
||||||
|
m_FreeTimers.pop();
|
||||||
}
|
}
|
||||||
m_FreeTimers.popall();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerSystem::OnSourceModAllInitialized()
|
void TimerSystem::OnSourceModAllInitialized()
|
||||||
@@ -227,10 +234,11 @@ void TimerSystem::GameFrame(bool simulating)
|
|||||||
m_fLastTickedTime = gpGlobals->curtime;
|
m_fLastTickedTime = gpGlobals->curtime;
|
||||||
m_bHasMapTickedYet = true;
|
m_bHasMapTickedYet = true;
|
||||||
|
|
||||||
if (g_fUniversalTime >= g_fTimerThink)
|
const bool timerThink = g_fUniversalTime >= g_fTimerThink;
|
||||||
{
|
RunFrame(timerThink);
|
||||||
RunFrame();
|
|
||||||
|
|
||||||
|
if (timerThink)
|
||||||
|
{
|
||||||
g_fTimerThink = CalcNextThink(g_fTimerThink, TIMER_MIN_ACCURACY);
|
g_fTimerThink = CalcNextThink(g_fTimerThink, TIMER_MIN_ACCURACY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,31 +250,12 @@ void TimerSystem::GameFrame(bool simulating)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerSystem::RunFrame()
|
void TimerSystem::ProcessRepeatTimers(double curtime, std::list<ITimer*>& timerList)
|
||||||
{
|
{
|
||||||
ITimer *pTimer;
|
ITimer *pTimer;
|
||||||
TimerIter iter;
|
|
||||||
|
|
||||||
double curtime = GetSimulatedTime();
|
ResultType res;
|
||||||
for (iter=m_SingleTimers.begin(); iter!=m_SingleTimers.end(); )
|
for (auto iter=timerList.begin(); iter!=timerList.end(); )
|
||||||
{
|
|
||||||
pTimer = (*iter);
|
|
||||||
if (curtime >= pTimer->m_ToExec)
|
|
||||||
{
|
|
||||||
pTimer->m_InExec = true;
|
|
||||||
pTimer->m_Listener->OnTimer(pTimer, pTimer->m_pData);
|
|
||||||
pTimer->m_Listener->OnTimerEnd(pTimer, pTimer->m_pData);
|
|
||||||
iter = m_SingleTimers.erase(iter);
|
|
||||||
m_FreeTimers.push(pTimer);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ResultType res;
|
|
||||||
for (iter=m_LoopTimers.begin(); iter!=m_LoopTimers.end(); )
|
|
||||||
{
|
{
|
||||||
pTimer = (*iter);
|
pTimer = (*iter);
|
||||||
if (curtime >= pTimer->m_ToExec)
|
if (curtime >= pTimer->m_ToExec)
|
||||||
@@ -276,7 +265,7 @@ void TimerSystem::RunFrame()
|
|||||||
if (pTimer->m_KillMe || (res == Pl_Stop))
|
if (pTimer->m_KillMe || (res == Pl_Stop))
|
||||||
{
|
{
|
||||||
pTimer->m_Listener->OnTimerEnd(pTimer, pTimer->m_pData);
|
pTimer->m_Listener->OnTimerEnd(pTimer, pTimer->m_pData);
|
||||||
iter = m_LoopTimers.erase(iter);
|
iter = timerList.erase(iter);
|
||||||
m_FreeTimers.push(pTimer);
|
m_FreeTimers.push(pTimer);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -287,17 +276,57 @@ void TimerSystem::RunFrame()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TimerSystem::RunFrame(bool timerThink)
|
||||||
|
{
|
||||||
|
const double curtime = GetSimulatedTime();
|
||||||
|
|
||||||
|
//// One-off timers
|
||||||
|
ITimer *pTimer;
|
||||||
|
for (auto iter=m_SingleTimers.begin(); iter!=m_SingleTimers.end(); )
|
||||||
|
{
|
||||||
|
pTimer = (*iter);
|
||||||
|
|
||||||
|
// m_SingleTimers is sorted
|
||||||
|
if (curtime < pTimer->m_ToExec)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timerThink || pTimer->m_Flags & TIMER_FLAG_TICK_PRECISE)
|
||||||
|
{
|
||||||
|
pTimer->m_InExec = true;
|
||||||
|
pTimer->m_Listener->OnTimer(pTimer, pTimer->m_pData);
|
||||||
|
pTimer->m_Listener->OnTimerEnd(pTimer, pTimer->m_pData);
|
||||||
|
iter = m_SingleTimers.erase(iter);
|
||||||
|
m_FreeTimers.push(pTimer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//// Repeating timers
|
||||||
|
// Most repeating timers do not need to be updated every frame
|
||||||
|
if (timerThink)
|
||||||
|
{
|
||||||
|
ProcessRepeatTimers(curtime, m_LowSpeedLoopTimers);
|
||||||
|
}
|
||||||
|
|
||||||
|
// High speed repeating timers will always update
|
||||||
|
ProcessRepeatTimers(curtime, m_HighSpeedLoopTimers);
|
||||||
|
}
|
||||||
|
|
||||||
ITimer *TimerSystem::CreateTimer(ITimedEvent *pCallbacks, float fInterval, void *pData, int flags)
|
ITimer *TimerSystem::CreateTimer(ITimedEvent *pCallbacks, float fInterval, void *pData, int flags)
|
||||||
{
|
{
|
||||||
ITimer *pTimer;
|
ITimer *pTimer;
|
||||||
TimerIter iter;
|
const double to_exec = GetSimulatedTime() + fInterval;
|
||||||
float to_exec = GetSimulatedTime() + fInterval;
|
|
||||||
|
|
||||||
if (m_FreeTimers.empty())
|
if (m_FreeTimers.empty())
|
||||||
{
|
{
|
||||||
pTimer = new ITimer;
|
pTimer = new ITimer;
|
||||||
} else {
|
} else {
|
||||||
pTimer = m_FreeTimers.front();
|
pTimer = m_FreeTimers.top();
|
||||||
m_FreeTimers.pop();
|
m_FreeTimers.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,20 +334,21 @@ ITimer *TimerSystem::CreateTimer(ITimedEvent *pCallbacks, float fInterval, void
|
|||||||
|
|
||||||
if (flags & TIMER_FLAG_REPEAT)
|
if (flags & TIMER_FLAG_REPEAT)
|
||||||
{
|
{
|
||||||
m_LoopTimers.push_back(pTimer);
|
std::list<ITimer*>& timerList = pTimer->m_Flags & TIMER_FLAG_TICK_PRECISE ? m_HighSpeedLoopTimers : m_LowSpeedLoopTimers;
|
||||||
|
timerList.push_back(pTimer);
|
||||||
goto return_timer;
|
goto return_timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_SingleTimers.size() >= 1)
|
if (m_SingleTimers.size() >= 1)
|
||||||
{
|
{
|
||||||
iter = --m_SingleTimers.end();
|
auto iter = --m_SingleTimers.end();
|
||||||
if ((*iter)->m_ToExec <= to_exec)
|
if ((*iter)->m_ToExec <= to_exec)
|
||||||
{
|
{
|
||||||
goto normal_insert_end;
|
goto normal_insert_end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (iter=m_SingleTimers.begin(); iter!=m_SingleTimers.end(); iter++)
|
for (auto iter=m_SingleTimers.begin(); iter!=m_SingleTimers.end(); iter++)
|
||||||
{
|
{
|
||||||
if ((*iter)->m_ToExec >= to_exec)
|
if ((*iter)->m_ToExec >= to_exec)
|
||||||
{
|
{
|
||||||
@@ -363,8 +393,10 @@ void TimerSystem::FireTimerOnce(ITimer *pTimer, bool delayExec)
|
|||||||
pTimer->m_InExec = false;
|
pTimer->m_InExec = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::list<ITimer*>& timerList = pTimer->m_Flags & TIMER_FLAG_TICK_PRECISE ? m_HighSpeedLoopTimers : m_LowSpeedLoopTimers;
|
||||||
pTimer->m_Listener->OnTimerEnd(pTimer, pTimer->m_pData);
|
pTimer->m_Listener->OnTimerEnd(pTimer, pTimer->m_pData);
|
||||||
m_LoopTimers.remove(pTimer);
|
timerList.remove(pTimer);
|
||||||
m_FreeTimers.push(pTimer);
|
m_FreeTimers.push(pTimer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -382,12 +414,13 @@ void TimerSystem::KillTimer(ITimer *pTimer)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTimer->m_InExec = true; /* The timer it's not really executed but this check needs to be done */
|
pTimer->m_InExec = true; /* The timer is not really executed but this check needs to be done */
|
||||||
pTimer->m_Listener->OnTimerEnd(pTimer, pTimer->m_pData);
|
pTimer->m_Listener->OnTimerEnd(pTimer, pTimer->m_pData);
|
||||||
|
|
||||||
if (pTimer->m_Flags & TIMER_FLAG_REPEAT)
|
if (pTimer->m_Flags & TIMER_FLAG_REPEAT)
|
||||||
{
|
{
|
||||||
m_LoopTimers.remove(pTimer);
|
std::list<ITimer*>& timerList = pTimer->m_Flags & TIMER_FLAG_TICK_PRECISE ? m_HighSpeedLoopTimers : m_LowSpeedLoopTimers;
|
||||||
|
timerList.remove(pTimer);
|
||||||
} else {
|
} else {
|
||||||
m_SingleTimers.remove(pTimer);
|
m_SingleTimers.remove(pTimer);
|
||||||
}
|
}
|
||||||
@@ -395,33 +428,27 @@ void TimerSystem::KillTimer(ITimer *pTimer)
|
|||||||
m_FreeTimers.push(pTimer);
|
m_FreeTimers.push(pTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
CStack<ITimer *> s_tokill;
|
std::stack<ITimer *> s_tokill;
|
||||||
void TimerSystem::RemoveMapChangeTimers()
|
void TimerSystem::RemoveMapChangeTimers()
|
||||||
{
|
{
|
||||||
ITimer *pTimer;
|
const auto KillMapchangeTimers = [](std::list<ITimer*>& timerList) {
|
||||||
TimerIter iter;
|
for (ITimer* pTimer : timerList)
|
||||||
|
{
|
||||||
|
if (pTimer->m_Flags & TIMER_FLAG_NO_MAPCHANGE)
|
||||||
|
{
|
||||||
|
s_tokill.push(pTimer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
for (iter=m_SingleTimers.begin(); iter!=m_SingleTimers.end(); iter++)
|
KillMapchangeTimers(m_SingleTimers);
|
||||||
{
|
|
||||||
pTimer = (*iter);
|
|
||||||
if (pTimer->m_Flags & TIMER_FLAG_NO_MAPCHANGE)
|
|
||||||
{
|
|
||||||
s_tokill.push(pTimer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (iter=m_LoopTimers.begin(); iter!=m_LoopTimers.end(); iter++)
|
KillMapchangeTimers(m_LowSpeedLoopTimers);
|
||||||
{
|
KillMapchangeTimers(m_HighSpeedLoopTimers);
|
||||||
pTimer = (*iter);
|
|
||||||
if (pTimer->m_Flags & TIMER_FLAG_NO_MAPCHANGE)
|
|
||||||
{
|
|
||||||
s_tokill.push(pTimer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (!s_tokill.empty())
|
while (!s_tokill.empty())
|
||||||
{
|
{
|
||||||
KillTimer(s_tokill.front());
|
KillTimer(s_tokill.top());
|
||||||
s_tokill.pop();
|
s_tokill.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -484,4 +511,3 @@ bool TimerSystem::GetMapTimeLeft(float *time_left)
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-11
@@ -33,21 +33,17 @@
|
|||||||
#define _INCLUDE_SOURCEMOD_CTIMERSYS_H_
|
#define _INCLUDE_SOURCEMOD_CTIMERSYS_H_
|
||||||
|
|
||||||
#include <ITimerSystem.h>
|
#include <ITimerSystem.h>
|
||||||
#include <sh_stack.h>
|
#include <stack>
|
||||||
#include <sh_list.h>
|
#include <list>
|
||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
|
|
||||||
using namespace SourceHook;
|
|
||||||
using namespace SourceMod;
|
using namespace SourceMod;
|
||||||
|
|
||||||
typedef List<ITimer *> TimerList;
|
|
||||||
typedef List<ITimer *>::iterator TimerIter;
|
|
||||||
|
|
||||||
class SourceMod::ITimer
|
class SourceMod::ITimer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void Initialize(ITimedEvent *pCallbacks, float fInterval, float fToExec, void *pData, int flags);
|
void Initialize(ITimedEvent *pCallbacks, float fInterval, double fToExec, void *pData, int flags);
|
||||||
ITimedEvent *m_Listener;
|
ITimedEvent *m_Listener;
|
||||||
void *m_pData;
|
void *m_pData;
|
||||||
float m_Interval;
|
float m_Interval;
|
||||||
@@ -80,13 +76,16 @@ public: //ITimerSystem
|
|||||||
bool GetMapTimeLeft(float *pTime);
|
bool GetMapTimeLeft(float *pTime);
|
||||||
IMapTimer *GetMapTimer();
|
IMapTimer *GetMapTimer();
|
||||||
public:
|
public:
|
||||||
void RunFrame();
|
void RunFrame(bool timerThink);
|
||||||
void RemoveMapChangeTimers();
|
void RemoveMapChangeTimers();
|
||||||
void GameFrame(bool simulating);
|
void GameFrame(bool simulating);
|
||||||
private:
|
private:
|
||||||
List<ITimer *> m_SingleTimers;
|
void ProcessRepeatTimers(double curtime, std::list<ITimer*>& timerList);
|
||||||
List<ITimer *> m_LoopTimers;
|
private:
|
||||||
CStack<ITimer *> m_FreeTimers;
|
std::list<ITimer*> m_SingleTimers;
|
||||||
|
std::list<ITimer*> m_LowSpeedLoopTimers;
|
||||||
|
std::list<ITimer*> m_HighSpeedLoopTimers;
|
||||||
|
std::stack<ITimer *> m_FreeTimers;
|
||||||
IMapTimer *m_pMapTimer;
|
IMapTimer *m_pMapTimer;
|
||||||
|
|
||||||
/* This is stuff for our manual ticking escapades. */
|
/* This is stuff for our manual ticking escapades. */
|
||||||
|
|||||||
+101
-25
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* vim: set ts=4 :
|
* vim: set ts=4 sw=4 tw=99 noet :
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
* SourceMod
|
* SourceMod
|
||||||
* Copyright (C) 2013 AlliedModders LLC. All rights reserved.
|
* Copyright (C) 2013 AlliedModders LLC. All rights reserved.
|
||||||
@@ -32,8 +32,13 @@
|
|||||||
#ifndef _INCLUDE_SOURCEMOD_SMPBMESSAGE_H_
|
#ifndef _INCLUDE_SOURCEMOD_SMPBMESSAGE_H_
|
||||||
#define _INCLUDE_SOURCEMOD_SMPBMESSAGE_H_
|
#define _INCLUDE_SOURCEMOD_SMPBMESSAGE_H_
|
||||||
|
|
||||||
|
#ifdef GetMessage
|
||||||
|
#undef GetMessage
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <sh_list.h>
|
#include <sh_list.h>
|
||||||
#include <google/protobuf/descriptor.h>
|
#include <google/protobuf/descriptor.h>
|
||||||
|
#include <amtl/am-string.h>
|
||||||
|
|
||||||
#define GETCHECK_FIELD() \
|
#define GETCHECK_FIELD() \
|
||||||
const protobuf::FieldDescriptor *field = msg->GetDescriptor()->FindFieldByName(pszFieldName); \
|
const protobuf::FieldDescriptor *field = msg->GetDescriptor()->FindFieldByName(pszFieldName); \
|
||||||
@@ -84,7 +89,7 @@
|
|||||||
return false; \
|
return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef List<Handle_t> PBHandleList;
|
typedef std::list<Handle_t> PBHandleList;
|
||||||
|
|
||||||
class SMProtobufMessage
|
class SMProtobufMessage
|
||||||
{
|
{
|
||||||
@@ -96,7 +101,7 @@ public:
|
|||||||
|
|
||||||
~SMProtobufMessage()
|
~SMProtobufMessage()
|
||||||
{
|
{
|
||||||
PBHandleList::iterator iter = childHandles.begin();
|
auto iter = childHandles.begin();
|
||||||
while (iter != childHandles.end())
|
while (iter != childHandles.end())
|
||||||
{
|
{
|
||||||
Handle_t &hndl = (*iter);
|
Handle_t &hndl = (*iter);
|
||||||
@@ -117,6 +122,13 @@ public:
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool HasField(const char *pszFieldName)
|
||||||
|
{
|
||||||
|
GETCHECK_FIELD();
|
||||||
|
CHECK_FIELD_NOT_REPEATED();
|
||||||
|
return msg->GetReflection()->HasField(*msg, field);
|
||||||
|
}
|
||||||
|
|
||||||
inline bool GetInt32(const char *pszFieldName, int32 *out)
|
inline bool GetInt32(const char *pszFieldName, int32 *out)
|
||||||
{
|
{
|
||||||
GETCHECK_FIELD();
|
GETCHECK_FIELD();
|
||||||
@@ -340,6 +352,20 @@ public:
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool GetInt64OrUnsigned(const char *pszFieldName, int64 *out)
|
||||||
|
{
|
||||||
|
GETCHECK_FIELD();
|
||||||
|
CHECK_FIELD_TYPE2(INT64, UINT64);
|
||||||
|
CHECK_FIELD_NOT_REPEATED();
|
||||||
|
|
||||||
|
if (fieldType == protobuf::FieldDescriptor::CPPTYPE_UINT64)
|
||||||
|
*out = (int64)msg->GetReflection()->GetUInt64(*msg, field);
|
||||||
|
else
|
||||||
|
*out = msg->GetReflection()->GetInt64(*msg, field);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool SetInt32OrUnsignedOrEnum(const char *pszFieldName, int32 value)
|
inline bool SetInt32OrUnsignedOrEnum(const char *pszFieldName, int32 value)
|
||||||
{
|
{
|
||||||
@@ -366,6 +392,24 @@ public:
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool SetInt64OrUnsigned(const char *pszFieldName, int64 value)
|
||||||
|
{
|
||||||
|
GETCHECK_FIELD();
|
||||||
|
CHECK_FIELD_TYPE2(INT64, UINT64);
|
||||||
|
CHECK_FIELD_NOT_REPEATED();
|
||||||
|
|
||||||
|
if (fieldType == protobuf::FieldDescriptor::CPPTYPE_UINT64)
|
||||||
|
{
|
||||||
|
msg->GetReflection()->SetUInt64(msg, field, (uint64)value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg->GetReflection()->SetInt64(msg, field, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool GetRepeatedInt32OrUnsignedOrEnum(const char *pszFieldName, int index, int32 *out)
|
inline bool GetRepeatedInt32OrUnsignedOrEnum(const char *pszFieldName, int index, int32 *out)
|
||||||
{
|
{
|
||||||
@@ -383,6 +427,21 @@ public:
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool GetRepeatedInt64OrUnsigned(const char *pszFieldName, int index, int64 *out)
|
||||||
|
{
|
||||||
|
GETCHECK_FIELD();
|
||||||
|
CHECK_FIELD_TYPE2(INT64, UINT64);
|
||||||
|
CHECK_FIELD_REPEATED();
|
||||||
|
CHECK_REPEATED_ELEMENT(index);
|
||||||
|
|
||||||
|
if (fieldType == protobuf::FieldDescriptor::CPPTYPE_UINT64)
|
||||||
|
*out = (int64)msg->GetReflection()->GetRepeatedUInt64(*msg, field, index);
|
||||||
|
else
|
||||||
|
*out = msg->GetReflection()->GetRepeatedInt64(*msg, field, index);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool SetRepeatedInt32OrUnsignedOrEnum(const char *pszFieldName, int index, int32 value)
|
inline bool SetRepeatedInt32OrUnsignedOrEnum(const char *pszFieldName, int index, int32 value)
|
||||||
{
|
{
|
||||||
@@ -410,6 +469,25 @@ public:
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool SetRepeatedInt64OrUnsigned(const char *pszFieldName, int index, int64 value)
|
||||||
|
{
|
||||||
|
GETCHECK_FIELD();
|
||||||
|
CHECK_FIELD_TYPE2(INT64, UINT64);
|
||||||
|
CHECK_FIELD_REPEATED();
|
||||||
|
CHECK_REPEATED_ELEMENT(index);
|
||||||
|
|
||||||
|
if (fieldType == protobuf::FieldDescriptor::CPPTYPE_UINT64)
|
||||||
|
{
|
||||||
|
msg->GetReflection()->SetRepeatedUInt64(msg, field, index, (uint64)value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg->GetReflection()->SetRepeatedInt64(msg, field, index, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool AddInt32OrUnsignedOrEnum(const char *pszFieldName, int32 value)
|
inline bool AddInt32OrUnsignedOrEnum(const char *pszFieldName, int32 value)
|
||||||
{
|
{
|
||||||
@@ -436,6 +514,24 @@ public:
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool AddInt64OrUnsigned(const char *pszFieldName, int64 value)
|
||||||
|
{
|
||||||
|
GETCHECK_FIELD();
|
||||||
|
CHECK_FIELD_TYPE2(INT64, UINT64);
|
||||||
|
CHECK_FIELD_REPEATED();
|
||||||
|
|
||||||
|
if (fieldType == protobuf::FieldDescriptor::CPPTYPE_UINT64)
|
||||||
|
{
|
||||||
|
msg->GetReflection()->AddUInt64(msg, field, (uint64)value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg->GetReflection()->AddInt64(msg, field, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool GetBool(const char *pszFieldName, bool *out)
|
inline bool GetBool(const char *pszFieldName, bool *out)
|
||||||
{
|
{
|
||||||
@@ -672,7 +768,7 @@ public:
|
|||||||
CHECK_FIELD_NOT_REPEATED();
|
CHECK_FIELD_NOT_REPEATED();
|
||||||
|
|
||||||
std::string scratch;
|
std::string scratch;
|
||||||
strncopy(out, msg->GetReflection()->GetStringReference(*msg, field, &scratch).c_str(), size);
|
ke::SafeStrcpy(out, size, msg->GetReflection()->GetStringReference(*msg, field, &scratch).c_str());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -695,7 +791,7 @@ public:
|
|||||||
CHECK_REPEATED_ELEMENT(index);
|
CHECK_REPEATED_ELEMENT(index);
|
||||||
|
|
||||||
std::string scratch;
|
std::string scratch;
|
||||||
strncopy(out, msg->GetReflection()->GetRepeatedStringReference(*msg, field, index, &scratch).c_str(), size);
|
ke::SafeStrcpy(out, size, msg->GetReflection()->GetRepeatedStringReference(*msg, field, index, &scratch).c_str());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -724,9 +820,6 @@ public:
|
|||||||
|
|
||||||
inline bool GetColor(const char *pszFieldName, Color *out)
|
inline bool GetColor(const char *pszFieldName, Color *out)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE != SE_CSGO
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
GETCHECK_FIELD();
|
GETCHECK_FIELD();
|
||||||
CHECK_FIELD_TYPE(MESSAGE);
|
CHECK_FIELD_TYPE(MESSAGE);
|
||||||
CHECK_FIELD_NOT_REPEATED();
|
CHECK_FIELD_NOT_REPEATED();
|
||||||
@@ -740,14 +833,10 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool SetColor(const char *pszFieldName, const Color &value)
|
inline bool SetColor(const char *pszFieldName, const Color &value)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE != SE_CSGO
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
GETCHECK_FIELD();
|
GETCHECK_FIELD();
|
||||||
CHECK_FIELD_TYPE(MESSAGE);
|
CHECK_FIELD_TYPE(MESSAGE);
|
||||||
CHECK_FIELD_NOT_REPEATED();
|
CHECK_FIELD_NOT_REPEATED();
|
||||||
@@ -759,14 +848,10 @@ public:
|
|||||||
msgRGBA->set_a(value.a());
|
msgRGBA->set_a(value.a());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool GetRepeatedColor(const char *pszFieldName, int index, Color *out)
|
inline bool GetRepeatedColor(const char *pszFieldName, int index, Color *out)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE != SE_CSGO
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
GETCHECK_FIELD();
|
GETCHECK_FIELD();
|
||||||
CHECK_FIELD_TYPE(MESSAGE);
|
CHECK_FIELD_TYPE(MESSAGE);
|
||||||
CHECK_FIELD_REPEATED();
|
CHECK_FIELD_REPEATED();
|
||||||
@@ -781,14 +866,10 @@ public:
|
|||||||
);
|
);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool SetRepeatedColor(const char *pszFieldName, int index, const Color &value)
|
inline bool SetRepeatedColor(const char *pszFieldName, int index, const Color &value)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE != SE_CSGO
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
GETCHECK_FIELD();
|
GETCHECK_FIELD();
|
||||||
CHECK_FIELD_TYPE(MESSAGE);
|
CHECK_FIELD_TYPE(MESSAGE);
|
||||||
CHECK_FIELD_REPEATED();
|
CHECK_FIELD_REPEATED();
|
||||||
@@ -801,14 +882,10 @@ public:
|
|||||||
msgRGBA->set_a(value.a());
|
msgRGBA->set_a(value.a());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool AddColor(const char *pszFieldName, const Color &value)
|
inline bool AddColor(const char *pszFieldName, const Color &value)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE != SE_CSGO
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
GETCHECK_FIELD();
|
GETCHECK_FIELD();
|
||||||
CHECK_FIELD_TYPE(MESSAGE);
|
CHECK_FIELD_TYPE(MESSAGE);
|
||||||
CHECK_FIELD_REPEATED();
|
CHECK_FIELD_REPEATED();
|
||||||
@@ -820,7 +897,6 @@ public:
|
|||||||
msgRGBA->set_a(value.a());
|
msgRGBA->set_a(value.a());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool GetVector2D(const char *pszFieldName, Vector2D *out)
|
inline bool GetVector2D(const char *pszFieldName, Vector2D *out)
|
||||||
|
|||||||
+75
-51
@@ -33,15 +33,21 @@
|
|||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
#include "logic_bridge.h"
|
#include "logic_bridge.h"
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO
|
||||||
#include <dota_usermessage_helpers.h>
|
|
||||||
#elif SOURCE_ENGINE == SE_CSGO
|
|
||||||
#include <cstrike15_usermessage_helpers.h>
|
#include <cstrike15_usermessage_helpers.h>
|
||||||
|
#elif SOURCE_ENGINE == SE_BLADE
|
||||||
|
#include <berimbau_usermessage_helpers.h>
|
||||||
|
#elif SOURCE_ENGINE == SE_MCV
|
||||||
|
#include <vietnam_usermessage_helpers.h>
|
||||||
|
#elif SOURCE_ENGINE == SE_OUTBREAK
|
||||||
|
#include <base_usermessage_helpers.h>
|
||||||
|
#include <terror_usermessage_helpers.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <amtl/am-string.h>
|
||||||
|
|
||||||
UserMessages g_UserMsgs;
|
UserMessages g_UserMsgs;
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
SH_DECL_HOOK3_void(IVEngineServer, SendUserMessage, SH_NOATTRIB, 0, IRecipientFilter &, int, const protobuf::Message &);
|
SH_DECL_HOOK3_void(IVEngineServer, SendUserMessage, SH_NOATTRIB, 0, IRecipientFilter &, int, const protobuf::Message &);
|
||||||
#else
|
#else
|
||||||
#if SOURCE_ENGINE >= SE_LEFT4DEAD
|
#if SOURCE_ENGINE >= SE_LEFT4DEAD
|
||||||
@@ -50,7 +56,7 @@ SH_DECL_HOOK3(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write *, IRec
|
|||||||
SH_DECL_HOOK2(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write *, IRecipientFilter *, int);
|
SH_DECL_HOOK2(IVEngineServer, UserMessageBegin, SH_NOATTRIB, 0, bf_write *, IRecipientFilter *, int);
|
||||||
#endif
|
#endif
|
||||||
SH_DECL_HOOK0_void(IVEngineServer, MessageEnd, SH_NOATTRIB, 0);
|
SH_DECL_HOOK0_void(IVEngineServer, MessageEnd, SH_NOATTRIB, 0);
|
||||||
#endif // ==SE_CSGO
|
#endif // ==SE_CSGO || ==SE_BLADE || ==SE_MCV || ==SE_OUTBREAK
|
||||||
|
|
||||||
UserMessages::UserMessages()
|
UserMessages::UserMessages()
|
||||||
#ifndef USE_PROTOBUF_USERMESSAGES
|
#ifndef USE_PROTOBUF_USERMESSAGES
|
||||||
@@ -69,12 +75,11 @@ UserMessages::UserMessages()
|
|||||||
|
|
||||||
UserMessages::~UserMessages()
|
UserMessages::~UserMessages()
|
||||||
{
|
{
|
||||||
CStack<ListenerInfo *>::iterator iter;
|
while (!m_FreeListeners.empty())
|
||||||
for (iter=m_FreeListeners.begin(); iter!=m_FreeListeners.end(); iter++)
|
|
||||||
{
|
{
|
||||||
delete (*iter);
|
delete m_FreeListeners.top();
|
||||||
|
m_FreeListeners.pop();
|
||||||
}
|
}
|
||||||
m_FreeListeners.popall();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserMessages::OnSourceModStartup(bool late)
|
void UserMessages::OnSourceModStartup(bool late)
|
||||||
@@ -94,7 +99,7 @@ void UserMessages::OnSourceModAllShutdown()
|
|||||||
{
|
{
|
||||||
if (m_HookCount)
|
if (m_HookCount)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Pre), false);
|
SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Pre), false);
|
||||||
SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Post), true);
|
SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Post), true);
|
||||||
#else
|
#else
|
||||||
@@ -109,12 +114,16 @@ void UserMessages::OnSourceModAllShutdown()
|
|||||||
|
|
||||||
int UserMessages::GetMessageIndex(const char *msg)
|
int UserMessages::GetMessageIndex(const char *msg)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO
|
||||||
// Can split this per engine and/or game later
|
|
||||||
return g_DotaUsermessageHelpers.GetIndex(msg);
|
|
||||||
#elif SOURCE_ENGINE == SE_CSGO
|
|
||||||
// Can split this per engine and/or game later
|
// Can split this per engine and/or game later
|
||||||
return g_Cstrike15UsermessageHelpers.GetIndex(msg);
|
return g_Cstrike15UsermessageHelpers.GetIndex(msg);
|
||||||
|
#elif SOURCE_ENGINE == SE_BLADE
|
||||||
|
return g_BerimbauUsermessageHelpers.GetIndex(msg);
|
||||||
|
#elif SOURCE_ENGINE == SE_MCV
|
||||||
|
return g_VietnamUsermessageHelpers.GetIndex(msg);
|
||||||
|
#elif SOURCE_ENGINE == SE_OUTBREAK
|
||||||
|
int idx = g_TerrorUsermessageHelpers.GetIndex(msg);
|
||||||
|
return idx == -1 ? g_BaseUsermessageHelpers.GetIndex(msg) : idx;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int msgid;
|
int msgid;
|
||||||
@@ -150,15 +159,21 @@ int UserMessages::GetMessageIndex(const char *msg)
|
|||||||
bool UserMessages::GetMessageName(int msgid, char *buffer, size_t maxlength) const
|
bool UserMessages::GetMessageName(int msgid, char *buffer, size_t maxlength) const
|
||||||
{
|
{
|
||||||
#ifdef USE_PROTOBUF_USERMESSAGES
|
#ifdef USE_PROTOBUF_USERMESSAGES
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO
|
||||||
const char *pszName = g_DotaUsermessageHelpers.GetName(msgid);
|
|
||||||
#elif SOURCE_ENGINE == SE_CSGO
|
|
||||||
const char *pszName = g_Cstrike15UsermessageHelpers.GetName(msgid);
|
const char *pszName = g_Cstrike15UsermessageHelpers.GetName(msgid);
|
||||||
|
#elif SOURCE_ENGINE == SE_BLADE
|
||||||
|
const char *pszName = g_BerimbauUsermessageHelpers.GetName(msgid);
|
||||||
|
#elif SOURCE_ENGINE == SE_MCV
|
||||||
|
const char *pszName = g_VietnamUsermessageHelpers.GetName(msgid);
|
||||||
|
#elif SOURCE_ENGINE == SE_OUTBREAK
|
||||||
|
const char *pszName = g_TerrorUsermessageHelpers.GetName(msgid);
|
||||||
|
if (pszName == nullptr)
|
||||||
|
pszName = g_BaseUsermessageHelpers.GetName(msgid);
|
||||||
#endif
|
#endif
|
||||||
if (!pszName)
|
if (!pszName)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
strncopy(buffer, pszName, maxlength);
|
ke::SafeStrcpy(buffer, maxlength, pszName);
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
if (m_FallbackSearch)
|
if (m_FallbackSearch)
|
||||||
@@ -171,7 +186,7 @@ bool UserMessages::GetMessageName(int msgid, char *buffer, size_t maxlength) con
|
|||||||
|
|
||||||
if (msg)
|
if (msg)
|
||||||
{
|
{
|
||||||
strncopy(buffer, msg, maxlength);
|
ke::SafeStrcpy(buffer, maxlength, msg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,7 +318,7 @@ bool UserMessages::EndMessage()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
if (m_CurFlags & USERMSG_BLOCKHOOKS)
|
if (m_CurFlags & USERMSG_BLOCKHOOKS)
|
||||||
{
|
{
|
||||||
ENGINE_CALL(SendUserMessage)(static_cast<IRecipientFilter &>(m_CellRecFilter), m_CurId, *m_FakeEngineBuffer);
|
ENGINE_CALL(SendUserMessage)(static_cast<IRecipientFilter &>(m_CellRecFilter), m_CurId, *m_FakeEngineBuffer);
|
||||||
@@ -333,7 +348,7 @@ bool UserMessages::EndMessage()
|
|||||||
} else {
|
} else {
|
||||||
engine->MessageEnd();
|
engine->MessageEnd();
|
||||||
}
|
}
|
||||||
#endif // SE_CSGO || SE_DOTA
|
#endif // SE_CSGO || SE_BLADE || SE_MCV || SE_OUTBREAK
|
||||||
|
|
||||||
m_InExec = false;
|
m_InExec = false;
|
||||||
m_CurFlags = 0;
|
m_CurFlags = 0;
|
||||||
@@ -407,7 +422,7 @@ bool UserMessages::InternalHook(int msg_id, IBitBufUserMessageListener *pListene
|
|||||||
{
|
{
|
||||||
pInfo = new ListenerInfo;
|
pInfo = new ListenerInfo;
|
||||||
} else {
|
} else {
|
||||||
pInfo = m_FreeListeners.front();
|
pInfo = m_FreeListeners.top();
|
||||||
m_FreeListeners.pop();
|
m_FreeListeners.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,7 +433,7 @@ bool UserMessages::InternalHook(int msg_id, IBitBufUserMessageListener *pListene
|
|||||||
|
|
||||||
if (!m_HookCount++)
|
if (!m_HookCount++)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
SH_ADD_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Pre), false);
|
SH_ADD_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Pre), false);
|
||||||
SH_ADD_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Post), true);
|
SH_ADD_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Post), true);
|
||||||
#else
|
#else
|
||||||
@@ -442,10 +457,17 @@ bool UserMessages::InternalHook(int msg_id, IBitBufUserMessageListener *pListene
|
|||||||
#ifdef USE_PROTOBUF_USERMESSAGES
|
#ifdef USE_PROTOBUF_USERMESSAGES
|
||||||
const protobuf::Message *UserMessages::GetMessagePrototype(int msg_type)
|
const protobuf::Message *UserMessages::GetMessagePrototype(int msg_type)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO
|
||||||
return g_DotaUsermessageHelpers.GetPrototype(msg_type);
|
|
||||||
#elif SOURCE_ENGINE == SE_CSGO
|
|
||||||
return g_Cstrike15UsermessageHelpers.GetPrototype(msg_type);
|
return g_Cstrike15UsermessageHelpers.GetPrototype(msg_type);
|
||||||
|
#elif SOURCE_ENGINE == SE_BLADE
|
||||||
|
return g_BerimbauUsermessageHelpers.GetPrototype(msg_type);
|
||||||
|
#elif SOURCE_ENGINE == SE_MCV
|
||||||
|
return g_VietnamUsermessageHelpers.GetPrototype(msg_type);
|
||||||
|
#elif SOURCE_ENGINE == SE_OUTBREAK
|
||||||
|
auto *msg = g_TerrorUsermessageHelpers.GetPrototype(msg_type);
|
||||||
|
if (msg == nullptr)
|
||||||
|
msg = g_BaseUsermessageHelpers.GetPrototype(msg_type);
|
||||||
|
return msg;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -457,7 +479,6 @@ bool UserMessages::InternalUnhook(int msg_id, IBitBufUserMessageListener *pListe
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
MsgList *pList;
|
MsgList *pList;
|
||||||
MsgIter iter;
|
|
||||||
ListenerInfo *pInfo;
|
ListenerInfo *pInfo;
|
||||||
bool deleted = false;
|
bool deleted = false;
|
||||||
|
|
||||||
@@ -467,7 +488,7 @@ bool UserMessages::InternalUnhook(int msg_id, IBitBufUserMessageListener *pListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
pList = (intercept) ? &m_msgIntercepts[msg_id] : &m_msgHooks[msg_id];
|
pList = (intercept) ? &m_msgIntercepts[msg_id] : &m_msgHooks[msg_id];
|
||||||
for (iter=pList->begin(); iter!=pList->end(); iter++)
|
for (auto iter=pList->begin(); iter!=pList->end(); iter++)
|
||||||
{
|
{
|
||||||
pInfo = (*iter);
|
pInfo = (*iter);
|
||||||
if (pInfo->Callback == pListener && pInfo->IsNew == isNew)
|
if (pInfo->Callback == pListener && pInfo->IsNew == isNew)
|
||||||
@@ -495,7 +516,7 @@ void UserMessages::_DecRefCounter()
|
|||||||
{
|
{
|
||||||
if (--m_HookCount == 0)
|
if (--m_HookCount == 0)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Pre), false);
|
SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Pre), false);
|
||||||
SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Post), true);
|
SH_REMOVE_HOOK(IVEngineServer, SendUserMessage, engine, SH_MEMBER(this, &UserMessages::OnSendUserMessage_Post), true);
|
||||||
#else
|
#else
|
||||||
@@ -507,14 +528,23 @@ void UserMessages::_DecRefCounter()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
void UserMessages::OnSendUserMessage_Pre(IRecipientFilter &filter, int msg_type, const protobuf::Message &msg)
|
void UserMessages::OnSendUserMessage_Pre(IRecipientFilter &filter, int msg_type, const protobuf::Message &msg)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO
|
||||||
OnStartMessage_Pre(&filter, msg_type, g_DotaUsermessageHelpers.GetName(msg_type));
|
const char *pszName = g_Cstrike15UsermessageHelpers.GetName(msg_type);
|
||||||
#elif SOURCE_ENGINE == SE_CSGO
|
#elif SOURCE_ENGINE == SE_BLADE
|
||||||
OnStartMessage_Pre(&filter, msg_type, g_Cstrike15UsermessageHelpers.GetName(msg_type));
|
const char *pszName = g_BerimbauUsermessageHelpers.GetName(msg_type);
|
||||||
|
#elif SOURCE_ENGINE == SE_MCV
|
||||||
|
const char *pszName = g_VietnamUsermessageHelpers.GetName(msg_type);
|
||||||
|
#elif SOURCE_ENGINE == SE_OUTBREAK
|
||||||
|
const char *pszName = g_TerrorUsermessageHelpers.GetName(msg_type);
|
||||||
|
if (pszName == nullptr)
|
||||||
|
pszName = g_BaseUsermessageHelpers.GetName(msg_type);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
OnStartMessage_Pre(&filter, msg_type, pszName);
|
||||||
|
|
||||||
if (m_FakeMetaRes == MRES_SUPERCEDE)
|
if (m_FakeMetaRes == MRES_SUPERCEDE)
|
||||||
{
|
{
|
||||||
int size = msg.ByteSize();
|
int size = msg.ByteSize();
|
||||||
@@ -527,11 +557,7 @@ void UserMessages::OnSendUserMessage_Pre(IRecipientFilter &filter, int msg_type,
|
|||||||
m_FakeEngineBuffer = &const_cast<protobuf::Message &>(msg);
|
m_FakeEngineBuffer = &const_cast<protobuf::Message &>(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_DOTA
|
OnStartMessage_Post(&filter, msg_type, pszName);
|
||||||
OnStartMessage_Post(&filter, msg_type, g_DotaUsermessageHelpers.GetName(msg_type));
|
|
||||||
#elif SOURCE_ENGINE == SE_CSGO
|
|
||||||
OnStartMessage_Post(&filter, msg_type, g_Cstrike15UsermessageHelpers.GetName(msg_type));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
OnMessageEnd_Pre();
|
OnMessageEnd_Pre();
|
||||||
if (m_FakeMetaRes == MRES_SUPERCEDE)
|
if (m_FakeMetaRes == MRES_SUPERCEDE)
|
||||||
@@ -563,7 +589,7 @@ void UserMessages::OnSendUserMessage_Post(IRecipientFilter &filter, int msg_type
|
|||||||
RETURN_META(res)
|
RETURN_META(res)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
protobuf::Message *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name)
|
protobuf::Message *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name)
|
||||||
#elif SOURCE_ENGINE >= SE_LEFT4DEAD
|
#elif SOURCE_ENGINE >= SE_LEFT4DEAD
|
||||||
bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name)
|
bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name)
|
||||||
@@ -603,7 +629,7 @@ bf_write *UserMessages::OnStartMessage_Pre(IRecipientFilter *filter, int msg_typ
|
|||||||
UM_RETURN_META_VALUE(MRES_IGNORED, NULL);
|
UM_RETURN_META_VALUE(MRES_IGNORED, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
protobuf::Message *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name)
|
protobuf::Message *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name)
|
||||||
#elif SOURCE_ENGINE >= SE_LEFT4DEAD
|
#elif SOURCE_ENGINE >= SE_LEFT4DEAD
|
||||||
bf_write *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name)
|
bf_write *UserMessages::OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name)
|
||||||
@@ -636,13 +662,12 @@ void UserMessages::OnMessageEnd_Post()
|
|||||||
}
|
}
|
||||||
|
|
||||||
MsgList *pList;
|
MsgList *pList;
|
||||||
MsgIter iter;
|
|
||||||
ListenerInfo *pInfo;
|
ListenerInfo *pInfo;
|
||||||
|
|
||||||
m_InHook = false;
|
m_InHook = false;
|
||||||
|
|
||||||
pList = &m_msgIntercepts[m_CurId];
|
pList = &m_msgIntercepts[m_CurId];
|
||||||
for (iter=pList->begin(); iter!=pList->end(); )
|
for (auto iter=pList->begin(); iter!=pList->end(); )
|
||||||
{
|
{
|
||||||
pInfo = (*iter);
|
pInfo = (*iter);
|
||||||
if (m_BlockEndPost && !pInfo->IsNew)
|
if (m_BlockEndPost && !pInfo->IsNew)
|
||||||
@@ -669,7 +694,7 @@ void UserMessages::OnMessageEnd_Post()
|
|||||||
}
|
}
|
||||||
|
|
||||||
pList = &m_msgHooks[m_CurId];
|
pList = &m_msgHooks[m_CurId];
|
||||||
for (iter=pList->begin(); iter!=pList->end(); )
|
for (auto iter=pList->begin(); iter!=pList->end(); )
|
||||||
{
|
{
|
||||||
pInfo = (*iter);
|
pInfo = (*iter);
|
||||||
if (m_BlockEndPost && !pInfo->IsNew)
|
if (m_BlockEndPost && !pInfo->IsNew)
|
||||||
@@ -704,7 +729,6 @@ void UserMessages::OnMessageEnd_Pre()
|
|||||||
}
|
}
|
||||||
|
|
||||||
MsgList *pList;
|
MsgList *pList;
|
||||||
MsgIter iter;
|
|
||||||
ListenerInfo *pInfo;
|
ListenerInfo *pInfo;
|
||||||
|
|
||||||
ResultType res;
|
ResultType res;
|
||||||
@@ -712,7 +736,7 @@ void UserMessages::OnMessageEnd_Pre()
|
|||||||
bool handled = false;
|
bool handled = false;
|
||||||
|
|
||||||
pList = &m_msgIntercepts[m_CurId];
|
pList = &m_msgIntercepts[m_CurId];
|
||||||
for (iter=pList->begin(); iter!=pList->end(); )
|
for (auto iter=pList->begin(); iter!=pList->end(); )
|
||||||
{
|
{
|
||||||
pInfo = (*iter);
|
pInfo = (*iter);
|
||||||
pInfo->IsHooked = true;
|
pInfo->IsHooked = true;
|
||||||
@@ -768,7 +792,7 @@ void UserMessages::OnMessageEnd_Pre()
|
|||||||
|
|
||||||
if (!handled && intercepted)
|
if (!handled && intercepted)
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
ENGINE_CALL(SendUserMessage)(static_cast<IRecipientFilter &>(*m_CurRecFilter), m_CurId, *m_InterceptBuffer);
|
ENGINE_CALL(SendUserMessage)(static_cast<IRecipientFilter &>(*m_CurRecFilter), m_CurId, *m_InterceptBuffer);
|
||||||
#else
|
#else
|
||||||
bf_write *engine_bfw;
|
bf_write *engine_bfw;
|
||||||
@@ -780,11 +804,11 @@ void UserMessages::OnMessageEnd_Pre()
|
|||||||
m_ReadBuffer.StartReading(m_InterceptBuffer.GetBasePointer(), m_InterceptBuffer.GetNumBytesWritten());
|
m_ReadBuffer.StartReading(m_InterceptBuffer.GetBasePointer(), m_InterceptBuffer.GetNumBytesWritten());
|
||||||
engine_bfw->WriteBitsFromBuffer(&m_ReadBuffer, m_InterceptBuffer.GetNumBitsWritten());
|
engine_bfw->WriteBitsFromBuffer(&m_ReadBuffer, m_InterceptBuffer.GetNumBitsWritten());
|
||||||
ENGINE_CALL(MessageEnd)();
|
ENGINE_CALL(MessageEnd)();
|
||||||
#endif // SE_CSGO || SE_DOTA
|
#endif // SE_CSGO || SE_BLADE || SE_MCV || SE_OUTBREAK
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
int size = m_OrigBuffer->ByteSize();
|
int size = m_OrigBuffer->ByteSize();
|
||||||
uint8 *data = (uint8 *)stackalloc(size);
|
uint8 *data = (uint8 *)stackalloc(size);
|
||||||
m_OrigBuffer->SerializePartialToArray(data, size);
|
m_OrigBuffer->SerializePartialToArray(data, size);
|
||||||
@@ -796,7 +820,7 @@ void UserMessages::OnMessageEnd_Pre()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
pList = &m_msgHooks[m_CurId];
|
pList = &m_msgHooks[m_CurId];
|
||||||
for (iter=pList->begin(); iter!=pList->end(); )
|
for (auto iter=pList->begin(); iter!=pList->end(); )
|
||||||
{
|
{
|
||||||
pInfo = (*iter);
|
pInfo = (*iter);
|
||||||
pInfo->IsHooked = true;
|
pInfo->IsHooked = true;
|
||||||
@@ -814,7 +838,7 @@ void UserMessages::OnMessageEnd_Pre()
|
|||||||
iter++;
|
iter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
delete pTempMsg;
|
delete pTempMsg;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-12
@@ -34,21 +34,23 @@
|
|||||||
|
|
||||||
#include <IUserMessages.h>
|
#include <IUserMessages.h>
|
||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
#include <sm_stringhashmap.h>
|
#include <sm_hashmap.h>
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
#include "CellRecipientFilter.h"
|
#include "CellRecipientFilter.h"
|
||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
#include <sh_list.h>
|
#include <list>
|
||||||
#include <sh_stack.h>
|
#include <stack>
|
||||||
|
|
||||||
using namespace SourceHook;
|
|
||||||
using namespace SourceMod;
|
using namespace SourceMod;
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
#define USE_PROTOBUF_USERMESSAGES
|
#define USE_PROTOBUF_USERMESSAGES
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_PROTOBUF_USERMESSAGES
|
#ifdef USE_PROTOBUF_USERMESSAGES
|
||||||
|
#ifdef GetMessage
|
||||||
|
#undef GetMessage
|
||||||
|
#endif
|
||||||
#include <google/protobuf/message.h>
|
#include <google/protobuf/message.h>
|
||||||
#include <google/protobuf/descriptor.h>
|
#include <google/protobuf/descriptor.h>
|
||||||
#include <netmessages.pb.h>
|
#include <netmessages.pb.h>
|
||||||
@@ -72,8 +74,7 @@ struct ListenerInfo
|
|||||||
bool IsNew;
|
bool IsNew;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef List<ListenerInfo *> MsgList;
|
typedef std::list<ListenerInfo *> MsgList;
|
||||||
typedef List<ListenerInfo *>::iterator MsgIter;
|
|
||||||
|
|
||||||
class UserMessages :
|
class UserMessages :
|
||||||
public IUserMessages,
|
public IUserMessages,
|
||||||
@@ -102,12 +103,12 @@ public: //IUserMessages
|
|||||||
bool intercept=false);
|
bool intercept=false);
|
||||||
UserMessageType GetUserMessageType() const;
|
UserMessageType GetUserMessageType() const;
|
||||||
public:
|
public:
|
||||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
void OnSendUserMessage_Pre(IRecipientFilter &filter, int msg_type, const protobuf::Message &msg);
|
void OnSendUserMessage_Pre(IRecipientFilter &filter, int msg_type, const protobuf::Message &msg);
|
||||||
void OnSendUserMessage_Post(IRecipientFilter &filter, int msg_type, const protobuf::Message &msg);
|
void OnSendUserMessage_Post(IRecipientFilter &filter, int msg_type, const protobuf::Message &msg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_DOTA
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
protobuf::Message *OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name);
|
protobuf::Message *OnStartMessage_Pre(IRecipientFilter *filter, int msg_type, const char *msg_name);
|
||||||
protobuf::Message *OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name);
|
protobuf::Message *OnStartMessage_Post(IRecipientFilter *filter, int msg_type, const char *msg_name);
|
||||||
#elif SOURCE_ENGINE >= SE_LEFT4DEAD
|
#elif SOURCE_ENGINE >= SE_LEFT4DEAD
|
||||||
@@ -130,9 +131,9 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
void _DecRefCounter();
|
void _DecRefCounter();
|
||||||
private:
|
private:
|
||||||
List<ListenerInfo *> m_msgHooks[255];
|
std::list<ListenerInfo *> m_msgHooks[255];
|
||||||
List<ListenerInfo *> m_msgIntercepts[255];
|
std::list<ListenerInfo *> m_msgIntercepts[255];
|
||||||
CStack<ListenerInfo *> m_FreeListeners;
|
std::stack<ListenerInfo *> m_FreeListeners;
|
||||||
IRecipientFilter *m_CurRecFilter;
|
IRecipientFilter *m_CurRecFilter;
|
||||||
#ifndef USE_PROTOBUF_USERMESSAGES
|
#ifndef USE_PROTOBUF_USERMESSAGES
|
||||||
unsigned char m_pBase[2500];
|
unsigned char m_pBase[2500];
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
// vim: set ts=4 sw=4 tw=99 noet :
|
||||||
|
// =============================================================================
|
||||||
|
// SourceMod
|
||||||
|
// Copyright (C) 2004-2015 AlliedModders LLC. All rights reserved.
|
||||||
|
// =============================================================================
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify it under
|
||||||
|
// the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
// Free Software Foundation.
|
||||||
|
//
|
||||||
|
// 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
//
|
||||||
|
// As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
// code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
// by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
// all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
// this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
// or <http://www.sourcemod.net/license.php>.
|
||||||
|
#ifndef _INCLUDE_SOURCEMOD_CCOMMANDARGS_IMPL_H_
|
||||||
|
#define _INCLUDE_SOURCEMOD_CCOMMANDARGS_IMPL_H_
|
||||||
|
|
||||||
|
#include "sourcemm_api.h"
|
||||||
|
#include <IRootConsoleMenu.h>
|
||||||
|
#include <compat_wrappers.h>
|
||||||
|
|
||||||
|
#if SOURCE_ENGINE==SE_EPISODEONE || SOURCE_ENGINE==SE_DARKMESSIAH
|
||||||
|
class EngineArgs : public ICommandArgs
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
EngineArgs(const CCommand& _cmd)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
const char *Arg(int n) const
|
||||||
|
{
|
||||||
|
return engine->Cmd_Argv(n);
|
||||||
|
}
|
||||||
|
int ArgC() const
|
||||||
|
{
|
||||||
|
return engine->Cmd_Argc();
|
||||||
|
}
|
||||||
|
const char *ArgS() const
|
||||||
|
{
|
||||||
|
return engine->Cmd_Args();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#else
|
||||||
|
class EngineArgs : public ICommandArgs
|
||||||
|
{
|
||||||
|
const CCommand *cmd;
|
||||||
|
public:
|
||||||
|
EngineArgs(const CCommand& _cmd) : cmd(&_cmd)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
const char *Arg(int n) const
|
||||||
|
{
|
||||||
|
return cmd->Arg(n);
|
||||||
|
}
|
||||||
|
int ArgC() const
|
||||||
|
{
|
||||||
|
return cmd->ArgC();
|
||||||
|
}
|
||||||
|
const char *ArgS() const
|
||||||
|
{
|
||||||
|
return cmd->ArgS();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // _INCLUDE_SOURCEMOD_CCOMMANDARGS_IMPL_H_
|
||||||
+52
-71
@@ -1,51 +1,50 @@
|
|||||||
/**
|
// vim: set ts=4 sw=4 tw=99 et:
|
||||||
* vim: set ts=4 :
|
// =============================================================================
|
||||||
* =============================================================================
|
// SourceMod
|
||||||
* SourceMod
|
// Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||||
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
// =============================================================================
|
||||||
* =============================================================================
|
//
|
||||||
*
|
// This program is free software; you can redistribute it and/or modify it under
|
||||||
* This program is free software; you can redistribute it and/or modify it under
|
// the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
// Free Software Foundation.
|
||||||
* Free Software Foundation.
|
//
|
||||||
*
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* 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
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
// details.
|
||||||
* details.
|
//
|
||||||
*
|
// You should have received a copy of the GNU General Public License along with
|
||||||
* You should have received a copy of the GNU General Public License along with
|
// this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
//
|
||||||
*
|
// As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
* As a special exception, AlliedModders LLC gives you permission to link the
|
// code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
// "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
// by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
* by the Valve Corporation. You must obey the GNU General Public License in
|
// all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
// this exception to all derivative works. AlliedModders LLC defines further
|
||||||
* this exception to all derivative works. AlliedModders LLC defines further
|
// exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
// or <http://www.sourcemod.net/license.php>.
|
||||||
* or <http://www.sourcemod.net/license.php>.
|
|
||||||
*
|
|
||||||
* Version: $Id$
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "sm_globals.h"
|
#include "sm_globals.h"
|
||||||
#include <sh_list.h>
|
#include <list>
|
||||||
#include <convar.h>
|
#include <convar.h>
|
||||||
#include "concmd_cleaner.h"
|
#include "concmd_cleaner.h"
|
||||||
#include "sm_stringutil.h"
|
#include "sm_stringutil.h"
|
||||||
#include "sourcemm_api.h"
|
#include "sourcemm_api.h"
|
||||||
#include "compat_wrappers.h"
|
#include "compat_wrappers.h"
|
||||||
|
#include <amtl/am-string.h>
|
||||||
|
|
||||||
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
#if SOURCE_ENGINE >= SE_ORANGEBOX
|
||||||
SH_DECL_HOOK1_void(ICvar, UnregisterConCommand, SH_NOATTRIB, 0, ConCommandBase *);
|
SH_DECL_HOOK1_void(ICvar, UnregisterConCommand, SH_NOATTRIB, 0, ConCommandBase *);
|
||||||
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
|
SH_DECL_HOOK2_void(ICvar, RegisterConCommand, SH_NOATTRIB, 0, ConCommandBase *, bool);
|
||||||
|
#else
|
||||||
SH_DECL_HOOK1_void(ICvar, RegisterConCommand, SH_NOATTRIB, 0, ConCommandBase *);
|
SH_DECL_HOOK1_void(ICvar, RegisterConCommand, SH_NOATTRIB, 0, ConCommandBase *);
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
SH_DECL_HOOK1_void(ICvar, RegisterConCommandBase, SH_NOATTRIB, 0, ConCommandBase *);
|
SH_DECL_HOOK1_void(ICvar, RegisterConCommandBase, SH_NOATTRIB, 0, ConCommandBase *);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace SourceHook;
|
|
||||||
|
|
||||||
struct ConCommandInfo
|
struct ConCommandInfo
|
||||||
{
|
{
|
||||||
ConCommandBase *pBase;
|
ConCommandBase *pBase;
|
||||||
@@ -53,7 +52,7 @@ struct ConCommandInfo
|
|||||||
char name[64];
|
char name[64];
|
||||||
};
|
};
|
||||||
|
|
||||||
List<ConCommandInfo *> tracked_bases;
|
std::list<ConCommandInfo *> tracked_bases;
|
||||||
IConCommandLinkListener *IConCommandLinkListener::head = NULL;
|
IConCommandLinkListener *IConCommandLinkListener::head = NULL;
|
||||||
|
|
||||||
ConCommandBase *FindConCommandBase(const char *name);
|
ConCommandBase *FindConCommandBase(const char *name);
|
||||||
@@ -81,7 +80,11 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV || SOURCE_ENGINE == SE_OUTBREAK
|
||||||
|
void LinkConCommandBase(ConCommandBase *pBase, bool unknown)
|
||||||
|
#else
|
||||||
void LinkConCommandBase(ConCommandBase *pBase)
|
void LinkConCommandBase(ConCommandBase *pBase)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
IConCommandLinkListener *listener = IConCommandLinkListener::head;
|
IConCommandLinkListener *listener = IConCommandLinkListener::head;
|
||||||
while (listener)
|
while (listener)
|
||||||
@@ -94,7 +97,7 @@ public:
|
|||||||
void UnlinkConCommandBase(ConCommandBase *pBase)
|
void UnlinkConCommandBase(ConCommandBase *pBase)
|
||||||
{
|
{
|
||||||
ConCommandInfo *pInfo;
|
ConCommandInfo *pInfo;
|
||||||
List<ConCommandInfo *>::iterator iter = tracked_bases.begin();
|
auto iter = tracked_bases.begin();
|
||||||
|
|
||||||
IConCommandLinkListener *listener = IConCommandLinkListener::head;
|
IConCommandLinkListener *listener = IConCommandLinkListener::head;
|
||||||
while (listener)
|
while (listener)
|
||||||
@@ -103,40 +106,19 @@ public:
|
|||||||
listener = listener->next;
|
listener = listener->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pBase)
|
while (iter != tracked_bases.end())
|
||||||
{
|
{
|
||||||
while (iter != tracked_bases.end())
|
if ((*iter)->pBase == pBase)
|
||||||
{
|
{
|
||||||
if ((*iter)->pBase == pBase)
|
pInfo = (*iter);
|
||||||
{
|
iter = tracked_bases.erase(iter);
|
||||||
pInfo = (*iter);
|
pInfo->cls->OnUnlinkConCommandBase(pBase, pBase->GetName());
|
||||||
iter = tracked_bases.erase(iter);
|
delete pInfo;
|
||||||
pInfo->cls->OnUnlinkConCommandBase(pBase, pBase->GetName(), true);
|
}
|
||||||
delete pInfo;
|
else
|
||||||
}
|
{
|
||||||
else
|
iter++;
|
||||||
{
|
}
|
||||||
iter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while (iter != tracked_bases.end())
|
|
||||||
{
|
|
||||||
/* This is just god-awful! */
|
|
||||||
if (FindCommandBase((*iter)->name) != (*iter)->pBase)
|
|
||||||
{
|
|
||||||
pInfo = (*iter);
|
|
||||||
iter = tracked_bases.erase(iter);
|
|
||||||
pInfo->cls->OnUnlinkConCommandBase(pBase, pInfo->name, false);
|
|
||||||
delete pInfo;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,17 +128,16 @@ public:
|
|||||||
|
|
||||||
info->pBase = pBase;
|
info->pBase = pBase;
|
||||||
info->cls = cls;
|
info->cls = cls;
|
||||||
strncopy(info->name, pBase->GetName(), sizeof(info->name));
|
ke::SafeStrcpy(info->name, sizeof(info->name), pBase->GetName());
|
||||||
|
|
||||||
tracked_bases.push_back(info);
|
tracked_bases.push_back(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoveTarget(ConCommandBase *pBase, IConCommandTracker *cls)
|
void RemoveTarget(ConCommandBase *pBase, IConCommandTracker *cls)
|
||||||
{
|
{
|
||||||
List<ConCommandInfo *>::iterator iter;
|
|
||||||
ConCommandInfo *pInfo;
|
ConCommandInfo *pInfo;
|
||||||
|
|
||||||
iter = tracked_bases.begin();
|
auto iter = tracked_bases.begin();
|
||||||
while (iter != tracked_bases.end())
|
while (iter != tracked_bases.end())
|
||||||
{
|
{
|
||||||
pInfo = (*iter);
|
pInfo = (*iter);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
class IConCommandTracker
|
class IConCommandTracker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name, bool is_read_safe) = 0;
|
virtual void OnUnlinkConCommandBase(ConCommandBase *pBase, const char *name) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void TrackConCommandBase(ConCommandBase *pBase, IConCommandTracker *me);
|
void TrackConCommandBase(ConCommandBase *pBase, IConCommandTracker *me);
|
||||||
|
|||||||
@@ -1,551 +0,0 @@
|
|||||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $Workfile: $
|
|
||||||
// $Date: 2006-08-13 06:34:30 -0500 (Sun, 13 Aug 2006) $
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// $NoKeywords: $
|
|
||||||
//=============================================================================//
|
|
||||||
|
|
||||||
#ifndef CONVAR_H
|
|
||||||
#define CONVAR_H
|
|
||||||
#if _WIN32
|
|
||||||
#pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "tier0/dbg.h"
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define FORCEINLINE_CVAR FORCEINLINE
|
|
||||||
#elif _LINUX
|
|
||||||
#define FORCEINLINE_CVAR __inline__ FORCEINLINE
|
|
||||||
#else
|
|
||||||
#error "implement me"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// The default, no flags at all
|
|
||||||
#define FCVAR_NONE 0
|
|
||||||
|
|
||||||
// Command to ConVars and ConCommands
|
|
||||||
// ConVar Systems
|
|
||||||
#define FCVAR_UNREGISTERED (1<<0) // If this is set, don't add to linked list, etc.
|
|
||||||
#define FCVAR_LAUNCHER (1<<1) // defined by launcher
|
|
||||||
#define FCVAR_GAMEDLL (1<<2) // defined by the game DLL
|
|
||||||
#define FCVAR_CLIENTDLL (1<<3) // defined by the client DLL
|
|
||||||
#define FCVAR_MATERIAL_SYSTEM (1<<4) // Defined by the material system.
|
|
||||||
#define FCVAR_DATACACHE (1<<19) // Defined by the datacache system.
|
|
||||||
#define FCVAR_STUDIORENDER (1<<15) // Defined by the studiorender system.
|
|
||||||
#define FCVAR_FILESYSTEM (1<<21) // Defined by the file system.
|
|
||||||
#define FCVAR_PLUGIN (1<<18) // Defined by a 3rd party plugin.
|
|
||||||
#define FCVAR_TOOLSYSTEM (1<<20) // Defined by an IToolSystem library
|
|
||||||
#define FCVAR_SOUNDSYSTEM (1<<23) // Defined by the soundsystem library
|
|
||||||
#define FCVAR_INPUTSYSTEM (1<<25) // Defined by the inputsystem dll
|
|
||||||
#define FCVAR_NETWORKSYSTEM (1<<26) // Defined by the network system
|
|
||||||
// NOTE!! if you add a cvar system, add it here too!!!!
|
|
||||||
// the engine lacks a cvar flag, but needs it for xbox
|
|
||||||
// an engine cvar is thus a cvar not marked with any other system
|
|
||||||
#define FCVAR_NON_ENGINE ((FCVAR_LAUNCHER|FCVAR_GAMEDLL|FCVAR_CLIENTDLL|FCVAR_MATERIAL_SYSTEM|FCVAR_DATACACHE|FCVAR_STUDIORENDER|FCVAR_FILESYSTEM|FCVAR_PLUGIN|FCVAR_TOOLSYSTEM|FCVAR_SOUNDSYSTEM|FCVAR_INPUTSYSTEM|FCVAR_NETWORKSYSTEM))
|
|
||||||
|
|
||||||
// ConVar only
|
|
||||||
#define FCVAR_PROTECTED (1<<5) // It's a server cvar, but we don't send the data since it's a password, etc. Sends 1 if it's not bland/zero, 0 otherwise as value
|
|
||||||
#define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server.
|
|
||||||
#define FCVAR_ARCHIVE (1<<7) // set to cause it to be saved to vars.rc
|
|
||||||
#define FCVAR_NOTIFY (1<<8) // notifies players when changed
|
|
||||||
#define FCVAR_USERINFO (1<<9) // changes the client's info string
|
|
||||||
#define FCVAR_CHEAT (1<<14) // Only useable in singleplayer / debug / multiplayer & sv_cheats
|
|
||||||
|
|
||||||
#define FCVAR_PRINTABLEONLY (1<<10) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ).
|
|
||||||
#define FCVAR_UNLOGGED (1<<11) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log
|
|
||||||
#define FCVAR_NEVER_AS_STRING (1<<12) // never try to print that cvar
|
|
||||||
|
|
||||||
// It's a ConVar that's shared between the client and the server.
|
|
||||||
// At signon, the values of all such ConVars are sent from the server to the client (skipped for local
|
|
||||||
// client, of course )
|
|
||||||
// If a change is requested it must come from the console (i.e., no remote client changes)
|
|
||||||
// If a value is changed while a server is active, it's replicated to all connected clients
|
|
||||||
#define FCVAR_REPLICATED (1<<13) // server setting enforced on clients, TODO rename to FCAR_SERVER at some time
|
|
||||||
#define FCVAR_DEMO (1<<16) // record this cvar when starting a demo file
|
|
||||||
#define FCVAR_DONTRECORD (1<<17) // don't record these command in demofiles
|
|
||||||
|
|
||||||
#define FCVAR_NOT_CONNECTED (1<<22) // cvar cannot be changed by a client that is connected to a server
|
|
||||||
|
|
||||||
#define FCVAR_ARCHIVE_XBOX (1<<24) // cvar written to config.cfg on the Xbox
|
|
||||||
|
|
||||||
|
|
||||||
// #define FCVAR_AVAILABLE (1<<27)
|
|
||||||
// #define FCVAR_AVAILABLE (1<<28)
|
|
||||||
// #define FCVAR_AVAILABLE (1<<29)
|
|
||||||
// #define FCVAR_AVAILABLE (1<<30)
|
|
||||||
// #define FCVAR_AVAILABLE (1<<31)
|
|
||||||
|
|
||||||
|
|
||||||
class ConVar;
|
|
||||||
class ConCommand;
|
|
||||||
class ConCommandBase;
|
|
||||||
|
|
||||||
// Any executable that wants to use ConVars need to implement one of
|
|
||||||
// these to hook up access to console variables.
|
|
||||||
class IConCommandBaseAccessor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Flags is a combination of FCVAR flags in cvar.h.
|
|
||||||
// hOut is filled in with a handle to the variable.
|
|
||||||
virtual bool RegisterConCommandBase( ConCommandBase *pVar )=0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// You don't have to instantiate one of these, just call its
|
|
||||||
// OneTimeInit function when your executable is initializing.
|
|
||||||
class ConCommandBaseMgr
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Call this ONCE when the executable starts up.
|
|
||||||
static void OneTimeInit( IConCommandBaseAccessor *pAccessor );
|
|
||||||
#ifdef _XBOX
|
|
||||||
static bool Fixup( ConCommandBase* pConCommandBase );
|
|
||||||
#ifndef _RETAIL
|
|
||||||
static void PublishCommands( bool bForce );
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
// Called when a ConVar changes value
|
|
||||||
typedef void ( *FnChangeCallback )( ConVar *var, char const *pOldString );
|
|
||||||
|
|
||||||
// Called when a ConCommand needs to execute
|
|
||||||
typedef void ( *FnCommandCallback )( void );
|
|
||||||
|
|
||||||
#define COMMAND_COMPLETION_MAXITEMS 64
|
|
||||||
#define COMMAND_COMPLETION_ITEM_LENGTH 64
|
|
||||||
|
|
||||||
// Returns 0 to COMMAND_COMPLETION_MAXITEMS worth of completion strings
|
|
||||||
typedef int ( *FnCommandCompletionCallback )( char const *partial, char commands[ COMMAND_COMPLETION_MAXITEMS ][ COMMAND_COMPLETION_ITEM_LENGTH ] );
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: The base console invoked command/cvar interface
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class ConCommandBase
|
|
||||||
{
|
|
||||||
friend class ConCommandBaseMgr;
|
|
||||||
friend class CCvar;
|
|
||||||
friend class ConVar;
|
|
||||||
friend class ConCommand;
|
|
||||||
|
|
||||||
public:
|
|
||||||
ConCommandBase( void );
|
|
||||||
ConCommandBase( char const *pName, char const *pHelpString = 0,
|
|
||||||
int flags = 0 );
|
|
||||||
|
|
||||||
virtual ~ConCommandBase( void );
|
|
||||||
|
|
||||||
virtual bool IsCommand( void ) const;
|
|
||||||
|
|
||||||
// Check flag
|
|
||||||
virtual bool IsBitSet( int flag ) const;
|
|
||||||
// Set flag
|
|
||||||
virtual void AddFlags( int flags );
|
|
||||||
|
|
||||||
// Return name of cvar
|
|
||||||
virtual char const *GetName( void ) const;
|
|
||||||
|
|
||||||
// Return help text for cvar
|
|
||||||
virtual char const *GetHelpText( void ) const;
|
|
||||||
|
|
||||||
// Deal with next pointer
|
|
||||||
const ConCommandBase *GetNext( void ) const;
|
|
||||||
void SetNext( ConCommandBase *next );
|
|
||||||
|
|
||||||
virtual bool IsRegistered( void ) const;
|
|
||||||
|
|
||||||
// Global methods
|
|
||||||
static ConCommandBase const *GetCommands( void );
|
|
||||||
static void AddToList( ConCommandBase *var );
|
|
||||||
static void RemoveFlaggedCommands( int flag );
|
|
||||||
static void RevertFlaggedCvars( int flag );
|
|
||||||
static ConCommandBase const *FindCommand( char const *name );
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void Create( char const *pName, char const *pHelpString = 0,
|
|
||||||
int flags = 0 );
|
|
||||||
|
|
||||||
// Used internally by OneTimeInit to initialize.
|
|
||||||
virtual void Init();
|
|
||||||
|
|
||||||
// Internal copy routine ( uses new operator from correct module )
|
|
||||||
char *CopyString( char const *from );
|
|
||||||
|
|
||||||
// Next ConVar in chain
|
|
||||||
ConCommandBase *m_pNext;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Has the cvar been added to the global list?
|
|
||||||
bool m_bRegistered;
|
|
||||||
|
|
||||||
// Static data
|
|
||||||
char const *m_pszName;
|
|
||||||
char const *m_pszHelpString;
|
|
||||||
|
|
||||||
// ConVar flags
|
|
||||||
int m_nFlags;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
// ConVars add themselves to this list for the executable. Then ConVarMgr::Init() runs through
|
|
||||||
// all the console variables and registers them.
|
|
||||||
static ConCommandBase *s_pConCommandBases;
|
|
||||||
|
|
||||||
// ConVars in this executable use this 'global' to access values.
|
|
||||||
static IConCommandBaseAccessor *s_pAccessor;
|
|
||||||
|
|
||||||
public: // Hackalicous
|
|
||||||
inline int GetFlags() const
|
|
||||||
{
|
|
||||||
return m_nFlags;
|
|
||||||
}
|
|
||||||
inline void SetFlags(int flags)
|
|
||||||
{
|
|
||||||
m_nFlags = flags;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: The console invoked command
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class ConCommand : public ConCommandBase
|
|
||||||
{
|
|
||||||
friend class ConCommandBaseMgr;
|
|
||||||
friend class CCvar;
|
|
||||||
#ifdef _STATIC_LINKED
|
|
||||||
friend class G_ConCommand;
|
|
||||||
friend class C_ConCommand;
|
|
||||||
friend class M_ConCommand;
|
|
||||||
friend class S_ConCommand;
|
|
||||||
friend class D_ConCommand;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef ConCommandBase BaseClass;
|
|
||||||
|
|
||||||
ConCommand( void );
|
|
||||||
ConCommand( char const *pName, FnCommandCallback callback,
|
|
||||||
char const *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 );
|
|
||||||
|
|
||||||
virtual ~ConCommand( void );
|
|
||||||
|
|
||||||
virtual bool IsCommand( void ) const;
|
|
||||||
|
|
||||||
virtual int AutoCompleteSuggest( char const *partial, char commands[ COMMAND_COMPLETION_MAXITEMS ][ COMMAND_COMPLETION_ITEM_LENGTH ] );
|
|
||||||
|
|
||||||
virtual bool CanAutoComplete( void );
|
|
||||||
|
|
||||||
// Invoke the function
|
|
||||||
virtual void Dispatch( void );
|
|
||||||
private:
|
|
||||||
virtual void Create( char const *pName, FnCommandCallback callback,
|
|
||||||
char const *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 );
|
|
||||||
|
|
||||||
// Call this function when executing the command
|
|
||||||
FnCommandCallback m_fnCommandCallback;
|
|
||||||
|
|
||||||
FnCommandCompletionCallback m_fnCompletionCallback;
|
|
||||||
bool m_bHasCompletionCallback;
|
|
||||||
public: // Hackalicous
|
|
||||||
inline FnCommandCallback GetCallback() const
|
|
||||||
{
|
|
||||||
return m_fnCommandCallback;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: A console variable
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class ConVar : public ConCommandBase
|
|
||||||
{
|
|
||||||
friend class ConCommandBaseMgr;
|
|
||||||
friend class CCvar;
|
|
||||||
friend class CDefaultCvar;
|
|
||||||
#ifdef _STATIC_LINKED
|
|
||||||
friend class G_ConVar;
|
|
||||||
friend class C_ConVar;
|
|
||||||
friend class M_ConVar;
|
|
||||||
friend class S_ConVar;
|
|
||||||
friend class D_ConVar;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef ConCommandBase BaseClass;
|
|
||||||
|
|
||||||
ConVar( char const *pName, char const *pDefaultValue, int flags = 0);
|
|
||||||
|
|
||||||
ConVar( char const *pName, char const *pDefaultValue, int flags,
|
|
||||||
char const *pHelpString );
|
|
||||||
ConVar( char const *pName, char const *pDefaultValue, int flags,
|
|
||||||
char const *pHelpString, bool bMin, float fMin, bool bMax, float fMax );
|
|
||||||
ConVar( char const *pName, char const *pDefaultValue, int flags,
|
|
||||||
char const *pHelpString, FnChangeCallback callback );
|
|
||||||
ConVar( char const *pName, char const *pDefaultValue, int flags,
|
|
||||||
char const *pHelpString, bool bMin, float fMin, bool bMax, float fMax,
|
|
||||||
FnChangeCallback callback );
|
|
||||||
|
|
||||||
virtual ~ConVar( void );
|
|
||||||
|
|
||||||
virtual bool IsBitSet( int flag ) const;
|
|
||||||
virtual char const* GetHelpText( void ) const;
|
|
||||||
virtual bool IsRegistered( void ) const;
|
|
||||||
virtual char const *GetName( void ) const;
|
|
||||||
virtual void AddFlags( int flags );
|
|
||||||
virtual bool IsCommand( void ) const;
|
|
||||||
|
|
||||||
// Install a change callback (there shouldn't already be one....)
|
|
||||||
void InstallChangeCallback( FnChangeCallback callback );
|
|
||||||
|
|
||||||
// Retrieve value
|
|
||||||
FORCEINLINE_CVAR float GetFloat( void ) const;
|
|
||||||
FORCEINLINE_CVAR int GetInt( void ) const;
|
|
||||||
FORCEINLINE_CVAR bool GetBool() const { return !!GetInt(); }
|
|
||||||
FORCEINLINE_CVAR char const *GetString( void ) const;
|
|
||||||
|
|
||||||
// Any function that allocates/frees memory needs to be virtual or else you'll have crashes
|
|
||||||
// from alloc/free across dll/exe boundaries.
|
|
||||||
|
|
||||||
// These just call into the IConCommandBaseAccessor to check flags and set the var (which ends up calling InternalSetValue).
|
|
||||||
virtual void SetValue( char const *value );
|
|
||||||
virtual void SetValue( float value );
|
|
||||||
virtual void SetValue( int value );
|
|
||||||
|
|
||||||
// Reset to default value
|
|
||||||
void Revert( void );
|
|
||||||
|
|
||||||
// True if it has a min/max setting
|
|
||||||
bool GetMin( float& minVal ) const;
|
|
||||||
bool GetMax( float& maxVal ) const;
|
|
||||||
char const *GetDefault( void ) const;
|
|
||||||
|
|
||||||
static void RevertAll( void );
|
|
||||||
private:
|
|
||||||
// Called by CCvar when the value of a var is changing.
|
|
||||||
virtual void InternalSetValue(char const *value);
|
|
||||||
// For CVARs marked FCVAR_NEVER_AS_STRING
|
|
||||||
virtual void InternalSetFloatValue( float fNewValue );
|
|
||||||
virtual void InternalSetIntValue( int nValue );
|
|
||||||
|
|
||||||
virtual bool ClampValue( float& value );
|
|
||||||
virtual void ChangeStringValue( char const *tempVal );
|
|
||||||
|
|
||||||
virtual void Create( char const *pName, char const *pDefaultValue, int flags = 0,
|
|
||||||
char const *pHelpString = 0, bool bMin = false, float fMin = 0.0,
|
|
||||||
bool bMax = false, float fMax = false, FnChangeCallback callback = 0 );
|
|
||||||
|
|
||||||
// Used internally by OneTimeInit to initialize.
|
|
||||||
virtual void Init();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
// This either points to "this" or it points to the original declaration of a ConVar.
|
|
||||||
// This allows ConVars to exist in separate modules, and they all use the first one to be declared.
|
|
||||||
// m_pParent->m_pParent must equal m_pParent (ie: m_pParent must be the root, or original, ConVar).
|
|
||||||
ConVar *m_pParent;
|
|
||||||
|
|
||||||
// Static data
|
|
||||||
char const *m_pszDefaultValue;
|
|
||||||
|
|
||||||
// Value
|
|
||||||
// Dynamically allocated
|
|
||||||
char *m_pszString;
|
|
||||||
int m_StringLength;
|
|
||||||
|
|
||||||
// Values
|
|
||||||
float m_fValue;
|
|
||||||
int m_nValue;
|
|
||||||
|
|
||||||
// Min/Max values
|
|
||||||
bool m_bHasMin;
|
|
||||||
float m_fMinVal;
|
|
||||||
bool m_bHasMax;
|
|
||||||
float m_fMaxVal;
|
|
||||||
|
|
||||||
// Call this function when ConVar changes
|
|
||||||
FnChangeCallback m_fnChangeCallback;
|
|
||||||
public: // Hackalicous
|
|
||||||
inline FnChangeCallback GetCallback() const
|
|
||||||
{
|
|
||||||
return m_fnChangeCallback;
|
|
||||||
}
|
|
||||||
inline void SetMin(bool set, float min=0.0)
|
|
||||||
{
|
|
||||||
m_bHasMin = set;
|
|
||||||
m_fMinVal = min;
|
|
||||||
}
|
|
||||||
inline void SetMax(bool set, float max=0.0)
|
|
||||||
{
|
|
||||||
m_bHasMax = set;
|
|
||||||
m_fMaxVal = max;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Return ConVar value as a float
|
|
||||||
// Output : float
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
FORCEINLINE_CVAR float ConVar::GetFloat( void ) const
|
|
||||||
{
|
|
||||||
return m_pParent->m_fValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Return ConVar value as an int
|
|
||||||
// Output : int
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
FORCEINLINE_CVAR int ConVar::GetInt( void ) const
|
|
||||||
{
|
|
||||||
return m_pParent->m_nValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Return ConVar value as a string, return "" for bogus string pointer, etc.
|
|
||||||
// Output : char const *
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
FORCEINLINE_CVAR char const *ConVar::GetString( void ) const
|
|
||||||
{
|
|
||||||
if ( m_nFlags & FCVAR_NEVER_AS_STRING )
|
|
||||||
{
|
|
||||||
return "FCVAR_NEVER_AS_STRING";
|
|
||||||
}
|
|
||||||
|
|
||||||
return ( m_pParent->m_pszString ) ? m_pParent->m_pszString : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _STATIC_LINKED
|
|
||||||
// identifies subsystem via piggybacking constructors with flags
|
|
||||||
class G_ConCommand : public ConCommand
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
G_ConCommand(char const *pName, FnCommandCallback callback, char const *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 ) : ConCommand(pName, callback, pHelpString, flags|FCVAR_GAMEDLL, completionFunc) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class C_ConCommand : public ConCommand
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
C_ConCommand(char const *pName, FnCommandCallback callback, char const *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 ) : ConCommand(pName, callback, pHelpString, flags|FCVAR_CLIENTDLL, completionFunc) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class M_ConCommand : public ConCommand
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
M_ConCommand(char const *pName, FnCommandCallback callback, char const *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 ) : ConCommand(pName, callback, pHelpString, flags|FCVAR_MATERIAL_SYSTEM, completionFunc) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class S_ConCommand : public ConCommand
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
S_ConCommand(char const *pName, FnCommandCallback callback, char const *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 ) : ConCommand(pName, callback, pHelpString, flags|FCVAR_STUDIORENDER, completionFunc) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class D_ConCommand : public ConCommand
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
D_ConCommand(char const *pName, FnCommandCallback callback, char const *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 ) : ConCommand(pName, callback, pHelpString, flags|FCVAR_DATACACHE, completionFunc) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef void ( *G_FnChangeCallback )( G_ConVar *var, char const *pOldString );
|
|
||||||
typedef void ( *C_FnChangeCallback )( C_ConVar *var, char const *pOldString );
|
|
||||||
typedef void ( *M_FnChangeCallback )( M_ConVar *var, char const *pOldString );
|
|
||||||
typedef void ( *S_FnChangeCallback )( S_ConVar *var, char const *pOldString );
|
|
||||||
typedef void ( *D_FnChangeCallback )( D_ConVar *var, char const *pOldString );
|
|
||||||
|
|
||||||
class G_ConVar : public ConVar
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
G_ConVar( char const *pName, char const *pDefaultValue, int flags = 0) : ConVar(pName, pDefaultValue, flags|FCVAR_GAMEDLL) {}
|
|
||||||
G_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString ) : ConVar(pName, pDefaultValue, flags|FCVAR_GAMEDLL, pHelpString ) {}
|
|
||||||
G_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString, bool bMin, float fMin, bool bMax, float fMax ) : ConVar(pName, pDefaultValue, flags|FCVAR_GAMEDLL, pHelpString, bMin, fMin, bMax, fMax) {}
|
|
||||||
G_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString, G_FnChangeCallback callback ) : ConVar(pName, pDefaultValue, flags|FCVAR_GAMEDLL, pHelpString, (FnChangeCallback)callback ) {}
|
|
||||||
G_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString, bool bMin, float fMin, bool bMax, float fMax, G_FnChangeCallback callback ) : ConVar(pName, pDefaultValue, flags|FCVAR_GAMEDLL, pHelpString, bMin, fMin, bMax, fMax, (FnChangeCallback)callback ) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class C_ConVar : public ConVar
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
C_ConVar( char const *pName, char const *pDefaultValue, int flags = 0) : ConVar(pName, pDefaultValue, flags|FCVAR_CLIENTDLL) {}
|
|
||||||
C_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString ) : ConVar(pName, pDefaultValue, flags|FCVAR_CLIENTDLL, pHelpString ) {}
|
|
||||||
C_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString, bool bMin, float fMin, bool bMax, float fMax ) : ConVar(pName, pDefaultValue, flags|FCVAR_CLIENTDLL, pHelpString, bMin, fMin, bMax, fMax) {}
|
|
||||||
C_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString, C_FnChangeCallback callback ) : ConVar(pName, pDefaultValue, flags|FCVAR_CLIENTDLL, pHelpString, (FnChangeCallback)callback ) {}
|
|
||||||
C_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString, bool bMin, float fMin, bool bMax, float fMax, C_FnChangeCallback callback ) : ConVar(pName, pDefaultValue, flags|FCVAR_CLIENTDLL, pHelpString, bMin, fMin, bMax, fMax, (FnChangeCallback)callback ) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class M_ConVar : public ConVar
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
M_ConVar( char const *pName, char const *pDefaultValue, int flags = 0) : ConVar(pName, pDefaultValue, flags|FCVAR_MATERIAL_SYSTEM) {}
|
|
||||||
M_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString ) : ConVar(pName, pDefaultValue, flags|FCVAR_MATERIAL_SYSTEM, pHelpString ) {}
|
|
||||||
M_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString, bool bMin, float fMin, bool bMax, float fMax ) : ConVar(pName, pDefaultValue, flags|FCVAR_MATERIAL_SYSTEM, pHelpString, bMin, fMin, bMax, fMax) {}
|
|
||||||
M_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString, M_FnChangeCallback callback ) : ConVar(pName, pDefaultValue, flags|FCVAR_MATERIAL_SYSTEM, pHelpString, (FnChangeCallback)callback ) {}
|
|
||||||
M_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString, bool bMin, float fMin, bool bMax, float fMax, M_FnChangeCallback callback ) : ConVar(pName, pDefaultValue, flags|FCVAR_MATERIAL_SYSTEM, pHelpString, bMin, fMin, bMax, fMax, (FnChangeCallback)callback ) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class S_ConVar : public ConVar
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
S_ConVar( char const *pName, char const *pDefaultValue, int flags = 0) : ConVar(pName, pDefaultValue, flags|FCVAR_STUDIORENDER) {}
|
|
||||||
S_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString ) : ConVar(pName, pDefaultValue, flags|FCVAR_STUDIORENDER, pHelpString ) {}
|
|
||||||
S_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString, bool bMin, float fMin, bool bMax, float fMax ) : ConVar(pName, pDefaultValue, flags|FCVAR_STUDIORENDER, pHelpString, bMin, fMin, bMax, fMax) {}
|
|
||||||
S_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString, M_FnChangeCallback callback ) : ConVar(pName, pDefaultValue, flags|FCVAR_STUDIORENDER, pHelpString, (FnChangeCallback)callback ) {}
|
|
||||||
S_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString, bool bMin, float fMin, bool bMax, float fMax, S_FnChangeCallback callback ) : ConVar(pName, pDefaultValue, flags|FCVAR_STUDIORENDER, pHelpString, bMin, fMin, bMax, fMax, (FnChangeCallback)callback ) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class D_ConVar : public ConVar
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
D_ConVar( char const *pName, char const *pDefaultValue, int flags = 0) : ConVar(pName, pDefaultValue, flags|FCVAR_DATACACHE) {}
|
|
||||||
D_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString ) : ConVar(pName, pDefaultValue, flags|FCVAR_DATACACHE, pHelpString ) {}
|
|
||||||
D_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString, bool bMin, float fMin, bool bMax, float fMax ) : ConVar(pName, pDefaultValue, flags|FCVAR_DATACACHE, pHelpString, bMin, fMin, bMax, fMax) {}
|
|
||||||
D_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString, M_FnChangeCallback callback ) : ConVar(pName, pDefaultValue, flags|FCVAR_DATACACHE, pHelpString, (FnChangeCallback)callback ) {}
|
|
||||||
D_ConVar( char const *pName, char const *pDefaultValue, int flags, char const *pHelpString, bool bMin, float fMin, bool bMax, float fMax, D_FnChangeCallback callback ) : ConVar(pName, pDefaultValue, flags|FCVAR_DATACACHE, pHelpString, bMin, fMin, bMax, fMax, (FnChangeCallback)callback ) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
// redirect these declarations to their specific subsystem
|
|
||||||
#ifdef GAME_DLL
|
|
||||||
#define ConCommand G_ConCommand
|
|
||||||
#define ConVar G_ConVar
|
|
||||||
#endif
|
|
||||||
#ifdef CLIENT_DLL
|
|
||||||
#define ConCommand C_ConCommand
|
|
||||||
#define ConVar C_ConVar
|
|
||||||
#endif
|
|
||||||
#ifdef MATERIALSYSTEM_DLL
|
|
||||||
#define ConCommand M_ConCommand
|
|
||||||
#define ConVar M_ConVar
|
|
||||||
#endif
|
|
||||||
#ifdef STUDIORENDER_DLL
|
|
||||||
#define ConCommand S_ConCommand
|
|
||||||
#define ConVar S_ConVar
|
|
||||||
#endif
|
|
||||||
#ifdef DATACACHE_DLL
|
|
||||||
#define ConCommand D_ConCommand
|
|
||||||
#define ConVar D_ConVar
|
|
||||||
#endif
|
|
||||||
#endif // _STATIC_LINKED
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Utility to quicky generate a simple console command
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
#define CON_COMMAND( name, description ) \
|
|
||||||
static void name(); \
|
|
||||||
static ConCommand name##_command( #name, name, description ); \
|
|
||||||
static void name()
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Utility to quicky generate a simple console command
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
#define CON_COMMAND_F( name, description, flags ) \
|
|
||||||
static void name(); \
|
|
||||||
static ConCommand name##_command( #name, name, description, flags ); \
|
|
||||||
static void name()
|
|
||||||
|
|
||||||
|
|
||||||
#endif // CONVAR_H
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,718 +0,0 @@
|
|||||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $Workfile: $
|
|
||||||
// $Date: $
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// $NoKeywords: $
|
|
||||||
//===========================================================================//
|
|
||||||
|
|
||||||
#ifndef CONVAR_H
|
|
||||||
#define CONVAR_H
|
|
||||||
|
|
||||||
#if _WIN32
|
|
||||||
#pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "tier0/dbg.h"
|
|
||||||
#include "tier1/iconvar.h"
|
|
||||||
#include "tier1/utlvector.h"
|
|
||||||
#include "tier1/utlstring.h"
|
|
||||||
#include "icvar.h"
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define FORCEINLINE_CVAR FORCEINLINE
|
|
||||||
#elif defined _LINUX || defined __APPLE__
|
|
||||||
#define FORCEINLINE_CVAR inline
|
|
||||||
#else
|
|
||||||
#error "implement me"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Forward declarations
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class ConVar;
|
|
||||||
class CCommand;
|
|
||||||
class ConCommand;
|
|
||||||
class ConCommandBase;
|
|
||||||
struct characterset_t;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Any executable that wants to use ConVars need to implement one of
|
|
||||||
// these to hook up access to console variables.
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class IConCommandBaseAccessor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Flags is a combination of FCVAR flags in cvar.h.
|
|
||||||
// hOut is filled in with a handle to the variable.
|
|
||||||
virtual bool RegisterConCommandBase( ConCommandBase *pVar ) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Helper method for console development
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
#if defined( _X360 ) && !defined( _RETAIL )
|
|
||||||
void ConVar_PublishToVXConsole();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Called when a ConCommand needs to execute
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
typedef void ( *FnCommandCallbackV1_t )( void );
|
|
||||||
typedef void ( *FnCommandCallback_t )( const CCommand &command );
|
|
||||||
|
|
||||||
#define COMMAND_COMPLETION_MAXITEMS 64
|
|
||||||
#define COMMAND_COMPLETION_ITEM_LENGTH 64
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Returns 0 to COMMAND_COMPLETION_MAXITEMS worth of completion strings
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
typedef int ( *FnCommandCompletionCallback )( const char *partial, char commands[ COMMAND_COMPLETION_MAXITEMS ][ COMMAND_COMPLETION_ITEM_LENGTH ] );
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Interface version
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class ICommandCallback
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void CommandCallback( const CCommand &command ) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ICommandCompletionCallback
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual int CommandCompletionCallback( const char *pPartial, CUtlVector< CUtlString > &commands ) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: The base console invoked command/cvar interface
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class ConCommandBase
|
|
||||||
{
|
|
||||||
friend class CCvar;
|
|
||||||
friend class ConVar;
|
|
||||||
friend class ConCommand;
|
|
||||||
friend void ConVar_Register( int nCVarFlag, IConCommandBaseAccessor *pAccessor );
|
|
||||||
friend void ConVar_PublishToVXConsole();
|
|
||||||
|
|
||||||
// FIXME: Remove when ConVar changes are done
|
|
||||||
friend class CDefaultCvar;
|
|
||||||
|
|
||||||
public:
|
|
||||||
ConCommandBase( void );
|
|
||||||
ConCommandBase( const char *pName, const char *pHelpString = 0,
|
|
||||||
int flags = 0 );
|
|
||||||
|
|
||||||
virtual ~ConCommandBase( void );
|
|
||||||
|
|
||||||
virtual bool IsCommand( void ) const;
|
|
||||||
|
|
||||||
// Check flag
|
|
||||||
virtual bool IsFlagSet( int flag ) const;
|
|
||||||
// Set flag
|
|
||||||
virtual void AddFlags( int flags );
|
|
||||||
// Remove flag
|
|
||||||
virtual void RemoveFlags( int flags );
|
|
||||||
// Get flags
|
|
||||||
virtual int GetFlags( void ) const;
|
|
||||||
|
|
||||||
// Return name of cvar
|
|
||||||
virtual const char *GetName( void ) const;
|
|
||||||
|
|
||||||
// Return help text for cvar
|
|
||||||
virtual const char *GetHelpText( void ) const;
|
|
||||||
|
|
||||||
// Deal with next pointer
|
|
||||||
const ConCommandBase *GetNext( void ) const;
|
|
||||||
ConCommandBase *GetNext( void );
|
|
||||||
|
|
||||||
inline void SetNext(ConCommandBase *pBase)
|
|
||||||
{
|
|
||||||
m_pNext = pBase;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool IsRegistered( void ) const;
|
|
||||||
|
|
||||||
// Returns the DLL identifier
|
|
||||||
virtual CVarDLLIdentifier_t GetDLLIdentifier() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void Create( const char *pName, const char *pHelpString = 0,
|
|
||||||
int flags = 0 );
|
|
||||||
|
|
||||||
// Used internally by OneTimeInit to initialize/shutdown
|
|
||||||
virtual void Init();
|
|
||||||
void Shutdown();
|
|
||||||
|
|
||||||
// Internal copy routine ( uses new operator from correct module )
|
|
||||||
char *CopyString( const char *from );
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Next ConVar in chain
|
|
||||||
// Prior to register, it points to the next convar in the DLL.
|
|
||||||
// Once registered, though, m_pNext is reset to point to the next
|
|
||||||
// convar in the global list
|
|
||||||
ConCommandBase *m_pNext;
|
|
||||||
|
|
||||||
// Has the cvar been added to the global list?
|
|
||||||
bool m_bRegistered;
|
|
||||||
|
|
||||||
// Static data
|
|
||||||
const char *m_pszName;
|
|
||||||
const char *m_pszHelpString;
|
|
||||||
|
|
||||||
// ConVar flags
|
|
||||||
int m_nFlags;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// ConVars add themselves to this list for the executable.
|
|
||||||
// Then ConVar_Register runs through all the console variables
|
|
||||||
// and registers them into a global list stored in vstdlib.dll
|
|
||||||
static ConCommandBase *s_pConCommandBases;
|
|
||||||
|
|
||||||
// ConVars in this executable use this 'global' to access values.
|
|
||||||
static IConCommandBaseAccessor *s_pAccessor;
|
|
||||||
public:
|
|
||||||
inline void SetFlags(int flags)
|
|
||||||
{
|
|
||||||
m_nFlags = flags;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Command tokenizer
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class CCommand
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CCommand();
|
|
||||||
CCommand( int nArgC, const char **ppArgV );
|
|
||||||
bool Tokenize( const char *pCommand, characterset_t *pBreakSet = NULL );
|
|
||||||
void Reset();
|
|
||||||
|
|
||||||
int ArgC() const;
|
|
||||||
const char **ArgV() const;
|
|
||||||
const char *ArgS() const; // All args that occur after the 0th arg, in string form
|
|
||||||
const char *GetCommandString() const; // The entire command in string form, including the 0th arg
|
|
||||||
const char *operator[]( int nIndex ) const; // Gets at arguments
|
|
||||||
const char *Arg( int nIndex ) const; // Gets at arguments
|
|
||||||
|
|
||||||
// Helper functions to parse arguments to commands.
|
|
||||||
const char* FindArg( const char *pName ) const;
|
|
||||||
int FindArgInt( const char *pName, int nDefaultVal ) const;
|
|
||||||
|
|
||||||
static int MaxCommandLength();
|
|
||||||
static characterset_t* DefaultBreakSet();
|
|
||||||
|
|
||||||
private:
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
COMMAND_MAX_ARGC = 64,
|
|
||||||
COMMAND_MAX_LENGTH = 512,
|
|
||||||
};
|
|
||||||
|
|
||||||
int m_nArgc;
|
|
||||||
int m_nArgv0Size;
|
|
||||||
char m_pArgSBuffer[ COMMAND_MAX_LENGTH ];
|
|
||||||
char m_pArgvBuffer[ COMMAND_MAX_LENGTH ];
|
|
||||||
const char* m_ppArgv[ COMMAND_MAX_ARGC ];
|
|
||||||
};
|
|
||||||
|
|
||||||
inline int CCommand::MaxCommandLength()
|
|
||||||
{
|
|
||||||
return COMMAND_MAX_LENGTH - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int CCommand::ArgC() const
|
|
||||||
{
|
|
||||||
return m_nArgc;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const char **CCommand::ArgV() const
|
|
||||||
{
|
|
||||||
return m_nArgc ? (const char**)m_ppArgv : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const char *CCommand::ArgS() const
|
|
||||||
{
|
|
||||||
return m_nArgv0Size ? &m_pArgSBuffer[m_nArgv0Size] : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const char *CCommand::GetCommandString() const
|
|
||||||
{
|
|
||||||
return m_nArgc ? m_pArgSBuffer : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const char *CCommand::Arg( int nIndex ) const
|
|
||||||
{
|
|
||||||
// FIXME: Many command handlers appear to not be particularly careful
|
|
||||||
// about checking for valid argc range. For now, we're going to
|
|
||||||
// do the extra check and return an empty string if it's out of range
|
|
||||||
if ( nIndex < 0 || nIndex >= m_nArgc )
|
|
||||||
return "";
|
|
||||||
return m_ppArgv[nIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const char *CCommand::operator[]( int nIndex ) const
|
|
||||||
{
|
|
||||||
return Arg( nIndex );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: The console invoked command
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class ConCommand : public ConCommandBase
|
|
||||||
{
|
|
||||||
friend class CCvar;
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef ConCommandBase BaseClass;
|
|
||||||
|
|
||||||
ConCommand( const char *pName, FnCommandCallbackV1_t callback,
|
|
||||||
const char *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 );
|
|
||||||
ConCommand( const char *pName, FnCommandCallback_t callback,
|
|
||||||
const char *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 );
|
|
||||||
ConCommand( const char *pName, ICommandCallback *pCallback,
|
|
||||||
const char *pHelpString = 0, int flags = 0, ICommandCompletionCallback *pCommandCompletionCallback = 0 );
|
|
||||||
|
|
||||||
virtual ~ConCommand( void );
|
|
||||||
|
|
||||||
virtual bool IsCommand( void ) const;
|
|
||||||
|
|
||||||
virtual int AutoCompleteSuggest( const char *partial, CUtlVector< CUtlString > &commands );
|
|
||||||
|
|
||||||
virtual bool CanAutoComplete( void );
|
|
||||||
|
|
||||||
// Invoke the function
|
|
||||||
virtual void Dispatch( const CCommand &command );
|
|
||||||
|
|
||||||
private:
|
|
||||||
// NOTE: To maintain backward compat, we have to be very careful:
|
|
||||||
// All public virtual methods must appear in the same order always
|
|
||||||
// since engine code will be calling into this code, which *does not match*
|
|
||||||
// in the mod code; it's using slightly different, but compatible versions
|
|
||||||
// of this class. Also: Be very careful about adding new fields to this class.
|
|
||||||
// Those fields will not exist in the version of this class that is instanced
|
|
||||||
// in mod code.
|
|
||||||
|
|
||||||
// Call this function when executing the command
|
|
||||||
union
|
|
||||||
{
|
|
||||||
FnCommandCallbackV1_t m_fnCommandCallbackV1;
|
|
||||||
FnCommandCallback_t m_fnCommandCallback;
|
|
||||||
ICommandCallback *m_pCommandCallback;
|
|
||||||
};
|
|
||||||
|
|
||||||
union
|
|
||||||
{
|
|
||||||
FnCommandCompletionCallback m_fnCompletionCallback;
|
|
||||||
ICommandCompletionCallback *m_pCommandCompletionCallback;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool m_bHasCompletionCallback : 1;
|
|
||||||
bool m_bUsingNewCommandCallback : 1;
|
|
||||||
bool m_bUsingCommandCallbackInterface : 1;
|
|
||||||
public:
|
|
||||||
inline FnCommandCallback_t GetCallback() const
|
|
||||||
{
|
|
||||||
return m_fnCommandCallback;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: A console variable
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class ConVar : public ConCommandBase, public IConVar
|
|
||||||
{
|
|
||||||
friend class CCvar;
|
|
||||||
friend class ConVarRef;
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef ConCommandBase BaseClass;
|
|
||||||
|
|
||||||
ConVar( const char *pName, const char *pDefaultValue, int flags = 0);
|
|
||||||
|
|
||||||
ConVar( const char *pName, const char *pDefaultValue, int flags,
|
|
||||||
const char *pHelpString );
|
|
||||||
ConVar( const char *pName, const char *pDefaultValue, int flags,
|
|
||||||
const char *pHelpString, bool bMin, float fMin, bool bMax, float fMax );
|
|
||||||
ConVar( const char *pName, const char *pDefaultValue, int flags,
|
|
||||||
const char *pHelpString, FnChangeCallback_t callback );
|
|
||||||
ConVar( const char *pName, const char *pDefaultValue, int flags,
|
|
||||||
const char *pHelpString, bool bMin, float fMin, bool bMax, float fMax,
|
|
||||||
FnChangeCallback_t callback );
|
|
||||||
|
|
||||||
virtual ~ConVar( void );
|
|
||||||
|
|
||||||
virtual bool IsCommand( void ) const;
|
|
||||||
virtual bool IsFlagSet( int flag ) const;
|
|
||||||
virtual void AddFlags( int flags );
|
|
||||||
virtual int GetFlags( void ) const;
|
|
||||||
virtual const char *GetName( void ) const;
|
|
||||||
virtual const char* GetHelpText( void ) const;
|
|
||||||
virtual bool IsRegistered( void ) const;
|
|
||||||
|
|
||||||
// Install a change callback (there shouldn't already be one....)
|
|
||||||
void InstallChangeCallback( FnChangeCallback_t callback );
|
|
||||||
|
|
||||||
// Retrieve value
|
|
||||||
FORCEINLINE_CVAR float GetFloat( void ) const;
|
|
||||||
FORCEINLINE_CVAR int GetInt( void ) const;
|
|
||||||
FORCEINLINE_CVAR bool GetBool() const { return !!GetInt(); }
|
|
||||||
FORCEINLINE_CVAR char const *GetString( void ) const;
|
|
||||||
|
|
||||||
// Used internally by OneTimeInit to initialize.
|
|
||||||
virtual void Init();
|
|
||||||
|
|
||||||
virtual const char *GetBaseName( void ) const;
|
|
||||||
virtual int GetSplitScreenPlayerSlot ( void ) const;
|
|
||||||
|
|
||||||
// Any function that allocates/frees memory needs to be virtual or else you'll have crashes
|
|
||||||
// from alloc/free across dll/exe boundaries.
|
|
||||||
|
|
||||||
// These just call into the IConCommandBaseAccessor to check flags and set the var (which ends up calling InternalSetValue).
|
|
||||||
virtual void SetValue( const char *value );
|
|
||||||
virtual void SetValue( float value );
|
|
||||||
virtual void SetValue( int value );
|
|
||||||
#if SOURCE_ENGINE >= SE_NUCLEARDAWN
|
|
||||||
virtual void SetValue( Color value );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Reset to default value
|
|
||||||
void Revert( void );
|
|
||||||
|
|
||||||
// True if it has a min/max setting
|
|
||||||
bool GetMin( float& minVal ) const;
|
|
||||||
bool GetMax( float& maxVal ) const;
|
|
||||||
const char *GetDefault( void ) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Called by CCvar when the value of a var is changing.
|
|
||||||
virtual void InternalSetValue(const char *value);
|
|
||||||
// For CVARs marked FCVAR_NEVER_AS_STRING
|
|
||||||
virtual void InternalSetFloatValue( float fNewValue );
|
|
||||||
virtual void InternalSetIntValue( int nValue );
|
|
||||||
#if SOURCE_ENGINE >= SE_LEFT4DEAD2
|
|
||||||
virtual void InternalSetColorValue( Color value );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
virtual bool ClampValue( float& value );
|
|
||||||
virtual void ChangeStringValue( const char *tempVal, float flOldValue );
|
|
||||||
|
|
||||||
virtual void Create( const char *pName, const char *pDefaultValue, int flags = 0,
|
|
||||||
const char *pHelpString = 0, bool bMin = false, float fMin = 0.0,
|
|
||||||
bool bMax = false, float fMax = false, FnChangeCallback_t callback = 0 );
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
// This either points to "this" or it points to the original declaration of a ConVar.
|
|
||||||
// This allows ConVars to exist in separate modules, and they all use the first one to be declared.
|
|
||||||
// m_pParent->m_pParent must equal m_pParent (ie: m_pParent must be the root, or original, ConVar).
|
|
||||||
ConVar *m_pParent;
|
|
||||||
|
|
||||||
// Static data
|
|
||||||
const char *m_pszDefaultValue;
|
|
||||||
|
|
||||||
// Value
|
|
||||||
// Dynamically allocated
|
|
||||||
char *m_pszString;
|
|
||||||
int m_StringLength;
|
|
||||||
|
|
||||||
// Values
|
|
||||||
float m_fValue;
|
|
||||||
int m_nValue;
|
|
||||||
|
|
||||||
// Min/Max values
|
|
||||||
bool m_bHasMin;
|
|
||||||
float m_fMinVal;
|
|
||||||
bool m_bHasMax;
|
|
||||||
float m_fMaxVal;
|
|
||||||
|
|
||||||
// Call this function when ConVar changes
|
|
||||||
FnChangeCallback_t m_fnChangeCallback;
|
|
||||||
public:
|
|
||||||
inline FnChangeCallback_t GetCallback() const
|
|
||||||
{
|
|
||||||
return m_fnChangeCallback;
|
|
||||||
}
|
|
||||||
inline void SetMin(bool set, float min=0.0)
|
|
||||||
{
|
|
||||||
m_bHasMin = set;
|
|
||||||
m_fMinVal = min;
|
|
||||||
}
|
|
||||||
inline void SetMax(bool set, float max=0.0)
|
|
||||||
{
|
|
||||||
m_bHasMax = set;
|
|
||||||
m_fMaxVal = max;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Return ConVar value as a float
|
|
||||||
// Output : float
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
FORCEINLINE_CVAR float ConVar::GetFloat( void ) const
|
|
||||||
{
|
|
||||||
return m_pParent->m_fValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Return ConVar value as an int
|
|
||||||
// Output : int
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
FORCEINLINE_CVAR int ConVar::GetInt( void ) const
|
|
||||||
{
|
|
||||||
return m_pParent->m_nValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Return ConVar value as a string, return "" for bogus string pointer, etc.
|
|
||||||
// Output : const char *
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
FORCEINLINE_CVAR const char *ConVar::GetString( void ) const
|
|
||||||
{
|
|
||||||
if ( m_nFlags & FCVAR_NEVER_AS_STRING )
|
|
||||||
return "FCVAR_NEVER_AS_STRING";
|
|
||||||
|
|
||||||
return ( m_pParent->m_pszString ) ? m_pParent->m_pszString : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Used to read/write convars that already exist (replaces the FindVar method)
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class ConVarRef
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ConVarRef( const char *pName );
|
|
||||||
ConVarRef( const char *pName, bool bIgnoreMissing );
|
|
||||||
ConVarRef( IConVar *pConVar );
|
|
||||||
|
|
||||||
void Init( const char *pName, bool bIgnoreMissing );
|
|
||||||
bool IsValid() const;
|
|
||||||
bool IsFlagSet( int nFlags ) const;
|
|
||||||
IConVar *GetLinkedConVar();
|
|
||||||
|
|
||||||
// Get/Set value
|
|
||||||
float GetFloat( void ) const;
|
|
||||||
int GetInt( void ) const;
|
|
||||||
bool GetBool() const { return !!GetInt(); }
|
|
||||||
const char *GetString( void ) const;
|
|
||||||
|
|
||||||
void SetValue( const char *pValue );
|
|
||||||
void SetValue( float flValue );
|
|
||||||
void SetValue( int nValue );
|
|
||||||
void SetValue( bool bValue );
|
|
||||||
|
|
||||||
const char *GetName() const;
|
|
||||||
|
|
||||||
const char *GetDefault() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// High-speed method to read convar data
|
|
||||||
IConVar *m_pConVar;
|
|
||||||
ConVar *m_pConVarState;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Did we find an existing convar of that name?
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
FORCEINLINE_CVAR bool ConVarRef::IsFlagSet( int nFlags ) const
|
|
||||||
{
|
|
||||||
return ( m_pConVar->IsFlagSet( nFlags ) != 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCEINLINE_CVAR IConVar *ConVarRef::GetLinkedConVar()
|
|
||||||
{
|
|
||||||
return m_pConVar;
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCEINLINE_CVAR const char *ConVarRef::GetName() const
|
|
||||||
{
|
|
||||||
return m_pConVar->GetName();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Return ConVar value as a float
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
FORCEINLINE_CVAR float ConVarRef::GetFloat( void ) const
|
|
||||||
{
|
|
||||||
return m_pConVarState->m_fValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Return ConVar value as an int
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
FORCEINLINE_CVAR int ConVarRef::GetInt( void ) const
|
|
||||||
{
|
|
||||||
return m_pConVarState->m_nValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Return ConVar value as a string, return "" for bogus string pointer, etc.
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
FORCEINLINE_CVAR const char *ConVarRef::GetString( void ) const
|
|
||||||
{
|
|
||||||
Assert( !IsFlagSet( FCVAR_NEVER_AS_STRING ) );
|
|
||||||
return m_pConVarState->m_pszString;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FORCEINLINE_CVAR void ConVarRef::SetValue( const char *pValue )
|
|
||||||
{
|
|
||||||
m_pConVar->SetValue( pValue );
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCEINLINE_CVAR void ConVarRef::SetValue( float flValue )
|
|
||||||
{
|
|
||||||
m_pConVar->SetValue( flValue );
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCEINLINE_CVAR void ConVarRef::SetValue( int nValue )
|
|
||||||
{
|
|
||||||
m_pConVar->SetValue( nValue );
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCEINLINE_CVAR void ConVarRef::SetValue( bool bValue )
|
|
||||||
{
|
|
||||||
m_pConVar->SetValue( bValue ? 1 : 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCEINLINE_CVAR const char *ConVarRef::GetDefault() const
|
|
||||||
{
|
|
||||||
return m_pConVarState->m_pszDefaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Called by the framework to register ConCommands with the ICVar
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void ConVar_Register( int nCVarFlag = 0, IConCommandBaseAccessor *pAccessor = NULL );
|
|
||||||
void ConVar_Unregister( );
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Utility methods
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void ConVar_PrintFlags( const ConCommandBase *var );
|
|
||||||
void ConVar_PrintDescription( const ConCommandBase *pVar );
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Utility class to quickly allow ConCommands to call member methods
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning (disable : 4355 )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template< class T >
|
|
||||||
class CConCommandMemberAccessor : public ConCommand, public ICommandCallback, public ICommandCompletionCallback
|
|
||||||
{
|
|
||||||
typedef ConCommand BaseClass;
|
|
||||||
typedef void ( T::*FnMemberCommandCallback_t )( const CCommand &command );
|
|
||||||
typedef int ( T::*FnMemberCommandCompletionCallback_t )( const char *pPartial, CUtlVector< CUtlString > &commands );
|
|
||||||
|
|
||||||
public:
|
|
||||||
CConCommandMemberAccessor( T* pOwner, const char *pName, FnMemberCommandCallback_t callback, const char *pHelpString = 0,
|
|
||||||
int flags = 0, FnMemberCommandCompletionCallback_t completionFunc = 0 ) :
|
|
||||||
BaseClass( pName, this, pHelpString, flags, ( completionFunc != 0 ) ? this : NULL )
|
|
||||||
{
|
|
||||||
m_pOwner = pOwner;
|
|
||||||
m_Func = callback;
|
|
||||||
m_CompletionFunc = completionFunc;
|
|
||||||
}
|
|
||||||
|
|
||||||
~CConCommandMemberAccessor()
|
|
||||||
{
|
|
||||||
Shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetOwner( T* pOwner )
|
|
||||||
{
|
|
||||||
m_pOwner = pOwner;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void CommandCallback( const CCommand &command )
|
|
||||||
{
|
|
||||||
Assert( m_pOwner && m_Func );
|
|
||||||
(m_pOwner->*m_Func)( command );
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int CommandCompletionCallback( const char *pPartial, CUtlVector< CUtlString > &commands )
|
|
||||||
{
|
|
||||||
Assert( m_pOwner && m_CompletionFunc );
|
|
||||||
return (m_pOwner->*m_CompletionFunc)( pPartial, commands );
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
T* m_pOwner;
|
|
||||||
FnMemberCommandCallback_t m_Func;
|
|
||||||
FnMemberCommandCompletionCallback_t m_CompletionFunc;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
#pragma warning ( default : 4355 )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Utility macros to quicky generate a simple console command
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
#define CON_COMMAND( name, description ) \
|
|
||||||
static void name( const CCommand &args ); \
|
|
||||||
static ConCommand name##_command( #name, name, description ); \
|
|
||||||
static void name( const CCommand &args )
|
|
||||||
|
|
||||||
#define CON_COMMAND_F( name, description, flags ) \
|
|
||||||
static void name( const CCommand &args ); \
|
|
||||||
static ConCommand name##_command( #name, name, description, flags ); \
|
|
||||||
static void name( const CCommand &args )
|
|
||||||
|
|
||||||
#define CON_COMMAND_F_COMPLETION( name, description, flags, completion ) \
|
|
||||||
static void name( const CCommand &args ); \
|
|
||||||
static ConCommand name##_command( #name, name, description, flags, completion ); \
|
|
||||||
static void name( const CCommand &args )
|
|
||||||
|
|
||||||
#define CON_COMMAND_EXTERN( name, _funcname, description ) \
|
|
||||||
void _funcname( const CCommand &args ); \
|
|
||||||
static ConCommand name##_command( #name, _funcname, description ); \
|
|
||||||
void _funcname( const CCommand &args )
|
|
||||||
|
|
||||||
#define CON_COMMAND_EXTERN_F( name, _funcname, description, flags ) \
|
|
||||||
void _funcname( const CCommand &args ); \
|
|
||||||
static ConCommand name##_command( #name, _funcname, description, flags ); \
|
|
||||||
void _funcname( const CCommand &args )
|
|
||||||
|
|
||||||
#define CON_COMMAND_MEMBER_F( _thisclass, name, _funcname, description, flags ) \
|
|
||||||
void _funcname( const CCommand &args ); \
|
|
||||||
friend class CCommandMemberInitializer_##_funcname; \
|
|
||||||
class CCommandMemberInitializer_##_funcname \
|
|
||||||
{ \
|
|
||||||
public: \
|
|
||||||
CCommandMemberInitializer_##_funcname() : m_ConCommandAccessor( NULL, name, &_thisclass::_funcname, description, flags ) \
|
|
||||||
{ \
|
|
||||||
m_ConCommandAccessor.SetOwner( GET_OUTER( _thisclass, m_##_funcname##_register ) ); \
|
|
||||||
} \
|
|
||||||
private: \
|
|
||||||
CConCommandMemberAccessor< _thisclass > m_ConCommandAccessor; \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
CCommandMemberInitializer_##_funcname m_##_funcname##_register; \
|
|
||||||
|
|
||||||
|
|
||||||
#endif // CONVAR_H
|
|
||||||
@@ -1,709 +0,0 @@
|
|||||||
//===== Copyright © 1996-2005, Valve Corporation, All rights reserved. ======//
|
|
||||||
//
|
|
||||||
// Purpose:
|
|
||||||
//
|
|
||||||
// $Workfile: $
|
|
||||||
// $Date: $
|
|
||||||
//
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// $NoKeywords: $
|
|
||||||
//===========================================================================//
|
|
||||||
|
|
||||||
#ifndef CONVAR_H
|
|
||||||
#define CONVAR_H
|
|
||||||
|
|
||||||
#if _WIN32
|
|
||||||
#pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "tier0/dbg.h"
|
|
||||||
#include "tier1/iconvar.h"
|
|
||||||
#include "tier1/utlvector.h"
|
|
||||||
#include "tier1/utlstring.h"
|
|
||||||
#include "icvar.h"
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define FORCEINLINE_CVAR FORCEINLINE
|
|
||||||
#elif defined _LINUX || defined __APPLE__
|
|
||||||
#define FORCEINLINE_CVAR inline
|
|
||||||
#else
|
|
||||||
#error "implement me"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Forward declarations
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class ConVar;
|
|
||||||
class CCommand;
|
|
||||||
class ConCommand;
|
|
||||||
class ConCommandBase;
|
|
||||||
struct characterset_t;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Any executable that wants to use ConVars need to implement one of
|
|
||||||
// these to hook up access to console variables.
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class IConCommandBaseAccessor
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Flags is a combination of FCVAR flags in cvar.h.
|
|
||||||
// hOut is filled in with a handle to the variable.
|
|
||||||
virtual bool RegisterConCommandBase( ConCommandBase *pVar ) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Helper method for console development
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
#if defined( _X360 ) && !defined( _RETAIL )
|
|
||||||
void ConVar_PublishToVXConsole();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Called when a ConCommand needs to execute
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
typedef void ( *FnCommandCallbackV1_t )( void );
|
|
||||||
typedef void ( *FnCommandCallback_t )( const CCommand &command );
|
|
||||||
|
|
||||||
#define COMMAND_COMPLETION_MAXITEMS 64
|
|
||||||
#define COMMAND_COMPLETION_ITEM_LENGTH 64
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Returns 0 to COMMAND_COMPLETION_MAXITEMS worth of completion strings
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
typedef int ( *FnCommandCompletionCallback )( const char *partial, char commands[ COMMAND_COMPLETION_MAXITEMS ][ COMMAND_COMPLETION_ITEM_LENGTH ] );
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Interface version
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class ICommandCallback
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual void CommandCallback( const CCommand &command ) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ICommandCompletionCallback
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual int CommandCompletionCallback( const char *pPartial, CUtlVector< CUtlString > &commands ) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: The base console invoked command/cvar interface
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class ConCommandBase
|
|
||||||
{
|
|
||||||
friend class CCvar;
|
|
||||||
friend class ConVar;
|
|
||||||
friend class ConCommand;
|
|
||||||
friend void ConVar_Register( int nCVarFlag, IConCommandBaseAccessor *pAccessor );
|
|
||||||
friend void ConVar_PublishToVXConsole();
|
|
||||||
|
|
||||||
// FIXME: Remove when ConVar changes are done
|
|
||||||
friend class CDefaultCvar;
|
|
||||||
|
|
||||||
public:
|
|
||||||
ConCommandBase( void );
|
|
||||||
ConCommandBase( const char *pName, const char *pHelpString = 0,
|
|
||||||
int flags = 0 );
|
|
||||||
|
|
||||||
virtual ~ConCommandBase( void );
|
|
||||||
|
|
||||||
virtual bool IsCommand( void ) const;
|
|
||||||
|
|
||||||
// Check flag
|
|
||||||
virtual bool IsFlagSet( int flag ) const;
|
|
||||||
// Set flag
|
|
||||||
virtual void AddFlags( int flags );
|
|
||||||
|
|
||||||
// Return name of cvar
|
|
||||||
virtual const char *GetName( void ) const;
|
|
||||||
|
|
||||||
// Return help text for cvar
|
|
||||||
virtual const char *GetHelpText( void ) const;
|
|
||||||
|
|
||||||
// Deal with next pointer
|
|
||||||
const ConCommandBase *GetNext( void ) const;
|
|
||||||
ConCommandBase *GetNext( void );
|
|
||||||
|
|
||||||
void SetNext(ConCommandBase *pBase)
|
|
||||||
{
|
|
||||||
m_pNext = pBase;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool IsRegistered( void ) const;
|
|
||||||
|
|
||||||
// Returns the DLL identifier
|
|
||||||
virtual CVarDLLIdentifier_t GetDLLIdentifier() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
virtual void Create( const char *pName, const char *pHelpString = 0,
|
|
||||||
int flags = 0 );
|
|
||||||
|
|
||||||
// Used internally by OneTimeInit to initialize/shutdown
|
|
||||||
virtual void Init();
|
|
||||||
void Shutdown();
|
|
||||||
|
|
||||||
// Internal copy routine ( uses new operator from correct module )
|
|
||||||
char *CopyString( const char *from );
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Next ConVar in chain
|
|
||||||
// Prior to register, it points to the next convar in the DLL.
|
|
||||||
// Once registered, though, m_pNext is reset to point to the next
|
|
||||||
// convar in the global list
|
|
||||||
ConCommandBase *m_pNext;
|
|
||||||
|
|
||||||
// Has the cvar been added to the global list?
|
|
||||||
bool m_bRegistered;
|
|
||||||
|
|
||||||
// Static data
|
|
||||||
const char *m_pszName;
|
|
||||||
const char *m_pszHelpString;
|
|
||||||
|
|
||||||
// ConVar flags
|
|
||||||
int m_nFlags;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// ConVars add themselves to this list for the executable.
|
|
||||||
// Then ConVar_Register runs through all the console variables
|
|
||||||
// and registers them into a global list stored in vstdlib.dll
|
|
||||||
static ConCommandBase *s_pConCommandBases;
|
|
||||||
|
|
||||||
// ConVars in this executable use this 'global' to access values.
|
|
||||||
static IConCommandBaseAccessor *s_pAccessor;
|
|
||||||
public: // Hackalicous
|
|
||||||
inline int GetFlags() const
|
|
||||||
{
|
|
||||||
return m_nFlags;
|
|
||||||
}
|
|
||||||
inline void SetFlags(int flags)
|
|
||||||
{
|
|
||||||
m_nFlags = flags;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Command tokenizer
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class CCommand
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CCommand();
|
|
||||||
CCommand( int nArgC, const char **ppArgV );
|
|
||||||
bool Tokenize( const char *pCommand, characterset_t *pBreakSet = NULL );
|
|
||||||
void Reset();
|
|
||||||
|
|
||||||
int ArgC() const;
|
|
||||||
const char **ArgV() const;
|
|
||||||
const char *ArgS() const; // All args that occur after the 0th arg, in string form
|
|
||||||
const char *GetCommandString() const; // The entire command in string form, including the 0th arg
|
|
||||||
const char *operator[]( int nIndex ) const; // Gets at arguments
|
|
||||||
const char *Arg( int nIndex ) const; // Gets at arguments
|
|
||||||
|
|
||||||
// Helper functions to parse arguments to commands.
|
|
||||||
const char* FindArg( const char *pName ) const;
|
|
||||||
int FindArgInt( const char *pName, int nDefaultVal ) const;
|
|
||||||
|
|
||||||
static int MaxCommandLength();
|
|
||||||
static characterset_t* DefaultBreakSet();
|
|
||||||
|
|
||||||
private:
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
COMMAND_MAX_ARGC = 64,
|
|
||||||
COMMAND_MAX_LENGTH = 512,
|
|
||||||
};
|
|
||||||
|
|
||||||
int m_nArgc;
|
|
||||||
int m_nArgv0Size;
|
|
||||||
char m_pArgSBuffer[ COMMAND_MAX_LENGTH ];
|
|
||||||
char m_pArgvBuffer[ COMMAND_MAX_LENGTH ];
|
|
||||||
const char* m_ppArgv[ COMMAND_MAX_ARGC ];
|
|
||||||
};
|
|
||||||
|
|
||||||
inline int CCommand::MaxCommandLength()
|
|
||||||
{
|
|
||||||
return COMMAND_MAX_LENGTH - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int CCommand::ArgC() const
|
|
||||||
{
|
|
||||||
return m_nArgc;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const char **CCommand::ArgV() const
|
|
||||||
{
|
|
||||||
return m_nArgc ? (const char**)m_ppArgv : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const char *CCommand::ArgS() const
|
|
||||||
{
|
|
||||||
return m_nArgv0Size ? &m_pArgSBuffer[m_nArgv0Size] : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const char *CCommand::GetCommandString() const
|
|
||||||
{
|
|
||||||
return m_nArgc ? m_pArgSBuffer : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const char *CCommand::Arg( int nIndex ) const
|
|
||||||
{
|
|
||||||
// FIXME: Many command handlers appear to not be particularly careful
|
|
||||||
// about checking for valid argc range. For now, we're going to
|
|
||||||
// do the extra check and return an empty string if it's out of range
|
|
||||||
if ( nIndex < 0 || nIndex >= m_nArgc )
|
|
||||||
return "";
|
|
||||||
return m_ppArgv[nIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
inline const char *CCommand::operator[]( int nIndex ) const
|
|
||||||
{
|
|
||||||
return Arg( nIndex );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: The console invoked command
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class ConCommand : public ConCommandBase
|
|
||||||
{
|
|
||||||
friend class CCvar;
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef ConCommandBase BaseClass;
|
|
||||||
|
|
||||||
ConCommand( const char *pName, FnCommandCallbackV1_t callback,
|
|
||||||
const char *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 );
|
|
||||||
ConCommand( const char *pName, FnCommandCallback_t callback,
|
|
||||||
const char *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 );
|
|
||||||
ConCommand( const char *pName, ICommandCallback *pCallback,
|
|
||||||
const char *pHelpString = 0, int flags = 0, ICommandCompletionCallback *pCommandCompletionCallback = 0 );
|
|
||||||
|
|
||||||
virtual ~ConCommand( void );
|
|
||||||
|
|
||||||
virtual bool IsCommand( void ) const;
|
|
||||||
|
|
||||||
virtual int AutoCompleteSuggest( const char *partial, CUtlVector< CUtlString > &commands );
|
|
||||||
|
|
||||||
virtual bool CanAutoComplete( void );
|
|
||||||
|
|
||||||
// Invoke the function
|
|
||||||
virtual void Dispatch( const CCommand &command );
|
|
||||||
|
|
||||||
private:
|
|
||||||
// NOTE: To maintain backward compat, we have to be very careful:
|
|
||||||
// All public virtual methods must appear in the same order always
|
|
||||||
// since engine code will be calling into this code, which *does not match*
|
|
||||||
// in the mod code; it's using slightly different, but compatible versions
|
|
||||||
// of this class. Also: Be very careful about adding new fields to this class.
|
|
||||||
// Those fields will not exist in the version of this class that is instanced
|
|
||||||
// in mod code.
|
|
||||||
|
|
||||||
// Call this function when executing the command
|
|
||||||
union
|
|
||||||
{
|
|
||||||
FnCommandCallbackV1_t m_fnCommandCallbackV1;
|
|
||||||
FnCommandCallback_t m_fnCommandCallback;
|
|
||||||
ICommandCallback *m_pCommandCallback;
|
|
||||||
};
|
|
||||||
|
|
||||||
union
|
|
||||||
{
|
|
||||||
FnCommandCompletionCallback m_fnCompletionCallback;
|
|
||||||
ICommandCompletionCallback *m_pCommandCompletionCallback;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool m_bHasCompletionCallback : 1;
|
|
||||||
bool m_bUsingNewCommandCallback : 1;
|
|
||||||
bool m_bUsingCommandCallbackInterface : 1;
|
|
||||||
public: // Hackalicous
|
|
||||||
inline FnCommandCallback_t GetCallback() const
|
|
||||||
{
|
|
||||||
return m_fnCommandCallback;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: A console variable
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class ConVar : public ConCommandBase, public IConVar
|
|
||||||
{
|
|
||||||
friend class CCvar;
|
|
||||||
friend class ConVarRef;
|
|
||||||
|
|
||||||
public:
|
|
||||||
typedef ConCommandBase BaseClass;
|
|
||||||
|
|
||||||
ConVar( const char *pName, const char *pDefaultValue, int flags = 0);
|
|
||||||
|
|
||||||
ConVar( const char *pName, const char *pDefaultValue, int flags,
|
|
||||||
const char *pHelpString );
|
|
||||||
ConVar( const char *pName, const char *pDefaultValue, int flags,
|
|
||||||
const char *pHelpString, bool bMin, float fMin, bool bMax, float fMax );
|
|
||||||
ConVar( const char *pName, const char *pDefaultValue, int flags,
|
|
||||||
const char *pHelpString, FnChangeCallback_t callback );
|
|
||||||
ConVar( const char *pName, const char *pDefaultValue, int flags,
|
|
||||||
const char *pHelpString, bool bMin, float fMin, bool bMax, float fMax,
|
|
||||||
FnChangeCallback_t callback );
|
|
||||||
|
|
||||||
virtual ~ConVar( void );
|
|
||||||
|
|
||||||
virtual bool IsFlagSet( int flag ) const;
|
|
||||||
virtual const char* GetHelpText( void ) const;
|
|
||||||
virtual bool IsRegistered( void ) const;
|
|
||||||
virtual const char *GetName( void ) const;
|
|
||||||
virtual void AddFlags( int flags );
|
|
||||||
virtual bool IsCommand( void ) const;
|
|
||||||
|
|
||||||
// Install a change callback (there shouldn't already be one....)
|
|
||||||
void InstallChangeCallback( FnChangeCallback_t callback );
|
|
||||||
|
|
||||||
// Retrieve value
|
|
||||||
FORCEINLINE_CVAR float GetFloat( void ) const;
|
|
||||||
FORCEINLINE_CVAR int GetInt( void ) const;
|
|
||||||
FORCEINLINE_CVAR bool GetBool() const { return !!GetInt(); }
|
|
||||||
FORCEINLINE_CVAR char const *GetString( void ) const;
|
|
||||||
|
|
||||||
// Any function that allocates/frees memory needs to be virtual or else you'll have crashes
|
|
||||||
// from alloc/free across dll/exe boundaries.
|
|
||||||
|
|
||||||
// These just call into the IConCommandBaseAccessor to check flags and set the var (which ends up calling InternalSetValue).
|
|
||||||
virtual void SetValue( const char *value );
|
|
||||||
virtual void SetValue( float value );
|
|
||||||
virtual void SetValue( int value );
|
|
||||||
|
|
||||||
// Reset to default value
|
|
||||||
void Revert( void );
|
|
||||||
|
|
||||||
// True if it has a min/max setting
|
|
||||||
bool GetMin( float& minVal ) const;
|
|
||||||
bool GetMax( float& maxVal ) const;
|
|
||||||
const char *GetDefault( void ) const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Called by CCvar when the value of a var is changing.
|
|
||||||
virtual void InternalSetValue(const char *value);
|
|
||||||
// For CVARs marked FCVAR_NEVER_AS_STRING
|
|
||||||
virtual void InternalSetFloatValue( float fNewValue );
|
|
||||||
virtual void InternalSetIntValue( int nValue );
|
|
||||||
|
|
||||||
virtual bool ClampValue( float& value );
|
|
||||||
virtual void ChangeStringValue( const char *tempVal, float flOldValue );
|
|
||||||
|
|
||||||
virtual void Create( const char *pName, const char *pDefaultValue, int flags = 0,
|
|
||||||
const char *pHelpString = 0, bool bMin = false, float fMin = 0.0,
|
|
||||||
bool bMax = false, float fMax = false, FnChangeCallback_t callback = 0 );
|
|
||||||
|
|
||||||
// Used internally by OneTimeInit to initialize.
|
|
||||||
virtual void Init();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
// This either points to "this" or it points to the original declaration of a ConVar.
|
|
||||||
// This allows ConVars to exist in separate modules, and they all use the first one to be declared.
|
|
||||||
// m_pParent->m_pParent must equal m_pParent (ie: m_pParent must be the root, or original, ConVar).
|
|
||||||
ConVar *m_pParent;
|
|
||||||
|
|
||||||
// Static data
|
|
||||||
const char *m_pszDefaultValue;
|
|
||||||
|
|
||||||
// Value
|
|
||||||
// Dynamically allocated
|
|
||||||
char *m_pszString;
|
|
||||||
int m_StringLength;
|
|
||||||
|
|
||||||
// Values
|
|
||||||
float m_fValue;
|
|
||||||
int m_nValue;
|
|
||||||
|
|
||||||
// Min/Max values
|
|
||||||
bool m_bHasMin;
|
|
||||||
float m_fMinVal;
|
|
||||||
bool m_bHasMax;
|
|
||||||
float m_fMaxVal;
|
|
||||||
|
|
||||||
// Call this function when ConVar changes
|
|
||||||
FnChangeCallback_t m_fnChangeCallback;
|
|
||||||
public: // Hackalicous
|
|
||||||
inline FnChangeCallback_t GetCallback() const
|
|
||||||
{
|
|
||||||
return m_fnChangeCallback;
|
|
||||||
}
|
|
||||||
inline void SetMin(bool set, float min=0.0)
|
|
||||||
{
|
|
||||||
m_bHasMin = set;
|
|
||||||
m_fMinVal = min;
|
|
||||||
}
|
|
||||||
inline void SetMax(bool set, float max=0.0)
|
|
||||||
{
|
|
||||||
m_bHasMax = set;
|
|
||||||
m_fMaxVal = max;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Return ConVar value as a float
|
|
||||||
// Output : float
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
FORCEINLINE_CVAR float ConVar::GetFloat( void ) const
|
|
||||||
{
|
|
||||||
return m_pParent->m_fValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Return ConVar value as an int
|
|
||||||
// Output : int
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
FORCEINLINE_CVAR int ConVar::GetInt( void ) const
|
|
||||||
{
|
|
||||||
return m_pParent->m_nValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Return ConVar value as a string, return "" for bogus string pointer, etc.
|
|
||||||
// Output : const char *
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
FORCEINLINE_CVAR const char *ConVar::GetString( void ) const
|
|
||||||
{
|
|
||||||
if ( m_nFlags & FCVAR_NEVER_AS_STRING )
|
|
||||||
return "FCVAR_NEVER_AS_STRING";
|
|
||||||
|
|
||||||
return ( m_pParent->m_pszString ) ? m_pParent->m_pszString : "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Used to read/write convars that already exist (replaces the FindVar method)
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
class ConVarRef
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ConVarRef( const char *pName );
|
|
||||||
ConVarRef( const char *pName, bool bIgnoreMissing );
|
|
||||||
ConVarRef( IConVar *pConVar );
|
|
||||||
|
|
||||||
void Init( const char *pName, bool bIgnoreMissing );
|
|
||||||
bool IsValid() const;
|
|
||||||
bool IsFlagSet( int nFlags ) const;
|
|
||||||
IConVar *GetLinkedConVar();
|
|
||||||
|
|
||||||
// Get/Set value
|
|
||||||
float GetFloat( void ) const;
|
|
||||||
int GetInt( void ) const;
|
|
||||||
bool GetBool() const { return !!GetInt(); }
|
|
||||||
const char *GetString( void ) const;
|
|
||||||
|
|
||||||
void SetValue( const char *pValue );
|
|
||||||
void SetValue( float flValue );
|
|
||||||
void SetValue( int nValue );
|
|
||||||
void SetValue( bool bValue );
|
|
||||||
|
|
||||||
const char *GetName() const;
|
|
||||||
|
|
||||||
const char *GetDefault() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
// High-speed method to read convar data
|
|
||||||
IConVar *m_pConVar;
|
|
||||||
ConVar *m_pConVarState;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Did we find an existing convar of that name?
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
FORCEINLINE_CVAR bool ConVarRef::IsFlagSet( int nFlags ) const
|
|
||||||
{
|
|
||||||
return ( m_pConVar->IsFlagSet( nFlags ) != 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCEINLINE_CVAR IConVar *ConVarRef::GetLinkedConVar()
|
|
||||||
{
|
|
||||||
return m_pConVar;
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCEINLINE_CVAR const char *ConVarRef::GetName() const
|
|
||||||
{
|
|
||||||
return m_pConVar->GetName();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Return ConVar value as a float
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
FORCEINLINE_CVAR float ConVarRef::GetFloat( void ) const
|
|
||||||
{
|
|
||||||
return m_pConVarState->m_fValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Return ConVar value as an int
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
FORCEINLINE_CVAR int ConVarRef::GetInt( void ) const
|
|
||||||
{
|
|
||||||
return m_pConVarState->m_nValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Return ConVar value as a string, return "" for bogus string pointer, etc.
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
FORCEINLINE_CVAR const char *ConVarRef::GetString( void ) const
|
|
||||||
{
|
|
||||||
Assert( !IsFlagSet( FCVAR_NEVER_AS_STRING ) );
|
|
||||||
return m_pConVarState->m_pszString;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FORCEINLINE_CVAR void ConVarRef::SetValue( const char *pValue )
|
|
||||||
{
|
|
||||||
m_pConVar->SetValue( pValue );
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCEINLINE_CVAR void ConVarRef::SetValue( float flValue )
|
|
||||||
{
|
|
||||||
m_pConVar->SetValue( flValue );
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCEINLINE_CVAR void ConVarRef::SetValue( int nValue )
|
|
||||||
{
|
|
||||||
m_pConVar->SetValue( nValue );
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCEINLINE_CVAR void ConVarRef::SetValue( bool bValue )
|
|
||||||
{
|
|
||||||
m_pConVar->SetValue( bValue ? 1 : 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
FORCEINLINE_CVAR const char *ConVarRef::GetDefault() const
|
|
||||||
{
|
|
||||||
return m_pConVarState->m_pszDefaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Called by the framework to register ConCommands with the ICVar
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void ConVar_Register( int nCVarFlag = 0, IConCommandBaseAccessor *pAccessor = NULL );
|
|
||||||
void ConVar_Unregister( );
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Utility methods
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
void ConVar_PrintFlags( const ConCommandBase *var );
|
|
||||||
void ConVar_PrintDescription( const ConCommandBase *pVar );
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Utility class to quickly allow ConCommands to call member methods
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
#if defined _MSC_VER
|
|
||||||
#pragma warning (disable : 4355 )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template< class T >
|
|
||||||
class CConCommandMemberAccessor : public ConCommand, public ICommandCallback, public ICommandCompletionCallback
|
|
||||||
{
|
|
||||||
typedef ConCommand BaseClass;
|
|
||||||
typedef void ( T::*FnMemberCommandCallback_t )( const CCommand &command );
|
|
||||||
typedef int ( T::*FnMemberCommandCompletionCallback_t )( const char *pPartial, CUtlVector< CUtlString > &commands );
|
|
||||||
|
|
||||||
public:
|
|
||||||
CConCommandMemberAccessor( T* pOwner, const char *pName, FnMemberCommandCallback_t callback, const char *pHelpString = 0,
|
|
||||||
int flags = 0, FnMemberCommandCompletionCallback_t completionFunc = 0 ) :
|
|
||||||
BaseClass( pName, this, pHelpString, flags, ( completionFunc != 0 ) ? this : NULL )
|
|
||||||
{
|
|
||||||
m_pOwner = pOwner;
|
|
||||||
m_Func = callback;
|
|
||||||
m_CompletionFunc = completionFunc;
|
|
||||||
}
|
|
||||||
|
|
||||||
~CConCommandMemberAccessor()
|
|
||||||
{
|
|
||||||
Shutdown();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetOwner( T* pOwner )
|
|
||||||
{
|
|
||||||
m_pOwner = pOwner;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void CommandCallback( const CCommand &command )
|
|
||||||
{
|
|
||||||
Assert( m_pOwner && m_Func );
|
|
||||||
(m_pOwner->*m_Func)( command );
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual int CommandCompletionCallback( const char *pPartial, CUtlVector< CUtlString > &commands )
|
|
||||||
{
|
|
||||||
Assert( m_pOwner && m_CompletionFunc );
|
|
||||||
return (m_pOwner->*m_CompletionFunc)( pPartial, commands );
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
T* m_pOwner;
|
|
||||||
FnMemberCommandCallback_t m_Func;
|
|
||||||
FnMemberCommandCompletionCallback_t m_CompletionFunc;
|
|
||||||
};
|
|
||||||
|
|
||||||
#if defined _MSC_VER
|
|
||||||
#pragma warning ( default : 4355 )
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// Purpose: Utility macros to quicky generate a simple console command
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
#define CON_COMMAND( name, description ) \
|
|
||||||
static void name( const CCommand &args ); \
|
|
||||||
static ConCommand name##_command( #name, name, description ); \
|
|
||||||
static void name( const CCommand &args )
|
|
||||||
|
|
||||||
#define CON_COMMAND_F( name, description, flags ) \
|
|
||||||
static void name( const CCommand &args ); \
|
|
||||||
static ConCommand name##_command( #name, name, description, flags ); \
|
|
||||||
static void name( const CCommand &args )
|
|
||||||
|
|
||||||
#define CON_COMMAND_F_COMPLETION( name, description, flags, completion ) \
|
|
||||||
static void name( const CCommand &args ); \
|
|
||||||
static ConCommand name##_command( #name, name, description, flags, completion ); \
|
|
||||||
static void name( const CCommand &args )
|
|
||||||
|
|
||||||
#define CON_COMMAND_EXTERN( name, _funcname, description ) \
|
|
||||||
void _funcname( const CCommand &args ); \
|
|
||||||
static ConCommand name##_command( #name, _funcname, description ); \
|
|
||||||
void _funcname( const CCommand &args )
|
|
||||||
|
|
||||||
#define CON_COMMAND_EXTERN_F( name, _funcname, description, flags ) \
|
|
||||||
void _funcname( const CCommand &args ); \
|
|
||||||
static ConCommand name##_command( #name, _funcname, description, flags ); \
|
|
||||||
void _funcname( const CCommand &args )
|
|
||||||
|
|
||||||
#define CON_COMMAND_MEMBER_F( _thisclass, name, _funcname, description, flags ) \
|
|
||||||
void _funcname( const CCommand &args ); \
|
|
||||||
friend class CCommandMemberInitializer_##_funcname; \
|
|
||||||
class CCommandMemberInitializer_##_funcname \
|
|
||||||
{ \
|
|
||||||
public: \
|
|
||||||
CCommandMemberInitializer_##_funcname() : m_ConCommandAccessor( NULL, name, &_thisclass::_funcname, description, flags ) \
|
|
||||||
{ \
|
|
||||||
m_ConCommandAccessor.SetOwner( GET_OUTER( _thisclass, m_##_funcname##_register ) ); \
|
|
||||||
} \
|
|
||||||
private: \
|
|
||||||
CConCommandMemberAccessor< _thisclass > m_ConCommandAccessor; \
|
|
||||||
}; \
|
|
||||||
\
|
|
||||||
CCommandMemberInitializer_##_funcname m_##_funcname##_register; \
|
|
||||||
|
|
||||||
|
|
||||||
#endif // CONVAR_H
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -45,6 +45,7 @@ static Queue<FrameAction> *frame_actions;
|
|||||||
static float g_LastMenuTime = 0.0f;
|
static float g_LastMenuTime = 0.0f;
|
||||||
static float g_LastAuthCheck = 0.0f;
|
static float g_LastAuthCheck = 0.0f;
|
||||||
bool g_PendingInternalPush = false;
|
bool g_PendingInternalPush = false;
|
||||||
|
bool g_PendingAuthCheck = false;
|
||||||
|
|
||||||
class FrameActionInit : public SMGlobalClass
|
class FrameActionInit : public SMGlobalClass
|
||||||
{
|
{
|
||||||
@@ -114,9 +115,16 @@ void RunFrameHooks(bool simulating)
|
|||||||
g_LastMenuTime = curtime;
|
g_LastMenuTime = curtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*g_NumPlayersToAuth && curtime - g_LastAuthCheck >= 0.7f)
|
/* g_PendingAuthCheck is set by the NetworkIDValidated hook so that a client
|
||||||
|
* whose Steam ticket was just validated is authorized on the next frame rather
|
||||||
|
* than waiting up to 0.7s for the periodic check. It's deferred to the next frame
|
||||||
|
* (instead of authorizing inline in the hook) because the engine doesn't flag the
|
||||||
|
* client as fully authenticated until after the NetworkIDValidated callback returns.
|
||||||
|
*/
|
||||||
|
if (*g_NumPlayersToAuth && (g_PendingAuthCheck || curtime - g_LastAuthCheck >= 0.7f))
|
||||||
{
|
{
|
||||||
g_Players.RunAuthChecks();
|
g_Players.RunAuthChecks();
|
||||||
g_LastAuthCheck = curtime;
|
g_LastAuthCheck = curtime;
|
||||||
|
g_PendingAuthCheck = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ struct FrameAction
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern bool g_PendingInternalPush;
|
extern bool g_PendingInternalPush;
|
||||||
|
extern bool g_PendingAuthCheck;
|
||||||
|
|
||||||
void AddFrameAction(const FrameAction & action);
|
void AddFrameAction(const FrameAction & action);
|
||||||
void RunFrameHooks(bool simulating);
|
void RunFrameHooks(bool simulating);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
#include <IADTFactory.h>
|
#include <IADTFactory.h>
|
||||||
#include "common_logic.h"
|
#include "common_logic.h"
|
||||||
#include <sm_stringhashmap.h>
|
#include <sm_hashmap.h>
|
||||||
|
|
||||||
using namespace SourceMod;
|
using namespace SourceMod;
|
||||||
|
|
||||||
|
|||||||
+95
-77
@@ -1,84 +1,102 @@
|
|||||||
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
||||||
import os
|
import os
|
||||||
|
|
||||||
binary = SM.Library(builder, 'sourcemod.logic')
|
for cxx in builder.targets:
|
||||||
binary.compiler.cxxincludes += [
|
binary = SM.Library(builder, cxx, 'sourcemod.logic')
|
||||||
os.path.join(builder.sourcePath, 'core', 'logic'),
|
binary.compiler.cxxincludes += [
|
||||||
os.path.join(builder.sourcePath, 'public'),
|
builder.sourcePath,
|
||||||
os.path.join(builder.sourcePath, 'public', 'sourcepawn'),
|
os.path.join(builder.sourcePath, 'core', 'logic'),
|
||||||
os.path.join(builder.sourcePath, 'public', 'amtl'),
|
os.path.join(builder.sourcePath, 'public'),
|
||||||
os.path.join(SM.mms_root, 'core', 'sourcehook')
|
os.path.join(builder.sourcePath, 'sourcepawn', 'include'),
|
||||||
]
|
os.path.join(builder.sourcePath, 'sourcepawn'),
|
||||||
binary.compiler.defines += [
|
os.path.join(builder.sourcePath, 'sourcepawn', 'vm'),
|
||||||
'SM_DEFAULT_THREADER',
|
os.path.join(builder.sourcePath, 'public', 'amtl', 'amtl'),
|
||||||
'SM_LOGIC'
|
os.path.join(builder.sourcePath, 'public', 'amtl'),
|
||||||
]
|
os.path.join(SM.mms_root, 'core', 'sourcehook')
|
||||||
|
]
|
||||||
|
binary.compiler.defines += [
|
||||||
|
'SM_DEFAULT_THREADER',
|
||||||
|
'SM_LOGIC'
|
||||||
|
]
|
||||||
|
SP.AddVmFlags(binary)
|
||||||
|
|
||||||
if builder.target_platform == 'linux':
|
if binary.compiler.target.platform == 'linux':
|
||||||
binary.compiler.postlink += ['-lpthread', '-lrt']
|
binary.compiler.postlink += ['-lpthread', '-lrt', '-lm']
|
||||||
elif builder.target_platform == 'mac':
|
elif binary.compiler.target.platform == 'mac':
|
||||||
binary.compiler.cflags += ['-Wno-deprecated-declarations']
|
binary.compiler.cflags += ['-Wno-deprecated-declarations']
|
||||||
binary.compiler.postlink += ['-framework', 'CoreServices']
|
binary.compiler.postlink += ['-framework', 'CoreServices', '-lm']
|
||||||
|
|
||||||
if binary.compiler.vendor == 'gcc' or binary.compiler.vendor == 'clang':
|
target = binary.compiler.target
|
||||||
binary.compiler.cxxflags += ['-fno-rtti']
|
binary.compiler.linkflags += [
|
||||||
elif binary.compiler.vendor == 'msvc':
|
SP.static_libsp[target],
|
||||||
binary.compiler.cxxflags += ['/GR-']
|
SP.libamtl[target],
|
||||||
|
SP.zlib[target],
|
||||||
|
SP.mimalloc[target],
|
||||||
|
]
|
||||||
|
|
||||||
binary.sources += [
|
if binary.compiler.family == 'gcc' or binary.compiler.family == 'clang':
|
||||||
'common_logic.cpp',
|
binary.compiler.cxxflags += ['-fno-rtti', '-Wno-invalid-offsetof']
|
||||||
'smn_adt_array.cpp',
|
elif binary.compiler.family == 'msvc':
|
||||||
'smn_sorting.cpp',
|
binary.compiler.cxxflags += ['/GR-']
|
||||||
'smn_maplists.cpp',
|
|
||||||
'ADTFactory.cpp',
|
|
||||||
'smn_adt_stack.cpp',
|
|
||||||
'thread/ThreadWorker.cpp',
|
|
||||||
'thread/BaseWorker.cpp',
|
|
||||||
'ThreadSupport.cpp',
|
|
||||||
'smn_float.cpp',
|
|
||||||
'TextParsers.cpp',
|
|
||||||
'smn_textparse.cpp',
|
|
||||||
'smn_adt_trie.cpp',
|
|
||||||
'smn_functions.cpp',
|
|
||||||
'smn_timers.cpp',
|
|
||||||
'smn_players.cpp',
|
|
||||||
'MemoryUtils.cpp',
|
|
||||||
'smn_admin.cpp',
|
|
||||||
'smn_banning.cpp',
|
|
||||||
'smn_filesystem.cpp',
|
|
||||||
'stringutil.cpp',
|
|
||||||
'Translator.cpp',
|
|
||||||
'PhraseCollection.cpp',
|
|
||||||
'smn_lang.cpp',
|
|
||||||
'smn_string.cpp',
|
|
||||||
'smn_handles.cpp',
|
|
||||||
'smn_datapacks.cpp',
|
|
||||||
'smn_gameconfigs.cpp',
|
|
||||||
'smn_fakenatives.cpp',
|
|
||||||
'GameConfigs.cpp',
|
|
||||||
'sm_crc32.cpp',
|
|
||||||
'smn_profiler.cpp',
|
|
||||||
'ShareSys.cpp',
|
|
||||||
'PluginSys.cpp',
|
|
||||||
'HandleSys.cpp',
|
|
||||||
'NativeOwner.cpp',
|
|
||||||
'NativeInvoker.cpp',
|
|
||||||
'ExtensionSys.cpp',
|
|
||||||
'DebugReporter.cpp',
|
|
||||||
'Database.cpp',
|
|
||||||
'smn_database.cpp',
|
|
||||||
'ForwardSys.cpp',
|
|
||||||
'AdminCache.cpp',
|
|
||||||
'sm_trie.cpp',
|
|
||||||
'smn_console.cpp',
|
|
||||||
'ProfileTools.cpp',
|
|
||||||
'Logger.cpp',
|
|
||||||
'smn_core.cpp',
|
|
||||||
'smn_menus.cpp',
|
|
||||||
]
|
|
||||||
if builder.target_platform == 'windows':
|
|
||||||
binary.sources += ['thread/WinThreads.cpp']
|
|
||||||
else:
|
|
||||||
binary.sources += ['thread/PosixThreads.cpp']
|
|
||||||
|
|
||||||
SM.binaries += [builder.Add(binary)]
|
binary.sources += [
|
||||||
|
'common_logic.cpp',
|
||||||
|
'smn_adt_array.cpp',
|
||||||
|
'smn_sorting.cpp',
|
||||||
|
'smn_maplists.cpp',
|
||||||
|
'ADTFactory.cpp',
|
||||||
|
'smn_adt_stack.cpp',
|
||||||
|
'BaseWorker.cpp',
|
||||||
|
'ThreadSupport.cpp',
|
||||||
|
'smn_float.cpp',
|
||||||
|
'TextParsers.cpp',
|
||||||
|
'smn_textparse.cpp',
|
||||||
|
'smn_adt_trie.cpp',
|
||||||
|
'smn_functions.cpp',
|
||||||
|
'smn_timers.cpp',
|
||||||
|
'smn_players.cpp',
|
||||||
|
'MemoryUtils.cpp',
|
||||||
|
'smn_admin.cpp',
|
||||||
|
'smn_banning.cpp',
|
||||||
|
'smn_filesystem.cpp',
|
||||||
|
'stringutil.cpp',
|
||||||
|
'Translator.cpp',
|
||||||
|
'PhraseCollection.cpp',
|
||||||
|
'smn_lang.cpp',
|
||||||
|
'smn_string.cpp',
|
||||||
|
'smn_handles.cpp',
|
||||||
|
'smn_datapacks.cpp',
|
||||||
|
'smn_gameconfigs.cpp',
|
||||||
|
'smn_fakenatives.cpp',
|
||||||
|
'GameConfigs.cpp',
|
||||||
|
'sm_crc32.cpp',
|
||||||
|
'smn_profiler.cpp',
|
||||||
|
'ShareSys.cpp',
|
||||||
|
'PluginSys.cpp',
|
||||||
|
'HandleSys.cpp',
|
||||||
|
'NativeOwner.cpp',
|
||||||
|
'ExtensionSys.cpp',
|
||||||
|
'DebugReporter.cpp',
|
||||||
|
'Database.cpp',
|
||||||
|
'smn_database.cpp',
|
||||||
|
'ForwardSys.cpp',
|
||||||
|
'AdminCache.cpp',
|
||||||
|
'sm_trie.cpp',
|
||||||
|
'smn_console.cpp',
|
||||||
|
'ProfileTools.cpp',
|
||||||
|
'Logger.cpp',
|
||||||
|
'smn_core.cpp',
|
||||||
|
'smn_menus.cpp',
|
||||||
|
'sprintf.cpp',
|
||||||
|
'LibrarySys.cpp',
|
||||||
|
'RootConsoleMenu.cpp',
|
||||||
|
'CDataPack.cpp',
|
||||||
|
'frame_tasks.cpp',
|
||||||
|
'smn_halflife.cpp',
|
||||||
|
'FrameIterator.cpp',
|
||||||
|
'DatabaseConfBuilder.cpp',
|
||||||
|
'LumpManager.cpp',
|
||||||
|
'smn_entitylump.cpp'
|
||||||
|
]
|
||||||
|
|
||||||
|
SM.binaries += [builder.Add(binary)]
|
||||||
|
|||||||
+66
-51
@@ -39,15 +39,19 @@
|
|||||||
#include "AdminCache.h"
|
#include "AdminCache.h"
|
||||||
#include "Translator.h"
|
#include "Translator.h"
|
||||||
#include "common_logic.h"
|
#include "common_logic.h"
|
||||||
|
#include "stringutil.h"
|
||||||
|
#include <bridge/include/ILogger.h>
|
||||||
|
#include <bridge/include/CoreProvider.h>
|
||||||
|
#include <bridge/include/IVEngineServerBridge.h>
|
||||||
|
|
||||||
#define LEVEL_STATE_NONE 0
|
#define LEVEL_STATE_NONE 0
|
||||||
#define LEVEL_STATE_LEVELS 1
|
#define LEVEL_STATE_LEVELS 1
|
||||||
#define LEVEL_STATE_FLAGS 2
|
#define LEVEL_STATE_FLAGS 2
|
||||||
|
|
||||||
AdminCache g_Admins;
|
AdminCache g_Admins;
|
||||||
char g_ReverseFlags[26];
|
char g_ReverseFlags[AdminFlags_TOTAL];
|
||||||
AdminFlag g_FlagLetters[26];
|
AdminFlag g_FlagLetters[26];
|
||||||
bool g_FlagSet[26];
|
bool g_FlagCharSet[26];
|
||||||
|
|
||||||
/* Default flags */
|
/* Default flags */
|
||||||
AdminFlag g_DefaultFlags[26] =
|
AdminFlag g_DefaultFlags[26] =
|
||||||
@@ -71,9 +75,9 @@ public:
|
|||||||
memcpy(g_FlagLetters, g_DefaultFlags, sizeof(AdminFlag) * 26);
|
memcpy(g_FlagLetters, g_DefaultFlags, sizeof(AdminFlag) * 26);
|
||||||
for (unsigned int i=0; i<20; i++)
|
for (unsigned int i=0; i<20; i++)
|
||||||
{
|
{
|
||||||
g_FlagSet[i] = true;
|
g_FlagCharSet[i] = true;
|
||||||
}
|
}
|
||||||
g_FlagSet[25] = true;
|
g_FlagCharSet[25] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
@@ -103,7 +107,7 @@ private:
|
|||||||
{
|
{
|
||||||
m_LevelState = LEVEL_STATE_NONE;
|
m_LevelState = LEVEL_STATE_NONE;
|
||||||
m_IgnoreLevel = 0;
|
m_IgnoreLevel = 0;
|
||||||
memset(g_FlagSet, 0, sizeof(g_FlagSet));
|
memset(g_FlagCharSet, 0, sizeof(g_FlagCharSet));
|
||||||
}
|
}
|
||||||
SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name)
|
SMCResult ReadSMC_NewSection(const SMCStates *states, const char *name)
|
||||||
{
|
{
|
||||||
@@ -163,7 +167,7 @@ private:
|
|||||||
return SMCResult_Continue;
|
return SMCResult_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_FlagSet[c] = true;
|
g_FlagCharSet[c] = true;
|
||||||
|
|
||||||
return SMCResult_Continue;
|
return SMCResult_Continue;
|
||||||
}
|
}
|
||||||
@@ -229,8 +233,7 @@ AdminCache::~AdminCache()
|
|||||||
DumpAdminCache(AdminCache_Overrides, false);
|
DumpAdminCache(AdminCache_Overrides, false);
|
||||||
DumpAdminCache(AdminCache_Groups, false);
|
DumpAdminCache(AdminCache_Groups, false);
|
||||||
|
|
||||||
List<AuthMethod *>::iterator iter;
|
for (auto iter=m_AuthMethods.begin();
|
||||||
for (iter=m_AuthMethods.begin();
|
|
||||||
iter!=m_AuthMethods.end();
|
iter!=m_AuthMethods.end();
|
||||||
iter++)
|
iter++)
|
||||||
{
|
{
|
||||||
@@ -267,6 +270,21 @@ void AdminCache::OnSourceModStartup(bool late)
|
|||||||
NameFlag("custom4", Admin_Custom4);
|
NameFlag("custom4", Admin_Custom4);
|
||||||
NameFlag("custom5", Admin_Custom5);
|
NameFlag("custom5", Admin_Custom5);
|
||||||
NameFlag("custom6", Admin_Custom6);
|
NameFlag("custom6", Admin_Custom6);
|
||||||
|
|
||||||
|
auto sm_dump_admcache = [this] (int client, const ICommandArgs *args) -> bool {
|
||||||
|
char buffer[PLATFORM_MAX_PATH];
|
||||||
|
g_pSM->BuildPath(Path_SM, buffer, sizeof(buffer), "data/admin_cache_dump.txt");
|
||||||
|
|
||||||
|
if (!DumpCache(buffer)) {
|
||||||
|
bridge->ConsolePrint("Could not open file for writing: %s", buffer);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bridge->ConsolePrint("Admin cache dumped to: %s", buffer);
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
bridge->DefineCommand("sm_dump_admcache", "Dumps the admin cache for debugging", sm_dump_admcache);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdminCache::OnSourceModAllInitialized()
|
void AdminCache::OnSourceModAllInitialized()
|
||||||
@@ -327,7 +345,7 @@ void AdminCache::AddCommandOverride(const char *cmd, OverrideType type, FlagBits
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
map->insert(cmd, flags);
|
map->insert(cmd, flags);
|
||||||
smcore.UpdateAdminCmdFlags(cmd, type, flags, false);
|
bridge->UpdateAdminCmdFlags(cmd, type, flags, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AdminCache::GetCommandOverride(const char *cmd, OverrideType type, FlagBits *pFlags)
|
bool AdminCache::GetCommandOverride(const char *cmd, OverrideType type, FlagBits *pFlags)
|
||||||
@@ -356,13 +374,13 @@ void AdminCache::UnsetCommandOverride(const char *cmd, OverrideType type)
|
|||||||
void AdminCache::_UnsetCommandGroupOverride(const char *group)
|
void AdminCache::_UnsetCommandGroupOverride(const char *group)
|
||||||
{
|
{
|
||||||
m_CmdGrpOverrides.remove(group);
|
m_CmdGrpOverrides.remove(group);
|
||||||
smcore.UpdateAdminCmdFlags(group, Override_CommandGroup, 0, true);
|
bridge->UpdateAdminCmdFlags(group, Override_CommandGroup, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdminCache::_UnsetCommandOverride(const char *cmd)
|
void AdminCache::_UnsetCommandOverride(const char *cmd)
|
||||||
{
|
{
|
||||||
m_CmdOverrides.remove(cmd);
|
m_CmdOverrides.remove(cmd);
|
||||||
smcore.UpdateAdminCmdFlags(cmd, Override_Command, 0, true);
|
bridge->UpdateAdminCmdFlags(cmd, Override_Command, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdminCache::DumpCommandOverrideCache(OverrideType type)
|
void AdminCache::DumpCommandOverrideCache(OverrideType type)
|
||||||
@@ -740,8 +758,7 @@ bool AdminCache::GetGroupCommandOverride(GroupId id, const char *name, OverrideT
|
|||||||
|
|
||||||
AuthMethod *AdminCache::GetMethodByIndex(unsigned int index)
|
AuthMethod *AdminCache::GetMethodByIndex(unsigned int index)
|
||||||
{
|
{
|
||||||
List<AuthMethod *>::iterator iter;
|
for (auto iter=m_AuthMethods.begin();
|
||||||
for (iter=m_AuthMethods.begin();
|
|
||||||
iter!=m_AuthMethods.end();
|
iter!=m_AuthMethods.end();
|
||||||
iter++)
|
iter++)
|
||||||
{
|
{
|
||||||
@@ -955,8 +972,7 @@ void AdminCache::InvalidateAdminCache(bool unlink_admins)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Wipe the identity cache first */
|
/* Wipe the identity cache first */
|
||||||
List<AuthMethod *>::iterator iter;
|
for (auto iter=m_AuthMethods.begin();
|
||||||
for (iter=m_AuthMethods.begin();
|
|
||||||
iter!=m_AuthMethods.end();
|
iter!=m_AuthMethods.end();
|
||||||
iter++)
|
iter++)
|
||||||
{
|
{
|
||||||
@@ -979,9 +995,7 @@ void AdminCache::InvalidateAdminCache(bool unlink_admins)
|
|||||||
|
|
||||||
void AdminCache::DumpAdminCache(AdminCachePart part, bool rebuild)
|
void AdminCache::DumpAdminCache(AdminCachePart part, bool rebuild)
|
||||||
{
|
{
|
||||||
List<IAdminListener *>::iterator iter;
|
|
||||||
IAdminListener *pListener;
|
IAdminListener *pListener;
|
||||||
cell_t result;
|
|
||||||
|
|
||||||
if (part == AdminCache_Overrides)
|
if (part == AdminCache_Overrides)
|
||||||
{
|
{
|
||||||
@@ -989,13 +1003,13 @@ void AdminCache::DumpAdminCache(AdminCachePart part, bool rebuild)
|
|||||||
DumpCommandOverrideCache(Override_CommandGroup);
|
DumpCommandOverrideCache(Override_CommandGroup);
|
||||||
if (rebuild && !m_destroying)
|
if (rebuild && !m_destroying)
|
||||||
{
|
{
|
||||||
for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++)
|
for (auto iter=m_hooks.begin(); iter!=m_hooks.end(); iter++)
|
||||||
{
|
{
|
||||||
pListener = (*iter);
|
pListener = (*iter);
|
||||||
pListener->OnRebuildOverrideCache();
|
pListener->OnRebuildOverrideCache();
|
||||||
}
|
}
|
||||||
m_pCacheFwd->PushCell(part);
|
m_pCacheFwd->PushCell(part);
|
||||||
m_pCacheFwd->Execute(&result);
|
m_pCacheFwd->Execute();
|
||||||
}
|
}
|
||||||
} else if (part == AdminCache_Groups || part == AdminCache_Admins) {
|
} else if (part == AdminCache_Groups || part == AdminCache_Admins) {
|
||||||
if (part == AdminCache_Groups)
|
if (part == AdminCache_Groups)
|
||||||
@@ -1003,25 +1017,25 @@ void AdminCache::DumpAdminCache(AdminCachePart part, bool rebuild)
|
|||||||
InvalidateGroupCache();
|
InvalidateGroupCache();
|
||||||
if (rebuild && !m_destroying)
|
if (rebuild && !m_destroying)
|
||||||
{
|
{
|
||||||
for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++)
|
for (auto iter=m_hooks.begin(); iter!=m_hooks.end(); iter++)
|
||||||
{
|
{
|
||||||
pListener = (*iter);
|
pListener = (*iter);
|
||||||
pListener->OnRebuildGroupCache();
|
pListener->OnRebuildGroupCache();
|
||||||
}
|
}
|
||||||
m_pCacheFwd->PushCell(part);
|
m_pCacheFwd->PushCell(part);
|
||||||
m_pCacheFwd->Execute(&result);
|
m_pCacheFwd->Execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InvalidateAdminCache(true);
|
InvalidateAdminCache(true);
|
||||||
if (rebuild && !m_destroying)
|
if (rebuild && !m_destroying)
|
||||||
{
|
{
|
||||||
for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++)
|
for (auto iter=m_hooks.begin(); iter!=m_hooks.end(); iter++)
|
||||||
{
|
{
|
||||||
pListener = (*iter);
|
pListener = (*iter);
|
||||||
pListener->OnRebuildAdminCache((part == AdminCache_Groups));
|
pListener->OnRebuildAdminCache((part == AdminCache_Groups));
|
||||||
}
|
}
|
||||||
m_pCacheFwd->PushCell(AdminCache_Admins);
|
m_pCacheFwd->PushCell(AdminCache_Admins);
|
||||||
m_pCacheFwd->Execute(&result);
|
m_pCacheFwd->Execute();
|
||||||
playerhelpers->RecheckAnyAdmins();
|
playerhelpers->RecheckAnyAdmins();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1040,9 +1054,8 @@ const char *AdminCache::GetAdminName(AdminId id)
|
|||||||
|
|
||||||
bool AdminCache::GetMethodIndex(const char *name, unsigned int *_index)
|
bool AdminCache::GetMethodIndex(const char *name, unsigned int *_index)
|
||||||
{
|
{
|
||||||
List<AuthMethod *>::iterator iter;
|
|
||||||
unsigned int index = 0;
|
unsigned int index = 0;
|
||||||
for (iter=m_AuthMethods.begin();
|
for (auto iter=m_AuthMethods.begin();
|
||||||
iter!=m_AuthMethods.end();
|
iter!=m_AuthMethods.end();
|
||||||
iter++,index++)
|
iter++,index++)
|
||||||
{
|
{
|
||||||
@@ -1063,22 +1076,29 @@ bool AdminCache::GetMethodIndex(const char *name, unsigned int *_index)
|
|||||||
bool AdminCache::GetUnifiedSteamIdentity(const char *ident, char *out, size_t maxlen)
|
bool AdminCache::GetUnifiedSteamIdentity(const char *ident, char *out, size_t maxlen)
|
||||||
{
|
{
|
||||||
int len = strlen(ident);
|
int len = strlen(ident);
|
||||||
/* If the id was a steam id strip off the STEAM_*: part */
|
if (!strcmp(ident, "BOT"))
|
||||||
if (len >= 11 && !strncmp(ident, "STEAM_", 6) && ident[8] != '_')
|
|
||||||
{
|
{
|
||||||
// non-bot/lan Steam2 Id
|
// Bots
|
||||||
snprintf(out, maxlen, "%s", &ident[8]);
|
strncopy(out, ident, maxlen);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (len >= 11 && !strncmp(ident, "STEAM_", 6) && ident[8] != '_')
|
||||||
|
{
|
||||||
|
// non-bot/lan Steam2 Id, strip off the STEAM_* part
|
||||||
|
ke::SafeStrcpy(out, maxlen, &ident[8]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (len >= 7 && !strncmp(ident, "[U:", 3) && ident[len-1] == ']')
|
else if (len >= 7 && !strncmp(ident, "[U:", 3) && ident[len-1] == ']')
|
||||||
{
|
{
|
||||||
// Steam3 Id
|
// Steam3 Id, replicate the Steam2 Post-"STEAM_" part
|
||||||
uint32_t accountId = strtoul(&ident[5], nullptr, 10);
|
uint32_t accountId = strtoul(&ident[5], nullptr, 10);
|
||||||
snprintf(out, maxlen, "%u:%u", accountId & 1, accountId >> 1);
|
ke::SafeSprintf(out, maxlen, "%u:%u", accountId & 1, accountId >> 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// 64-bit CSteamID, replicate the Steam2 Post-"STEAM_" part
|
||||||
|
|
||||||
// some constants from steamclientpublic.h
|
// some constants from steamclientpublic.h
|
||||||
static const uint32_t k_EAccountTypeIndividual = 1;
|
static const uint32_t k_EAccountTypeIndividual = 1;
|
||||||
static const int k_EUniverseInvalid = 0;
|
static const int k_EUniverseInvalid = 0;
|
||||||
@@ -1099,7 +1119,7 @@ bool AdminCache::GetUnifiedSteamIdentity(const char *ident, char *out, size_t ma
|
|||||||
&& accountType == k_EAccountTypeIndividual && accountInstance <= k_unSteamUserWebInstance
|
&& accountType == k_EAccountTypeIndividual && accountInstance <= k_unSteamUserWebInstance
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
snprintf(out, maxlen, "%u:%u", accountId & 1, accountId >> 1);
|
ke::SafeSprintf(out, maxlen, "%u:%u", accountId & 1, accountId >> 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1509,7 +1529,7 @@ bool AdminCache::CanAdminTarget(AdminId id, AdminId target)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Fourth, if the targeted admin is immune from targeting admin. */
|
/** Fourth, if the targeted admin is immune from targeting admin. */
|
||||||
int mode = smcore.GetImmunityMode();
|
int mode = bridge->GetImmunityMode();
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
@@ -1556,7 +1576,7 @@ bool AdminCache::CanAdminTarget(AdminId id, AdminId target)
|
|||||||
{
|
{
|
||||||
id = grp_table[i];
|
id = grp_table[i];
|
||||||
num = GetGroupImmunityCount(id);
|
num = GetGroupImmunityCount(id);
|
||||||
for (unsigned int j=0; j<num; i++)
|
for (unsigned int j=0; j<num; j++)
|
||||||
{
|
{
|
||||||
other = GetGroupImmunity(id, j);
|
other = GetGroupImmunity(id, j);
|
||||||
for (unsigned int k=0; k<pUser->grp_count; k++)
|
for (unsigned int k=0; k<pUser->grp_count; k++)
|
||||||
@@ -1577,7 +1597,7 @@ bool AdminCache::FindFlag(char c, AdminFlag *pAdmFlag)
|
|||||||
{
|
{
|
||||||
if (c < 'a'
|
if (c < 'a'
|
||||||
|| c > 'z'
|
|| c > 'z'
|
||||||
|| !g_FlagSet[(unsigned)c - (unsigned)'a'])
|
|| !g_FlagCharSet[(unsigned)c - (unsigned)'a'])
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1592,17 +1612,13 @@ bool AdminCache::FindFlag(char c, AdminFlag *pAdmFlag)
|
|||||||
|
|
||||||
bool AdminCache::FindFlagChar(AdminFlag flag, char *c)
|
bool AdminCache::FindFlagChar(AdminFlag flag, char *c)
|
||||||
{
|
{
|
||||||
if (!g_FlagSet[flag])
|
char flagchar = g_ReverseFlags[flag];
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (c)
|
if (c)
|
||||||
{
|
{
|
||||||
*c = g_ReverseFlags[flag];
|
*c = flagchar;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return flagchar != '?';
|
||||||
}
|
}
|
||||||
|
|
||||||
FlagBits AdminCache::ReadFlagString(const char *flags, const char **end)
|
FlagBits AdminCache::ReadFlagString(const char *flags, const char **end)
|
||||||
@@ -1650,7 +1666,7 @@ bool AdminCache::CanAdminUseCommand(int client, const char *cmd)
|
|||||||
cmd++;
|
cmd++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!smcore.LookForCommandAdminFlags(cmd, &bits))
|
if (!bridge->LookForCommandAdminFlags(cmd, &bits))
|
||||||
{
|
{
|
||||||
if (!GetCommandOverride(cmd, otype, &bits))
|
if (!GetCommandOverride(cmd, otype, &bits))
|
||||||
{
|
{
|
||||||
@@ -1725,7 +1741,7 @@ bool AdminCache::CheckAccess(int client, const char *cmd, FlagBits flags, bool o
|
|||||||
bool found_command = false;
|
bool found_command = false;
|
||||||
if (!override_only)
|
if (!override_only)
|
||||||
{
|
{
|
||||||
found_command = smcore.LookForCommandAdminFlags(cmd, &bits);
|
found_command = bridge->LookForCommandAdminFlags(cmd, &bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found_command)
|
if (!found_command)
|
||||||
@@ -1822,13 +1838,13 @@ bool AdminCache::DumpCache(const char *filename)
|
|||||||
fprintf(fp, "\n\t\t\"Overrides\"\n\t\t{\n");
|
fprintf(fp, "\n\t\t\"Overrides\"\n\t\t{\n");
|
||||||
if (pGroup->pCmdGrpTable != NULL)
|
if (pGroup->pCmdGrpTable != NULL)
|
||||||
{
|
{
|
||||||
for (OverrideMap::iterator iter = pGroup->pCmdTable->iter(); !iter.empty(); iter.next())
|
for (OverrideMap::iterator iter = pGroup->pCmdGrpTable->iter(); !iter.empty(); iter.next())
|
||||||
iterator_group_grp_override(fp, iter->key.chars(), iter->value);
|
iterator_group_grp_override(fp, iter->key.c_str(), iter->value);
|
||||||
}
|
}
|
||||||
if (pGroup->pCmdTable != NULL)
|
if (pGroup->pCmdTable != NULL)
|
||||||
{
|
{
|
||||||
for (OverrideMap::iterator iter = pGroup->pCmdTable->iter(); !iter.empty(); iter.next())
|
for (OverrideMap::iterator iter = pGroup->pCmdTable->iter(); !iter.empty(); iter.next())
|
||||||
iterator_group_basic_override(fp, iter->key.chars(), iter->value);
|
iterator_group_basic_override(fp, iter->key.c_str(), iter->value);
|
||||||
}
|
}
|
||||||
fprintf(fp, "\t\t}\n");
|
fprintf(fp, "\t\t}\n");
|
||||||
|
|
||||||
@@ -1903,9 +1919,9 @@ bool AdminCache::DumpCache(const char *filename)
|
|||||||
|
|
||||||
fprintf(fp, "\"Overrides\"\n{\n");
|
fprintf(fp, "\"Overrides\"\n{\n");
|
||||||
for (FlagMap::iterator iter = m_CmdGrpOverrides.iter(); !iter.empty(); iter.next())
|
for (FlagMap::iterator iter = m_CmdGrpOverrides.iter(); !iter.empty(); iter.next())
|
||||||
iterator_glob_grp_override(fp, iter->key.chars(), iter->value);
|
iterator_glob_grp_override(fp, iter->key.c_str(), iter->value);
|
||||||
for (FlagMap::iterator iter = m_CmdOverrides.iter(); !iter.empty(); iter.next())
|
for (FlagMap::iterator iter = m_CmdOverrides.iter(); !iter.empty(); iter.next())
|
||||||
iterator_glob_basic_override(fp, iter->key.chars(), iter->value);
|
iterator_glob_basic_override(fp, iter->key.c_str(), iter->value);
|
||||||
fprintf(fp, "}\n");
|
fprintf(fp, "}\n");
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
@@ -1941,8 +1957,7 @@ AdminUser *AdminCache::GetUser(AdminId aid)
|
|||||||
|
|
||||||
const char *AdminCache::GetMethodName(unsigned int index)
|
const char *AdminCache::GetMethodName(unsigned int index)
|
||||||
{
|
{
|
||||||
List<AuthMethod *>::iterator iter;
|
for (auto iter=m_AuthMethods.begin();
|
||||||
for (iter=m_AuthMethods.begin();
|
|
||||||
iter!=m_AuthMethods.end();
|
iter!=m_AuthMethods.end();
|
||||||
iter++)
|
iter++)
|
||||||
{
|
{
|
||||||
|
|||||||
+10
-8
@@ -36,14 +36,12 @@
|
|||||||
#include <IAdminSystem.h>
|
#include <IAdminSystem.h>
|
||||||
#include "sm_memtable.h"
|
#include "sm_memtable.h"
|
||||||
#include <sm_trie.h>
|
#include <sm_trie.h>
|
||||||
#include <sh_list.h>
|
#include <list>
|
||||||
#include <sh_string.h>
|
#include <string>
|
||||||
#include <IForwardSys.h>
|
#include <IForwardSys.h>
|
||||||
#include <sm_stringhashmap.h>
|
#include <sm_hashmap.h>
|
||||||
#include <sm_namehashset.h>
|
#include <sm_namehashset.h>
|
||||||
|
|
||||||
using namespace SourceHook;
|
|
||||||
|
|
||||||
#define GRP_MAGIC_SET 0xDEADFADE
|
#define GRP_MAGIC_SET 0xDEADFADE
|
||||||
#define GRP_MAGIC_UNSET 0xFACEFACE
|
#define GRP_MAGIC_UNSET 0xFACEFACE
|
||||||
#define USR_MAGIC_SET 0xDEADFACE
|
#define USR_MAGIC_SET 0xDEADFACE
|
||||||
@@ -70,7 +68,7 @@ struct AdminGroup
|
|||||||
|
|
||||||
struct AuthMethod
|
struct AuthMethod
|
||||||
{
|
{
|
||||||
String name;
|
std::string name;
|
||||||
StringHashMap<AdminId> identities;
|
StringHashMap<AdminId> identities;
|
||||||
|
|
||||||
AuthMethod(const char *name)
|
AuthMethod(const char *name)
|
||||||
@@ -82,6 +80,10 @@ struct AuthMethod
|
|||||||
{
|
{
|
||||||
return strcmp(name, method->name.c_str()) == 0;
|
return strcmp(name, method->name.c_str()) == 0;
|
||||||
}
|
}
|
||||||
|
static inline uint32_t hash(const detail::CharsAndLength &key)
|
||||||
|
{
|
||||||
|
return key.hash();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct UserAuth
|
struct UserAuth
|
||||||
@@ -210,8 +212,8 @@ public:
|
|||||||
int m_LastGroup;
|
int m_LastGroup;
|
||||||
int m_FreeGroupList;
|
int m_FreeGroupList;
|
||||||
StringHashMap<GroupId> m_Groups;
|
StringHashMap<GroupId> m_Groups;
|
||||||
List<IAdminListener *> m_hooks;
|
std::list<IAdminListener *> m_hooks;
|
||||||
List<AuthMethod *> m_AuthMethods;
|
std::list<AuthMethod *> m_AuthMethods;
|
||||||
NameHashSet<AuthMethod *> m_AuthTables;
|
NameHashSet<AuthMethod *> m_AuthTables;
|
||||||
IForward *m_pCacheFwd;
|
IForward *m_pCacheFwd;
|
||||||
int m_FirstUser;
|
int m_FirstUser;
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ BaseWorker::BaseWorker(IThreadWorkerCallbacks *hooks) :
|
|||||||
|
|
||||||
BaseWorker::~BaseWorker()
|
BaseWorker::~BaseWorker()
|
||||||
{
|
{
|
||||||
if (m_state != Worker_Stopped || m_state != Worker_Invalid)
|
if (m_state != Worker_Stopped && m_state != Worker_Invalid)
|
||||||
Stop(true);
|
Stop(true);
|
||||||
|
|
||||||
if (m_ThreadQueue.size())
|
if (m_ThreadQueue.size())
|
||||||
@@ -109,10 +109,9 @@ SWThreadHandle *BaseWorker::PopThreadFromQueue()
|
|||||||
if (!m_ThreadQueue.size())
|
if (!m_ThreadQueue.size())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
SourceHook::List<SWThreadHandle *>::iterator begin;
|
|
||||||
SWThreadHandle *swt;
|
SWThreadHandle *swt;
|
||||||
|
|
||||||
begin = m_ThreadQueue.begin();
|
auto begin = m_ThreadQueue.begin();
|
||||||
swt = (*begin);
|
swt = (*begin);
|
||||||
m_ThreadQueue.erase(begin);
|
m_ThreadQueue.erase(begin);
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
#ifndef _INCLUDE_SOURCEMOD_BASEWORKER_H
|
#ifndef _INCLUDE_SOURCEMOD_BASEWORKER_H
|
||||||
#define _INCLUDE_SOURCEMOD_BASEWORKER_H
|
#define _INCLUDE_SOURCEMOD_BASEWORKER_H
|
||||||
|
|
||||||
#include "sh_list.h"
|
#include <list>
|
||||||
#include "ThreadSupport.h"
|
#include "ThreadSupport.h"
|
||||||
|
|
||||||
#define SM_DEFAULT_THREADS_PER_FRAME 1
|
#define SM_DEFAULT_THREADS_PER_FRAME 1
|
||||||
@@ -43,6 +43,7 @@ class BaseWorker;
|
|||||||
class SWThreadHandle : public IThreadHandle
|
class SWThreadHandle : public IThreadHandle
|
||||||
{
|
{
|
||||||
friend class BaseWorker;
|
friend class BaseWorker;
|
||||||
|
friend class CompatWorker;
|
||||||
public:
|
public:
|
||||||
SWThreadHandle(IThreadCreator *parent, const ThreadParams *p, IThread *thread);
|
SWThreadHandle(IThreadCreator *parent, const ThreadParams *p, IThread *thread);
|
||||||
IThread *GetThread();
|
IThread *GetThread();
|
||||||
@@ -95,7 +96,7 @@ public: //BaseWorker
|
|||||||
virtual void AddThreadToQueue(SWThreadHandle *pHandle);
|
virtual void AddThreadToQueue(SWThreadHandle *pHandle);
|
||||||
virtual SWThreadHandle *PopThreadFromQueue();
|
virtual SWThreadHandle *PopThreadFromQueue();
|
||||||
protected:
|
protected:
|
||||||
SourceHook::List<SWThreadHandle *> m_ThreadQueue;
|
std::list<SWThreadHandle *> m_ThreadQueue;
|
||||||
unsigned int m_perFrame;
|
unsigned int m_perFrame;
|
||||||
volatile WorkerState m_state;
|
volatile WorkerState m_state;
|
||||||
IThreadWorkerCallbacks *m_pHooks;
|
IThreadWorkerCallbacks *m_pHooks;
|
||||||
@@ -0,0 +1,304 @@
|
|||||||
|
/**
|
||||||
|
* vim: set ts=4 :
|
||||||
|
* =============================================================================
|
||||||
|
* SourceMod
|
||||||
|
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||||
|
* =============================================================================
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
* Free Software Foundation.
|
||||||
|
*
|
||||||
|
* 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
* this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
* or <http://www.sourcemod.net/license.php>.
|
||||||
|
*
|
||||||
|
* Version: $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "CDataPack.h"
|
||||||
|
|
||||||
|
CDataPack::CDataPack()
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
CDataPack::~CDataPack()
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDataPack::Initialize()
|
||||||
|
{
|
||||||
|
position = 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
} while (this->RemoveItem());
|
||||||
|
|
||||||
|
elements.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDataPack::ResetSize()
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t CDataPack::CreateMemory(size_t size, void **addr)
|
||||||
|
{
|
||||||
|
InternalPack val;
|
||||||
|
val.type = CDataPackType::Raw;
|
||||||
|
val.pData.vval = new uint8_t[size + sizeof(size)];
|
||||||
|
reinterpret_cast<size_t *>(val.pData.vval)[0] = size;
|
||||||
|
elements.emplace(elements.begin() + position, val);
|
||||||
|
|
||||||
|
return position++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDataPack::PackCell(cell_t cell)
|
||||||
|
{
|
||||||
|
InternalPack val;
|
||||||
|
val.type = CDataPackType::Cell;
|
||||||
|
val.pData.cval = cell;
|
||||||
|
elements.emplace(elements.begin() + position, val);
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDataPack::PackFunction(cell_t function)
|
||||||
|
{
|
||||||
|
InternalPack val;
|
||||||
|
val.type = CDataPackType::Function;
|
||||||
|
val.pData.cval = function;
|
||||||
|
elements.emplace(elements.begin() + position, val);
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDataPack::PackFloat(float floatval)
|
||||||
|
{
|
||||||
|
InternalPack val;
|
||||||
|
val.type = CDataPackType::Float;
|
||||||
|
val.pData.fval = floatval;
|
||||||
|
elements.emplace(elements.begin() + position, val);
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDataPack::PackString(const char *string)
|
||||||
|
{
|
||||||
|
InternalPack val;
|
||||||
|
val.type = CDataPackType::String;
|
||||||
|
std::string *sval = new std::string(string);
|
||||||
|
val.pData.sval = sval;
|
||||||
|
elements.emplace(elements.begin() + position, val);
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDataPack::PackCellArray(cell_t const *vals, cell_t count)
|
||||||
|
{
|
||||||
|
InternalPack val;
|
||||||
|
val.type = CDataPackType::CellArray;
|
||||||
|
|
||||||
|
val.pData.aval = new cell_t [count + 1];
|
||||||
|
memcpy(&val.pData.aval[1], vals, sizeof(cell_t) * count);
|
||||||
|
val.pData.aval[0] = count;
|
||||||
|
elements.emplace(elements.begin() + position, val);
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDataPack::PackFloatArray(cell_t const *vals, cell_t count)
|
||||||
|
{
|
||||||
|
InternalPack val;
|
||||||
|
val.type = CDataPackType::FloatArray;
|
||||||
|
|
||||||
|
val.pData.aval = new cell_t [count + 1];
|
||||||
|
memcpy(&val.pData.aval[1], vals, sizeof(cell_t) * count);
|
||||||
|
val.pData.aval[0] = count;
|
||||||
|
elements.emplace(elements.begin() + position, val);
|
||||||
|
position++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDataPack::Reset() const
|
||||||
|
{
|
||||||
|
position = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t CDataPack::GetPosition() const
|
||||||
|
{
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CDataPack::SetPosition(size_t pos) const
|
||||||
|
{
|
||||||
|
if (pos > elements.size())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
position = pos;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
cell_t CDataPack::ReadCell() const
|
||||||
|
{
|
||||||
|
if (!IsReadable() || elements[position].type != CDataPackType::Cell)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return elements[position++].pData.cval;
|
||||||
|
}
|
||||||
|
|
||||||
|
cell_t CDataPack::ReadFunction() const
|
||||||
|
{
|
||||||
|
if (!IsReadable() || elements[position].type != CDataPackType::Function)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return elements[position++].pData.cval;
|
||||||
|
}
|
||||||
|
|
||||||
|
float CDataPack::ReadFloat() const
|
||||||
|
{
|
||||||
|
if (!IsReadable() || elements[position].type != CDataPackType::Float)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return elements[position++].pData.fval;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CDataPack::IsReadable(size_t bytes) const
|
||||||
|
{
|
||||||
|
return (position < elements.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *CDataPack::ReadString(size_t *len) const
|
||||||
|
{
|
||||||
|
if (!IsReadable() || elements[position].type != CDataPackType::String)
|
||||||
|
{
|
||||||
|
if (len)
|
||||||
|
*len = 0;
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string &val = *elements[position++].pData.sval;
|
||||||
|
if (len)
|
||||||
|
*len = val.size();
|
||||||
|
|
||||||
|
return val.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
|
cell_t *CDataPack::ReadCellArray(cell_t *size) const
|
||||||
|
{
|
||||||
|
if (!IsReadable() || elements[position].type != CDataPackType::CellArray)
|
||||||
|
{
|
||||||
|
if(size)
|
||||||
|
*size = 0;
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
cell_t *val = elements[position].pData.aval;
|
||||||
|
cell_t *ptr = &(val[1]);
|
||||||
|
++position;
|
||||||
|
|
||||||
|
if (size)
|
||||||
|
*size = val[0];
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
cell_t *CDataPack::ReadFloatArray(cell_t *size) const
|
||||||
|
{
|
||||||
|
if (!IsReadable() || elements[position].type != CDataPackType::FloatArray)
|
||||||
|
{
|
||||||
|
if(size)
|
||||||
|
*size = 0;
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
cell_t *val = elements[position].pData.aval;
|
||||||
|
cell_t *ptr = &(val[1]);
|
||||||
|
++position;
|
||||||
|
|
||||||
|
if (size)
|
||||||
|
*size = val[0];
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *CDataPack::ReadMemory(size_t *size) const
|
||||||
|
{
|
||||||
|
void *ptr = nullptr;
|
||||||
|
if (!IsReadable() || elements[position].type != CDataPackType::Raw)
|
||||||
|
return ptr;
|
||||||
|
|
||||||
|
size_t *val = reinterpret_cast<size_t *>(elements[position].pData.vval);
|
||||||
|
ptr = &(val[1]);
|
||||||
|
++position;
|
||||||
|
|
||||||
|
if (size)
|
||||||
|
*size = val[0]; /* Egor!!!! */
|
||||||
|
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CDataPack::RemoveItem(size_t pos)
|
||||||
|
{
|
||||||
|
if (!elements.size())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pos == static_cast<size_t>(-1))
|
||||||
|
{
|
||||||
|
pos = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pos >= elements.size())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pos < position) // we're deleting under us, step back
|
||||||
|
{
|
||||||
|
--position;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (elements[pos].type)
|
||||||
|
{
|
||||||
|
case CDataPackType::Raw:
|
||||||
|
{
|
||||||
|
delete [] elements[pos].pData.vval;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case CDataPackType::String:
|
||||||
|
{
|
||||||
|
delete elements[pos].pData.sval;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case CDataPackType::CellArray:
|
||||||
|
case CDataPackType::FloatArray:
|
||||||
|
{
|
||||||
|
delete [] elements[pos].pData.aval;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
elements.erase(elements.begin() + pos);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -0,0 +1,226 @@
|
|||||||
|
/**
|
||||||
|
* vim: set ts=4 :
|
||||||
|
* =============================================================================
|
||||||
|
* SourceMod
|
||||||
|
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
|
||||||
|
* =============================================================================
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify it under
|
||||||
|
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||||
|
* Free Software Foundation.
|
||||||
|
*
|
||||||
|
* 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, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* As a special exception, AlliedModders LLC gives you permission to link the
|
||||||
|
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
||||||
|
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
||||||
|
* by the Valve Corporation. You must obey the GNU General Public License in
|
||||||
|
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
||||||
|
* this exception to all derivative works. AlliedModders LLC defines further
|
||||||
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
||||||
|
* or <http://www.sourcemod.net/license.php>.
|
||||||
|
*
|
||||||
|
* Version: $Id$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _INCLUDE_SOURCEMOD_CDATAPACK_H_
|
||||||
|
#define _INCLUDE_SOURCEMOD_CDATAPACK_H_
|
||||||
|
|
||||||
|
#include <ISourceMod.h>
|
||||||
|
#include <amtl/am-vector.h>
|
||||||
|
#include <amtl/am-string.h>
|
||||||
|
|
||||||
|
using namespace SourceMod;
|
||||||
|
|
||||||
|
enum CDataPackType {
|
||||||
|
Raw,
|
||||||
|
Cell,
|
||||||
|
Float,
|
||||||
|
String,
|
||||||
|
Function,
|
||||||
|
CellArray,
|
||||||
|
FloatArray,
|
||||||
|
};
|
||||||
|
|
||||||
|
class CDataPack
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CDataPack();
|
||||||
|
~CDataPack();
|
||||||
|
|
||||||
|
public: // Originally IDataReader
|
||||||
|
/**
|
||||||
|
* @brief Resets the position in the data stream to the beginning.
|
||||||
|
*/
|
||||||
|
void Reset() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Retrieves the current stream position.
|
||||||
|
*
|
||||||
|
* @return Index into the stream.
|
||||||
|
*/
|
||||||
|
size_t GetPosition() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Sets the current stream position.
|
||||||
|
*
|
||||||
|
* @param pos Index to set the stream at.
|
||||||
|
* @return True if succeeded, false if out of bounds.
|
||||||
|
*/
|
||||||
|
bool SetPosition(size_t pos) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reads one cell from the data stream.
|
||||||
|
*
|
||||||
|
* @return A cell read from the current position.
|
||||||
|
*/
|
||||||
|
cell_t ReadCell() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reads one float from the data stream.
|
||||||
|
*
|
||||||
|
* @return A float read from the current position.
|
||||||
|
*/
|
||||||
|
float ReadFloat() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reads an array of values from the data stream.
|
||||||
|
*
|
||||||
|
* @param len The size of the array stored at this position to return.
|
||||||
|
* @return A cell array read from the current position.
|
||||||
|
*/
|
||||||
|
cell_t *ReadCellArray(cell_t *len) const;
|
||||||
|
/**
|
||||||
|
* @brief Reads an array of values from the data stream.
|
||||||
|
*
|
||||||
|
* @param len The size of the array stored at this position to return.
|
||||||
|
* @return A cell array read from the current position.
|
||||||
|
*/
|
||||||
|
cell_t *ReadFloatArray(cell_t *len) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returns whether or not a specified number of bytes from the current stream
|
||||||
|
* position to the end can be read.
|
||||||
|
*
|
||||||
|
* @param bytes Number of bytes to simulate reading.
|
||||||
|
* @return True if can be read, false otherwise.
|
||||||
|
*/
|
||||||
|
bool IsReadable(size_t bytes = 0) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reads a string from the data stream.
|
||||||
|
*
|
||||||
|
* @param len Optional pointer to store the string length.
|
||||||
|
* @return Pointer to the string, or NULL if out of bounds.
|
||||||
|
*/
|
||||||
|
const char *ReadString(size_t *len) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reads the current position as a generic data type.
|
||||||
|
*
|
||||||
|
* @param size Optional pointer to store the size of the data type.
|
||||||
|
* @return Pointer to the data, or NULL if out of bounds.
|
||||||
|
*/
|
||||||
|
void *ReadMemory(size_t *size) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reads a function pointer from the data stream.
|
||||||
|
*
|
||||||
|
* @return A function pointer read from the current position.
|
||||||
|
*/
|
||||||
|
cell_t ReadFunction() const;
|
||||||
|
|
||||||
|
public: // Originally IDataPack
|
||||||
|
/**
|
||||||
|
* @brief Resets the used size of the stream back to zero.
|
||||||
|
*/
|
||||||
|
void ResetSize();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packs one cell into the data stream.
|
||||||
|
*
|
||||||
|
* @param cell Cell value to write.
|
||||||
|
*/
|
||||||
|
void PackCell(cell_t cell);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packs one float into the data stream.
|
||||||
|
*
|
||||||
|
* @param val Float value to write.
|
||||||
|
*/
|
||||||
|
void PackFloat(float val);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packs one string into the data stream.
|
||||||
|
* The length is recorded as well for buffer overrun protection.
|
||||||
|
*
|
||||||
|
* @param string String to write.
|
||||||
|
*/
|
||||||
|
void PackString(const char *string);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packs an array of cells into the data stream.
|
||||||
|
*
|
||||||
|
* @param vals Cells to write.
|
||||||
|
* @param count Number of cells.
|
||||||
|
*/
|
||||||
|
void PackCellArray(cell_t const *vals, cell_t count);
|
||||||
|
/**
|
||||||
|
* @brief Packs an array of cells into the data stream.
|
||||||
|
*
|
||||||
|
* @param vals Cells to write.
|
||||||
|
* @param count Number of cells.
|
||||||
|
*/
|
||||||
|
void PackFloatArray(cell_t const *vals, cell_t count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Creates a generic block of memory in the stream.
|
||||||
|
*
|
||||||
|
* Note that the pointer it returns can be invalidated on further
|
||||||
|
* writing, since the stream size may grow. You may need to double back
|
||||||
|
* and fetch the pointer again.
|
||||||
|
*
|
||||||
|
* @param size Size of the memory to create in the stream.
|
||||||
|
* @param addr Optional pointer to store the relocated memory address.
|
||||||
|
* @return Current position of the stream beforehand.
|
||||||
|
*/
|
||||||
|
size_t CreateMemory(size_t size, void **addr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packs one function pointer into the data stream.
|
||||||
|
*
|
||||||
|
* @param function The function pointer to write.
|
||||||
|
*/
|
||||||
|
void PackFunction(cell_t function);
|
||||||
|
|
||||||
|
public:
|
||||||
|
void Initialize();
|
||||||
|
inline size_t GetCapacity() const { return this->elements.size(); };
|
||||||
|
inline CDataPackType GetCurrentType(void) const { return this->elements[this->position].type; };
|
||||||
|
bool RemoveItem(size_t pos = -1);
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef union {
|
||||||
|
cell_t cval;
|
||||||
|
float fval;
|
||||||
|
uint8_t *vval;
|
||||||
|
std::string *sval;
|
||||||
|
cell_t *aval;
|
||||||
|
} InternalPackValue;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
InternalPackValue pData;
|
||||||
|
CDataPackType type;
|
||||||
|
} InternalPack;
|
||||||
|
|
||||||
|
std::vector<InternalPack> elements;
|
||||||
|
mutable size_t position;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //_INCLUDE_SOURCEMOD_CDATAPACK_H_
|
||||||
+54
-11
@@ -34,10 +34,12 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ICellArray.h>
|
||||||
|
#include <amtl/am-bits.h>
|
||||||
|
|
||||||
extern HandleType_t htCellArray;
|
extern HandleType_t htCellArray;
|
||||||
|
|
||||||
class CellArray
|
class CellArray : public ICellArray
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CellArray(size_t blocksize) : m_Data(NULL), m_BlockSize(blocksize), m_AllocSize(0), m_Size(0)
|
CellArray(size_t blocksize) : m_Data(NULL), m_BlockSize(blocksize), m_AllocSize(0), m_Size(0)
|
||||||
@@ -49,6 +51,31 @@ public:
|
|||||||
free(m_Data);
|
free(m_Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Creates a cell array object.
|
||||||
|
*
|
||||||
|
* @param blocksize The number of cells each member of the array can
|
||||||
|
* hold. For example, 32 cells is equivalent to:
|
||||||
|
* new Array[X][32]
|
||||||
|
* @return A new ICellArray object.
|
||||||
|
*/
|
||||||
|
static ICellArray *New(size_t blocksize)
|
||||||
|
{
|
||||||
|
return new CellArray(blocksize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Releases a cell array's resources.
|
||||||
|
*
|
||||||
|
* @param pack An ICellArray object to release.
|
||||||
|
*/
|
||||||
|
static void Free(ICellArray *arr)
|
||||||
|
{
|
||||||
|
delete arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ICellArray
|
||||||
|
public:
|
||||||
size_t size() const
|
size_t size() const
|
||||||
{
|
{
|
||||||
return m_Size;
|
return m_Size;
|
||||||
@@ -154,12 +181,18 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CellArray *clone()
|
ICellArray *clone()
|
||||||
{
|
{
|
||||||
CellArray *array = new CellArray(m_BlockSize);
|
CellArray *array = new CellArray(m_BlockSize);
|
||||||
array->m_AllocSize = m_AllocSize;
|
array->m_AllocSize = m_AllocSize;
|
||||||
array->m_Size = m_Size;
|
array->m_Size = m_Size;
|
||||||
array->m_Data = (cell_t *)malloc(sizeof(cell_t) * m_BlockSize * m_AllocSize);
|
array->m_Data = (cell_t *)malloc(sizeof(cell_t) * m_BlockSize * m_AllocSize);
|
||||||
|
if (!array->m_Data)
|
||||||
|
{
|
||||||
|
delete array;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
memcpy(array->m_Data, m_Data, sizeof(cell_t) * m_BlockSize * m_Size);
|
memcpy(array->m_Data, m_Data, sizeof(cell_t) * m_BlockSize * m_Size);
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
@@ -182,24 +215,34 @@ private:
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
size_t newAllocSize = m_AllocSize;
|
||||||
/* Set a base allocation size of 8 items */
|
/* Set a base allocation size of 8 items */
|
||||||
if (!m_AllocSize)
|
if (!newAllocSize)
|
||||||
{
|
{
|
||||||
m_AllocSize = 8;
|
newAllocSize = 8;
|
||||||
|
}
|
||||||
|
if (!ke::IsUintPtrAddSafe(m_Size, count))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
/* If it's not enough, keep doubling */
|
/* If it's not enough, keep doubling */
|
||||||
while (m_Size + count > m_AllocSize)
|
while (m_Size + count > newAllocSize)
|
||||||
{
|
{
|
||||||
m_AllocSize *= 2;
|
if (!ke::IsUintPtrMultiplySafe(newAllocSize, 2))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
newAllocSize *= 2;
|
||||||
}
|
}
|
||||||
/* finally, allocate the new block */
|
/* finally, allocate the new block */
|
||||||
if (m_Data)
|
cell_t *data = static_cast<cell_t*>(realloc(m_Data, sizeof(cell_t) * m_BlockSize * newAllocSize));
|
||||||
|
/* Update state if allocation was successful */
|
||||||
|
if (data)
|
||||||
{
|
{
|
||||||
m_Data = (cell_t *)realloc(m_Data, sizeof(cell_t) * m_BlockSize * m_AllocSize);
|
m_AllocSize = newAllocSize;
|
||||||
} else {
|
m_Data = data;
|
||||||
m_Data = (cell_t *)malloc(sizeof(cell_t) * m_BlockSize * m_AllocSize);
|
|
||||||
}
|
}
|
||||||
return (m_Data != NULL);
|
return (data != nullptr);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
cell_t *m_Data;
|
cell_t *m_Data;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user