[INCLUDE] AutoExecConfig: Read and append to auto configs
What is this?
In short, this provides the missing functionality to update your autoconfig if you add new convars to your plugins. When i wrote this I've worked on a bigger project where convars were added very often and telling people to rewrite their configs made me hesitant to add them. In times of plugins like the updater people expect to not have to add new convars by hand. The most important things i had in mind were security, performance, easy implementation and consistent files (white spaces, newlines) I've came up with a working but relatively slow solution with some limitations. How does it work? If you add a convar with the appropriate function it will be searched in the auto-config-file you have set before. If it can't be found within the file it will add it with the information you created the convar with. After that, the file can be cleaned from unnecessary white spaces created by the user or autoexecconfig itself. This is done purely for the viewer's pleasure and to conserve some bytes. The source / Download You can view the source and some more information on Github. Feel free to send pull requests, ideas, criticism or enhancements. Limitations Although most functions return something, some also multiple defined values/codes, you currently can't get the return of the parser/appender while adding a convar. This could be fixed with a by ref value, but i feel that, in some cases, it would make the command longer than it needs to be. As a workaround this can be retrieved directly after you created a convar with one of the AutoExecConfig_Get*Result functions. Notes This include requires a sourcemod compiler with version 1.7+, see here for more information. The prototype or name of some functions may be changed or even removed in later versions, but this will not cause compatibility issues with plugins. Convars with a FCVAR_DONTRECORD flag will be skipped by the appender. The parser will ignore spaces between convars and values, inside values or behind values for security. The search, by default, is case sensitive. The cleaner will format your file the way autoexecconfig does, 2 spaces after information, 1 after convars. The value of a convar must be quoted, otherwise the parser will not find it. Please let me know if you find a bug or have suggestions. Implementing Here is a basic example of the usage. Please also take a look at the include file and the test plugin for more functions. PHP Code:
|
Re: [INCLUDE] Autoexecconfig read and append beta
This is a really cool contribution, but it really should be a part of Core alongside AutoExecConfig.
|
Re: [INCLUDE] Autoexecconfig read and append beta
Thanks.
One of the bugs i referred to is this five year old one, maybe sometime it will be supported natively. Yours sincerely Impact |
Re: [INCLUDE] Autoexecconfig read and append beta
Just an little statusupdate here.
Cleaner now must be called by the developer, it was just too expensive to call it everytime a cvar was added, performance should be a lot better now. In addition to that change i added some defined return values to the function. Because you can't see the parser or appenderresults while adding a cvar i've added two functions to grab the results as an workaround for that. All functions which you can input an buffer to now safely terminate it even if the function fails. There now is a function with which you can get the formatted autoconfigfilepath if you need to. Also i've came to test it on linux, as i thought it works fine there too. Yours sincerely Impact |
Re: [INCLUDE] Autoexecconfig read and append beta
Interesting and useful idea! I would like to see that in future sourcemod releases. :up:
It looks nice (especially because I need only <include> file for working!) I'll give it a try to my future plugins! Thanks |
Re: [INCLUDE] Autoexecconfig read and append beta
SetFile looks only in cfg/sourcemod, but config files can also be only in the cfg folder!
When appending a new cvar, a long description get cut, don't know why. |
Re: [INCLUDE] Autoexecconfig read and append beta
Nice find, i'll look into it and report back.
This must come from cleanfile, it's copybuffer is 128 in size, how long is your description? Yours sincerely Impact |
Re: [INCLUDE] Autoexecconfig read and append beta
Yes that could be^^ it have 154 symbols, but it breaks at 60^^
|
Re: [INCLUDE] Autoexecconfig read and append beta
I've made some changes to the file, tell me if this works out for you.
Raw changelog
Yours sincerely Impact |
Re: [INCLUDE] Autoexecconfig read and append beta
Updated my iBots plugin to use this - I missed this when you first posted it, but I'm glad I found it... thank you.
|
All times are GMT -4. The time now is 23:41. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.