Skip to content

API Level 3

aufau edited this page Jan 20, 2018 · 1 revision
Header JK2MV Version Supported since
Level 3 1.4 20 Jan 2018

SysCalls

SysCalls available with this API-Level.

Declaration Number ASM game cgame ui
MVAPI_FS_FLOCK 708 -709 ☑️ ☑️ ☑️
MVAPI_R_ADDREFENTITYTOSCENE2 706 -707 ☑️ ☑️
MVAPI_SETVIRTUALSCREEN 707 -708 ☑️ ☑️

MVAPI_FS_FLOCK

int trap_FS_FLock(fileHandle_t h, flockCmd_t cmd, qboolean nb);

Apply or remove an advisory lock on an open file. This is a rudimentary IPC (Inter-Process Communication) mean for synchronization of file read/write access between JK2MV processes. The argument cmd is one of following:

Command Description
FLOCK_SH Shared lock – multiple processes may apply this lock simultaneously. Used for reading.
FLOCK_EX Exclusive lock – only one process may hold an exclusive lock. Used for writing.
FLOCK_UN Unlock – remove an existing lock held by this process.

nb argument specifies if syscall should be blocking or non-blocking. A blocking syscall returns only when a resource becomes available. Non-blocking call returns -1 immediately if another process prevents us from acquiring a lock. Return value of 0 means succcess and -1 means failure. The lock is advisory, meaning that it doesn't physically prevent a mod from using a file regardless if it's locked or not. Keep in mind that using the blocking version of the syscall is susceptible to deadlocks. One fail-safe way to avoid such issues is to never acquire a lock on more that one file at a time, or not use a blocking variant of the syscall. For more information on process synchronization strategies and issues, refer to programming literature.

MVAPI_R_ADDREFENTITYTOSCENE2

void trap_R_AddRefEntityToScene2(const refEntity_t *re);

shaderTime field of refEntity_t will be read as int, rather than float. For refEntities that use this field (none in original basejk modules), use this syscall instead of original trap_R_AddRefEntityToScene to avoid bugs on high server time.

MVAPI_SETVIRTUALSCREEN

trap_MVAPI_SetVirtualScreen(float w, float h);

Set virtual screen size (default 640x480) used by following SysCalls: R_FONT_STRLENPIXELS, R_FONT_STRHEIGHTPIXELS, R_FONT_DRAWSTRING, R_DRAWSTRETCHPIC, R_ROTATEPIC, R_ROTATEPIC2. Changing virtual screen size won't affect other modules and it's a very cheap operation performance-wise. It can be used to handily correct aspect ratio of HUD/UI elements. Exemplary implementation of the former can be seen here: https://github.com/aufau/SaberMod/commits/widescreen

MVAPI Fixes

See Cvars page for bug descriptions.

Flag game cgame ui
MVFIX_PLAYERGHOSTING ☑️