|
@@ -1,9 +1,9 @@
|
|
-#include "NetworkResponse.h"
|
|
|
|
|
|
+#include "NetworkMessage.h"
|
|
#include "Chunk.h"
|
|
#include "Chunk.h"
|
|
#include "Entity.h"
|
|
#include "Entity.h"
|
|
#include "Game.h"
|
|
#include "Game.h"
|
|
|
|
|
|
-NetworkResponse::NetworkResponse()
|
|
|
|
|
|
+NetworkMessage::NetworkMessage()
|
|
{
|
|
{
|
|
adress = 0;
|
|
adress = 0;
|
|
adressLength = 0;
|
|
adressLength = 0;
|
|
@@ -12,17 +12,23 @@ NetworkResponse::NetworkResponse()
|
|
msgDelete = 0;
|
|
msgDelete = 0;
|
|
msgLength = 0;
|
|
msgLength = 0;
|
|
useBackground = 0;
|
|
useBackground = 0;
|
|
|
|
+ minPosition.x = std::numeric_limits<float>::min();
|
|
|
|
+ minPosition.y = std::numeric_limits<float>::min();
|
|
|
|
+ minPosition.z = std::numeric_limits<float>::min();
|
|
|
|
+ maxPosition.x = std::numeric_limits<float>::max();
|
|
|
|
+ maxPosition.y = std::numeric_limits<float>::max();
|
|
|
|
+ maxPosition.z = std::numeric_limits<float>::max();
|
|
affectedDimension = -1;
|
|
affectedDimension = -1;
|
|
}
|
|
}
|
|
|
|
|
|
-NetworkResponse::~NetworkResponse()
|
|
|
|
|
|
+NetworkMessage::~NetworkMessage()
|
|
{
|
|
{
|
|
if (msgDelete)
|
|
if (msgDelete)
|
|
delete[] message;
|
|
delete[] message;
|
|
delete[] adress;
|
|
delete[] adress;
|
|
}
|
|
}
|
|
|
|
|
|
-void NetworkResponse::adressChunck(Chunk* zChunk)
|
|
|
|
|
|
+void NetworkMessage::adressChunck(Chunk* zChunk)
|
|
{
|
|
{
|
|
adressLength = 10;
|
|
adressLength = 10;
|
|
adress = new char[adressLength];
|
|
adress = new char[adressLength];
|
|
@@ -36,7 +42,7 @@ void NetworkResponse::adressChunck(Chunk* zChunk)
|
|
affectedDimension = zChunk->getDimensionId();
|
|
affectedDimension = zChunk->getDimensionId();
|
|
}
|
|
}
|
|
|
|
|
|
-void NetworkResponse::adressEntity(Entity* zEntity)
|
|
|
|
|
|
+void NetworkMessage::adressEntity(Entity* zEntity)
|
|
{
|
|
{
|
|
adressLength = 6;
|
|
adressLength = 6;
|
|
adress = new char[adressLength];
|
|
adress = new char[adressLength];
|
|
@@ -48,7 +54,7 @@ void NetworkResponse::adressEntity(Entity* zEntity)
|
|
affectedDimension = zEntity->getCurrentDimensionId();
|
|
affectedDimension = zEntity->getCurrentDimensionId();
|
|
}
|
|
}
|
|
|
|
|
|
-void NetworkResponse::adressBlock(Block* zBlock)
|
|
|
|
|
|
+void NetworkMessage::adressBlock(Block* zBlock)
|
|
{
|
|
{
|
|
adressLength = 14;
|
|
adressLength = 14;
|
|
adress = new char[adressLength];
|
|
adress = new char[adressLength];
|
|
@@ -63,7 +69,7 @@ void NetworkResponse::adressBlock(Block* zBlock)
|
|
affectedDimension = zBlock->getDimensionId();
|
|
affectedDimension = zBlock->getDimensionId();
|
|
}
|
|
}
|
|
|
|
|
|
-void NetworkResponse::openDialog(Framework::Text dialogName)
|
|
|
|
|
|
+void NetworkMessage::openDialog(Framework::Text dialogName)
|
|
{
|
|
{
|
|
adressLength = (char)(4 + dialogName.getLength());
|
|
adressLength = (char)(4 + dialogName.getLength());
|
|
adress = new char[adressLength];
|
|
adress = new char[adressLength];
|
|
@@ -71,15 +77,9 @@ void NetworkResponse::openDialog(Framework::Text dialogName)
|
|
adress[1] = 0; // open dialog
|
|
adress[1] = 0; // open dialog
|
|
*(short*)(adress + 2) = (short)dialogName.getLength(); // block
|
|
*(short*)(adress + 2) = (short)dialogName.getLength(); // block
|
|
memcpy(adress + 4, dialogName.getText(), dialogName.getLength());
|
|
memcpy(adress + 4, dialogName.getText(), dialogName.getLength());
|
|
- minPosition.x = std::numeric_limits<float>::min();
|
|
|
|
- minPosition.y = std::numeric_limits<float>::min();
|
|
|
|
- minPosition.z = std::numeric_limits<float>::min();
|
|
|
|
- maxPosition.x = std::numeric_limits<float>::max();
|
|
|
|
- maxPosition.y = std::numeric_limits<float>::max();
|
|
|
|
- maxPosition.z = std::numeric_limits<float>::max();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-void NetworkResponse::adressGui(Framework::Text elementId)
|
|
|
|
|
|
+void NetworkMessage::adressGui(Framework::Text elementId)
|
|
{
|
|
{
|
|
adressLength = (char)(4 + elementId.getLength());
|
|
adressLength = (char)(4 + elementId.getLength());
|
|
adress = new char[adressLength];
|
|
adress = new char[adressLength];
|
|
@@ -87,60 +87,55 @@ void NetworkResponse::adressGui(Framework::Text elementId)
|
|
adress[1] = 1; // element message
|
|
adress[1] = 1; // element message
|
|
*(short*)(adress + 2) = (short)elementId.getLength(); // block
|
|
*(short*)(adress + 2) = (short)elementId.getLength(); // block
|
|
memcpy(adress + 4, elementId.getText(), elementId.getLength());
|
|
memcpy(adress + 4, elementId.getText(), elementId.getLength());
|
|
- minPosition.x = std::numeric_limits<float>::min();
|
|
|
|
- minPosition.y = std::numeric_limits<float>::min();
|
|
|
|
- minPosition.z = std::numeric_limits<float>::min();
|
|
|
|
- maxPosition.x = std::numeric_limits<float>::max();
|
|
|
|
- maxPosition.y = std::numeric_limits<float>::max();
|
|
|
|
- maxPosition.z = std::numeric_limits<float>::max();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-void NetworkResponse::setMessage(char* msg, int length, bool deleteMsg)
|
|
|
|
|
|
+void NetworkMessage::setMessage(char* msg, int length, bool deleteMsg)
|
|
{
|
|
{
|
|
message = msg;
|
|
message = msg;
|
|
msgLength = length;
|
|
msgLength = length;
|
|
msgDelete = deleteMsg;
|
|
msgDelete = deleteMsg;
|
|
}
|
|
}
|
|
|
|
|
|
-void NetworkResponse::setUseBackground()
|
|
|
|
|
|
+void NetworkMessage::setUseBackground()
|
|
{
|
|
{
|
|
useBackground = 1;
|
|
useBackground = 1;
|
|
}
|
|
}
|
|
|
|
|
|
-void NetworkResponse::sendToAll()
|
|
|
|
|
|
+void NetworkMessage::sendToAll()
|
|
{
|
|
{
|
|
broadcast = true;
|
|
broadcast = true;
|
|
}
|
|
}
|
|
|
|
|
|
-bool NetworkResponse::isAreaAffected(Framework::Vec3<float> min, Framework::Vec3<float> max, int affectedDimension) const
|
|
|
|
|
|
+bool NetworkMessage::isAreaAffected(Framework::Vec3<float> min, Framework::Vec3<float> max, int affectedDimension) const
|
|
{
|
|
{
|
|
return minPosition.x <= max.x && maxPosition.x >= min.x &&
|
|
return minPosition.x <= max.x && maxPosition.x >= min.x &&
|
|
minPosition.y <= max.y && maxPosition.y >= min.y &&
|
|
minPosition.y <= max.y && maxPosition.y >= min.y &&
|
|
minPosition.z <= max.z && maxPosition.z >= min.z && (this->affectedDimension < 0 || this->affectedDimension == affectedDimension);
|
|
minPosition.z <= max.z && maxPosition.z >= min.z && (this->affectedDimension < 0 || this->affectedDimension == affectedDimension);
|
|
}
|
|
}
|
|
|
|
|
|
-void NetworkResponse::writeTo(Framework::StreamWriter* zWriter) const
|
|
|
|
|
|
+void NetworkMessage::writeTo(Framework::StreamWriter* zWriter) const
|
|
{
|
|
{
|
|
int total = msgLength + adressLength;
|
|
int total = msgLength + adressLength;
|
|
if (total)
|
|
if (total)
|
|
{
|
|
{
|
|
|
|
+ zWriter->schreibe((char*)&GameClient::Message::API_MESSAGE, 1);
|
|
zWriter->schreibe((char*)&total, 4);
|
|
zWriter->schreibe((char*)&total, 4);
|
|
zWriter->schreibe(adress, adressLength);
|
|
zWriter->schreibe(adress, adressLength);
|
|
zWriter->schreibe(message, msgLength);
|
|
zWriter->schreibe(message, msgLength);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-bool NetworkResponse::isBroadcast() const
|
|
|
|
|
|
+bool NetworkMessage::isBroadcast() const
|
|
{
|
|
{
|
|
return broadcast;
|
|
return broadcast;
|
|
}
|
|
}
|
|
|
|
|
|
-bool NetworkResponse::isEmpty() const
|
|
|
|
|
|
+bool NetworkMessage::isEmpty() const
|
|
{
|
|
{
|
|
return msgLength + adressLength <= 0;
|
|
return msgLength + adressLength <= 0;
|
|
}
|
|
}
|
|
|
|
|
|
-bool NetworkResponse::isUseBackground() const
|
|
|
|
|
|
+bool NetworkMessage::isUseBackground() const
|
|
{
|
|
{
|
|
return useBackground;
|
|
return useBackground;
|
|
}
|
|
}
|