C# DLM petit doute

Inscrit
16 Mars 2014
Messages
214
Reactions
30
#1
Yo je me suis mis à faire mon reader de dlm mais j'ai un soucis ou pas avec ceci BackgroundsCount et BackgroundFixtures

J'ai beau avoir essayer plusieurs dlm ma variable BackgroundsCount est toujours "0" est-ce normal?

C#:
        public void FromRaw(BigEndianReader raw)
        {
            int header;
            try
            {
                header = raw.ReadByte();
                if (header != 77)
                {
                    throw new Exception("Unknown file format");
                }
                MapVersion = raw.ReadByte();
                Id = raw.ReadInt();
                RelativeId = raw.ReadInt();
                MapType = raw.ReadByte();
                SubareaId = raw.ReadInt();
                TopNeighbourId = raw.ReadInt();
                BottomNeighbourId = raw.ReadInt();
                LeftNeighbourId = raw.ReadInt();
                RightNeighbourId = raw.ReadInt();
                ShadowBonusOnEntities = raw.ReadInt();
                BackgroundsCount = raw.ReadByte();
                //TODO
            }
            catch(Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
Le code AS de ma version : https://github.com/skeezr/Dofus-2.0...4a15/dofus/ankamagames/atouin/data/map/Map.as
 

BlueDream

Administrateur
Membre du personnel
Inscrit
8 Decembre 2012
Messages
2 010
Reactions
150
#2
Ta classe Map n'est pas du tout à jour.
Tu sautes une condition sur la variable mapVersion.

Code:
public function fromRaw(param1:IDataInput, param2:ByteArray = null) : void
  {
  var i:int = 0;
  var header:int = 0;
  var bg:Fixture = null;
  var la:Layer = null;
  var _oldMvtSystem:uint = 0;
  var cd:CellData = null;
  var dataLen:uint = 0;
  var encryptedData:ByteArray = null;
  var readColor:int = 0;
  var gridAlpha:int = 0;
  var gridRed:int = 0;
  var gridGreen:int = 0;
  var gridBlue:int = 0;
  var fg:Fixture = null;
  var raw:IDataInput = param1;
  var decryptionKey:ByteArray = param2;
  try
  {
  header = raw.readByte();
  if(header != 77)
  {
  throw new DataFormatError("Unknown file format");
  }
  this.mapVersion = raw.readByte();
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("Map version : " + this.mapVersion);
  }
  this.id = raw.readUnsignedInt();
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("Map id : " + this.id);
  }
  if(this.mapVersion >= 7)
  {
  this.encrypted = raw.readBoolean();
  this.encryptionVersion = raw.readByte();
  dataLen = raw.readInt();
  if(this.encrypted)
  {
  if(!decryptionKey)
  {
  throw new IllegalOperationError("Map decryption key is empty");
  }
  encryptedData = new ByteArray();
  raw.readBytes(encryptedData,0,dataLen);
  i = 0;
  while(i < encryptedData.length)
  {
  encryptedData[i] = encryptedData[i] ^ decryptionKey[i % decryptionKey.length];
  i++;
  }
  encryptedData.position = 0;
  raw = encryptedData;
  }
  }
  this.relativeId = raw.readUnsignedInt();
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("Map relativeId: " + this.relativeId);
  }
  this.mapType = raw.readByte();
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("Map type : " + this.mapType);
  }
  this.subareaId = raw.readInt();
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("Subarea id : " + this.subareaId);
  }
  this.topNeighbourId = raw.readInt();
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("topNeighbourId : " + this.topNeighbourId);
  }
  this.bottomNeighbourId = raw.readInt();
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("bottomNeighbourId : " + this.bottomNeighbourId);
  }
  this.leftNeighbourId = raw.readInt();
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("leftNeighbourId : " + this.leftNeighbourId);
  }
  this.rightNeighbourId = raw.readInt();
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("rightNeighbourId : " + this.rightNeighbourId);
  }
  this.shadowBonusOnEntities = raw.readUnsignedInt();
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("ShadowBonusOnEntities : " + this.shadowBonusOnEntities);
  }
  if(this.mapVersion >= 9)
  {
  readColor = raw.readInt();
  this.backgroundAlpha = (readColor & 4.27819008E9) >> 32;
  this.backgroundRed = (readColor & 16711680) >> 16;
  this.backgroundGreen = (readColor & 65280) >> 8;
  this.backgroundBlue = readColor & 255;
  readColor = raw.readUnsignedInt();
  gridAlpha = (readColor & 4.27819008E9) >> 32;
  gridRed = (readColor & 16711680) >> 16;
  gridGreen = (readColor & 65280) >> 8;
  gridBlue = readColor & 255;
  this.gridColor = (gridAlpha & 255) << 32 | (gridRed & 255) << 16 | (gridGreen & 255) << 8 | gridBlue & 255;
  }
  else if(this.mapVersion >= 3)
  {
  this.backgroundRed = raw.readByte();
  this.backgroundGreen = raw.readByte();
  this.backgroundBlue = raw.readByte();
  }
  this.backgroundColor = (this.backgroundAlpha & 255) << 32 | (this.backgroundRed & 255) << 16 | (this.backgroundGreen & 255) << 8 | this.backgroundBlue & 255;
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("BackgroundColor : " + this.backgroundRed + "," + this.backgroundGreen + "," + this.backgroundBlue);
  }
  if(this.mapVersion >= 4)
  {
  this.zoomScale = raw.readUnsignedShort() / 100;
  this.zoomOffsetX = raw.readShort();
  this.zoomOffsetY = raw.readShort();
  if(this.zoomScale < 1)
  {
  this.zoomScale = 1;
  this.zoomOffsetY = 0;
  this.zoomOffsetX = 0;
  }
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("Zoom auto : " + this.zoomScale + "," + this.zoomOffsetX + "," + this.zoomOffsetY);
  }
  }
  this.useLowPassFilter = raw.readByte() == 1;
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("useLowPassFilter : " + this.useLowPassFilter);
  }
  this.useReverb = raw.readByte() == 1;
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("useReverb : " + this.useReverb);
  }
  if(this.useReverb)
  {
  this.presetId = raw.readInt();
  }
  else
  {
  this.presetId = -1;
  }
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("presetId : " + this.presetId);
  }
  this.backgroundsCount = raw.readByte();
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("Backgrounds count : " + this.backgroundsCount);
  }
  this.backgroundFixtures = new Array();
  i = 0;
  while(i < this.backgroundsCount)
  {
  bg = new Fixture(this);
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("Background at index " + i + " :");
  }
  bg.fromRaw(raw);
  this.backgroundFixtures.push(bg);
  i++;
  }
  this.foregroundsCount = raw.readByte();
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("Foregrounds count : " + this.foregroundsCount);
  }
  this.foregroundFixtures = new Array();
  i = 0;
  while(i < this.foregroundsCount)
  {
  fg = new Fixture(this);
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("Foreground at index " + i + " :");
  }
  fg.fromRaw(raw);
  this.foregroundFixtures.push(fg);
  i++;
  }
  this.cellsCount = AtouinConstants.MAP_CELLS_COUNT;
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("Cells count : " + this.cellsCount);
  }
  raw.readInt();
  this.groundCRC = raw.readInt();
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("groundCRC : " + this.groundCRC);
  }
  this.layersCount = raw.readByte();
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("Layers count : " + this.layersCount);
  }
  this.layers = new Array();
  i = 0;
  while(i < this.layersCount)
  {
  la = new Layer(this);
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  _log.debug("Layer at index " + i + " :");
  }
  la.fromRaw(raw,this.mapVersion);
  this.layers.push(la);
  i++;
  }
  this.cells = new Array();
  i = 0;
  while(i < this.cellsCount)
  {
  cd = new CellData(this,i);
  cd.fromRaw(raw);
  if(!_oldMvtSystem)
  {
  _oldMvtSystem = cd.moveZone;
  }
  if(cd.moveZone != _oldMvtSystem)
  {
  this.isUsingNewMovementSystem = true;
  }
  this.cells.push(cd);
  i++;
  }
  if(AtouinConstants.DEBUG_FILES_PARSING)
  {
  trace(this.isUsingNewMovementSystem?"This map is using the new movement system":"This map is using the old movement system");
  }
  this._parsed = true;
  return;
  }
  catch(e:*)
  {
  _failed = true;
  throw e;
  }
  }
 
Inscrit
16 Mars 2014
Messages
214
Reactions
30
#3
Ce n'est pas pour la version actuelle de dofus aussi :p c'est pour sa que j'ai mis le lien vers le code AS de ma version actuelle
 

asyade

Membre Actif
Inscrit
26 Avril 2013
Messages
368
Reactions
1
#4
Si je me souviens bien les background ne sont jamais utiliser sauf sur deux ou trois map donc pas trop de soucis a se faire
 

BlueDream

Administrateur
Membre du personnel
Inscrit
8 Decembre 2012
Messages
2 010
Reactions
150
#5
Hum essaye pas mal de map, il y en a plus que deux ou trois.
 
Inscrit
16 Mars 2014
Messages
214
Reactions
30
#6
Si je me souviens bien les background ne sont jamais utiliser sauf sur deux ou trois map donc pas trop de soucis a se faire
Hum essaye pas mal de map, il y en a plus que deux ou trois.
Ok car j'ai test 4, 5 dlm et rien sa me paraissait bizarre ^^

edit: C'est bon aucun problème enfaîte sa dépend des maps et c'est souvent à 0
 
Dernière édition par un modérateur:
Inscrit
18 Février 2015
Messages
228
Reactions
7
#8
Inscrit
16 Mars 2014
Messages
214
Reactions
30
#9
Oui j'ai eu la même chose pour les dlm 2.34 en pensant récupérer les bonnes fightcells, je me suis retrouvé avec la false pour toute les cellules
Ta trouvé pourquoi sa fait sa? ou bien c'est normal ?
 
Inscrit
16 Mars 2014
Messages
214
Reactions
30
#11
ça a l'air d'être normal car j'avais essayé avec beaucoup d'autre version du jeu
Du coup c'est inutile aussi logiquement sa doit te mettre true quand ta cellule est une cellule rouge et false quand non comme sa tu peut savoir quels sont tes cells de placement
 
Inscrit
18 Février 2015
Messages
228
Reactions
7
#12
Du coup c'est inutile aussi logiquement sa doit te mettre true quand ta cellule est une cellule rouge et false quand non comme sa tu peut savoir quels sont tes cells de placement
en théorie ça doit être ça sauf que ça reste continuellement à false
 
Inscrit
7 Mars 2015
Messages
30
Reactions
0
#14
C'est le serveur qui te les envoie quand tu rejoins un combat
 
Inscrit
16 Mars 2014
Messages
214
Reactions
30
#15
C'est le serveur qui te les envoie quand tu rejoins un combat
Oue je sais mais d'ou le serveur récupère ces infos? C'est pour un émulateur perso et j'aimerais récupérer toutes les cellules de placement pour ma version
 
Haut Bas