the whole game

This commit is contained in:
Kolyah35
2026-03-02 22:04:18 +03:00
parent 816e9060b4
commit f0617a5d22
2069 changed files with 581500 additions and 0 deletions

41
src/network/packet/ChatPacket.h Executable file
View File

@@ -0,0 +1,41 @@
#ifndef NET_MINECRAFT_NETWORK_PACKET__ChatPacket_H__
#define NET_MINECRAFT_NETWORK_PACKET__ChatPacket_H__
#include "../Packet.h"
#include "../..//world/entity/player/Player.h"
class ChatPacket: public Packet
{
public:
static const int MAX_CHAT_LENGTH = 100;
static const int MAX_LENGTH = MAX_CHAT_LENGTH + Player::MAX_NAME_LENGTH;
ChatPacket() {
}
ChatPacket(std::string message, bool isSystem = true) {
if(message.length() > MAX_LENGTH) {
message = message.substr(0, MAX_LENGTH);
}
this->message = message;
this->isSystem = isSystem;
}
void write(RakNet::BitStream* bitStream) {
bitStream->Write((RakNet::MessageID)(ID_USER_PACKET_ENUM + PACKET_CHAT));
bitStream->Write(message.c_str());
}
void read(RakNet::BitStream* bitStream) {
char buff[MAX_LENGTH + 30];
bitStream->Read(buff);
message = buff;
}
void handle(const RakNet::RakNetGUID& source, NetEventCallback* callback) {
callback->handle(source, (ChatPacket*)this);
}
std::string message;
bool isSystem;
};
#endif /* NET_MINECRAFT_NETWORK_PACKET__ChatPacket_H__ */