diff --git a/Minecraft.World/Exceptions.h b/Minecraft.World/Exceptions.h index 8aabb94a3..2a167732c 100644 --- a/Minecraft.World/Exceptions.h +++ b/Minecraft.World/Exceptions.h @@ -1,7 +1,5 @@ #pragma once -// izzint - TODO: these other exceptions should really be implemented - class EOFException : public std::runtime_error { public: diff --git a/Minecraft.World/Packet.cpp b/Minecraft.World/Packet.cpp index 0a080f0cf..96efd2e63 100644 --- a/Minecraft.World/Packet.cpp +++ b/Minecraft.World/Packet.cpp @@ -152,15 +152,13 @@ void Packet::staticCtor() map(255, true, true, true, false, typeid(DisconnectPacket), DisconnectPacket::create); } -IllegalArgumentException::IllegalArgumentException(const wstring& information) -{ - this->information = information; -} +IllegalArgumentException::IllegalArgumentException(const wstring &info) : std::runtime_error("IllegalArgumentException"), information(info) {} -IOException::IOException(const wstring &info) : std::runtime_error("IOException") -{ - this->information = info; -} +EOFException::EOFException(const wstring &info) : std::runtime_error("EOFException"), information(info) {} + +IOException::IOException(const wstring &info) : std::runtime_error("IOException"), information(info) {} + +RuntimeException::RuntimeException(const wstring &info) : std::runtime_error("RuntimeException"), information(info) {} Packet::Packet() : createTime( System::currentTimeMillis() ) { @@ -282,12 +280,7 @@ byteArray Packet::readBytes(DataInputStream *datainputstream) int size = datainputstream->readShort(); if (size < 0) { - app.DebugPrintf("Key was smaller than nothing! Weird key!"); -#ifndef _CONTENT_PACKAGE - __debugbreak(); -#endif - return byteArray(); - //throw new IOException("Key was smaller than nothing! Weird key!"); + throw IOException(L"Key was smaller than nothing! Weird key!"); } byteArray bytes(size); @@ -296,7 +289,6 @@ byteArray Packet::readBytes(DataInputStream *datainputstream) return bytes; } - bool Packet::canSendToAnyClient(shared_ptr packet) { int packetId = packet->getId(); @@ -329,14 +321,14 @@ shared_ptr Packet::readPacket(DataInputStream *dis, bool isServer) // th if ((isServer && serverReceivedPackets.find(id) == serverReceivedPackets.end()) || (!isServer && clientReceivedPackets.find(id) == clientReceivedPackets.end())) { - //app.DebugPrintf("Bad packet id %d\n", id); - __debugbreak(); - assert(false); - // throw new IOException(wstring(L"Bad packet id ") + std::to_wstring(id)); + throw IOException(wstring(L"Bad packet id ") + std::to_wstring(id)); } packet = getPacket(id); - if (packet == NULL) assert(false);//throw new IOException(wstring(L"Bad packet id ") + std::to_wstring(id)); + if (packet == nullptr) + { + throw IOException(wstring(L"Bad packet id ") + std::to_wstring(id)); + } //app.DebugPrintf("%s reading packet %d\n", isServer ? "Server" : "Client", packet->getId()); packet->read(dis);