ZetaMap / ProjectZomboid-Patches

Patches for Project Zomboid client/server, useful for modders.
3 stars 1 forks source link

NPE on GameLoading #1

Open cyberbobjr opened 3 months ago

cyberbobjr commented 3 months ago

Hello, nice works :) I tried to launch the game (in debug mode, nosteam), and i have a NPE at startup :

LOG  : Lua         , 1719420952139> [API Unlocker] [DEBUG] {exposeLikeJava} Exposing class zombie.iso.TileOverlays
LOG  : Lua         , 1719420952140> [API Unlocker] [DEBUG] {exposeLikeJava} Exposing gnu.trove.map.hash.THashMap<java.lang.String, zombie.iso.TileOverlays$TileOverlay>
LOG  : Lua         , 1719420952140> [API Unlocker] [DEBUG] {exposeLikeJava} Exposing class zombie.iso.TileOverlays$TileOverlay
LOG  : Lua         , 1719420952140> [API Unlocker] [DEBUG] {exposeLikeJava} class zombie.iso.TileOverlays$TileOverlay will be not exposed
LOG  : Lua         , 1719420952141> [API Unlocker] [DEBUG] {exposeLikeJava} Exposing java.util.ArrayList<zombie.iso.TileOverlays$TileOverlayEntry>
LOG  : Lua         , 1719420952141> [API Unlocker] [DEBUG] {exposeLikeJava} Exposing class zombie.iso.TileOverlays$TileOverlayEntry
LOG  : Lua         , 1719420952142> [API Unlocker] [DEBUG] {exposeLikeJava} class zombie.iso.TileOverlays$TileOverlayEntry will be not exposed
LOG  : Lua         , 1719420952142> [API Unlocker] [DEBUG] {exposeLikeJava} Exposing class zombie.randomizedWorld.randomizedDeadSurvivor.RDSZombiesEating
LOG  : Lua         , 1719420952148> [API Unlocker] Loading all classes in folder 'D:\steam\steamapps\common\ProjectZomboid\java' for full game api access.
ERROR: General     , 1719420952155> GameWindow.uncaughtException> Unhandled java.lang.RuntimeException thrown by thread MainThread.
ERROR: General     , 1719420952156> ExceptionLogger.logException> Exception thrown java.lang.RuntimeException: java.lang.NullPointerException: Cannot read the array length because "<local4>" is null at GameWindow.mainThreadInit line:580. Message: Unhandled java.lang.RuntimeException thrown by thread MainThread.
ERROR: General     , 1719420952156> DebugLogStream.printException> Stack trace:
java.lang.RuntimeException: java.lang.NullPointerException: Cannot read the array length because "<local4>" is null
        at zombie.GameWindow.mainThreadInit(GameWindow.java:580)
        at zombie.GameWindow.mainThread(GameWindow.java:489)
        at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException: Cannot read the array length because "<local4>" is null
        at se.krka.kahlua.integration.expose.LuaJavaClassExposer.loadClasses(LuaJavaClassExposer.java:283)
        at se.krka.kahlua.integration.expose.LuaJavaClassExposer.exposeGlobalFunctions(LuaJavaClassExposer.java:318)
        at zombie.Lua.LuaManager$Exposer.exposeAll(LuaManager.java:1442)
        at zombie.Lua.LuaManager.init(LuaManager.java:247)
        at zombie.GameWindow.init(GameWindow.java:1200)
        at zombie.GameWindow.mainThreadInit(GameWindow.java:576)
        ... 2 more
LOG  : General     , 1719420952160> GameThread exited.

Thanks for your help :)

ZetaMap commented 3 months ago

mmmm probably the path D:\steam\steamapps\common\ProjectZomboid\java isn't correct.... mmm i never tested on client side because i don't have the game, but it's probably that the "java" folder is in another folder. How look's like game files on client side?

cyberbobjr commented 3 months ago

Yeah the correct path is :

D:\steam\steamapps\common\ProjectZomboid\zombie

cyberbobjr commented 3 months ago

Hello @ZetaMap , i'm not a java expert, but a beginner. I have a question : if i made some changes into the code, how can i compile it to produce a "class" file please ?

cyberbobjr commented 3 months ago

ok found the way :)

javac -cp "D:\steam\steamapps\common\ProjectZomboid" --release 17 -Xlint:unchecked .\*.java -d ..\out

i fixed the path, compile the classes and all is working 👍

cyberbobjr commented 3 months ago

@ZetaMap i have one doubt : in LuaManager.java at line 612 you declare

public static class GlobalObject

but without any of the original exposed lua methods like these:

        @LuaMethod(
                name = "loadVehicleModel",
                global = true
        )
        public static Model loadVehicleModel(String var0, String var1, String var2) {
            return loadZomboidModel(var0, var1, var2, "vehicle", true);
        }

        @LuaMethod(
                name = "loadStaticZomboidModel",
                global = true
        )
        public static Model loadStaticZomboidModel(String var0, String var1, String var2) {
            return loadZomboidModel(var0, var1, var2, (String) null, true);
        }

        @LuaMethod(
                name = "loadSkinnedZomboidModel",
                global = true
        )
        public static Model loadSkinnedZomboidModel(String var0, String var1, String var2) {
            return loadZomboidModel(var0, var1, var2, (String) null, false);
        }
       ...

won't this break the game ?

ZetaMap commented 3 months ago

yea normal, this is a stub, just for compilation, because i have lot of errors with importations, i create stubs.

ZetaMap commented 3 months ago

but the problem is, i cannot test this anymore because I was using my friend's game files, who is no longer there, because the school year is over.