private bool setTileDescription(NetworkMessage incMsg, NetworkMessage outMsg, Position pos) { //set the tile in the map Tile tile = Map.GetInstance().SetTile(pos); if (tile == null) return false; //and clear it tile.Clear(); int n = 0; while (true) { //avoid infinite loop n++; ushort inspectTileId = incMsg.PeekUInt16(); if (inspectTileId >= 0xFF00) { //end of the tile //Notifications::onTileUpdate(pos); return true; } else { if (n > 10) { Logger.Log("Muitos objetos no tile. Posição: " + pos.ToString(), LogType.ERROR); return false; } //read tile things: items and creatures Thing thing = internalGetThing(incMsg, outMsg); if (thing == null) { Logger.Log("Falha ao obter o objeto. Posição: " + pos.ToString(), LogType.ERROR); return false; } //and add to the tile if (!tile.AddThing(thing)) { Logger.Log("Falha ao adicionar um objeto. Posição: " + pos.ToString(), LogType.ERROR); return false; } } } }
private bool setFloorDescription(NetworkMessage incMsg, NetworkMessage outMsg, int x, int y, int z, int width, int height, int offset) { for (int nx = 0; nx < width; nx++) { for (int ny = 0; ny < height; ny++) { if (skipTiles == 0) { ushort tileOpt = incMsg.PeekUInt16(); //Decide if we have to skip tiles // or if it is a real tile if (tileOpt >= 0xFF00) { ushort skip = incMsg.GetUInt16(); outMsg.AddUInt16(skip); skipTiles = (ushort)(skip & 0xFF); } else { //real tile so read tile Position pos = new Position((uint)(x + nx + offset), (uint)(y + ny + offset), (uint)z); if (!setTileDescription(incMsg, outMsg, pos)) { Logger.Log("Falha ao setar a descrição do tile. Posição: " + pos.ToString(), LogType.ERROR); return false; } //read skip tiles info ushort skip = incMsg.GetUInt16(); outMsg.AddUInt16(skip); skipTiles = (ushort)(skip & 0xFF); } } //skipping tiles... else { skipTiles--; } } } return true; }