tchegito / zildo

The Land of Alembrume
GNU Lesser General Public License v3.0
4 stars 1 forks source link

NPE when selling items #146

Closed tchegito closed 6 years ago

tchegito commented 6 years ago

Seen on google console: (26/03/2018)

java.lang.NullPointerException: 
   at zildo.monde.items.StoredItem.fromString (StoredItem.java:32)
   at zildo.server.state.ScriptManagement.sellItem (ScriptManagement.java:645)
   at zildo.monde.sprites.persos.PersoPlayer.buyItem (PersoPlayer.java:1342)
   at zildo.server.PlayerManagement.keyPressAction (PlayerManagement.java:425)
   at zildo.server.PlayerManagement.handleCommon (PlayerManagement.java:167)
   at zildo.server.PlayerManagement.manageKeyboard (PlayerManagement.java:127)
   at zildo.server.EngineZildo.renderFrame (EngineZildo.java:153)
   at zildo.client.stage.SinglePlayer.updateGame (SinglePlayer.java:172)
   at zildo.client.Client.mainLoop (Client.java:194)
   at com.alembrum.OpenGLRenderer.onDrawFrame (OpenGLRenderer.java:107)
   at android.opengl.GLSurfaceView$GLThread.guardedRun (GLSurfaceView.java:1571)
   at android.opengl.GLSurfaceView$GLThread.run (GLSurfaceView.java:1270)
tchegito commented 6 years ago

It seems a BuyingAction was created with an empty store description.

Actually there's only 3 cases:

Maybe the associated global variable is null ? Maybe player has a name containing "$sell(" ? That's really unlikely, but this causes the same symptom.

tchegito commented 6 years ago

Happened again in June:

version=v2.52
map=d5m1 (20x15)
sprites=[Perso=Zildo
Coords:(123.14865, 84.52833 0.0)
info=ZILDO
mvt=VIDE pv=6 weapon=[MILK,0] name=angelus lasthit=null, 123.14865, 94.52833 (80 - bank 0), 691.0, 540.0 (83 - bank 0), 691.0, 540.0 (SHADOW), 691.0, 540.0 (102 - bank 0), Entity id=141
x=80.0
y=24.0
nSpr=161
visible=true, Entity id=142
x=176.0
y=24.0
nSpr=161
visible=true, Entity id=143
x=80.0
y=152.0
nSpr=161
visible=true, Entity id=144
x=176.0
y=152.0
nSpr=161
visible=true, Perso=gerard
Coords:(120.0, 72.0 0.0)
info=NEUTRAL
mvt=VIDE pv=1, 0.0, 0.0 (80 - bank 0), 120.0, 71.0 (SHADOW)]
persos=[Perso=Zildo
Coords:(123.14865, 84.52833 0.0)
info=ZILDO
mvt=VIDE pv=6 weapon=[MILK,0] name=angelus lasthit=null, Perso=gerard
Coords:(120.0, 72.0 0.0)
info=NEUTRAL
mvt=VIDE pv=1]
variables={nettleCount=-1, Carlo=[[MOON, 1], 800, 1], allowedDynamite=yes, Dizzie=[[DYNAMITE, 1], 15, 20], BilelIgorVillage=[[EMPTY_BAG, 1], 100, 2], [[BLUEDROP, 1], 15, -1], [[DYNAMITE, 1], 100, 2]}
scripts=0 scripts running {[}
quests=[flut_ask, enlevebuissons, enlevebuissons_win]
lastdialog=Lugdunia
�Gerard�: I think that your grandfather gave me a Flute to fix, some time ago. Is that what you are here for?
�Grandpa�: I'm counting on you angelus. Find the woodcutters!
�Grandpa�: It's very important to me. This Flute can call on Nature. But I will explain that later.
�Grandpa�: Can you do me a favor? Please go see Gerard and Robert, the woodcutters east of the village. They have fixed my Flute for me.
�Grandpa�: Hi angelus, my little son...You seem to be doing well! I'm pleased to see that!
�Angelus�: I shouldn't go into the tavern, my grandfather told me not to.
�Laura�: Hi boy! Welcome to our modest farm!
�Old lady�: Welcome to our farm! I'm the oldest of the Piochais family.
�Angelus�: I shouldn't go into the tavern, my grandfather told me not to.
�Mostapha�: Hello, my name's Mostapha, cheapest trader in the village...
�Robert�: Hi angelus. As you can see, I'm exhausted from my work. There is always more work to do around here!
�Grandpa�: I'm counting on you angelus. Find the woodcutters!
�Grandpa�: It's very important to me. This Flute can call on Nature. But I will explain that later.
�Grandpa�: Can you do me a favor? Please go see Gerard and Robert, the woodcutters east of the village. They have fixed my Flute for me.
�Grandpa�: Hi angelus, my little son...You seem to be doing well! I'm pleased to see that!
�Christa�: Thank you very much! I couldn't have done it myself! Please take this, it's a bottle of fresh Milk from my farm!
�Christa�: Can you help me? I have to take out all the bushes from this hill, but I'm not strong enough to do it myself.
�Christa�: Hello my boy. My name's Christa. I am Laura's younger sister.
�Grandpa�: I'm counting on you angelus. Find the woodcutters!
�Grandpa�: It's very important to me. This Flute can call on Nature. But I will explain that later.
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.replace(java.lang.CharSequence, java.lang.CharSequence)' on a null object reference
    at zildo.monde.items.StoredItem.fromString(StoredItem.java:32)
    at zildo.server.state.ScriptManagement.sellItem(ScriptManagement.java:645)
    at zildo.monde.sprites.persos.PersoPlayer.buyItem(PersoPlayer.java:1342)
    at zildo.server.PlayerManagement.keyPressAction(PlayerManagement.java:425)
    at zildo.server.PlayerManagement.handleCommon(PlayerManagement.java:167)
    at zildo.server.PlayerManagement.manageKeyboard(PlayerManagement.java:127)
    at zildo.server.EngineZildo.renderFrame(EngineZildo.java:153)
    at zildo.client.stage.SinglePlayer.updateGame(SinglePlayer.java:172)
    at zildo.client.Client.mainLoop(Client.java:194)
    at com.alembrum.OpenGLRenderer.onDrawFrame(OpenGLRenderer.java:107)
    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1522)
    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)
tchegito commented 6 years ago

It seems that payer is doing two things forbidden at the same time:

Maybe he managed to press Inventory and Talk key in a really close nanoseconds ?

tchegito commented 6 years ago

[Fixed in 2.53]

25a35a2cca09d236c1c4b82ac38e4c6393d77e2a