Skip to content

Commit

Permalink
Fixes NullPointer exception in Ui.java
Browse files Browse the repository at this point in the history
  • Loading branch information
gamatecal committed Mar 27, 2010
1 parent 3627de8 commit 03986c4
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions Client/src/org/pokenet/client/network/TcpProtocolHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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':
/*
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 03986c4

Please sign in to comment.