DarkflameServer/dGame/dGameMessages/RequestServerProjectileImpact.h
David Markowitz fc75d6048f
dGame Precompiled header improvements (#876)
* moving branch

* Add deleteinven slash command

* Change name of BRICKS_IN_BBB

* Use string_view instead of strcmp

* Clean up include tree

* Remove unneeded headers from PCH files

Removes unneeded headers from pre-compiled headers.  This increases compile time, however reduces development time for most files.

* Update Entity.h

* Update EntityManager.h

* Update GameMessages.cpp

* There it compiles now

Co-authored-by: Aaron Kimbrell <aronwk.aaron@gmail.com>
2023-01-06 23:17:05 -06:00

75 lines
2.0 KiB
C++

#ifndef __REQUESTSERVERPROJECTILEIMPACT__H__
#define __REQUESTSERVERPROJECTILEIMPACT__H__
#include "dCommonVars.h"
#include "dMessageIdentifiers.h"
/* Notifying the server that a locally owned projectile impacted. Sent to the caster of the projectile
should always be the local char. */
class RequestServerProjectileImpact {
static const GAME_MSG MsgID = GAME_MSG_REQUEST_SERVER_PROJECTILE_IMPACT;
public:
RequestServerProjectileImpact() {
i64LocalID = LWOOBJID_EMPTY;
i64TargetID = LWOOBJID_EMPTY;
}
RequestServerProjectileImpact(std::string _sBitStream, LWOOBJID _i64LocalID = LWOOBJID_EMPTY, LWOOBJID _i64TargetID = LWOOBJID_EMPTY) {
i64LocalID = _i64LocalID;
i64TargetID = _i64TargetID;
sBitStream = _sBitStream;
}
RequestServerProjectileImpact(RakNet::BitStream* stream) : RequestServerProjectileImpact() {
Deserialize(stream);
}
~RequestServerProjectileImpact() {
}
void Serialize(RakNet::BitStream* stream) {
stream->Write(MsgID);
stream->Write(i64LocalID != LWOOBJID_EMPTY);
if (i64LocalID != LWOOBJID_EMPTY) stream->Write(i64LocalID);
stream->Write(i64TargetID != LWOOBJID_EMPTY);
if (i64TargetID != LWOOBJID_EMPTY) stream->Write(i64TargetID);
uint32_t sBitStreamLength = sBitStream.length();
stream->Write(sBitStreamLength);
for (uint32_t k = 0; k < sBitStreamLength; k++) {
stream->Write(sBitStream[k]);
}
}
bool Deserialize(RakNet::BitStream* stream) {
bool i64LocalIDIsDefault{};
stream->Read(i64LocalIDIsDefault);
if (i64LocalIDIsDefault != 0) stream->Read(i64LocalID);
bool i64TargetIDIsDefault{};
stream->Read(i64TargetIDIsDefault);
if (i64TargetIDIsDefault != 0) stream->Read(i64TargetID);
uint32_t sBitStreamLength{};
stream->Read(sBitStreamLength);
for (uint32_t k = 0; k < sBitStreamLength; k++) {
unsigned char character;
stream->Read(character);
sBitStream.push_back(character);
}
return true;
}
LWOOBJID i64LocalID;
LWOOBJID i64TargetID;
std::string sBitStream;
};
#endif //!__REQUESTSERVERPROJECTILEIMPACT__H__