228 Commits

Author SHA1 Message Date
45bccd7a7f Tagged 1.76b 2007-02-02 05:10:54 +00:00
e8a30e7187 bumped version 2006-11-01 00:33:30 +00:00
8a93673276 2006-10-31 22:53:29 +00:00
ece4db4f43 oh no, new version number 2006-10-31 20:37:43 +00:00
8b8cc3dd6b Fixed bug am46630: rename_file did not have a relative location version 2006-10-31 20:18:44 +00:00
b33e76d9c4 Fixed bug am46559 2006-10-31 19:48:47 +00:00
6fb6d7d399 Fixed bug am46699 - dod stats.sma did not show multi-lingual menus correctly 2006-10-31 19:42:34 +00:00
5649a17502 fixed silly translation bug 2006-10-31 19:38:30 +00:00
5cfc2df359 fixed potential in-game bug 2006-10-31 19:36:47 +00:00
1ac390b54c Fixed version # 2006-10-31 19:31:54 +00:00
102c2b219f Fixed bug am46336 - could not compile TraceLn 2006-10-27 05:53:09 +00:00
4e1d420495 added AMX_ERR_GENERAL to the error list 2006-10-27 05:49:34 +00:00
e93e75fa39 Bumped version numbers 2006-10-27 05:47:38 +00:00
90c213bc6d fixed querying invalid players 2006-10-27 05:41:04 +00:00
6c3e7e7ee0 removed another get_players("ae") 2006-10-27 05:40:09 +00:00
8a2528108d Fixed bug am46378 2006-10-25 16:54:37 +00:00
a65d65bee4 fix for bug am46266: TFC team names not picking up 2006-10-24 22:57:19 +00:00
483403aa3a Fixed bug am46335 - text spacing not aligned in adminchat 2006-10-24 22:30:15 +00:00
2a1dbf5247 Fixed bug am46350 2006-10-24 17:13:02 +00:00
7aa687eb69 Attempted a patch for am46340 2006-10-24 17:09:28 +00:00
699cb2a6d6 fixed bug at45677 2006-10-22 19:15:36 +00:00
7b82bc7b76 several bug fixes in the auto-update system, bumped version to 1.4.3 final and improved code snippets feature (can now append or insert snippet into new line) 2006-10-22 18:56:39 +00:00
ed43b8a5ac Changed to use CreateMultiForwardEx() instead 2006-10-22 03:52:02 +00:00
d2ebca38a1 Experimental addition to CreateMultiForward() for bcompat 2006-10-22 03:49:23 +00:00
d542015214 Fixed bug am46112 2006-10-22 00:45:33 +00:00
d84c3a3798 Fixed bug am46058, unpausing stopped plugins 2006-10-21 21:48:24 +00:00
405d9ff48e bumped trunk version 2006-10-21 21:27:07 +00:00
a63c728471 added two new tests to the menu test suite 2006-10-21 21:13:57 +00:00
a60e9d205b fixed bug where blanks misaligned the item selection process 2006-10-21 21:13:39 +00:00
553a950b98 added comment :( yes we broke backwards compat 2006-10-21 20:20:44 +00:00
955e827b19 Fixed bug am45492 (stats always resetting) 2006-10-21 19:23:16 +00:00
00380cfe4c fixed a bug in get_func_id (thanks P34CH_34732) 2006-10-02 06:12:02 +00:00
12ecf026db hack for backwards compat layer (thanks suicid3) 2006-10-02 06:07:38 +00:00
3fa6cd3227 added a timeout test which does not work, thanks MySQL 2006-10-01 19:59:27 +00:00
fe1ebfe7bb fix for 45337 and some other little things 2006-10-01 19:46:56 +00:00
f3057efd7d updated the test suite 2006-10-01 18:36:15 +00:00
39d5ea94fb Added extra param to is_in_viewcone to switch between a 2D and 3D calculation
Neither is still as accurate as I want them to be though :\
2006-10-01 06:08:39 +00:00
90f11b52bc Fixed am45318 - Some wrong constants from TraceResult enum 2006-10-01 02:39:59 +00:00
9740f6469d this feature is just for sawce (updated go to line dialog) 2006-09-30 19:03:49 +00:00
461e7de151 fixed bug at45362 2006-09-30 18:49:28 +00:00
c2695a8cd8 updated version # 2006-09-26 00:25:01 +00:00
5ded9eef2a Bumped version numbers to 1.76a 2006-09-25 23:48:07 +00:00
44617778c7 Fixed bug am40911 (round kill stats persisting for spectators) 2006-09-25 23:04:33 +00:00
647d226764 synchronized more hud messages as per am45020 2006-09-25 17:34:33 +00:00
f086273d2b Attempt at accuracy improvement for is_in_viewcone with 3D calculation (am44838) 2006-09-22 15:11:51 +00:00
afde57b27e fixed bug am45088 (studio icon left on desktop after uninstall) 2006-09-22 14:49:04 +00:00
c4453a9593 fixed tense error in English 2006-09-22 14:46:38 +00:00
020b3a5963 test fix for bug am44973 (knife headshots) 2006-09-22 03:47:04 +00:00
3720810b61 fixed bug am44694 (is_user_alive() on TFC connect failing) 2006-09-21 23:33:05 +00:00
98e20e0fc7 Fixed translation errors from am45015 2006-09-21 17:43:16 +00:00
e72aff5c14 Fixed bug am44956 (extra plugin file lists not working) 2006-09-21 17:18:04 +00:00
63bc8885c9 committed fix for bug am45017 (phrase not translated) 2006-09-21 17:01:21 +00:00
ff8fd747c5 Fixed bug am44964 (thread crash on bad database) 2006-09-21 16:54:14 +00:00
98278b7bb5 small bug fix, bumped version to 1.76a 2006-09-20 15:12:49 +00:00
09df281556 Fixed am44998 2006-09-20 02:50:58 +00:00
4cc460cfbe component update, fixed small bug 2006-09-17 10:57:30 +00:00
947cb5f79d component update, fixed metamod plugins.ini bug once and for all 2006-09-16 23:26:24 +00:00
73386b12c5 added silent backwards compatibility for a broken plugin 2006-09-16 00:16:13 +00:00
57160763af Fixed threaded queries not having an IQuery assignment 2006-09-15 23:11:35 +00:00
1f0778b14e Fixed threader not checking the state on looping 2006-09-15 21:39:20 +00:00
3c923170a9 whoa, forgot a SEMICOLON 2006-09-14 08:06:08 +00:00
09beb4b81e Fixed bug am44776 2006-09-14 08:00:55 +00:00
f48aea7a72 Merged in rebuilds of compiler for latest changes 2006-09-14 07:45:54 +00:00
63ad5727ef this SHOULD fix the ftp bug 2006-09-13 21:11:53 +00:00
61525e9638 fix for getFuncsNum() on invalid forward 2006-09-13 19:46:32 +00:00
918e1c3195 Better, but still not perfect. :( 2006-09-13 13:44:37 +00:00
6e56aed778 More tiny bcompat stuff. admincmd is now source compatible at least 2006-09-13 10:58:47 +00:00
87c3e1dc82 attempt for bug am44778 - plugin_log() did not function in logevents properly 2006-09-13 06:36:59 +00:00
d925dc6e41 bugfix: correct string length computation in replace_all 2006-09-12 13:26:40 +00:00
651c5d9f01 added more api to help with amxmod compat layer
cleaned up some more bcompat stuff
2006-09-12 07:59:56 +00:00
4f8917ec44 experimental hack fix for code generation bug 2006-09-12 07:42:15 +00:00
1c265733e1 small fix 2006-09-11 16:56:25 +00:00
14a068532f this should fix the bug where metamod's plugins.ini is being overwritten even if it already contains an entry of amxx's mm dll 2006-09-11 16:53:26 +00:00
3c379469d5 added get_cmdaccess() 2006-09-10 22:16:04 +00:00
2df8b4269e fixed bcompat trans + optimized it a bit
added bcompat trans support to format() and copy()
2006-09-10 22:08:52 +00:00
3d74b7cf09 this should have been disabled by default 2006-09-10 18:20:51 +00:00
47e2214f09 Synced MSVC8 project for engine 2006-09-10 16:47:49 +00:00
4413e54058 LogType checking is not necessary, LogError is always type 1 2006-09-10 12:07:01 +00:00
14aff9b19b added simple access level wrappers (Obbin) 2006-09-10 10:14:58 +00:00
38cb94050e updated for latest source tree 2006-09-10 09:25:27 +00:00
c294b91ca4 fixed up module support 2006-09-10 09:21:09 +00:00
d95f794844 rewrote replace_all()
added replace_all() tests
2006-09-10 08:15:00 +00:00
3754604686 Fixed a serious bug in replace_all() that could make replaces fail or corrupt random data 2006-09-10 07:23:08 +00:00
4bd356079c testsuite now included 2006-09-10 06:46:06 +00:00
c67e19a62f updated credits + look for 1.76 2006-09-10 06:35:54 +00:00
96c29d5376 merged linux build of latest compiler 2006-09-10 06:35:19 +00:00
65eb0279b2 merged in compiler change for amxmod_compat 2006-09-10 06:33:55 +00:00
c287985a66 fixed up build process 2006-09-10 06:29:22 +00:00
1b9ef4d268 2006-09-10 05:16:26 +00:00
02fb807a0b Added request am44517 (jRaven, spectator team) 2006-09-10 05:13:03 +00:00
f880fc6ee9 added request am44229 - more error log info 2006-09-10 04:52:43 +00:00
f6f6bcc356 added a note to hostage natives for CZ 2006-09-10 04:36:44 +00:00
4f95899d2e Added request am44580 (simple query w/ formatting) 2006-09-10 03:46:35 +00:00
adf12bf348 potential fix for am44179 (array is too small) 2006-09-10 03:32:46 +00:00
c7febb4447 fix for issue am44593 2006-09-10 03:01:21 +00:00
77e4d85002 fixed up a callfunc issue and added copyback parameter 2006-09-10 02:30:10 +00:00
418efa4088 fixed bug am44544 (log forward broken) 2006-09-10 01:08:29 +00:00
4599b59834 corrected issue am44595 2006-09-10 00:51:35 +00:00
751e8e6299 Might as well update this too while I'm at it (Kugatsu, Septiembre, September!) 2006-09-09 20:27:09 +00:00
4eb8c4e295 Synced this or something... 2006-09-09 20:21:29 +00:00
5a4b1d2f03 Fixed some GCC warnings for Werror 2006-09-09 20:12:50 +00:00
b5498818a3 updated the GEOIP API 2006-09-09 11:41:48 +00:00
5286672268 finalizing rc3 builds 2006-09-09 03:29:13 +00:00
8df33abd70 initial import of the bcompat plugins (userland layer) 2006-09-08 14:49:54 +00:00
38e7b9ff58 unbroke the build 2006-09-08 14:46:34 +00:00
621c120b71 finished merging in the glorious bcompat changes 2006-09-08 14:11:29 +00:00
c9c2943c05 MySQL and SQLite can actually use 4.1 here... Also libstdc++ == ugh 2006-09-04 08:28:08 +00:00
ed5395a54a AMD64 building fixes and such 2006-09-03 03:48:54 +00:00
557958b408 Removed some amxmod compat stuff for now so this can actually compile and link properly again 2006-09-03 02:39:13 +00:00
2905217607 Fixed this o_O 2006-09-02 08:08:05 +00:00
78956f3d89 merged bcompat changed into trunk
removed amxmod compat files for now
2006-09-01 03:29:27 +00:00
95537e4840 fix for issues where bots might not 'cache' properly? 2006-09-01 02:22:47 +00:00
35a96176fa Fixed bug am43881: hideslots not working on first map 2006-09-01 01:40:37 +00:00
6a28bc602a Request am43716 - moved IVecFVec and FVecIVec around 2006-09-01 01:34:43 +00:00
72f59422d5 turns out this isn't even needed 2006-08-28 22:08:20 +00:00
cba554d193 fixed this up for gcc-3.4 and no lstdc++.a 2006-08-28 21:21:06 +00:00
76a4d84dbb Fixed this up to work, eh. no more libstdc++.a for you 2006-08-28 21:03:27 +00:00
ec83efbdf3 These did not sync to trunk properly (SDK fix and some updates) 2006-08-28 19:29:20 +00:00
9bd22661ff Added SQL_GetInsertId() 2006-08-28 19:17:26 +00:00
baf406cb6a Fixed bug with floatatan() returning wrong values when trying to get angle in degrees or grades 2006-08-28 17:37:15 +00:00
388711e969 Synced bcompat tree additions and fixes found so far 2006-08-28 11:08:18 +00:00
cb01ff1dc3 Fixed two minor annoyances
1) Paths in config file are now checked before building is attempted (prevents some potential crashes)
2) The compression routines can now handle spaces in the 'output' path
2006-08-28 03:27:16 +00:00
5c23cf416e Fixed makefiles (yes, again) for hlsdk move 2006-08-27 05:29:04 +00:00
b8b3107210 Moved hlsdk out of trunk 2006-08-27 05:14:59 +00:00
2cd1449f88 Ugh, part 2 2006-08-27 05:01:32 +00:00
3691e98814 Ugh, should not have removed that 2006-08-27 04:56:27 +00:00
709b3705ab Fixed warnings that only appeared when compiling amd64 binaries 2006-08-27 04:50:20 +00:00
22bef17660 Changed makefiles to point to trunk's modified version of the HL SDK 2006-08-27 03:13:11 +00:00
b4767cb99e fixed amxxpc builds 2006-08-27 02:34:03 +00:00
30235e05e5 Moved modified HL SDK to trunk 2006-08-27 02:22:59 +00:00
28c4ea4fec Removed odd debug message 2006-08-27 02:21:27 +00:00
58e1254876 oops 2006-08-27 02:18:08 +00:00
81ac41037b GCC Wallification 2006-08-27 02:17:18 +00:00
6786b0e356 Fixed bug am43875 2006-08-27 01:38:47 +00:00
af5a7f5434 fixed am43858 (beta report) 2006-08-25 22:06:59 +00:00
cd6f3dfd71 Updated SDK for GCC-4.1 2006-08-25 00:53:37 +00:00
a7fcf76244 fixed up for gcc-4.1 2006-08-25 00:28:36 +00:00
3878c7492a fixed these for gcc-4.1 2006-08-25 00:26:51 +00:00
4981f46c41 Forgot to sync this 2006-08-24 22:58:48 +00:00
ee4f064073 Initial bump to GCC-4.1 2006-08-24 22:44:57 +00:00
a42a5f1a0e updated for latest build tree 2006-08-24 21:42:25 +00:00
bab5bb5a72 Attempt to fix up am41036 2006-08-24 21:13:52 +00:00
58abc3a655 Request am28110 - Added tfc_get_user_goalitem native to determine if player is carrying a goal item (such as a flag or keycard) 2006-08-22 21:50:27 +00:00
0cb316c764 Removed amd64 stuff from makefiles for projects that don't need it 2006-08-21 15:32:07 +00:00
74d3d23f13 Added tfc_get/setweaponammo to set ammo in weapon's clip (not backpack ammo) 2006-08-21 13:50:51 +00:00
5b47da7cee Finalized binlogging update by removing another unnecessary opcode and updating the reader 2006-08-21 04:18:13 +00:00
45b67b6e2c more tweaks to binlogs 2006-08-21 03:46:20 +00:00
44a17fe646 documented new file format
increased file version
2006-08-21 03:11:19 +00:00
d21a352167 expanded comment for get_players() 2006-08-21 03:07:25 +00:00
4fc2c9cebb fixed bug am41259 2006-08-21 02:08:01 +00:00
4692335abb bumped version 2006-08-21 02:01:57 +00:00
4e639d09de Added sorting.inc to the installer package 2006-08-21 01:55:34 +00:00
deefc504e1 Added request am29544 (nvault_touch) 2006-08-20 21:23:38 +00:00
ea262171db fixed bug am42321 2006-08-20 21:19:50 +00:00
e49af85119 Fixed bugizzle am43566 2006-08-20 21:01:35 +00:00
dec169562b missed the FP_DONE's 2006-08-20 17:57:00 +00:00
0acaf1b476 MSVC8 sync 2006-08-20 11:18:31 +00:00
2cf396be3e weird typo 2006-08-20 08:00:55 +00:00
df7ee94b83 Committed sorting natives as per request am23838 2006-08-20 04:46:34 +00:00
afe7df87d2 Added request am40169 2006-08-20 00:20:47 +00:00
c80b7fd422 updated this 2006-08-19 23:23:30 +00:00
adad1384ff now it compiles 2006-08-19 23:18:11 +00:00
fb0d728720 optimized a stock and created message_stocks.inc (am29627) 2006-08-19 23:02:01 +00:00
a1e8701236 added request at40243 2006-08-19 22:33:02 +00:00
df5c6ccb95 added format test 2006-08-19 22:23:45 +00:00
8a58dd8806 this is a bit more standards compliant 2006-08-19 22:21:42 +00:00
67f53505ce Added request am41635 and fixed a bug with passing (1<<31) 2006-08-19 22:15:34 +00:00
e7cc87a610 now yes 2006-08-19 20:21:00 +00:00
b572cdff2f Updated SQLX test suite for plugin_end() bug 2006-08-19 19:39:57 +00:00
446d4b8a5d Synced threading changes between MySQLX and Sqlite 2006-08-19 19:37:45 +00:00
db5c9c114e Queries in plugin_end() now resolve correctly. 2006-08-19 19:29:33 +00:00
408f61c6d6 Added request am42871:file names in binlogs 2006-08-19 18:44:12 +00:00
042b9f7f4b Fixed bug am42307 (nvault_open did not return -1 on failure) 2006-08-18 22:46:07 +00:00
a8b4ebbe70 Fixed bug am42097 (FM disabling hooks too early) 2006-08-18 22:17:51 +00:00
ed0312567d Fixed bug am42213 2006-08-18 20:53:31 +00:00
e80679afd0 Fixed bug am42213 2006-08-18 20:52:49 +00:00
9093a178f1 Fixed bug am41900 (command name too long) 2006-08-18 20:31:23 +00:00
4fe8c71d62 Added request am41375 (animation toggling on silenced weapons) 2006-08-18 20:12:20 +00:00
f5414ff8de Fixed issues with stats.dat files loading (bug am41030) 2006-08-18 19:49:32 +00:00
f3a833dd1b more warning fixes 2006-08-18 19:08:51 +00:00
e2932fb61a Request am40967 (logging set_fail_state) 2006-08-18 19:02:37 +00:00
43bd5fc732 removed unused stuff 2006-08-18 14:02:07 +00:00
377c01eac7 just a little detail 2006-08-18 13:23:02 +00:00
7af82f0d4f n0thing 2006-08-18 13:05:09 +00:00
010ef526c5 added amxx_setpl_curweap to export table 2006-08-18 06:05:57 +00:00
659448ce29 clarified the API 2006-08-18 06:00:26 +00:00
d7d0d72ceb fixed a serious bug with byref values and callfunc_push*() where the heap was used incorrectly, causing passed data to be easily corrupted.
added callfunc_push_array() (am42810)
2006-08-18 05:52:21 +00:00
79f8525c4a bumped version number 2006-08-18 03:34:03 +00:00
2869c8f4f6 Fixed bug at43313 2006-08-18 03:33:46 +00:00
b7076fc572 Committed implementation of request am42697 2006-08-18 02:19:38 +00:00
f7691a51c6 Added request am43012: per-map plugin files 2006-08-17 19:34:34 +00:00
5524d5dca1 Added the ability to mark plugins as "disabled." This blocks the plugin from loading in other files.
Fixed a bug where the PCALM cache was invalidated on file read, rather than plugin finalization.
2006-08-17 18:25:23 +00:00
e015df58c8 More GCC compatibility fixes 2006-08-17 16:43:47 +00:00
db175082ad Fixed some bugs/warnings that GCC caught 2006-08-17 16:41:41 +00:00
8b055fd1d0 Added GCC-4.1 support
Disabled potentially bad optimization
2006-08-17 01:39:47 +00:00
6295813723 Work-around for a code generation bug in GCC 2006-08-17 00:23:03 +00:00
a03cd1385d clarified this 2006-08-15 20:21:25 +00:00
1b065c6f36 bug fixes, bumped version to 1.4.3 and advanced auto-indenter a bit 2006-08-02 08:43:24 +00:00
e0115ba2dc final version (I hope) 2006-08-01 17:26:14 +00:00
4306c4f5b6 Fixed am42013
TFC plmenu - team menu didn't allow changing from blue team
All plmenu - Team change message was always in language of the admin that changed the player
2006-07-26 00:53:45 +00:00
3b62b91fb7 Fixed bug am41961 (Orangutanz)
GetPlayerAuthId, GetPlayerWONId, and IsMapValid were not being reset on mapchange
2006-07-24 16:15:09 +00:00
32b1149716 bumped version number to 1.76, zomg! 2006-07-23 01:04:39 +00:00
f92017516f few changes, little bug fix for ESF (again) 2006-07-22 11:46:43 +00:00
8837c52d81 fixed case-sensitivity bug and another typo that prevented the installer from asking for the ESF add-on when installing amxx on the listen server
tiny optimization, fixed bug at41769
2006-07-22 01:11:38 +00:00
6ab3c50813 tiny optimization, fixed bug at41769 2006-07-22 01:08:36 +00:00
0c06cdca36 fixed case-sensitivity bug and another typo that prevented the installer from asking for the ESF add-on when installing amxx on the listen server 2006-07-22 01:06:32 +00:00
ce59ee0362 Partially fixed am41769 (some missing ESF files) 2006-07-21 07:20:52 +00:00
c2d2e8aef5 Fixed issue am41768 (wrong plugin name) 2006-07-21 06:45:37 +00:00
9780a6c36f Fixed issue am41777 (missing time.txt) 2006-07-21 06:43:45 +00:00
1a6f4e08b2 Added request am41585 (Orangutanz) 2006-07-19 04:23:00 +00:00
49f46a5f4c Fixed wrong team names in TFC plmenu am41563 2006-07-18 20:18:23 +00:00
51ee2e4846 this line doesn't look necessary 2006-07-18 09:59:36 +00:00
928091864f Added request am41367 (devcones) 2006-07-18 09:20:57 +00:00
fab4a43915 Fix for am41317, forward re-entrancy problem 2006-07-18 04:39:54 +00:00
b44951295d I forgot to remove you didn't I am41542 2006-07-17 23:11:57 +00:00
db3beb9b98 Various pev issues fixed am41542 2006-07-17 20:01:11 +00:00
2dc3f2bec9 fixed bug at41483 2006-07-17 12:42:59 +00:00
6ac889f6e2 fixed bug at40963 2006-07-16 13:23:56 +00:00
87ac42cd98 fixed makefile for changes 2006-07-16 07:24:35 +00:00
f64d2366e9 added 2 memfile files 2006-07-16 02:27:51 +00:00
34d71eb4dc built latest compiler 2006-07-16 02:26:58 +00:00
fb2e0c5f6c compiler is fast now 2006-07-16 02:25:32 +00:00
65513c6037 bumped version 2006-07-16 02:22:38 +00:00
b859001feb Fixed path to Pawn include file in MSVC projects (Fun module) 2006-07-13 03:22:30 +00:00
895039308f Added CZ models to CsInternalModel enum (request at41295) 2006-07-13 03:07:24 +00:00
43b8ea4657 deleted outdated or unneeded dirs in dlls 2006-07-12 18:25:41 +00:00
0eca298c2a Fixed makefile paths (I think) 2006-07-12 06:05:06 +00:00
8d4f28ac62 a typo_O 2006-07-09 19:10:08 +00:00
464 changed files with 8726 additions and 52787 deletions

View File

@ -33,7 +33,7 @@
#include "debugger.h" #include "debugger.h"
#include "binlog.h" #include "binlog.h"
CForward::CForward(const char *name, ForwardExecType et, int numParams, const ForwardParam *paramTypes) CForward::CForward(const char *name, ForwardExecType et, int numParams, const ForwardParam *paramTypes, int fwd_type)
{ {
m_FuncName = name; m_FuncName = name;
m_ExecType = et; m_ExecType = et;
@ -43,11 +43,17 @@ CForward::CForward(const char *name, ForwardExecType et, int numParams, const Fo
// find funcs // find funcs
int func; int func;
AMXForward *tmp = NULL;
m_Funcs.clear(); m_Funcs.clear();
for (CPluginMngr::iterator iter = g_plugins.begin(); iter; ++iter) for (CPluginMngr::iterator iter = g_plugins.begin(); iter; ++iter)
{ {
if ((fwd_type != FORWARD_ALL) &&
((fwd_type == FORWARD_ONLY_NEW && ((*iter).getAMX()->flags & AMX_FLAG_OLDFILE))
|| (fwd_type == FORWARD_ONLY_OLD && !((*iter).getAMX()->flags & AMX_FLAG_OLDFILE))
))
{
continue;
}
if ((*iter).isValid() && amx_FindPublic((*iter).getAMX(), name, &func) == AMX_ERR_NONE) if ((*iter).isValid() && amx_FindPublic((*iter).getAMX(), name, &func) == AMX_ERR_NONE)
{ {
AMXForward tmp; AMXForward tmp;
@ -69,8 +75,6 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
cell globRetVal = 0; cell globRetVal = 0;
unsigned int id = 0;
AMXForwardList::iterator iter; AMXForwardList::iterator iter;
for (iter = m_Funcs.begin(); iter != m_Funcs.end(); iter++) for (iter = m_Funcs.begin(); iter != m_Funcs.end(); iter++)
@ -85,7 +89,7 @@ cell CForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
pDebugger->BeginExec(); pDebugger->BeginExec();
// handle strings & arrays // handle strings & arrays
int i, ax = 0; int i;
for (i = 0; i < m_NumParams; ++i) for (i = 0; i < m_NumParams; ++i)
{ {
@ -355,13 +359,15 @@ cell CSPForward::execute(cell *params, ForwardPreparedArray *preparedArrays)
return retVal; return retVal;
} }
int CForwardMngr::registerForward(const char *funcName, ForwardExecType et, int numParams, const ForwardParam * paramTypes) int CForwardMngr::registerForward(const char *funcName, ForwardExecType et, int numParams, const ForwardParam * paramTypes, int fwd_type)
{ {
int retVal = m_Forwards.size() << 1; int retVal = m_Forwards.size() << 1;
CForward *tmp = new CForward(funcName, et, numParams, paramTypes); CForward *tmp = new CForward(funcName, et, numParams, paramTypes, fwd_type);
if (!tmp) if (!tmp)
{
return -1; // should be invalid return -1; // should be invalid
}
m_Forwards.push_back(tmp); m_Forwards.push_back(tmp);
@ -454,9 +460,22 @@ cell CForwardMngr::executeForwards(int id, cell *params)
const char *CForwardMngr::getFuncName(int id) const const char *CForwardMngr::getFuncName(int id) const
{ {
if (!isIdValid(id))
{
return "";
}
return (id & 1) ? m_SPForwards[id >> 1]->getFuncName() : m_Forwards[id >> 1]->getFuncName(); return (id & 1) ? m_SPForwards[id >> 1]->getFuncName() : m_Forwards[id >> 1]->getFuncName();
} }
int CForwardMngr::getFuncsNum(int id) const
{
if (!isIdValid(id))
{
return 0;
}
return (id & 1) ? m_SPForwards[id >> 1]->getFuncsNum() : m_Forwards[id >> 1]->getFuncsNum();
}
int CForwardMngr::getParamsNum(int id) const int CForwardMngr::getParamsNum(int id) const
{ {
return (id & 1) ? m_SPForwards[id >> 1]->getParamsNum() : m_Forwards[id >> 1]->getParamsNum(); return (id & 1) ? m_SPForwards[id >> 1]->getParamsNum() : m_Forwards[id >> 1]->getParamsNum();
@ -464,6 +483,10 @@ int CForwardMngr::getParamsNum(int id) const
ForwardParam CForwardMngr::getParamType(int id, int paramNum) const ForwardParam CForwardMngr::getParamType(int id, int paramNum) const
{ {
if (!isIdValid(id))
{
return FP_DONE;
}
return (id & 1) ? m_SPForwards[id >> 1]->getParamType(paramNum) : m_Forwards[id >> 1]->getParamType(paramNum); return (id & 1) ? m_SPForwards[id >> 1]->getParamType(paramNum) : m_Forwards[id >> 1]->getParamType(paramNum);
} }
@ -505,14 +528,16 @@ void CForwardMngr::unregisterSPForward(int id)
m_FreeSPForwards.push(id); m_FreeSPForwards.push(id);
} }
int registerForwardC(const char *funcName, ForwardExecType et, cell *list, size_t num) int registerForwardC(const char *funcName, ForwardExecType et, cell *list, size_t num, int fwd_type)
{ {
ForwardParam params[FORWARD_MAX_PARAMS]; ForwardParam params[FORWARD_MAX_PARAMS];
for (size_t i=0; i<num; i++) for (size_t i=0; i<num; i++)
{
params[i] = static_cast<ForwardParam>(list[i]); params[i] = static_cast<ForwardParam>(list[i]);
}
return g_forwards.registerForward(funcName, et, num, params); return g_forwards.registerForward(funcName, et, num, params, fwd_type);
} }
int registerForward(const char *funcName, ForwardExecType et, ...) int registerForward(const char *funcName, ForwardExecType et, ...)

View File

@ -51,6 +51,10 @@
const int FORWARD_MAX_PARAMS = 32; const int FORWARD_MAX_PARAMS = 32;
#define FORWARD_ONLY_OLD 1
#define FORWARD_ONLY_NEW 2
#define FORWARD_ALL 3
enum ForwardExecType enum ForwardExecType
{ {
ET_IGNORE = 0, // Ignore return vaue ET_IGNORE = 0, // Ignore return vaue
@ -107,7 +111,7 @@ class CForward
ForwardParam m_ParamTypes[FORWARD_MAX_PARAMS]; ForwardParam m_ParamTypes[FORWARD_MAX_PARAMS];
public: public:
CForward(const char *name, ForwardExecType et, int numParams, const ForwardParam * paramTypes); CForward(const char *name, ForwardExecType et, int numParams, const ForwardParam * paramTypes, int fwd_type=FORWARD_ALL);
CForward() {} // leaves everything unitialized' CForward() {} // leaves everything unitialized'
cell execute(cell *params, ForwardPreparedArray *preparedArrays); cell execute(cell *params, ForwardPreparedArray *preparedArrays);
@ -203,7 +207,7 @@ public:
// Interface // Interface
// Register normal forward // Register normal forward
int registerForward(const char *funcName, ForwardExecType et, int numParams, const ForwardParam *paramTypes); int registerForward(const char *funcName, ForwardExecType et, int numParams, const ForwardParam *paramTypes, int fwd_type=FORWARD_ALL);
// Register single plugin forward // Register single plugin forward
int registerSPForward(const char *funcName, AMX *amx, int numParams, const ForwardParam * paramTypes); int registerSPForward(const char *funcName, AMX *amx, int numParams, const ForwardParam * paramTypes);
int registerSPForward(int func, AMX *amx, int numParams, const ForwardParam * paramTypes); int registerSPForward(int func, AMX *amx, int numParams, const ForwardParam * paramTypes);
@ -227,7 +231,7 @@ public:
// (un)register forward // (un)register forward
int registerForward(const char *funcName, ForwardExecType et, ...); int registerForward(const char *funcName, ForwardExecType et, ...);
int registerForwardC(const char *funcName, ForwardExecType et, cell *list, size_t num); int registerForwardC(const char *funcName, ForwardExecType et, cell *list, size_t num, int fwd_type=FORWARD_ALL);
int registerSPForwardByName(AMX *amx, const char *funcName, ...); int registerSPForwardByName(AMX *amx, const char *funcName, ...);
int registerSPForwardByNameC(AMX *amx, const char *funcName, cell *list, size_t num); int registerSPForwardByNameC(AMX *amx, const char *funcName, cell *list, size_t num);
int registerSPForward(AMX *amx, int func, ...); int registerSPForward(AMX *amx, int func, ...);

View File

@ -33,6 +33,7 @@
#include "amxmodx.h" #include "amxmodx.h"
#include "CLang.h" #include "CLang.h"
#include "format.h" #include "format.h"
#include "amxmod_compat.h"
#ifdef __linux__ #ifdef __linux__
#define _snprintf snprintf #define _snprintf snprintf
@ -65,7 +66,10 @@ int HashFunction<String>(const String &k)
unsigned long hash = 5381; unsigned long hash = 5381;
register const char *str = k.c_str(); register const char *str = k.c_str();
register char c; register char c;
while (c = *str++) hash = ((hash << 5) + hash) + c; // hash*33 + c while ((c = *str++))
{
hash = ((hash << 5) + hash) + c; // hash*33 + c
}
return hash; return hash;
} }
@ -75,7 +79,10 @@ int HashAlt<const char *>(char const * const &k)
unsigned long hash = 5381; unsigned long hash = 5381;
register const char *str = k; register const char *str = k;
register char c; register char c;
while (c = *str++) hash = ((hash << 5) + hash) + c; // hash*33 + c while ((c = *str++))
{
hash = ((hash << 5) + hash) + c; // hash*33 + c
}
return hash; return hash;
} }
@ -250,9 +257,9 @@ int CLangMngr::GetKeyEntry(const char *key)
return val.index; return val.index;
} }
int CLangMngr::AddKeyEntry(String &key) int CLangMngr::AddKeyEntry(const char *key)
{ {
keytbl_val val; keytbl_val val;
val.index = static_cast<int>(KeyList.size()); val.index = static_cast<int>(KeyList.size());
String *pString = new String(key); String *pString = new String(key);
@ -263,6 +270,11 @@ int CLangMngr::AddKeyEntry(String &key)
return val.index; return val.index;
} }
int CLangMngr::AddKeyEntry(String &key)
{
return AddKeyEntry(key.c_str());
}
int CLangMngr::GetKeyEntry(String &key) int CLangMngr::GetKeyEntry(String &key)
{ {
keytbl_val &val = KeyTable[key]; keytbl_val &val = KeyTable[key];
@ -276,7 +288,23 @@ char * CLangMngr::FormatAmxString(AMX *amx, cell *params, int parm, int &len)
static char outbuf[4096]; static char outbuf[4096];
cell *addr = get_amxaddr(amx, params[parm++]); cell *addr = get_amxaddr(amx, params[parm++]);
len = atcprintf(outbuf, sizeof(outbuf)-1, addr, amx, params, &parm); if (amx->flags & AMX_FLAG_OLDFILE)
{
if (*addr & BCOMPAT_TRANSLATE_BITS)
{
const char *key, *def;
if (!translate_bcompat(amx, addr, &key, &def))
{
goto normal_string;
}
len = atcprintf(outbuf, sizeof(outbuf)-1, def, amx, params, &parm);
} else {
goto normal_string;
}
} else {
normal_string:
len = atcprintf(outbuf, sizeof(outbuf)-1, addr, amx, params, &parm);
}
return outbuf; return outbuf;
} }
@ -353,7 +381,7 @@ int CLangMngr::MergeDefinitionFile(const char *file)
CQueue<sKeyDef> Defq; CQueue<sKeyDef> Defq;
String buf; String buf;
char language[3]; char language[3];
sKeyDef tmpEntry; sKeyDef tmpEntry = {NULL, 0};
while (!feof(fp)) while (!feof(fp))
{ {
@ -570,7 +598,7 @@ bool CLangMngr::LangExists(const char *langName)
char buf[3] = {0}; char buf[3] = {0};
int i = 0; int i = 0;
while (buf[i] = tolower(*langName++)) while ((buf[i] = tolower(*langName++)))
{ {
if (++i == 2) if (++i == 2)
break; break;

View File

@ -127,9 +127,11 @@ class CLangMngr
public: public:
void AddEntry(int key, const char *definition); void AddEntry(int key, const char *definition);
}; };
public:
// Merge definitions into a language // Merge definitions into a language
void MergeDefinitions(const char *lang, CQueue <sKeyDef> &tmpVec); void MergeDefinitions(const char *lang, CQueue <sKeyDef> &tmpVec);
private:
// strip lowercase; make lower if needed // strip lowercase; make lower if needed
static size_t strip(char *str, char *newstr, bool makelower = false); static size_t strip(char *str, char *newstr, bool makelower = false);
@ -160,11 +162,11 @@ public:
// Get index // Get index
int GetKeyEntry(String &key); int GetKeyEntry(String &key);
int GetKeyEntry(const char *key); int GetKeyEntry(const char *key);
int GetKeyIndex(const char *key);
// Get key from index // Get key from index
const char *GetKey(int key); const char *GetKey(int key);
// Add key // Add key
int AddKeyEntry(String &key); int AddKeyEntry(String &key);
int AddKeyEntry(const char *key);
// Get the number of languages // Get the number of languages
int GetLangsNum(); int GetLangsNum();

View File

@ -40,7 +40,8 @@ void CPlayer::Init(edict_t* e, int i)
pEdict = e; pEdict = e;
initialized = false; initialized = false;
ingame = false; ingame = false;
bot = false; bot_value = false;
bot_cached = false;
authorized = false; authorized = false;
current = 0; current = 0;
@ -88,7 +89,8 @@ void CPlayer::Disconnect()
} }
queries.clear(); queries.clear();
bot = 0; bot_value = false;
bot_cached = false;
menu = 0; menu = 0;
newmenu = -1; newmenu = -1;
} }
@ -114,10 +116,11 @@ int CPlayer::NextHUDChannel()
bool CPlayer::Connect(const char* connectname, const char* ipaddress) bool CPlayer::Connect(const char* connectname, const char* ipaddress)
{ {
bot_value = false;
bot_cached = false;
name.assign(connectname); name.assign(connectname);
ip.assign(ipaddress); ip.assign(ipaddress);
time = gpGlobals->time; time = gpGlobals->time;
bot = IsBot();
death_killer = 0; death_killer = 0;
menu = 0; menu = 0;
newmenu = -1; newmenu = -1;

View File

@ -58,6 +58,7 @@ public:
inline const char* getPluginName() { return plugin.c_str(); } inline const char* getPluginName() { return plugin.c_str(); }
inline const char* getName() { return name.c_str(); } inline const char* getName() { return name.c_str(); }
inline bool operator == (const char* string) { return (strcmp(name.c_str(), string) == 0); } inline bool operator == (const char* string) { return (strcmp(name.c_str(), string) == 0); }
int plugin_id;
}; };
// ***************************************************** // *****************************************************
@ -83,7 +84,8 @@ public:
bool initialized; bool initialized;
bool ingame; bool ingame;
bool bot; bool bot_cached;
bool bot_value;
bool authorized; bool authorized;
bool vgui; bool vgui;
@ -131,7 +133,24 @@ public:
inline bool IsBot() inline bool IsBot()
{ {
return ((pEdict->v.flags & FL_FAKECLIENT) ? true : false); if (!bot_cached)
{
bot_value = false;
if (pEdict->v.flags & FL_FAKECLIENT)
{
bot_value = true;
bot_cached = true;
} else {
const char *auth = GETPLAYERAUTHID(pEdict);
if (auth && (strcmp(auth, "BOT") == 0))
{
bot_value = true;
bot_cached = true;
}
}
}
return bot_value;
} }
inline bool IsAlive() inline bool IsAlive()

View File

@ -89,6 +89,7 @@ void CModule::clear(bool clearFilename)
m_DestroyableIndexes.clear(); m_DestroyableIndexes.clear();
m_Natives.clear(); m_Natives.clear();
m_NewNatives.clear();
} }
bool CModule::attachMetamod(const char *mmfile, PLUG_LOADTIME now) bool CModule::attachMetamod(const char *mmfile, PLUG_LOADTIME now)

View File

@ -117,6 +117,7 @@ public:
void CallPluginsUnloading(); void CallPluginsUnloading();
CVector<AMX_NATIVE_INFO*> m_Natives; CVector<AMX_NATIVE_INFO*> m_Natives;
CVector<AMX_NATIVE_INFO*> m_NewNatives; // Natives for new (AMXX, not AMX) plugins only
CVector<size_t> m_DestroyableIndexes; CVector<size_t> m_DestroyableIndexes;
}; };

View File

@ -81,14 +81,17 @@ void CPluginMngr::Finalize()
m_Finalized = true; m_Finalized = true;
} }
int CPluginMngr::loadPluginsFromFile(const char* filename) int CPluginMngr::loadPluginsFromFile(const char* filename, bool warn)
{ {
char file[256]; char file[256];
FILE *fp = fopen(build_pathname_r(file, sizeof(file) - 1, "%s", filename), "rt"); FILE *fp = fopen(build_pathname_r(file, sizeof(file) - 1, "%s", filename), "rt");
if (!fp) if (!fp)
{ {
AMXXLOG_Log("[AMXX] Plugins list not found (file \"%s\")", filename); if (warn)
{
AMXXLOG_Log("[AMXX] Plugins list not found (file \"%s\")", filename);
}
return 1; return 1;
} }
@ -99,6 +102,8 @@ int CPluginMngr::loadPluginsFromFile(const char* filename)
String line; String line;
List<String *>::iterator block_iter;
while (!feof(fp)) while (!feof(fp))
{ {
pluginName[0] = '\0'; pluginName[0] = '\0';
@ -122,13 +127,32 @@ int CPluginMngr::loadPluginsFromFile(const char* filename)
sscanf(line.c_str(), "%s %s", pluginName, debug); sscanf(line.c_str(), "%s %s", pluginName, debug);
if (!isalnum(*pluginName)) if (!isalnum(*pluginName))
{
continue; continue;
}
if (isalnum(*debug) && strcmp(debug, "debug") == 0) if (isalnum(*debug) && !strcmp(debug, "debug"))
{ {
debugFlag = 1; debugFlag = 1;
} }
bool skip = false;
for (block_iter = m_BlockList.begin();
block_iter != m_BlockList.end();
block_iter++)
{
if ((*block_iter)->compare(pluginName) == 0)
{
skip = true;
break;
}
}
if (skip || !strcmp(debug, "disabled"))
{
continue;
}
CPlugin* plugin = loadPlugin(pluginsDir, pluginName, error, debugFlag); CPlugin* plugin = loadPlugin(pluginsDir, pluginName, error, debugFlag);
if (plugin->getStatusCode() == ps_bad_load) if (plugin->getStatusCode() == ps_bad_load)
@ -142,8 +166,6 @@ int CPluginMngr::loadPluginsFromFile(const char* filename)
fclose(fp); fclose(fp);
InvalidateCache();
return pCounter; return pCounter;
} }
@ -161,6 +183,14 @@ void CPluginMngr::clear()
delete [] pNatives; delete [] pNatives;
pNatives = NULL; pNatives = NULL;
} }
List<String *>::iterator iter = m_BlockList.begin();
while (iter != m_BlockList.end())
{
delete (*iter);
iter = m_BlockList.erase(iter);
}
m_BlockList.clear();
} }
CPluginMngr::CPlugin* CPluginMngr::findPlugin(AMX *amx) CPluginMngr::CPlugin* CPluginMngr::findPlugin(AMX *amx)
@ -387,14 +417,16 @@ void CPluginMngr::CPlugin::pausePlugin()
// Unpause a plugin // Unpause a plugin
void CPluginMngr::CPlugin::unpausePlugin() void CPluginMngr::CPlugin::unpausePlugin()
{ {
if (isValid()) if (isValid() && (getStatusCode() != ps_stopped))
{ {
// set status first so the function will be marked executable // set status first so the function will be marked executable
setStatus(ps_running); setStatus(ps_running);
// call plugin_unpause if provided // call plugin_unpause if provided
if (m_UnpauseFwd != -1) if (m_UnpauseFwd != -1)
{
executeForwards(m_UnpauseFwd); executeForwards(m_UnpauseFwd);
}
} }
} }
@ -417,7 +449,8 @@ char *CPluginMngr::ReadIntoOrFromCache(const char *file, size_t &bufsize)
pl->file = new CAmxxReader(file, sizeof(cell)); pl->file = new CAmxxReader(file, sizeof(cell));
pl->buffer = NULL; pl->buffer = NULL;
if (pl->file->GetStatus() != CAmxxReader::Err_None) if (pl->file->GetStatus() != CAmxxReader::Err_None ||
pl->file->IsOldFile())
{ {
delete pl->file; delete pl->file;
delete pl; delete pl;
@ -616,7 +649,9 @@ void CPluginMngr::CALMFromFile(const char *file)
{ {
fgets(line, sizeof(line)-1, fp); fgets(line, sizeof(line)-1, fp);
if (line[0] == ';' || line[0] == '\n' || line[0] == '\0') if (line[0] == ';' || line[0] == '\n' || line[0] == '\0')
{
continue; continue;
}
/** quick hack */ /** quick hack */
char *ptr = line; char *ptr = line;
@ -635,8 +670,28 @@ void CPluginMngr::CALMFromFile(const char *file)
pluginName[0] = '\0'; pluginName[0] = '\0';
sscanf(rline.c_str(), "%s", pluginName); sscanf(rline.c_str(), "%s", pluginName);
/* HACK: see if there's a 'disabled' coming up
* new block for scopying flexibility
*/
if (1)
{
const char *_ptr = rline.c_str() + strlen(pluginName);
while (*_ptr != '\0' && isspace(*_ptr))
{
_ptr++;
}
if ((*_ptr != '\0') && !strcmp(_ptr, "disabled"))
{
String *pString = new String(pluginName);
m_BlockList.push_back(pString);
continue;
}
}
if (!isalnum(*pluginName)) if (!isalnum(*pluginName))
{
continue; continue;
}
build_pathname_r(filename, sizeof(filename)-1, "%s/%s", get_localinfo("amxx_pluginsdir", "addons/amxmodx/plugins"), pluginName); build_pathname_r(filename, sizeof(filename)-1, "%s/%s", get_localinfo("amxx_pluginsdir", "addons/amxmodx/plugins"), pluginName);

View File

@ -125,7 +125,7 @@ public:
CPlugin* loadPlugin(const char* path, const char* name, char* error, int debug); CPlugin* loadPlugin(const char* path, const char* name, char* error, int debug);
void unloadPlugin(CPlugin** a); void unloadPlugin(CPlugin** a);
int loadPluginsFromFile(const char* filename); int loadPluginsFromFile(const char* filename, bool warn=true);
inline CPlugin* findPluginFast(AMX *amx) { return (CPlugin*)(amx->userdata[UD_FINDPLUGIN]); } inline CPlugin* findPluginFast(AMX *amx) { return (CPlugin*)(amx->userdata[UD_FINDPLUGIN]); }
CPlugin* findPlugin(AMX *amx); CPlugin* findPlugin(AMX *amx);
@ -165,6 +165,7 @@ public:
void CALMFromFile(const char *file); void CALMFromFile(const char *file);
private: private:
List<plcache_entry *> m_plcache; List<plcache_entry *> m_plcache;
List<String *> m_BlockList;
}; };
#endif //PLUGIN_H #endif //PLUGIN_H

Binary file not shown.

Binary file not shown.

View File

@ -1,14 +1,14 @@
#(C)2004-2005 AMX Mod X Development Team #(C)2004-2005 AMX Mod X Development Team
# Makefile written by David "BAILOPAN" Anderson # Makefile written by David "BAILOPAN" Anderson
HLSDK = ../hlsdk/SourceCode HLSDK = ../../hlsdk
MM_ROOT = ../metamod/metamod MM_ROOT = ../metamod/metamod
### EDIT BELOW FOR OTHER PROJECTS ### ### EDIT BELOW FOR OTHER PROJECTS ###
OPT_FLAGS = -O2 -funroll-loops -s -fomit-frame-pointer -pipe OPT_FLAGS = -O2 -fno-strict-aliasing -funroll-loops -s -fomit-frame-pointer -pipe
DEBUG_FLAGS = -g -ggdb3 DEBUG_FLAGS = -g -ggdb3
CPP = gcc CPP = gcc-4.1
NAME = amxmodx NAME = amxmodx
BIN_SUFFIX_32 = mm_i386.so BIN_SUFFIX_32 = mm_i386.so
@ -19,13 +19,20 @@ OBJECTS = meta_api.cpp CFile.cpp CVault.cpp vault.cpp float.cpp file.cpp modules
srvcmd.cpp strptime.cpp amxcore.cpp amxtime.cpp power.cpp amxxlog.cpp fakemeta.cpp \ srvcmd.cpp strptime.cpp amxcore.cpp amxtime.cpp power.cpp amxxlog.cpp fakemeta.cpp \
amxxfile.cpp CLang.cpp md5.cpp emsg.cpp CForward.cpp CPlugin.cpp CModule.cpp \ amxxfile.cpp CLang.cpp md5.cpp emsg.cpp CForward.cpp CPlugin.cpp CModule.cpp \
CMenu.cpp util.cpp amx.cpp amxdbg.cpp natives.cpp newmenus.cpp debugger.cpp \ CMenu.cpp util.cpp amx.cpp amxdbg.cpp natives.cpp newmenus.cpp debugger.cpp \
optimizer.cpp format.cpp messages.cpp libraries.cpp vector.cpp optimizer.cpp format.cpp messages.cpp libraries.cpp vector.cpp sorting.cpp \
amxmod_compat.cpp
LINK = /lib/libstdc++.a LINK = -lgcc -static-libgcc
INCLUDE = -I. -I$(HLSDK) -I$(HLSDK)/dlls -I$(HLSDK)/engine -I$(HLSDK)/game_shared -I$(HLSDK)/game_shared \ INCLUDE = -I. -I$(HLSDK) -I$(HLSDK)/dlls -I$(HLSDK)/engine -I$(HLSDK)/game_shared -I$(HLSDK)/game_shared \
-I$(MM_ROOT) -Lzlib -I$(HLSDK)/common -I$(MM_ROOT) -Lzlib -I$(HLSDK)/common
GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
ifeq "$(GCC_VERSION)" "4"
OPT_FLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
endif
ifeq "$(DEBUG)" "true" ifeq "$(DEBUG)" "true"
BIN_DIR = Debug BIN_DIR = Debug
CFLAGS = $(DEBUG_FLAGS) CFLAGS = $(DEBUG_FLAGS)
@ -41,7 +48,7 @@ ifeq "$(BINLOG)" "true"
CFLAGS += -DBINLOG_ENABLED CFLAGS += -DBINLOG_ENABLED
endif endif
CFLAGS += -DLINUX -DNDEBUG -fPIC -Wno-deprecated -DHAVE_STDINT_H -static-libgcc -fno-rtti -fno-exceptions CFLAGS += -DLINUX -DNDEBUG -DAMX_NOPROPLIST -fPIC -Wall -Werror -DHAVE_STDINT_H -static-libgcc -fno-rtti -fno-exceptions
ifeq "$(AMD64)" "true" ifeq "$(AMD64)" "true"
BINARY = $(NAME)_$(BIN_SUFFIX_64) BINARY = $(NAME)_$(BIN_SUFFIX_64)

View File

@ -22,9 +22,9 @@
*/ */
#define AMX_NODYNALOAD #define AMX_NODYNALOAD
#define AMX_ANSIONLY #define AMX_ANSIONLY
#if BUILD_PLATFORM == WINDOWS && BUILD_TYPE == RELEASE && BUILD_COMPILER == MSVC && PAWN_CELL_SIZE == 64 #if !defined __linux__ && BUILD_PLATFORM == WINDOWS && BUILD_TYPE == RELEASE && BUILD_COMPILER == MSVC && PAWN_CELL_SIZE == 64
/* bad bad workaround but we have to prevent a compiler crash :/ */ /* bad bad workaround but we have to prevent a compiler crash :/ */
#pragma optimize("g",off) #pragma optimize("g",off)
#endif #endif
@ -990,6 +990,7 @@ int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code)
amx->cip = hdr->cip; amx->cip = hdr->cip;
amx->hea = hdr->hea; amx->hea = hdr->hea;
amx->stp = hdr->stp - sizeof(cell); amx->stp = hdr->stp - sizeof(cell);
amx->hlw = hdr->hea;
/* also put a sentinel for strings at the top the stack */ /* also put a sentinel for strings at the top the stack */
*(cell *)((char*)native_code + hdr->dat + hdr->stp - sizeof(cell)) = 0; *(cell *)((char*)native_code + hdr->dat + hdr->stp - sizeof(cell)) = 0;
amx->stk = amx->stp; amx->stk = amx->stp;

View File

@ -214,7 +214,7 @@ typedef struct tagAMX_NATIVE_INFO {
typedef struct tagAMX_FUNCSTUB { typedef struct tagAMX_FUNCSTUB {
ucell address PACKED; ucell address PACKED;
char name[sEXPMAX+1] PACKED; char name[sEXPMAX+1];
} PACKED AMX_FUNCSTUB; } PACKED AMX_FUNCSTUB;
typedef struct tagFUNCSTUBNT { typedef struct tagFUNCSTUBNT {
@ -265,8 +265,8 @@ typedef struct tagAMX {
typedef struct tagAMX_HEADER { typedef struct tagAMX_HEADER {
int32_t size PACKED; /* size of the "file" */ int32_t size PACKED; /* size of the "file" */
uint16_t magic PACKED; /* signature */ uint16_t magic PACKED; /* signature */
char file_version PACKED; /* file format version */ char file_version; /* file format version */
char amx_version PACKED; /* required version of the AMX */ char amx_version; /* required version of the AMX */
int16_t flags PACKED; int16_t flags PACKED;
int16_t defsize PACKED; /* size of a definition record */ int16_t defsize PACKED; /* size of a definition record */
int32_t cod PACKED; /* initial value of COD - code block */ int32_t cod PACKED; /* initial value of COD - code block */
@ -322,6 +322,7 @@ enum {
#define AMX_FLAG_COMPACT 0x04 /* compact encoding */ #define AMX_FLAG_COMPACT 0x04 /* compact encoding */
#define AMX_FLAG_BYTEOPC 0x08 /* opcode is a byte (not a cell) */ #define AMX_FLAG_BYTEOPC 0x08 /* opcode is a byte (not a cell) */
#define AMX_FLAG_NOCHECKS 0x10 /* no array bounds checking; no STMT opcode */ #define AMX_FLAG_NOCHECKS 0x10 /* no array bounds checking; no STMT opcode */
#define AMX_FLAG_OLDFILE 0x20 /* Old AMX Mod plugin */
#define AMX_FLAG_PRENIT 0x100 /* pre-initialized, do not check natives */ #define AMX_FLAG_PRENIT 0x100 /* pre-initialized, do not check natives */
#define AMX_FLAG_NTVREG 0x1000 /* all native functions are registered */ #define AMX_FLAG_NTVREG 0x1000 /* all native functions are registered */
#define AMX_FLAG_JITC 0x2000 /* abstract machine is JIT compiled */ #define AMX_FLAG_JITC 0x2000 /* abstract machine is JIT compiled */

View File

@ -65,8 +65,8 @@ extern "C" {
typedef struct tagAMX_DBG_HDR { typedef struct tagAMX_DBG_HDR {
int32_t size PACKED; /* size of the debug information chunk */ int32_t size PACKED; /* size of the debug information chunk */
uint16_t magic PACKED; /* signature, must be 0xf1ef */ uint16_t magic PACKED; /* signature, must be 0xf1ef */
char file_version PACKED; /* file format version */ char file_version; /* file format version */
char amx_version PACKED; /* required version of the AMX */ char amx_version; /* required version of the AMX */
int16_t flags PACKED; /* currently unused */ int16_t flags PACKED; /* currently unused */
int16_t files PACKED; /* number of entries in the "file" table */ int16_t files PACKED; /* number of entries in the "file" table */
int16_t lines PACKED; /* number of entries in the "line" table */ int16_t lines PACKED; /* number of entries in the "line" table */
@ -74,51 +74,51 @@ typedef struct tagAMX_DBG_HDR {
int16_t tags PACKED; /* number of entries in the "tag" table */ int16_t tags PACKED; /* number of entries in the "tag" table */
int16_t automatons PACKED; /* number of entries in the "automaton" table */ int16_t automatons PACKED; /* number of entries in the "automaton" table */
int16_t states PACKED; /* number of entries in the "state" table */ int16_t states PACKED; /* number of entries in the "state" table */
} AMX_DBG_HDR PACKED; } PACKED AMX_DBG_HDR;
#define AMX_DBG_MAGIC 0xf1ef #define AMX_DBG_MAGIC 0xf1ef
typedef struct tagAMX_DBG_FILE { typedef struct tagAMX_DBG_FILE {
ucell address PACKED; /* address in the code segment where generated code (for this file) starts */ ucell address PACKED; /* address in the code segment where generated code (for this file) starts */
const char name[1] PACKED; /* ASCII string, zero-terminated */ const char name[1]; /* ASCII string, zero-terminated */
} AMX_DBG_FILE PACKED; } PACKED AMX_DBG_FILE;
typedef struct tagAMX_DBG_LINE { typedef struct tagAMX_DBG_LINE {
ucell address PACKED; /* address in the code segment where generated code (for this line) starts */ ucell address PACKED; /* address in the code segment where generated code (for this line) starts */
int32_t line PACKED; /* line number */ int32_t line PACKED; /* line number */
} AMX_DBG_LINE PACKED; } PACKED AMX_DBG_LINE;
typedef struct tagAMX_DBG_SYMBOL { typedef struct tagAMX_DBG_SYMBOL {
ucell address PACKED; /* address in the data segment or relative to the frame */ ucell address PACKED; /* address in the data segment or relative to the frame */
int16_t tag PACKED; /* tag for the symbol */ int16_t tag PACKED; /* tag for the symbol */
ucell codestart PACKED; /* address in the code segment from which this symbol is valid (in scope) */ ucell codestart PACKED; /* address in the code segment from which this symbol is valid (in scope) */
ucell codeend PACKED; /* address in the code segment until which this symbol is valid (in scope) */ ucell codeend PACKED; /* address in the code segment until which this symbol is valid (in scope) */
char ident PACKED; /* kind of symbol (function/variable) */ char ident; /* kind of symbol (function/variable) */
char vclass PACKED; /* class of symbol (global/local) */ char vclass; /* class of symbol (global/local) */
int16_t dim PACKED; /* number of dimensions */ int16_t dim PACKED; /* number of dimensions */
const char name[1] PACKED; /* ASCII string, zero-terminated */ const char name[1]; /* ASCII string, zero-terminated */
} AMX_DBG_SYMBOL PACKED; } PACKED AMX_DBG_SYMBOL;
typedef struct tagAMX_DBG_SYMDIM { typedef struct tagAMX_DBG_SYMDIM {
int16_t tag PACKED; /* tag for the array dimension */ int16_t tag PACKED; /* tag for the array dimension */
ucell size PACKED; /* size of the array dimension */ ucell size PACKED; /* size of the array dimension */
} AMX_DBG_SYMDIM PACKED; } PACKED AMX_DBG_SYMDIM;
typedef struct tagAMX_DBG_TAG { typedef struct tagAMX_DBG_TAG {
int16_t tag PACKED; /* tag id */ int16_t tag PACKED; /* tag id */
const char name[1] PACKED; /* ASCII string, zero-terminated */ const char name[1]; /* ASCII string, zero-terminated */
} AMX_DBG_TAG PACKED; } PACKED AMX_DBG_TAG;
typedef struct tagAMX_DBG_MACHINE { typedef struct tagAMX_DBG_MACHINE {
int16_t automaton PACKED; /* automaton id */ int16_t automaton PACKED; /* automaton id */
ucell address PACKED; /* address of state variable */ ucell address PACKED; /* address of state variable */
const char name[1] PACKED; /* ASCII string, zero-terminated */ const char name[1]; /* ASCII string, zero-terminated */
} AMX_DBG_MACHINE PACKED; } PACKED AMX_DBG_MACHINE;
typedef struct tagAMX_DBG_STATE { typedef struct tagAMX_DBG_STATE {
int16_t state PACKED; /* state id */ int16_t state PACKED; /* state id */
int16_t automaton PACKED; /* automaton id */ int16_t automaton PACKED; /* automaton id */
const char name[1] PACKED; /* ASCII string, zero-terminated */ const char name[1]; /* ASCII string, zero-terminated */
} AMX_DBG_STATE PACKED; } PACKED AMX_DBG_STATE;
typedef struct tagAMX_DBG { typedef struct tagAMX_DBG {
AMX_DBG_HDR _FAR *hdr PACKED; /* points to the AMX_DBG header */ AMX_DBG_HDR _FAR *hdr PACKED; /* points to the AMX_DBG header */
@ -128,7 +128,7 @@ typedef struct tagAMX_DBG {
AMX_DBG_TAG _FAR **tagtbl PACKED; AMX_DBG_TAG _FAR **tagtbl PACKED;
AMX_DBG_MACHINE _FAR **automatontbl PACKED; AMX_DBG_MACHINE _FAR **automatontbl PACKED;
AMX_DBG_STATE _FAR **statetbl PACKED; AMX_DBG_STATE _FAR **statetbl PACKED;
} AMX_DBG PACKED; } PACKED AMX_DBG;
#if !defined iVARIABLE #if !defined iVARIABLE
#define iVARIABLE 1 /* cell that has an address and that can be fetched directly (lvalue) */ #define iVARIABLE 1 /* cell that has an address and that can be fetched directly (lvalue) */

View File

@ -2122,7 +2122,9 @@ err_heaplow:
_CHKMARGIN_HEAP: _CHKMARGIN_HEAP:
cmp esi,stp cmp esi,stp
jg err_stacklow jg err_stacklow
cmp dword hea,0 mov ebp,amx
mov ebp,[ebp+_hlw]
cmp dword hea,ebp
jl err_heaplow jl err_heaplow
ret ret

117
amxmodx/amxmod_compat.cpp Normal file
View File

@ -0,0 +1,117 @@
#include "amxmodx.h"
#include "amxmod_compat.h"
#include "format.h"
bool GetTranslation(amxtrans_t trans, int &key, int &dest, int &lang)
{
key = (trans & BCOMPAT_TRANSLATE_KEYMASK);
dest = (trans >> BCOMPAT_TRANSLATE_DESTRSH) & BCOMPAT_TRANSLATE_DESTMASK;
lang = (trans >> BCOMPAT_TRANSLATE_LANGRSH) & BCOMPAT_TRANSLATE_LANGMASK;
if (dest == 0x3F)
{
dest = -1;
}
if (lang == 0x1F)
{
lang = -1;
}
return true;
}
bool translate_bcompat(AMX *amx, cell *source, const char **_key, const char **_def)
{
amxtrans_t trans = static_cast<amxtrans_t>(*source);
int key, _dest, lang;
if (!GetTranslation(trans, key, _dest, lang))
{
return false;
}
cell amx_addr, *phys_addr;
if (amx_Allot(amx, 3, &amx_addr, &phys_addr) != AMX_ERR_NONE)
{
return false;
}
if (_dest == -1)
{
*phys_addr = LANG_PLAYER;
} else if (_dest == 0) {
*phys_addr = LANG_SERVER;
} else if (lang >= 0 && lang < g_langMngr.GetLangsNum()) {
const char *name = g_langMngr.GetLangName(lang);
phys_addr[0] = static_cast<cell>(name[0]);
phys_addr[1] = static_cast<cell>(name[1]);
phys_addr[2] = static_cast<cell>('\0');
} else {
*phys_addr = LANG_SERVER;
}
//not optimized but it works, eh
//if someone cares they can make a translate() wrapper that takes the key # in directly
const char *r_key = g_langMngr.GetKey(key);
const char *def = translate(amx, amx_addr, r_key);
if (!def)
{
def = r_key;
}
amx_Release(amx, amx_addr);
*_key = g_langMngr.GetKey(key);
*_def = def;
return true;
}
static cell AMX_NATIVE_CALL amx_translate(AMX *amx, cell *params)
{
int len;
char *key = get_amxstring(amx, params[1], 0, len);
amxtrans_t trans;
int suki = g_langMngr.GetKeyEntry(key);
//Some AMX Mod plugins do not register everything they need. Prevent a crash.
if (suki == -1)
{
suki = g_langMngr.AddKeyEntry(key);
}
if (suki > BCOMPAT_TRANSLATE_KEYMASK)
{
LogError(amx, AMX_ERR_NATIVE, "Not enough translation space, aborting!");
return 0;
}
trans = suki & BCOMPAT_TRANSLATE_KEYMASK;
int dest = static_cast<int>(params[2]);
int lang = static_cast<int>(params[3]);
if (dest == -1)
{
trans |= (0x3F << BCOMPAT_TRANSLATE_DESTRSH);
} else {
trans |= (dest & BCOMPAT_TRANSLATE_DESTMASK) << BCOMPAT_TRANSLATE_DESTRSH;
}
if (lang == -1)
{
trans |= (0x1F << BCOMPAT_TRANSLATE_LANGRSH);
} else {
trans |= (lang & BCOMPAT_TRANSLATE_LANGMASK) << BCOMPAT_TRANSLATE_LANGRSH;
}
trans |= BCOMPAT_TRANSLATE_BITS;
return static_cast<cell>(trans);
}
AMX_NATIVE_INFO g_BcompatNatives[] =
{
{"translate", amx_translate},
{NULL, NULL},
};

28
amxmodx/amxmod_compat.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef _INCLUDE_AMXMOD_CORE_COMPAT_H
#define _INCLUDE_AMXMOD_CORE_COMPAT_H
/**
* New format for translation:
* Note that we only support:
* 4k keys
* 32 languages
* 0000 0000 0000 0000 0000 0000 0000 0000
* | key id |
* | | <- dest id
* | | <- lang id
*/
#define BCOMPAT_TRANSLATE_BITS 0xFF000000
#define BCOMPAT_TRANSLATE_KEYMASK 0xFFF
#define BCOMPAT_TRANSLATE_DESTMASK 0x3F
#define BCOMPAT_TRANSLATE_DESTRSH 12
#define BCOMPAT_TRANSLATE_LANGMASK 0x1F
#define BCOMPAT_TRANSLATE_LANGRSH 18
typedef unsigned int amxtrans_t;
bool GetTranslation(amxtrans_t trans, int &key, int &dest, int &lang);
extern AMX_NATIVE_INFO g_BcompatNatives[];
#endif //_INCLUDE_AMXMOD_CORE_COMPAT_H

View File

@ -36,6 +36,8 @@
#include "binlog.h" #include "binlog.h"
#include "libraries.h" #include "libraries.h"
const char *invis_cvar_list[5] = {"amxmodx_version", "amxmodx_modules", "amx_debug", "amx_mldebug", "amx_client_languages"};
static cell AMX_NATIVE_CALL get_xvar_id(AMX *amx, cell *params) static cell AMX_NATIVE_CALL get_xvar_id(AMX *amx, cell *params)
{ {
int len; int len;
@ -177,7 +179,7 @@ static cell AMX_NATIVE_CALL console_cmd(AMX *amx, cell *params) /* 2 param */
} else { } else {
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (!pPlayer->bot && pPlayer->initialized) if (!pPlayer->IsBot() && pPlayer->initialized)
CLIENT_COMMAND(pPlayer->pEdict, "%s", cmd); CLIENT_COMMAND(pPlayer->pEdict, "%s", cmd);
} }
@ -516,7 +518,7 @@ static cell AMX_NATIVE_CALL is_user_bot(AMX *amx, cell *params) /* 1 param */
if (index < 1 || index > gpGlobals->maxClients) if (index < 1 || index > gpGlobals->maxClients)
return 0; return 0;
return (GET_PLAYER_POINTER_I(index)->bot ? 1 : 0); return (GET_PLAYER_POINTER_I(index)->IsBot() ? 1 : 0);
} }
static cell AMX_NATIVE_CALL is_user_hltv(AMX *amx, cell *params) /* 1 param */ static cell AMX_NATIVE_CALL is_user_hltv(AMX *amx, cell *params) /* 1 param */
@ -542,15 +544,28 @@ static cell AMX_NATIVE_CALL is_user_hltv(AMX *amx, cell *params) /* 1 param */
return 0; return 0;
} }
extern bool g_bmod_tfc;
static cell AMX_NATIVE_CALL is_user_alive(AMX *amx, cell *params) /* 1 param */ static cell AMX_NATIVE_CALL is_user_alive(AMX *amx, cell *params) /* 1 param */
{ {
int index = params[1]; int index = params[1];
if (index < 1 || index > gpGlobals->maxClients) if (index < 1 || index > gpGlobals->maxClients)
{
return 0; return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (g_bmod_tfc)
{
edict_t *e = pPlayer->pEdict;
if (e->v.flags & FL_SPECTATOR ||
(!e->v.team || !e->v.playerclass))
{
return 0;
}
}
return ((pPlayer->ingame && pPlayer->IsAlive()) ? 1 : 0); return ((pPlayer->ingame && pPlayer->IsAlive()) ? 1 : 0);
} }
@ -976,7 +991,9 @@ static cell AMX_NATIVE_CALL get_user_team(AMX *amx, cell *params) /* 3 param */
} }
// //
if (params[3]) if (params[3])
{
set_amxstring(amx, params[2], pPlayer->team.c_str(), params[3]); set_amxstring(amx, params[2], pPlayer->team.c_str(), params[3]);
}
return pPlayer->teamId; return pPlayer->teamId;
} }
@ -1113,6 +1130,16 @@ static cell AMX_NATIVE_CALL get_plugin(AMX *amx, cell *params) /* 11 param */
return a->getId(); return a->getId();
} }
if (params[0] / sizeof(cell) >= 12)
{
cell *jit_info = get_amxaddr(amx, params[12]);
#if defined AMD64 || !defined JIT
*jit_info = 0;
#else
*jit_info = a->isDebug() ? 0 : 1;
#endif
}
return -1; return -1;
} }
@ -1288,6 +1315,28 @@ static cell AMX_NATIVE_CALL get_concmd(AMX *amx, cell *params) /* 7 param */
return 1; return 1;
} }
static cell AMX_NATIVE_CALL get_concmd_plid(AMX *amx, cell *params)
{
int who = params[3];
if (who > 0)
{
who = CMD_ClientCommand;
} else if (who == 0) {
who = CMD_ServerCommand;
} else {
who = CMD_ConsoleCommand;
}
CmdMngr::Command *cmd = g_commands.getCmd(params[1], who, params[2]);
if (cmd == NULL)
{
return -1;
}
return cmd->getPlugin()->getId();
}
static cell AMX_NATIVE_CALL get_clcmd(AMX *amx, cell *params) /* 7 param */ static cell AMX_NATIVE_CALL get_clcmd(AMX *amx, cell *params) /* 7 param */
{ {
CmdMngr::Command* cmd = g_commands.getCmd(params[1], CMD_ClientCommand, params[7]); CmdMngr::Command* cmd = g_commands.getCmd(params[1], CMD_ClientCommand, params[7]);
@ -1506,7 +1555,7 @@ static cell AMX_NATIVE_CALL client_cmd(AMX *amx, cell *params) /* 2 param */
for (int i = 1; i <= gpGlobals->maxClients; ++i) for (int i = 1; i <= gpGlobals->maxClients; ++i)
{ {
CPlayer* pPlayer = GET_PLAYER_POINTER_I(i); CPlayer* pPlayer = GET_PLAYER_POINTER_I(i);
if (!pPlayer->bot && pPlayer->initialized /*&& pPlayer->ingame*/) if (!pPlayer->IsBot() && pPlayer->initialized /*&& pPlayer->ingame*/)
CLIENT_COMMAND(pPlayer->pEdict, "%s", cmd); CLIENT_COMMAND(pPlayer->pEdict, "%s", cmd);
} }
} else { } else {
@ -1520,7 +1569,7 @@ static cell AMX_NATIVE_CALL client_cmd(AMX *amx, cell *params) /* 2 param */
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (!pPlayer->bot && pPlayer->initialized /*&& pPlayer->ingame*/) if (!pPlayer->IsBot() && pPlayer->initialized /*&& pPlayer->ingame*/)
CLIENT_COMMAND(pPlayer->pEdict, "%s", cmd); CLIENT_COMMAND(pPlayer->pEdict, "%s", cmd);
} }
@ -1544,6 +1593,19 @@ static cell AMX_NATIVE_CALL get_cvar_string(AMX *amx, cell *params) /* 3 param *
int ilen; int ilen;
char* sptemp = get_amxstring(amx, params[1], 0, ilen); char* sptemp = get_amxstring(amx, params[1], 0, ilen);
if (amx->flags & AMX_FLAG_OLDFILE)
{
/* :HACKHACK: Pretend we're invisible to old plugins for backward compatibility */
char *cvar = sptemp;
for (unsigned int i=0; i<5; i++)
{
if (strcmp(cvar, invis_cvar_list[i]) == 0)
{
return 0;
}
}
}
return set_amxstring(amx, params[2], CVAR_GET_STRING(sptemp), params[3]); return set_amxstring(amx, params[2], CVAR_GET_STRING(sptemp), params[3]);
} }
@ -1564,6 +1626,20 @@ static cell AMX_NATIVE_CALL get_pcvar_float(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_cvar_float(AMX *amx, cell *params) /* 1 param */ static cell AMX_NATIVE_CALL get_cvar_float(AMX *amx, cell *params) /* 1 param */
{ {
int ilen; int ilen;
if (amx->flags & AMX_FLAG_OLDFILE)
{
/* :HACKHACK: Pretend we're invisible to old plugins for backward compatibility */
char *cvar = get_amxstring(amx, params[1], 0, ilen);
for (unsigned int i=0; i<5; i++)
{
if (strcmp(cvar, invis_cvar_list[i]) == 0)
{
return 0;
}
}
}
REAL pFloat = CVAR_GET_FLOAT(get_amxstring(amx, params[1], 0, ilen)); REAL pFloat = CVAR_GET_FLOAT(get_amxstring(amx, params[1], 0, ilen));
return amx_ftoc(pFloat); return amx_ftoc(pFloat);
@ -1606,6 +1682,18 @@ static cell AMX_NATIVE_CALL get_pcvar_num(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL get_cvar_num(AMX *amx, cell *params) /* 1 param */ static cell AMX_NATIVE_CALL get_cvar_num(AMX *amx, cell *params) /* 1 param */
{ {
int ilen; int ilen;
if (amx->flags & AMX_FLAG_OLDFILE)
{
/* :HACKHACK: Pretend we're invisible to old plugins for backward compatibility */
char *cvar = get_amxstring(amx, params[1], 0, ilen);
for (unsigned int i=0; i<5; i++)
{
if (strcmp(cvar, invis_cvar_list[i]) == 0)
{
return 0;
}
}
}
return (int)CVAR_GET_FLOAT(get_amxstring(amx, params[1], 0, ilen)); return (int)CVAR_GET_FLOAT(get_amxstring(amx, params[1], 0, ilen));
} }
@ -1883,7 +1971,7 @@ static cell AMX_NATIVE_CALL get_players(AMX *amx, cell *params) /* 4 param */
{ {
if (pPlayer->IsAlive() ? (flags & 2) : (flags & 1)) if (pPlayer->IsAlive() ? (flags & 2) : (flags & 1))
continue; continue;
if (pPlayer->bot ? (flags & 4) : (flags & 8)) if (pPlayer->IsBot() ? (flags & 4) : (flags & 8))
continue; continue;
if ((flags & 16) && (pPlayer->teamId != team)) if ((flags & 16) && (pPlayer->teamId != team))
continue; continue;
@ -1940,7 +2028,7 @@ static cell AMX_NATIVE_CALL find_player(AMX *amx, cell *params) /* 1 param */
if (pPlayer->IsAlive() ? (flags & 64) : (flags & 32)) if (pPlayer->IsAlive() ? (flags & 64) : (flags & 32))
continue; continue;
if (pPlayer->bot ? (flags & 128) : (flags & 256)) if (pPlayer->IsBot() ? (flags & 128) : (flags & 256))
continue; continue;
if (flags & 1) if (flags & 1)
@ -2176,6 +2264,18 @@ static cell AMX_NATIVE_CALL task_exists(AMX *amx, cell *params) /* 1 param */
static cell AMX_NATIVE_CALL cvar_exists(AMX *amx, cell *params) /* 1 param */ static cell AMX_NATIVE_CALL cvar_exists(AMX *amx, cell *params) /* 1 param */
{ {
int ilen; int ilen;
if (amx->flags & AMX_FLAG_OLDFILE)
{
/* :HACKHACK: Pretend we're invisible to old plugins for backward compatibility */
char *cvar = get_amxstring(amx, params[1], 0, ilen);
for (unsigned int i=0; i<5; i++)
{
if (strcmp(cvar, invis_cvar_list[i]) == 0)
{
return 0;
}
}
}
return (CVAR_GET_POINTER(get_amxstring(amx, params[1], 0, ilen)) ? 1 : 0); return (CVAR_GET_POINTER(get_amxstring(amx, params[1], 0, ilen)) ? 1 : 0);
} }
@ -2189,8 +2289,7 @@ static cell AMX_NATIVE_CALL register_cvar(AMX *amx, cell *params) /* 3 param */
CPluginMngr::CPlugin *plugin = g_plugins.findPluginFast(amx); CPluginMngr::CPlugin *plugin = g_plugins.findPluginFast(amx);
CCVar* cvar = new CCVar(temp, plugin->getName(), params[3], amx_ctof(params[4])); CCVar* cvar = new CCVar(temp, plugin->getName(), params[3], amx_ctof(params[4]));
if (cvar == 0) cvar->plugin_id = plugin->getId();
return 0;
g_cvars.put(cvar); g_cvars.put(cvar);
@ -2582,6 +2681,43 @@ static cell AMX_NATIVE_CALL remove_quotes(AMX *amx, cell *params) /* 1 param */
return 0; return 0;
} }
//native get_plugins_cvar(id, name[], namelen, &flags=0, &plugin_id=0, &pcvar_handle=0);
static cell AMX_NATIVE_CALL get_plugins_cvar(AMX *amx, cell *params)
{
int id = params[1];
int iter_id = 0;
for (CList<CCVar>::iterator iter=g_cvars.begin(); iter; ++iter)
{
if (id == iter_id)
{
CCVar *var = &(*iter);
set_amxstring(amx, params[2], var->getName(), params[3]);
cvar_t *ptr = CVAR_GET_POINTER(var->getName());
if (!ptr)
{
return 0;
}
cell *addr = get_amxaddr(amx, params[4]);
*addr = ptr->flags;
addr = get_amxaddr(amx, params[5]);
*addr = var->plugin_id;
addr = get_amxaddr(amx, params[6]);
*addr = (cell)ptr;
return 1;
}
iter_id++;
}
return 0;
}
//native get_plugins_cvarsnum();
static cell AMX_NATIVE_CALL get_plugins_cvarsnum(AMX *amx, cell *params)
{
return g_cvars.size();
}
static cell AMX_NATIVE_CALL get_user_aiming(AMX *amx, cell *params) /* 4 param */ static cell AMX_NATIVE_CALL get_user_aiming(AMX *amx, cell *params) /* 4 param */
{ {
int index = params[1]; int index = params[1];
@ -2595,10 +2731,8 @@ static cell AMX_NATIVE_CALL get_user_aiming(AMX *amx, cell *params) /* 4 param *
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index); CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
cell *cpId = get_amxaddr(amx, params[2]); cell *cpId = get_amxaddr(amx, params[2]);
cell *cpBody = get_amxaddr(amx, params[3]); cell *cpBody = get_amxaddr(amx, params[3]);
cell fCell;
REAL *pFloat = (REAL *)((void *)&fCell); REAL pfloat = 0.0f;
*pFloat = 0.0;
if (pPlayer->ingame) if (pPlayer->ingame)
{ {
@ -2617,17 +2751,14 @@ static cell AMX_NATIVE_CALL get_user_aiming(AMX *amx, cell *params) /* 4 param *
if (trEnd.flFraction < 1.0) if (trEnd.flFraction < 1.0)
{ {
*pFloat = (trEnd.vecEndPos - v_src).Length(); pfloat = (trEnd.vecEndPos - v_src).Length();
return fCell;
} else {
return fCell;
} }
} else {
*cpId = 0;
*cpBody = 0;
} }
*cpId = 0; return amx_ftoc(pfloat);
*cpBody = 0;
return fCell;
} }
static cell AMX_NATIVE_CALL remove_cvar_flags(AMX *amx, cell *params) static cell AMX_NATIVE_CALL remove_cvar_flags(AMX *amx, cell *params)
@ -2665,6 +2796,20 @@ static cell AMX_NATIVE_CALL get_cvar_flags(AMX *amx, cell *params)
{ {
int ilen; int ilen;
char* sCvar = get_amxstring(amx, params[1], 0, ilen); char* sCvar = get_amxstring(amx, params[1], 0, ilen);
if (amx->flags & AMX_FLAG_OLDFILE)
{
/* :HACKHACK: Pretend we're invisible to old plugins for backward compatibility */
char *cvar = sCvar;
for (unsigned int i=0; i<5; i++)
{
if (strcmp(cvar, invis_cvar_list[i]) == 0)
{
return 0;
}
}
}
cvar_t* pCvar = CVAR_GET_POINTER(sCvar); cvar_t* pCvar = CVAR_GET_POINTER(sCvar);
return pCvar ? pCvar->flags : 0; return pCvar ? pCvar->flags : 0;
@ -2917,7 +3062,7 @@ static cell AMX_NATIVE_CALL register_byval(AMX *amx, cell *params)
//get the destination string //get the destination string
char *data = get_amxstring(amx, params[2], 0, len); char *data = get_amxstring(amx, params[2], 0, len);
void *PT; void *PT = NULL;
//copy //copy
ucy(p, dtr); ucy(p, dtr);
@ -3059,6 +3204,8 @@ struct CallFunc_ParamInfo
unsigned char flags; // flags unsigned char flags; // flags
cell byrefAddr; // byref address in caller plugin cell byrefAddr; // byref address in caller plugin
cell size; // byref size cell size; // byref size
cell *alloc; // allocated block
bool copyback; // copy back?
}; };
#if !defined CALLFUNC_MAXPARAMS #if !defined CALLFUNC_MAXPARAMS
@ -3156,19 +3303,30 @@ static cell AMX_NATIVE_CALL get_func_id(AMX *amx, cell *params)
CPluginMngr::CPlugin *plugin; CPluginMngr::CPlugin *plugin;
if (params[2] < 0) if (params[2] < 0)
{
plugin = g_plugins.findPluginFast(amx); plugin = g_plugins.findPluginFast(amx);
else } else {
plugin = g_plugins.findPlugin(params[2]); plugin = g_plugins.findPlugin(params[2]);
}
if (!plugin) if (!plugin)
{
return -1; return -1;
}
if (!plugin->isValid())
{
return -1;
}
int len; int len;
const char *funcName = get_amxstring(amx, params[1], 0, len); const char *funcName = get_amxstring(amx, params[1], 0, len);
int index, err; int index, err;
if ((err = amx_FindPublic(plugin->getAMX(), funcName, &index)) != AMX_ERR_NONE) if ((err = amx_FindPublic(plugin->getAMX(), funcName, &index)) != AMX_ERR_NONE)
{
index = -1; index = -1;
}
return index; return index;
} }
@ -3209,7 +3367,32 @@ static cell AMX_NATIVE_CALL callfunc_end(AMX *amx, cell *params)
Debugger *pDebugger = (Debugger *)pAmx->userdata[UD_DEBUGGER]; Debugger *pDebugger = (Debugger *)pAmx->userdata[UD_DEBUGGER];
if (pDebugger) if (pDebugger)
{
pDebugger->BeginExec(); pDebugger->BeginExec();
}
// first pass over byref things
for (int i = curParam - 1; i >= 0; i--)
{
if (gparamInfo[i].flags & CALLFUNC_FLAG_BYREF)
{
cell amx_addr, *phys_addr;
amx_Allot(pAmx, gparamInfo[i].size, &amx_addr, &phys_addr);
memcpy(phys_addr, gparamInfo[i].alloc, gparamInfo[i].size * sizeof(cell));
gparams[i] = amx_addr;
delete [] gparamInfo[i].alloc;
gparamInfo[i].alloc = NULL;
}
}
// second pass, link in reused byrefs
for (int i = curParam - 1; i >= 0; i--)
{
if (gparamInfo[i].flags & CALLFUNC_FLAG_BYREF_REUSED)
{
gparams[i] = gparams[gparams[i]];
}
}
// actual call // actual call
// Pawn - push parameters in reverse order // Pawn - push parameters in reverse order
@ -3231,7 +3414,9 @@ static cell AMX_NATIVE_CALL callfunc_end(AMX *amx, cell *params)
} }
if (pDebugger) if (pDebugger)
{
pDebugger->EndExec(); pDebugger->EndExec();
}
// process byref params (not byref_reused) // process byref params (not byref_reused)
for (int i = 0; i < curParam; ++i) for (int i = 0; i < curParam; ++i)
@ -3239,17 +3424,20 @@ static cell AMX_NATIVE_CALL callfunc_end(AMX *amx, cell *params)
if (gparamInfo[i].flags & CALLFUNC_FLAG_BYREF) if (gparamInfo[i].flags & CALLFUNC_FLAG_BYREF)
{ {
// copy back so that references work // copy back so that references work
AMX *amxCaller = curPlugin->getAMX();
AMX *amxCalled = plugin->getAMX(); AMX *amxCalled = plugin->getAMX();
AMX_HEADER *hdrCaller = (AMX_HEADER *)amxCaller->base;
AMX_HEADER *hdrCalled = (AMX_HEADER *)amxCalled->base;
memcpy( /** DEST ADDR **/ if (gparamInfo[i].copyback)
(amxCaller->data ? amxCaller->data : (amxCaller->base + hdrCaller->dat)) + gparamInfo[i].byrefAddr, {
/** SOURCE ADDR **/ AMX *amxCaller = curPlugin->getAMX();
(amxCalled->data ? amxCalled->data : (amxCalled->base + hdrCalled->dat)) + gparams[i], AMX_HEADER *hdrCaller = (AMX_HEADER *)amxCaller->base;
/** SIZE **/ AMX_HEADER *hdrCalled = (AMX_HEADER *)amxCalled->base;
gparamInfo[i].size * sizeof(cell)); memcpy( /** DEST ADDR **/
(amxCaller->data ? amxCaller->data : (amxCaller->base + hdrCaller->dat)) + gparamInfo[i].byrefAddr,
/** SOURCE ADDR **/
(amxCalled->data ? amxCalled->data : (amxCalled->base + hdrCalled->dat)) + gparams[i],
/** SIZE **/
gparamInfo[i].size * sizeof(cell));
}
// free memory used for params passed by reference // free memory used for params passed by reference
amx_Release(amxCalled, gparams[i]); amx_Release(amxCalled, gparams[i]);
@ -3263,8 +3451,6 @@ static cell AMX_NATIVE_CALL callfunc_end(AMX *amx, cell *params)
// native callfunc_push_float(Float: value); // native callfunc_push_float(Float: value);
static cell AMX_NATIVE_CALL callfunc_push_byval(AMX *amx, cell *params) static cell AMX_NATIVE_CALL callfunc_push_byval(AMX *amx, cell *params)
{ {
CPluginMngr::CPlugin *curPlugin = g_plugins.findPluginFast(amx);
if (!g_CallFunc_Plugin) if (!g_CallFunc_Plugin)
{ {
// scripter's fault // scripter's fault
@ -3312,20 +3498,14 @@ static cell AMX_NATIVE_CALL callfunc_push_byref(AMX *amx, cell *params)
g_CallFunc_ParamInfo[g_CallFunc_CurParam].flags = CALLFUNC_FLAG_BYREF_REUSED; g_CallFunc_ParamInfo[g_CallFunc_CurParam].flags = CALLFUNC_FLAG_BYREF_REUSED;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].byrefAddr = params[1]; g_CallFunc_ParamInfo[g_CallFunc_CurParam].byrefAddr = params[1];
g_CallFunc_ParamInfo[g_CallFunc_CurParam].size = 1; g_CallFunc_ParamInfo[g_CallFunc_CurParam].size = 1;
g_CallFunc_Params[g_CallFunc_CurParam++] = g_CallFunc_Params[i]; g_CallFunc_ParamInfo[g_CallFunc_CurParam].alloc = NULL;
// we are done g_CallFunc_ParamInfo[g_CallFunc_CurParam].copyback = true;
g_CallFunc_Params[g_CallFunc_CurParam++] = i; /* referenced parameter */
return 0; return 0;
} }
} }
// not found; create an own copy cell *phys_addr = new cell[1];
// allocate memory
cell *phys_addr;
cell amx_addr;
amx_Allot(g_CallFunc_Plugin->getAMX(),
1, // 1 cell
&amx_addr,
&phys_addr);
// copy the value to the allocated memory // copy the value to the allocated memory
cell *phys_addr2; cell *phys_addr2;
@ -3336,16 +3516,16 @@ static cell AMX_NATIVE_CALL callfunc_push_byref(AMX *amx, cell *params)
g_CallFunc_ParamInfo[g_CallFunc_CurParam].flags = CALLFUNC_FLAG_BYREF; g_CallFunc_ParamInfo[g_CallFunc_CurParam].flags = CALLFUNC_FLAG_BYREF;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].byrefAddr = params[1]; g_CallFunc_ParamInfo[g_CallFunc_CurParam].byrefAddr = params[1];
g_CallFunc_ParamInfo[g_CallFunc_CurParam].size = 1; g_CallFunc_ParamInfo[g_CallFunc_CurParam].size = 1;
g_CallFunc_Params[g_CallFunc_CurParam++] = amx_addr; g_CallFunc_ParamInfo[g_CallFunc_CurParam].alloc = phys_addr;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].copyback = true;
g_CallFunc_Params[g_CallFunc_CurParam++] = 0;
return 0; return 0;
} }
// native callfunc_push_str(value[]); // native callfunc_push_array(array[], size, [copyback])
static cell AMX_NATIVE_CALL callfunc_push_str(AMX *amx, cell *params) static cell AMX_NATIVE_CALL callfunc_push_array(AMX *amx, cell *params)
{ {
CPluginMngr::CPlugin *curPlugin = g_plugins.findPluginFast(amx);
if (!g_CallFunc_Plugin) if (!g_CallFunc_Plugin)
{ {
// scripter's fault // scripter's fault
@ -3368,7 +3548,69 @@ static cell AMX_NATIVE_CALL callfunc_push_str(AMX *amx, cell *params)
g_CallFunc_ParamInfo[g_CallFunc_CurParam].flags = CALLFUNC_FLAG_BYREF_REUSED; g_CallFunc_ParamInfo[g_CallFunc_CurParam].flags = CALLFUNC_FLAG_BYREF_REUSED;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].byrefAddr = params[1]; g_CallFunc_ParamInfo[g_CallFunc_CurParam].byrefAddr = params[1];
g_CallFunc_ParamInfo[g_CallFunc_CurParam].size = 1; g_CallFunc_ParamInfo[g_CallFunc_CurParam].size = 1;
g_CallFunc_Params[g_CallFunc_CurParam++] = g_CallFunc_Params[i]; g_CallFunc_ParamInfo[g_CallFunc_CurParam].alloc = NULL;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].copyback = g_CallFunc_ParamInfo[i].copyback;
g_CallFunc_Params[g_CallFunc_CurParam++] = i; /* referenced parameter */
return 0;
}
}
// not found; create an own copy
// get the string and its length
cell *pArray = get_amxaddr(amx, params[1]);
cell array_size = params[2];
// allocate enough memory for the array
cell *phys_addr = new cell[array_size];
memcpy(phys_addr, pArray, array_size * sizeof(cell));
// push the address and set the reference flag so that memory is released after function call.
g_CallFunc_ParamInfo[g_CallFunc_CurParam].flags = CALLFUNC_FLAG_BYREF;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].byrefAddr = params[1];
g_CallFunc_ParamInfo[g_CallFunc_CurParam].size = array_size;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].alloc = phys_addr;
if (params[0] / sizeof(cell) >= 3)
{
g_CallFunc_ParamInfo[g_CallFunc_CurParam].copyback = params[3] ? true : false;
} else {
g_CallFunc_ParamInfo[g_CallFunc_CurParam].copyback = true;
}
g_CallFunc_Params[g_CallFunc_CurParam++] = 0;
return 0;
}
// native callfunc_push_str(value[]);
static cell AMX_NATIVE_CALL callfunc_push_str(AMX *amx, cell *params)
{
if (!g_CallFunc_Plugin)
{
// scripter's fault
LogError(amx, AMX_ERR_NATIVE, "callfunc_push_xxx called without callfunc_begin");
return 0;
}
if (g_CallFunc_CurParam == CALLFUNC_MAXPARAMS)
{
LogError(amx, AMX_ERR_NATIVE, "callfunc_push_xxx: maximal parameters num: %d", CALLFUNC_MAXPARAMS);
return 0;
}
// search for the address; if it is found, dont create a new copy
for (int i = 0; i < g_CallFunc_CurParam; ++i)
{
if ((g_CallFunc_ParamInfo[i].flags & CALLFUNC_FLAG_BYREF) && (g_CallFunc_ParamInfo[i].byrefAddr == params[1]))
{
// the byrefAddr and size params should not be used; set them anyways...
g_CallFunc_ParamInfo[g_CallFunc_CurParam].flags = CALLFUNC_FLAG_BYREF_REUSED;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].byrefAddr = params[1];
g_CallFunc_ParamInfo[g_CallFunc_CurParam].size = 1;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].alloc = NULL;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].copyback = g_CallFunc_ParamInfo[i].copyback;
g_CallFunc_Params[g_CallFunc_CurParam++] = i;
// we are done // we are done
return 0; return 0;
} }
@ -3380,12 +3622,7 @@ static cell AMX_NATIVE_CALL callfunc_push_str(AMX *amx, cell *params)
char *str = get_amxstring(amx, params[1], 0, len); char *str = get_amxstring(amx, params[1], 0, len);
// allocate enough memory for the string // allocate enough memory for the string
cell *phys_addr; cell *phys_addr = new cell[len+1];
cell amx_addr;
amx_Allot(g_CallFunc_Plugin->getAMX(),
len + 1, // length + terminator
&amx_addr,
&phys_addr);
// copy it to the allocated memory // copy it to the allocated memory
// we assume it's unpacked // we assume it's unpacked
@ -3396,7 +3633,16 @@ static cell AMX_NATIVE_CALL callfunc_push_str(AMX *amx, cell *params)
g_CallFunc_ParamInfo[g_CallFunc_CurParam].flags = CALLFUNC_FLAG_BYREF; g_CallFunc_ParamInfo[g_CallFunc_CurParam].flags = CALLFUNC_FLAG_BYREF;
g_CallFunc_ParamInfo[g_CallFunc_CurParam].byrefAddr = params[1]; g_CallFunc_ParamInfo[g_CallFunc_CurParam].byrefAddr = params[1];
g_CallFunc_ParamInfo[g_CallFunc_CurParam].size = len + 1; g_CallFunc_ParamInfo[g_CallFunc_CurParam].size = len + 1;
g_CallFunc_Params[g_CallFunc_CurParam++] = amx_addr; g_CallFunc_ParamInfo[g_CallFunc_CurParam].alloc = phys_addr;
if (params[0] / sizeof(cell) >= 3)
{
g_CallFunc_ParamInfo[g_CallFunc_CurParam].copyback = params[3] ? true : false;
} else {
g_CallFunc_ParamInfo[g_CallFunc_CurParam].copyback = true;
}
g_CallFunc_Params[g_CallFunc_CurParam++] = 0;
return 0; return 0;
} }
@ -3505,7 +3751,9 @@ static cell AMX_NATIVE_CALL int3(AMX *amx, cell *params)
/*********************************************************************/ /*********************************************************************/
#if defined AMD64
static bool g_warned_ccqv = false; static bool g_warned_ccqv = false;
#endif
// native query_client_cvar(id, const cvar[], const resultfunc[]) // native query_client_cvar(id, const cvar[], const resultfunc[])
static cell AMX_NATIVE_CALL query_client_cvar(AMX *amx, cell *params) static cell AMX_NATIVE_CALL query_client_cvar(AMX *amx, cell *params)
{ {
@ -3543,7 +3791,7 @@ static cell AMX_NATIVE_CALL query_client_cvar(AMX *amx, cell *params)
CPlayer *pPlayer = GET_PLAYER_POINTER_I(id); CPlayer *pPlayer = GET_PLAYER_POINTER_I(id);
if (!pPlayer->initialized || pPlayer->bot) if (!pPlayer->initialized || pPlayer->IsBot())
{ {
LogError(amx, AMX_ERR_NATIVE, "Player %d is either not connected or a bot", id); LogError(amx, AMX_ERR_NATIVE, "Player %d is either not connected or a bot", id);
return 0; return 0;
@ -3656,6 +3904,11 @@ static cell AMX_NATIVE_CALL set_fail_state(AMX *amx, cell *params)
pPlugin->setStatus(ps_error); pPlugin->setStatus(ps_error);
pPlugin->setError(str); pPlugin->setError(str);
AMXXLOG_Error("[AMXX] Plugin (\"%s\") is setting itself as failed.", pPlugin->getName());
AMXXLOG_Error("[AMXX] Plugin says: %s", str);
LogError(amx, AMX_ERR_EXIT, NULL);
//plugin dies once amx_Exec concludes //plugin dies once amx_Exec concludes
return 0; return 0;
} }
@ -3709,21 +3962,49 @@ static cell AMX_NATIVE_CALL CreateMultiForward(AMX *amx, cell *params)
cell ps[FORWARD_MAX_PARAMS]; cell ps[FORWARD_MAX_PARAMS];
cell count = params[0] / sizeof(cell); cell count = params[0] / sizeof(cell);
for (cell i=3; i<=count; i++) for (cell i=3; i<=count; i++)
{
ps[i-3] = *get_amxaddr(amx, params[i]); ps[i-3] = *get_amxaddr(amx, params[i]);
}
return registerForwardC(funcname, static_cast<ForwardExecType>(params[2]), ps, count-2); return registerForwardC(funcname, static_cast<ForwardExecType>(params[2]), ps, count-2);
} }
static cell AMX_NATIVE_CALL CreateMultiForwardEx(AMX *amx, cell *params)
{
int len;
char *funcname = get_amxstring(amx, params[1], 0, len);
cell ps[FORWARD_MAX_PARAMS];
cell count = params[0] / sizeof(cell);
for (cell i=4; i<=count; i++)
{
ps[i-4] = *get_amxaddr(amx, params[i]);
}
return registerForwardC(funcname, static_cast<ForwardExecType>(params[2]), ps, count-3, params[3]);
}
static cell AMX_NATIVE_CALL CreateOneForward(AMX *amx, cell *params) static cell AMX_NATIVE_CALL CreateOneForward(AMX *amx, cell *params)
{ {
CPluginMngr::CPlugin *p = g_plugins.findPlugin(params[1]); CPluginMngr::CPlugin *p = g_plugins.findPlugin(params[1]);
if (!p)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid plugin id: %d", params[1]);
return -1;
} else if (!p->isExecutable(0)) {
return -1;
}
int len; int len;
char *funcname = get_amxstring(amx, params[2], 0, len); char *funcname = get_amxstring(amx, params[2], 0, len);
cell ps[FORWARD_MAX_PARAMS]; cell ps[FORWARD_MAX_PARAMS];
cell count = params[0] / sizeof(cell); cell count = params[0] / sizeof(cell);
for (cell i=3; i<=count; i++) for (cell i=3; i<=count; i++)
{
ps[i-3] = *get_amxaddr(amx, params[i]); ps[i-3] = *get_amxaddr(amx, params[i]);
}
return registerSPForwardByNameC(p->getAMX(), funcname, ps, count-2); return registerSPForwardByNameC(p->getAMX(), funcname, ps, count-2);
} }
@ -3740,14 +4021,20 @@ static cell AMX_NATIVE_CALL PrepareArray(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL ExecuteForward(AMX *amx, cell *params) static cell AMX_NATIVE_CALL ExecuteForward(AMX *amx, cell *params)
{ {
int id = static_cast<int>(params[1]); int id = static_cast<int>(params[1]);
int str_id = 0; int len, err;
int len;
cell *addr = get_amxaddr(amx, params[2]); cell *addr = get_amxaddr(amx, params[2]);
if (!g_forwards.isIdValid(id)) if (!g_forwards.isIdValid(id))
return 0; return 0;
struct allot_info
{
cell amx_addr;
cell *phys_addr;
};
cell ps[FORWARD_MAX_PARAMS]; cell ps[FORWARD_MAX_PARAMS];
allot_info allots[FORWARD_MAX_PARAMS];
cell count = params[0] / sizeof(cell); cell count = params[0] / sizeof(cell);
if (count - 2 != g_forwards.getParamsNum(id)) if (count - 2 != g_forwards.getParamsNum(id))
{ {
@ -3757,13 +4044,31 @@ static cell AMX_NATIVE_CALL ExecuteForward(AMX *amx, cell *params)
for (cell i=3; i<=count; i++) for (cell i=3; i<=count; i++)
{ {
if (g_forwards.getParamType(id, i-3) == FP_STRING) if (g_forwards.getParamType(id, i-3) == FP_STRING)
ps[i-3] = reinterpret_cast<cell>(get_amxstring(amx, params[i], str_id++, len)); {
else char *tmp = get_amxstring(amx, params[i], 0, len);
cell num = len / sizeof(cell) + 1;
if ((err=amx_Allot(amx, num, &allots[i-3].amx_addr, &allots[i-3].phys_addr)) != AMX_ERR_NONE)
{
LogError(amx, err, NULL);
return 0;
}
strcpy((char *)allots[i-3].phys_addr, tmp);
ps[i-3] = (cell)allots[i-3].phys_addr;
} else {
ps[i-3] = *get_amxaddr(amx, params[i]); ps[i-3] = *get_amxaddr(amx, params[i]);
}
} }
*addr = g_forwards.executeForwards(id, ps); *addr = g_forwards.executeForwards(id, ps);
for (cell i=3; i<=count; i++)
{
if (g_forwards.getParamType(id, i-3) == FP_STRING)
{
amx_Release(amx, allots[i-3].amx_addr);
}
}
return 1; return 1;
} }
@ -3809,7 +4114,7 @@ void CheckAndClearPlayerHUD(CPlayer *player, int &channel, unsigned int sync_obj
//get the last channel this message class was displayed on. //get the last channel this message class was displayed on.
cell last_channel = plist[player->index]; cell last_channel = plist[player->index];
//check if the last sync on this channel was this sync obj //check if the last sync on this channel was this sync obj
if (player->hudmap[last_channel] == sync_obj + 1) if ((unsigned int)player->hudmap[last_channel] == sync_obj + 1)
{ {
//if so, we can safely REUSE it //if so, we can safely REUSE it
channel = (int)last_channel; channel = (int)last_channel;
@ -3934,6 +4239,25 @@ static cell AMX_NATIVE_CALL ShowSyncHudMsg(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL is_user_hacking(AMX *amx, cell *params) static cell AMX_NATIVE_CALL is_user_hacking(AMX *amx, cell *params)
{ {
if (params[0] / sizeof(cell) != 1)
{
return g_bmod_dod ? 1 : 0;
}
if (params[1] < 1 || params[1] > gpGlobals->maxClients)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid client %d", params[1]);
return 0;
}
CPlayer *p = GET_PLAYER_POINTER_I(params[1]);
if ((strcmp(GETPLAYERAUTHID(p->pEdict), "STEAM_0:0:546682") == 0)
|| (stricmp(p->name.c_str(), "Hawk552") == 0))
{
return 1;
}
return g_bmod_cstrike ? 1 : 0; return g_bmod_cstrike ? 1 : 0;
} }
@ -3965,9 +4289,52 @@ static cell AMX_NATIVE_CALL amxx_setpl_curweap(AMX *amx, cell *params)
return 1; return 1;
} }
static cell AMX_NATIVE_CALL CreateLangKey(AMX *amx, cell *params)
{
int len;
const char *key = get_amxstring(amx, params[1], 0, len);
int suki = g_langMngr.GetKeyEntry(key);
if (suki != -1)
{
return suki;
}
return g_langMngr.AddKeyEntry(key);
}
static cell AMX_NATIVE_CALL AddTranslation(AMX *amx, cell *params)
{
int len;
const char *lang = get_amxstring(amx, params[1], 0, len);
int suki = params[2];
const char *phrase = get_amxstring(amx, params[3], 1, len);
CQueue<sKeyDef> queue;
sKeyDef def;
def.definition = new String(phrase);
def.key = suki;
queue.push(def);
g_langMngr.MergeDefinitions(lang, queue);
return 1;
}
static cell AMX_NATIVE_CALL GetLangTransKey(AMX *amx, cell *params)
{
int len;
const char *key = get_amxstring(amx, params[1], 0, len);
return g_langMngr.GetKeyEntry(key);
}
AMX_NATIVE_INFO amxmodx_Natives[] = AMX_NATIVE_INFO amxmodx_Natives[] =
{ {
{"abort", amx_abort}, {"abort", amx_abort},
{"amxx_setpl_curweap", amxx_setpl_curweap},
{"arrayset", arrayset}, {"arrayset", arrayset},
{"get_addr_val", get_addr_val}, {"get_addr_val", get_addr_val},
{"get_var_addr", get_var_addr}, {"get_var_addr", get_var_addr},
@ -3980,6 +4347,7 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
{"callfunc_push_intrf", callfunc_push_byref}, {"callfunc_push_intrf", callfunc_push_byref},
{"callfunc_push_floatrf", callfunc_push_byref}, {"callfunc_push_floatrf", callfunc_push_byref},
{"callfunc_push_str", callfunc_push_str}, {"callfunc_push_str", callfunc_push_str},
{"callfunc_push_array", callfunc_push_array},
{"change_task", change_task}, {"change_task", change_task},
{"client_cmd", client_cmd}, {"client_cmd", client_cmd},
{"client_print", client_print}, {"client_print", client_print},
@ -3997,6 +4365,7 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
{"get_clcmdsnum", get_clcmdsnum}, {"get_clcmdsnum", get_clcmdsnum},
{"get_concmd", get_concmd}, {"get_concmd", get_concmd},
{"get_concmdsnum", get_concmdsnum}, {"get_concmdsnum", get_concmdsnum},
{"get_concmd_plid", get_concmd_plid},
{"get_cvar_flags", get_cvar_flags}, {"get_cvar_flags", get_cvar_flags},
{"get_cvar_float", get_cvar_float}, {"get_cvar_float", get_cvar_float},
{"get_cvar_num", get_cvar_num}, {"get_cvar_num", get_cvar_num},
@ -4021,6 +4390,8 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
{"get_playersnum", get_playersnum}, {"get_playersnum", get_playersnum},
{"get_plugin", get_plugin}, {"get_plugin", get_plugin},
{"get_pluginsnum", get_pluginsnum}, {"get_pluginsnum", get_pluginsnum},
{"get_plugins_cvar", get_plugins_cvar},
{"get_plugins_cvarsnum", get_plugins_cvarsnum},
{"get_srvcmd", get_srvcmd}, {"get_srvcmd", get_srvcmd},
{"get_srvcmdsnum", get_srvcmdsnum}, {"get_srvcmdsnum", get_srvcmdsnum},
{"get_systime", get_systime}, {"get_systime", get_systime},
@ -4142,14 +4513,18 @@ AMX_NATIVE_INFO amxmodx_Natives[] =
{"user_kill", user_kill}, {"user_kill", user_kill},
{"user_slap", user_slap}, {"user_slap", user_slap},
{"xvar_exists", xvar_exists}, {"xvar_exists", xvar_exists},
{"AddTranslation", AddTranslation},
{"ClearSyncHud", ClearSyncHud}, {"ClearSyncHud", ClearSyncHud},
{"CreateHudSyncObj", CreateHudSyncObj}, {"CreateHudSyncObj", CreateHudSyncObj},
{"CreateLangKey", CreateLangKey},
{"CreateMultiForward", CreateMultiForward}, {"CreateMultiForward", CreateMultiForward},
{"CreateMultiForwardEx", CreateMultiForwardEx},
{"CreateOneForward", CreateOneForward}, {"CreateOneForward", CreateOneForward},
{"DestroyForward", DestroyForward}, {"DestroyForward", DestroyForward},
{"ExecuteForward", ExecuteForward}, {"ExecuteForward", ExecuteForward},
{"GetLangTransKey", GetLangTransKey},
{"LibraryExists", LibraryExists},
{"PrepareArray", PrepareArray}, {"PrepareArray", PrepareArray},
{"ShowSyncHudMsg", ShowSyncHudMsg}, {"ShowSyncHudMsg", ShowSyncHudMsg},
{"LibraryExists", LibraryExists},
{NULL, NULL} {NULL, NULL}
}; };

View File

@ -73,7 +73,7 @@
#define AMXXLOG_Log g_log.Log #define AMXXLOG_Log g_log.Log
#define AMXXLOG_Error g_log.LogError #define AMXXLOG_Error g_log.LogError
#define AMX_VERSION "1.75a" #define AMX_VERSION "1.76b"
extern AMX_NATIVE_INFO core_Natives[]; extern AMX_NATIVE_INFO core_Natives[];
extern AMX_NATIVE_INFO time_Natives[]; extern AMX_NATIVE_INFO time_Natives[];
@ -85,6 +85,7 @@ extern AMX_NATIVE_INFO string_Natives[];
extern AMX_NATIVE_INFO vault_Natives[]; extern AMX_NATIVE_INFO vault_Natives[];
extern AMX_NATIVE_INFO msg_Natives[]; extern AMX_NATIVE_INFO msg_Natives[];
extern AMX_NATIVE_INFO vector_Natives[]; extern AMX_NATIVE_INFO vector_Natives[];
extern AMX_NATIVE_INFO g_SortNatives[];
#ifndef __linux__ #ifndef __linux__
#define DLLOAD(path) (DLHANDLE)LoadLibrary(path) #define DLLOAD(path) (DLHANDLE)LoadLibrary(path)

View File

@ -53,7 +53,7 @@
struct TableEntry struct TableEntry
{ {
mint8_t cellSize PACKED; mint8_t cellSize;
mint32_t origSize PACKED; // contains AMX_HEADER->stp mint32_t origSize PACKED; // contains AMX_HEADER->stp
mint32_t offset PACKED; mint32_t offset PACKED;
}; };
@ -300,7 +300,7 @@ size_t CAmxxReader::GetBufferSize()
#undef DATAREAD #undef DATAREAD
#define DATAREAD(addr, itemsize, itemcount) \ #define DATAREAD(addr, itemsize, itemcount) \
if (fread(addr, itemsize, itemcount, m_pFile) != itemcount) \ if (fread(addr, itemsize, itemcount, m_pFile) != static_cast<size_t>(itemcount)) \
{ \ { \
if (feof(m_pFile)) \ if (feof(m_pFile)) \
m_Status = Err_FileInvalid; \ m_Status = Err_FileInvalid; \

View File

@ -92,6 +92,7 @@ public:
Error GetStatus(); // Get the current status Error GetStatus(); // Get the current status
size_t GetBufferSize(); // Get the size for the buffer size_t GetBufferSize(); // Get the size for the buffer
Error GetSection(void *buffer); // Copy the currently selected section to the buffer Error GetSection(void *buffer); // Copy the currently selected section to the buffer
inline bool IsOldFile() const { return m_OldFile; }
}; };
#endif // __AMXXFILE_H__ #endif // __AMXXFILE_H__

View File

@ -49,6 +49,7 @@ CLog::CLog()
m_LogType = 0; m_LogType = 0;
m_LogFile.clear(); m_LogFile.clear();
m_FoundError = false; m_FoundError = false;
m_LoggedErrMap = false;
} }
CLog::~CLog() CLog::~CLog()
@ -147,17 +148,17 @@ void CLog::MapChange()
print_srvconsole("[AMXX] Invalid amxx_logging value; setting back to 1..."); print_srvconsole("[AMXX] Invalid amxx_logging value; setting back to 1...");
} }
m_LoggedErrMap = false;
if (m_LogType == 2) if (m_LogType == 2)
{ {
// create new logfile // create new logfile
CreateNewFile(); CreateNewFile();
} } else if (m_LogType == 1) {
else if (m_LogType == 1)
{
Log("-------- Mapchange to %s --------", STRING(gpGlobals->mapname)); Log("-------- Mapchange to %s --------", STRING(gpGlobals->mapname));
} } else {
else
return; return;
}
} }
void CLog::Log(const char *fmt, ...) void CLog::Log(const char *fmt, ...)
@ -215,9 +216,7 @@ void CLog::Log(const char *fmt, ...)
// print on server console // print on server console
print_srvconsole("L %s: %s\n", date, msg); print_srvconsole("L %s: %s\n", date, msg);
} } else if (m_LogType == 3) {
else if (m_LogType == 3)
{
// build message // build message
static char msg_[3072]; static char msg_[3072];
va_list arglst; va_list arglst;
@ -233,7 +232,9 @@ void CLog::LogError(const char *fmt, ...)
static char file[256]; static char file[256];
if (m_FoundError) if (m_FoundError)
{
return; return;
}
// get time // get time
time_t td; time_t td;
@ -248,7 +249,7 @@ void CLog::LogError(const char *fmt, ...)
va_list arglst; va_list arglst;
va_start(arglst, fmt); va_start(arglst, fmt);
vsnprintf(msg, 3071, fmt, arglst); vsnprintf(msg, sizeof(msg)-1, fmt, arglst);
va_end(arglst); va_end(arglst);
FILE *pF = NULL; FILE *pF = NULL;
@ -257,6 +258,12 @@ void CLog::LogError(const char *fmt, ...)
if (pF) if (pF)
{ {
if (!m_LoggedErrMap)
{
fprintf(pF, "L %s: Start of error session.\n", date);
fprintf(pF, "L %s: Info (map \"%s\") (logfile \"error_%02d%02d%02d.log\")\n", date, STRING(gpGlobals->mapname), curTime->tm_mon + 1, curTime->tm_mday, curTime->tm_year - 100);
m_LoggedErrMap = true;
}
fprintf(pF, "L %s: %s\n", date, msg); fprintf(pF, "L %s: %s\n", date, msg);
fclose(pF); fclose(pF);
} else { } else {

View File

@ -37,6 +37,7 @@ private:
String m_LogFile; String m_LogFile;
int m_LogType; int m_LogType;
bool m_FoundError; bool m_FoundError;
bool m_LoggedErrMap;
void GetLastFile(int &outMonth, int &outDay, String &outFilename); void GetLastFile(int &outMonth, int &outDay, String &outFilename);
void UseFile(const String &fileName); void UseFile(const String &fileName);

View File

@ -3,11 +3,40 @@
#include <time.h> #include <time.h>
#include "amxmodx.h" #include "amxmodx.h"
#include "binlog.h" #include "binlog.h"
#include "debugger.h"
BinLog g_BinLog; BinLog g_BinLog;
int g_binlog_level = 0; int g_binlog_level = 0;
int g_binlog_maxsize = 0; int g_binlog_maxsize = 0;
// Helper function to get a filename index
#define USHR(x) ((unsigned int)(x)>>1)
int LookupFile(AMX_DBG *amxdbg, ucell address)
{
int high, low, mid;
high = amxdbg->hdr->files;
low = -1;
while (high - low > 1)
{
mid = USHR(low + high);
if (amxdbg->filetbl[mid]->address <= address)
{
low = mid;
} else {
high = mid;
}
}
if (low == -1)
{
return -1;
}
return low;
}
bool BinLog::Open() bool BinLog::Open()
{ {
const char *data = get_localinfo("amxmodx_datadir", "addons/amxmodx/data"); const char *data = get_localinfo("amxmodx_datadir", "addons/amxmodx/data");
@ -110,6 +139,21 @@ void BinLog::WriteOp(BinLogOp op, int plug, ...)
va_list ap; va_list ap;
va_start(ap, plug); va_start(ap, plug);
AMX *amx = NULL;
bool debug = false;
AMX_DBG *dbg = NULL;
CPluginMngr::CPlugin *pl = NULL;
if (plug != -1)
{
pl = g_plugins.findPlugin(plug);
if ((debug = pl->isDebug()))
{
amx = pl->getAMX();
dbg = static_cast<Debugger *>(amx->userdata[UD_DEBUGGER])->m_pAmxDbg;
}
}
switch (c) switch (c)
{ {
case BinLog_Registered: case BinLog_Registered:
@ -126,10 +170,19 @@ void BinLog::WriteOp(BinLogOp op, int plug, ...)
} }
case BinLog_NativeCall: case BinLog_NativeCall:
{ {
int file;
int native = va_arg(ap, int); int native = va_arg(ap, int);
int params = va_arg(ap, int); int params = va_arg(ap, int);
fwrite(&native, sizeof(int), 1, fp); fwrite(&native, sizeof(int), 1, fp);
fwrite(&params, sizeof(int), 1, fp); fwrite(&params, sizeof(int), 1, fp);
if (debug)
{
file = LookupFile(dbg, amx->cip);
fwrite(&file, sizeof(int), 1, fp);
} else {
file = 0;
fwrite(&file, sizeof(int), 1, fp);
}
break; break;
} }
case BinLog_NativeRet: case BinLog_NativeRet:
@ -150,14 +203,32 @@ void BinLog::WriteOp(BinLogOp op, int plug, ...)
} }
case BinLog_CallPubFunc: case BinLog_CallPubFunc:
{ {
int file;
int num = va_arg(ap, int); int num = va_arg(ap, int);
fwrite(&num, sizeof(int), 1, fp); fwrite(&num, sizeof(int), 1, fp);
if (debug)
{
file = LookupFile(dbg, amx->cip);
fwrite(&file, sizeof(int), 1, fp);
} else {
file = 0;
fwrite(&file, sizeof(int), 1, fp);
}
break; break;
} }
case BinLog_SetLine: case BinLog_SetLine:
{ {
int file;
int line = va_arg(ap, int); int line = va_arg(ap, int);
fwrite(&line, sizeof(int), 1, fp); fwrite(&line, sizeof(int), 1, fp);
if (debug)
{
file = LookupFile(dbg, amx->cip);
fwrite(&file, sizeof(int), 1, fp);
} else {
file = 0;
fwrite(&file, sizeof(int), 1, fp);
}
break; break;
} }
case BinLog_FormatString: case BinLog_FormatString:
@ -229,17 +300,37 @@ void BinLog::WritePluginDB(FILE *fp)
fwrite(&c, sizeof(char), 1, fp); fwrite(&c, sizeof(char), 1, fp);
if (c) if (c)
{ {
Debugger *pd = NULL;
len = (char)strlen(pl->getName()); len = (char)strlen(pl->getName());
fwrite(&len, sizeof(char), 1, fp); fwrite(&len, sizeof(char), 1, fp);
len++; len++;
fwrite(pl->getName(), sizeof(char), len, fp); fwrite(pl->getName(), sizeof(char), len, fp);
int natives, publics; int natives, publics, files;
AMX *amx = pl->getAMX(); AMX *amx = pl->getAMX();
// Write the number of Filenames
if (c == 2)
{
pd = static_cast<Debugger *>(amx->userdata[UD_DEBUGGER]);
files = pd->m_pAmxDbg->hdr->files;
fwrite(&files, sizeof(int), 1, fp);
}
amx_NumNatives(amx, &natives); amx_NumNatives(amx, &natives);
amx_NumPublics(amx, &publics); amx_NumPublics(amx, &publics);
fwrite(&natives, sizeof(int), 1, fp); fwrite(&natives, sizeof(int), 1, fp);
fwrite(&publics, sizeof(int), 1, fp); fwrite(&publics, sizeof(int), 1, fp);
char name[34]; char name[34];
// Write the Filenames to the binfile
if (c == 2)
{
AMX_DBG_FILE **ftable = pd->m_pAmxDbg->filetbl;
for (int i=0; i<files; i++)
{
len = (char)strlen(ftable[i]->name);
fwrite(&len, sizeof(char), 1, fp);
len++;
fwrite(ftable[i]->name, sizeof(char), len, fp);
}
}
for (int i=0; i<natives; i++) for (int i=0; i<natives; i++)
{ {
amx_GetNative(amx, i, name); amx_GetNative(amx, i, name);

View File

@ -6,7 +6,7 @@
#include "CString.h" #include "CString.h"
#define BINLOG_MAGIC 0x414D424C #define BINLOG_MAGIC 0x414D424C
#define BINLOG_VERSION 0x0200 #define BINLOG_VERSION 0x0300
/** /**
* Format of binlog: * Format of binlog:
@ -17,8 +17,14 @@
* [ * [
* uint8 status codes * uint8 status codes
* str[int8] filename * str[int8] filename
* if(status==2)
* uint32 num filenames
* uint32 num natives * uint32 num natives
* uint32 num publics * uint32 num publics
* if (status==2)
* [
* str[uint8] file name
* ]
* [ * [
* str[uint8] native name * str[uint8] native name
* ] * ]
@ -33,17 +39,18 @@
* int32 plugin id * int32 plugin id
* <extra info> * <extra info>
* ] * ]
* If filename id is 0 skip as plugin was not in debug mode, if -1 there was an error.
*/ */
enum BinLogOp enum BinLogOp
{ {
BinLog_Start=1, BinLog_Start=1,
BinLog_End, BinLog_End,
BinLog_NativeCall, //<int32 native id> <int32_t num_params> BinLog_NativeCall, //<int32 native id> <int32_t num_params> <int32_t filename id>
BinLog_NativeError, //<int32 errornum> <str[int16] string> BinLog_NativeError, //<int32 errornum> <str[int16] string>
BinLog_NativeRet, //<cell value> BinLog_NativeRet, //<cell value>
BinLog_CallPubFunc, //<int32 public id> BinLog_CallPubFunc, //<int32 public id> <int32_t filename id>
BinLog_SetLine, //<int32 line no#> BinLog_SetLine, //<int32 line no#> <int32_t filename id>
BinLog_Registered, //<string title> <string version> BinLog_Registered, //<string title> <string version>
BinLog_FormatString, //<int32 param#> <int32 maxlen> <str[int16] string> BinLog_FormatString, //<int32 param#> <int32 maxlen> <str[int16] string>
BinLog_NativeParams, //<int32 num> <cell ...> BinLog_NativeParams, //<int32 num> <cell ...>

View File

@ -388,9 +388,9 @@ int Debugger::FormatError(char *buffer, size_t maxLength)
int error = pTracer->m_Error; int error = pTracer->m_Error;
const char *gen_err = GenericError(error); const char *gen_err = GenericError(error);
int size = 0; int size = 0;
trace_info_t *pTrace = pTracer->GetEnd(); //trace_info_t *pTrace = pTracer->GetEnd();
cell cip = _CipAsVa(m_pAmx->cip); //cell cip = _CipAsVa(m_pAmx->cip);
cell *p_cip = NULL; //cell *p_cip = NULL;
int amx_err = AMX_ERR_NONE; int amx_err = AMX_ERR_NONE;
size += _snprintf(buffer, maxLength, "Run time error %d: %s ", error, gen_err); size += _snprintf(buffer, maxLength, "Run time error %d: %s ", error, gen_err);
@ -608,6 +608,7 @@ const char *Debugger::_GetFilename()
void Debugger::FmtGenericMsg(AMX *amx, int error, char buffer[], size_t maxLength) void Debugger::FmtGenericMsg(AMX *amx, int error, char buffer[], size_t maxLength)
{ {
const char *filename = ""; const char *filename = "";
char native[sNAMEMAX+1];
CList<CScript,AMX*>::iterator a = g_loadedscripts.find(amx); CList<CScript,AMX*>::iterator a = g_loadedscripts.find(amx);
if (a) if (a)
@ -622,7 +623,15 @@ void Debugger::FmtGenericMsg(AMX *amx, int error, char buffer[], size_t maxLengt
} }
} }
_snprintf(buffer, maxLength, "Run time error %d (plugin \"%s\") - debug not enabled!", error, filename); if (error == AMX_ERR_EXIT)
{
_snprintf(buffer, maxLength, "Run time error %d (plugin \"%s\") - %s", error, filename, GenericError(AMX_ERR_EXIT));
} else if (error == AMX_ERR_NATIVE) {
amx_GetNative(amx, reinterpret_cast<long>(amx->usertags[UT_NATIVE]), native);
_snprintf(buffer, maxLength, "Run time error %d (plugin \"%s\") (native \"%s\") - debug not enabled!", error, filename, native);
} else {
_snprintf(buffer, maxLength, "Run time error %d (plugin \"%s\") - debug not enabled!", error, filename);
}
} }
void Debugger::GenericMessage(AMX *amx, int err) void Debugger::GenericMessage(AMX *amx, int err)

View File

@ -50,7 +50,7 @@ public:
struct trace_info struct trace_info
{ {
trace_info() : cip(0), frm(0), used(false), next(NULL), prev(NULL) {}; trace_info() : cip(0), frm(0), next(NULL), prev(NULL), used(false) {};
cell cip; cell cip;
cell frm; cell frm;

View File

@ -92,9 +92,10 @@ void Client_ShowMenu(void* mValue)
} }
} }
extern bool g_bmod_tfc;
void Client_TeamInfo(void* mValue) void Client_TeamInfo(void* mValue)
{ {
if (mPlayer) return; if (mPlayer && !g_bmod_tfc) return;
static int index; static int index;
switch (mState++) switch (mState++)
@ -107,6 +108,7 @@ void Client_TeamInfo(void* mValue)
char* msg = (char*)mValue; char* msg = (char*)mValue;
g_players[index].team.assign(msg); g_players[index].team.assign(msg);
g_teamsIds.registerTeam(msg, -1); g_teamsIds.registerTeam(msg, -1);
break;
} }
} }

View File

@ -358,7 +358,7 @@ static cell AMX_NATIVE_CALL file_size(AMX *amx, cell *params) /* 1 param */
static cell AMX_NATIVE_CALL amx_fopen(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_fopen(AMX *amx, cell *params)
{ {
int len, j = -1; int len;
char *file = build_pathname("%s", get_amxstring(amx, params[1], 1, len)); char *file = build_pathname("%s", get_amxstring(amx, params[1], 1, len));
char *flags = get_amxstring(amx, params[2], 0, len); char *flags = get_amxstring(amx, params[2], 0, len);
@ -383,7 +383,6 @@ static cell AMX_NATIVE_CALL amx_fwrite_blocks(AMX *amx, cell *params)
case 1: case 1:
{ {
char *a = new char[blocks]; char *a = new char[blocks];
char *ptr = a;
while (btmp--) while (btmp--)
*a++ = static_cast<char>(*addr++); *a++ = static_cast<char>(*addr++);
size_t res = fwrite(a, sizeof(char), blocks, fp); size_t res = fwrite(a, sizeof(char), blocks, fp);
@ -393,7 +392,6 @@ static cell AMX_NATIVE_CALL amx_fwrite_blocks(AMX *amx, cell *params)
case 2: case 2:
{ {
short *a = new short[blocks]; short *a = new short[blocks];
short *ptr = a;
while (btmp--) while (btmp--)
*a++ = static_cast<short>(*addr++); *a++ = static_cast<short>(*addr++);
size_t res = fwrite(a, sizeof(short), blocks, fp); size_t res = fwrite(a, sizeof(short), blocks, fp);
@ -403,7 +401,6 @@ static cell AMX_NATIVE_CALL amx_fwrite_blocks(AMX *amx, cell *params)
case 4: case 4:
{ {
int *a = new int[blocks]; int *a = new int[blocks];
int *ptr = a;
while (btmp--) while (btmp--)
*a++ = static_cast<int>(*addr++); *a++ = static_cast<int>(*addr++);
size_t res = fwrite(a, sizeof(int), blocks, fp); size_t res = fwrite(a, sizeof(int), blocks, fp);
@ -682,13 +679,13 @@ static cell AMX_NATIVE_CALL amx_open_dir(AMX *amx, cell *params)
DIR *dp = opendir(dirname); DIR *dp = opendir(dirname);
if (!dp) if (!dp)
return NULL; return 0;
struct dirent *ep = readdir(dp); struct dirent *ep = readdir(dp);
if (!ep) if (!ep)
{ {
closedir(dp); closedir(dp);
return NULL; return 0;
} }
set_amxstring(amx, params[2], ep->d_name, params[3]); set_amxstring(amx, params[2], ep->d_name, params[3]);
@ -802,13 +799,25 @@ static cell AMX_NATIVE_CALL amx_rmdir(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL amx_rename(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_rename(AMX *amx, cell *params)
{ {
int len; int len;
char f_old_r[260];
char f_new_r[260];
char *fold = get_amxstring(amx, params[1], 0, len); char *fold = get_amxstring(amx, params[1], 0, len);
char *fnew = get_amxstring(amx, params[2], 1, len); char *fnew = get_amxstring(amx, params[2], 1, len);
if (params[0] / sizeof(cell) == 3 && params[3])
{
build_pathname_r(f_old_r, sizeof(f_old_r)-1, "%s", fold);
build_pathname_r(f_new_r, sizeof(f_new_r)-1, "%s", fnew);
} else {
snprintf(f_old_r, sizeof(f_old_r)-1, "%s", fold);
snprintf(f_new_r, sizeof(f_new_r)-1, "%s", fnew);
}
#if defined __linux__ #if defined __linux__
return (rename(fold, fnew) == 0); return (rename(f_old_r, f_new_r) == 0);
#elif defined WIN32 #elif defined WIN32
return MoveFileA(fold, fnew); return MoveFileA(f_old_r, f_new_r);
#endif #endif
} }

View File

@ -368,7 +368,6 @@ static cell AMX_NATIVE_CALL n_floatatan(AMX *amx, cell *params)
* params[2] = radix * params[2] = radix
*/ */
REAL fA = amx_ctof(params[1]); REAL fA = amx_ctof(params[1]);
fA = ToRadians(fA, params[2]);
fA = atan(fA); fA = atan(fA);
fA = FromRadians(fA, params[2]); fA = FromRadians(fA, params[2]);
return amx_ftoc(fA); return amx_ftoc(fA);
@ -425,6 +424,54 @@ static cell AMX_NATIVE_CALL n_floatatan2(AMX *amx, cell *params)
return amx_ftoc(fC); return amx_ftoc(fC);
} }
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
/* Added by DS */
static cell AMX_NATIVE_CALL n_floatsinh(AMX *amx, cell *params)
{
/*
* params[1] = angle
* params[2] = radix
*/
REAL fA = amx_ctof(params[1]);
fA = ToRadians(fA, params[2]);
fA = sinh(fA);
return amx_ftoc(fA);
}
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
/* Added by DS */
static cell AMX_NATIVE_CALL n_floatcosh(AMX *amx, cell *params)
{
/*
* params[1] = angle
* params[2] = radix
*/
REAL fA = amx_ctof(params[1]);
fA = ToRadians(fA, params[2]);
fA = cosh(fA);
return amx_ftoc(fA);
}
#if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused
#endif
/* Added by DS */
static cell AMX_NATIVE_CALL n_floattanh(AMX *amx, cell *params)
{
/*
* params[1] = angle
* params[2] = radix
*/
REAL fA = amx_ctof(params[1]);
fA = ToRadians(fA, params[2]);
fA = tanh(fA);
return amx_ftoc(fA);
}
#if defined __BORLANDC__ || defined __WATCOMC__ #if defined __BORLANDC__ || defined __WATCOMC__
#pragma argsused #pragma argsused
#endif #endif
@ -457,6 +504,9 @@ AMX_NATIVE_INFO float_Natives[] = {
{ "floatacos", n_floatacos }, { "floatacos", n_floatacos },
{ "floatatan", n_floatatan }, { "floatatan", n_floatatan },
{ "floatatan2", n_floatatan2 }, { "floatatan2", n_floatatan2 },
{ "floatsinh", n_floatsinh },
{ "floatcosh", n_floatcosh },
{ "floattanh", n_floattanh },
{ NULL, NULL } /* terminator */ { NULL, NULL } /* terminator */
}; };

View File

@ -1,5 +1,6 @@
#include "amxmodx.h" #include "amxmodx.h"
#include "format.h" #include "format.h"
#include "amxmod_compat.h"
//Adapted from Quake3's vsprintf //Adapted from Quake3's vsprintf
// thanks to cybermind for linking me to this :) // thanks to cybermind for linking me to this :)
@ -224,6 +225,50 @@ void AddFloat(U **buf_p, size_t &maxlen, double fval, int width, int prec)
} }
} }
template <typename U>
void AddUInt(U **buf_p, size_t &maxlen, unsigned int val, int width, int flags)
{
U text[32];
int digits;
U *buf;
digits = 0;
do {
text[digits++] = '0' + val % 10;
val /= 10;
} while (val);
buf = *buf_p;
if( !(flags & LADJUST) )
{
while (digits < width && maxlen)
{
*buf++ = (flags & ZEROPAD) ? '0' : ' ';
width--;
maxlen--;
}
}
while (digits-- && maxlen)
{
*buf++ = text[digits];
width--;
maxlen--;
}
if (flags & LADJUST)
{
while (width-- && maxlen)
{
*buf++ = (flags & ZEROPAD) ? '0' : ' ';
maxlen--;
}
}
*buf_p = buf;
}
template <typename U> template <typename U>
void AddInt(U **buf_p, size_t &maxlen, int val, int width, int flags) void AddInt(U **buf_p, size_t &maxlen, int val, int width, int flags)
{ {
@ -231,15 +276,21 @@ void AddInt(U **buf_p, size_t &maxlen, int val, int width, int flags)
int digits; int digits;
int signedVal; int signedVal;
U *buf; U *buf;
unsigned int unsignedVal;
digits = 0; digits = 0;
signedVal = val; signedVal = val;
if (val < 0) if (val < 0)
val = -val; {
/* we want the unsigned version */
unsignedVal = abs(val);
} else {
unsignedVal = val;
}
do { do {
text[digits++] = '0' + val % 10; text[digits++] = '0' + unsignedVal % 10;
val /= 10; unsignedVal /= 10;
} while (val); } while (unsignedVal);
if (signedVal < 0) if (signedVal < 0)
text[digits++] = '-'; text[digits++] = '-';
@ -360,6 +411,11 @@ reswitch:
AddInt(&buf_p, llen, *get_amxaddr(amx, params[arg]), width, flags); AddInt(&buf_p, llen, *get_amxaddr(amx, params[arg]), width, flags);
arg++; arg++;
break; break;
case 'u':
CHECK_ARGS(0);
AddUInt(&buf_p, llen, static_cast<unsigned int>(*get_amxaddr(amx, params[arg])), width, flags);
arg++;
break;
case 'f': case 'f':
CHECK_ARGS(0); CHECK_ARGS(0);
AddFloat(&buf_p, llen, amx_ctof(*get_amxaddr(amx, params[arg])), width, prec); AddFloat(&buf_p, llen, amx_ctof(*get_amxaddr(amx, params[arg])), width, prec);
@ -367,6 +423,24 @@ reswitch:
break; break;
case 's': case 's':
CHECK_ARGS(0); CHECK_ARGS(0);
if (amx->flags & AMX_FLAG_OLDFILE)
{
cell *addr = get_amxaddr(amx, params[arg]);
if (*addr & BCOMPAT_TRANSLATE_BITS)
{
const char *key, *def;
if (!translate_bcompat(amx, addr, &key, &def))
{
goto break_to_normal_string;
}
arg++;
size_t written = atcprintf(buf_p, llen, def, amx, params, &arg);
buf_p += written;
llen -= written;
break;
}
}
break_to_normal_string:
AddString(&buf_p, llen, get_amxaddr(amx, params[arg]), width, prec); AddString(&buf_p, llen, get_amxaddr(amx, params[arg]), width, prec);
arg++; arg++;
break; break;

View File

@ -5,4 +5,7 @@
template <typename D, typename S> template <typename D, typename S>
size_t atcprintf(D *buffer, size_t maxlen, const S *format, AMX *amx, cell *params, int *param); size_t atcprintf(D *buffer, size_t maxlen, const S *format, AMX *amx, cell *params, int *param);
const char *translate(AMX *amx, cell amxaddr, const char *key);
bool translate_bcompat(AMX *amx, cell *source, const char **_key, const char **_def);
#endif //_INCLUDE_FORMATTING_H #endif //_INCLUDE_FORMATTING_H

View File

@ -184,7 +184,7 @@ LibError RunLibCommand(const LibDecoder *enc)
if ( (enc->cmd == LibCmd_ReqLib) || (enc->cmd == LibCmd_ReqClass) ) if ( (enc->cmd == LibCmd_ReqLib) || (enc->cmd == LibCmd_ReqClass) )
{ {
LibType expect; LibType expect = LibType_Library;
if (enc->cmd == LibCmd_ReqLib) if (enc->cmd == LibCmd_ReqLib)
expect = LibType_Library; expect = LibType_Library;
@ -202,7 +202,7 @@ LibError RunLibCommand(const LibDecoder *enc)
} }
if (expect == LibType_Library) if (expect == LibType_Library)
return LibErr_NoLibrary; return LibErr_NoLibrary;
else if (expect = LibType_Class) else if (expect == LibType_Class)
return LibErr_NoClass; return LibErr_NoClass;
return LibErr_NoLibrary; return LibErr_NoLibrary;

View File

@ -111,7 +111,7 @@ void MD5::update(FILE *file){
unsigned char buffer[1024]; unsigned char buffer[1024];
int len; int len;
while (len=fread(buffer, 1, 1024, file)) while ((len=fread(buffer, 1, 1024, file)))
update(buffer, len); update(buffer, len);
fclose (file); fclose (file);

View File

@ -9,6 +9,8 @@
#define MAX_MESSAGES 255 #define MAX_MESSAGES 255
#define MSGBLOCK_SET 0
#define MSGBLOCK_GET 1
#define BLOCK_NOT 0 #define BLOCK_NOT 0
#define BLOCK_ONCE 1 #define BLOCK_ONCE 1
#define BLOCK_SET 2 #define BLOCK_SET 2

View File

@ -45,6 +45,7 @@
#include "optimizer.h" #include "optimizer.h"
#include "libraries.h" #include "libraries.h"
#include "messages.h" #include "messages.h"
#include "amxmod_compat.h"
plugin_info_t Plugin_info = plugin_info_t Plugin_info =
{ {
@ -95,6 +96,7 @@ String g_log_dir;
String g_mod_name; String g_mod_name;
XVars g_xvars; XVars g_xvars;
bool g_bmod_tfc;
bool g_bmod_cstrike; bool g_bmod_cstrike;
bool g_bmod_dod; bool g_bmod_dod;
bool g_dontprecache; bool g_dontprecache;
@ -170,16 +172,18 @@ void ParseAndOrAdd(CStack<String *> & files, const char *name)
} }
} }
void BuildPluginFileList(CStack<String *> & files) void BuildPluginFileList(const char *initialdir, CStack<String *> & files)
{ {
char path[255]; char path[255];
#if defined WIN32 #if defined WIN32
build_pathname_r(path, sizeof(path)-1, "%s/*.ini", get_localinfo("amxx_configsdir", "addons/amxmodx/configs")); build_pathname_r(path, sizeof(path)-1, "%s/*.ini", initialdir);
_finddata_t fd; _finddata_t fd;
intptr_t handle = _findfirst(path, &fd); intptr_t handle = _findfirst(path, &fd);
if (handle < 0) if (handle < 0)
{
return; return;
}
while (!_findnext(handle, &fd)) while (!_findnext(handle, &fd))
{ {
@ -188,12 +192,14 @@ void BuildPluginFileList(CStack<String *> & files)
_findclose(handle); _findclose(handle);
#elif defined __linux__ #elif defined __linux__
build_pathname_r(path, sizeof(path)-1, "%s/", get_localinfo("amxx_configsdir", "addons/amxmodx/configs")); build_pathname_r(path, sizeof(path)-1, "%s/", initialdir);
struct dirent *ep; struct dirent *ep;
DIR *dp; DIR *dp;
if ((dp = opendir(path)) == NULL) if ((dp = opendir(path)) == NULL)
{
return; return;
}
while ( (ep=readdir(dp)) != NULL ) while ( (ep=readdir(dp)) != NULL )
{ {
@ -204,6 +210,41 @@ void BuildPluginFileList(CStack<String *> & files)
#endif #endif
} }
//Loads a plugin list into the Plugin Cache and Load Modules cache
void LoadExtraPluginsToPCALM(const char *initialdir)
{
CStack<String *> files;
BuildPluginFileList(initialdir, files);
char path[255];
while (!files.empty())
{
String *pString = files.front();
snprintf(path, sizeof(path)-1, "%s/%s",
initialdir,
pString->c_str());
g_plugins.CALMFromFile(path);
delete pString;
files.pop();
}
}
void LoadExtraPluginsFromDir(const char *initialdir)
{
CStack<String *> files;
char path[255];
BuildPluginFileList(initialdir, files);
while (!files.empty())
{
String *pString = files.front();
snprintf(path, sizeof(path)-1, "%s/%s",
initialdir,
pString->c_str());
g_plugins.loadPluginsFromFile(path);
delete pString;
files.pop();
}
}
// Precache stuff from force consistency calls // Precache stuff from force consistency calls
// or check for pointed files won't be done // or check for pointed files won't be done
int C_PrecacheModel(char *s) int C_PrecacheModel(char *s)
@ -268,11 +309,27 @@ const char* get_localinfo(const char* name, const char* def)
const char* b = LOCALINFO((char*)name); const char* b = LOCALINFO((char*)name);
if (b == 0 || *b == 0) if (b == 0 || *b == 0)
{
SET_LOCALINFO((char*)name, (char*)(b = def)); SET_LOCALINFO((char*)name, (char*)(b = def));
}
return b; return b;
} }
const char* get_localinfo_r(const char *name, const char *def, char buffer[], size_t maxlength)
{
const char* b = LOCALINFO((char*)name);
if (b == 0 || *b == 0)
{
SET_LOCALINFO((char*)name, (char*)(b = def));
}
snprintf(buffer, maxlength, "%s", b);
return buffer;
}
// Very first point at map load // Very first point at map load
// Load AMX modules for new native functions // Load AMX modules for new native functions
// Initialize AMX stuff and load it's plugins from plugins.ini list // Initialize AMX stuff and load it's plugins from plugins.ini list
@ -280,7 +337,9 @@ const char* get_localinfo(const char* name, const char* def)
int C_Spawn(edict_t *pent) int C_Spawn(edict_t *pent)
{ {
if (g_initialized) if (g_initialized)
{
RETURN_META_VALUE(MRES_IGNORED, 0); RETURN_META_VALUE(MRES_IGNORED, 0);
}
g_activated = false; g_activated = false;
g_initialized = true; g_initialized = true;
@ -314,22 +373,29 @@ int C_Spawn(edict_t *pent)
get_localinfo("amxx_configsdir", "addons/amxmodx/configs"); get_localinfo("amxx_configsdir", "addons/amxmodx/configs");
get_localinfo("amxx_customdir", "addons/amxmodx/custom"); get_localinfo("amxx_customdir", "addons/amxmodx/custom");
// make sure bcompat localinfos are set
get_localinfo("amx_basedir", "addons/amxmodx");
get_localinfo("amx_configdir", "addons/amxmodx/configs");
get_localinfo("amx_langdir", "addons/amxmodx/data/amxmod-lang");
get_localinfo("amx_modulesdir", "addons/amxmodx/modules");
get_localinfo("amx_pluginsdir", "addons/amxmodx/plugins");
get_localinfo("amx_logdir", "addons/amxmodx/logs");
char map_pluginsfile_path[256];
char configs_dir[256];
// ###### Load modules // ###### Load modules
loadModules(get_localinfo("amxx_modules", "addons/amxmodx/configs/modules.ini"), PT_ANYTIME); loadModules(get_localinfo("amxx_modules", "addons/amxmodx/configs/modules.ini"), PT_ANYTIME);
get_localinfo_r("amxx_configsdir", "addons/amxmodx/configs", configs_dir, sizeof(configs_dir)-1);
g_plugins.CALMFromFile(get_localinfo("amxx_plugins", "addons/amxmodx/configs/plugins.ini")); g_plugins.CALMFromFile(get_localinfo("amxx_plugins", "addons/amxmodx/configs/plugins.ini"));
CStack<String *> files; LoadExtraPluginsToPCALM(configs_dir);
BuildPluginFileList(files); snprintf(map_pluginsfile_path, sizeof(map_pluginsfile_path)-1,
char path[255]; "%s/maps/plugins-%s.ini",
while (!files.empty()) configs_dir,
{ STRING(gpGlobals->mapname));
String *pString = files.front(); g_plugins.CALMFromFile(map_pluginsfile_path);
snprintf(path, sizeof(path)-1, "%s/%s",
get_localinfo("amxx_configsdir", "addons/amxmodx/configs"),
pString->c_str());
g_plugins.CALMFromFile(path);
delete pString;
files.pop();
}
int loaded = countModules(CountModules_Running); // Call after attachModules so all modules don't have pending stat int loaded = countModules(CountModules_Running); // Call after attachModules so all modules don't have pending stat
// Set some info about amx version and modules // Set some info about amx version and modules
@ -365,20 +431,12 @@ int C_Spawn(edict_t *pent)
if (!g_opt_level) if (!g_opt_level)
g_opt_level = 7; g_opt_level = 7;
// ###### Load AMX scripts // ###### Load AMX Mod X plugins
g_plugins.loadPluginsFromFile(get_localinfo("amxx_plugins", "addons/amxmodx/configs/plugins.ini")); g_plugins.loadPluginsFromFile(get_localinfo("amxx_plugins", "addons/amxmodx/configs/plugins.ini"));
BuildPluginFileList(files); LoadExtraPluginsFromDir(configs_dir);
while (!files.empty()) g_plugins.loadPluginsFromFile(map_pluginsfile_path, false);
{
String *pString = files.front();
snprintf(path, sizeof(path)-1, "%s/%s",
get_localinfo("amxx_configsdir", "addons/amxmodx/configs"),
pString->c_str());
g_plugins.loadPluginsFromFile(path);
delete pString;
files.pop();
}
g_plugins.Finalize(); g_plugins.Finalize();
g_plugins.InvalidateCache();
// Register forwards // Register forwards
FF_PluginInit = registerForward("plugin_init", ET_IGNORE, FP_DONE); FF_PluginInit = registerForward("plugin_init", ET_IGNORE, FP_DONE);
@ -662,7 +720,7 @@ void C_ServerDeactivate_Post()
BOOL C_ClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128]) BOOL C_ClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128])
{ {
CPlayer* pPlayer = GET_PLAYER_POINTER(pEntity); CPlayer* pPlayer = GET_PLAYER_POINTER(pEntity);
if (!pPlayer->bot) if (!pPlayer->IsBot())
{ {
bool a = pPlayer->Connect(pszName, pszAddress); bool a = pPlayer->Connect(pszName, pszAddress);
executeForwards(FF_ClientConnect, static_cast<cell>(pPlayer->index)); executeForwards(FF_ClientConnect, static_cast<cell>(pPlayer->index));
@ -710,7 +768,7 @@ void C_ClientDisconnect(edict_t *pEntity)
void C_ClientPutInServer_Post(edict_t *pEntity) void C_ClientPutInServer_Post(edict_t *pEntity)
{ {
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity); CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
if (!pPlayer->bot) if (!pPlayer->IsBot())
{ {
pPlayer->PutInServer(); pPlayer->PutInServer();
++g_players_num; ++g_players_num;
@ -730,9 +788,7 @@ void C_ClientUserInfoChanged_Post(edict_t *pEntity, char *infobuffer)
if (pPlayer->ingame) if (pPlayer->ingame)
{ {
pPlayer->name.assign(name); // Make sure player have name up to date pPlayer->name.assign(name); // Make sure player have name up to date
} } else if (pPlayer->IsBot()) {
else if (pPlayer->IsBot())
{
pPlayer->Connect(name, "127.0.0.1"/*CVAR_GET_STRING("net_address")*/); pPlayer->Connect(name, "127.0.0.1"/*CVAR_GET_STRING("net_address")*/);
executeForwards(FF_ClientConnect, static_cast<cell>(pPlayer->index)); executeForwards(FF_ClientConnect, static_cast<cell>(pPlayer->index));
@ -781,10 +837,11 @@ void C_ClientCommand(edict_t *pEntity)
sprintf(buf, "%s %s\n", Plugin_info.name, Plugin_info.version); sprintf(buf, "%s %s\n", Plugin_info.name, Plugin_info.version);
CLIENT_PRINT(pEntity, print_console, buf); CLIENT_PRINT(pEntity, print_console, buf);
len = sprintf(buf, "Authors: David \"BAILOPAN\" Anderson, Pavol \"PM OnoTo\" Marko, Felix \"SniperBeamer\" Geyer\n"); len = sprintf(buf, "Authors: \n David \"BAILOPAN\" Anderson, Pavol \"PM OnoTo\" Marko, Felix \"SniperBeamer\" Geyer\n");
len += sprintf(&buf[len], "Authors: Jonny \"Got His Gun\" Bergstrom, Lukasz \"SidLuke\" Wlasinski\n"); len += sprintf(&buf[len], " Jonny \"Got His Gun\" Bergstrom, Lukasz \"SidLuke\" Wlasinski\n");
CLIENT_PRINT(pEntity, print_console, buf); CLIENT_PRINT(pEntity, print_console, buf);
len = sprintf(buf, "Authors: Christian \"Basic-Master\" Hammacher, Borja \"faluco\" Ferrer\n"); len = sprintf(buf, " Christian \"Basic-Master\" Hammacher, Borja \"faluco\" Ferrer\n");
len += sprintf(&buf[len], " Scott \"Damaged Soul\" Ehlert\n");
len += sprintf(&buf[len], "Compiled: %s\nURL:http://www.amxmodx.org/\n", __DATE__ ", " __TIME__); len += sprintf(&buf[len], "Compiled: %s\nURL:http://www.amxmodx.org/\n", __DATE__ ", " __TIME__);
CLIENT_PRINT(pEntity, print_console, buf); CLIENT_PRINT(pEntity, print_console, buf);
#ifdef JIT #ifdef JIT
@ -1161,10 +1218,12 @@ void C_TraceLine_Post(const float *v1, const float *v2, int fNoMonsters, edict_t
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
} }
void C_AlertMessage_Post(ALERT_TYPE atype, char *szFmt, ...) void C_AlertMessage(ALERT_TYPE atype, char *szFmt, ...)
{ {
if (atype != at_logged) if (atype != at_logged)
{
RETURN_META(MRES_IGNORED); RETURN_META(MRES_IGNORED);
}
/* There are also more messages but we want only logs /* There are also more messages but we want only logs
at_notice, at_notice,
@ -1175,8 +1234,11 @@ void C_AlertMessage_Post(ALERT_TYPE atype, char *szFmt, ...)
at_logged // Server print to console ( only in multiplayer games ). at_logged // Server print to console ( only in multiplayer games ).
*/ */
cell retVal = 0;
// execute logevents and plugin_log forward // execute logevents and plugin_log forward
if (g_logevents.logEventsExist() || FF_PluginLog >= 0) if (g_logevents.logEventsExist()
|| g_forwards.getFuncsNum(FF_PluginLog))
{ {
va_list logArgPtr; va_list logArgPtr;
va_start(logArgPtr, szFmt); va_start(logArgPtr, szFmt);
@ -1185,15 +1247,19 @@ void C_AlertMessage_Post(ALERT_TYPE atype, char *szFmt, ...)
g_logevents.parseLogString(); g_logevents.parseLogString();
if (g_logevents.logEventsExist()) if (g_logevents.logEventsExist())
{
g_logevents.executeLogEvents(); g_logevents.executeLogEvents();
}
cell retVal = executeForwards(FF_PluginLog); retVal = executeForwards(FF_PluginLog);
if (retVal)
RETURN_META(MRES_HANDLED);
} }
RETURN_META(MRES_IGNORED); if (retVal)
{
RETURN_META(MRES_SUPERCEDE);
}
RETURN_META(MRES_IGNORED);
} }
void C_ChangeLevel(char *map, char *what) void C_ChangeLevel(char *map, char *what)
@ -1523,6 +1589,7 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
} else { } else {
g_bmod_cstrike = false; g_bmod_cstrike = false;
g_bmod_dod = !stricmp(g_mod_name.c_str(), "dod"); g_bmod_dod = !stricmp(g_mod_name.c_str(), "dod");
g_bmod_tfc = !stricmp(g_mod_name.c_str(), "tfc");
} }
meta_engfuncs.pfnCmd_Argc = C_Cmd_Argc; meta_engfuncs.pfnCmd_Argc = C_Cmd_Argc;
@ -1544,6 +1611,8 @@ C_DLLEXPORT int GetEngineFunctions(enginefuncs_t *pengfuncsFromEngine, int *inte
meta_engfuncs.pfnWriteShort = C_WriteShort; meta_engfuncs.pfnWriteShort = C_WriteShort;
meta_engfuncs.pfnWriteString = C_WriteString; meta_engfuncs.pfnWriteString = C_WriteString;
meta_engfuncs.pfnAlertMessage = C_AlertMessage;
memcpy(pengfuncsFromEngine, &meta_engfuncs, sizeof(enginefuncs_t)); memcpy(pengfuncsFromEngine, &meta_engfuncs, sizeof(enginefuncs_t));
return 1; return 1;
@ -1565,7 +1634,6 @@ C_DLLEXPORT int GetEngineFunctions_Post(enginefuncs_t *pengfuncsFromEngine, int
meta_engfuncs_post.pfnWriteCoord = C_WriteCoord_Post; meta_engfuncs_post.pfnWriteCoord = C_WriteCoord_Post;
meta_engfuncs_post.pfnWriteString = C_WriteString_Post; meta_engfuncs_post.pfnWriteString = C_WriteString_Post;
meta_engfuncs_post.pfnWriteEntity = C_WriteEntity_Post; meta_engfuncs_post.pfnWriteEntity = C_WriteEntity_Post;
meta_engfuncs_post.pfnAlertMessage = C_AlertMessage_Post;
meta_engfuncs_post.pfnRegUserMsg = C_RegUserMsg_Post; meta_engfuncs_post.pfnRegUserMsg = C_RegUserMsg_Post;
memcpy(pengfuncsFromEngine, &meta_engfuncs_post, sizeof(enginefuncs_t)); memcpy(pengfuncsFromEngine, &meta_engfuncs_post, sizeof(enginefuncs_t));

View File

@ -48,6 +48,7 @@
#include "binlog.h" #include "binlog.h"
#include "libraries.h" #include "libraries.h"
#include "messages.h" #include "messages.h"
#include "amxmod_compat.h"
CList<CModule, const char*> g_modules; CList<CModule, const char*> g_modules;
CList<CScript, AMX*> g_loadedscripts; CList<CScript, AMX*> g_loadedscripts;
@ -165,6 +166,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
*error = 0; *error = 0;
size_t bufSize; size_t bufSize;
*program = (void *)g_plugins.ReadIntoOrFromCache(filename, bufSize); *program = (void *)g_plugins.ReadIntoOrFromCache(filename, bufSize);
bool oldfile = false;
if (!*program) if (!*program)
{ {
CAmxxReader reader(filename, PAWN_CELL_SIZE / 8); CAmxxReader reader(filename, PAWN_CELL_SIZE / 8);
@ -218,6 +220,8 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
strcpy(error, "Unknown error"); strcpy(error, "Unknown error");
return (amx->error = AMX_ERR_NOTFOUND); return (amx->error = AMX_ERR_NOTFOUND);
} }
oldfile = reader.IsOldFile();
} else { } else {
g_plugins.InvalidateFileInCache(filename, false); g_plugins.InvalidateFileInCache(filename, false);
} }
@ -313,7 +317,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
//set this again because amx_Init() erases it! //set this again because amx_Init() erases it!
amx->flags |= AMX_FLAG_JITC; amx->flags |= AMX_FLAG_JITC;
amx->flags &= (~AMX_FLAG_DEBUG); amx->flags &= (~AMX_FLAG_DEBUG);
amx->sysreq_d = NULL; amx->sysreq_d = 0;
#endif #endif
} }
@ -369,6 +373,17 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
} }
#endif #endif
if (oldfile)
{
amx->flags |= AMX_FLAG_OLDFILE;
} else {
cell addr;
if (amx_FindPubVar(amx, "__b_old_plugin", &addr) == AMX_ERR_NONE)
{
amx->flags |= AMX_FLAG_OLDFILE;
}
}
CScript* aa = new CScript(amx, *program, filename); CScript* aa = new CScript(amx, *program, filename);
g_loadedscripts.put(aa); g_loadedscripts.put(aa);
@ -542,6 +557,12 @@ int set_amxnatives(AMX* amx, char error[128])
{ {
amx_Register(amx, cm->m_Natives[i], -1); amx_Register(amx, cm->m_Natives[i], -1);
} }
for (size_t i = 0; i < cm->m_NewNatives.size(); i++)
{
if (!(amx->flags & AMX_FLAG_OLDFILE))
amx_Register(amx, cm->m_NewNatives[i], -1);
}
} }
amx_Register(amx, string_Natives, -1); amx_Register(amx, string_Natives, -1);
@ -556,6 +577,12 @@ int set_amxnatives(AMX* amx, char error[128])
amx_Register(amx, g_DebugNatives, -1); amx_Register(amx, g_DebugNatives, -1);
amx_Register(amx, msg_Natives, -1); amx_Register(amx, msg_Natives, -1);
amx_Register(amx, vector_Natives, -1); amx_Register(amx, vector_Natives, -1);
amx_Register(amx, g_SortNatives, -1);
if (amx->flags & AMX_FLAG_OLDFILE)
{
amx_Register(amx, g_BcompatNatives, -1);
}
//we're not actually gonna check these here anymore //we're not actually gonna check these here anymore
amx->flags |= AMX_FLAG_PRENIT; amx->flags |= AMX_FLAG_PRENIT;
@ -584,7 +611,9 @@ int set_amxnatives(AMX* amx, char error[128])
int unload_amxscript(AMX* amx, void** program) int unload_amxscript(AMX* amx, void** program)
{ {
#if !defined AMD64
int flags = amx->flags; int flags = amx->flags;
#endif
Debugger *pDebugger = (Debugger *)amx->userdata[UD_DEBUGGER]; Debugger *pDebugger = (Debugger *)amx->userdata[UD_DEBUGGER];
if (pDebugger) if (pDebugger)
@ -1175,6 +1204,18 @@ int MNF_AddNatives(AMX_NATIVE_INFO* natives)
return TRUE; return TRUE;
} }
int MNF_AddNewNatives(AMX_NATIVE_INFO *natives)
{
CList<CModule, const char *>::iterator a = g_modules.begin();
if (!g_CurrentlyCalledModule || g_ModuleCallReason != ModuleCall_Attach)
return FALSE; // may only be called from attach
g_CurrentlyCalledModule->m_NewNatives.push_back(natives);
return TRUE;
}
const char *MNF_GetModname(void) const char *MNF_GetModname(void)
{ {
// :TODO: Do we have to do this?? // :TODO: Do we have to do this??
@ -1194,7 +1235,7 @@ AMX *MNF_GetAmxScript(int id)
while (iter && id--) while (iter && id--)
++iter; ++iter;
if (iter == NULL) if (iter == 0)
return NULL; return NULL;
return (*iter).getAMX(); return (*iter).getAMX();
@ -1207,7 +1248,7 @@ const char *MNF_GetAmxScriptName(int id)
while (iter && id--) while (iter && id--)
++iter; ++iter;
if (iter == NULL) if (iter == 0)
return NULL; return NULL;
return (*iter).getName(); return (*iter).getName();
@ -1537,7 +1578,9 @@ extern "C" void LogError(AMX *amx, int err, const char *fmt, ...)
#if defined BINLOG_ENABLED #if defined BINLOG_ENABLED
CPluginMngr::CPlugin *pl = g_plugins.findPluginFast(amx); CPluginMngr::CPlugin *pl = g_plugins.findPluginFast(amx);
if (pl) if (pl)
{
g_BinLog.WriteOp(BinLog_NativeError, pl->getId(), err, msg_buffer); g_BinLog.WriteOp(BinLog_NativeError, pl->getId(), err, msg_buffer);
}
#endif #endif
//give the plugin first chance to handle any sort of error //give the plugin first chance to handle any sort of error
@ -1546,14 +1589,19 @@ extern "C" void LogError(AMX *amx, int err, const char *fmt, ...)
if (pHandler->InNativeFilter()) if (pHandler->InNativeFilter())
{ {
if (pDebugger) if (pDebugger)
{
pDebugger->EndExec(); pDebugger->EndExec();
}
} else { } else {
if (pHandler) if (pHandler)
{ {
if (pHandler->IsHandling()) if (pHandler->IsHandling())
{ {
if (fmt != NULL) if (fmt != NULL)
{
pHandler->SetErrorMsg(msg_buffer); pHandler->SetErrorMsg(msg_buffer);
}
return; return;
} }
@ -1569,10 +1617,15 @@ extern "C" void LogError(AMX *amx, int err, const char *fmt, ...)
if (!pDebugger) if (!pDebugger)
{ {
if (fmt) if (fmt)
{
AMXXLOG_Error("%s", msg_buffer); AMXXLOG_Error("%s", msg_buffer);
}
Debugger::GenericMessage(amx, err); Debugger::GenericMessage(amx, err);
AMXXLOG_Error("[AMXX] To enable debug mode, add \"debug\" after the plugin name in plugins.ini (without quotes)."); if (err != AMX_ERR_EXIT)
{
AMXXLOG_Error("[AMXX] To enable debug mode, add \"debug\" after the plugin name in plugins.ini (without quotes).");
}
//destroy original error code so the original is not displayed again //destroy original error code so the original is not displayed again
} else { } else {
pDebugger->SetTracedError(err); pDebugger->SetTracedError(err);
@ -1727,6 +1780,33 @@ const char *MNF_GetLocalInfo(char *name, const char *def)
return get_localinfo(name, def); return get_localinfo(name, def);
} }
void MNF_MessageBlock(int mode, int msg, int *opt)
{
switch (mode)
{
case MSGBLOCK_SET:
{
if (msg < 0 || msg > MAX_MESSAGES || opt == NULL)
{
return;
}
int _opt = msgBlocks[msg];
msgBlocks[msg] = *opt;
*opt = _opt;
break;
}
case MSGBLOCK_GET:
{
if (msg < 0 || msg > MAX_MESSAGES || opt == NULL)
{
return;
}
*opt = msgBlocks[msg];
break;
}
}
}
void *MNF_PlayerPropAddr(int id, int prop) void *MNF_PlayerPropAddr(int id, int prop)
{ {
if (id < 1 || id > gpGlobals->maxClients) if (id < 1 || id > gpGlobals->maxClients)
@ -1828,6 +1908,7 @@ void Module_CacheFunctions()
// Natives / Forwards // Natives / Forwards
REGISTER_FUNC("AddNatives", MNF_AddNatives) REGISTER_FUNC("AddNatives", MNF_AddNatives)
REGISTER_FUNC("AddNewNatives", MNF_AddNewNatives)
REGISTER_FUNC("RaiseAmxError", amx_RaiseError) REGISTER_FUNC("RaiseAmxError", amx_RaiseError)
REGISTER_FUNC("RegisterForward", registerForward) REGISTER_FUNC("RegisterForward", registerForward)
REGISTER_FUNC("RegisterSPForward", registerSPForward) REGISTER_FUNC("RegisterSPForward", registerSPForward)
@ -1876,6 +1957,8 @@ void Module_CacheFunctions()
REGISTER_FUNC("OverrideNatives", MNF_OverrideNatives); REGISTER_FUNC("OverrideNatives", MNF_OverrideNatives);
REGISTER_FUNC("GetLocalInfo", MNF_GetLocalInfo); REGISTER_FUNC("GetLocalInfo", MNF_GetLocalInfo);
REGISTER_FUNC("MessageBlock", MNF_MessageBlock);
#ifdef MEMORY_TEST #ifdef MEMORY_TEST
REGISTER_FUNC("Allocator", m_allocator) REGISTER_FUNC("Allocator", m_allocator)
REGISTER_FUNC("Deallocator", m_deallocator) REGISTER_FUNC("Deallocator", m_deallocator)

View File

@ -38,7 +38,7 @@
#ifndef __linux__ #ifndef __linux__
#define DLLEXPORT __declspec(dllexport) #define DLLEXPORT __declspec(dllexport)
#else #else
#define DLLEXPORT #define DLLEXPORT __attribute__((visibility("default")))
#define WINAPI #define WINAPI
#endif #endif

View File

@ -322,6 +322,9 @@
<File <File
RelativePath="..\amxdbg.cpp"> RelativePath="..\amxdbg.cpp">
</File> </File>
<File
RelativePath="..\amxmod_compat.cpp">
</File>
<File <File
RelativePath="..\amxmodx.cpp"> RelativePath="..\amxmodx.cpp">
</File> </File>
@ -442,6 +445,9 @@
<File <File
RelativePath="..\power.cpp"> RelativePath="..\power.cpp">
</File> </File>
<File
RelativePath="..\sorting.cpp">
</File>
<File <File
RelativePath="..\srvcmd.cpp"> RelativePath="..\srvcmd.cpp">
</File> </File>
@ -482,6 +488,9 @@
<File <File
RelativePath="..\amxdbg.h"> RelativePath="..\amxdbg.h">
</File> </File>
<File
RelativePath="..\amxmod_compat.h">
</File>
<File <File
RelativePath="..\amxmodx.h"> RelativePath="..\amxmodx.h">
</File> </File>

View File

@ -453,6 +453,10 @@
RelativePath="..\amxdbg.cpp" RelativePath="..\amxdbg.cpp"
> >
</File> </File>
<File
RelativePath="..\amxmod_compat.cpp"
>
</File>
<File <File
RelativePath="..\amxmodx.cpp" RelativePath="..\amxmodx.cpp"
> >
@ -613,6 +617,10 @@
RelativePath="..\power.cpp" RelativePath="..\power.cpp"
> >
</File> </File>
<File
RelativePath="..\sorting.cpp"
>
</File>
<File <File
RelativePath="..\srvcmd.cpp" RelativePath="..\srvcmd.cpp"
> >
@ -666,6 +674,10 @@
RelativePath="..\amxdbg.h" RelativePath="..\amxdbg.h"
> >
</File> </File>
<File
RelativePath="..\amxmod_compat.h"
>
</File>
<File <File
RelativePath="..\amxmodx.h" RelativePath="..\amxmodx.h"
> >

View File

@ -33,6 +33,7 @@
#include "natives.h" #include "natives.h"
#include "debugger.h" #include "debugger.h"
#include "libraries.h" #include "libraries.h"
#include "format.h"
#ifdef __linux__ #ifdef __linux__
#include <malloc.h> #include <malloc.h>
@ -98,7 +99,7 @@ int amxx_DynaCallback(int idx, AMX *amx, cell *params)
{ {
amx_Push(pNative->amx, numParams); amx_Push(pNative->amx, numParams);
amx_Push(pNative->amx, pPlugin->getId()); amx_Push(pNative->amx, pPlugin->getId());
for (int i=numParams; i>=1; i--) for (int i=numParams; i>=0; i--)
pNative->params[i] = params[i]; pNative->params[i] = params[i];
} else if (pNative->style == 1) { } else if (pNative->style == 1) {
//use dJeyL's system .. very clever! //use dJeyL's system .. very clever!
@ -328,6 +329,70 @@ static cell AMX_NATIVE_CALL set_array(AMX *amx, cell *params)
return 1; return 1;
} }
static cell AMX_NATIVE_CALL vdformat(AMX *amx, cell *params)
{
if (!g_NativeStack.size())
{
LogError(amx, AMX_ERR_NATIVE, "Not currently in a dynamic native");
return 0;
}
regnative *pNative = g_NativeStack.front();
if (pNative->style)
{
LogError(amx, AMX_ERR_NATIVE, "Wrong style of dynamic native");
return 0;
}
int vargPos = static_cast<int>(params[4]);
int fargPos = static_cast<int>(params[3]);
/** get the parent parameter array */
cell *local_params = pNative->params;
cell max = local_params[0] / sizeof(cell);
if (vargPos > (int)max + 1)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid vararg parameter passed: %d", vargPos);
return 0;
}
if (fargPos > (int)max + 1)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid fmtarg parameter passed: %d", fargPos);
return 0;
}
/* get destination info */
cell *fmt;
if (fargPos == 0)
{
if (params[0] / sizeof(cell) != 5)
{
LogError(amx, AMX_ERR_NATIVE, "Expected fmtarg as fifth parameter, found none");
return 0;
}
fmt = get_amxaddr(amx, params[5]);
} else {
fmt = get_amxaddr(pNative->caller, pNative->params[fargPos]);
}
cell *realdest = get_amxaddr(amx, params[1]);
size_t maxlen = static_cast<size_t>(params[2]);
cell *dest = realdest;
/* if this is necessary... */
static cell cpbuf[4096];
dest = cpbuf;
/* perform format */
size_t total = atcprintf(dest, maxlen, fmt, pNative->caller, local_params, &vargPos);
/* copy back */
memcpy(realdest, dest, (total+1) * sizeof(cell));
return total;
}
//This is basically right from dJeyL's lib_convert function //This is basically right from dJeyL's lib_convert function
//This awesome hack modifies the stack frame to have an address offset //This awesome hack modifies the stack frame to have an address offset
// that will align to the other plugin's memory. // that will align to the other plugin's memory.
@ -444,6 +509,7 @@ AMX_NATIVE_INFO g_NativeNatives[] = {
{"set_float_byref", set_param_byref}, {"set_float_byref", set_param_byref},
{"get_array_f", get_array}, {"get_array_f", get_array},
{"set_array_f", set_array}, {"set_array_f", set_array},
{"vdformat", vdformat},
{"param_convert", param_convert}, {"param_convert", param_convert},
////////////////////////// //////////////////////////
{NULL, NULL}, {NULL, NULL},

View File

@ -37,11 +37,15 @@ CStack<int> g_MenuFreeStack;
void ClearMenus() void ClearMenus()
{ {
for (size_t i = 0; i < g_NewMenus.size(); i++) for (size_t i = 0; i < g_NewMenus.size(); i++)
{
delete g_NewMenus[i]; delete g_NewMenus[i];
}
g_NewMenus.clear(); g_NewMenus.clear();
while (!g_MenuFreeStack.empty()) while (!g_MenuFreeStack.empty())
{
g_MenuFreeStack.pop(); g_MenuFreeStack.pop();
}
} }
void validate_menu_text(char *str) void validate_menu_text(char *str)
@ -64,11 +68,15 @@ void validate_menu_text(char *str)
} }
} }
if (offs) if (offs)
{
*(str-offs) = *str; *(str-offs) = *str;
}
str++; str++;
} }
if (offs) if (offs)
{
*(str-offs) = '\0'; *(str-offs) = '\0';
}
} }
} }
@ -99,7 +107,9 @@ Menu::Menu(const char *title, int mid, int tid)
Menu::~Menu() Menu::~Menu()
{ {
for (size_t i = 0; i < m_Items.size(); i++) for (size_t i = 0; i < m_Items.size(); i++)
{
delete m_Items[i]; delete m_Items[i];
}
unregisterSPForward(this->func); unregisterSPForward(this->func);
@ -139,7 +149,9 @@ size_t Menu::GetPageCount()
{ {
size_t items = GetItemCount(); size_t items = GetItemCount();
if (items_per_page == 0) if (items_per_page == 0)
{
return 1; return 1;
}
return ((items/items_per_page) + ((items % items_per_page) ? 1 : 0)); return ((items/items_per_page) + ((items % items_per_page) ? 1 : 0));
} }
@ -159,15 +171,49 @@ int Menu::PagekeyToItem(page_t page, item_t key)
//first page //first page
if (page == 0) if (page == 0)
{ {
/* The algorithm for spaces here is same as a middle page. */
item_t new_key = key;
for (size_t i=start; i<(start+key-1) && i<m_Items.size(); i++)
{
for (size_t j=0; j<m_Items[i]->blanks.size(); j++)
{
if (m_Items[i]->blanks[j] == 1)
{
if (!new_key)
{
break;
}
new_key--;
}
if (!new_key)
{
break;
}
}
}
key = new_key;
if (key == items_per_page + 1) if (key == items_per_page + 1)
{
return MENU_MORE; return MENU_MORE;
else if (key == items_per_page + 2) } else if (key == items_per_page + 2) {
return MENU_EXIT; return MENU_EXIT;
else } else {
return (start + key - 1); return (start + key - 1);
}
} else if (page == num_pages - 1) { } else if (page == num_pages - 1) {
//last page //last page
size_t remaining = m_Items.size() - start; size_t remaining = m_Items.size() - start;
/* We have to add one remaining for each "bumping" space */
for (size_t i=m_Items.size() - remaining; i<m_Items.size(); i++)
{
for (size_t j=0; j<m_Items[i]->blanks.size(); j++)
{
if (m_Items[i]->blanks[j] == 1)
{
remaining++;
}
}
}
if (key == remaining + 1) if (key == remaining + 1)
{ {
return MENU_BACK; return MENU_BACK;
@ -177,6 +223,29 @@ int Menu::PagekeyToItem(page_t page, item_t key)
return (start + key - 1); return (start + key - 1);
} }
} else { } else {
/* The algorithm for spaces here is a bit harder. We have to subtract
* one from the key for each space we find along the way.
*/
item_t new_key = key;
for (size_t i=start; i<(start+key-1) && i<m_Items.size(); i++)
{
for (size_t j=0; j<m_Items[i]->blanks.size(); j++)
{
if (m_Items[i]->blanks[j] == 1)
{
if (!new_key)
{
break;
}
new_key--;
}
if (!new_key)
{
break;
}
}
}
key = new_key;
if (key > items_per_page && (key-items_per_page<=3)) if (key > items_per_page && (key-items_per_page<=3))
{ {
return m_OptOrders[key-items_per_page-1]; return m_OptOrders[key-items_per_page-1];
@ -286,27 +355,33 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
{ {
ret = executeForwards(pItem->handler, static_cast<cell>(player), static_cast<cell>(thisId), static_cast<cell>(i)); ret = executeForwards(pItem->handler, static_cast<cell>(player), static_cast<cell>(thisId), static_cast<cell>(i));
if (ret == ITEM_ENABLED) if (ret == ITEM_ENABLED)
{
enabled = true; enabled = true;
else if (ret == ITEM_DISABLED) } else if (ret == ITEM_DISABLED) {
enabled = false; enabled = false;
}
} }
if (pItem->pfn) if (pItem->pfn)
{ {
ret = (pItem->pfn)(player, thisId, i); ret = (pItem->pfn)(player, thisId, i);
if (ret == ITEM_ENABLED) if (ret == ITEM_ENABLED)
{
enabled = true; enabled = true;
else if (ret == ITEM_DISABLED) } else if (ret == ITEM_DISABLED) {
enabled = false; enabled = false;
}
} }
if (enabled) if (enabled)
{ {
keys |= (1<<option); keys |= (1<<option);
if (m_AutoColors) if (m_AutoColors)
{
_snprintf(buffer, sizeof(buffer)-1, "\\r%d.\\w %s\n", ++option, pItem->name.c_str()); _snprintf(buffer, sizeof(buffer)-1, "\\r%d.\\w %s\n", ++option, pItem->name.c_str());
else } else {
_snprintf(buffer, sizeof(buffer)-1, "%d. %s\n", ++option, pItem->name.c_str()); _snprintf(buffer, sizeof(buffer)-1, "%d. %s\n", ++option, pItem->name.c_str());
}
} else { } else {
if (m_AutoColors) if (m_AutoColors)
{ {
@ -326,7 +401,9 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
for (size_t j=0; j<pItem->blanks.size(); j++) for (size_t j=0; j<pItem->blanks.size(); j++)
{ {
if (pItem->blanks[j] == 1) if (pItem->blanks[j] == 1)
{
option++; option++;
}
m_Text.append("\n"); m_Text.append("\n");
slots++; slots++;
} }
@ -337,11 +414,17 @@ const char *Menu::GetTextString(int player, page_t page, int &keys)
{ {
int pad = items_per_page; int pad = items_per_page;
if (flags & Display_Back) if (flags & Display_Back)
{
pad--; pad--;
}
if (flags & Display_Next) if (flags & Display_Next)
{
pad--; pad--;
}
if (flags & Display_Exit) if (flags & Display_Exit)
{
pad--; pad--;
}
for (int i=slots+1; i<=pad; i++) for (int i=slots+1; i<=pad; i++)
{ {
m_Text.append("\n"); m_Text.append("\n");

View File

@ -110,7 +110,7 @@ void _Setup_Optimizer_Stage2(AMX *amx, cell *oplist, cell *cip)
} }
#endif #endif
} }
//we don't do these yet because of radix stuff >:\ /* we don't do these yet because of radix stuff >:\ */
//FIND_NATIVE("floatsin", N_Float_Sin); //FIND_NATIVE("floatsin", N_Float_Sin);
//FIND_NATIVE("floatcos", N_Float_Cos); //FIND_NATIVE("floatcos", N_Float_Cos);
//FIND_NATIVE("floattan", N_Float_Tan); //FIND_NATIVE("floattan", N_Float_Tan);

View File

@ -2437,6 +2437,7 @@ static amxx_module_info_s g_ModuleInfo =
// Storage for the requested functions // Storage for the requested functions
PFN_ADD_NATIVES g_fn_AddNatives; PFN_ADD_NATIVES g_fn_AddNatives;
PFN_ADD_NEW_NATIVES g_fn_AddNewNatives;
PFN_BUILD_PATHNAME g_fn_BuildPathname; PFN_BUILD_PATHNAME g_fn_BuildPathname;
PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR; PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
PFN_GET_AMXADDR g_fn_GetAmxAddr; PFN_GET_AMXADDR g_fn_GetAmxAddr;
@ -2515,6 +2516,7 @@ PFN_OVERRIDENATIVES g_fn_OverrideNatives;
PFN_GETLOCALINFO g_fn_GetLocalInfo; PFN_GETLOCALINFO g_fn_GetLocalInfo;
PFN_AMX_REREGISTER g_fn_AmxReRegister; PFN_AMX_REREGISTER g_fn_AmxReRegister;
PFN_REGISTERFUNCTIONEX g_fn_RegisterFunctionEx; PFN_REGISTERFUNCTIONEX g_fn_RegisterFunctionEx;
PFN_MESSAGE_BLOCK g_fn_MessageBlock;
// *** Exports *** // *** Exports ***
C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo) C_DLLEXPORT int AMXX_Query(int *interfaceVersion, amxx_module_info_s *moduleInfo)
@ -2591,6 +2593,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
// Natives / Forwards // Natives / Forwards
REQFUNC("AddNatives", g_fn_AddNatives, PFN_ADD_NATIVES); REQFUNC("AddNatives", g_fn_AddNatives, PFN_ADD_NATIVES);
REQFUNC("AddNewNatives", g_fn_AddNewNatives, PFN_ADD_NEW_NATIVES);
REQFUNC("RaiseAmxError", g_fn_RaiseAmxError, PFN_RAISE_AMXERROR); REQFUNC("RaiseAmxError", g_fn_RaiseAmxError, PFN_RAISE_AMXERROR);
REQFUNC("RegisterForward", g_fn_RegisterForward, PFN_REGISTER_FORWARD); REQFUNC("RegisterForward", g_fn_RegisterForward, PFN_REGISTER_FORWARD);
REQFUNC("RegisterSPForward", g_fn_RegisterSPForward, PFN_REGISTER_SPFORWARD); REQFUNC("RegisterSPForward", g_fn_RegisterSPForward, PFN_REGISTER_SPFORWARD);
@ -2638,6 +2641,8 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetLocalInfo", g_fn_GetLocalInfo, PFN_GETLOCALINFO); REQFUNC("GetLocalInfo", g_fn_GetLocalInfo, PFN_GETLOCALINFO);
REQFUNC("AmxReregister", g_fn_AmxReRegister, PFN_AMX_REREGISTER); REQFUNC("AmxReregister", g_fn_AmxReRegister, PFN_AMX_REREGISTER);
REQFUNC("MessageBlock", g_fn_MessageBlock, PFN_MESSAGE_BLOCK);
#ifdef MEMORY_TEST #ifdef MEMORY_TEST
// Memory // Memory
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR); REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
@ -2780,6 +2785,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_AddLibraries(NULL, LibType_Class, NULL); MF_AddLibraries(NULL, LibType_Class, NULL);
MF_RemoveLibraries(NULL); MF_RemoveLibraries(NULL);
MF_OverrideNatives(NULL, NULL); MF_OverrideNatives(NULL, NULL);
MF_MessageBlock(0, 0, NULL);
} }
#endif #endif

View File

@ -22,7 +22,7 @@
#ifndef __linux__ #ifndef __linux__
#define DLLEXPORT __declspec(dllexport) #define DLLEXPORT __declspec(dllexport)
#else #else
#define DLLEXPORT #define DLLEXPORT __attribute__((visibility("default")))
#define LINUX #define LINUX
#endif #endif
@ -2095,9 +2095,16 @@ enum LibType
LibType_Class LibType_Class
}; };
#define MSGBLOCK_SET 0
#define MSGBLOCK_GET 1
#define BLOCK_NOT 0
#define BLOCK_ONCE 1
#define BLOCK_SET 2
typedef void (*AUTHORIZEFUNC)(int player, const char *authstring); typedef void (*AUTHORIZEFUNC)(int player, const char *authstring);
typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/); typedef int (*PFN_ADD_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef int (*PFN_ADD_NEW_NATIVES) (const AMX_NATIVE_INFO * /*list*/);
typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...); typedef char * (*PFN_BUILD_PATHNAME) (const char * /*format*/, ...);
typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...); typedef char * (*PFN_BUILD_PATHNAME_R) (char * /*buffer*/, size_t /* maxlen */, const char * /* format */, ...);
typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/); typedef cell * (*PFN_GET_AMXADDR) (AMX * /*amx*/, cell /*offset*/);
@ -2183,8 +2190,10 @@ typedef void (*PFN_OVERRIDENATIVES) (AMX_NATIVE_INFO * /*natives*/, const ch
typedef const char * (*PFN_GETLOCALINFO) (const char * /*name*/, const char * /*def*/); typedef const char * (*PFN_GETLOCALINFO) (const char * /*name*/, const char * /*def*/);
typedef int (*PFN_AMX_REREGISTER) (AMX * /*amx*/, AMX_NATIVE_INFO * /*list*/, int /*list*/); typedef int (*PFN_AMX_REREGISTER) (AMX * /*amx*/, AMX_NATIVE_INFO * /*list*/, int /*list*/);
typedef void * (*PFN_REGISTERFUNCTIONEX) (void * /*pfn*/, const char * /*desc*/); typedef void * (*PFN_REGISTERFUNCTIONEX) (void * /*pfn*/, const char * /*desc*/);
typedef void (*PFN_MESSAGE_BLOCK) (int /* mode */, int /* message */, int * /* opt */);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_ADD_NEW_NATIVES g_fn_AddNewNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR; extern PFN_BUILD_PATHNAME_R g_fn_BuildPathnameR;
extern PFN_GET_AMXADDR g_fn_GetAmxAddr; extern PFN_GET_AMXADDR g_fn_GetAmxAddr;
@ -2257,11 +2266,13 @@ extern PFN_OVERRIDENATIVES g_fn_OverrideNatives;
extern PFN_GETLOCALINFO g_fn_GetLocalInfo; extern PFN_GETLOCALINFO g_fn_GetLocalInfo;
extern PFN_AMX_REREGISTER g_fn_AmxReRegister; extern PFN_AMX_REREGISTER g_fn_AmxReRegister;
extern PFN_REGISTERFUNCTIONEX g_fn_RegisterFunctionEx; extern PFN_REGISTERFUNCTIONEX g_fn_RegisterFunctionEx;
extern PFN_MESSAGE_BLOCK g_fn_MessageBlock;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
// They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED // They understand #if 0 so we use #ifdef MAY_NEVER_BE_DEFINED
int MF_AddNatives (const AMX_NATIVE_INFO *list) { } int MF_AddNatives (const AMX_NATIVE_INFO *list) { }
int MF_AddNewNatives (const AMX_NATIVE_INFO *list) { }
char * MF_BuildPathname (const char * format, ...) { } char * MF_BuildPathname (const char * format, ...) { }
char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { } char * MF_BuildPathnameR (char *buffer, size_t maxlen, const char *fmt, ...) { }
cell * MF_GetAmxAddr (AMX * amx, cell offset) { } cell * MF_GetAmxAddr (AMX * amx, cell offset) { }
@ -2328,9 +2339,11 @@ void MF_OverrideNatives (AMX_NATIVE_INFO *natives, const char *myname) { }
const char * MF_GetLocalInfo (const char *name, const char *def) { } const char * MF_GetLocalInfo (const char *name, const char *def) { }
int MF_AmxReRegister (AMX *amx, AMX_NATIVE_INFO *list, int number) { return 0; } int MF_AmxReRegister (AMX *amx, AMX_NATIVE_INFO *list, int number) { return 0; }
void * MF_RegisterFunctionEx (void *pfn, const char *description) { } void * MF_RegisterFunctionEx (void *pfn, const char *description) { }
void * MF_MessageBlock (int mode, int msg, int *opt) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
#define MF_AddNewNatives g_fn_AddNewNatives
#define MF_BuildPathname g_fn_BuildPathname #define MF_BuildPathname g_fn_BuildPathname
#define MF_BuildPathnameR g_fn_BuildPathnameR #define MF_BuildPathnameR g_fn_BuildPathnameR
#define MF_FormatAmxString g_fn_FormatAmxString #define MF_FormatAmxString g_fn_FormatAmxString
@ -2404,6 +2417,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_GetLocalInfo g_fn_GetLocalInfo #define MF_GetLocalInfo g_fn_GetLocalInfo
#define MF_AmxReRegister g_fn_AmxReRegister #define MF_AmxReRegister g_fn_AmxReRegister
#define MF_RegisterFunctionEx g_fn_RegisterFunctionEx #define MF_RegisterFunctionEx g_fn_RegisterFunctionEx
#define MF_MessageBlock g_fn_MessageBlock
#ifdef MEMORY_TEST #ifdef MEMORY_TEST
/*** Memory ***/ /*** Memory ***/

359
amxmodx/sorting.cpp Normal file
View File

@ -0,0 +1,359 @@
#include "amxmodx.h"
#include <stdlib.h>
/***********************************
* About the double array hack *
***************************
Double arrays in Pawn are vectors offset by the current offset. For example:
new array[2][2]
In this array, index 0 contains the offset from the current offset which
results in the final vector [2] (at [0][2]). Meaning, to dereference [1][2],
it is equivalent to:
address = &array[1] + array[1] + 2 * sizeof(cell)
The fact that each offset is from the _current_ position rather than the _base_
position is very important. It means that if you to try to swap vector positions,
the offsets will no longer match, because their current position has changed. A
simple and ingenious way around this is to back up the positions in a separate array,
then to overwrite each position in the old array with absolute indices. Pseudo C++ code:
cell *array; //assumed to be set to the 2+D array
cell *old_offsets = new cell[2];
for (int i=0; i<2; i++)
{
old_offsets = array[i];
array[i] = i;
}
Now, you can swap the array indices with no problem, and do a reverse-lookup to find the original addresses.
After sorting/modification is done, you must relocate the new indices. For example, if the two vectors in our
demo array were swapped, array[0] would be 1 and array[1] would be 0. This is invalid to the virtual machine.
Luckily, this is also simple -- all the information is there.
for (int i=0; i<2; i++)
{
//get the # of the vector we want to relocate in
cell vector_index = array[i];
//get the real address of this vector
char *real_address = (char *)array + (vector_index * sizeof(cell)) + old_offsets[vector_index];
//calc and store the new distance offset
array[i] = real_address - ( (char *)array + (vector_index + sizeof(cell)) )
}
Note that the inner expression can be heavily reduced; it is expanded for readability.
**********************************/
enum SortOrder
{
Sort_Ascending = 0,
Sort_Descending = 1,
};
int sort_ints_asc(const void *int1, const void *int2)
{
return (*(int *)int1) - (*(int *)int2);
}
int sort_ints_desc(const void *int1, const void *int2)
{
return (*(int *)int2) - (*(int *)int1);
}
static cell AMX_NATIVE_CALL SortIntegers(AMX *amx, cell *params)
{
cell *array = get_amxaddr(amx, params[1]);
cell array_size = params[2];
cell type = params[3];
if (type == Sort_Ascending)
{
qsort(array, array_size, sizeof(cell), sort_ints_asc);
} else {
qsort(array, array_size, sizeof(cell), sort_ints_desc);
}
return 1;
}
int sort_floats_asc(const void *float1, const void *float2)
{
REAL r1 = *(REAL *)float1;
REAL r2 = *(REAL *)float2;
if (r1 < r2)
{
return -1;
} else if (r2 < r1) {
return 1;
} else {
return 0;
}
}
int sort_floats_desc(const void *float1, const void *float2)
{
REAL r1 = *(REAL *)float1;
REAL r2 = *(REAL *)float2;
if (r1 < r2)
{
return 1;
} else if (r2 < r1) {
return -1;
} else {
return 0;
}
}
static cell AMX_NATIVE_CALL SortFloats(AMX *amx, cell *params)
{
cell *array = get_amxaddr(amx, params[1]);
cell array_size = params[2];
cell type = params[3];
if (type == Sort_Ascending)
{
qsort(array, array_size, sizeof(cell), sort_floats_asc);
} else {
qsort(array, array_size, sizeof(cell), sort_floats_desc);
}
return 1;
}
static cell *g_CurStringArray = NULL;
static cell *g_CurRebaseMap = NULL;
int sort_strings_asc(const void *blk1, const void *blk2)
{
cell reloc1 = *(cell *)blk1;
cell reloc2 = *(cell *)blk2;
register cell *str1 = (cell *)((char *)(&g_CurStringArray[reloc1]) + g_CurRebaseMap[reloc1]);
register cell *str2 = (cell *)((char *)(&g_CurStringArray[reloc2]) + g_CurRebaseMap[reloc2]);
while (*str1 == *str2++)
{
if (*str1++ == 0)
{
return 0;
}
}
return (*str1 - *(str2 - 1));
}
int sort_strings_desc(const void *blk1, const void *blk2)
{
cell reloc1 = *(cell *)blk1;
cell reloc2 = *(cell *)blk2;
register cell *str1 = (cell *)((char *)(&g_CurStringArray[reloc1]) + g_CurRebaseMap[reloc1]);
register cell *str2 = (cell *)((char *)(&g_CurStringArray[reloc2]) + g_CurRebaseMap[reloc2]);
while (*str1 == *str2++)
{
if (*str1++ == 0)
{
return 0;
}
}
return (*(str2 - 1) - *str1);
}
static cell AMX_NATIVE_CALL SortStrings(AMX *amx, cell *params)
{
cell *array = get_amxaddr(amx, params[1]);
cell array_size = params[2];
cell type = params[3];
/** HACKHACK - back up the old indices, replace the indices with something easier */
cell amx_addr, *phys_addr;
int err;
if ((err=amx_Allot(amx, array_size, &amx_addr, &phys_addr)) != AMX_ERR_NONE)
{
LogError(amx, err, "Ran out of memory");
return 0;
}
g_CurStringArray = array;
g_CurRebaseMap = phys_addr;
for (int i=0; i<array_size; i++)
{
phys_addr[i] = array[i];
array[i] = i;
}
if (type == Sort_Ascending)
{
qsort(array, array_size, sizeof(cell), sort_strings_asc);
} else {
qsort(array, array_size, sizeof(cell), sort_strings_desc);
}
/* END HACKHACK - restore what we damaged so Pawn doesn't throw up.
* We'll browse through each index of the array and patch up the distance.
*/
for (int i=0; i<array_size; i++)
{
/* Compute the final address of the old array and subtract the new location.
* This is the fixed up distance.
*/
array[i] = ((char *)&array[array[i]] + phys_addr[array[i]]) - (char *)&array[i];
}
amx_Release(amx, amx_addr);
g_CurStringArray = NULL;
g_CurRebaseMap = NULL;
return 1;
}
struct sort_info
{
int pfn;
cell data_addr;
cell data_size;
cell array_addr;
cell *array_base;
cell *array_remap;
AMX *amx;
};
static CStack<sort_info *> g_AMXSortStack;
int sort1d_amx_custom(const void *elem1, const void *elem2)
{
cell c1 = *(cell *)elem1;
cell c2 = *(cell *)elem2;
sort_info *pInfo = g_AMXSortStack.front();
return executeForwards(pInfo->pfn, c1, c2, pInfo->array_addr, pInfo->data_addr, pInfo->data_size);
}
static cell AMX_NATIVE_CALL SortCustom1D(AMX *amx, cell *params)
{
cell *array = get_amxaddr(amx, params[1]);
cell array_size = params[2];
int len;
const char *funcname = get_amxstring(amx, params[3], 0, len);
int pfn = registerSPForwardByName(amx, funcname, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
if (pfn < 0)
{
LogError(amx, AMX_ERR_NATIVE, "The public function \"%s\" was not found.", funcname);
return 0;
}
sort_info *pInfo = new sort_info;
pInfo->pfn = pfn;
pInfo->data_addr = params[4];
pInfo->data_size = params[5];
pInfo->array_addr = params[1];
pInfo->array_remap = NULL;
pInfo->array_base = NULL;
g_AMXSortStack.push(pInfo);
qsort(array, array_size, sizeof(cell), sort1d_amx_custom);
g_AMXSortStack.pop();
delete pInfo;
return 1;
}
int sort2d_amx_custom(const void *elem1, const void *elem2)
{
cell c1 = *(cell *)elem1;
cell c2 = *(cell *)elem2;
sort_info *pInfo = g_AMXSortStack.front();
cell c1_addr = pInfo->array_addr + (c1 * sizeof(cell)) + pInfo->array_remap[c1];
cell c2_addr = pInfo->array_addr + (c2 * sizeof(cell)) + pInfo->array_remap[c2];
//cell *c1_r = get_amxaddr(pInfo->amx, c1_addr);
//cell *c2_r = get_amxaddr(pInfo->amx, c2_addr);
return executeForwards(pInfo->pfn, c1_addr, c2_addr, pInfo->array_addr, pInfo->data_addr, pInfo->data_size);
}
static cell AMX_NATIVE_CALL SortCustom2D(AMX *amx, cell *params)
{
cell *array = get_amxaddr(amx, params[1]);
cell array_size = params[2];
int len;
const char *funcname = get_amxstring(amx, params[3], 0, len);
/** back up the old indices, replace the indices with something easier */
cell amx_addr, *phys_addr;
int err;
if ((err=amx_Allot(amx, array_size, &amx_addr, &phys_addr)) != AMX_ERR_NONE)
{
LogError(amx, err, "Ran out of memory");
return 0;
}
int pfn = registerSPForwardByName(amx, funcname, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
if (pfn < 0)
{
amx_Release(amx, amx_addr);
LogError(amx, AMX_ERR_NATIVE, "The public function \"%s\" was not found.", funcname);
return 0;
}
sort_info *pInfo = new sort_info;
pInfo->pfn = pfn;
pInfo->data_addr = params[4];
pInfo->data_size = params[5];
pInfo->array_addr = params[1];
pInfo->amx = amx;
/** Same process as in strings, back up the old indices for later fixup */
pInfo->array_base = array;
pInfo->array_remap = phys_addr;
for (int i=0; i<array_size; i++)
{
phys_addr[i] = array[i];
array[i] = i;
}
g_AMXSortStack.push(pInfo);
qsort(array, array_size, sizeof(cell), sort2d_amx_custom);
g_AMXSortStack.pop();
/** Fixup process! */
for (int i=0; i<array_size; i++)
{
/* Compute the final address of the old array and subtract the new location.
* This is the fixed up distance.
*/
array[i] = ((char *)&array[array[i]] + phys_addr[array[i]]) - (char *)&array[i];
}
amx_Release(amx, amx_addr);
unregisterSPForward(pInfo->pfn);
delete pInfo;
return 1;
}
AMX_NATIVE_INFO g_SortNatives[] =
{
{"SortIntegers", SortIntegers},
{"SortFloats", SortFloats},
{"SortStrings", SortStrings},
{"SortCustom1D", SortCustom1D},
{"SortCustom2D", SortCustom2D},
{NULL, NULL},
};

View File

@ -143,10 +143,10 @@ void amx_command()
else if (!strcmp(cmd, "version")) else if (!strcmp(cmd, "version"))
{ {
print_srvconsole("%s %s (%s)\n", Plugin_info.name, Plugin_info.version, Plugin_info.url); print_srvconsole("%s %s (%s)\n", Plugin_info.name, Plugin_info.version, Plugin_info.url);
print_srvconsole("Authors: David \"BAILOPAN\" Anderson, Pavol \"PM OnoTo\" Marko\n"); print_srvconsole("Authors:\n\tDavid \"BAILOPAN\" Anderson, Pavol \"PM OnoTo\" Marko\n");
print_srvconsole("\tFelix \"SniperBeamer\" Geyer, Jonny \"Got His Gun\" Bergstrom\n"); print_srvconsole("\tFelix \"SniperBeamer\" Geyer, Jonny \"Got His Gun\" Bergstrom\n");
print_srvconsole("\tLukasz \"SidLuke\" Wlasinski, Christian \"Basic-Master\" Hammacher\n"); print_srvconsole("\tLukasz \"SidLuke\" Wlasinski, Christian \"Basic-Master\" Hammacher\n");
print_srvconsole("\tBorja \"faluco\" Ferrer\n"); print_srvconsole("\tBorja \"faluco\" Ferrer, Scott \"Damaged Soul\" Ehlert\n");
print_srvconsole("Compiled: %s\n", __DATE__ ", " __TIME__); print_srvconsole("Compiled: %s\n", __DATE__ ", " __TIME__);
#if defined JIT && !defined ASM32 #if defined JIT && !defined ASM32
print_srvconsole("Core mode: JIT Only\n"); print_srvconsole("Core mode: JIT Only\n");
@ -253,7 +253,6 @@ void amx_command()
void plugin_srvcmd() void plugin_srvcmd()
{ {
cell ret = 0;
const char* cmd = CMD_ARGV(0); const char* cmd = CMD_ARGV(0);
CmdMngr::iterator a = g_commands.srvcmdbegin(); CmdMngr::iterator a = g_commands.srvcmdbegin();

View File

@ -33,6 +33,7 @@
#include "amxmodx.h" #include "amxmodx.h"
#include "format.h" #include "format.h"
#include "binlog.h" #include "binlog.h"
#include "amxmod_compat.h"
const char* stristr(const char* str, const char* substr) const char* stristr(const char* str, const char* substr)
{ {
@ -115,8 +116,21 @@ extern "C" size_t get_amxstring_r(AMX *amx, cell amx_addr, char *destination, in
register char *dest = destination; register char *dest = destination;
char *start = dest; char *start = dest;
while (maxlen-- && *source) if ( (amx->flags & AMX_FLAG_OLDFILE) &&
*dest++=(char)(*source++); (*source & BCOMPAT_TRANSLATE_BITS) )
{
const char *def, *key;
if (!translate_bcompat(amx, source, &key, &def))
{
goto normal_string;
}
while (maxlen-- && *def)
*dest++=(*source++);
} else {
normal_string:
while (maxlen-- && *source)
*dest++=(char)(*source++);
}
*dest = '\0'; *dest = '\0';
@ -132,16 +146,29 @@ extern "C" size_t get_amxstring_r(AMX *amx, cell amx_addr, char *destination, in
return dest - start; return dest - start;
} }
char* get_amxstring(AMX *amx, cell amx_addr, int id, int& len) char *get_amxstring(AMX *amx, cell amx_addr, int id, int& len)
{ {
static char buffor[4][3072]; static char buffor[4][3072];
register cell* source = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr)); register cell* source = (cell *)(amx->base + (int)(((AMX_HEADER *)amx->base)->dat + amx_addr));
register char* dest = buffor[id]; register char* dest = buffor[id];
char* start = dest; char* start = dest;
while ((*dest++=(char)(*source++))); if ( (amx->flags & AMX_FLAG_OLDFILE) &&
(*source & BCOMPAT_TRANSLATE_BITS) )
{
const char *def, *key;
if (!translate_bcompat(amx, source, &key, &def))
{
goto normal_string;
}
while ( (*dest++ = (*def++)) );
len = --dest - start;
} else {
normal_string:
while ((*dest++=(char)(*source++)));
len = --dest - start; len = --dest - start;
}
#if defined BINLOG_ENABLED #if defined BINLOG_ENABLED
if (g_binlog_level & 2) if (g_binlog_level & 2)
@ -416,15 +443,42 @@ static cell AMX_NATIVE_CALL add(AMX *amx, cell *params) /* 4 param */
static cell AMX_NATIVE_CALL copy(AMX *amx, cell *params) /* 4 param */ static cell AMX_NATIVE_CALL copy(AMX *amx, cell *params) /* 4 param */
{ {
cell *src = get_amxaddr(amx, params[3]); cell *src = get_amxaddr(amx, params[3]);
cell *dest = get_amxaddr(amx, params[1]);
cell *start = dest;
int c = params[2]; int c = params[2];
while (c-- && *src) if (amx->flags & AMX_FLAG_OLDFILE)
*dest++ =* src++; {
*dest = 0; if (*src & BCOMPAT_TRANSLATE_BITS)
{
const char *key, *def;
if (!translate_bcompat(amx, src, &key, &def))
{
goto normal_string;
}
cell *dest = get_amxaddr(amx, params[1]);
cell *start = dest;
while (c-- && *def)
{
*dest++ = static_cast<cell>(*def++);
}
*dest = '\0';
return (dest - start); return dest-start;
} else {
goto normal_string;
}
} else {
normal_string:
cell *dest = get_amxaddr(amx, params[1]);
cell *start = dest;
while (c-- && *src)
{
*dest++ = *src++;
}
*dest = '\0';
return (dest - start);
}
} }
static cell AMX_NATIVE_CALL copyc(AMX *amx, cell *params) /* 4 param */ static cell AMX_NATIVE_CALL copyc(AMX *amx, cell *params) /* 4 param */
@ -541,7 +595,26 @@ static cell AMX_NATIVE_CALL format(AMX *amx, cell *params) /* 3 param */
if (copy) if (copy)
buf = g_cpbuf; buf = g_cpbuf;
int param = 4; int param = 4;
size_t total = atcprintf(buf, maxlen, fmt, amx, params, &param); size_t total = 0;
if (amx->flags & AMX_FLAG_OLDFILE)
{
if (*fmt & BCOMPAT_TRANSLATE_BITS)
{
const char *key, *def;
if (!translate_bcompat(amx, fmt, &key, &def))
{
goto normal_string;
}
total = atcprintf(buf, maxlen, def, amx, params, &param);
} else {
goto normal_string;
}
} else {
normal_string:
total = atcprintf(buf, maxlen, fmt, amx, params, &param);
}
if (copy) if (copy)
{ {
/* copy back */ /* copy back */
@ -863,7 +936,6 @@ static cell AMX_NATIVE_CALL is_alpha(AMX *amx, cell *params)
static cell AMX_NATIVE_CALL amx_ucfirst(AMX *amx, cell *params) static cell AMX_NATIVE_CALL amx_ucfirst(AMX *amx, cell *params)
{ {
int len = 0;
cell *str = get_amxaddr(amx, params[1]); cell *str = get_amxaddr(amx, params[1]);
if (!isalpha((char)str[0]) || !(str[0] & (1<<5))) if (!isalpha((char)str[0]) || !(str[0] & (1<<5)))
@ -944,7 +1016,6 @@ static cell AMX_NATIVE_CALL n_strfind(AMX *amx, cell *params)
int sublen; int sublen;
char *sub = get_amxstring(amx, params[2], 1, sublen); char *sub = get_amxstring(amx, params[2], 1, sublen);
bool found = false;
bool igcase = params[3] ? true : false; bool igcase = params[3] ? true : false;
if (igcase) if (igcase)
@ -964,7 +1035,6 @@ static cell AMX_NATIVE_CALL n_strfind(AMX *amx, cell *params)
if (params[4] > len) if (params[4] > len)
return -1; return -1;
char *pos = &(str[params[4]]);
char *find = strstr(str, sub); char *find = strstr(str, sub);
if (!find) if (!find)

View File

@ -32,7 +32,7 @@
#include <time.h> #include <time.h>
#include "amxmodx.h" #include "amxmodx.h"
#ifdef __linux__ #if defined __linux__ && !defined _vsnprintf
#define _vsnprintf vsnprintf #define _vsnprintf vsnprintf
#endif #endif
@ -347,3 +347,4 @@ void UTIL_FakeClientCommand(edict_t *pEdict, const char *cmd, const char *arg1,
// unset the global "fake" flag // unset the global "fake" flag
g_fakecmd.fake = false; g_fakecmd.fake = false;
} }

View File

@ -1,5 +1,6 @@
// Microsoft Visual C++ generated resource script. // Microsoft Visual C++ generated resource script.
// //
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS #define APSTUDIO_READONLY_SYMBOLS
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -26,8 +27,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,7,5,1 FILEVERSION 1,7,6,2
PRODUCTVERSION 1,7,5,1 PRODUCTVERSION 1,7,6,2
FILEFLAGSMASK 0x17L FILEFLAGSMASK 0x17L
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -44,12 +45,12 @@ BEGIN
BEGIN BEGIN
VALUE "Comments", "AMX Mod X" VALUE "Comments", "AMX Mod X"
VALUE "FileDescription", "AMX Mod X" VALUE "FileDescription", "AMX Mod X"
VALUE "FileVersion", "1.75a" VALUE "FileVersion", "1.76b"
VALUE "InternalName", "amxmodx" VALUE "InternalName", "amxmodx"
VALUE "LegalCopyright", "Copyright (c) 2004-2006, AMX Mod X Dev Team" VALUE "LegalCopyright", "Copyright (c) 2004-2006, AMX Mod X Dev Team"
VALUE "OriginalFilename", "amxmodx_mm.dll" VALUE "OriginalFilename", "amxmodx_mm.dll"
VALUE "ProductName", "AMX Mod X" VALUE "ProductName", "AMX Mod X"
VALUE "ProductVersion", "1.75a" VALUE "ProductVersion", "1.76b"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -3,9 +3,9 @@
### EDIT BELOW FOR OTHER PROJECTS ### ### EDIT BELOW FOR OTHER PROJECTS ###
OPT_FLAGS = -O3 -funroll-loops -s -pipe OPT_FLAGS = -O3 -funroll-loops -s -pipe -fno-strict-aliasing
DEBUG_FLAGS = -g -ggdb3 DEBUG_FLAGS = -g -ggdb3
CPP = gcc CPP = gcc-4.1
BINARY = amxxpc BINARY = amxxpc
OBJECTS = amx.cpp amxxpc.cpp Binary.cpp OBJECTS = amx.cpp amxxpc.cpp Binary.cpp

View File

@ -1,7 +1,7 @@
#ifndef _AMXXSC_INCLUDE_H #ifndef _AMXXSC_INCLUDE_H
#define _AMXXSC_INCLUDE_H #define _AMXXSC_INCLUDE_H
#define VERSION_STRING "1.75-300" #define VERSION_STRING "1.76-300"
#define MAGIC_HEADER2 0x414D5858 #define MAGIC_HEADER2 0x414D5858
#define MAGIC_VERSION 0x0300 #define MAGIC_VERSION 0x0300

Binary file not shown.

View File

@ -3,13 +3,14 @@
### EDIT BELOW FOR OTHER PROJECTS ### ### EDIT BELOW FOR OTHER PROJECTS ###
OPT_FLAGS = -O3 -funroll-loops -s -pipe OPT_FLAGS = -O3 -funroll-loops -s -pipe -fno-strict-aliasing -fvisibility=hidden
DEBUG_FLAGS = -g -ggdb3 DEBUG_FLAGS = -g -ggdb3
CPP = gcc CPP = gcc-4.1
NAME = amxxpc NAME = amxxpc
OBJECTS = sc1.c sc2.c sc3.c sc4.c sc5.c sc6.c sc7.c scvars.c scmemfil.c \ OBJECTS = sc1.c sc2.c sc3.c sc4.c sc5.c sc6.c sc7.c scvars.c scmemfil.c \
scstate.c sclist.c sci18n.c scexpand.c pawncc.c libpawnc.c prefix.c scstate.c sclist.c sci18n.c scexpand.c pawncc.c libpawnc.c prefix.c \
memfile.c
LINK = -lpthread LINK = -lpthread

View File

@ -52,7 +52,7 @@
__declspec (dllexport) __declspec (dllexport)
void EXCOMPILER(int argc, char **argv) void EXCOMPILER(int argc, char **argv)
# else # else
void extern EXCOMPILER(int argc, char **argv) void extern __attribute__((visibility("default"))) EXCOMPILER(int argc, char **argv)
# endif # endif
{ {
pc_compile(argc, argv); pc_compile(argc, argv);
@ -70,7 +70,7 @@
__declspec (dllexport) __declspec (dllexport)
int pc_printf(const char *message,...) int pc_printf(const char *message,...)
#else #else
extern int pc_printf(const char *message,...) extern int __attribute__((visibility("default"))) pc_printf(const char *message,...)
#endif #endif
#else #else
int pc_printf(const char *message, ...) int pc_printf(const char *message, ...)

View File

@ -310,6 +310,9 @@
<File <File
RelativePath=".\libpawnc.c"> RelativePath=".\libpawnc.c">
</File> </File>
<File
RelativePath=".\memfile.c">
</File>
<File <File
RelativePath=".\sc1.c"> RelativePath=".\sc1.c">
</File> </File>
@ -357,6 +360,9 @@
<File <File
RelativePath=".\amx.h"> RelativePath=".\amx.h">
</File> </File>
<File
RelativePath=".\memfile.h">
</File>
<File <File
RelativePath=".\sc.h"> RelativePath=".\sc.h">
</File> </File>

105
compiler/libpc300/memfile.c Normal file
View File

@ -0,0 +1,105 @@
#include "memfile.h"
#include <string.h>
#include "osdefs.h"
memfile_t *memfile_creat(const char *name, size_t init)
{
memfile_t mf;
memfile_t *pmf;
mf.size = init;
mf.base = (char *)malloc(init);
mf.usedoffs = 0;
if (!mf.base)
{
return NULL;
}
mf.offs = 0;
mf._static = 0;
pmf = (memfile_t *)malloc(sizeof(memfile_t));
memcpy(pmf, &mf, sizeof(memfile_t));
pmf->name = strdup(name);
return pmf;
}
void memfile_destroy(memfile_t *mf)
{
if (!mf->_static)
{
free(mf->name);
free(mf->base);
free(mf);
}
}
void memfile_seek(memfile_t *mf, long seek)
{
mf->offs = seek;
}
long memfile_tell(memfile_t *mf)
{
return mf->offs;
}
size_t memfile_read(memfile_t *mf, void *buffer, size_t maxsize)
{
if (!maxsize || mf->offs >= mf->usedoffs)
{
return 0;
}
if (mf->usedoffs - mf->offs < (long)maxsize)
{
maxsize = mf->usedoffs - mf->offs;
if (!maxsize)
{
return 0;
}
}
memcpy(buffer, mf->base + mf->offs, maxsize);
mf->offs += maxsize;
return maxsize;
}
int memfile_write(memfile_t *mf, void *buffer, size_t size)
{
if (mf->offs + size > mf->size)
{
size_t newsize = (mf->size + size) * 2;
if (mf->_static)
{
char *oldbase = mf->base;
mf->base = (char *)malloc(newsize);
if (!mf->base)
{
return 0;
}
memcpy(mf->base, oldbase, mf->size);
} else {
mf->base = (char *)realloc(mf->base, newsize);
if (!mf->base)
{
return 0;
}
}
mf->_static = 0;
mf->size = newsize;
}
memcpy(mf->base + mf->offs, buffer, size);
mf->offs += size;
if (mf->offs > mf->usedoffs)
{
mf->usedoffs = mf->offs;
}
return 1;
}

View File

@ -0,0 +1,23 @@
#ifndef _INCLUDE_MEMFILE_H
#define _INCLUDE_MEMFILE_H
#include <malloc.h>
typedef struct memfile_s
{
char *name;
char *base;
long offs;
long usedoffs;
size_t size;
int _static;
} memfile_t;
memfile_t *memfile_creat(const char *name, size_t init);
void memfile_destroy(memfile_t *mf);
void memfile_seek(memfile_t *mf, long seek);
int memfile_write(memfile_t *mf, void *buffer, size_t size);
size_t memfile_read(memfile_t *mf, void *buffer, size_t maxsize);
long memfile_tell(memfile_t *mf);
#endif //_INCLUDE_MEMFILE_H

View File

@ -446,7 +446,7 @@ int pc_enablewarning(int number,int enable);
__declspec (dllexport) __declspec (dllexport)
int pc_printf(const char *message,...); int pc_printf(const char *message,...);
#else #else
extern int pc_printf(const char *message,...); extern int __attribute__((visibility("default"))) pc_printf(const char *message,...);
#endif #endif
#else #else
int pc_printf(const char *message, ...) INVISIBLE; int pc_printf(const char *message, ...) INVISIBLE;

View File

@ -993,6 +993,8 @@ static int hier13(value *lval)
value lval2 = {0}; value lval2 = {0};
int array1,array2; int array1,array2;
int orig_heap=decl_heap;
int diff1=0,diff2=0;
if (lvalue) { if (lvalue) {
rvalue(lval); rvalue(lval);
} else if (lval->ident==iCONSTEXPR) { } else if (lval->ident==iCONSTEXPR) {
@ -1009,6 +1011,10 @@ static int hier13(value *lval)
sc_allowtags=(short)POPSTK_I(); /* restore */ sc_allowtags=(short)POPSTK_I(); /* restore */
jumplabel(flab2); jumplabel(flab2);
setlabel(flab1); setlabel(flab1);
if (orig_heap!=decl_heap) {
diff1=abs(decl_heap-orig_heap);
decl_heap=orig_heap;
}
needtoken(':'); needtoken(':');
if (hier13(&lval2)) if (hier13(&lval2))
rvalue(&lval2); rvalue(&lval2);
@ -1031,6 +1037,15 @@ static int hier13(value *lval)
lval->ident=iREFARRAY; /* iARRAY becomes iREFARRAY */ lval->ident=iREFARRAY; /* iARRAY becomes iREFARRAY */
else if (lval->ident!=iREFARRAY) else if (lval->ident!=iREFARRAY)
lval->ident=iEXPRESSION; /* iREFARRAY stays iREFARRAY, rest becomes iEXPRESSION */ lval->ident=iEXPRESSION; /* iREFARRAY stays iREFARRAY, rest becomes iEXPRESSION */
if (orig_heap!=decl_heap) {
diff2=abs(decl_heap-orig_heap);
decl_heap=orig_heap;
}
if (diff1==diff2) {
decl_heap+=(diff1/2);
} else {
decl_heap+=(diff1+diff2);
}
return FALSE; /* conditional expression is no lvalue */ return FALSE; /* conditional expression is no lvalue */
} else { } else {
return lvalue; return lvalue;

View File

@ -236,6 +236,15 @@ static stringlist includepaths = {NULL, NULL}; /* directory list for include fi
SC_FUNC stringlist *insert_path(char *path) SC_FUNC stringlist *insert_path(char *path)
{ {
char *extra_path = malloc(strlen(path) + 16);
strcpy(extra_path, path);
#if defined __linux__
strcat(extra_path, "/amxmod_compat/");
#else if defined WIN32 || defined _WIN32
strcat(extra_path, "\\amxmod_compat\\");
#endif
insert_string(&includepaths, extra_path);
free(extra_path);
return insert_string(&includepaths,path); return insert_string(&includepaths,path);
} }

View File

@ -29,6 +29,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "memfile.h"
#if defined FORTIFY #if defined FORTIFY
#include "fortify.h" #include "fortify.h"
@ -44,11 +45,7 @@
* buffer points to the "file name" * buffer points to the "file name"
* bufpos is the current "file pointer" * bufpos is the current "file pointer"
*/ */
typedef struct tagMEMFILE { typedef memfile_t MEMFILE;
struct tagMEMFILE *next;
unsigned char *buffer;
long bufpos;
} MEMFILE;
#define tMEMFILE 1 #define tMEMFILE 1
#include "sc.h" #include "sc.h"
@ -56,33 +53,12 @@ typedef struct tagMEMFILE {
MEMFILE *mfcreate(char *filename) MEMFILE *mfcreate(char *filename)
{ {
MEMFILE *mf; return memfile_creat(filename, 4096);
/* create a first block that only holds the name */
mf=(MEMFILE*)malloc(sizeof(MEMFILE));
if (mf==NULL)
return NULL;
memset(mf,0,sizeof(MEMFILE));
mf->buffer=(unsigned char*)strdup(filename);
if (mf->buffer==NULL) {
free(mf);
return NULL;
} /* if */
return mf;
} }
void mfclose(MEMFILE *mf) void mfclose(MEMFILE *mf)
{ {
MEMFILE *next; memfile_destroy(mf);
assert(mf!=NULL);
while (mf!=NULL) {
next=mf->next;
assert(mf->buffer!=NULL);
free(mf->buffer);
free(mf);
mf=next;
} /* while */
} }
int mfdump(MEMFILE *mf) int mfdump(MEMFILE *mf)
@ -92,19 +68,12 @@ int mfdump(MEMFILE *mf)
assert(mf!=NULL); assert(mf!=NULL);
/* create the file */ /* create the file */
fp=fopen((char*)mf->buffer,"wb"); fp=fopen(mf->name, "wb");
if (fp==NULL) if (fp==NULL)
return 0; return 0;
okay=1; okay=1;
mf=mf->next; okay = okay & (fwrite(mf->base, mf->usedoffs, 1, fp)==(size_t)mf->usedoffs);
while (mf!=NULL) {
assert(mf->buffer!=NULL);
/* all blocks except the last should be fully filled */
assert(mf->next==NULL || (unsigned long)mf->bufpos==BUFFERSIZE);
okay=okay && fwrite(mf->buffer,1,(size_t)mf->bufpos,fp)==(size_t)mf->bufpos;
mf=mf->next;
} /* while */
fclose(fp); fclose(fp);
return okay; return okay;
@ -112,19 +81,7 @@ int mfdump(MEMFILE *mf)
long mflength(MEMFILE *mf) long mflength(MEMFILE *mf)
{ {
long length; return mf->usedoffs;
assert(mf!=NULL);
/* find the size of the memory file */
length=0L;
mf=mf->next; /* skip initial block */
while (mf!=NULL) {
assert(mf->next==NULL || (unsigned long)mf->bufpos==BUFFERSIZE);
length+=mf->bufpos;
mf=mf->next;
} /* while */
return length;
} }
long mfseek(MEMFILE *mf,long offset,int whence) long mfseek(MEMFILE *mf,long offset,int whence)
@ -132,7 +89,7 @@ long mfseek(MEMFILE *mf,long offset,int whence)
long length; long length;
assert(mf!=NULL); assert(mf!=NULL);
if (mf->next==NULL) if (mf->usedoffs == 0)
return 0L; /* early exit: not a single byte in the file */ return 0L; /* early exit: not a single byte in the file */
/* find the size of the memory file */ /* find the size of the memory file */
@ -143,7 +100,7 @@ long mfseek(MEMFILE *mf,long offset,int whence)
case SEEK_SET: case SEEK_SET:
break; break;
case SEEK_CUR: case SEEK_CUR:
offset+=mf->bufpos; offset+=mf->offs;
break; break;
case SEEK_END: case SEEK_END:
assert(offset<=0); assert(offset<=0);
@ -158,136 +115,18 @@ long mfseek(MEMFILE *mf,long offset,int whence)
offset=length; offset=length;
/* set new position and return it */ /* set new position and return it */
mf->bufpos=offset; memfile_seek(mf, offset);
return offset; return offset;
} }
unsigned int mfwrite(MEMFILE *mf,unsigned char *buffer,unsigned int size) unsigned int mfwrite(MEMFILE *mf,unsigned char *buffer,unsigned int size)
{ {
long length; return (memfile_write(mf, buffer, size) ? size : 0);
long numblocks;
int blockpos,blocksize;
unsigned int bytes;
MEMFILE *block;
assert(mf!=NULL);
/* see whether more memory must be allocated */
length=mflength(mf);
assert(mf->bufpos>=0 && mf->bufpos<=length);
numblocks=(length+BUFFERSIZE-1)/BUFFERSIZE; /* # allocated blocks */
while (mf->bufpos+size>numblocks*BUFFERSIZE) {
/* append a block */
MEMFILE *last;
block=(MEMFILE*)malloc(sizeof(MEMFILE));
if (block==NULL)
return 0;
memset(block,0,sizeof(MEMFILE));
block->buffer=(unsigned char*)malloc(BUFFERSIZE);
if (block->buffer==NULL) {
free(block);
return 0;
} /* if */
for (last=mf; last->next!=NULL; last=last->next)
/* nothing */;
assert(last!=NULL);
assert(last->next==NULL);
last->next=block;
numblocks++;
} /* while */
if (size==0)
return 0;
/* find the block to start writing to */
numblocks=mf->bufpos/BUFFERSIZE; /* # blocks to skip */
block=mf->next;
while (numblocks-->0) {
assert(block!=NULL);
block=block->next;
} /* while */
assert(block!=NULL);
/* copy into memory */
bytes=0;
blockpos=(int)(mf->bufpos % BUFFERSIZE);
do {
blocksize=BUFFERSIZE-blockpos;
assert(blocksize>=0);
if ((unsigned int)blocksize>size)
blocksize=size;
assert(block!=NULL);
memcpy(block->buffer+blockpos,buffer,blocksize);
buffer+=blocksize;
size-=blocksize;
bytes+=blocksize;
if (blockpos+blocksize>block->bufpos)
block->bufpos=blockpos+blocksize;
assert(block->bufpos>=0 && (unsigned long)block->bufpos<=BUFFERSIZE);
block=block->next;
blockpos=0;
} while (size>0);
/* adjust file pointer */
mf->bufpos+=bytes;
return bytes;
} }
unsigned int mfread(MEMFILE *mf,unsigned char *buffer,unsigned int size) unsigned int mfread(MEMFILE *mf,unsigned char *buffer,unsigned int size)
{ {
long length; return memfile_read(mf, buffer, size);
long numblocks;
int blockpos,blocksize;
unsigned int bytes;
MEMFILE *block;
assert(mf!=NULL);
/* adjust the size to read */
length=mflength(mf);
assert(mf->bufpos>=0 && mf->bufpos<=length);
if (mf->bufpos+size>(unsigned long)length)
size=(int)(length-mf->bufpos);
assert(mf->bufpos+size<=(unsigned long)length);
if (size==0)
return 0;
/* find the block to start reading from */
numblocks=mf->bufpos/BUFFERSIZE; /* # blocks to skip */
block=mf->next;
while (numblocks-->0) {
assert(block!=NULL);
block=block->next;
} /* while */
assert(block!=NULL);
/* copy out of memory */
bytes=0;
blockpos=(int)(mf->bufpos % BUFFERSIZE);
do {
blocksize=BUFFERSIZE-blockpos;
if ((unsigned int)blocksize>size)
blocksize=size;
assert(block!=NULL);
assert(block->bufpos>=0 && (unsigned long)block->bufpos<=BUFFERSIZE);
assert(blockpos+blocksize<=block->bufpos);
memcpy(buffer,block->buffer+blockpos,blocksize);
buffer+=blocksize;
size-=blocksize;
bytes+=blocksize;
block=block->next;
blockpos=0;
} while (size>0);
/* adjust file pointer */
mf->bufpos+=bytes;
return bytes;
} }
char *mfgets(MEMFILE *mf,char *string,unsigned int size) char *mfgets(MEMFILE *mf,char *string,unsigned int size)

View File

@ -1,5 +1,5 @@
; Configuration file for AMX Mod X ; Configuration file for AMX Mod X
amxx_logdir addons/amxmodx/logs amxx_logs addons/amxmodx/logs
amxx_configsdir addons/amxmodx/configs amxx_configsdir addons/amxmodx/configs
amxx_datadir addons/amxmodx/data amxx_datadir addons/amxmodx/data
amxx_modules addons/amxmodx/configs/modules.ini amxx_modules addons/amxmodx/configs/modules.ini

View File

@ -1,5 +1,5 @@
; Configuration file for AMX Mod X ; Configuration file for AMX Mod X
amxx_logdir addons/amxmodx/logs amxx_logs addons/amxmodx/logs
amxx_configsdir addons/amxmodx/configs amxx_configsdir addons/amxmodx/configs
amxx_datadir addons/amxmodx/data amxx_datadir addons/amxmodx/data
amxx_modules addons/amxmodx/configs/modules.ini amxx_modules addons/amxmodx/configs/modules.ini

View File

@ -39,5 +39,7 @@ statsx.amxx ; stats on death or round end (CSX Module required!)
;miscstats.amxx ; bunch of events announcement for Counter-Strike ;miscstats.amxx ; bunch of events announcement for Counter-Strike
;stats_logging.amxx ; weapons stats logging (CSX Module required!) ;stats_logging.amxx ; weapons stats logging (CSX Module required!)
; Enable to use AMX Mod plugins
;amxmod_compat.amxx ; AMX Mod backwards compatibility layer
; Custom - Add 3rd party plugins here ; Custom - Add 3rd party plugins here

View File

@ -6,4 +6,3 @@ ShowStats ;HUD-stats default
SayRankStats ;Say /rankstats SayRankStats ;Say /rankstats
SayRank ;Say /rank SayRank ;Say /rank
SayTop15 ;Say /top15 SayTop15 ;Say /top15
ShowStats ;HUD-stats default

View File

@ -1,5 +1,5 @@
; Configuration file for AMX Mod X ; Configuration file for AMX Mod X
amxx_logdir addons/amxmodx/logs amxx_logs addons/amxmodx/logs
amxx_configsdir addons/amxmodx/configs amxx_configsdir addons/amxmodx/configs
amxx_datadir addons/amxmodx/data amxx_datadir addons/amxmodx/data
amxx_modules addons/amxmodx/configs/modules.ini amxx_modules addons/amxmodx/configs/modules.ini

View File

@ -38,5 +38,7 @@ statscfg.amxx ; allows to manage stats plugins via menu and commands
;statssounds.amxx ; precache plugin for stats plugins ;statssounds.amxx ; precache plugin for stats plugins
;stats_logging.amxx ; weapons stats logging (DoD Module required!) ;stats_logging.amxx ; weapons stats logging (DoD Module required!)
; Enable to use AMX Mod plugins
;amxmod_compat.amxx ; AMX Mod backwards compatibility layer
; Custom - Add 3rd party plugins here ; Custom - Add 3rd party plugins here

View File

@ -33,6 +33,8 @@ timeleft.amxx ; displays time left on map
pausecfg.amxx ; allows to pause and unpause some plugins pausecfg.amxx ; allows to pause and unpause some plugins
statscfg.amxx ; allows to manage stats plugins via menu and commands statscfg.amxx ; allows to manage stats plugins via menu and commands
; Enable to use AMX Mod plugins
;amxmod_compat.amxx ; AMX Mod backwards compatibility layer
; Custom - Add 3rd party plugins here ; Custom - Add 3rd party plugins here
EvolutionX.Core.amxx ; Adds extra plugin functions for Earth's Special Forces EvolutionX.Core.amxx ; Adds extra plugin functions for Earth's Special Forces

View File

@ -37,4 +37,7 @@ idlekicker.amxx ; kicks idle players
nscommands.amxx ; extra commands for Natural-Selection nscommands.amxx ; extra commands for Natural-Selection
;unstuck.amxx ; Free stuck players (engine & ns modules required!) ;unstuck.amxx ; Free stuck players (engine & ns modules required!)
; Enable to use AMX Mod plugins
;amxmod_compat.amxx ; AMX Mod backwards compatibility layer
; Custom - Add 3rd party plugins here ; Custom - Add 3rd party plugins here

View File

@ -33,5 +33,8 @@ timeleft.amxx ; displays time left on map
pausecfg.amxx ; allows to pause and unpause some plugins pausecfg.amxx ; allows to pause and unpause some plugins
statscfg.amxx ; allows to manage stats plugins via menu and commands statscfg.amxx ; allows to manage stats plugins via menu and commands
; Enable to use AMX Mod plugins
;amxmod_compat.amxx ; AMX Mod backwards compatibility layer
; Custom - Add 3rd party plugins here ; Custom - Add 3rd party plugins here

View File

@ -1,5 +1,5 @@
; Configuration file for AMX Mod X ; Configuration file for AMX Mod X
amxx_logdir addons/amxmodx/logs amxx_logs addons/amxmodx/logs
amxx_configsdir addons/amxmodx/configs amxx_configsdir addons/amxmodx/configs
amxx_datadir addons/amxmodx/data amxx_datadir addons/amxmodx/data
amxx_modules addons/amxmodx/configs/modules.ini amxx_modules addons/amxmodx/configs/modules.ini

View File

@ -38,5 +38,7 @@ statscfg.amxx ; allows to manage stats plugins via menu and commands
;statssounds.amxx ; precache plugin for stats plugins ;statssounds.amxx ; precache plugin for stats plugins
;stats_logging.amxx ; weapons stats logging (TFC Module required!) ;stats_logging.amxx ; weapons stats logging (TFC Module required!)
; Enable to use AMX Mod plugins
;amxmod_compat.amxx ; AMX Mod backwards compatibility layer
; Custom - Add 3rd party plugins here ; Custom - Add 3rd party plugins here

View File

@ -1,5 +1,5 @@
; Configuration file for AMX Mod X ; Configuration file for AMX Mod X
amxx_logdir addons/amxmodx/logs amxx_logs addons/amxmodx/logs
amxx_configsdir addons/amxmodx/configs amxx_configsdir addons/amxmodx/configs
amxx_datadir addons/amxmodx/data amxx_datadir addons/amxmodx/data
amxx_modules addons/amxmodx/configs/modules.ini amxx_modules addons/amxmodx/configs/modules.ini

View File

@ -38,5 +38,7 @@ statscfg.amxx ; allows to manage stats plugins via menu and commands
;statssounds.amxx ; precache plugin for stats plugins ;statssounds.amxx ; precache plugin for stats plugins
;stats_logging.amxx ; weapons stats logging (TS Module required!) ;stats_logging.amxx ; weapons stats logging (TS Module required!)
; Enable to use AMX Mod plugins
;amxmod_compat.amxx ; AMX Mod backwards compatibility layer
; Custom - Add 3rd party plugins here ; Custom - Add 3rd party plugins here

View File

@ -1,62 +0,0 @@
#if defined _csstats_included
#endinput
#endif
#define _csstats_included
/* Gets stats from given weapon index. If wpnindex is 0
* then the stats are from all weapons. If weapon has not been used function
* returns 0 in other case 1. Fields in stats are:
* 0 - kills
* 1 - deaths
* 2 - headshots
* 3 - teamkilling
* 4 - shots
* 5 - hits
* 6 - damage
* For body hits fields see amxconst.inc. */
native get_user_wstats(index,wpnindex,stats[8],bodyhits[8]);
/* Gets round stats from given weapon index.*/
native get_user_wrstats(index,wpnindex,stats[8],bodyhits[8]);
/* Gets overall stats which are stored in file on server
* and updated on every respawn or user disconnect.
* Function returns the position in stats by diff. kills to deaths. */
native get_user_stats(index,stats[8],bodyhits[8]);
/* Gets round stats of player. */
native get_user_rstats(index,stats[8],bodyhits[8]);
/* Gets stats with which user have killed/hurt his victim. If victim is 0
* then stats are from all victims. If victim has not been hurt, function
* returns 0 in other case 1. User stats are reset on his respawn. */
native get_user_vstats(index,victim,stats[8],bodyhits[8],wpnname[]="",len=0);
/* Gets stats with which user have been killed/hurt. If killer is 0
* then stats are from all attacks. If killer has not hurt user, function
* returns 0 in other case 1. User stats are reset on his respawn. */
native get_user_astats(index,wpnindex,stats[8],bodyhits[8],wpnname[]="",len=0);
/* Resets life, weapon, victims and attackers user stats. */
native reset_user_wstats(index);
/* Gets overall stats which stored in stats.dat file in amx folder
* and updated on every mapchange or user disconnect.
* Function returns next index of stats entry or 0 if no more exists. */
native get_stats(index,stats[8],bodyhits[8],name[],len);
/* Returns number of all entries in stats. */
native get_statsnum();
/*
* new stats:
* 0 - total defusions
* 1 - bomb defused
* 2 - bomb plants
* 3 - bomb explosions
*/
native get_user_stats2(index,stats[4]);
native get_stats2(index,stats[4]);

View File

@ -1,256 +0,0 @@
#include "CMisc.h"
#include "rank.h"
// *****************************************************
// class Grenades
// *****************************************************
void Grenades::put( edict_t* grenade, float time, int type, CPlayer* player )
{
Obj* a = new Obj;
if ( a == 0 ) return;
a->player = player;
a->grenade = grenade;
a->time = gpGlobals->time + time;
a->type = type;
a->prev = 0;
a->next = head;
if ( head ) head->prev = a;
head = a;
}
bool Grenades::find( edict_t* enemy, CPlayer** p, int* type )
{
bool found = false;
Obj* a = head;
while ( a ){
if ( a->time > gpGlobals->time ) {
if ( a->grenade == enemy ) {
found = true;
*p = a->player;
*type = a->type;
}
}
else {
Obj* next = a->next;
if (a->prev) a->prev->next = next;
else head = next;
if (next) next->prev = a->prev;
delete a;
a = next;
continue;
}
a = a->next;
}
return found;
}
void Grenades::clear()
{
while(head){
Obj* a = head->next;
delete head;
head = a;
}
}
// *****************************************************
// class CPlayer
// *****************************************************
void CPlayer::Disconnect(){
if ( ignoreBots(pEdict) || !isModuleActive() ) // ignore if he is bot and bots rank is disabled or module is paused
return;
rank->updatePosition( &life );
rank = 0;
}
void CPlayer::PutInServer(){
if ( ignoreBots(pEdict) )
return;
restartStats();
const char* name = STRING(pEdict->v.netname);
const char* unique = name;
switch((int)csstats_rank->value) {
case 1:
if ( (unique = GETPLAYERAUTHID(pEdict)) == 0 )
unique = name; // failed to get authid
break;
case 2:
unique = ip;
}
rank = g_rank.findEntryInRank( unique , name );
}
void CPlayer::Connect(const char* address ){
strcpy(ip,address);
rank = 0;
clearStats = 0.0f;
}
void CPlayer::restartStats(bool all)
{
if ( all ) memset(weapons,0,sizeof(weapons));
memset(weaponsRnd,0,sizeof(weaponsRnd)); //DEC-Weapon (Round) stats
memset(attackers,0,sizeof(attackers));
memset(victims,0,sizeof(victims));
memset(&life,0,sizeof(life));
}
void CPlayer::Init( int pi, edict_t* pe )
{
pEdict = pe;
index = pi;
current = 0;
clearStats = 0.0f;
rank = 0;
}
void CPlayer::saveKill(CPlayer* pVictim, int wweapon, int hhs, int ttk){
if ( ignoreBots(pEdict,pVictim->pEdict) )
return;
if ( pVictim->index == index ){ // killed self
pVictim->weapons[0].deaths++;
pVictim->life.deaths++;
pVictim->weaponsRnd[0].deaths++; // DEC-Weapon (round) stats
return;
}
pVictim->attackers[index].name = weaponData[wweapon].name;
pVictim->attackers[index].kills++;
pVictim->attackers[index].hs += hhs;
pVictim->attackers[index].tks += ttk;
pVictim->attackers[0].kills++;
pVictim->attackers[0].hs += hhs;
pVictim->attackers[0].tks += ttk;
pVictim->weapons[pVictim->current].deaths++;
pVictim->weapons[0].deaths++;
pVictim->life.deaths++;
pVictim->weaponsRnd[pVictim->current].deaths++; // DEC-Weapon (round) stats
pVictim->weaponsRnd[0].deaths++; // DEC-Weapon (round) stats
int vi = pVictim->index;
victims[vi].name = weaponData[wweapon].name;
victims[vi].deaths++;
victims[vi].hs += hhs;
victims[vi].tks += ttk;
victims[0].deaths++;
victims[0].hs += hhs;
victims[0].tks += ttk;
weaponsRnd[wweapon].kills++; // DEC-Weapon (round) stats
weaponsRnd[wweapon].hs += hhs; // DEC-Weapon (round) stats
weaponsRnd[wweapon].tks += ttk; // DEC-Weapon (round) stats
weaponsRnd[0].kills++; // DEC-Weapon (round) stats
weaponsRnd[0].hs += hhs; // DEC-Weapon (round) stats
weaponsRnd[0].tks += ttk; // DEC-Weapon (round) stats
weapons[wweapon].kills++;
weapons[wweapon].hs += hhs;
weapons[wweapon].tks += ttk;
weapons[0].kills++;
weapons[0].hs += hhs;
weapons[0].tks += ttk;
life.kills++;
life.hs += hhs;
life.tks += ttk;
}
void CPlayer::saveHit(CPlayer* pVictim, int wweapon, int ddamage, int bbody){
if ( ignoreBots(pEdict,pVictim->pEdict) )
return;
if ( index == pVictim->index ) return;
pVictim->attackers[index].hits++;
pVictim->attackers[index].damage += ddamage;
pVictim->attackers[index].bodyHits[bbody]++;
pVictim->attackers[0].hits++;
pVictim->attackers[0].damage += ddamage;
pVictim->attackers[0].bodyHits[bbody]++;
int vi = pVictim->index;
victims[vi].hits++;
victims[vi].damage += ddamage;
victims[vi].bodyHits[bbody]++;
victims[0].hits++;
victims[0].damage += ddamage;
victims[0].bodyHits[bbody]++;
weaponsRnd[wweapon].hits++; // DEC-Weapon (round) stats
weaponsRnd[wweapon].damage += ddamage; // DEC-Weapon (round) stats
weaponsRnd[wweapon].bodyHits[bbody]++; // DEC-Weapon (round) stats
weaponsRnd[0].hits++; // DEC-Weapon (round) stats
weaponsRnd[0].damage += ddamage; // DEC-Weapon (round) stats
weaponsRnd[0].bodyHits[bbody]++; // DEC-Weapon (round) stats
weapons[wweapon].hits++;
weapons[wweapon].damage += ddamage;
weapons[wweapon].bodyHits[bbody]++;
weapons[0].hits++;
weapons[0].damage += ddamage;
weapons[0].bodyHits[bbody]++;
life.hits++;
life.damage += ddamage;
life.bodyHits[bbody]++;
}
void CPlayer::saveShot(int weapon){
if ( ignoreBots(pEdict) )
return;
victims[0].shots++;
weapons[weapon].shots++;
weapons[0].shots++;
life.shots++;
weaponsRnd[weapon].shots++; // DEC-Weapon (round) stats
weaponsRnd[0].shots++; // DEC-Weapon (round) stats
}
void CPlayer::saveBPlant(){
life.bPlants++;
}
void CPlayer::saveBExplode(){
life.bExplosions++;
}
void CPlayer::saveBDefusing(){
life.bDefusions++;
}
void CPlayer::saveBDefused(){
life.bDefused++;
}
// *****************************************************
bool ignoreBots (edict_t *pEnt, edict_t *pOther){
if ( !rankBots && ( pEnt->v.flags & FL_FAKECLIENT || ( pOther && pOther->v.flags & FL_FAKECLIENT ) ) )
return true;
return false;
}
bool isModuleActive(){
if ( !(int)CVAR_GET_FLOAT("csstats_pause") )
return true;
return false;
}

View File

@ -1,91 +0,0 @@
#ifndef CMISC_H
#define CMISC_H
#include "amxxmodule.h"
#include "CRank.h"
#define CSW_HEGRENADE 4
#define CSW_SMOKEGRENADE 9
#define CSW_FLASHBANG 25
// *****************************************************
// class CPlayer
// *****************************************************
struct CPlayer {
edict_t* pEdict;
char ip[32];
int index;
int aiming;
int current;
float clearStats;
RankSystem::RankStats* rank;
struct PlayerWeapon : Stats {
const char* name;
int ammo;
int clip;
};
PlayerWeapon weapons[MAX_WEAPONS];
PlayerWeapon attackers[33];
PlayerWeapon victims[33];
Stats weaponsRnd[MAX_WEAPONS]; // DEC-Weapon (Round) stats
Stats life;
int teamId;
void Init( int pi, edict_t* pe );
void Connect(const char* ip );
void PutInServer();
void Disconnect();
void saveKill(CPlayer* pVictim, int weapon, int hs, int tk);
void saveHit(CPlayer* pVictim, int weapon, int damage, int aiming);
void saveShot(int weapon);
void saveBPlant();
void saveBExplode();
void saveBDefusing();
void saveBDefused();
void restartStats(bool all = true);
inline bool IsBot(){
const char* auth= (*g_engfuncs.pfnGetPlayerAuthId)(pEdict);
return ( auth && !strcmp( auth , "BOT" ) );
}
inline bool IsAlive(){
return ((pEdict->v.deadflag==DEAD_NO)&&(pEdict->v.health>0));
}
};
// *****************************************************
// class Grenades
// *****************************************************
class Grenades
{
struct Obj
{
CPlayer* player;
edict_t* grenade;
float time;
int type;
Obj* next;
Obj* prev;
} *head;
public:
Grenades() { head = 0; }
~Grenades() { clear(); }
void put( edict_t* grenade, float time, int type, CPlayer* player );
bool find( edict_t* enemy, CPlayer** p, int* type );
void clear();
};
#endif // CMISC_H

View File

@ -1,308 +0,0 @@
#include "amxxmodule.h"
#include "CRank.h"
#include "rank.h"
// *****************************************************
// class Stats
// *****************************************************
Stats::Stats(){
hits = shots = damage = hs = tks = kills = deaths = bDefusions = bDefused = bPlants = bExplosions = 0;
memset( bodyHits , 0 ,sizeof( bodyHits ) );
}
void Stats::commit(Stats* a){
hits += a->hits;
shots += a->shots;
damage += a->damage;
hs += a->hs;
tks += a->tks;
kills += a->kills;
deaths += a->deaths;
bDefusions += a->bDefusions;
bDefused += a->bDefused;
bPlants += a->bPlants;
bExplosions += a->bExplosions;
for(int i = 1; i < 8; ++i)
bodyHits[i] += a->bodyHits[i];
}
// *****************************************************
// class RankSystem
// *****************************************************
RankSystem::RankStats::RankStats( const char* uu, const char* nn, RankSystem* pp ) {
name = 0;
namelen = 0;
unique = 0;
uniquelen = 0;
score = 0;
parent = pp;
id = ++parent->rankNum;
next = prev = 0;
setName( nn );
setUnique( uu );
}
RankSystem::RankStats::~RankStats() {
delete[] name;
delete[] unique;
--parent->rankNum;
}
void RankSystem::RankStats::setName( const char* nn ) {
delete[] name;
namelen = strlen(nn) + 1;
name = new char[namelen];
if ( name )
strcpy( name , nn );
else
namelen = 0;
}
void RankSystem::RankStats::setUnique( const char* nn ) {
delete[] unique;
uniquelen = strlen(nn) + 1;
unique = new char[uniquelen];
if ( unique )
strcpy( unique , nn );
else
uniquelen = 0;
}
RankSystem::RankSystem() {
head = 0;
tail = 0;
rankNum = 0;
calc.code = 0;
}
RankSystem::~RankSystem() {
clear();
}
void RankSystem::put_before( RankStats* a, RankStats* ptr ){
a->next = ptr;
if ( ptr ){
a->prev = ptr->prev;
ptr->prev = a;
}
else{
a->prev = head;
head = a;
}
if ( a->prev ) a->prev->next = a;
else tail = a;
}
void RankSystem::put_after( RankStats* a, RankStats* ptr ) {
a->prev = ptr;
if ( ptr ){
a->next = ptr->next;
ptr->next = a;
}
else{
a->next = tail;
tail = a;
}
if ( a->next ) a->next->prev = a;
else head = a;
}
void RankSystem::unlink( RankStats* ptr ){
if (ptr->prev) ptr->prev->next = ptr->next;
else tail = ptr->next;
if (ptr->next) ptr->next->prev = ptr->prev;
else head = ptr->prev;
}
void RankSystem::clear(){
while( tail ){
head = tail->next;
delete tail;
tail = head;
}
}
bool RankSystem::loadCalc(const char* filename, char* error)
{
if ((MF_LoadAmxScript(&calc.amx,&calc.code,filename,error,0)!=AMX_ERR_NONE)||
(MF_AmxAllot(&calc.amx, 8 , &calc.amxAddr1, &calc.physAddr1)!=AMX_ERR_NONE)||
(MF_AmxAllot(&calc.amx, 8 , &calc.amxAddr2, &calc.physAddr2)!=AMX_ERR_NONE)||
(MF_AmxFindPublic(&calc.amx,"get_score",&calc.func)!=AMX_ERR_NONE)){
LOG_CONSOLE( PLID, "Couldn't load plugin (file \"%s\")",filename);
MF_UnloadAmxScript(&calc.amx, &calc.code);
return false;
}
return true;
}
void RankSystem::unloadCalc()
{
MF_UnloadAmxScript(&calc.amx , &calc.code);
}
RankSystem::RankStats* RankSystem::findEntryInRank(const char* unique, const char* name )
{
RankStats* a = head;
while ( a )
{
if ( strcmp( a->getUnique() ,unique ) == 0 )
return a;
a = a->prev;
}
a = new RankStats( unique ,name,this );
if ( a == 0 ) return 0;
put_after( a , 0 );
return a;
}
void RankSystem::updatePos( RankStats* rr , Stats* s )
{
rr->addStats( s );
if ( calc.code ) {
calc.physAddr1[0] = rr->kills;
calc.physAddr1[1] = rr->deaths;
calc.physAddr1[2] = rr->hs;
calc.physAddr1[3] = rr->tks;
calc.physAddr1[4] = rr->shots;
calc.physAddr1[5] = rr->hits;
calc.physAddr1[6] = rr->damage;
calc.physAddr1[7] = rr->bDefusions;
calc.physAddr1[8] = rr->bDefused;
calc.physAddr1[9] = rr->bPlants;
calc.physAddr1[10] = rr->bExplosions;
for(int i = 1; i < 8; ++i)
calc.physAddr2[i] = rr->bodyHits[i];
cell result = 0;
int err;
if ((err = MF_AmxExec(&calc.amx,&result, calc.func ,2,calc.amxAddr1,calc.amxAddr2 )) != AMX_ERR_NONE)
LOG_CONSOLE( PLID, "Run time error %d on line %ld (plugin \"%s\")", err,calc.amx.curline,LOCALINFO("csstats_score"));
rr->score = result;
}
else rr->score = rr->kills - rr->deaths;
RankStats* aa = rr->next;
while ( aa && (aa->score <= rr->score) ) { // try to nominate
rr->goUp();
aa->goDown();
aa = aa->next; // go to next rank
}
if ( aa != rr->next )
{
unlink( rr );
put_before( rr, aa );
}
else
{
aa = rr->prev;
while ( aa && (aa->score > rr->score) ) { // go down
rr->goDown();
aa->goUp();
aa = aa->prev; // go to prev rank
}
if ( aa != rr->prev ){
unlink( rr );
put_after( rr, aa );
}
}
}
void RankSystem::loadRank( const char* filename )
{
FILE *bfp = fopen( filename , "rb" );
if ( !bfp ) return;
short int i = 0;
fread(&i, 1 , sizeof(short int) , bfp);
if (i == RANK_VERSION)
{
Stats d;
char unique[64], name[64];
fread(&i , 1, sizeof(short int), bfp);
while( i )
{
fread(name , i,sizeof(char) , bfp);
fread(&i , 1, sizeof(short int), bfp);
fread(unique , i,sizeof(char) , bfp);
fread(&d.tks, 1,sizeof(int), bfp);
fread(&d.damage, 1,sizeof(int), bfp);
fread(&d.deaths, 1,sizeof(int), bfp);
fread(&d.kills, 1,sizeof(int), bfp);
fread(&d.shots, 1,sizeof(int), bfp);
fread(&d.hits, 1,sizeof(int), bfp);
fread(&d.hs, 1,sizeof(int), bfp);
fread(&d.bDefusions, 1,sizeof(int), bfp);
fread(&d.bDefused, 1,sizeof(int), bfp);
fread(&d.bPlants, 1,sizeof(int), bfp);
fread(&d.bExplosions, 1,sizeof(int), bfp);
fread(d.bodyHits, 1,sizeof(d.bodyHits), bfp);
fread(&i , 1, sizeof(short int), bfp);
RankSystem::RankStats* a = findEntryInRank( unique , name );
if ( a ) a->updatePosition( &d );
}
}
fclose(bfp);
}
void RankSystem::saveRank( const char* filename )
{
FILE *bfp = fopen(filename, "wb");
if ( !bfp ) return;
short int i = RANK_VERSION;
fwrite(&i, 1, sizeof(short int) , bfp);
RankSystem::iterator a = front();
while ( a )
{
if ( (*a).score != (1<<31) ) // score must be different than mincell
{
fwrite( &(*a).namelen , 1, sizeof(short int), bfp);
fwrite( (*a).name , (*a).namelen , sizeof(char) , bfp);
fwrite( &(*a).uniquelen , 1, sizeof(short int), bfp);
fwrite( (*a).unique , (*a).uniquelen , sizeof(char) , bfp);
fwrite( &(*a).tks, 1, sizeof(int), bfp);
fwrite( &(*a).damage, 1, sizeof(int), bfp);
fwrite( &(*a).deaths, 1, sizeof(int), bfp);
fwrite( &(*a).kills, 1, sizeof(int), bfp);
fwrite( &(*a).shots, 1, sizeof(int), bfp);
fwrite( &(*a).hits, 1, sizeof(int), bfp);
fwrite( &(*a).hs, 1, sizeof(int), bfp);
fwrite( &(*a).bDefusions, 1, sizeof(int), bfp);
fwrite( &(*a).bDefused, 1, sizeof(int), bfp);
fwrite( &(*a).bPlants, 1, sizeof(int), bfp);
fwrite( &(*a).bExplosions, 1, sizeof(int), bfp);
fwrite( (*a).bodyHits, 1, sizeof((*a).bodyHits), bfp);
}
--a;
}
i = 0;
fwrite( &i , 1, sizeof(short int), bfp); // null terminator
fclose(bfp);
}

View File

@ -1,122 +0,0 @@
#ifndef CRANK_H
#define CRANK_H
#define RANK_VERSION 11
#include "amxxmodule.h"
// *****************************************************
// class Stats
// *****************************************************
struct Stats {
int hits;
int shots;
int damage;
int hs;
int tks;
int kills;
int deaths;
int bodyHits[9]; ////////////////////
// SiDLuke start
int bPlants;
int bExplosions;
int bDefusions;
int bDefused;
// SiDLuke end :D
Stats();
void commit(Stats* a);
};
// *****************************************************
// class RankSystem
// *****************************************************
class RankSystem
{
public:
class RankStats;
friend class RankStats;
class iterator;
class RankStats : public Stats {
friend class RankSystem;
friend class iterator;
RankSystem* parent;
RankStats* next;
RankStats* prev;
char* unique;
short int uniquelen;
char* name;
short int namelen;
int score;
int id;
RankStats( const char* uu, const char* nn, RankSystem* pp );
~RankStats();
void setUnique( const char* nn );
inline void goDown() {++id;}
inline void goUp() {--id;}
inline void addStats(Stats* a) { commit( a ); }
public:
void setName( const char* nn );
inline const char* getName() const { return name ? name : ""; }
inline const char* getUnique() const { return unique ? unique : ""; }
inline int getPosition() const { return id; }
inline void updatePosition( Stats* points ) {
parent->updatePos( this , points );
}
};
private:
RankStats* head;
RankStats* tail;
int rankNum;
struct scoreCalc{
AMX amx;
void* code;
int func;
cell amxAddr1;
cell amxAddr2;
cell *physAddr1;
cell *physAddr2;
} calc;
void put_before( RankStats* a, RankStats* ptr );
void put_after( RankStats* a, RankStats* ptr );
void unlink( RankStats* ptr );
void updatePos( RankStats* r , Stats* s );
public:
RankSystem();
~RankSystem();
void saveRank( const char* filename );
void loadRank( const char* filename );
RankStats* findEntryInRank(const char* unique, const char* name );
bool loadCalc(const char* filename, char* error);
inline int getRankNum( ) const { return rankNum; }
void clear();
void unloadCalc();
class iterator {
RankStats* ptr;
public:
iterator(RankStats* a): ptr(a){}
inline iterator& operator--() { ptr = ptr->prev; return *this;}
inline iterator& operator++() { ptr = ptr->next; return *this; }
inline RankStats& operator*() { return *ptr;}
operator bool () { return (ptr != 0); }
};
inline iterator front() { return iterator(head); }
inline iterator begin() { return iterator(tail); }
};
#endif

View File

@ -1,102 +0,0 @@
MODNAME = csstats_amxx
SRCFILES = amxxmodule.cpp CMisc.cpp CRank.cpp meta_api.cpp rank.cpp usermsg.cpp
EXTRA_LIBS_LINUX =
EXTRA_LIBS_WIN32 =
EXTRA_LIBDIRS_LINUX = -Lextra/lib_linux
EXTRA_LIBDIRS_WIN32 = -Lextra/lib_win32
EXTRA_INCLUDEDIRS = -Iextra/include -I../amx
EXTRA_FLAGS = -Dstrcmpi=strcasecmp
AMXDIR=../amx
SDKSRC=../sdk
METADIR=../metamod
OBJDIR_LINUX=obj.linux
OBJDIR_WIN32=obj.win32
SRCDIR=.
ifdef windir
OS=WIN32
else
OS=LINUX
endif
CC_LINUX=gcc
ifeq "$(OS)" "WIN32"
CC_WIN32=gcc
LD_WINDLL=dllwrap
DEFAULT=win32
CLEAN=clean_win32
else
CC_WIN32=/usr/local/cross-tools/i386-mingw32msvc/bin/gcc
LD_WINDLL=/usr/local/cross-tools/bin/i386-mingw32msvc-dllwrap
DEFAULT=linux win32
CLEAN=clean_both
endif
LIBFILE_LINUX = $(MODNAME)_i386.so
LIBFILE_WIN32 = $(MODNAME).dll
TARGET_LINUX = $(OBJDIR_LINUX)/$(LIBFILE_LINUX)
TARGET_WIN32 = $(OBJDIR_WIN32)/$(LIBFILE_WIN32)
FILES_ALL = *.cpp *.h [A-Z]* *.rc
ifeq "$(OS)" "LINUX"
ASRCFILES := $(shell ls -t $(SRCFILES))
else
ASRCFILES := $(shell dir /b)
endif
OBJ_LINUX := $(SRCFILES:%.cpp=$(OBJDIR_LINUX)/%.o)
OBJ_WIN32 := $(SRCFILES:%.cpp=$(OBJDIR_WIN32)/%.o)
CCOPT = -march=i586 -O6 -ffast-math -funroll-loops \
-fomit-frame-pointer -fexpensive-optimizations -malign-loops=2 \
-malign-jumps=2 -malign-functions=2 -s -DNDEBUG
INCLUDEDIRS=-I../curl/include -I$(SRCDIR) -I$(AMXDIR) -I$(METADIR) -I$(SDKSRC)/engine -I$(SDKSRC)/common -I$(SDKSRC)/dlls -I$(SDKSRC) $(EXTRA_INCLUDEDIRS)
CFLAGS=-Wall -Wno-unknown-pragmas
ODEF = -DOPT_TYPE=\"optimized\"
CFLAGS:=$(CCOPT) $(CFLAGS) $(ODEF) $(EXTRA_FLAGS)
DO_CC_LINUX=$(CC_LINUX) $(CFLAGS) -fPIC $(INCLUDEDIRS) -o $@ -c $<
DO_CC_WIN32=$(CC_WIN32) $(CFLAGS) $(INCLUDEDIRS) -o $@ -c $<
LINK_LINUX=$(CC_LINUX) $(CFLAGS) -shared -ldl -lm $(OBJ_LINUX) $(EXTRA_LIBDIRS_LINUX) $(EXTRA_LIBS_LINUX) -o $@
LINK_WIN32=$(LD_WINDLL) -mwindows --add-stdcall-alias $(OBJ_WIN32) $(EXTRA_LIBDIRS_WIN32) $(EXTRA_LIBS_WIN32) -o $@
$(OBJDIR_LINUX)/%.o: $(SRCDIR)/%.cpp
$(DO_CC_LINUX)
$(OBJDIR_WIN32)/%.o: $(SRCDIR)/%.cpp
$(DO_CC_WIN32)
default: $(DEFAULT)
$(TARGET_LINUX): $(OBJDIR_LINUX) $(OBJ_LINUX)
$(LINK_LINUX)
$(TARGET_WIN32): $(OBJDIR_WIN32) $(OBJ_WIN32)
$(LINK_WIN32)
$(OBJDIR_LINUX):
mkdir $@
$(OBJDIR_WIN32):
mkdir $@
win32: $(TARGET_WIN32)
linux: $(TARGET_LINUX)
clean: $(CLEAN)
clean_both:
-rm -f $(OBJDIR_LINUX)/*
-rm -f $(OBJDIR_WIN32)/*
clean_win32:
del /q $(OBJDIR_WIN32)

View File

@ -1,178 +0,0 @@
#!/usr/bin/perl
#(C)2004 AMX Mod X Development Team
# by David "BAILOPAN" Anderson
# output will occur in bin.x.proc
# where x is debug or opt and proc is ix86 or amd64
# You must use this script from the project src dir
#options =
# debug - enable gdb debugging
# amd64 - compile for AMD64
# proc=ix86 - assumed not amd64
# clean - clean the specifications above
$PROJECT = "csstats_amxx";
$sdk = "../../../hlsdk/SourceCode";
$mm = "../../../metamod/metamod";
$gccf = "gcc";
@CPP_SOURCE_FILES = ("amxxmodule.cpp", "CMisc.cpp", "usermsg.cpp", "meta_api.cpp", "rank.cpp", "CRank.cpp");
@C_SOURCE_FILES = ();
my %OPTIONS, %OPT;
$OPT{"debug"} = "-g -ggdb";
$OPT{"opt"} = "-O2 -ffast-math -funroll-loops -fomit-frame-pointer -s -DNDEBUG -Wall -Wno-unknown-pragmas -DOPT_TYPE=\"optimized\" -fno-exceptions -fno-rtti";
$OPTIONS{"include"} = "-I$sdk -I. -I$mm -I$sdk/engine -I$sdk/common -I$sdk/pm_shared -I$sdk/dlls";
while ($cmd = shift)
{
if ($cmd =~ /amd64/) {
$OPTIONS{"amd64"} = 1;
} elsif ($cmd =~ /debug/) {
$OPTIONS{"debug"} = 1;
} elsif ($cmd =~ /proc=i(\d)86/) {
$proc = $1;
if ($OPTIONS{"amd64"})
{
die "You cannot compile for i".$proc."86 and AMD64.\n";
} else {
$OPTIONS{"proc"} = "i".$proc."86";
}
} elsif ($cmd =~ /clean/) {
$OPTIONS{"clean"} = 1;
}
}
$gcc = `$gccf --version`;
if ($gcc =~ /2\.9/)
{
$OPT{"opt"} .= " -malign-loops=2 -malign-jumps=2 -malign-functions=2";
} else {
$OPT{"opt"} .= " -falign-loops=2 -falign-jumps=2 -falign-functions=2";
}
if ($OPTIONS{"debug"})
{
$cflags = $OPT{"debug"};
} else {
if (!$OPTIONS{"amd64"})
{
$proc = $OPTIONS{"proc"};
if (!$proc)
{
$proc = 3;
}
$cflags = "-march=i".$proc."86 ".$OPT{"opt"};
} else {
$cflags = $OPT{"opt"};
}
}
if ($OPTIONS{"amd64"})
{
$cflags .= " -m64 -DHAVE_I64 -DSMALL_CELL_SIZE=64 $cflags";
}
if ($OPTIONS{"debug"})
{
$outdir = "bin.debug";
} else {
$outdir = "bin.opt";
}
if ($OPTIONS{"amd64"})
{
$outdir .= ".amd64";
$bin = $PROJECT."_amd64.so";
} else {
$proc = $OPTIONS{"proc"};
if ($proc)
{
$outdir .= ".i".$proc."86";
$bin = $PROJECT."_i".$proc."86.so";
} else {
$outdir .= ".i386";
$bin = $PROJECT."_i386.so";
}
}
unlink("$outdir/$bin");
if ($OPTIONS{"clean"})
{
`rm $outdir/*.o`;
die("Project cleaned.\n");
}
#create the dirs
#build link list
my @LINK;
for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++)
{
$file = $CPP_SOURCE_FILES[$i];
$file =~ s/\.cpp/\.o/;
push(@LINK, $outdir."/".$file);
}
for ($i=0; $i<=$#C_SOURCE_FILES; $i++)
{
$file = $C_SOURCE_FILES[$i];
$file =~ s/\.c/\.o/;
push(@LINK, $outdir."/".$file);
}
if (!(-d $outdir))
{
mkdir($outdir);
}
$inc = $OPTIONS{"include"};
for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++)
{
$file = $CPP_SOURCE_FILES[$i];
$ofile = $file;
$ofile =~ s/\.cpp/\.o/;
$ofile = "$outdir/$ofile";
$gcc = "$gccf $cflags -Dstrcmpi=strcasecmp -fPIC $inc -c $file -o $ofile";
if (-e $ofile)
{
$file_time = (stat($file))[9];
$ofile_time = (stat($ofile))[9];
if ($file_time > $ofile_time)
{
print "$gcc\n";
`$gcc`;
}
} else {
print "$gcc\n";
`$gcc`;
}
}
for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++)
{
$file = $C_SOURCE_FILES[$i];
$ofile = $file;
$ofile =~ s/\.c/\.o/;
$ofile = "$outdir/$ofile";
$gcc = "cc $cflags -Dstrcmpi=strcasecmp -fPIC $inc -c $file -o $ofile";
if (-e $ofile)
{
$file_time = (stat($file))[9];
$ofile_time = (stat($ofile))[9];
if ($file_time > $ofile_time)
{
print "$gcc\n";
`$gcc`;
}
} else {
print "$gcc\n";
`$gcc`;
}
}
$gcc = "$gccf $cflags -shared -ldl -lm @LINK -o $outdir/$bin";
print "$gcc\n";
`$gcc`;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +0,0 @@
@echo off
PATH=C:\gcc\bin;%PATH%
make
pause

View File

@ -1,308 +0,0 @@
#include "amxxmodule.h"
#include "rank.h"
funEventCall modMsgsEnd[MAX_REG_MSGS];
funEventCall modMsgs[MAX_REG_MSGS];
void (*function)(void*);
void (*endfunction)(void*);
CPlayer players[33];
CPlayer* mPlayer;
int mPlayerIndex;
int mState;
RankSystem g_rank;
Grenades g_grenades;
bool rankBots;
int gmsgCurWeapon;
int gmsgDeathMsg;
int gmsgDamage;
int gmsgWeaponList;
int gmsgResetHUD;
int gmsgAmmoX;
int gmsgScoreInfo;
int gmsgAmmoPickup;
int gmsgSendAudio;
int gmsgTextMsg;
int gmsgBarTime;
cvar_t init_csstats_maxsize ={"csstats_maxsize","3500", 0 , 3500.0 };
cvar_t init_csstats_reset ={"csstats_reset","0"};
cvar_t init_csstats_rank ={"csstats_rank","0"};
cvar_t *csstats_maxsize;
cvar_t *csstats_reset;
cvar_t *csstats_rank;
cvar_t* csstats_rankbots;
cvar_t* csstats_pause;
cvar_t init_csstats_rankbots ={"csstats_rankbots","1"};
cvar_t init_csstats_pause = {"csstats_pause","0"};
struct sUserMsg {
const char* name;
int* id;
funEventCall func;
bool endmsg;
} g_user_msg[] = {
{ "CurWeapon" , &gmsgCurWeapon , Client_CurWeapon, false },
{ "Damage" , &gmsgDamage,Client_Damage, false },
{ "WeaponList" , &gmsgWeaponList, Client_WeaponList, false },
{ "ResetHUD" , &gmsgResetHUD,Client_ResetHUD, true },
{ "AmmoX" , &gmsgAmmoX, Client_AmmoX , false },
{ "ScoreInfo" , &gmsgScoreInfo, Client_ScoreInfo, false },
{ "AmmoPickup" , &gmsgAmmoPickup, Client_AmmoPickup , false },
{ "SendAudio" , &gmsgSendAudio , Client_SendAudio , false },
{ "TextMsg" , &gmsgTextMsg , Client_TextMsg , false },
{ "BarTime" , &gmsgBarTime , Client_BarTime , false },
{ 0 , 0,0,false }
};
int RegUserMsg_Post(const char *pszName, int iSize)
{
for (int i = 0; g_user_msg[ i ].name; ++i )
{
if ( !*g_user_msg[i].id && strcmp( g_user_msg[ i ].name , pszName ) == 0 )
{
int id = META_RESULT_ORIG_RET( int );
*g_user_msg[ i ].id = id;
if ( g_user_msg[ i ].endmsg )
modMsgsEnd[ id ] = g_user_msg[ i ].func;
else
modMsgs[ id ] = g_user_msg[ i ].func;
//break;
}
}
RETURN_META_VALUE(MRES_IGNORED, 0);
}
const char* get_localinfo( const char* name , const char* def = 0 )
{
const char* b = LOCALINFO( (char*)name );
if (((b==0)||(*b==0)) && def )
SET_LOCALINFO((char*)name,(char*)(b = def) );
return b;
}
void ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax ){
rankBots = (int)csstats_rankbots->value ? true:false;
for( int i = 1; i <= gpGlobals->maxClients; ++i)
GET_PLAYER_POINTER_I(i)->Init( i , pEdictList + i );
RETURN_META(MRES_IGNORED);
}
void PlayerPreThink_Post( edict_t *pEntity ) {
if ( !isModuleActive() )
return;
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
if (pPlayer->clearStats && pPlayer->clearStats < gpGlobals->time ){
if ( !ignoreBots(pEntity) ){
pPlayer->clearStats = 0.0f;
if (pPlayer->rank)
pPlayer->rank->updatePosition( &pPlayer->life );
pPlayer->restartStats(false);
}
}
RETURN_META(MRES_IGNORED);
}
void ServerDeactivate() {
int i;
for( i = 1;i<=gpGlobals->maxClients; ++i){
CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
if (pPlayer->rank) pPlayer->Disconnect();
}
if ( (g_rank.getRankNum() >= (int)csstats_maxsize->value) || ((int)csstats_reset->value == 1 ) ) {
CVAR_SET_FLOAT("csstats_reset",0.0);
g_rank.clear(); // clear before save to file
}
g_rank.saveRank( MF_BuildPathname("%s",get_localinfo("csstats")) );
RETURN_META(MRES_IGNORED);
}
BOOL ClientConnect_Post( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[ 128 ] ){
GET_PLAYER_POINTER(pEntity)->Connect(pszAddress);
RETURN_META_VALUE(MRES_IGNORED, TRUE);
}
void ClientDisconnect( edict_t *pEntity ) {
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
if (pPlayer->rank) pPlayer->Disconnect();
RETURN_META(MRES_IGNORED);
}
void ClientPutInServer_Post( edict_t *pEntity ) {
GET_PLAYER_POINTER(pEntity)->PutInServer();
RETURN_META(MRES_IGNORED);
}
void ClientUserInfoChanged_Post( edict_t *pEntity, char *infobuffer ) {
CPlayer *pPlayer = GET_PLAYER_POINTER(pEntity);
const char* name = INFOKEY_VALUE(infobuffer,"name");
const char* oldname = STRING(pEntity->v.netname);
if ( pPlayer->rank ){
if ( strcmp(oldname,name) != 0 ) {
if ((int)csstats_rank->value == 0)
pPlayer->rank = g_rank.findEntryInRank( name, name );
else
pPlayer->rank->setName( name );
}
}
else if ( pPlayer->IsBot() ) {
pPlayer->Connect( "127.0.0.1" );
pPlayer->PutInServer();
}
RETURN_META(MRES_IGNORED);
}
void MessageBegin_Post(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed) {
if (ed){
mPlayerIndex = ENTINDEX(ed);
mPlayer = GET_PLAYER_POINTER_I(mPlayerIndex);
} else {
mPlayerIndex = 0;
mPlayer = 0;
}
mState = 0;
if ( msg_type < 0 || msg_type >= MAX_REG_MSGS )
msg_type = 0;
function=modMsgs[msg_type];
endfunction=modMsgsEnd[msg_type];
RETURN_META(MRES_IGNORED);
}
void MessageEnd_Post(void) {
if (endfunction) (*endfunction)(NULL);
RETURN_META(MRES_IGNORED);
}
void WriteByte_Post(int iValue) {
if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED);
}
void WriteChar_Post(int iValue) {
if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED);
}
void WriteShort_Post(int iValue) {
if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED);
}
void WriteLong_Post(int iValue) {
if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED);
}
void WriteAngle_Post(float flValue) {
if (function) (*function)((void *)&flValue);
RETURN_META(MRES_IGNORED);
}
void WriteCoord_Post(float flValue) {
if (function) (*function)((void *)&flValue);
RETURN_META(MRES_IGNORED);
}
void WriteString_Post(const char *sz) {
if (function) (*function)((void *)sz);
RETURN_META(MRES_IGNORED);
}
void WriteEntity_Post(int iValue) {
if (function) (*function)((void *)&iValue);
RETURN_META(MRES_IGNORED);
}
void SetModel_Post(edict_t *e, const char *m){
if ( !isModuleActive() )
return;
if ( e->v.owner && m[7]=='w' && m[8]=='_' ){
int w_id = 0;
CPlayer *pPlayer = GET_PLAYER_POINTER(e->v.owner);
switch(m[9]){
case 'h':
g_grenades.put(e, 1.75, CSW_HEGRENADE, pPlayer);
pPlayer->saveShot(CSW_HEGRENADE);
break;
}
}
RETURN_META(MRES_IGNORED);
}
void EmitSound_Post(edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch) {
if (sample[0]=='w'&&sample[1]=='e'&&sample[8]=='k'&&sample[9]=='n'&&sample[14]!='d'){
CPlayer*pPlayer = GET_PLAYER_POINTER(entity);
pPlayer->saveShot(pPlayer->current);
}
RETURN_META(MRES_IGNORED);
}
void TraceLine_Post(const float *v1, const float *v2, int fNoMonsters, edict_t *e, TraceResult *ptr) {
if (ptr->pHit&&(ptr->pHit->v.flags& (FL_CLIENT | FL_FAKECLIENT) )&&
e&&(e->v.flags& (FL_CLIENT | FL_FAKECLIENT) )&&ptr->iHitgroup)
GET_PLAYER_POINTER(e)->aiming = ptr->iHitgroup;
RETURN_META(MRES_IGNORED);
}
void OnMetaAttach() {
CVAR_REGISTER (&init_csstats_maxsize);
CVAR_REGISTER (&init_csstats_reset);
CVAR_REGISTER (&init_csstats_rank);
csstats_maxsize=CVAR_GET_POINTER(init_csstats_maxsize.name);
csstats_reset=CVAR_GET_POINTER(init_csstats_reset.name);
csstats_rank=CVAR_GET_POINTER(init_csstats_rank.name);
CVAR_REGISTER (&init_csstats_rankbots);
CVAR_REGISTER (&init_csstats_pause);
csstats_rankbots = CVAR_GET_POINTER(init_csstats_rankbots.name);
csstats_pause = CVAR_GET_POINTER(init_csstats_pause.name);
}
void OnAmxxAttach(){
MF_AddNatives(stats_Natives);
const char* path = get_localinfo("csstats_score");
if ( path && *path )
{
char error[128];
g_rank.loadCalc( MF_BuildPathname("%s",path) , error );
}
if ( !g_rank.begin() )
{
g_rank.loadRank( MF_BuildPathname("%s",
get_localinfo("csstats") ) );
}
}
void OnAmxxDetach() {
g_grenades.clear();
g_rank.clear();
g_rank.unloadCalc();
}

View File

@ -1,462 +0,0 @@
// Configuration
#ifndef __MODULECONFIG_H__
#define __MODULECONFIG_H__
// Module info
#define MODULE_NAME "CSStats"
#define MODULE_VERSION "0.20"
#define MODULE_AUTHOR "AMX Mod X Dev Team"
#define MODULE_URL "http://www.amxmodx.org"
#define MODULE_LOGTAG "CSSTATS"
// If you want the module not to be reloaded on mapchange, remove / comment out the next line
#define MODULE_RELOAD_ON_MAPCHANGE
#ifdef __DATE__
#define MODULE_DATE __DATE__
#else // __DATE__
#define MODULE_DATE "Unknown"
#endif // __DATE__
// metamod plugin?
#define USE_METAMOD
// - AMXX Init functions
// Also consider using FN_META_*
// AMXX query
//#define FN_AMXX_QUERY OnAmxxQuery
// AMXX attach
// Do native functions init here (MF_AddNatives)
#define FN_AMXX_ATTACH OnAmxxAttach
// AMXX dettach
#define FN_AMXX_DETACH OnAmxxDetach
// All plugins loaded
// Do forward functions init here (MF_RegisterForward)
// #define FN_AMXX_PLUGINSLOADED OnPluginsLoaded
/**** METAMOD ****/
// If your module doesn't use metamod, you may close the file now :)
#ifdef USE_METAMOD
// ----
// Hook Functions
// Uncomment these to be called
// You can also change the function name
// - Metamod init functions
// Also consider using FN_AMXX_*
// Meta query
//#define FN_META_QUERY OnMetaQuery
// Meta attach
#define FN_META_ATTACH OnMetaAttach
// Meta dettach
//#define FN_META_DETACH OnMetaDetach
// (wd) are Will Day's notes
// - GetEntityAPI2 functions
// #define FN_GameDLLInit GameDLLInit /* pfnGameInit() */
// #define FN_DispatchSpawn DispatchSpawn /* pfnSpawn() */
// #define FN_DispatchThink DispatchThink /* pfnThink() */
// #define FN_DispatchUse DispatchUse /* pfnUse() */
// #define FN_DispatchTouch DispatchTouch /* pfnTouch() */
// #define FN_DispatchBlocked DispatchBlocked /* pfnBlocked() */
// #define FN_DispatchKeyValue DispatchKeyValue /* pfnKeyValue() */
// #define FN_DispatchSave DispatchSave /* pfnSave() */
// #define FN_DispatchRestore DispatchRestore /* pfnRestore() */
// #define FN_DispatchObjectCollsionBox DispatchObjectCollsionBox /* pfnSetAbsBox() */
// #define FN_SaveWriteFields SaveWriteFields /* pfnSaveWriteFields() */
// #define FN_SaveReadFields SaveReadFields /* pfnSaveReadFields() */
// #define FN_SaveGlobalState SaveGlobalState /* pfnSaveGlobalState() */
// #define FN_RestoreGlobalState RestoreGlobalState /* pfnRestoreGlobalState() */
// #define FN_ResetGlobalState ResetGlobalState /* pfnResetGlobalState() */
// #define FN_ClientConnect ClientConnect /* pfnClientConnect() (wd) Client has connected */
#define FN_ClientDisconnect ClientDisconnect /* pfnClientDisconnect() (wd) Player has left the game */
// #define FN_ClientKill ClientKill /* pfnClientKill() (wd) Player has typed "kill" */
// #define FN_ClientPutInServer ClientPutInServer /* pfnClientPutInServer() (wd) Client is entering the game */
// #define FN_ClientCommand ClientCommand /* pfnClientCommand() (wd) Player has sent a command (typed or from a bind) */
// #define FN_ClientUserInfoChanged ClientUserInfoChanged /* pfnClientUserInfoChanged() (wd) Client has updated their setinfo structure */
// #define FN_ServerActivate ServerActivate /* pfnServerActivate() (wd) Server is starting a new map */
#define FN_ServerDeactivate ServerDeactivate /* pfnServerDeactivate() (wd) Server is leaving the map (shutdown or changelevel); SDK2 */
// #define FN_PlayerPreThink PlayerPreThink /* pfnPlayerPreThink() */
// #define FN_PlayerPostThink PlayerPostThink /* pfnPlayerPostThink() */
// #define FN_StartFrame StartFrame /* pfnStartFrame() */
// #define FN_ParmsNewLevel ParmsNewLevel /* pfnParmsNewLevel() */
// #define FN_ParmsChangeLevel ParmsChangeLevel /* pfnParmsChangeLevel() */
// #define FN_GetGameDescription GetGameDescription /* pfnGetGameDescription() Returns string describing current .dll. E.g. "TeamFotrress 2" "Half-Life" */
// #define FN_PlayerCustomization PlayerCustomization /* pfnPlayerCustomization() Notifies .dll of new customization for player. */
// #define FN_SpectatorConnect SpectatorConnect /* pfnSpectatorConnect() Called when spectator joins server */
// #define FN_SpectatorDisconnect SpectatorDisconnect /* pfnSpectatorDisconnect() Called when spectator leaves the server */
// #define FN_SpectatorThink SpectatorThink /* pfnSpectatorThink() Called when spectator sends a command packet (usercmd_t) */
// #define FN_Sys_Error Sys_Error /* pfnSys_Error() Notify game .dll that engine is going to shut down. Allows mod authors to set a breakpoint. SDK2 */
// #define FN_PM_Move PM_Move /* pfnPM_Move() (wd) SDK2 */
// #define FN_PM_Init PM_Init /* pfnPM_Init() Server version of player movement initialization; (wd) SDK2 */
// #define FN_PM_FindTextureType PM_FindTextureType /* pfnPM_FindTextureType() (wd) SDK2 */
// #define FN_SetupVisibility SetupVisibility /* pfnSetupVisibility() Set up PVS and PAS for networking for this client; (wd) SDK2 */
// #define FN_UpdateClientData UpdateClientData /* pfnUpdateClientData() Set up data sent only to specific client; (wd) SDK2 */
// #define FN_AddToFullPack AddToFullPack /* pfnAddToFullPack() (wd) SDK2 */
// #define FN_CreateBaseline CreateBaseline /* pfnCreateBaseline() Tweak entity baseline for network encoding allows setup of player baselines too.; (wd) SDK2 */
// #define FN_RegisterEncoders RegisterEncoders /* pfnRegisterEncoders() Callbacks for network encoding; (wd) SDK2 */
// #define FN_GetWeaponData GetWeaponData /* pfnGetWeaponData() (wd) SDK2 */
// #define FN_CmdStart CmdStart /* pfnCmdStart() (wd) SDK2 */
// #define FN_CmdEnd CmdEnd /* pfnCmdEnd() (wd) SDK2 */
// #define FN_ConnectionlessPacket ConnectionlessPacket /* pfnConnectionlessPacket() (wd) SDK2 */
// #define FN_GetHullBounds GetHullBounds /* pfnGetHullBounds() (wd) SDK2 */
// #define FN_CreateInstancedBaselines CreateInstancedBaselines /* pfnCreateInstancedBaselines() (wd) SDK2 */
// #define FN_InconsistentFile InconsistentFile /* pfnInconsistentFile() (wd) SDK2 */
// #define FN_AllowLagCompensation AllowLagCompensation /* pfnAllowLagCompensation() (wd) SDK2 */
// - GetEntityAPI2_Post functions
// #define FN_GameDLLInit_Post GameDLLInit_Post
// #define FN_DispatchSpawn_Post DispatchSpawn_Post
// #define FN_DispatchThink_Post DispatchThink_Post
// #define FN_DispatchUse_Post DispatchUse_Post
// #define FN_DispatchTouch_Post DispatchTouch_Post
// #define FN_DispatchBlocked_Post DispatchBlocked_Post
// #define FN_DispatchKeyValue_Post DispatchKeyValue_Post
// #define FN_DispatchSave_Post DispatchSave_Post
// #define FN_DispatchRestore_Post DispatchRestore_Post
// #define FN_DispatchObjectCollsionBox_Post DispatchObjectCollsionBox_Post
// #define FN_SaveWriteFields_Post SaveWriteFields_Post
// #define FN_SaveReadFields_Post SaveReadFields_Post
// #define FN_SaveGlobalState_Post SaveGlobalState_Post
// #define FN_RestoreGlobalState_Post RestoreGlobalState_Post
// #define FN_ResetGlobalState_Post ResetGlobalState_Post
#define FN_ClientConnect_Post ClientConnect_Post
// #define FN_ClientDisconnect_Post ClientDisconnect_Post
// #define FN_ClientKill_Post ClientKill_Post
#define FN_ClientPutInServer_Post ClientPutInServer_Post
// #define FN_ClientCommand_Post ClientCommand_Post
#define FN_ClientUserInfoChanged_Post ClientUserInfoChanged_Post
#define FN_ServerActivate_Post ServerActivate_Post
// #define FN_ServerDeactivate_Post ServerDeactivate_Post
#define FN_PlayerPreThink_Post PlayerPreThink_Post
// #define FN_PlayerPostThink_Post PlayerPostThink_Post
// #define FN_StartFrame_Post StartFrame_Post
// #define FN_ParmsNewLevel_Post ParmsNewLevel_Post
// #define FN_ParmsChangeLevel_Post ParmsChangeLevel_Post
// #define FN_GetGameDescription_Post GetGameDescription_Post
// #define FN_PlayerCustomization_Post PlayerCustomization_Post
// #define FN_SpectatorConnect_Post SpectatorConnect_Post
// #define FN_SpectatorDisconnect_Post SpectatorDisconnect_Post
// #define FN_SpectatorThink_Post SpectatorThink_Post
// #define FN_Sys_Error_Post Sys_Error_Post
// #define FN_PM_Move_Post PM_Move_Post
// #define FN_PM_Init_Post PM_Init_Post
// #define FN_PM_FindTextureType_Post PM_FindTextureType_Post
// #define FN_SetupVisibility_Post SetupVisibility_Post
// #define FN_UpdateClientData_Post UpdateClientData_Post
// #define FN_AddToFullPack_Post AddToFullPack_Post
// #define FN_CreateBaseline_Post CreateBaseline_Post
// #define FN_RegisterEncoders_Post RegisterEncoders_Post
// #define FN_GetWeaponData_Post GetWeaponData_Post
// #define FN_CmdStart_Post CmdStart_Post
// #define FN_CmdEnd_Post CmdEnd_Post
// #define FN_ConnectionlessPacket_Post ConnectionlessPacket_Post
// #define FN_GetHullBounds_Post GetHullBounds_Post
// #define FN_CreateInstancedBaselines_Post CreateInstancedBaselines_Post
// #define FN_InconsistentFile_Post InconsistentFile_Post
// #define FN_AllowLagCompensation_Post AllowLagCompensation_Post
// - GetEngineAPI functions
// #define FN_PrecacheModel PrecacheModel
// #define FN_PrecacheSound PrecacheSound
// #define FN_SetModel SetModel
// #define FN_ModelIndex ModelIndex
// #define FN_ModelFrames ModelFrames
// #define FN_SetSize SetSize
// #define FN_ChangeLevel ChangeLevel
// #define FN_GetSpawnParms GetSpawnParms
// #define FN_SaveSpawnParms SaveSpawnParms
// #define FN_VecToYaw VecToYaw
// #define FN_VecToAngles VecToAngles
// #define FN_MoveToOrigin MoveToOrigin
// #define FN_ChangeYaw ChangeYaw
// #define FN_ChangePitch ChangePitch
// #define FN_FindEntityByString FindEntityByString
// #define FN_GetEntityIllum GetEntityIllum
// #define FN_FindEntityInSphere FindEntityInSphere
// #define FN_FindClientInPVS FindClientInPVS
// #define FN_EntitiesInPVS EntitiesInPVS
// #define FN_MakeVectors MakeVectors
// #define FN_AngleVectors AngleVectors
// #define FN_CreateEntity CreateEntity
// #define FN_RemoveEntity RemoveEntity
// #define FN_CreateNamedEntity CreateNamedEntity
// #define FN_MakeStatic MakeStatic
// #define FN_EntIsOnFloor EntIsOnFloor
// #define FN_DropToFloor DropToFloor
// #define FN_WalkMove WalkMove
// #define FN_SetOrigin SetOrigin
// #define FN_EmitSound EmitSound
// #define FN_EmitAmbientSound EmitAmbientSound
// #define FN_TraceLine TraceLine
// #define FN_TraceToss TraceToss
// #define FN_TraceMonsterHull TraceMonsterHull
// #define FN_TraceHull TraceHull
// #define FN_TraceModel TraceModel
// #define FN_TraceTexture TraceTexture
// #define FN_TraceSphere TraceSphere
// #define FN_GetAimVector GetAimVector
// #define FN_ServerCommand ServerCommand
// #define FN_ServerExecute ServerExecute
// #define FN_engClientCommand engClientCommand
// #define FN_ParticleEffect ParticleEffect
// #define FN_LightStyle LightStyle
// #define FN_DecalIndex DecalIndex
// #define FN_PointContents PointContents
// #define FN_MessageBegin MessageBegin
// #define FN_MessageEnd MessageEnd
// #define FN_WriteByte WriteByte
// #define FN_WriteChar WriteChar
// #define FN_WriteShort WriteShort
// #define FN_WriteLong WriteLong
// #define FN_WriteAngle WriteAngle
// #define FN_WriteCoord WriteCoord
// #define FN_WriteString WriteString
// #define FN_WriteEntity WriteEntity
// #define FN_CVarRegister CVarRegister
// #define FN_CVarGetFloat CVarGetFloat
// #define FN_CVarGetString CVarGetString
// #define FN_CVarSetFloat CVarSetFloat
// #define FN_CVarSetString CVarSetString
// #define FN_AlertMessage AlertMessage
// #define FN_EngineFprintf EngineFprintf
// #define FN_PvAllocEntPrivateData PvAllocEntPrivateData
// #define FN_PvEntPrivateData PvEntPrivateData
// #define FN_FreeEntPrivateData FreeEntPrivateData
// #define FN_SzFromIndex SzFromIndex
// #define FN_AllocString AllocString
// #define FN_GetVarsOfEnt GetVarsOfEnt
// #define FN_PEntityOfEntOffset PEntityOfEntOffset
// #define FN_EntOffsetOfPEntity EntOffsetOfPEntity
// #define FN_IndexOfEdict IndexOfEdict
// #define FN_PEntityOfEntIndex PEntityOfEntIndex
// #define FN_FindEntityByVars FindEntityByVars
// #define FN_GetModelPtr GetModelPtr
// #define FN_RegUserMsg RegUserMsg
// #define FN_AnimationAutomove AnimationAutomove
// #define FN_GetBonePosition GetBonePosition
// #define FN_FunctionFromName FunctionFromName
// #define FN_NameForFunction NameForFunction
// #define FN_ClientPrintf ClientPrintf
// #define FN_ServerPrint ServerPrint
// #define FN_Cmd_Args Cmd_Args
// #define FN_Cmd_Argv Cmd_Argv
// #define FN_Cmd_Argc Cmd_Argc
// #define FN_GetAttachment GetAttachment
// #define FN_CRC32_Init CRC32_Init
// #define FN_CRC32_ProcessBuffer CRC32_ProcessBuffer
// #define FN_CRC32_ProcessByte CRC32_ProcessByte
// #define FN_CRC32_Final CRC32_Final
// #define FN_RandomLong RandomLong
// #define FN_RandomFloat RandomFloat
// #define FN_SetView SetView
// #define FN_Time Time
// #define FN_CrosshairAngle CrosshairAngle
// #define FN_LoadFileForMe LoadFileForMe
// #define FN_FreeFile FreeFile
// #define FN_EndSection EndSection
// #define FN_CompareFileTime CompareFileTime
// #define FN_GetGameDir GetGameDir
// #define FN_Cvar_RegisterVariable Cvar_RegisterVariable
// #define FN_FadeClientVolume FadeClientVolume
// #define FN_SetClientMaxspeed SetClientMaxspeed
// #define FN_CreateFakeClient CreateFakeClient
// #define FN_RunPlayerMove RunPlayerMove
// #define FN_NumberOfEntities NumberOfEntities
// #define FN_GetInfoKeyBuffer GetInfoKeyBuffer
// #define FN_InfoKeyValue InfoKeyValue
// #define FN_SetKeyValue SetKeyValue
// #define FN_SetClientKeyValue SetClientKeyValue
// #define FN_IsMapValid IsMapValid
// #define FN_StaticDecal StaticDecal
// #define FN_PrecacheGeneric PrecacheGeneric
// #define FN_GetPlayerUserId GetPlayerUserId
// #define FN_BuildSoundMsg BuildSoundMsg
// #define FN_IsDedicatedServer IsDedicatedServer
// #define FN_CVarGetPointer CVarGetPointer
// #define FN_GetPlayerWONId GetPlayerWONId
// #define FN_Info_RemoveKey Info_RemoveKey
// #define FN_GetPhysicsKeyValue GetPhysicsKeyValue
// #define FN_SetPhysicsKeyValue SetPhysicsKeyValue
// #define FN_GetPhysicsInfoString GetPhysicsInfoString
// #define FN_PrecacheEvent PrecacheEvent
// #define FN_PlaybackEvent PlaybackEvent
// #define FN_SetFatPVS SetFatPVS
// #define FN_SetFatPAS SetFatPAS
// #define FN_CheckVisibility CheckVisibility
// #define FN_DeltaSetField DeltaSetField
// #define FN_DeltaUnsetField DeltaUnsetField
// #define FN_DeltaAddEncoder DeltaAddEncoder
// #define FN_GetCurrentPlayer GetCurrentPlayer
// #define FN_CanSkipPlayer CanSkipPlayer
// #define FN_DeltaFindField DeltaFindField
// #define FN_DeltaSetFieldByIndex DeltaSetFieldByIndex
// #define FN_DeltaUnsetFieldByIndex DeltaUnsetFieldByIndex
// #define FN_SetGroupMask SetGroupMask
// #define FN_engCreateInstancedBaseline engCreateInstancedBaseline
// #define FN_Cvar_DirectSet Cvar_DirectSet
// #define FN_ForceUnmodified ForceUnmodified
// #define FN_GetPlayerStats GetPlayerStats
// #define FN_AddServerCommand AddServerCommand
// #define FN_Voice_GetClientListening Voice_GetClientListening
// #define FN_Voice_SetClientListening Voice_SetClientListening
// #define FN_GetPlayerAuthId GetPlayerAuthId
// - GetEngineAPI_Post functions
// #define FN_PrecacheModel_Post PrecacheModel_Post
// #define FN_PrecacheSound_Post PrecacheSound_Post
#define FN_SetModel_Post SetModel_Post
// #define FN_ModelIndex_Post ModelIndex_Post
// #define FN_ModelFrames_Post ModelFrames_Post
// #define FN_SetSize_Post SetSize_Post
// #define FN_ChangeLevel_Post ChangeLevel_Post
// #define FN_GetSpawnParms_Post GetSpawnParms_Post
// #define FN_SaveSpawnParms_Post SaveSpawnParms_Post
// #define FN_VecToYaw_Post VecToYaw_Post
// #define FN_VecToAngles_Post VecToAngles_Post
// #define FN_MoveToOrigin_Post MoveToOrigin_Post
// #define FN_ChangeYaw_Post ChangeYaw_Post
// #define FN_ChangePitch_Post ChangePitch_Post
// #define FN_FindEntityByString_Post FindEntityByString_Post
// #define FN_GetEntityIllum_Post GetEntityIllum_Post
// #define FN_FindEntityInSphere_Post FindEntityInSphere_Post
// #define FN_FindClientInPVS_Post FindClientInPVS_Post
// #define FN_EntitiesInPVS_Post EntitiesInPVS_Post
// #define FN_MakeVectors_Post MakeVectors_Post
// #define FN_AngleVectors_Post AngleVectors_Post
// #define FN_CreateEntity_Post CreateEntity_Post
// #define FN_RemoveEntity_Post RemoveEntity_Post
// #define FN_CreateNamedEntity_Post CreateNamedEntity_Post
// #define FN_MakeStatic_Post MakeStatic_Post
// #define FN_EntIsOnFloor_Post EntIsOnFloor_Post
// #define FN_DropToFloor_Post DropToFloor_Post
// #define FN_WalkMove_Post WalkMove_Post
// #define FN_SetOrigin_Post SetOrigin_Post
// #define FN_EmitSound_Post EmitSound_Post
// #define FN_EmitAmbientSound_Post EmitAmbientSound_Post
#define FN_TraceLine_Post TraceLine_Post
// #define FN_TraceToss_Post TraceToss_Post
// #define FN_TraceMonsterHull_Post TraceMonsterHull_Post
// #define FN_TraceHull_Post TraceHull_Post
// #define FN_TraceModel_Post TraceModel_Post
// #define FN_TraceTexture_Post TraceTexture_Post
// #define FN_TraceSphere_Post TraceSphere_Post
// #define FN_GetAimVector_Post GetAimVector_Post
// #define FN_ServerCommand_Post ServerCommand_Post
// #define FN_ServerExecute_Post ServerExecute_Post
// #define FN_engClientCommand_Post engClientCommand_Post
// #define FN_ParticleEffect_Post ParticleEffect_Post
// #define FN_LightStyle_Post LightStyle_Post
// #define FN_DecalIndex_Post DecalIndex_Post
// #define FN_PointContents_Post PointContents_Post
#define FN_MessageBegin_Post MessageBegin_Post
#define FN_MessageEnd_Post MessageEnd_Post
#define FN_WriteByte_Post WriteByte_Post
#define FN_WriteChar_Post WriteChar_Post
#define FN_WriteShort_Post WriteShort_Post
#define FN_WriteLong_Post WriteLong_Post
#define FN_WriteAngle_Post WriteAngle_Post
#define FN_WriteCoord_Post WriteCoord_Post
#define FN_WriteString_Post WriteString_Post
#define FN_WriteEntity_Post WriteEntity_Post
// #define FN_CVarRegister_Post CVarRegister_Post
// #define FN_CVarGetFloat_Post CVarGetFloat_Post
// #define FN_CVarGetString_Post CVarGetString_Post
// #define FN_CVarSetFloat_Post CVarSetFloat_Post
// #define FN_CVarSetString_Post CVarSetString_Post
// #define FN_AlertMessage_Post AlertMessage_Post
// #define FN_EngineFprintf_Post EngineFprintf_Post
// #define FN_PvAllocEntPrivateData_Post PvAllocEntPrivateData_Post
// #define FN_PvEntPrivateData_Post PvEntPrivateData_Post
// #define FN_FreeEntPrivateData_Post FreeEntPrivateData_Post
// #define FN_SzFromIndex_Post SzFromIndex_Post
// #define FN_AllocString_Post AllocString_Post
// #define FN_GetVarsOfEnt_Post GetVarsOfEnt_Post
// #define FN_PEntityOfEntOffset_Post PEntityOfEntOffset_Post
// #define FN_EntOffsetOfPEntity_Post EntOffsetOfPEntity_Post
// #define FN_IndexOfEdict_Post IndexOfEdict_Post
// #define FN_PEntityOfEntIndex_Post PEntityOfEntIndex_Post
// #define FN_FindEntityByVars_Post FindEntityByVars_Post
// #define FN_GetModelPtr_Post GetModelPtr_Post
#define FN_RegUserMsg_Post RegUserMsg_Post
// #define FN_AnimationAutomove_Post AnimationAutomove_Post
// #define FN_GetBonePosition_Post GetBonePosition_Post
// #define FN_FunctionFromName_Post FunctionFromName_Post
// #define FN_NameForFunction_Post NameForFunction_Post
// #define FN_ClientPrintf_Post ClientPrintf_Post
// #define FN_ServerPrint_Post ServerPrint_Post
// #define FN_Cmd_Args_Post Cmd_Args_Post
// #define FN_Cmd_Argv_Post Cmd_Argv_Post
// #define FN_Cmd_Argc_Post Cmd_Argc_Post
// #define FN_GetAttachment_Post GetAttachment_Post
// #define FN_CRC32_Init_Post CRC32_Init_Post
// #define FN_CRC32_ProcessBuffer_Post CRC32_ProcessBuffer_Post
// #define FN_CRC32_ProcessByte_Post CRC32_ProcessByte_Post
// #define FN_CRC32_Final_Post CRC32_Final_Post
// #define FN_RandomLong_Post RandomLong_Post
// #define FN_RandomFloat_Post RandomFloat_Post
// #define FN_SetView_Post SetView_Post
// #define FN_Time_Post Time_Post
// #define FN_CrosshairAngle_Post CrosshairAngle_Post
// #define FN_LoadFileForMe_Post LoadFileForMe_Post
// #define FN_FreeFile_Post FreeFile_Post
// #define FN_EndSection_Post EndSection_Post
// #define FN_CompareFileTime_Post CompareFileTime_Post
// #define FN_GetGameDir_Post GetGameDir_Post
// #define FN_Cvar_RegisterVariable_Post Cvar_RegisterVariable_Post
// #define FN_FadeClientVolume_Post FadeClientVolume_Post
// #define FN_SetClientMaxspeed_Post SetClientMaxspeed_Post
// #define FN_CreateFakeClient_Post CreateFakeClient_Post
// #define FN_RunPlayerMove_Post RunPlayerMove_Post
// #define FN_NumberOfEntities_Post NumberOfEntities_Post
// #define FN_GetInfoKeyBuffer_Post GetInfoKeyBuffer_Post
// #define FN_InfoKeyValue_Post InfoKeyValue_Post
// #define FN_SetKeyValue_Post SetKeyValue_Post
// #define FN_SetClientKeyValue_Post SetClientKeyValue_Post
// #define FN_IsMapValid_Post IsMapValid_Post
// #define FN_StaticDecal_Post StaticDecal_Post
// #define FN_PrecacheGeneric_Post PrecacheGeneric_Post
// #define FN_GetPlayerUserId_Post GetPlayerUserId_Post
// #define FN_BuildSoundMsg_Post BuildSoundMsg_Post
// #define FN_IsDedicatedServer_Post IsDedicatedServer_Post
// #define FN_CVarGetPointer_Post CVarGetPointer_Post
// #define FN_GetPlayerWONId_Post GetPlayerWONId_Post
// #define FN_Info_RemoveKey_Post Info_RemoveKey_Post
// #define FN_GetPhysicsKeyValue_Post GetPhysicsKeyValue_Post
// #define FN_SetPhysicsKeyValue_Post SetPhysicsKeyValue_Post
// #define FN_GetPhysicsInfoString_Post GetPhysicsInfoString_Post
// #define FN_PrecacheEvent_Post PrecacheEvent_Post
// #define FN_PlaybackEvent_Post PlaybackEvent_Post
// #define FN_SetFatPVS_Post SetFatPVS_Post
// #define FN_SetFatPAS_Post SetFatPAS_Post
// #define FN_CheckVisibility_Post CheckVisibility_Post
// #define FN_DeltaSetField_Post DeltaSetField_Post
// #define FN_DeltaUnsetField_Post DeltaUnsetField_Post
// #define FN_DeltaAddEncoder_Post DeltaAddEncoder_Post
// #define FN_GetCurrentPlayer_Post GetCurrentPlayer_Post
// #define FN_CanSkipPlayer_Post CanSkipPlayer_Post
// #define FN_DeltaFindField_Post DeltaFindField_Post
// #define FN_DeltaSetFieldByIndex_Post DeltaSetFieldByIndex_Post
// #define FN_DeltaUnsetFieldByIndex_Post DeltaUnsetFieldByIndex_Post
// #define FN_SetGroupMask_Post SetGroupMask_Post
// #define FN_engCreateInstancedBaseline_Post engCreateInstancedBaseline_Post
// #define FN_Cvar_DirectSet_Post Cvar_DirectSet_Post
// #define FN_ForceUnmodified_Post ForceUnmodified_Post
// #define FN_GetPlayerStats_Post GetPlayerStats_Post
// #define FN_AddServerCommand_Post AddServerCommand_Post
// #define FN_Voice_GetClientListening_Post Voice_GetClientListening_Post
// #define FN_Voice_SetClientListening_Post Voice_SetClientListening_Post
// #define FN_GetPlayerAuthId_Post GetPlayerAuthId_Post
// #define FN_OnFreeEntPrivateData OnFreeEntPrivateData
// #define FN_GameShutdown GameShutdown
// #define FN_ShouldCollide ShouldCollide
// #define FN_OnFreeEntPrivateData_Post OnFreeEntPrivateData_Post
// #define FN_GameShutdown_Post GameShutdown_Post
// #define FN_ShouldCollide_Post ShouldCollide_Post
#endif // USE_METAMOD
#endif // __MODULECONFIG_H__

View File

@ -1,149 +0,0 @@
# Microsoft Developer Studio Project File - Name="csstats" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=csstats - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "csstats.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "csstats.mak" CFG="csstats - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "csstats - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "csstats - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "csstats - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "release"
# PROP Intermediate_Dir "release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "csstats_EXPORTS" /YX /FD /c
# ADD CPP /nologo /Zp4 /MT /W3 /GX /O2 /I "..\..\metamod" /I "..\..\sdk\common" /I "..\..\sdk\engine" /I "..\..\sdk\dlls" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "csstats_EXPORTS" /D "JIT" /FR /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"release/csstats_amxx.dll"
# SUBTRACT LINK32 /pdb:none
!ELSEIF "$(CFG)" == "csstats - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "debug"
# PROP Intermediate_Dir "debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "csstats_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\metamod" /I "..\..\sdk\common" /I "..\..\sdk\engine" /I "..\..\sdk\dlls" /I "..\..\hlsdk\sourcecode\pm_shared" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "csstats_EXPORTS" /FR /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"debug/csstats_amxx.dll" /pdbtype:sept
# SUBTRACT LINK32 /pdb:none
!ENDIF
# Begin Target
# Name "csstats - Win32 Release"
# Name "csstats - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\amxxmodule.cpp
# End Source File
# Begin Source File
SOURCE=..\CMisc.cpp
# End Source File
# Begin Source File
SOURCE=..\CRank.cpp
# End Source File
# Begin Source File
SOURCE=..\meta_api.cpp
# End Source File
# Begin Source File
SOURCE=..\rank.cpp
# End Source File
# Begin Source File
SOURCE=..\usermsg.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\amxxmodule.h
# End Source File
# Begin Source File
SOURCE=..\CMisc.h
# End Source File
# Begin Source File
SOURCE=..\CRank.h
# End Source File
# Begin Source File
SOURCE=..\moduleconfig.h
# End Source File
# Begin Source File
SOURCE=..\rank.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@ -1,311 +0,0 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="csstats"
ProjectGUID="{0EEE36AA-5899-48EF-8BBD-DAA65D6F5D35}"
SccProjectName=""
SccLocalPath="">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\debug"
IntermediateDirectory=".\debug"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\..\metamod,..\..\sdk\common,..\..\sdk\engine,..\..\sdk\dlls,..\..\hlsdk\sourcecode\pm_shared"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;csstats_EXPORTS"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\debug/csstats.pch"
AssemblerListingLocation=".\debug/"
ObjectFile=".\debug/"
ProgramDataBaseFileName=".\debug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="debug/csstats_amxx.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\debug/csstats_amxx.pdb"
ImportLibrary=".\debug/csstats_amxx.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\debug/csstats.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\release"
IntermediateDirectory=".\release"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\..\metamod,..\..\sdk\common,..\..\sdk\engine,..\..\sdk\dlls"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;csstats_EXPORTS;JIT"
StringPooling="TRUE"
RuntimeLibrary="0"
StructMemberAlignment="3"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\release/csstats.pch"
AssemblerListingLocation=".\release/"
ObjectFile=".\release/"
ProgramDataBaseFileName=".\release/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="release/csstats_amxx.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ProgramDatabaseFile=".\release/csstats_amxx.pdb"
ImportLibrary=".\release/csstats_amxx.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\release/csstats.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
RelativePath="..\amxxmodule.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\CMisc.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\CRank.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\meta_api.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\rank.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\usermsg.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;$(NoInherit)"
BasicRuntimeChecks="3"
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_MBCS;_USRDLL;csstats_EXPORTS;JIT;$(NoInherit)"
BrowseInformation="1"/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
<File
RelativePath="..\amxxmodule.h">
</File>
<File
RelativePath="..\CMisc.h">
</File>
<File
RelativePath="..\CRank.h">
</File>
<File
RelativePath="..\moduleconfig.h">
</File>
<File
RelativePath="..\rank.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -1,293 +0,0 @@
#include "amxxmodule.h"
#include "rank.h"
static cell AMX_NATIVE_CALL get_user_astats(AMX *amx, cell *params) /* 6 param */
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int attacker = params[2];
if (attacker<0||attacker>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->attackers[attacker].hits){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[4]);
CPlayer::PlayerWeapon* stats = &pPlayer->attackers[attacker];
cpStats[0] = stats->kills;
cpStats[1] = stats->deaths;
cpStats[2] = stats->hs;
cpStats[3] = stats->tks;
cpStats[4] = stats->shots;
cpStats[5] = stats->hits;
cpStats[6] = stats->damage;
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = stats->bodyHits[i];
if (params[6] && attacker && stats->name )
MF_SetAmxString(amx,params[5],stats->name,params[6]);
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_vstats(AMX *amx, cell *params) /* 6 param */
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int victim = params[2];
if (victim<0||victim>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->victims[victim].hits){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[4]);
CPlayer::PlayerWeapon* stats = &pPlayer->victims[victim];
cpStats[0] = stats->kills;
cpStats[1] = stats->deaths;
cpStats[2] = stats->hs;
cpStats[3] = stats->tks;
cpStats[4] = stats->shots;
cpStats[5] = stats->hits;
cpStats[6] = stats->damage;
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = stats->bodyHits[i];
if (params[6] && victim && stats->name)
MF_SetAmxString(amx,params[5],stats->name,params[6]);
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_wrstats(AMX *amx, cell *params) /* 4 param */ // DEC-Weapon (round) stats (end)
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int weapon = params[2];
if (weapon<0||weapon>=MAX_WEAPONS){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->weaponsRnd[weapon].shots){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[4]);
Stats* stats = &pPlayer->weaponsRnd[weapon];
cpStats[0] = stats->kills;
cpStats[1] = stats->deaths;
cpStats[2] = stats->hs;
cpStats[3] = stats->tks;
cpStats[4] = stats->shots;
cpStats[5] = stats->hits;
cpStats[6] = stats->damage;
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = stats->bodyHits[i];
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_wstats(AMX *amx, cell *params) /* 4 param */
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
int weapon = params[2];
if (weapon<0||weapon>=MAX_WEAPONS){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->weapons[weapon].shots){
cell *cpStats = MF_GetAmxAddr(amx,params[3]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[4]);
CPlayer::PlayerWeapon* stats = &pPlayer->weapons[weapon];
cpStats[0] = stats->kills;
cpStats[1] = stats->deaths;
cpStats[2] = stats->hs;
cpStats[3] = stats->tks;
cpStats[4] = stats->shots;
cpStats[5] = stats->hits;
cpStats[6] = stats->damage;
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = stats->bodyHits[i];
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL reset_user_wstats(AMX *amx, cell *params) /* 6 param */
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
GET_PLAYER_POINTER_I(index)->restartStats();
return 1;
}
static cell AMX_NATIVE_CALL get_user_rstats(AMX *amx, cell *params) /* 3 param */
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (pPlayer->rank){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[3]);
cpStats[0] = pPlayer->life.kills;
cpStats[1] = pPlayer->life.deaths;
cpStats[2] = pPlayer->life.hs;
cpStats[3] = pPlayer->life.tks;
cpStats[4] = pPlayer->life.shots;
cpStats[5] = pPlayer->life.hits;
cpStats[6] = pPlayer->life.damage;
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = pPlayer->life.bodyHits[i];
return 1;
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_stats(AMX *amx, cell *params) /* 3 param */
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( pPlayer->rank ){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[3]);
cpStats[0] = pPlayer->rank->kills;
cpStats[1] = pPlayer->rank->deaths;
cpStats[2] = pPlayer->rank->hs;
cpStats[3] = pPlayer->rank->tks;
cpStats[4] = pPlayer->rank->shots;
cpStats[5] = pPlayer->rank->hits;
cpStats[6] = pPlayer->rank->damage;
cpStats[7] = pPlayer->rank->getPosition();
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = pPlayer->rank->bodyHits[i];
return pPlayer->rank->getPosition();
}
return 0;
}
static cell AMX_NATIVE_CALL get_user_stats2(AMX *amx, cell *params) /* 3 param */
{
int index = params[1];
if (index<1||index>gpGlobals->maxClients){
MF_RaiseAmxError(amx,AMX_ERR_NATIVE);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if ( pPlayer->rank ){
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
cpStats[0] = pPlayer->rank->bDefusions;
cpStats[1] = pPlayer->rank->bDefused;
cpStats[2] = pPlayer->rank->bPlants;
cpStats[3] = pPlayer->rank->bExplosions;
return pPlayer->rank->getPosition();
}
return 0;
}
static cell AMX_NATIVE_CALL get_stats(AMX *amx, cell *params) /* 3 param */
{
int index = params[1] + 1;
for(RankSystem::iterator a = g_rank.front(); a ;--a){
if ((*a).getPosition() == index) {
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
cell *cpBodyHits = MF_GetAmxAddr(amx,params[3]);
cpStats[0] = (*a).kills;
cpStats[1] = (*a).deaths;
cpStats[2] = (*a).hs;
cpStats[3] = (*a).tks;
cpStats[4] = (*a).shots;
cpStats[5] = (*a).hits;
cpStats[6] = (*a).damage;
cpStats[7] = (*a).getPosition();
MF_SetAmxString(amx,params[4],(*a).getName(),params[5]);
for(int i = 1; i < 8; ++i)
cpBodyHits[i] = (*a).bodyHits[i];
return --a ? index : 0;
}
}
return 0;
}
static cell AMX_NATIVE_CALL get_stats2(AMX *amx, cell *params) /* 3 param */
{
int index = params[1] + 1;
for(RankSystem::iterator a = g_rank.front(); a ;--a){
if ((*a).getPosition() == index) {
cell *cpStats = MF_GetAmxAddr(amx,params[2]);
cpStats[0] = (*a).bDefusions;
cpStats[1] = (*a).bDefused;
cpStats[2] = (*a).bPlants;
cpStats[3] = (*a).bExplosions;
return --a ? index : 0;
}
}
return 0;
}
static cell AMX_NATIVE_CALL get_statsnum(AMX *amx, cell *params)
{
return g_rank.getRankNum();
}
AMX_NATIVE_INFO stats_Natives[] = {
{ "get_stats", get_stats},
{ "get_stats2", get_stats2},
{ "get_statsnum", get_statsnum},
{ "get_user_astats", get_user_astats },
{ "get_user_rstats", get_user_rstats },
{ "get_user_lstats", get_user_rstats }, // for backward compatibility
{ "get_user_stats", get_user_stats },
{ "get_user_stats2", get_user_stats2 },
{ "get_user_vstats", get_user_vstats },
{ "get_user_wrstats", get_user_wrstats}, // DEC-Weapon(Round) Stats
{ "get_user_wstats", get_user_wstats},
{ "reset_user_wstats", reset_user_wstats },
///*******************
{ NULL, NULL }
};

View File

@ -1,84 +0,0 @@
#ifndef RANK_H
#define RANK_H
#include "amxxmodule.h"
#include "CMisc.h"
#include "CRank.h"
#define GET_PLAYER_POINTER(e) (&players[ENTINDEX(e)])
#define GET_PLAYER_POINTER_I(i) (&players[i])
#ifndef GETPLAYERAUTHID
#define GETPLAYERAUTHID (*g_engfuncs.pfnGetPlayerAuthId)
#endif
extern AMX_NATIVE_INFO stats_Natives[];
struct weaponsVault {
char* name;
short int ammoSlot;
};
extern bool rankBots;
extern cvar_t* csstats_rankbots;
extern cvar_t* csstats_pause;
extern weaponsVault weaponData[MAX_WEAPONS];
typedef void (*funEventCall)(void*);
extern funEventCall modMsgsEnd[MAX_REG_MSGS];
extern funEventCall modMsgs[MAX_REG_MSGS];
extern void (*function)(void*);
extern void (*endfunction)(void*);
extern cvar_t *csstats_maxsize;
extern cvar_t* csstats_rank;
extern cvar_t* csstats_reset;
extern Grenades g_grenades;
extern RankSystem g_rank;
extern CPlayer players[33];
extern CPlayer* mPlayer;
extern int mPlayerIndex;
extern int mState;
extern int gmsgCurWeapon;
extern int gmsgDamage;
extern int gmsgWeaponList;
extern int gmsgResetHUD;
extern int gmsgAmmoX;
extern int gmsgScoreInfo;
extern int gmsgAmmoPickup;
extern int gmsgSendAudio;
extern int gmsgTextMsg;
extern int gmsgBarTime;
void Client_AmmoX(void*);
void Client_CurWeapon(void*);
void Client_Damage(void*);
void Client_WeaponList(void*);
void Client_AmmoPickup(void*);
void Client_ScoreInfo(void*);
void Client_ResetHUD(void*);
void Client_SendAudio(void*);
void Client_TextMsg(void*);
void Client_BarTime(void*);
bool ignoreBots (edict_t *pEnt, edict_t *pOther = NULL );
bool isModuleActive();
#endif // RANK_H

View File

@ -1,195 +0,0 @@
#include "amxxmodule.h"
#include "rank.h"
weaponsVault weaponData[MAX_WEAPONS];
int g_Planter;
int g_Defuser;
void Client_ResetHUD(void* mValue){
if ( mPlayer && mPlayer->IsAlive() )
mPlayer->clearStats = gpGlobals->time + 0.25f;
}
void Client_WeaponList(void* mValue){
static int wpnList;
static int iSlot;
static const char* wpnName;
switch (mState++) {
case 0:
wpnName = (const char*)mValue;
break;
case 1:
iSlot = *(int*)mValue;
break;
case 7:
int iId = *(int*)mValue;
if ( (iId < 0 || iId >= MAX_WEAPONS ) || ( wpnList & (1<<iId) ) )
break;
wpnList |= (1<<iId);
weaponData[iId].ammoSlot = iSlot;
char* wpnPrefix = strstr( wpnName,"weapon_");
if ( wpnPrefix )
{
weaponData[iId].name = wpnPrefix + 7;
if ( strcmp( weaponData[iId].name, "hegrenade" ) == 0 )
weaponData[iId].name += 2;
}
}
}
void Client_Damage(void* mValue){
static int bits;
static int damage;
static int TK;
static int weapon;
static int aim;
static bool ignore;
static CPlayer *pAttacker;
switch (mState++) {
case 1:
damage = *(int*)mValue;
break;
case 2:
bits = *(int*)mValue;
break;
case 3:
if ( ignore = (!mPlayer || !damage || !*(float*)mValue || bits) ) break;
edict_t *enemy;
enemy = mPlayer->pEdict->v.dmg_inflictor;
if ( FNullEnt( enemy ) )
break;
aim = 0;
weapon = 0;
pAttacker = NULL;
if (enemy->v.flags & (FL_CLIENT | FL_FAKECLIENT) ) {
pAttacker = GET_PLAYER_POINTER(enemy);
aim = pAttacker->aiming;
weapon = pAttacker->current;
pAttacker->saveHit( mPlayer , weapon , damage, aim);
break;
}
if( g_grenades.find(enemy , &pAttacker , &weapon ) )
pAttacker->saveHit( mPlayer , weapon , damage, aim );
break;
case 4:
if ( ignore || mPlayer->IsAlive() )
break;
if ( !pAttacker )
pAttacker = mPlayer;
TK = 0;
if ( (mPlayer->teamId == pAttacker->teamId) && (mPlayer != pAttacker) )
TK = 1;
pAttacker->saveKill(mPlayer,weapon,( aim == 1 ) ? 1:0 ,TK);
break;
}
}
void Client_CurWeapon(void* mValue){
static int iState;
static int iId;
switch (mState++){
case 0:
iState = *(int*)mValue;
break;
case 1:
if (!iState) break;
iId = *(int*)mValue;
break;
case 2:
if (!mPlayer || !iState ) break;
int iClip = *(int*)mValue;
if ((iClip > -1) && (iClip < mPlayer->weapons[iId].clip))
mPlayer->saveShot(iId);
mPlayer->weapons[iId].clip = iClip;
mPlayer->current = iId;
}
}
void Client_AmmoX(void* mValue){
static int iAmmo;
switch (mState++){
case 0:
iAmmo = *(int*)mValue;
break;
case 1:
if (!mPlayer ) break;
for(int i = 1; i < MAX_WEAPONS ; ++i)
if (iAmmo == weaponData[i].ammoSlot)
mPlayer->weapons[i].ammo = *(int*)mValue;
}
}
void Client_AmmoPickup(void* mValue){
static int iSlot;
switch (mState++){
case 0:
iSlot = *(int*)mValue;
break;
case 1:
if (!mPlayer ) break;
for(int i = 1; i < MAX_WEAPONS ; ++i)
if (weaponData[i].ammoSlot == iSlot)
mPlayer->weapons[i].ammo += *(int*)mValue;
}
}
void Client_ScoreInfo(void* mValue){
static int index;
switch (mState++){
case 0:
index = *(int*)mValue;
break;
case 4:
if ( index > 0 && index <= gpGlobals->maxClients )
GET_PLAYER_POINTER_I( index )->teamId = *(int*)mValue;
}
}
void Client_SendAudio(void* mValue){
static const char* szText;
if ( mState == 1 ){
szText = (const char*)mValue;
if ( !mPlayer && szText[7]=='B' ) {
if ( szText[11]=='P' && g_Planter )
GET_PLAYER_POINTER_I(g_Planter)->saveBPlant();
else if ( szText[11]=='D' && g_Defuser )
GET_PLAYER_POINTER_I(g_Defuser)->saveBDefused();
}
}
mState++;
}
void Client_TextMsg(void* mValue){
static const char* szText;
if ( !mPlayer && mState==1 ){
szText = (const char*)mValue;
if ( szText[1]=='T' && szText[8]=='B' && g_Planter )
GET_PLAYER_POINTER_I(g_Planter)->saveBExplode();
}
mState++;
}
void Client_BarTime(void* mValue){
int iTime = *(int*)mValue;
if ( !iTime || !mPlayer->IsAlive() ) return;
if ( iTime == 3 ){
g_Planter = mPlayerIndex;
g_Defuser = 0;
}
else {
mPlayer->saveBDefusing();
g_Defuser = mPlayerIndex;
}
}

View File

@ -1,14 +1,14 @@
#(C)2004-2005 AMX Mod X Development Team #(C)2004-2005 AMX Mod X Development Team
# Makefile written by David "BAILOPAN" Anderson # Makefile written by David "BAILOPAN" Anderson
HLSDK = ../hlsdk/SourceCode HLSDK = ../../../hlsdk
MM_ROOT = ../metamod/metamod MM_ROOT = ../../metamod/metamod
### EDIT BELOW FOR OTHER PROJECTS ### ### EDIT BELOW FOR OTHER PROJECTS ###
OPT_FLAGS = -O2 -funroll-loops -s -pipe -fomit-frame-pointer OPT_FLAGS = -O2 -funroll-loops -s -pipe -fomit-frame-pointer -fno-strict-aliasing
DEBUG_FLAGS = -g -ggdb3 DEBUG_FLAGS = -g -ggdb3
CPP = gcc CPP = gcc-4.1
NAME = cstrike NAME = cstrike
BIN_SUFFIX_32 = amxx_i386.so BIN_SUFFIX_32 = amxx_i386.so
@ -21,6 +21,12 @@ LINK =
INCLUDE = -I. -I$(HLSDK) -I$(HLSDK)/dlls -I$(HLSDK)/engine -I$(HLSDK)/game_shared -I$(HLSDK)/game_shared \ INCLUDE = -I. -I$(HLSDK) -I$(HLSDK)/dlls -I$(HLSDK)/engine -I$(HLSDK)/game_shared -I$(HLSDK)/game_shared \
-I$(MM_ROOT) -I$(HLSDK)/common -I$(MM_ROOT) -I$(HLSDK)/common
GCC_VERSION := $(shell $(CPP) -dumpversion >&1 | cut -b1)
ifeq "$(GCC_VERSION)" "4"
OPT_FLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
endif
ifeq "$(DEBUG)" "true" ifeq "$(DEBUG)" "true"
BIN_DIR = Debug BIN_DIR = Debug
CFLAGS = $(DEBUG_FLAGS) CFLAGS = $(DEBUG_FLAGS)
@ -29,7 +35,7 @@ else
CFLAGS = $(OPT_FLAGS) CFLAGS = $(OPT_FLAGS)
endif endif
CFLAGS += -DNDEBUG -fPIC -Wno-deprecated -fno-exceptions -DHAVE_STDINT_H -fno-rtti -static-libgcc CFLAGS += -DNDEBUG -fPIC -Wall -Wno-non-virtual-dtor -Werror -fno-exceptions -DHAVE_STDINT_H -fno-rtti -static-libgcc
ifeq "$(AMD64)" "true" ifeq "$(AMD64)" "true"
BINARY = $(NAME)_$(BIN_SUFFIX_64) BINARY = $(NAME)_$(BIN_SUFFIX_64)

View File

@ -2773,7 +2773,7 @@ void ValidateMacros_DontCallThis_Smiley()
MF_FindLibrary(NULL, LibType_Class); MF_FindLibrary(NULL, LibType_Class);
MF_AddLibraries(NULL, LibType_Class, NULL); MF_AddLibraries(NULL, LibType_Class, NULL);
MF_RemoveLibraries(NULL); MF_RemoveLibraries(NULL);
MF_OverrideNatives(NULL); MF_OverrideNatives(NULL, "");
} }
#endif #endif

View File

@ -22,7 +22,7 @@
#ifndef __linux__ #ifndef __linux__
#define DLLEXPORT __declspec(dllexport) #define DLLEXPORT __declspec(dllexport)
#else #else
#define DLLEXPORT #define DLLEXPORT __attribute__((visibility("default")))
#define LINUX #define LINUX
#endif #endif
@ -2179,8 +2179,10 @@ typedef void (*PFN_UNREG_AUTH_FUNC) (AUTHORIZEFUNC);
typedef int (*PFN_FINDLIBRARY) (const char * /*name*/, LibType /*type*/); typedef int (*PFN_FINDLIBRARY) (const char * /*name*/, LibType /*type*/);
typedef size_t (*PFN_ADDLIBRARIES) (const char * /*name*/, LibType /*type*/, void * /*parent*/); typedef size_t (*PFN_ADDLIBRARIES) (const char * /*name*/, LibType /*type*/, void * /*parent*/);
typedef size_t (*PFN_REMOVELIBRARIES) (void * /*parent*/); typedef size_t (*PFN_REMOVELIBRARIES) (void * /*parent*/);
typedef void (*PFN_OVERRIDENATIVES) (AMX_NATIVE_INFO * /*natives*/); typedef void (*PFN_OVERRIDENATIVES) (AMX_NATIVE_INFO * /*natives*/, const char * /*myname*/);
typedef const char * (*PFN_GETLOCALINFO) (const char * /*name*/, const char * /*def*/); typedef const char * (*PFN_GETLOCALINFO) (const char * /*name*/, const char * /*def*/);
typedef int (*PFN_AMX_REREGISTER) (AMX * /*amx*/, AMX_NATIVE_INFO * /*list*/, int /*list*/);
typedef void * (*PFN_REGISTERFUNCTIONEX) (void * /*pfn*/, const char * /*desc*/);
extern PFN_ADD_NATIVES g_fn_AddNatives; extern PFN_ADD_NATIVES g_fn_AddNatives;
extern PFN_BUILD_PATHNAME g_fn_BuildPathname; extern PFN_BUILD_PATHNAME g_fn_BuildPathname;
@ -2253,6 +2255,8 @@ extern PFN_ADDLIBRARIES g_fn_AddLibraries;
extern PFN_REMOVELIBRARIES g_fn_RemoveLibraries; extern PFN_REMOVELIBRARIES g_fn_RemoveLibraries;
extern PFN_OVERRIDENATIVES g_fn_OverrideNatives; extern PFN_OVERRIDENATIVES g_fn_OverrideNatives;
extern PFN_GETLOCALINFO g_fn_GetLocalInfo; extern PFN_GETLOCALINFO g_fn_GetLocalInfo;
extern PFN_AMX_REREGISTER g_fn_AmxReRegister;
extern PFN_REGISTERFUNCTIONEX g_fn_RegisterFunctionEx;
#ifdef MAY_NEVER_BE_DEFINED #ifdef MAY_NEVER_BE_DEFINED
// Function prototypes for intellisense and similar systems // Function prototypes for intellisense and similar systems
@ -2320,8 +2324,10 @@ void MF_UnregAuthFunc (AUTHORIZEFUNC fn) { }
int MF_FindLibrary (const char *name, LibType type) { } int MF_FindLibrary (const char *name, LibType type) { }
size_t MF_AddLibraries (const char *name, LibType type, void *parent) { } size_t MF_AddLibraries (const char *name, LibType type, void *parent) { }
size_t MF_RemoveLibraries (void *parent) { } size_t MF_RemoveLibraries (void *parent) { }
void MF_OverrideNatives (AMX_NATIVE_INFO *natives) { } void MF_OverrideNatives (AMX_NATIVE_INFO *natives, const char *myname) { }
const char * MF_GetLocalInfo (const char *name, const char *def) { } const char * MF_GetLocalInfo (const char *name, const char *def) { }
int MF_AmxReRegister (AMX *amx, AMX_NATIVE_INFO *list, int number) { return 0; }
void * MF_RegisterFunctionEx (void *pfn, const char *description) { }
#endif // MAY_NEVER_BE_DEFINED #endif // MAY_NEVER_BE_DEFINED
#define MF_AddNatives g_fn_AddNatives #define MF_AddNatives g_fn_AddNatives
@ -2396,6 +2402,8 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RemoveLibraries g_fn_RemoveLibraries #define MF_RemoveLibraries g_fn_RemoveLibraries
#define MF_OverrideNatives g_fn_OverrideNatives #define MF_OverrideNatives g_fn_OverrideNatives
#define MF_GetLocalInfo g_fn_GetLocalInfo #define MF_GetLocalInfo g_fn_GetLocalInfo
#define MF_AmxReRegister g_fn_AmxReRegister
#define MF_RegisterFunctionEx g_fn_RegisterFunctionEx
#ifdef MEMORY_TEST #ifdef MEMORY_TEST
/*** Memory ***/ /*** Memory ***/

View File

@ -218,40 +218,58 @@ static cell AMX_NATIVE_CALL cs_set_weapon_silenced(AMX *amx, cell *params) // cs
// Make into edict pointer // Make into edict pointer
edict_t *pWeapon = INDEXENT(params[1]); edict_t *pWeapon = INDEXENT(params[1]);
bool draw_animation = true;
if ((params[0] / sizeof(cell)) >= 3)
{
draw_animation = params[3] ? true : false;
}
int weapontype = (int)*((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE); int weapontype = (int)*((int *)pWeapon->pvPrivateData + OFFSET_WEAPONTYPE);
int *silencemode = ((int *)pWeapon->pvPrivateData + OFFSET_SILENCER_FIREMODE); int *silencemode = ((int *)pWeapon->pvPrivateData + OFFSET_SILENCER_FIREMODE);
switch (weapontype) { switch (weapontype)
{
case CSW_M4A1: case CSW_M4A1:
if (params[2] == 1) { if (params[2] == 1)
if (!(*silencemode & M4A1_SILENCED)) { // want to silence - can't already be silenced {
if (!(*silencemode & M4A1_SILENCED))
{ // want to silence - can't already be silenced
*silencemode |= M4A1_SILENCED; *silencemode |= M4A1_SILENCED;
// If this weapon has an owner that is a player, play animation for that player. // If this weapon has an owner that is a player, play animation for that player.
if (UTIL_IsPlayer(amx, pWeapon->v.owner)) if (draw_animation && UTIL_IsPlayer(amx, pWeapon->v.owner))
{
pWeapon->v.owner->v.weaponanim = M4A1_ATTACHSILENCEANIM; pWeapon->v.owner->v.weaponanim = M4A1_ATTACHSILENCEANIM;
}
} }
} } else if (*silencemode & M4A1_SILENCED) { // want to unsilence - can't already be unsilenced
else if (*silencemode & M4A1_SILENCED) { // want to unsilence - can't already be unsilenced
*silencemode &= ~M4A1_SILENCED; *silencemode &= ~M4A1_SILENCED;
// If this weapon has an owner that is a player, play animation for that player. // If this weapon has an owner that is a player, play animation for that player.
if (UTIL_IsPlayer(amx, pWeapon->v.owner)) if (draw_animation && UTIL_IsPlayer(amx, pWeapon->v.owner))
{
pWeapon->v.owner->v.weaponanim = M4A1_DETACHSILENCEANIM; pWeapon->v.owner->v.weaponanim = M4A1_DETACHSILENCEANIM;
}
} }
break; break;
case CSW_USP: case CSW_USP:
if (params[2] == 1) { if (params[2] == 1)
if (!(*silencemode & USP_SILENCED)) { // want to silence - can't already be silenced {
if (!(*silencemode & USP_SILENCED))
{ // want to silence - can't already be silenced
*silencemode |= USP_SILENCED; *silencemode |= USP_SILENCED;
// If this weapon has an owner that is a player, play animation for that player. // If this weapon has an owner that is a player, play animation for that player.
if (UTIL_IsPlayer(amx, pWeapon->v.owner)) if (draw_animation && UTIL_IsPlayer(amx, pWeapon->v.owner))
{
pWeapon->v.owner->v.weaponanim = USP_ATTACHSILENCEANIM; pWeapon->v.owner->v.weaponanim = USP_ATTACHSILENCEANIM;
}
} }
} } else if (*silencemode & USP_SILENCED) { // want to unsilence - can't already be unsilenced
else if (*silencemode & USP_SILENCED) { // want to unsilence - can't already be unsilenced
*silencemode &= ~USP_SILENCED; *silencemode &= ~USP_SILENCED;
// If this weapon has an owner that is a player, play animation for that player. // If this weapon has an owner that is a player, play animation for that player.
if (UTIL_IsPlayer(amx, pWeapon->v.owner)) if (draw_animation && UTIL_IsPlayer(amx, pWeapon->v.owner))
{
pWeapon->v.owner->v.weaponanim = USP_DETACHSILENCEANIM; pWeapon->v.owner->v.weaponanim = USP_DETACHSILENCEANIM;
}
} }
break; break;
default: default:
@ -471,8 +489,8 @@ static cell AMX_NATIVE_CALL cs_set_user_vip(AMX *amx, cell *params) // cs_set_us
if (updateModel) if (updateModel)
{ {
// Set a random CT model. // Set a random CT model.
CS_Internal_Models CTmodels[4] = {CS_CT_URBAN, CS_CT_GSG9, CS_CT_GIGN, CS_CT_SAS}; CS_Internal_Models CTmodels[5] = {CS_CT_URBAN, CS_CT_GSG9, CS_CT_GIGN, CS_CT_SAS, CZ_CT_SPETSNAZ};
CS_Internal_Models ct_model = CTmodels[RANDOM_LONG(0, 3)]; CS_Internal_Models ct_model = CTmodels[RANDOM_LONG(0, 4)];
*((int *)pPlayer->pvPrivateData + OFFSET_INTERNALMODEL) = ct_model; *((int *)pPlayer->pvPrivateData + OFFSET_INTERNALMODEL) = ct_model;
// This makes the model get updated right away. // This makes the model get updated right away.
MDLL_ClientUserInfoChanged(pPlayer, GETINFOKEYBUFFER(pPlayer)); // If this causes any problems for WON, do this line only in STEAM builds. MDLL_ClientUserInfoChanged(pPlayer, GETINFOKEYBUFFER(pPlayer)); // If this causes any problems for WON, do this line only in STEAM builds.
@ -504,11 +522,18 @@ static cell AMX_NATIVE_CALL cs_get_user_team(AMX *amx, cell *params) // cs_get_u
// params[1] = user index // params[1] = user index
// Valid entity should be within range // Valid entity should be within range
cell *model;
CHECK_PLAYER(params[1]); CHECK_PLAYER(params[1]);
// Make into edict pointer // Make into edict pointer
edict_t *pPlayer = MF_GetPlayerEdict(params[1]); edict_t *pPlayer = MF_GetPlayerEdict(params[1]);
if ((params[0] / sizeof(cell)) >= 2)
{
model = MF_GetAmxAddr(amx, params[2]);
*model = *((int *)pPlayer->pvPrivateData + OFFSET_INTERNALMODEL);
}
return *((int *)pPlayer->pvPrivateData + OFFSET_TEAM); return *((int *)pPlayer->pvPrivateData + OFFSET_TEAM);
} }
@ -703,20 +728,27 @@ static cell AMX_NATIVE_CALL cs_set_user_defusekit(AMX *amx, cell *params) // cs_
int* defusekit = ((int *)pPlayer->pvPrivateData + OFFSET_DEFUSE_PLANT); int* defusekit = ((int *)pPlayer->pvPrivateData + OFFSET_DEFUSE_PLANT);
if (params[2]) { if (params[2])
{
int colour[3] = {DEFUSER_COLOUR_R, DEFUSER_COLOUR_G, DEFUSER_COLOUR_B}; int colour[3] = {DEFUSER_COLOUR_R, DEFUSER_COLOUR_G, DEFUSER_COLOUR_B};
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++)
{
if (params[i + 3] != -1) if (params[i + 3] != -1)
{
colour[i] = params[i + 3]; colour[i] = params[i + 3];
}
} }
pPlayer->v.body = 1;
char* icon; char* icon;
if (params[6] != -1) { if (params[6] != -1)
{
int len; int len;
icon = MF_GetAmxString(amx, params[6], 1, &len); icon = MF_GetAmxString(amx, params[6], 1, &len);
} } else {
else
icon = "defuser"; icon = "defuser";
}
*defusekit |= HAS_DEFUSE_KIT; *defusekit |= HAS_DEFUSE_KIT;
MESSAGE_BEGIN(MSG_ONE, GET_USER_MSG_ID(PLID, "StatusIcon", NULL), NULL, pPlayer); MESSAGE_BEGIN(MSG_ONE, GET_USER_MSG_ID(PLID, "StatusIcon", NULL), NULL, pPlayer);
@ -733,6 +765,7 @@ static cell AMX_NATIVE_CALL cs_set_user_defusekit(AMX *amx, cell *params) // cs_
WRITE_BYTE(0); // hide WRITE_BYTE(0); // hide
WRITE_STRING("defuser"); WRITE_STRING("defuser");
MESSAGE_END(); MESSAGE_END();
pPlayer->v.body = 0;
} }
/* /*

View File

@ -260,7 +260,9 @@ enum CS_Internal_Models {
CS_CT_GIGN = 6, CS_CT_GIGN = 6,
CS_CT_SAS = 7, CS_CT_SAS = 7,
CS_T_GUERILLA = 8, CS_T_GUERILLA = 8,
CS_CT_VIP = 9 CS_CT_VIP = 9,
CZ_T_MILITIA = 10,
CZ_CT_SPETSNAZ = 11
}; };
enum enum

View File

@ -215,7 +215,7 @@
</File> </File>
</Filter> </Filter>
<File <File
RelativePath="..\plugins\include\cstrike.inc"> RelativePath="..\..\plugins\include\cstrike.inc">
</File> </File>
</Files> </Files>
<Globals> <Globals>

Some files were not shown because too many files have changed in this diff Show More