mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-24 14:43:37 +00:00
53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
#include "../../Platform/stdafx.h"
|
|
#include <iostream>
|
|
#include "../../IO/Streams/InputOutputStream.h"
|
|
#include "PacketListener.h"
|
|
#include "GameEventPacket.h"
|
|
|
|
const int GameEventPacket::NO_RESPAWN_BED_AVAILABLE = 0;
|
|
const int GameEventPacket::START_RAINING = 1;
|
|
const int GameEventPacket::STOP_RAINING = 2;
|
|
const int GameEventPacket::CHANGE_GAME_MODE = 3; // 1.8.2
|
|
const int GameEventPacket::WIN_GAME = 4; // 1.0.1
|
|
const int GameEventPacket::DEMO_EVENT = 5;
|
|
|
|
const int GameEventPacket::DEMO_PARAM_INTRO = 0;
|
|
const int GameEventPacket::DEMO_PARAM_HINT_1 = 101;
|
|
const int GameEventPacket::DEMO_PARAM_HINT_2 = 102;
|
|
const int GameEventPacket::DEMO_PARAM_HINT_3 = 103;
|
|
|
|
// 4J Added
|
|
const int GameEventPacket::START_SAVING = 10;
|
|
const int GameEventPacket::STOP_SAVING = 11;
|
|
|
|
const int GameEventPacket::EVENT_LANGUAGE_ID[EVENT_LANGUAGE_ID_LENGTH] = {
|
|
IDS_TILE_BED_NOT_VALID, -1, -1, IDS_GAME_MODE_CHANGED, -1, -1};
|
|
|
|
GameEventPacket::GameEventPacket() {
|
|
this->_event = 0;
|
|
this->param = 0;
|
|
}
|
|
|
|
GameEventPacket::GameEventPacket(int _event, int param) {
|
|
this->_event = _event;
|
|
this->param = param;
|
|
}
|
|
|
|
void GameEventPacket::read(DataInputStream* dis) // throws IOException
|
|
{
|
|
_event = (int)dis->readByte();
|
|
param = (int)dis->readByte();
|
|
}
|
|
|
|
void GameEventPacket::write(DataOutputStream* dos) // throws IOException
|
|
{
|
|
dos->writeByte((uint8_t)_event);
|
|
dos->writeByte((uint8_t)param);
|
|
}
|
|
|
|
void GameEventPacket::handle(PacketListener* listener) {
|
|
listener->handleGameEvent(shared_from_this());
|
|
}
|
|
|
|
int GameEventPacket::getEstimatedSize() { return 2; }
|