private bool LoadXML_OLD_sprite(Sprite s, XmlNodeList xnl) { int nNumTiles = s.NumTiles; int nTileIndex = 0; foreach (XmlNode xn in xnl) { if (xn.Name == "tile") { if (nTileIndex >= nNumTiles) { // too many tiles in sprite m_doc.ErrorString("Too many tiles specified for sprite '{0}' (expected {1})", s.Name, nNumTiles); return(false); } uint[] bTile = new uint[32]; int nCurrByte = 0; Regex rxTile = new Regex(@"\s*0x([0-9A-Fa-f]{2})\s*,"); Match mxTile = rxTile.Match(xn.InnerText); if (mxTile.Success) { while (mxTile.Success) { GroupCollection matchGroups = mxTile.Groups; if (nCurrByte >= 32) { // too many data bytes in tile m_doc.ErrorString("Too many data bytes in tile #{0} of sprite '{0}'", nTileIndex, s.Name); return(false); } bTile[nCurrByte] = Convert.ToUInt32(matchGroups[1].Value, 16); nCurrByte++; if (nCurrByte == 32) { // After we've read 32 bytes, import the tile into the sprite. if (!s.ImportTile32(nTileIndex, bTile)) { // Warning/Error message already displayed. return(false); } nTileIndex++; } // Get the next match. mxTile = mxTile.NextMatch(); } } if (nCurrByte != 32) { // too few data bytes for tile m_doc.ErrorString("Too few data bytes in tile #{0} of sprite '{0}'", nTileIndex, s.Name); return(false); } } } if (nTileIndex != s.NumTiles) { // incorrect number of tiles for this sprite - too few m_doc.ErrorString("Too few tiles specified for sprite '{0}' (expected {1})", s.Name, nNumTiles); return(false); } return(true); }
private bool LoadXML_OLD_sprite(Sprite s, XmlNodeList xnl) { int nNumTiles = s.NumTiles; int nTileIndex = 0; foreach (XmlNode xn in xnl) { if (xn.Name == "tile") { if (nTileIndex >= nNumTiles) { // too many tiles in sprite m_doc.ErrorString("Too many tiles specified for sprite '{0}' (expected {1})", s.Name, nNumTiles); return false; } uint[] bTile = new uint[32]; int nCurrByte = 0; Regex rxTile = new Regex(@"\s*0x([0-9A-Fa-f]{2})\s*,"); Match mxTile = rxTile.Match(xn.InnerText); if (mxTile.Success) { while (mxTile.Success) { GroupCollection matchGroups = mxTile.Groups; if (nCurrByte >= 32) { // too many data bytes in tile m_doc.ErrorString("Too many data bytes in tile #{0} of sprite '{0}'", nTileIndex, s.Name); return false; } bTile[nCurrByte] = Convert.ToUInt32(matchGroups[1].Value, 16); nCurrByte++; if (nCurrByte == 32) { // After we've read 32 bytes, import the tile into the sprite. if (!s.ImportTile32(nTileIndex, bTile)) { // Warning/Error message already displayed. return false; } nTileIndex++; } // Get the next match. mxTile = mxTile.NextMatch(); } } if (nCurrByte != 32) { // too few data bytes for tile m_doc.ErrorString("Too few data bytes in tile #{0} of sprite '{0}'", nTileIndex, s.Name); return false; } } } if (nTileIndex != s.NumTiles) { // incorrect number of tiles for this sprite - too few m_doc.ErrorString("Too few tiles specified for sprite '{0}' (expected {1})", s.Name, nNumTiles); return false; } return true; }