Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Rewrite keyvalue handling #5

Open
Admer456 opened this issue Oct 13, 2020 · 0 comments
Open

Rewrite keyvalue handling #5

Admer456 opened this issue Oct 13, 2020 · 0 comments
Labels
cleanup This issue is requesting a refactor/cleanup/tidyup improvement This issue is requesting an improvement or a change priority-2 Medium priority, should be fixed sometime
Milestone

Comments

@Admer456
Copy link
Owner

Keyvalue handling is not so nice in HL SDK, and while it's a bit faster to write in ADM, that brought a new "not so nice" thing.
Simply put, look at this: https://github.com/Admer456/halflife-ADM/blob/master/dlls/ADM/AdmGetSetKV.cpp
:(

Other than that, handling keyvalues in a manual fashion is fairly repetitive.

void SomeEntity::KeyValue( KeyValueData* pkvd )
{
   if ( KeyvalueToken( myKeyvalue ) )
   {
      KeyvalueToInt( myMember );
   }
   else
      KeyvaluesFromBase( CBaseEntity );
}

What should be done is a system similar to the save-restore system. Each entity class can have a static array of keyvalue elements, where keyvalue elements are basically pairs of strings and byte offsets. In implementation, they're a bit more than that, because you have to specify the data type too.

It'll eventually look something like this:

KeyValueElement MyEntity::keyValues[] =
{
   KV_Define( mykeyvalue, Int ),
   KV_DefineCustom( mykeyvalue2, Float );
};
@Admer456 Admer456 added enhancement priority-2 Medium priority, should be fixed sometime labels Oct 13, 2020
@Admer456 Admer456 added this to the v0.3.0 milestone Oct 13, 2020
@Admer456 Admer456 added cleanup This issue is requesting a refactor/cleanup/tidyup improvement This issue is requesting an improvement or a change and removed enhancement labels Oct 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cleanup This issue is requesting a refactor/cleanup/tidyup improvement This issue is requesting an improvement or a change priority-2 Medium priority, should be fixed sometime
Projects
None yet
Development

No branches or pull requests

1 participant