-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCharacterReader.cs
More file actions
193 lines (152 loc) · 6.98 KB
/
CharacterReader.cs
File metadata and controls
193 lines (152 loc) · 6.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GDParser {
public class CharacterReader {
private CryptoDataBuffer reader;
public byte charTestVal;
public string charClass; // Del
public uint charMoney; // Del
public bool isHardcore; // Del
public byte charSex; // Del
public byte charDiff; // Del
public byte charGreatestDiff; // Del
public bool charisInMainQuest; //Del
public bool charhasBeenInGame; //Del
public string Name { get; private set; }
public int Level { get; private set; }
//public GDInventory Inventory { get; private set; }
//private GDCharSkillList SkillList = new GDCharSkillList();
public GDCharBio Bio { get; private set; } = new GDCharBio();
private void ReadHeader() {
string classID;
bool hardcore;
byte sex;
string name;
bool testVal;
bool testVal2;
byte testVal3;
byte testVal4;
uint testVal5;
byte testVal6;
uint testVal7;
byte testVal8;
reader.ReadCryptoWString(out name);
Name = name;
reader.ReadCryptoByte(out sex);
charSex = sex;
if (!reader.ReadCryptoString(out classID))
throw new FormatException("Could not read class id");
charClass = classID;
Level = reader.ReadCryptoIntUnchecked();
reader.ReadCryptoBool(out hardcore);
isHardcore = hardcore;
/* Del */
//reader.ReadBlockStart(Constants.BLOCK);
//reader.ReadBlockStart(1);
//reader.ReadCryptoIntUnchecked();
//Console.WriteLine("Test (Main quest): " + reader.ReadCryptoBool(out testVal)); // Bool - In main quest?
//Console.WriteLine("Test 2 (Been in game): " + reader.ReadCryptoBool(out testVal2)); // Bool - Has been in game?
//reader.ReadCryptoByte(out testVal3); // Byte - Difficulty?
//Console.WriteLine("Test 3 (Diff): " + testVal3);
//reader.ReadCryptoByte(out testVal4); // Byte - Greatest Diff?
//Console.WriteLine("Test 4 (Grt Diff): " + testVal4);
//reader.ReadCryptoUInt(out testVal5); // Byte - Money?
//Console.WriteLine("Test 5 (Money): " + testVal5);
//reader.ReadCryptoByte(out testVal6); // Byte - greatestSurvivalDifficulty
//Console.WriteLine("Test 6 (Grt crucible): " + testVal6);
//reader.ReadCryptoUInt(out testVal7); // Byte - currentTribute
//Console.WriteLine("Test 7 (Tribute): " + testVal7);
//reader.ReadCryptoByte(out testVal8); // Byte - compass state
//Console.WriteLine("Test 8 (Compass state): " + testVal8);
reader.ReadBlockEnd();
//Console.WriteLine("Test val (string): " + charTestVal);
/* Del */
}
private void ReadCharacterInfo() {
bool isInMainQuest;
bool hasBeenInGame;
byte difficulty;
byte greatestCampaignDifficulty;
uint money;
byte greatestCrucibleDifficulty;
int tributes;
reader.ReadBlockStart(Constants.BLOCK);
int version = reader.ReadCryptoIntUnchecked();
//if ((version != Constants.VERSION_3) && (version != Constants.VERSION_4)) {
// throw new FormatException("ERR_UNSUPPORTED_VERSION");
//}
reader.ReadCryptoBool(out isInMainQuest);
charisInMainQuest = isInMainQuest;
reader.ReadCryptoBool(out hasBeenInGame);
charhasBeenInGame = hasBeenInGame;
//reader.ReadCryptoByte(out difficulty);
//charDiff = difficulty;
reader.ReadCryptoByte(out greatestCampaignDifficulty);
charGreatestDiff = greatestCampaignDifficulty;
reader.ReadCryptoUInt(out money);
charMoney = money;
//if (version == Constants.VERSION_4) {
// reader.ReadCryptoByte(out greatestCrucibleDifficulty);
// reader.ReadCryptoInt(out tributes);
//}
//byte compassState = reader.ReadCryptoByteUnchecked();
//int lootMode = reader.ReadCryptoIntUnchecked();
//byte skillWindowHelp = reader.ReadCryptoByteUnchecked();
//byte alternateConfig = reader.ReadCryptoByteUnchecked();
//byte alternateConfigEnabled = reader.ReadCryptoByteUnchecked();
//string texture = reader.ReadCryptoStringUnchecked();
reader.ReadBlockEnd();
}
public void ReadSummary(string file) {
ReadSummary(File.ReadAllBytes(file));
}
public void ReadSummary(byte[] data) {
reader = new CryptoDataBuffer(data);
int val = 0;
reader.ReadCryptoKey();
if (!reader.ReadCryptoInt(out val)) {
throw new FormatException("ERR_UNSUPPORTED_VERSION");
}
if (val != 0x58434447)
throw new FormatException("ERR_UNSUPPORTED_VERSION");
reader.ReadCryptoInt(out val);
//if (val != 1)
// throw new FormatException("ERR_UNSUPPORTED_VERSION");
ReadHeader();
reader.ReadCryptoInt(out val, false);
//if (val != 0)
// throw new FormatException("ERR_UNSUPPORTED_VERSION");
int version;
reader.ReadCryptoInt(out version);
//if ((version != 6) && (version != 7)) {
// throw new FormatException("ERR_UNSUPPORTED_VERSION");
//}
reader.ReadAndDiscardUID();
ReadCharacterInfo();
Bio.Read(reader);
this.Print();
//Inventory.Read(reader);
}
public void Print() {
Console.WriteLine("Character: " + Name);
Console.WriteLine("Level: " + Level);
Console.WriteLine("Class: " + charClass);
Console.WriteLine("Sex: " + charSex);
//Console.WriteLine("Difficulty: " + charDiff);
//Console.WriteLine("Money: " + charMoney);
Console.WriteLine("Hardcore: " + isHardcore);
//Console.WriteLine("Is in main quest: " + charisInMainQuest);
//Console.WriteLine("Has been in game: " + charhasBeenInGame);
//int str = (int)((Bio.TotalStrength - 50) / 8);
//int agi = Bio.Agility;
//int inte = Bio.Intelligence;
//String attributes = str + "/" + agi + "/" + inte;
//Console.WriteLine("Attributes: " + attributes);
}
}
}