Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reintroduce QVM support #1182

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open

Commits on Sep 26, 2023

  1. Add vm_arm.cpp, vm_interpreted.cpp, vm_local.h and vm_x86.c from mvde…

    …vs/jk2mv@7dc8400.
    
    Does not compile. Files unmodified to make diffs easier.
    Daggolin committed Sep 26, 2023
    Configuration menu
    Copy the full SHA
    2d7593c View commit details
    Browse the repository at this point in the history
  2. Fix compiling with the jk2mv vm_* files.

    Move some vm related structs.
    Merge some vm related structs.
    Adjust a few places in vm_* files.
    Port a few functions from jk2mv's vm.cpp file (same revision as the vm_* files).
    Daggolin committed Sep 26, 2023
    Configuration menu
    Copy the full SHA
    324b6fd View commit details
    Browse the repository at this point in the history
  3. Add QVM loading.

    Add vm_game, vm_cgame and vm_ui cvars to set the prefered vm mode:
    	- 0: native
    	- 1: interpret (qvm)
    	- 2: compile (qvm)
    
    Can load QVMs on 64 bit, but it's not stable, yet. Loading the ui.qvm shows the menu, but crashes when entering player customization. Loading jampgame.qvm crashes when loading a map. These crashes are most likely related to the QVM being 32 bit and addresses getting passed in and out that don't fit. Also shared structs may be offset.
    Daggolin committed Sep 26, 2023
    Configuration menu
    Copy the full SHA
    f57ce90 View commit details
    Browse the repository at this point in the history

Commits on Sep 30, 2023

  1. Fix return values in nested system calls from QVMs

    This issue occured when the game module called the syscall G_NAV_GETNEARESTNODE. The module would receive a different value than the engine intended to return and that caused issues when the incorrect return value was used as input for other functions, causing issues and eventually crashes during later syscalls. This did not affect interpreted QVMs. Once pinpointed the source of the issue being DoSyscall a diff with ioq3 provided a fix. This fix comes from ioq3@1ce8ba0cdb8d8f2825177877a16d8525100280dd.
    Daggolin committed Sep 30, 2023
    Configuration menu
    Copy the full SHA
    54b4990 View commit details
    Browse the repository at this point in the history
  2. Add support for ui.qvm on 64 bit engine builds.

    Add g2handles to map g2 instances (64 bit address) to integers that the QVM can handle and adjust legacy uiapi to make use of them for QVMs.
    Convert glconfig_t in uiapi for QVMs, because the structs don't match.
    Daggolin committed Sep 30, 2023
    Configuration menu
    Copy the full SHA
    1d3d3c4 View commit details
    Browse the repository at this point in the history
  3. Add extra memory to QVMs on load to use when the module doesn't provi…

    …de a destination itself and expects to be given a pointer.
    
    Make use of QVM extra memory in CL_GetGlconfig for uiapi.
    Daggolin committed Sep 30, 2023
    Configuration menu
    Copy the full SHA
    ccdc67e View commit details
    Browse the repository at this point in the history
  4. Adjust the gameapi in a similar way to the uiapi for better QVM compa…

    …tibility.
    
    Still missing conversion for structs like sharedEntity_t.
    Daggolin committed Sep 30, 2023
    Configuration menu
    Copy the full SHA
    9002d28 View commit details
    Browse the repository at this point in the history
  5. Replace sharedEntity_t with sharedEntityMapper_t in most places.

    As the QVM is always 32 bit, even if the engine is 64 bit the structs don't match due to pointers inside of them. The sharedEntityMapper_t struct has the same members as the sharedEntity_t struct, but all of them are pointers to the types sharedEntity_t uses. When the game module calls the locate gamedata syscall the pointers of the mapper struct are set. The mapper should be usable with native libraries and QVM.
    Daggolin committed Sep 30, 2023
    Configuration menu
    Copy the full SHA
    39000e2 View commit details
    Browse the repository at this point in the history

Commits on Oct 3, 2023

  1. Configuration menu
    Copy the full SHA
    b92fc59 View commit details
    Browse the repository at this point in the history
  2. Adjust the cgameapi in a similar way to the uiapi and gameapi for bet…

    …ter QVM compatibility.
    Daggolin committed Oct 3, 2023
    Configuration menu
    Copy the full SHA
    f981711 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    c249103 View commit details
    Browse the repository at this point in the history

Commits on Oct 6, 2023

  1. Fix previously undefined behavior in SV_ClipMoveToEntities.

    The vanilla and OpenJK game module use "-1" as magic value for the SV_Trace passEntityNum instead of ENTITYNUM_NONE (1023). This lead to SV_ClipMoveToEntities trying to access entity "-1" and to read its ownerNum. When switching from sharedEntity_t to sharedEntityMapper_t for the QVM support the code got adjusted to no longer read out of bounds values, potentially leaving passOwnerNum unset/undefined (as opposed to be read from undefined memory). This commit fixes this by assuming a default value and refactoring some code to be simpler.
    Daggolin committed Oct 6, 2023
    Configuration menu
    Copy the full SHA
    6fd6d78 View commit details
    Browse the repository at this point in the history

Commits on Oct 28, 2023

  1. Compile vm_legacy cvar into non-debug builds.

    As most (maybe all) modules that support the OpenJK API also support the Legacy API give users the option to use the legacy system without requiring a debug build.
    Daggolin committed Oct 28, 2023
    Configuration menu
    Copy the full SHA
    73e46f9 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    9e3da12 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    db0a3d4 View commit details
    Browse the repository at this point in the history

Commits on Oct 29, 2023

  1. Use longjmp in Com_Error, because throwing an exception when the call…

    … comes from within the QVM results in a crash.
    Daggolin committed Oct 29, 2023
    Configuration menu
    Copy the full SHA
    bce0347 View commit details
    Browse the repository at this point in the history
  2. Add com_dedicatedForceErrorsToFatal cvar.

    At some point OpenJK forced all Com_Error calls for dedicated servers to be ERR_FATAL, leading to the process terminating. This can be helpful for some simple forms of automatic restart scripts, but the original behavior of dropping to the interactive console can be useful during mod development or when testing various settings. To avoid issues with restart scripts depending on the ERR_FATAL rewrite the cvar defaults to enabled, but can be disabled to restore the original behavior.
    Daggolin committed Oct 29, 2023
    Configuration menu
    Copy the full SHA
    e02ac4a View commit details
    Browse the repository at this point in the history

Commits on Oct 31, 2023

  1. Configuration menu
    Copy the full SHA
    cf4fb13 View commit details
    Browse the repository at this point in the history

Commits on Nov 2, 2023

  1. Port file extension and character restrictions for vms from jk2mv.

    - Use GetFullPathNameA, GetFinalPathNameByHandleA and realpath to actually resolve paths when validating filenames
    - Use ERR_DROP instead of ERR_FATAL when a VM tries to access a forbidden extension
    - Check for more forbidden extensions
    - Prevent the VM from accessing files with unwanted characters in their names (just block the access and print a warning, don't drop)
    Daggolin committed Nov 2, 2023
    Configuration menu
    Copy the full SHA
    cf10de6 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d3f43ad View commit details
    Browse the repository at this point in the history

Commits on Nov 3, 2023

  1. vm_x86.cpp: push and pop ebx in EmitCallDoSyscall.

    Existing comments in the function suggested it would already push and pop ebx (non-volatile), but really performed the actions on ecx (volatile).
    Daggolin committed Nov 3, 2023
    Configuration menu
    Copy the full SHA
    4ab1db0 View commit details
    Browse the repository at this point in the history
  2. vm_x86.cpp: backup and restore registers r12, r13, r14 and r15 in Emi…

    …tCallDoSyscall, because they are non-volatile.
    Daggolin committed Nov 3, 2023
    Configuration menu
    Copy the full SHA
    afa3d13 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    2a74fa5 View commit details
    Browse the repository at this point in the history

Commits on Nov 6, 2023

  1. Configuration menu
    Copy the full SHA
    2626c38 View commit details
    Browse the repository at this point in the history
  2. Use new macros to fix double pointers in sharedEntityMapper reading 6…

    …4 bit addresses from QVMs when dereferencing.
    
    Remove ConvertedEntity function, because the sharedEntityMapper read macros handle the required changes on demand now.
    Daggolin committed Nov 6, 2023
    Configuration menu
    Copy the full SHA
    9eb8502 View commit details
    Browse the repository at this point in the history

Commits on Nov 12, 2023

  1. Add SV_EntityMapperReadGhoul2 to handle special case for ghoul2 handl…

    …es that SV_EntityMapperReadData was not aware of.
    Daggolin committed Nov 12, 2023
    Configuration menu
    Copy the full SHA
    57cf72f View commit details
    Browse the repository at this point in the history

Commits on Apr 7, 2024

  1. Configuration menu
    Copy the full SHA
    9292075 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1271456 View commit details
    Browse the repository at this point in the history