From: <aki...@us...> - 2006-12-23 19:09:38
|
Revision: 1228 http://svn.sourceforge.net/gridarta/?rev=1228&view=rev Author: akirschbaum Date: 2006-12-23 11:09:38 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Return the newly inserted game object from MapModel.insertArchToMap(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/map/DefaultMapModel.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/crossfire/src/cfeditor/map/MapModel.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/map/DefaultMapModel.java trunk/daimonin/src/daieditor/map/MapModel.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -587,7 +587,7 @@ mainView.showArchPanelQuickObject(gameObject); } - public boolean insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { + @Nullable public GameObject insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { return currentMap.insertArchToMap(newarch, archname, next, pos, join); } Modified: trunk/crossfire/src/cfeditor/map/DefaultMapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/crossfire/src/cfeditor/map/DefaultMapModel.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -245,12 +245,13 @@ /** * {@inheritDoc} */ - public boolean insertArchToMap(GameObject newObject, String archName, final GameObject next, final Point pos, final boolean join) { + @Nullable public GameObject insertArchToMap(GameObject newObject, String archName, final GameObject next, final Point pos, final boolean join) { // map coords must be valid if (!isPointValid(pos)) { - return false; + return null; } + final GameObject newGameObject; if (next == null || !next.isInContainer()) { // put arch on the map @@ -261,7 +262,7 @@ } // insert a new instance of the default arch (number 'archName') if (!addArchToMap(archName, pos, true, join, false)) { - return false; + return null; } } else { // insert the given 'newObject' (multis not allowed here yet - sorry) @@ -269,11 +270,11 @@ newObject = newObject.createClone(pos.x, pos.y); // create a clone addGameObjectToMap(newObject, false); // insert it to the map } else { - return false; // tried to insert multi (probably from pickmap) + return null; // tried to insert multi (probably from pickmap) } } - final GameObject node = mapGrid[pos.x][pos.y].getLast(); + newGameObject = mapGrid[pos.x][pos.y].getLast(); int position = 0; for (final GameObject search : mapGrid[pos.x][pos.y].reverse()) { if (search == next) { @@ -282,33 +283,32 @@ position++; } for(int i = 0; i < position - 1; i++) { - node.moveDown(); + newGameObject.moveDown(); } } else { // insert the new arch into the inventory of a map arch - final GameObject invnew; // new arch to be inserted if (newObject == null || newObject.isArchetype()) { if (newObject != null && newObject.isArchetype()) { archName = newObject.getArchetypeName(); } // create a new copy of a default arch - invnew = getArchetype(archName).createArch(); + newGameObject = getArchetype(archName).createArch(); } else { // create clone from a pickmap if (!newObject.isMulti()) { - invnew = newObject.createClone(pos.x, pos.y); + newGameObject = newObject.createClone(pos.x, pos.y); } else { - return false; + return null; } } - next.getContainer().addLast(invnew); - mainControl.getArchetypeParser().postParseGameObject(invnew, mapControl.getActiveEditType()); - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), invnew); + next.getContainer().addLast(newGameObject); + mainControl.getArchetypeParser().postParseGameObject(newGameObject, mapControl.getActiveEditType()); + mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), newGameObject); } setLevelChangedFlag(); // the map has been modified - return true; + return newGameObject; } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -202,7 +202,7 @@ return addArchToMap(archname, pos, allowDouble, join, false); } - public boolean insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { + @Nullable public GameObject insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point pos, final boolean join) { return mapModel.insertArchToMap(newarch, archname, next, pos, join); } Modified: trunk/crossfire/src/cfeditor/map/MapModel.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapModel.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/crossfire/src/cfeditor/map/MapModel.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -61,9 +61,9 @@ * -> 'next' must be an arch from the map! (or null) * @param pos map position to insert the new arch * @param join if set to JOIN_ENABLE auto-joining is supported - * @return true if insertion was successful + * @return the inserted game object, or <code>null</code> if an error occurred */ - boolean insertArchToMap(GameObject newObject, String archName, GameObject next, Point pos, boolean join); + @Nullable GameObject insertArchToMap(GameObject newObject, String archName, GameObject next, Point pos, boolean join); /** * Delete an existing arch from the map. (If the specified arch doesn't Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -783,7 +783,7 @@ mainView.showArchPanelQuickObject(gameObject); } - public boolean insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point point) { + @Nullable public GameObject insertArchToMap(final GameObject newarch, final String archname, final GameObject next, final Point point) { return currentMap.getMapModel().insertArchToMap(newarch, archname, next, point); } Modified: trunk/daimonin/src/daieditor/map/DefaultMapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/daimonin/src/daieditor/map/DefaultMapModel.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -172,12 +172,13 @@ * {@inheritDoc} * @xxx I'm too complex */ - public boolean insertArchToMap(GameObject newObject, String archName, final GameObject next, final Point pos) { + @Nullable public GameObject insertArchToMap(GameObject newObject, String archName, final GameObject next, final Point pos) { // map coords must be valid if (!isPointValid(pos)) { - return false; + return null; } + final GameObject newGameObject; if (next == null || !next.isInContainer()) { // put arch on the map @@ -188,7 +189,7 @@ } // insert a new instance of the default arch (number 'archName') if (!addArchToMap(archName, pos, true, false)) { - return false; + return null; } } else { // insert the given 'newObject' (multis not allowed here yet - sorry) @@ -196,11 +197,11 @@ newObject = newObject.createClone(pos.x, pos.y); // create a clone addGameObjectToMap(newObject, false); // insert it to the map } else { - return false; // tried to insert multi (probably from pickmap) + return null; // tried to insert multi (probably from pickmap) } } - final GameObject node = mapGrid[pos.x][pos.y].getLast(); + newGameObject = mapGrid[pos.x][pos.y].getLast(); int position = 0; for (final GameObject search : mapGrid[pos.x][pos.y].reverse()) { // This is okay because next is on the desired square. @@ -211,33 +212,32 @@ position++; } for(int i = 0; i < position - 1; i++) { - node.moveDown(); + newGameObject.moveDown(); } } else { // insert the new arch into the inventory of a map arch - final GameObject invnew; // new arch to be inserted if (newObject == null || newObject.isArchetype()) { if (newObject != null && newObject.isArchetype()) { archName = newObject.getArchetypeName(); } // create a new copy of a default arch - invnew = getArchetype(archName).createArch(); + newGameObject = getArchetype(archName).createArch(); } else { // create clone from a pickmap if (!newObject.isMulti()) { - invnew = newObject.createClone(pos.x, pos.y); + newGameObject = newObject.createClone(pos.x, pos.y); } else { - return false; + return null; } } - next.getContainer().addLast(invnew); - invnew.setObjectFace(); - mainControl.getArchetypeParser().postParseGameObject(invnew, mapControl.getActiveEditType()); - mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), invnew); + next.getContainer().addLast(newGameObject); + newGameObject.setObjectFace(); + mainControl.getArchetypeParser().postParseGameObject(newGameObject, mapControl.getActiveEditType()); + mainControl.getMainView().setMapTileList(mainControl.getCurrentMap(), newGameObject); } - return true; + return newGameObject; } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/map/MapModel.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapModel.java 2006-12-23 15:39:22 UTC (rev 1227) +++ trunk/daimonin/src/daieditor/map/MapModel.java 2006-12-23 19:09:38 UTC (rev 1228) @@ -61,9 +61,9 @@ * ('next'==null) the arch gets inserted at bottom * -> 'next' must be an arch from the map! (or null) * @param pos map position to insert the new arch - * @return true if insertion was successful + * @return the inserted game object, or <code>null</code> if an error occurred */ - boolean insertArchToMap(GameObject newObject, String archName, GameObject next, Point pos); + @Nullable GameObject insertArchToMap(GameObject newObject, String archName, GameObject next, Point pos); /** * Get the first exit on the MapSquare described by <var>hspot</var>. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |