From: <suv...@us...> - 2003-12-14 10:49:12
|
Update of /cvsroot/megamek/megamek/megamek/common/xml In directory sc8-pr-cvs1:/tmp/cvs-serv3518/megamek/common/xml Modified Files: BoardEncoder.java Log Message: + Patch 819982, RFE 748896: add option to allow tanks to "eject". Index: BoardEncoder.java =================================================================== RCS file: /cvsroot/megamek/megamek/megamek/common/xml/BoardEncoder.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** BoardEncoder.java 7 Dec 2003 15:53:03 -0000 1.7 --- BoardEncoder.java 13 Dec 2003 14:33:50 -0000 1.8 *************** *** 145,148 **** --- 145,150 ---- Hex[] hexes = null; boolean roadsAutoExit = false; + Enumeration subnodes = null; + ParsedXML subnode = null; // Did we get a null node? *************** *** 162,168 **** while ( children.hasMoreElements() ) { ParsedXML child = (ParsedXML) children.nextElement(); // Did we find the boardData node? ! if ( child.getName().equals( "boardData" ) ) { // There should be only one boardData node. --- 164,177 ---- while ( children.hasMoreElements() ) { ParsedXML child = (ParsedXML) children.nextElement(); + String childName = child.getName(); + + // Handle null child names. + if ( null == childName ) { + + // No-op. + } // Did we find the boardData node? ! else if ( childName.equals( "boardData" ) ) { // There should be only one boardData node. *************** *** 227,235 **** // Walk through the subnodes, parsing out hex nodes. int numHexes = 0; ! Enumeration subnodes = child.elements(); while ( subnodes.hasMoreElements() ) { // Is this a "hex" node? ! ParsedXML subnode = (ParsedXML) subnodes.nextElement(); if ( subnode.getName().equals( "hex" ) ) { --- 236,244 ---- // Walk through the subnodes, parsing out hex nodes. int numHexes = 0; ! subnodes = child.elements(); while ( subnodes.hasMoreElements() ) { // Is this a "hex" node? ! subnode = (ParsedXML) subnodes.nextElement(); if ( subnode.getName().equals( "hex" ) ) { *************** *** 258,265 **** } // End found-"boardData"-node } // Look at the next child. // Did we find all needed child nodes? ! // TODO : perform data validation. // Construct the board. --- 267,334 ---- } // End found-"boardData"-node + // Did we find the infernos node? + else if ( childName.equals("infernos") ) { + subnodes = child.elements(); + while ( subnodes.hasMoreElements() ) { + subnode = (ParsedXML) subnodes.nextElement(); + if ( subnode.getName().equals("inferno") ) { + Coords coords = null; + InfernoTracker tracker = new InfernoTracker(); + + // Try to find the inferno detail nodes. + Enumeration details = subnode.elements(); + while ( details.hasMoreElements() ) { + ParsedXML detail = (ParsedXML) + details.nextElement(); + + // Have we found the coords? + if ( detail.getName().equals("coords") ) { + coords = CoordsEncoder.decode + ( detail, game ); + } + + // Have we found the Arrow IV inferno entry? + if ( detail.getName().equals("coords") ) { + coords = CoordsEncoder.decode + ( detail, game ); + } + + // Have we found the standard inferno entry? + if ( detail.getName().equals("coords") ) { + coords = CoordsEncoder.decode + ( detail, game ); + } + + } // Handle the next detail node. + + // We *did* find the coords, right? + + // Add this inferno tracker to the map. + + } // End found-"inferno"-subnode + + } // Check the next subnode + + } // End found-"infernos"-child + + // Did we find the buildings node? + else if ( childName.equals("buildings") ) { + subnodes = child.elements(); + while ( subnodes.hasMoreElements() ) { + subnode = (ParsedXML) subnodes.nextElement(); + if ( subnode.getName().equals("building") ) { + buildings.addElement + ( BuildingEncoder.decode( subnode, game ) ); + } + } // Handle the next building + } + } // Look at the next child. // Did we find all needed child nodes? ! if ( null == hexes ) { ! throw new IllegalStateException ! ( "Couldn't locate the boardData for a board node." ); ! } // Construct the board. |