Closed zig-for closed 9 years ago
eeeem, there is another way to check it, if engine uses new api (not syscalls ) then its ojk, if it use syscalls then jamp.
What other api? How can I check for it?
Context: I'm running in mod code, linked to the original engine.
if you are querying modification using vmMain function ( cg/g_main.c ) then, it uses legacy api ( jamp ) . if you are querying modification using GetModuleAPI function, then it uses new api (OpenJK ).
int enginetype = 0; /// Define it somewhere
Q_EXPORT gameExport_t* QDECL GetModuleAPI( int apiVersion, gameImport_t *import ) { //// If Module API ( OpenJK )
.....
.....
enginetype = 1; //OpenJK
}
(or)
Q_EXPORT intptr_t vmMain( int command, intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4,
intptr_t arg5, intptr_t arg6, intptr_t arg7, intptr_t arg8, intptr_t arg9, intptr_t arg10, intptr_t arg11 ) { /// If vmMain ( JaMP)
.....
.....
enginetype = 2; //JaMP
}
Just check the "version" cvar. If it's the same as baseJKA, then you know you're working with base.
Date: Sat, 3 Jan 2015 18:08:34 -0800 From: notifications@github.com To: OpenJK@noreply.github.com Subject: Re: [OpenJK] Add new syscalls to check for engine type (#608)
if you are querying modification using vmMain function ( cg/g_main.c ) then, it uses legacy api ( jamp ) . if you are querying modification using GetModuleAPI function, then it uses new api (OpenJK ).
int enginetype = 0; /// Define it somewhere
Q_EXPORT gameExport_t* QDECL GetModuleAPI( int apiVersion, gameImport_t *import ) { //// If Module API ( OpenJK ) ..... ..... enginetype = 1; //OpenJK }
(or)
Q_EXPORT intptr_t vmMain( int command, intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6, intptr_t arg7, intptr_t arg8, intptr_t arg9, intptr_t arg10, intptr_t arg11 ) { /// If vmMain ( JaMP) ..... ..... enginetype = 2; //JaMP }
— Reply to this email directly or view it on GitHub.
=
Basically what eezstreet said.
If dllEntry or vmMain are accessed, then its an older engine. Or if GetModuleAPI is accessed, then its OpenJK.
The newer API also has version numbers so you can bump those to change the API to add new func pointers.
Did not know about the version cvar, thanks. That is exactly what I wanted.
Can we make that say openJK?
No, for compatibility issues.
Instead of relying on the version cvar or an engine function that may or may not exist, it is more reliable to do a checksum of the engine in memory to know for sure that the code you're trying to patch is the same as base.
It was going to be in addition to checking some bytes in memory. What kind of compatibility problems would be caused by changing that cvar?
Some older tools like the all seeing eye break and you won't see servers if it doesn't say JAmp: v1.0.1.0
Can we tack on [OpenJK] at the end? that shouldn't break anything.
Why do you need it?
Check the year. As is done here: https://github.com/JACoders/OpenJK/blob/master/codemp/ui/ui_main.c#L4340-L4342
@A-t48 Can we close this issue now? I think the issue's been solved now.
Hi, Subaru here. In some cases (patching the engine at runtime, mainly) it is useful to know what engine we are running (mostly if it is retail or not, but there are other instances, too).
I'd like to add TRAP_GETENGINE and TRAP_GETENGINEVERSION to the list of syscalls, replacing TRAP_TESTPRINTFLOAT and TRAP_TESTPRINTINT which do nothing.
trap_GetEngine would return a const char* representing the engine name ("OpenJK" in this case, "jaMME" for jamme, something else for thoughtful people who fork and pay attention). On baseJKA if it is called it will return null, so no issue there.
trap_GetEngineVersion would return a string version that is up to the engine maker (semantic versioning would be preferred).
Why not add new traps to the end? Well, in base it will cause needless errors and returns an ugly -1.
In any case, I have no problem with creating a patch to do this, but I wanted to make sure that the work would be accepted before I did it.