blob: 4557f7bb4b7a8b5d3589d51ff91a45170b5b09c6 (
plain)
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
|
#include "stdafx.h"
#include <iostream>
#include "InputOutputStream.h"
#include "PacketListener.h"
#include "SetHealthPacket.h"
SetHealthPacket::SetHealthPacket()
{
this->health = 0.0f;
this->food = 0;
this->saturation = 0;
this->damageSource = eTelemetryChallenges_Unknown;
}
SetHealthPacket::SetHealthPacket(float health, int food, float saturation, ETelemetryChallenges damageSource)
{
this->health = health;
this->food = food;
this->saturation = saturation;
// this.exhaustion = exhaustion; // 4J - Original comment
this->damageSource = damageSource;
}
void SetHealthPacket::read(DataInputStream *dis) //throws IOException
{
health = dis->readFloat();
food = dis->readShort();
saturation = dis->readFloat();
// exhaustion = dis.readFloat();
damageSource = static_cast<ETelemetryChallenges>(dis->readByte());
}
void SetHealthPacket::write(DataOutputStream *dos) //throws IOException
{
dos->writeFloat(health);
dos->writeShort(food);
dos->writeFloat(saturation);
// dos.writeFloat(exhaustion);
dos->writeByte(damageSource);
}
void SetHealthPacket::handle(PacketListener *listener)
{
listener->handleSetHealth(shared_from_this());
}
int SetHealthPacket::getEstimatedSize()
{
return 11;
}
bool SetHealthPacket::canBeInvalidated()
{
return true;
}
bool SetHealthPacket::isInvalidatedBy(shared_ptr<Packet> packet)
{
return true;
}
|