Skip to content

API Level 1

ouned edited this page Jun 7, 2017 · 18 revisions
Header JK2MV Version Supported since
Level 1 1.1 7 Nov 2015

SysCalls

Available SysCalls in this API-Level

MVAPI_ControlFixes

Declaration Number ASM game cgame ui
MVAPI_CONTROL_FIXES 703 -704 ☑️ ☑️
qboolean trap_MVAPI_ControlFixes(mvfix_t fixes);

Turns exploit- and bug-fixes in the engine on and off. This can be used to implement better fixes then what is possible from on the engines scope. fixes is a bitvalue which is expected to be a list of OR conjugated mvfix_t entrys. Every call to this function overwrites previous calls. Returns qfalse on success and qtrue on failure.

Example:

if ( trap_MVAPI_ControlFixes(MVFIX_GALAKING | MVFIX_BROKENMODEL) ) {
	G_Printf("Could not control JK2MV fixes.\n");
}

This example code switches off the fixes for galaking and broken models.

MVAPI_GET_VERSION
mvversion_t trap_MVAPI_GetVersion(void);
Syscall Number: 704 (asm: -705)
Modules: game, cgame, ui

Get the currently running gameversion from the engine. This is only useful if your mod is based on the mvsdk.

MVAPI_SEND_CONNECTIONLESSPACKET
qboolean trap_MVAPI_SendConnectionlessPacket(const mvaddr_t *addr, const char *message);
Syscall Number: 700 (asm: -701)
Module: game

Sends an UDP message to the given addr. Returns qfalse on success and qtrue on failure.

Example:

mvaddr_t addr;
addr.type = MV_IPV4;
addr.ip.v4[0] = 127; addr.ip.v4[1] = 0;
addr.ip.v4[2] = 0; addr.ip.v4[3] = 1;
addr.port = 12345;

if (trap_MVAPI_SendConnectionlessPacket(&addr, "hello world")) {
	G_Printf("Error sending connectionless packet.\n");
}

MVAPI_GET_CONNECTIONLESSPACKET
qboolean trap_MVAPI_GetConnectionlessPacket(mvaddr_t *addr, char *buf, unsigned int bufsize);
Syscall Number: 701 (asm: -702)
Module: game

Get the content of a connectionless packet. Only valid during a MVAPI_RECV_CONNECTIONLESSPACKET VMCall. Returns qfalse on success and qtrue on failure.

int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11  ) {
	switch ( command ) {
	...
	case MVAPI_RECV_CONNECTIONLESSPACKET:
		MVAPI_ReceiveConnectionlessPacket();
		return 0;
	}

	return -1;
}

void MVAPI_ReceiveConnectionlessPacket(void) {
	mvaddr_t addr;
	char message[256];
	
	if (trap_MVAPI_GetConnectionlessPacket(&addr, message, sizeof(message))) {
		G_Printf("Error receiving connectionless packet.\n");
		return;
	}
	
	G_Printf("connectionless packet %s received", message);
	if (addr.type == MV_IPV4) {
		G_Printf(" from %i.%i.%i.%i:%i.\n", (int)addr.ip.v4[0], (int)addr.ip.v4[1], (int)addr.ip.v4[2], (int)addr.ip.v4[3], (int)addr.port);
	} else {
		G_Printf(".\n");
	}
}

Clone this wiki locally