Salut tout le monde, je reviens après un long moment d'arrêt avec une nouvelle question.
Je me remets tranquillement au bot pendant les vacances et actuellement je suis sur les déplacements. Tout d'abord je voudrais juste pouvoir ajouter les fonctions top, bottom, right et left à mon bot. Elles consistent juste à se déplacer sur la map située au dessus, en dessous, à droite ou à gauche de la map actuelle.
Je pensais pouvoir utiliser les tableaux topArrowCell, bottomArrowCell, rightArrowCell et leftArrowCell mais ils sont toujours vides après l'analyse d'un fichier. Pourtant à la fin il ne reste plus aucun byte non lu. Peu import la map que je charge, les tableaux sont toujours vides.
Voici mon code :
(CellData:fromRaw)
public void fromRaw(ICustomDataInput input) throws Exception {
int tmpbytesv9 = 0;
boolean topArrow = false;
boolean bottomArrow = false;
boolean rightArrow = false;
boolean leftArrow = false;
int tmpBits = 0;
floor = input.readByte() * 10;
if (map.mapVersion >= 9) {
tmpbytesv9 = input.readShort();
mov = (tmpbytesv9 & 1) == 0;
nonWalkableDuringFight = (tmpbytesv9 & 2) != 0;
nonWalkableDuringRP = (tmpbytesv9 & 4) != 0;
los = (tmpbytesv9 & 8) == 0;
blue = (tmpbytesv9 & 16) == 0;
red = (tmpbytesv9 & 32) != 0;
visible = (tmpbytesv9 & 64) != 0;
farmCell = (tmpbytesv9 & 128) != 0;
if (map.mapVersion >= 10) {
havenbagCell = (tmpbytesv9 & 256) != 0;
topArrow = (tmpbytesv9 & 512) != 0;
bottomArrow = (tmpbytesv9 & 1024) != 0;
rightArrow = (tmpbytesv9 & 2048) != 0;
leftArrow = (tmpbytesv9 & 4096) != 0;
}
else {
topArrow = (tmpbytesv9 & 256) != 0;
bottomArrow = (tmpbytesv9 & 512) != 0;
rightArrow = (tmpbytesv9 & 1024) != 0;
leftArrow = (tmpbytesv9 & 2048) != 0;
}
if (topArrow)
map.topArrowCell.add(id);
if (bottomArrow)
map.bottomArrowCell.add(id);
if (rightArrow)
map.rightArrowCell.add(id);
if(leftArrow)
map.leftArrowCell.add(id);
}
else {
losmov = input.readUnsignedByte();
los = (losmov & 2) >> 1 == 1;
mov = (losmov & 1) == 0;
visible = (losmov & 64) >> 6 == 1;
farmCell = (losmov & 32) >> 5 == 1;
blue = (losmov & 16) >> 4 == 1;
red = (losmov & 8) >> 3 == 1;
nonWalkableDuringRP = (losmov & 128) >> 7 == 1;
nonWalkableDuringFight = (losmov & 4) >> 2 == 1;
}
speed = input.readByte();
mapChangeData = input.readByte();
if (map.mapVersion > 5) {
moveZone = input.readUnsignedByte();
}
if (map.mapVersion > 7 && map.mapVersion < 9) {
tmpBits = input.readByte();
arrow = 15 & tmpBits;
if (useTopArrow())
map.topArrowCell.add(id);
if (useBottomArrow())
map.bottomArrowCell.add(id);
if (useLeftArrow())
map.leftArrowCell.add(id);
if (useRightArrow())
map.rightArrowCell.add(id);
}
}
(Map:fromRaw)
public void fromRaw(ICustomDataInput data) throws Exception {
int oldMvtSystem = 0;
int header = data.readByte();
if (header != 77)
throw new RuntimeException("ERROR HEADER!");
mapVersion = data.readByte();
id = data.readInt();
if (mapVersion >= 7) {
encrypted = data.readBoolean();
encryptionVersion = data.readByte();
int dataLen = data.readInt();
if (encrypted) {
byte decryptionKeyBytes[] = decryptionKey.getBytes();
byte encryptedData[] = new byte[dataLen];
data.readFully(encryptedData);
for (int i = 0; i < encryptedData.length; ++i)
encryptedData = (byte)(encryptedData ^ decryptionKeyBytes[i % decryptionKeyBytes.length]);
ByteArrayInputStream dataDecryptedBuffer = new ByteArrayInputStream(encryptedData);
data = new CustomDataInput(dataDecryptedBuffer);
}
}
relativeId = data.readInt();
mapType = data.readByte();
subareaId = data.readInt();
topNeighbourId = data.readInt();
bottomNeighbourId = data.readInt();
leftNeighbourId = data.readInt();
rightNeighbourId = data.readInt();
shadowBonusOnEntities = data.readInt();
if (mapVersion >= 9) {
int readColor = data.readInt();
backgroundAlpha = (int)((readColor & 4278190080L) >> 32);
backgroundRed = (readColor & 16711680) >> 16;
backgroundGreen = (readColor & 65280) >> 8;
backgroundBlue = readColor & 255;
readColor = data.readInt();
int gridAlpha = (int)((readColor & 4278190080L) >> 32);
int gridRed = (readColor & 16711680) >> 16;
int gridGreen = (readColor & 65280) >> 8;
int gridBlue = readColor & 255;
gridColor = (gridAlpha & 255) << 32 | (gridRed & 255) << 16 | (gridGreen & 255) << 8 | gridBlue & 255;
}
else if (mapVersion >= 3) {
backgroundRed = data.readByte();
backgroundGreen = data.readByte();
backgroundBlue = data.readByte();
}
backgroundColor = (backgroundAlpha & 255) << 32 | (backgroundRed & 255) << 16 | (backgroundGreen & 255) << 8 | backgroundBlue & 255;
if (mapVersion >= 4) {
zoomScale = data.readUnsignedShort() / 100;
zoomOffsetX = data.readShort();
zoomOffsetY = data.readShort();
if (zoomScale < 1) {
zoomScale = 1;
zoomOffsetY = 0;
zoomOffsetX = 0;
}
}
useLowPassFilter = data.readByte() == 1;
useReverb = data.readByte() == 1;
if (useReverb)
presetId = data.readInt();
else
presetId = -1;
backgroundsCount = data.readByte();
for (int i = 0; i < backgroundsCount; ++i) {
Fixture tmp = new Fixture(this);
tmp.fromRaw(data);
backgroundsFixtures.add(tmp);
}
foregroundsCount = data.readByte();
for (int i = 0; i < foregroundsCount; ++i) {
Fixture tmp = new Fixture(this);
tmp.fromRaw(data);
foregroundFixtures.add(tmp);
}
cellsCount = AtouinConstants.MAP_CELLS_COUNT;
data.readInt();
groundCRC = data.readInt();
layersCount = data.readByte();
for (int i = 0; i < layersCount; ++i) {
Layer tmp = new Layer(this, mapVersion);
tmp.fromRaw(data);
layers.add(tmp);
}
for (int i = 0; i < cellsCount; ++i) {
CellData tmp = new CellData(this, i);
tmp.fromRaw(data);
if (oldMvtSystem == 0)
oldMvtSystem = tmp.moveZone;
if (tmp.moveZone != oldMvtSystem)
isUsingNewMovementSystem = true;
cells.add(tmp);
}
}