Yesterday while speaking to Sigsegv about some projectile entity-related topics, I asked if he could help me with a modification I wanted to make to SourceMod, specifically to how sm_dump_datamaps works.
Currently, you specify the filename that all the datamaps for every entity in the game will be dumped into, and the command just dumps everything into that file. That's a bit messy, and it also makes it harder for me to find information on just a specific entity. What I usually ended up doing was highlighting from the entity name
(for example "CPhysBox - func_physbox") all the way down to "- m_nModelIndexOverrides (Offset 124) (Save)(16 Bytes)" which
(I only know this is true in TF2's datamaps) is
always the very last map entry for an entity. I then move that highlighted entity map to a new document so I can easily CTRL+F and find things.
My idea was to instead have the command create a "datamaps" folder within the "tf/" folder and then individually create .TXT files for each entity and its map, for example "tf/datamaps/CTFPlayer - player.txt". However, I am no genius with C++. I personally find it much harder to learn than SourcePawn, even after my surprisingly quick adjustment to the new 1.8 SourcePawn syntax which is much more like C++ than the old syntax.
So after using a text crawler to find out that the
vhelper.cpp file (these lines specifically) is what contains the entirety of the sm_dump_datamaps command, I discovered I wasn't learned enough to figure out how to modify it to make it work how I wanted it to. Sigsegv came through however:
Here's the diff of the changes he made. And here's the
modified vhelpers.cpp file.
Sigsegv was nice enough to build me a TF2-specific copy that I could test-run on my test server to see if it dumped the files correctly, as for some reason whenever I build a copy of the sdktools extension, it loses its link to libtier0 and libvstdlib and refuses to load ingame, citing "unknown symbol: Warning".
And it definitely does work! So here's the suggestion. Instead of just outright overwriting sm_dump_datamaps to make it dump all the files individually, let's keep sm_dump_datamaps as it is, and add this new command in as "sm_dump_datamaps_sorted"
(no args needed, unless there's a want/need to have an arg to specify a custom directory)
As well, the same could be done for sm_dump_netprops/any other dump commands that currently just dump information on multiple entities into one file, so they also have a "_sorted" command as well. I believe this would be very useful for developers, especially anyone wanting to work with entities who would like to find out what entity datamaps they can utilize.
Note: Sigsegv has given me permission to post this, though he did tell me I should not imply that the modification he made is a "polished finished product". It does work though, as stated above.
Discuss away?