Hey, Well these are my problems and the code, I'm going to bed, hopefully someone could help me with this overnight.
I know why its calling a nullpointer, its because its not set yet, which it wont be until a certain situation which is only when casting is set to true, but it's not and nothing has changed it to true. My question is why is it allowing it to run through that void in the first place? the boolean isnt set to true.
ERROR:
[4/12/12 8:14 PM]: java.lang.NullPointerException [4/12/12 8:14 PM]: at server.model.players.SpellCast.FinishCast(SpellCast.java:58) [4/12/12 8:14 PM]: at server.model.players.Client.process(Client.java:759) [4/12/12 8:14 PM]: at server.model.players.PlayerHandler.process(PlayerHandler.java:138) [4/12/12 8:14 PM]: at server.Server.main(Server.java:159)public void FinishCast() { if (c.casting = false) { return; } if (c.castTime <= 0) { int i = c.playerIndex; int pX = c.getX(); int pY = c.getY(); nX = Server.playerHandler.players[i].getX();//line 58 nY = Server.playerHandler.players[i].getY(); offX = (pY - nY)* -1; offY = (pX - nX)* -1; c.casting = false; c.castTime = 0; c.getPA().createPlayersProjectile(pX, pY, offX, offY, 50, 78, c.castGFX, 10, 10, i, 53); } }public void process() { /* ton of irrelevant code */ if (casting = true) { if (castTime > 0) { castTime = castTime - 0.6; } if ((castTime == 0) && (casting = true)) { getSpells().FinishCast(); //line 759 } } /* another 2k lines of irrelevant code */public void process() { synchronized (PlayerHandler.players) { updatePlayerNames(); if(kickAllPlayers) { for(int i = 1; i < Config.MAX_PLAYERS; i++) { if(players[i] != null) { players[i].disconnected = true; } } } for(int i = 0; i < Config.MAX_PLAYERS; i++) { if(players[i] == null || !players[i].isActive) continue; try { if(players[i].disconnected && (System.currentTimeMillis() - players[i].logoutDelay > 10000 || players[i].properLogout || kickAllPlayers)) { if(players[i].inTrade) { Client o = (Client) Server.playerHandler.players[players[i].tradeWith]; if(o != null) { o.getTradeAndDuel().declineTrade(); } } if(players[i].duelStatus == 5) { Client o = (Client) Server.playerHandler.players[players[i].duelingWith]; if(o != null) { o.getTradeAndDuel().duelVictory(); } } else if (players[i].duelStatus <= 4 && players[i].duelStatus >= 1) { Client o = (Client) Server.playerHandler.players[players[i].duelingWith]; if(o != null) { o.getTradeAndDuel().declineDuel(); } } Client o = (Client) Server.playerHandler.players[i]; if(PlayerSave.saveGame(o)) { System.out.println("Game saved for player "+players[i].playerName); } else { System.out.println("Could not save for "+players[i].playerName); } removePlayer(players[i]); players[i] = null; continue; } players[i].preProcessing(); while(players[i].processQueuedPackets()); players[i].process(); //line 138 players[i].postProcessing(); players[i].getNextPlayerMovement(); } catch(Exception e) { e.printStackTrace(); } }public static void main(java.lang.String args[]) throws NullPointerException, IOException { /** * Starting Up Server */ //WalkingCheck.check(); try { WalkingHandler.getSingleton().initialize(); } catch(Exception ex) { ex.printStackTrace(); } System.setOut(new Logger(System.out)); System.setErr(new Logger(System.err)); System.out.println("Server Launched..."); /** * World Map Loader */ //if(!Config.SERVER_DEBUG) // VirtualWorld.init(); //WorldMap.loadWorldMap(); /** * Script Loader */ //ScriptManager.loadScripts(); /** * Accepting Connections */ acceptor = new SocketAcceptor(); connectionHandler = new ConnectionHandler(); SocketAcceptorConfig sac = new SocketAcceptorConfig(); sac.getSessionConfig().setTcpNoDelay(false); sac.setReuseAddress(true); sac.setBacklog(100); throttleFilter = new ConnectionThrottleFilter(Config.CONNECTION_DELAY); sac.getFilterChain().addFirst("throttleFilter", throttleFilter); acceptor.bind(new InetSocketAddress(serverlistenerPort), connectionHandler, sac); /** * Initialise Handlers */ EventManager.initialize(); Connection.initialize(); //PlayerSaving.initialize(); //MysqlManager.createConnection(); /** * Server Successfully Loaded */ System.out.println("Server is Listening on port: 43594");// + serverlistenerPort); /** * Main Server Tick */ try { while (!Server.shutdownServer) { if (sleepTime >= 0) Thread.sleep(sleepTime); else Thread.sleep(600); engineTimer.reset(); itemHandler.process(); playerHandler.process(); //line 159 npcHandler.process(); shopHandler.process(); objectManager.process(); fightPits.process(); pestControl.process(); cycleTime = engineTimer.elapsed(); sleepTime = cycleRate - cycleTime; totalCycleTime += cycleTime; cycles++; debug(); if (System.currentTimeMillis() - lastMassSave > 300000) { for(Player p : PlayerHandler.players) { if(p == null) continue; PlayerSave.saveGame((Client)p); System.out.println("Saved game for " + p.playerName + "."); lastMassSave = System.currentTimeMillis(); } } } } catch (Exception ex) { ex.printStackTrace(); System.out.println("A fatal exception has been thrown!"); for(Player p : PlayerHandler.players) { if(p == null) continue; PlayerSave.saveGame((Client)p); System.out.println("Saved game for " + p.playerName + "."); } } acceptor = null; connectionHandler = null; sac = null; System.exit(0); }
Hopefully someone could help me here.