Compare commits
No commits in common. "fe021e3b8aa65e545d97075110c5804decc0f1bc" and "5bce1b7d2a7a58d2f29c3836be7a2c281aaabc4c" have entirely different histories.
fe021e3b8a
...
5bce1b7d2a
@ -12,10 +12,6 @@ DestroyMsg::DestroyMsg(char* buffer) {}
|
||||
DestroyMsg::~DestroyMsg() {}
|
||||
|
||||
unsigned char DestroyMsg::Serialize(char *buffer) {
|
||||
#if defined(DEBUG)
|
||||
std::cout << "Send DestroyMsg [" << (int)this->networkId << "/" << (int)this->thingId
|
||||
<< "] " << std::endl;
|
||||
#endif
|
||||
unsigned char ix = 0;
|
||||
buffer[ix++] = this->id;
|
||||
buffer[ix++] = this->networkId;
|
||||
|
@ -14,10 +14,6 @@ InvestigateMsg::InvestigateMsg(unsigned char networkId, unsigned char thingId) {
|
||||
|
||||
InvestigateMsg::~InvestigateMsg() {}
|
||||
unsigned char InvestigateMsg::Serialize(char* buffer) {
|
||||
#if defined(DEBUG)
|
||||
std::cout << "Send InvestigateMsg [" << (int)this->networkId << "/" << (int)this->thingId
|
||||
<< "] " << std::endl;
|
||||
#endif
|
||||
unsigned char ix = 0;
|
||||
buffer[ix++] = this->id;
|
||||
buffer[ix++] = this->networkId;
|
||||
|
@ -22,23 +22,21 @@ ModelUrlMsg::ModelUrlMsg(unsigned char networkId, Thing* thing) {
|
||||
else
|
||||
this->urlLength = (unsigned char)strlen(thing->modelUrl);
|
||||
|
||||
// this->url = thing->modelUrl; // dangerous!
|
||||
//this->url = thing->modelUrl; // dangerous!
|
||||
|
||||
// the url string in the buffer is not \0 terminated!
|
||||
char* url = new char[this->urlLength + 1];
|
||||
for (int i = 0; i < this->urlLength; i++)
|
||||
url[i] = thing->modelUrl[i];
|
||||
url[this->urlLength] = '\0';
|
||||
this->url = url;
|
||||
}
|
||||
this->url = url;}
|
||||
|
||||
ModelUrlMsg::ModelUrlMsg(const char* buffer) {
|
||||
unsigned char ix = 1; // first byte is msg id
|
||||
this->networkId = buffer[ix++];
|
||||
this->thingId = buffer[ix++];
|
||||
this->urlLength = buffer[ix++];
|
||||
// this->url = &buffer[ix]; // dangerous! name should not be used anymore
|
||||
// after
|
||||
// this->url = &buffer[ix]; // dangerous! name should not be used anymore after
|
||||
// // buffer has been re-used...
|
||||
|
||||
// the url string in the buffer is not \0 terminated!
|
||||
@ -56,11 +54,6 @@ ModelUrlMsg::~ModelUrlMsg() {
|
||||
unsigned char ModelUrlMsg::Serialize(char* buffer) {
|
||||
if (this->urlLength == 0 || this->url == nullptr)
|
||||
return 0;
|
||||
#if defined(DEBUG)
|
||||
std::cout << "Send ModelUrlMsg [" << (int)this->networkId << "/"
|
||||
<< (int)this->thingId << "] " << (int)this->urlLength << " "
|
||||
<< this->url << std::endl;
|
||||
#endif
|
||||
unsigned char ix = 0;
|
||||
buffer[ix++] = this->id;
|
||||
buffer[ix++] = this->networkId;
|
||||
|
@ -42,11 +42,6 @@ unsigned char NameMsg::Serialize(char* buffer) {
|
||||
if (this->nameLength == 0 || this->name == nullptr)
|
||||
return 0;
|
||||
|
||||
#if defined(DEBUG)
|
||||
std::cout << "Send NameMsg [" << (int)this->networkId << "/"
|
||||
<< (int)this->thingId << "] " << (int)this->nameLength << " "
|
||||
<< this->name << std::endl;
|
||||
#endif
|
||||
unsigned char ix = 0;
|
||||
buffer[ix++] = this->id;
|
||||
buffer[ix++] = this->networkId;
|
||||
|
@ -13,19 +13,13 @@ ParticipantMsg::ParticipantMsg(const char* buffer) {
|
||||
ParticipantMsg::~ParticipantMsg() {}
|
||||
|
||||
unsigned char ParticipantMsg::Serialize(char* buffer) {
|
||||
#if defined(DEBUG)
|
||||
std::cout << "Send ParticipantMsg [" << (int)this->networkId << "] "
|
||||
<< std::endl;
|
||||
#endif
|
||||
|
||||
unsigned char ix = 0;
|
||||
buffer[ix++] = this->id;
|
||||
buffer[ix++] = this->networkId;
|
||||
return ParticipantMsg::length;
|
||||
}
|
||||
|
||||
// bool ParticipantMsg::Send(ParticipantUDP *participant, unsigned char
|
||||
// networkId) {
|
||||
// bool ParticipantMsg::Send(ParticipantUDP *participant, unsigned char networkId) {
|
||||
// ParticipantMsg msg = ParticipantMsg()
|
||||
// }
|
||||
// Client Msg
|
||||
|
@ -45,10 +45,6 @@ unsigned char PoseMsg::Serialize(char* buffer) {
|
||||
if (this->poseType == 0)
|
||||
return 0;
|
||||
|
||||
#if defined(DEBUG)
|
||||
std::cout << "Send PoseMsg [" << (int)this->networkId << "/"
|
||||
<< (int)this->thingId << "] " << (int)this->poseType << std::endl;
|
||||
#endif
|
||||
unsigned char ix = 0;
|
||||
buffer[ix++] = PoseMsg::id;
|
||||
buffer[ix++] = this->networkId;
|
||||
|
@ -13,9 +13,6 @@ SiteMsg::SiteMsg(unsigned char networkId) {
|
||||
SiteMsg::~SiteMsg() {}
|
||||
|
||||
unsigned char SiteMsg::Serialize(char* buffer) {
|
||||
#if defined(DEBUG)
|
||||
std::cout << "Send SiteMsg [" << (int)this->networkId << "] " << std::endl;
|
||||
#endif
|
||||
unsigned char ix = 0;
|
||||
buffer[ix++] = this->id;
|
||||
buffer[ix++] = this->networkId;
|
||||
|
@ -24,9 +24,6 @@ unsigned char TextMsg::Serialize(char* buffer) {
|
||||
if (this->textLength == 0 || this->text == nullptr)
|
||||
return 0;
|
||||
|
||||
#if defined(DEBUG)
|
||||
std::cout << "Send TextMsg " << (int)this->textLength << " " << this->text << std::endl;
|
||||
#endif
|
||||
unsigned char ix = 0;
|
||||
buffer[ix++] = this->id;
|
||||
buffer[ix++] = this->textLength;
|
||||
|
Loading…
x
Reference in New Issue
Block a user