File tree 4 files changed +21
-13
lines changed
4 files changed +21
-13
lines changed Original file line number Diff line number Diff line change @@ -11,18 +11,23 @@ hc_help() {
11
11
hc_build () {
12
12
rm -rf dist/
13
13
# TODO: Use other compilers
14
- dmd src/* .d -of./dist/hypercube.exe -v
14
+ dmd src/* .d -of./dist/hypercube.exe # -v
15
15
}
16
16
17
17
hc_run () {
18
- if [ ! -f " /dist/hypercube.exe" ]; then
18
+ if [ -f " /dist/hypercube.exe" ]; then
19
19
hc_build
20
20
fi
21
- if [ -f " /dist/hypercube.exe" ]; then
21
+ if [ ! -f " /dist/hypercube.exe" ]; then
22
22
dist/hypercube -debug -h=localhost -p=25565
23
23
fi
24
24
}
25
25
26
+ hc_reboot () {
27
+ hc_build
28
+ hc_run
29
+ }
30
+
26
31
if [ -z $1 ]; then
27
32
hc_help
28
33
exit
Original file line number Diff line number Diff line change @@ -51,7 +51,8 @@ void setupSockets() {
51
51
ubyte [1024 ] buffer;
52
52
int ptr = 0 ;
53
53
s.receive(buffer);
54
- int size = readVarInt(buffer, &ptr); // / size of packet
54
+ new IncomingPacket (buffer);
55
+ /* int size = readVarInt(buffer, &ptr); /// size of packet
55
56
int id = readVarInt(buffer, &ptr); /// packet id
56
57
int protocolVersion = readVarInt(buffer, &ptr); /// protocol version
57
58
string address = readString(buffer, &ptr); /// the client is stupid and sends the address to the address
@@ -65,7 +66,7 @@ void setupSockets() {
65
66
"\nPort: " ~ to!string(port) ~
66
67
"\nState: " ~ to!string(state)
67
68
);
68
- }
69
+ }*/
69
70
/* ptr = 0;
70
71
while(ptr <= buffer.length) {
71
72
write(to!string(readVarInt(buffer, &ptr)) ~ " ");
Original file line number Diff line number Diff line change @@ -31,11 +31,11 @@ class PacketField {
31
31
}
32
32
33
33
class Packet {
34
- enum To : string {
34
+ enum To : string {
35
35
Server = " Server" ,
36
36
Client = " Client" ,
37
37
}
38
- enum State : string {
38
+ enum State : string {
39
39
HandShake = " HandShake" ,
40
40
Status = " Status" ,
41
41
Login = " Login" ,
@@ -76,11 +76,12 @@ class Packet {
76
76
}
77
77
}
78
78
79
- Packet[] allPackets;
79
+ Packet[] allPackets = void ;
80
80
81
81
Packet getPacketById (ubyte id) {
82
82
foreach (p; allPackets) {
83
- if (p.getId()) {
83
+ log(to! string (p.getId()));
84
+ if (p.getId() == id) {
84
85
return p;
85
86
}
86
87
}
@@ -98,9 +99,10 @@ void parseProtocol(char[] s) {
98
99
packets ~= parsePackets(p[" states" ][" login" ][" toServer" ], Packet.State.Login, Packet.To.Server);
99
100
packets ~= parsePackets(p[" states" ][" play" ][" toClient" ], Packet.State.Play, Packet.To.Client);
100
101
packets ~= parsePackets(p[" states" ][" play" ][" toServer" ], Packet.State.Play, Packet.To.Server);
101
-
102
+
103
+ log(" Packets Found: " ~ to! string (packets.length));
102
104
allPackets = packets;
103
-
105
+
104
106
foreach (packet; packets) {
105
107
log(packet.toString());
106
108
}
@@ -137,10 +139,10 @@ class IncomingPacket {
137
139
138
140
this (ubyte [] buffer) {
139
141
this .data = buffer;
142
+ this .ptr = 0 ;
140
143
int size = readVarInt(data, &ptr); // / size of packet
141
144
int id = readVarInt(data, &ptr); // / packet id
142
145
Packet p = getPacketById(cast (ubyte )id);
143
- switch (id) {
144
- }
146
+ log(" Incoming Packet: " ~ to! string (id) ~ " :" ~ p.toString());
145
147
}
146
148
}
You can’t perform that action at this time.
0 commit comments