Not so fun facts about GoldSrc's version of Quake's ED_ParseEdict function:

1.

It first searches for classname key, and if it was found, immediately passes it to game DLL pfnKeyValue and after that uses the class name string from entvars_t::classname written by game DLL and NOT the actual value written in entities file. BECAUSE entities are exported as functions in DLL, it doesn't really allow scripting languages to add custom entities. This oversight (?) allowed scripting languages to replace the custom class name with something harmless like info_target to force the engine to create an entity. This is actually used in Custom Entities API for AMXModX by Hedgefog.


2.

However, VALVe knew that it might be not possible to export entity function and their solution was? Calling "custom" export in DLL and passing KeyValue to DLL with following parameters:

szClassName = "custom"
szKeyName = "customclass"
szValue = classname

The sad part is that it seemingly was undocumented and nobody ever used that engine feature.


3.

It has a hack to remove single trailing space in keys. Huh?


4.

It will not pass a KeyValue to a DLL if its value has the same value as the entity's class name. Do you think something missing here? Yes, it doesn't check for if the key is classname! It straight up rejects an entity pair that's value so happened to be an entity's class name.

The decompiled version from Ghidra: https://git.mentality.rip/a1batross/gist/src/branch/master/ed_parseedict.c