Git Product home page Git Product logo

phoenix-shared-interface's Introduction

phoenix shared interface

THIS REPO IS DEPRECATED. SWITCH TO ZenKitCAPI!

phoenix-shared-interface's People

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

sunbromarko

phoenix-shared-interface's Issues

pxVmStackPopInstance() from VM returns nullptr (0x0)

When I register TA_MIN, it should return the following values:

FUNC VOID TA_Min (var c_npc self, var int start_h, var int start_m, var int stop_h, var int stop_m, VAR func state, VAR string waypoint) { };

I implemented the pop() logic inside PxCs.Test and get all of the data except the instance which will always be 0x0.

image

(Code: https://github.com/GothicKit/phoenix-csharp-interface/blob/main/PxCs.Tests/PxVmTest.cs#L74)

As the other data is poped() right, I assume the order is correct?

        public static void TA_MIN(IntPtr vmPtr)
        {
            var waypoint = PxVm.pxVmStackPopString(vmPtr); // OCR_HUT_33 --> correct
            var action = PxVm.pxVmStackPopInt(vmPtr); // 5903 --> correct
            var stop_m = PxVm.pxVmStackPopInt(vmPtr);
            var stop_h = PxVm.pxVmStackPopInt(vmPtr);
            var start_m = PxVm.pxVmStackPopInt(vmPtr);  // 30 --> correct
            var start_h = PxVm.pxVmStackPopInt(vmPtr);  // 22 --> correct
            var npc = PxVm.pxVmStackPopInstance(vmPtr); // --> error. Shouldn't be 0

            Assert.True(npc != IntPtr.Zero, "Npc is IntPtr.Zero.");
        }

What could drive this error?

gitflow - built Win64.DLL can't be loaded

When I pick the built phoenix-shared.dll from GitHub actions, I can't run it neither on PxCs.Tests nor Unity.

The following error appears:
image

What I checked:

  • When I build phoenix-shared with MinGW-64 on Windows, I include the "libstdc++" as static dependency. This solved this issue earlier.

  • I checked file size (first indicator of different static dependencies)
    image
    --> libphoenix-shared.dll -> working one built with mingw
    --> phoenix-shared.dll -> taken from GitHub action

  • I checked with DependencyWalker what's the difference between the two dlls.
    --> Yes. Both show warnings/errors - seems natural ¯_(ツ)_/¯
    --> the GitHub Action one (second one) shows additional errors about API-MS-WIN-CRT in the main window. Could be related to these missing ones? Are there any required DLLs for Windows? Or can we bake it into the dll itself (like libstdc++ with mingw)

libphoenix-shared.dll
image

phoenix-shared.dll
image

Feel free to ping me for further tests.

VM: Resetting pxVmSetGlobalSelf() after a pxVmCallFunction() call throws memory exceptin

When calling the below VM method, I get a memory exception:

C#

 public static bool CallFunction(IntPtr vmPtr, uint index, IntPtr self, params object[] parameters)
        {
            var prevSelf = pxVmSetGlobalSelf(vmPtr, self); // returns 0x0

            StackPushParameters(vmPtr, parameters);
            var success = pxVmCallFunctionByIndex(vmPtr, index, IntPtr.Zero);

            pxVmSetGlobalSelf(vmPtr, prevSelf); // Memory Exception

            return success;
        }

C++

PxVmInstance* pxVmSetGlobalSelf(PxVm* vm, PxVmInstance* instance) {
    auto* old = pxVmGetGlobalSelf(vm);
    auto* instSym = vm->vm.find_symbol_by_index(instance->symbol_index());
    vm->vm.global_self()->set_instance(instSym->get_instance());
    return old; // returns 0x0 during first call of pxVmSetGlobalSelf()
}

OpenGothic is doing the reset of globalSelf() in a similar fashion, but there's a difference:
The original phoenix implementation uses std::shared_ptr which are never empty. But the C-API leverages the underlying .data() (c_npc*) which can be empty.

Could it be possible to have a null-check within C-API and reset to a default (empty shared_ptr<>()) value? (maybe create a new shared_ptr every time? But is the old one being deleted?)

Model for object element not loadable (mesh is empty)

When loading an object's model, I get no nullptr, but the model itself has no data.

Example:

auto mdm = pxMdmLoadFromVdf(vdfPtr, name);
auto checksum = pxMdmGetChecksum(mdm); // 0
auto meshCount = pxMdmGetMeshCount(mdm); // 0
...

It cab be tested with CHESTBIG_OCCHESTLARGE.MDM from anims.vdf

C# Debugger output of phoenix-csharp-interface
image

.dylib for MacOS seems to have a deprecated build target

When putting the .dylib into the same folder where the .so and .dlls of our Unity project are, we get the following error:
image

Hint: I got this message when I used Unity on Windows. (I have no clue if this is related or if the dylib won't work at all. Just want to mention it as this could be an issue if any other project wants to use this on their end).

Win64 dll compilation won't work on fresh installation of Windows 11

We tested with @Romeyyy's new PC and there were additional libraries inside the libphoenix-shared.dll missing.
They are:

  • libgcc
  • libwinpthread

You can see it in Dependency Walker tool:
2023-04-16 22_33_22-Open Office

Solution: We tested with a different static linking compiler flag for mingw builds. Works like a charm. And the DLL only got 100kb bigger in size.

clang-lint for PRs isn't checking header files

Currently clang-format is only checking .cc and .hh files. But the API headers are of format .h.

run: 'find include src -iname "*.hh" -or -iname "*.cc" | xargs clang-format --dry-run --style=file --Werror'

I would recommend changing this behavior. But beware: I tested it locally once and it showed some errors on the Header files.

Export function to get uncompressed Textures.

The API currently supports returning compressed Textures only.

PXC_API uint8_t const* pxTexGetMipmap(PxTexture const* tex, uint32_t* length, uint32_t level, uint32_t* width, uint32_t* height);

(https://github.com/GothicKit/phoenix-shared-interface/blob/main/include/phoenix/cffi/Texture.h#L46)

As not every game engine supports all the compression algorithms, we need to have a way getting the data uncompressed if needed.
(Specifically Unity3D can't handle dxt_3)

OpenGothic uses it like this:

      if (tex.format() == phoenix::tex_dxt1 ||
          tex.format() == phoenix::tex_dxt5) {
              ...
        } else {
            auto rgba = tex.as_rgba8(0); // This is the required method to call.
        }

https://github.com/Try/OpenGothic/blob/c648801ff216974e0756d162e1b8087a2b5f576e/game/resources.cpp#L304

It would be sufficient to either have another parameter like bool uncompressed or call a similar method like pxTexGetMipmapUncompressed()

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.