From: Hendrik B. <nh...@us...> - 2010-02-05 20:57:51
|
Update of /cvsroot/arianne/stendhal/src/games/stendhal/client/entity In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv16090/src/games/stendhal/client/entity Modified Files: RPEntity.java Log Message: cleaned up client side event handling by using one class per event in combination with a EventFactory instead of a huge if-else if-else block in RPEntity (fixes #2946132) Index: RPEntity.java =================================================================== RCS file: /cvsroot/arianne/stendhal/src/games/stendhal/client/entity/RPEntity.java,v retrieving revision 1.264 retrieving revision 1.265 diff -C2 -d -r1.264 -r1.265 *** RPEntity.java 5 Feb 2010 06:10:37 -0000 1.264 --- RPEntity.java 5 Feb 2010 20:57:42 -0000 1.265 *************** *** 14,25 **** import games.stendhal.client.ClientSingletonRepository; - import games.stendhal.client.GameObjects; import games.stendhal.client.stendhal; - import games.stendhal.client.gui.admin.TransitionDiagram; import games.stendhal.client.gui.chatlog.HeaderLessEventLine; import games.stendhal.client.gui.chatlog.StandardEventLine; import games.stendhal.client.gui.chatlog.StandardHeaderedEventLine; - import games.stendhal.client.gui.imageviewer.ItemListImageViewerEvent; - import games.stendhal.client.gui.imageviewer.RPEventImageViewer; import games.stendhal.client.sound.SoundLayer; import games.stendhal.client.soundreview.SoundMaster; --- 14,21 ---- *************** *** 28,32 **** import games.stendhal.common.NotificationType; import games.stendhal.common.Rand; - import games.stendhal.common.constants.Events; import java.util.Collection; --- 24,27 ---- *************** *** 35,39 **** import java.util.List; - import marauroa.common.game.RPEvent; import marauroa.common.game.RPObject; import marauroa.common.game.RPObject.ID; --- 30,33 ---- *************** *** 410,416 **** public void onStartAttack(final IEntity target) { if (target != null) { ! attackTarget = (RPEntity) target; ! this.onAttack(target); ! attackTarget.onAttacked(this); } } --- 404,410 ---- public void onStartAttack(final IEntity target) { if (target != null) { ! attackTarget = (RPEntity) target; ! this.onAttack(target); ! attackTarget.onAttacked(this); } } *************** *** 690,720 **** } - - for (final RPEvent event : object.events()) { - /* - * Private message - */ - if (event.getName().equals(Events.PRIVATE_TEXT)) { - onPrivateListen(event.get("texttype"), event.get("text")); - } - - /* - * noise / chat message - */ - if (event.getName().equals(Events.PUBLIC_TEXT)) { - onTalk(event.get("text")); - } - - if (event.getName().equals(Events.START_ATTACK)) { - onStartAttack(GameObjects.getInstance().get(new RPObject.ID( - event.getInt("target"), object.get("zoneid")))); - } - - if (event.getName().equals(Events.STOP_ATTACK)) { - onStopAttack(GameObjects.getInstance().get(new RPObject.ID( - event.getInt("target"), object.get("zoneid")))); - } - } - /* * Outfit --- 684,687 ---- *************** *** 906,945 **** } - - for (final RPEvent event : changes.events()) { - /* - * Private message - */ - if (event.getName().equals(Events.PRIVATE_TEXT)) { - onPrivateListen(event.get("texttype"), event.get("text")); - } - /* - * noise / chat message - */ - if (event.getName().equals(Events.PUBLIC_TEXT)) { - onTalk(event.get("text")); - } else if (event.getName().equals(Events.SOUND)) { - SoundMaster.play(SoundLayer.CREATURE_NOISE, event.get("sound") + ".ogg", getX(), getY()); - } - - if (event.getName().equals("transition_graph")) { - new TransitionDiagram().showTransitionDiagram(event.get("data")); - } else if (event.getName().equals("examine")) { - RPEventImageViewer.viewImage(event); - } else if (event.getName().equals("show_item_list")) { - new ItemListImageViewerEvent(event).view(); - } - - if (event.getName().equals(Events.START_ATTACK)) { - onStartAttack(GameObjects.getInstance().get(new RPObject.ID( - event.getInt("target"), object.get("zoneid")))); - } - - if (event.getName().equals(Events.STOP_ATTACK)) { - onStopAttack(GameObjects.getInstance().get(new RPObject.ID( - event.getInt("target"), object.get("zoneid")))); - } - } - /* * Outfit --- 873,876 ---- |