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

Added BOOK_DATA_RESPONSE_EVENT and BOOK_PAGE_DATA_RESPONSE_EVENT #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 185 additions & 1 deletion aclogview/CM_Writing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,20 @@ public override bool acceptMessageData(BinaryReader messageDataReader, TreeView
PacketOpcode opcode = Util.readOpcode(messageDataReader);
switch (opcode) {
// TODO: Add all BOOK_*_RESPONSE_EVENT
case PacketOpcode.Evt_Writing__BookData_ID: {
case PacketOpcode.BOOK_DATA_RESPONSE_EVENT:
{
PageDataList message = PageDataList.read(messageDataReader);
message.contributeToTreeView(outputTreeView);
break;
}
case PacketOpcode.BOOK_PAGE_DATA_RESPONSE_EVENT:
{
PageData message = PageData.read(messageDataReader);
message.contributeToTreeView(outputTreeView);
break;
}
case PacketOpcode.Evt_Writing__BookData_ID:
{
BookData message = BookData.read(messageDataReader);
message.contributeToTreeView(outputTreeView);
break;
Expand Down Expand Up @@ -55,6 +68,177 @@ public override bool acceptMessageData(BinaryReader messageDataReader, TreeView
return handled;
}

public class PageDataList : Message
{
public uint i_bookID;
public uint i_maxNumPages;
public uint numPages;
public uint maxNumCharsPerPage;
public List<BookPageDataResponse> pageData = new List<BookPageDataResponse>();
public PStringChar inscription;
public uint authorId;
public PStringChar authorName;

public static PageDataList read(BinaryReader binaryReader)
{
PageDataList newObj = new PageDataList();
newObj.i_bookID = binaryReader.ReadUInt32();
newObj.i_maxNumPages = binaryReader.ReadUInt32();
newObj.numPages = binaryReader.ReadUInt32();
newObj.maxNumCharsPerPage = binaryReader.ReadUInt32();

uint used_pages = binaryReader.ReadUInt32();
for (uint i = 0; i < used_pages; i++)
{
newObj.pageData.Add(BookPageDataResponse.read(binaryReader));
}

newObj.inscription = PStringChar.read(binaryReader);
newObj.authorId = binaryReader.ReadUInt32();
newObj.authorName = PStringChar.read(binaryReader);

return newObj;
}

public override void contributeToTreeView(TreeView treeView)
{
TreeNode rootNode = new TreeNode(this.GetType().Name);
rootNode.Expand();
rootNode.Nodes.Add("i_bookID = " + Utility.FormatGuid(i_bookID));
rootNode.Nodes.Add("i_maxNumPages = " + i_maxNumPages);
rootNode.Nodes.Add("numPages = " + numPages);
rootNode.Nodes.Add("maxNumCharsPerPage = " + maxNumCharsPerPage);

TreeNode pageDataNode = new TreeNode("pageData = ");
for (int i = 0; i < pageData.Count; i++)
pageData[i].contributeToTreeNode(pageDataNode);
rootNode.Nodes.Add(pageDataNode);

rootNode.Nodes.Add("inscription = " + inscription);
rootNode.Nodes.Add("authorId = " + authorId);
rootNode.Nodes.Add("authorName = " + authorName);
treeView.Nodes.Add(rootNode);
}
}


public class BookPageDataResponse : Message
{
public uint authorID;
public PStringChar authorName;
public PStringChar authorAccount;
public uint flags;
public uint textIncluded;
public uint ignoreAuthor;
public PStringChar pageText;

public static BookPageDataResponse read(BinaryReader binaryReader)
{
BookPageDataResponse newObj = new BookPageDataResponse();
newObj.authorID = binaryReader.ReadUInt32();
newObj.authorName = PStringChar.read(binaryReader);
newObj.authorAccount = PStringChar.read(binaryReader);
newObj.flags = binaryReader.ReadUInt32();
if ((newObj.flags >> 16) == 0xFFFF)
{
if ((ushort)newObj.flags == 2)
{
newObj.textIncluded = binaryReader.ReadUInt32();
newObj.ignoreAuthor = binaryReader.ReadUInt32();
}else
{
newObj.textIncluded = newObj.flags;
newObj.ignoreAuthor = 0;
}
}
if (newObj.textIncluded != 0)
newObj.pageText = PStringChar.read(binaryReader);

return newObj;
}

public override void contributeToTreeView(TreeView treeView)
{
TreeNode rootNode = new TreeNode(this.GetType().Name);
contributeToTreeNode(rootNode);
treeView.Nodes.Add(rootNode);
}

public void contributeToTreeNode(TreeNode node)
{
TreeNode rootNode = new TreeNode("PageData");
rootNode.Expand();
rootNode.Nodes.Add("authorID = " + Utility.FormatGuid(authorID));
rootNode.Nodes.Add("authorName = " + authorName);
rootNode.Nodes.Add("authorAccount = " + authorAccount);
rootNode.Nodes.Add("flags = " + flags);
rootNode.Nodes.Add("textIncluded = " + textIncluded);
rootNode.Nodes.Add("ignoreAuthor = " + ignoreAuthor);
if (textIncluded != 0)
rootNode.Nodes.Add("pageText = " + pageText);

node.Nodes.Add(rootNode);
}
}

public class PageData : Message
{
public uint bookID;
public uint page;
public uint authorID;
public PStringChar authorName;
public PStringChar authorAccount;
public uint flags;
public uint textIncluded;
public uint ignoreAuthor;
public PStringChar pageText;

public static PageData read(BinaryReader binaryReader)
{
PageData newObj = new PageData();
newObj.bookID = binaryReader.ReadUInt32();
newObj.page = binaryReader.ReadUInt32();
newObj.authorID = binaryReader.ReadUInt32();
newObj.authorName = PStringChar.read(binaryReader);
newObj.authorAccount = PStringChar.read(binaryReader);
newObj.flags = binaryReader.ReadUInt32();
if ((newObj.flags >> 16) == 0xFFFF)
{
if ((ushort)newObj.flags == 2)
{
newObj.textIncluded = binaryReader.ReadUInt32();
newObj.ignoreAuthor = binaryReader.ReadUInt32();
}
else
{
newObj.textIncluded = newObj.flags;
newObj.ignoreAuthor = 0;
}
}
if (newObj.textIncluded != 0)
newObj.pageText = PStringChar.read(binaryReader);

return newObj;
}

public override void contributeToTreeView(TreeView treeView)
{
TreeNode rootNode = new TreeNode(this.GetType().Name);
rootNode.Expand();
rootNode.Nodes.Add("bookID = " + Utility.FormatGuid(bookID));
rootNode.Nodes.Add("page = " + page);
rootNode.Nodes.Add("authorID = " + Utility.FormatGuid(authorID));
rootNode.Nodes.Add("authorName = " + authorName);
rootNode.Nodes.Add("authorAccount = " + authorAccount);
rootNode.Nodes.Add("flags = " + flags);
rootNode.Nodes.Add("textIncluded = " + textIncluded);
rootNode.Nodes.Add("ignoreAuthor = " + ignoreAuthor);
if (textIncluded != 0)
rootNode.Nodes.Add("pageText = " + pageText);
treeView.Nodes.Add(rootNode);
}
}

public class BookData : Message {
public uint i_objectid;

Expand Down
29 changes: 14 additions & 15 deletions aclogview/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.