AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Extensions (https://forums.alliedmods.net/forumdisplay.php?f=134)
-   -   [EXTENSION ALL] CTX editor (For anything/everything) (https://forums.alliedmods.net/showthread.php?t=161330)

Swixel 07-06-2011 02:09

[EXTENSION ALL] CTX editor (For anything/everything)
 
1 Attachment(s)
If upgrading from 1.0.0 or 1.0.1, remove the old gamedata before updating.

Licence

This extension, and the include, are licenced under AGPLv3. Anything attached to it must also be AGPLv3. This means that if anyone asks for your source code, you must provide it free of charge.

Why am I doing this? To help the community that helps you.

What is this?
This iteration of CTX replaces both CSS and TF2, adding support for any other source game which uses a weapon database (for weapons), and/or a function to call pointers to playerdata (anything) in one team type (e.g. TF2) or two (e.g. DOD:S), and/or a function to call pointers from an auxiliary database (defined as 'objects'), like in TF2.

Gamedata
  • ctx.all.txt - required by everything;
  • ctx.games.txt - handles ctx/ctx.<gamedir>.txt selection
  • ctx/<gamedir>.txt - gamedata on a per-game basis.

Natives
Replacing the large bank of natives, I've supplied the following in ctx.inc:
  • native bool:CTX_Reset(CTX_TYPE, String:strClassName[]);
  • native bool:CTX_ResetAll(CTX_TYPE);
  • native bool:CTX_SetBool(CTX_TYPE, String:Variable[], String:strClassName[], bool:NewValue);
  • native bool:CTX_GetBool(CTX_TYPE, String:Variable[], String:strClassName[], &bool:ReturnedBool);
  • native bool:CTX_SetFloat(CTX_TYPE, String:Variable[], String:strClassName[], Float:NewValue);
  • native bool:CTX_GetFloat(CTX_TYPE, String:Variable[], String:strClassName[], &Float:ReturnedFloat);
  • native bool:CTX_SetInt(CTX_TYPE, String:Variable[], String:strClassName[], NewValue);
  • native bool:CTX_GetInt(CTX_TYPE, String:Variable[], String:strClassName[], &ReturnedInt);
  • native bool:CTX_SetString(CTX_TYPE, String:Variable[], String:strClassName[], String:NewValue[]);
  • native bool:CTX_GetString(CTX_TYPE, String:Variable[], String:strClassName[], String:ReturnBuffer[]);
  • native bool:CTX_SetStringPtr(CTX_TYPE, String:Variable[], String:strClassName[], String:NewValue[]);
  • native bool:CTX_GetStringPtr(CTX_TYPE, String:Variable[], String:strClassName[], String:ReturnBuffer[]);
Everything is returned with a buffer to guard against false positives and to allow you to check for errors in your plugins.


Notes:
  • The 'bool' return on get will return a float or int if you request them, and the return string buffer may be undefined if you are not getting a string;
  • All input values are strings, so all floats are written like "0.1", all integers as "512", and all booleans are "0" or "1".

FYI
warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
I know, and don't care at the moment.

Tested/Untested
Testing has only been done for TF2.

Windows has been tested, Linux is untested (let me know is there are problems, but there shouldn't be). Objects aren't tested in TF2, but they should be fine (I'm only worried about char *, but there's no reason it should break).

Thanks to:
BAILOPAN/dvander, VoiDeD, asherkin - for helping me with alloc problems (that turned out not to be it);
Wazz - for starting all of this madness a year ago.
KyleS - for helping me work out the weird CS:S issues.

Changes

  • 1.0.2
    • Split natives by supported type.
    • Added proper gamedata support with ctx.games.txt.
  • 1.0.1
    • Corrected an error left from a fork in development (checking for NULL instead of doing strlen).
      • This should correct the 'crash on load' that happens for CS:S and DOD:S when objects (or players, for CS:S) aren't enabled. This should also block a much later error if you try to poke data that doesn't exist.

TODO
Manual pawn registration for datafiles, so that you can use custom class data (not urgent, not pressing, etc.)

Source and everything (except binaries)
https://bitbucket.org/aws/ctx

Attached
Binaries for SourceMod 1.3 and MM:S 1.8 (ctx.ext.so and ctx.ext.dll), as well as the include, a very simple sample for TF2, and gamedata for TF2, CS:S, and DOD:S (ctx.zip).

KyleS 07-06-2011 02:10

Re: [EXTENSION ALL] CTX editor (For anything/everything)
 
Very cool, thanks!

GoD-Tony 07-06-2011 07:03

Re: [EXTENSION ALL] CTX editor (For anything/everything)
 
Seems to be crashing on load for my Windows/CS:S server. Same result with a late load.

KyleS 07-06-2011 07:10

Re: [EXTENSION ALL] CTX editor (For anything/everything)
 
Quote:

Originally Posted by GoD-Tony (Post 1504816)
Seems to be crashing on load for my Windows/CS:S server. Same result with a late load.

Only tested with Lateload, same result on Linux as well.

Code:

#0  0xee3fc268 in CTXPatcher::SDK_OnLoad(char*, unsigned int, bool) ()
  from /home/kyle/SRCDS/orangebox/cstrike/addons/sourcemod/extensions/ctx.ext.so
#1  0xee3f9bcf in SDKExtension::OnExtensionLoad(SourceMod::IExtension*, SourceMod::IShareSys*, char*, unsigned int, bool) ()
  from /home/kyle/SRCDS/orangebox/cstrike/addons/sourcemod/extensions/ctx.ext.so
#2  0xefa2d096 in CExtension::Load(char*, unsigned int) ()
  from /home/kyle/SRCDS/orangebox/cstrike/addons/sourcemod/bin/sourcemod.2.ep2v.so
#3  0xefa2d944 in CLocalExtension::Load(char*, unsigned int) ()
  from /home/kyle/SRCDS/orangebox/cstrike/addons/sourcemod/bin/sourcemod.2.ep2v.so
#4  0xefa2fc2c in CExtensionManager::LoadExtension(char const*, char*, unsigned int) ()
  from /home/kyle/SRCDS/orangebox/cstrike/addons/sourcemod/bin/sourcemod.2.ep2v.so
#5  0xefa2fc9a in CExtensionManager::LoadExtension(char const*, char*, unsigned int) ()
  from /home/kyle/SRCDS/orangebox/cstrike/addons/sourcemod/bin/sourcemod.2.ep2v.so
#6  0xefa2e29a in CExtensionManager::OnRootConsoleCommand(char const*, CCommand const&) ()
---Type <return> to continue, or q <return> to quit---
  from /home/kyle/SRCDS/orangebox/cstrike/addons/sourcemod/bin/sourcemod.2.ep2v.so
#7  0xefa9c715 in sm(CCommand const&) ()
  from /home/kyle/SRCDS/orangebox/cstrike/addons/sourcemod/bin/sourcemod.2.ep2v.so
#8  0xf6bcb122 in Cmd_Dispatch(ConCommandBase const*, CCommand const&) ()
  from /home/kyle/SRCDS/orangebox/bin/engine.so
#9  0xf6bcced1 in T.1735 () from /home/kyle/SRCDS/orangebox/bin/engine.so
#10 0xf6bcd452 in Cbuf_Execute() ()
  from /home/kyle/SRCDS/orangebox/bin/engine.so
#11 0xf6c3acd0 in _Host_RunFrame(float) ()
  from /home/kyle/SRCDS/orangebox/bin/engine.so
#12 0xf6c44295 in CHostState::State_Run(float) ()
  from /home/kyle/SRCDS/orangebox/bin/engine.so
#13 0xf6c44ac1 in CHostState::FrameUpdate(float) ()
  from /home/kyle/SRCDS/orangebox/bin/engine.so
#14 0xf6c44cc8 in HostState_Frame(float) ()
  from /home/kyle/SRCDS/orangebox/bin/engine.so
#15 0xf6cf7df4 in CEngine::Frame() ()
  from /home/kyle/SRCDS/orangebox/bin/engine.so
#16 0xf6cf4639 in CDedicatedServerAPI::RunFrame() ()
  from /home/kyle/SRCDS/orangebox/bin/engine.so
#17 0xf6fd4a20 in ?? ()
---Type <return> to continue, or q <return> to quit---
#18 0xf6fd4777 in ?? ()
#19 0xf6cf4c5b in CModAppSystemGroup::Main() ()
  from /home/kyle/SRCDS/orangebox/bin/engine.so
#20 0xf6d0d9a1 in CAppSystemGroup::Run() ()
  from /home/kyle/SRCDS/orangebox/bin/engine.so
#21 0xf6cf5c0a in CDedicatedServerAPI::ModInit(ModInfo_t&) ()
  from /home/kyle/SRCDS/orangebox/bin/engine.so
#22 0xf6fd4c23 in ?? ()
#23 0xf6fd8471 in ?? ()
#24 0xf6fd9ced in ?? ()
#25 0xf6fd8471 in ?? ()
#26 0xf6fd503a in ?? ()
#27 0xf6fd632f in ?? ()
#28 0x080488ec in main ()


Swixel 07-06-2011 07:36

Re: [EXTENSION ALL] CTX editor (For anything/everything)
 
Quote:

Originally Posted by GoD-Tony (Post 1504816)
Seems to be crashing on load for my Windows/CS:S server. Same result with a late load.

I think I've resolved the issue, but it'll be a while before I can test CS:S, attaching latest binaries to the main post now ...

Chrisber 07-06-2011 07:42

Re: [EXTENSION ALL] CTX editor (For anything/everything)
 
Hey, what is this extension for? Never heard of the word "CTX" :D

Swixel 07-06-2011 07:44

Re: [EXTENSION ALL] CTX editor (For anything/everything)
 
Quote:

Originally Posted by Chrisber (Post 1504838)
Hey, what is this extension for? Never heard of the word "CTX" :D

Data files used to be stored in 'ctx' files (now many are just .txt). These files are cached by the server on load, so you can only make changes before you start the server up (i.e. changing requires a restart).

This data is stored in a CUtlDict<structOrClass*, unsigned short>. This ext basically just grabs the pointers and lets you manipulate them, after making backups ;)

GoD-Tony 07-06-2011 08:06

Re: [EXTENSION ALL] CTX editor (For anything/everything)
 
Quote:

Originally Posted by Swixel (Post 1504835)
I think I've resolved the issue, but it'll be a while before I can test CS:S, attaching latest binaries to the main post now ...

Working great now, nice one! :)

In case anyone else was wondering; setting the maxspeed in CS:S works with this extension:
Code:
CTX_Get(CTX_WEAPON, CTX_FLOAT, "maxplayerspeed", "weapon_knife") CTX_Set(CTX_WEAPON, CTX_FLOAT, "maxplayerspeed", "weapon_knife", "400.0");

Now I'll try to get it to only apply to specific clients (if possible). Edit: Doesn't seem possible.

KyleS 07-06-2011 11:36

Re: [EXTENSION ALL] CTX editor (For anything/everything)
 
2 Attachment(s)
Code:

Program received signal SIGSEGV, Segmentation fault.
0xeef82eef in RestoreSet(CUtlDict<void*, unsigned short>*, CUtlDict<void*, unsigned short>*, int, int, unsigned int) ()
  from /home/kyle/SRCDS/orangebox/cstrike/addons/sourcemod/extensions/ctx.ext.so
(gdb) backtrace
#0  0xeef82eef in RestoreSet(CUtlDict<void*, unsigned short>*, CUtlDict<void*, unsigned short>*, int, int, unsigned int) ()
  from /home/kyle/SRCDS/orangebox/cstrike/addons/sourcemod/extensions/ctx.ext.so
#1  0xeef830b5 in CTX_ResetAll(SourcePawn::IPluginContext*, int const*) () from /home/kyle/SRCDS/orangebox/cstrike/addons/sourcemod/extensions/ctx.ext.so
#2  0xef850c87 in NativeCallback(sp_context_s*, unsigned int, int*) () from /home/kyle/SRCDS/orangebox/cstrike/addons/sourcemod/bin/sourcepawn.jit.x86.so
#3  0x082c3ebd in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

This sure hates CSS :P

I wrote the attached plugin and was planning on releasing it. However, the bools don't seem to fire correctly (they always return true, even when garbage is entered)? The natives throw silent errors (I'm at fault for not looking at the source), and the return on CTX_Get doesn't have a static type (and can create false positives if the value of the said CTX is 0, 0.0, or false). Could you always fill the ReturnString and just return true or false depending on it's action? :o

To reproduce the crash (easily), just load the attached plugin and type in sm_ctx_resettype CTX_Weapon or any one of the types.

Swixel 07-06-2011 18:06

Re: [EXTENSION ALL] CTX editor (For anything/everything)
 
Quote:

Originally Posted by KyleS (Post 1504965)
Could you always fill the ReturnString and just return true or false depending on it's action? :o

UPDATE: Everything is returned in buffers to provide checks.

Things to take note of:
  • It's case sensitive for the variable and class (lower case for mine, whatever Valve uses for their code);
  • Constantly spamming it with a loop of things that don't exist will likely cause problems (don't).
The problem was that Kyle was trying to reset things not available (objects and players in CS:S).


All times are GMT -4. The time now is 18:23.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.