From 03986c4362a5848a7734b1b009165b3f33fad71e Mon Sep 17 00:00:00 2001 From: gamatecal Date: Sat, 27 Mar 2010 09:23:23 +0000 Subject: [PATCH] Fixes NullPointer exception in Ui.java --- .../client/network/TcpProtocolHandler.java | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Client/src/org/pokenet/client/network/TcpProtocolHandler.java b/Client/src/org/pokenet/client/network/TcpProtocolHandler.java index 066e41d10..bfd6a6409 100644 --- a/Client/src/org/pokenet/client/network/TcpProtocolHandler.java +++ b/Client/src/org/pokenet/client/network/TcpProtocolHandler.java @@ -367,12 +367,14 @@ public void messageReceived(IoSession session, Object m) { //Stats update details = message.substring(3).split(","); m_game.getOurPlayer().updatePokemon(Integer.parseInt(String.valueOf(message.charAt(2))), details); - m_game.getUi().refreshParty(); + if (m_game.getUi().isActive()) + m_game.getUi().refreshParty(); break; case 'N': //A pokemon left the party m_game.getOurPlayer().setPokemon(Integer.parseInt(String.valueOf(message.charAt(2))), null); - m_game.getUi().refreshParty(); + if (m_game.getUi().isActive()) + m_game.getUi().refreshParty(); break; case 'i': //Initialise a pokemon @@ -396,14 +398,16 @@ public void messageReceived(IoSession session, Object m) { m_game.getOurPlayer().getPokemon()[Integer.parseInt(String.valueOf(message.charAt(2)))] .setMoves(Integer.parseInt(String.valueOf(message.charAt(3))) , message.substring(4)); - GameClient.getInstance().getUi().update(false); + if (m_game.getUi().isActive()) + m_game.getUi().update(false); break; case 'e': //EXP gain int p1 = Integer.parseInt(String.valueOf(message.charAt(2))); int exp = m_game.getOurPlayer().getPokemon()[p1].getExp() + Integer.parseInt(message.substring(3)); m_game.getOurPlayer().getPokemon()[p1].setExp(exp); - m_game.getUi().update(false); + if (m_game.getUi().isActive()) + m_game.getUi().update(false); break; case 'E': /* @@ -420,13 +424,15 @@ public void messageReceived(IoSession session, Object m) { String[] levelData = message.substring(2).split(","); m_game.getOurPlayer().getPokemon()[Integer.parseInt(levelData[0])].setLevel( Integer.parseInt(levelData[1])); - m_game.getUi().update(false); + if (m_game.getUi().isActive()) + m_game.getUi().update(false); break; case 'h': //HP Change - through item usage m_game.getOurPlayer().getPokemon()[Integer.parseInt(String.valueOf(message.charAt(2)))] .setCurHP(Integer.parseInt(message.substring(3))); - GameClient.getInstance().getUi().update(false); + if (m_game.getUi().isActive()) + m_game.getUi().update(false); break; case 'p': //PP data - Pp POKEINDEX MOVEINDEX CURRENTPP , MAXPP @@ -569,7 +575,8 @@ public void messageReceived(IoSession session, Object m) { } } } - GameClient.getInstance().getUi().update(false); + if (m_game.getUi().isActive()) + m_game.getUi().update(false); break; case 'D': //Facing down