alliedmodders/metamod-source

Inaccurate interpretation of SE codes

Classes123 opened this issue · 1 comments

While looking at the source code, I noticed that metamod translates SE codes (that are given in the manifests) into its own codes, which it then uses.

int SourceProvider::DetermineSourceEngine()
{
#if SOURCE_ENGINE == SE_BLOODYGOODTIME
return SOURCE_ENGINE_BLOODYGOODTIME;
#elif SOURCE_ENGINE == SE_ALIENSWARM
return SOURCE_ENGINE_ALIENSWARM;
#elif SOURCE_ENGINE == SE_LEFT4DEAD2
return SOURCE_ENGINE_LEFT4DEAD2;
#elif SOURCE_ENGINE == SE_NUCLEARDAWN
return SOURCE_ENGINE_NUCLEARDAWN;
#elif SOURCE_ENGINE == SE_CONTAGION
return SOURCE_ENGINE_CONTAGION;
#elif SOURCE_ENGINE == SE_LEFT4DEAD
return SOURCE_ENGINE_LEFT4DEAD;
#elif SOURCE_ENGINE == SE_ORANGEBOX
return SOURCE_ENGINE_ORANGEBOX;
#elif SOURCE_ENGINE == SE_CSS
return SOURCE_ENGINE_CSS;
#elif SOURCE_ENGINE == SE_HL2DM
return SOURCE_ENGINE_HL2DM;
#elif SOURCE_ENGINE == SE_DODS
return SOURCE_ENGINE_DODS;
#elif SOURCE_ENGINE == SE_SDK2013
return SOURCE_ENGINE_SDK2013;
#elif SOURCE_ENGINE == SE_TF2
return SOURCE_ENGINE_TF2;
#elif SOURCE_ENGINE == SE_DARKMESSIAH
return SOURCE_ENGINE_DARKMESSIAH;
#elif SOURCE_ENGINE == SE_EYE
return SOURCE_ENGINE_EYE;
#elif SOURCE_ENGINE == SE_PORTAL2
return SOURCE_ENGINE_PORTAL2;
#elif SOURCE_ENGINE == SE_BLADE
return SOURCE_ENGINE_BLADE;
#elif SOURCE_ENGINE == SE_INSURGENCY
return SOURCE_ENGINE_INSURGENCY;
#elif SOURCE_ENGINE == SE_DOI
return SOURCE_ENGINE_DOI;
#elif SOURCE_ENGINE == SE_CSGO
return SOURCE_ENGINE_CSGO;
#elif SOURCE_ENGINE == SE_BMS
return SOURCE_ENGINE_BMS;
#elif SOURCE_ENGINE == SE_EPISODEONE
return bOriginalEngine ? SOURCE_ENGINE_ORIGINAL : SOURCE_ENGINE_EPISODEONE;
#elif SOURCE_ENGINE == SE_MOCK
return SOURCE_ENGINE_MOCK;
#elif SOURCE_ENGINE == SE_PVKII
return SOURCE_ENGINE_PVKII;
#elif SOURCE_ENGINE == SE_MCV
return SOURCE_ENGINE_MCV;
#else
#error "SOURCE_ENGINE not defined to a known value"
#endif
}

This creates problems (for example, if we want to create our own loader inside the extension) that we then have to translate these codes back.

So we have 2 different interpretations of the SE code and every time we want to add new SDK support, we have to add new logic to our loader.
https://github.com/alliedmodders/sourcemod/blob/4e8b66bf998cc1b0d40afd49a14856fde6a2e773/loader/loader.cpp#L202-L360


Possible solution:

  1. Move the loader logic from sourcemod to the upper level (metamod).
  2. Metamod sends the information itself: sdk suffix, major version, architecture, etc. (so that we can quickly get the module name: myext.<major_version>.<sdk_suffix>.<architecture>.<platform_ext>).

What will it give?

  1. (Theoretically) Adds module loading depending on the SDK (the way sourcemod does it).
  2. You will not need a deeper analysis in custom loaders.

Sending sdk suffix is a good idea. Architecture is implied in the build and the only major version is "6", so suffix is all you need. MM:S could even send the entire suffix string "6.whatever.arch.dll"