Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dat reader - creating a PR so I can comment. #235

Merged
merged 8 commits into from
Apr 13, 2017
Merged

Dat reader - creating a PR so I can comment. #235

merged 8 commits into from
Apr 13, 2017

Conversation

Mogwai-TheFurry
Copy link
Contributor

No description provided.

Copy link
Contributor Author

@Mogwai-TheFurry Mogwai-TheFurry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AnimationPartChange, Loc, TextureMapChange, and SubPalette all have corresponding objects that already exist. Refactoring can be a post-merge task.

public int Offset { get; set; }
private byte[] buffer;

public DatReader(string datFilePath, uint offset, uint size, uint sectorSize)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would rather see DatDatabase return a DatReader when given a file Id. For example, in DatDatabase:
public DatReader GetReaderForFile(uint fileId)

The design paradigm here is that you've already loaded a DatDatabase, so you shouldn't have to go fishing around in objects to find the properties to pass into here. DatDatabase already has them all, you just need to give it a file Id.

size = 0;
}
else
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd really like to see this block commented fairly heavily. It took me several minutes of staring at it to grok what it is doing, where comments would have taken 20 seconds to read to get the explanation.

this.buffer = new byte[size];
stream.Seek(offset, SeekOrigin.Begin);

if (size > sectorSize)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I know what this does because I wrote the original DAT stuff, but this is totally non-obvious to someone who didn't. Just put a comment as to why this is the right thing to do.


namespace ACE.DatLoader.Entity
{
public class AnimationPartChange
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// TODO: Refactor to merge with existing AnimationOverride object in ACE.


namespace ACE.DatLoader.Entity
{
public class Loc
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// TODO: refactor to use existing Position object

public List<List<Loc>> StarterAreas { get; set; } = new List<List<Loc>>();
public Dictionary<int, HeritageGroupCG> HeritageGroups { get; set; } = new Dictionary<int, HeritageGroupCG>();

public static CharGen ReadFromDat(string datFilePath, uint offset, uint size, uint sectorSize)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is CharGen essentially a singleton? That is, there's only ever one of them? If so, just leave this as a todo:
// TODO: refactor into a singleton pattern

using System.Collections.Generic;
namespace ACE.DatLoader.Entity
{
/* These are client_portal.dat files starting with 0x24------ */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a ///

tag for this please


namespace ACE.DatLoader.Entity
{
/* These are client_portal.dat files starting with 0x02------ */
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// <summary>
/// These are client_portal.dat files starting with 0x02
/// </summary>

@@ -15,16 +15,18 @@ public PortalDatDatabase(string filename) : base(filename, DatDatabaseType.Porta

public void ExtractCategorizedContents(string path)
{
string thisFolder = null;
// string thisFolder = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just remove the methods if you're going to fully comment them out. it's ok.

@@ -288,6 +291,54 @@ public void Kill()

Location = character.Location;

// TODO: Move this all into Character Creation and store directly in the database.
if (DatManager.PortalDat.AllFiles.ContainsKey(0x0E000002))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is in Character.CreateFromClientFragment

public class DatReader
{
public int Offset { get; set; }
public byte[] buffer { get; private set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stylecop rules dictate that we should use uppercase for the first letter of this name: ex. Buffer

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! It was private previously, but I exposed the getter so I could still export the content to a file using the console "portal-export" command.

cg.Did = datReader.ReadInt32();
datReader.Offset = 8;

/* STARTER AREA */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multi-line comment style is not really necessary for single line comments, but I do like how this shows separate logic sections.

You can use /// for a lot of metadata in comments that will be visible within visual studio.

</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an empty group?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, won't hurt anything, though.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what/how that got there. Something Visual Studio did for me, apparently. I'll remove it just to keep things clean, though.

Copy link
Contributor

@fantoms fantoms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial testing and review proves that character generation is working great!

  • I did not test the starting locations.

  • There was some a couple CR:LF messages on a couple files,

  • My eye could not notice any visual discrepancies from character generation, though I cannot confirm all character appearances are correct due to my own limitations - please have another eye check to for visual issues or motion table problems.

  • Testing has shown that this code consistently produces the correct player model on login.

@fantoms
Copy link
Contributor

fantoms commented Apr 12, 2017

Just pulled the latest changes and tested again; all functions were working as expected.

@Mogwai-TheFurry Mogwai-TheFurry merged commit 9709959 into ACEmulator:master Apr 13, 2017
@OptimShi OptimShi deleted the DatReader branch April 23, 2017 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants