Merge pull request #714 from DarkflameUniverse/macro-formatting

Macro formatting consistency
This commit is contained in:
Aaron Kimbrell 2022-08-05 12:37:29 -05:00 committed by GitHub
commit d626ac1ed4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 335 additions and 332 deletions

View File

@ -1,2 +1,5 @@
# format codebase # format codebase
19e77a38d837ce781ba0ca6ea8e78b67a6e3b5a5 19e77a38d837ce781ba0ca6ea8e78b67a6e3b5a5
# add semi-colons to macros consistently
9e4ce24fd2851e65df776dd9c57bcb0d45f4453a

View File

@ -730,9 +730,9 @@ void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeader
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
//portion that will get routed: //portion that will get routed:
CMSGHEADER CMSGHEADER;
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
bitStream.Write(GAME_MSG::GAME_MSG_TEAM_INVITE_CONFIRM); bitStream.Write(GAME_MSG::GAME_MSG_TEAM_INVITE_CONFIRM);
bitStream.Write(bLeaderIsFreeTrial); bitStream.Write(bLeaderIsFreeTrial);
@ -757,9 +757,9 @@ void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderI
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
//portion that will get routed: //portion that will get routed:
CMSGHEADER CMSGHEADER;
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
bitStream.Write(GAME_MSG::GAME_MSG_TEAM_GET_STATUS_RESPONSE); bitStream.Write(GAME_MSG::GAME_MSG_TEAM_GET_STATUS_RESPONSE);
bitStream.Write(i64LeaderID); bitStream.Write(i64LeaderID);
@ -782,9 +782,9 @@ void ChatPacketHandler::SendTeamSetLeader(PlayerData* receiver, LWOOBJID i64Play
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
//portion that will get routed: //portion that will get routed:
CMSGHEADER CMSGHEADER;
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
bitStream.Write(GAME_MSG::GAME_MSG_TEAM_SET_LEADER); bitStream.Write(GAME_MSG::GAME_MSG_TEAM_SET_LEADER);
bitStream.Write(i64PlayerID); bitStream.Write(i64PlayerID);
@ -799,9 +799,9 @@ void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTria
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
//portion that will get routed: //portion that will get routed:
CMSGHEADER CMSGHEADER;
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
bitStream.Write(GAME_MSG::GAME_MSG_TEAM_ADD_PLAYER); bitStream.Write(GAME_MSG::GAME_MSG_TEAM_ADD_PLAYER);
bitStream.Write(bIsFreeTrial); bitStream.Write(bIsFreeTrial);
@ -828,9 +828,9 @@ void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
//portion that will get routed: //portion that will get routed:
CMSGHEADER CMSGHEADER;
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
bitStream.Write(GAME_MSG::GAME_MSG_TEAM_REMOVE_PLAYER); bitStream.Write(GAME_MSG::GAME_MSG_TEAM_REMOVE_PLAYER);
bitStream.Write(bDisband); bitStream.Write(bDisband);
@ -854,9 +854,9 @@ void ChatPacketHandler::SendTeamSetOffWorldFlag(PlayerData* receiver, LWOOBJID i
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
//portion that will get routed: //portion that will get routed:
CMSGHEADER CMSGHEADER;
bitStream.Write(receiver->playerID); bitStream.Write(receiver->playerID);
bitStream.Write(GAME_MSG::GAME_MSG_TEAM_SET_OFF_WORLD_FLAG); bitStream.Write(GAME_MSG::GAME_MSG_TEAM_SET_OFF_WORLD_FLAG);
bitStream.Write(i64PlayerID); bitStream.Write(i64PlayerID);

View File

@ -31,10 +31,10 @@ using namespace std;
void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const SystemAddress& sysAddr, LWOOBJID objectID, GAME_MSG messageID) { void GameMessageHandler::HandleMessage(RakNet::BitStream* inStream, const SystemAddress& sysAddr, LWOOBJID objectID, GAME_MSG messageID) {
CBITSTREAM CBITSTREAM;
// Get the entity // Get the entity
Entity* entity = EntityManager::Instance()->GetEntity(objectID); Entity* entity = EntityManager::Instance()->GetEntity(objectID);
User* usr = UserManager::Instance()->GetUser(sysAddr); User* usr = UserManager::Instance()->GetUser(sysAddr);

File diff suppressed because it is too large Load Diff

View File

@ -12,8 +12,8 @@
#include "dServer.h" #include "dServer.h"
void ChatPackets::SendChatMessage(const SystemAddress& sysAddr, char chatChannel, const std::string& senderName, LWOOBJID playerObjectID, bool senderMythran, const std::u16string& message) { void ChatPackets::SendChatMessage(const SystemAddress& sysAddr, char chatChannel, const std::string& senderName, LWOOBJID playerObjectID, bool senderMythran, const std::u16string& message) {
CBITSTREAM CBITSTREAM;
PacketUtils::WriteHeader(bitStream, CHAT, MSG_CHAT_GENERAL_CHAT_MESSAGE); PacketUtils::WriteHeader(bitStream, CHAT, MSG_CHAT_GENERAL_CHAT_MESSAGE);
bitStream.Write(static_cast<uint64_t>(0)); bitStream.Write(static_cast<uint64_t>(0));
bitStream.Write(chatChannel); bitStream.Write(chatChannel);
@ -30,12 +30,12 @@ void ChatPackets::SendChatMessage(const SystemAddress& sysAddr, char chatChannel
} }
bitStream.Write(static_cast<uint16_t>(0)); bitStream.Write(static_cast<uint16_t>(0));
SEND_PACKET_BROADCAST SEND_PACKET_BROADCAST;
} }
void ChatPackets::SendSystemMessage(const SystemAddress& sysAddr, const std::u16string& message, const bool broadcast) { void ChatPackets::SendSystemMessage(const SystemAddress& sysAddr, const std::u16string& message, const bool broadcast) {
CBITSTREAM CBITSTREAM;
PacketUtils::WriteHeader(bitStream, CHAT, MSG_CHAT_GENERAL_CHAT_MESSAGE); PacketUtils::WriteHeader(bitStream, CHAT, MSG_CHAT_GENERAL_CHAT_MESSAGE);
bitStream.Write(static_cast<uint64_t>(0)); bitStream.Write(static_cast<uint64_t>(0));
bitStream.Write(static_cast<char>(4)); bitStream.Write(static_cast<char>(4));

View File

@ -8,8 +8,8 @@
#include <string> #include <string>
void MasterPackets::SendPersistentIDRequest(dServer* server, uint64_t requestID) { void MasterPackets::SendPersistentIDRequest(dServer* server, uint64_t requestID) {
CBITSTREAM CBITSTREAM;
PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_REQUEST_PERSISTENT_ID); PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_REQUEST_PERSISTENT_ID);
bitStream.Write(requestID); bitStream.Write(requestID);
server->SendToMaster(&bitStream); server->SendToMaster(&bitStream);
} }

View File

@ -34,7 +34,7 @@ void WorldPackets::SendLoadStaticZone(const SystemAddress& sysAddr, float x, flo
bitStream.Write(static_cast<uint32_t>(0)); // Change this to eventually use 4 on activity worlds bitStream.Write(static_cast<uint32_t>(0)); // Change this to eventually use 4 on activity worlds
SEND_PACKET SEND_PACKET;
} }
void WorldPackets::SendCharacterList(const SystemAddress& sysAddr, User* user) { void WorldPackets::SendCharacterList(const SystemAddress& sysAddr, User* user) {
@ -85,28 +85,28 @@ void WorldPackets::SendCharacterList(const SystemAddress& sysAddr, User* user) {
} }
} }
SEND_PACKET SEND_PACKET;
} }
void WorldPackets::SendCharacterCreationResponse(const SystemAddress& sysAddr, eCreationResponse response) { void WorldPackets::SendCharacterCreationResponse(const SystemAddress& sysAddr, eCreationResponse response) {
RakNet::BitStream bitStream; RakNet::BitStream bitStream;
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_CHARACTER_CREATE_RESPONSE); PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_CHARACTER_CREATE_RESPONSE);
bitStream.Write(response); bitStream.Write(response);
SEND_PACKET SEND_PACKET;
} }
void WorldPackets::SendCharacterRenameResponse(const SystemAddress& sysAddr, eRenameResponse response) { void WorldPackets::SendCharacterRenameResponse(const SystemAddress& sysAddr, eRenameResponse response) {
RakNet::BitStream bitStream; RakNet::BitStream bitStream;
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_CHARACTER_RENAME_RESPONSE); PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_CHARACTER_RENAME_RESPONSE);
bitStream.Write(response); bitStream.Write(response);
SEND_PACKET SEND_PACKET;
} }
void WorldPackets::SendCharacterDeleteResponse(const SystemAddress& sysAddr, bool response) { void WorldPackets::SendCharacterDeleteResponse(const SystemAddress& sysAddr, bool response) {
RakNet::BitStream bitStream; RakNet::BitStream bitStream;
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_DELETE_CHARACTER_RESPONSE); PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_DELETE_CHARACTER_RESPONSE);
bitStream.Write(static_cast<uint8_t>(response)); bitStream.Write(static_cast<uint8_t>(response));
SEND_PACKET SEND_PACKET;
} }
void WorldPackets::SendTransferToWorld(const SystemAddress& sysAddr, const std::string& serverIP, uint32_t serverPort, bool mythranShift) { void WorldPackets::SendTransferToWorld(const SystemAddress& sysAddr, const std::string& serverIP, uint32_t serverPort, bool mythranShift) {
@ -117,14 +117,14 @@ void WorldPackets::SendTransferToWorld(const SystemAddress& sysAddr, const std::
bitStream.Write(static_cast<uint16_t>(serverPort)); bitStream.Write(static_cast<uint16_t>(serverPort));
bitStream.Write(static_cast<uint8_t>(mythranShift)); bitStream.Write(static_cast<uint8_t>(mythranShift));
SEND_PACKET SEND_PACKET;
} }
void WorldPackets::SendServerState(const SystemAddress& sysAddr) { void WorldPackets::SendServerState(const SystemAddress& sysAddr) {
RakNet::BitStream bitStream; RakNet::BitStream bitStream;
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_SERVER_STATES); PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_SERVER_STATES);
bitStream.Write(static_cast<uint8_t>(1)); //If the server is receiving this request, it probably is ready anyway. bitStream.Write(static_cast<uint8_t>(1)); //If the server is receiving this request, it probably is ready anyway.
SEND_PACKET SEND_PACKET;
} }
void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, Entity* entity, const std::string& xmlData, const std::u16string& username, int32_t gm) { void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, Entity* entity, const std::string& xmlData, const std::u16string& username, int32_t gm) {
@ -184,13 +184,13 @@ void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, Entity* ent
#endif #endif
PacketUtils::SavePacket("chardata.bin", (const char*)bitStream.GetData(), static_cast<uint32_t>(bitStream.GetNumberOfBytesUsed())); PacketUtils::SavePacket("chardata.bin", (const char*)bitStream.GetData(), static_cast<uint32_t>(bitStream.GetNumberOfBytesUsed()));
SEND_PACKET SEND_PACKET;
Game::logger->Log("WorldPackets", "Sent CreateCharacter for ID: %llu", entity->GetObjectID()); Game::logger->Log("WorldPackets", "Sent CreateCharacter for ID: %llu", entity->GetObjectID());
} }
void WorldPackets::SendChatModerationResponse(const SystemAddress& sysAddr, bool requestAccepted, uint32_t requestID, const std::string& receiver, std::vector<std::pair<uint8_t, uint8_t>> unacceptedItems) { void WorldPackets::SendChatModerationResponse(const SystemAddress& sysAddr, bool requestAccepted, uint32_t requestID, const std::string& receiver, std::vector<std::pair<uint8_t, uint8_t>> unacceptedItems) {
CBITSTREAM CBITSTREAM;
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_CHAT_MODERATION_STRING); PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_CHAT_MODERATION_STRING);
bitStream.Write<uint8_t>(unacceptedItems.empty()); // Is sentence ok? bitStream.Write<uint8_t>(unacceptedItems.empty()); // Is sentence ok?
bitStream.Write<uint16_t>(0x16); // Source ID, unknown bitStream.Write<uint16_t>(0x16); // Source ID, unknown
@ -209,17 +209,17 @@ void WorldPackets::SendChatModerationResponse(const SystemAddress& sysAddr, bool
bitStream.Write<uint16_t>(0); bitStream.Write<uint16_t>(0);
} }
SEND_PACKET SEND_PACKET;
} }
void WorldPackets::SendGMLevelChange(const SystemAddress& sysAddr, bool success, uint8_t highestLevel, uint8_t prevLevel, uint8_t newLevel) { void WorldPackets::SendGMLevelChange(const SystemAddress& sysAddr, bool success, uint8_t highestLevel, uint8_t prevLevel, uint8_t newLevel) {
CBITSTREAM CBITSTREAM;
PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_MAKE_GM_RESPONSE); PacketUtils::WriteHeader(bitStream, CLIENT, MSG_CLIENT_MAKE_GM_RESPONSE);
bitStream.Write<uint8_t>(success); bitStream.Write<uint8_t>(success);
bitStream.Write<uint16_t>(highestLevel); bitStream.Write<uint16_t>(highestLevel);
bitStream.Write<uint16_t>(prevLevel); bitStream.Write<uint16_t>(prevLevel);
bitStream.Write<uint16_t>(newLevel); bitStream.Write<uint16_t>(newLevel);
SEND_PACKET SEND_PACKET;
} }

View File

@ -772,9 +772,9 @@ void HandlePacket(Packet* packet) {
Game::logger->Log("MasterServer", "Got affirmation request of transfer %llu", requestID); Game::logger->Log("MasterServer", "Got affirmation request of transfer %llu", requestID);
CBITSTREAM CBITSTREAM;
PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_AFFIRM_TRANSFER_RESPONSE); PacketUtils::WriteHeader(bitStream, MASTER, MSG_MASTER_AFFIRM_TRANSFER_RESPONSE);
bitStream.Write(requestID); bitStream.Write(requestID);
Game::server->SendToMaster(&bitStream); Game::server->SendToMaster(&bitStream);

View File

@ -14,47 +14,47 @@ std::unique_ptr<AMFValue> ReadFromBitStream(RakNet::BitStream* bitStream) {
} }
int ReadAMFUndefinedFromBitStream() { int ReadAMFUndefinedFromBitStream() {
CBITSTREAM CBITSTREAM;
bitStream.Write<uint8_t>(0x00); bitStream.Write<uint8_t>(0x00);
std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream)); std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream));
ASSERT_EQ(res->GetValueType(), AMFValueType::AMFUndefined); ASSERT_EQ(res->GetValueType(), AMFValueType::AMFUndefined);
return 0; return 0;
} }
int ReadAMFNullFromBitStream() { int ReadAMFNullFromBitStream() {
CBITSTREAM CBITSTREAM;
bitStream.Write<uint8_t>(0x01); bitStream.Write<uint8_t>(0x01);
std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream)); std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream));
ASSERT_EQ(res->GetValueType(), AMFValueType::AMFNull); ASSERT_EQ(res->GetValueType(), AMFValueType::AMFNull);
return 0; return 0;
} }
int ReadAMFFalseFromBitStream() { int ReadAMFFalseFromBitStream() {
CBITSTREAM CBITSTREAM;
bitStream.Write<uint8_t>(0x02); bitStream.Write<uint8_t>(0x02);
std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream)); std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream));
ASSERT_EQ(res->GetValueType(), AMFValueType::AMFFalse); ASSERT_EQ(res->GetValueType(), AMFValueType::AMFFalse);
return 0; return 0;
} }
int ReadAMFTrueFromBitStream() { int ReadAMFTrueFromBitStream() {
CBITSTREAM CBITSTREAM;
bitStream.Write<uint8_t>(0x03); bitStream.Write<uint8_t>(0x03);
std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream)); std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream));
ASSERT_EQ(res->GetValueType(), AMFValueType::AMFTrue); ASSERT_EQ(res->GetValueType(), AMFValueType::AMFTrue);
return 0; return 0;
} }
int ReadAMFIntegerFromBitStream() { int ReadAMFIntegerFromBitStream() {
CBITSTREAM CBITSTREAM;
{ {
bitStream.Write<uint8_t>(0x04); bitStream.Write<uint8_t>(0x04);
// 127 == 01111111 // 127 == 01111111
bitStream.Write<uint8_t>(127); bitStream.Write<uint8_t>(127);
std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream)); std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream));
ASSERT_EQ(res->GetValueType(), AMFValueType::AMFInteger); ASSERT_EQ(res->GetValueType(), AMFValueType::AMFInteger);
// Check that the max value of a byte can be read correctly // Check that the max value of a byte can be read correctly
ASSERT_EQ(static_cast<AMFIntegerValue*>(res.get())->GetIntegerValue(), 127); ASSERT_EQ(static_cast<AMFIntegerValue*>(res.get())->GetIntegerValue(), 127);
} }
bitStream.Reset(); bitStream.Reset();
{ {
@ -95,8 +95,8 @@ int ReadAMFIntegerFromBitStream() {
} }
int ReadAMFDoubleFromBitStream() { int ReadAMFDoubleFromBitStream() {
CBITSTREAM CBITSTREAM;
bitStream.Write<uint8_t>(0x05); bitStream.Write<uint8_t>(0x05);
bitStream.Write<double>(25346.4f); bitStream.Write<double>(25346.4f);
std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream)); std::unique_ptr<AMFValue> res(ReadFromBitStream(&bitStream));
ASSERT_EQ(res->GetValueType(), AMFValueType::AMFDouble); ASSERT_EQ(res->GetValueType(), AMFValueType::AMFDouble);
@ -105,8 +105,8 @@ int ReadAMFDoubleFromBitStream() {
} }
int ReadAMFStringFromBitStream() { int ReadAMFStringFromBitStream() {
CBITSTREAM CBITSTREAM;
bitStream.Write<uint8_t>(0x06); bitStream.Write<uint8_t>(0x06);
bitStream.Write<uint8_t>(0x0F); bitStream.Write<uint8_t>(0x0F);
std::string toWrite = "stateID"; std::string toWrite = "stateID";
for (auto e : toWrite) bitStream.Write<char>(e); for (auto e : toWrite) bitStream.Write<char>(e);
@ -117,9 +117,9 @@ int ReadAMFStringFromBitStream() {
} }
int ReadAMFArrayFromBitStream() { int ReadAMFArrayFromBitStream() {
CBITSTREAM CBITSTREAM;
// Test empty AMFArray // Test empty AMFArray
bitStream.Write<uint8_t>(0x09); bitStream.Write<uint8_t>(0x09);
bitStream.Write<uint8_t>(0x01); bitStream.Write<uint8_t>(0x01);
bitStream.Write<uint8_t>(0x01); bitStream.Write<uint8_t>(0x01);
{ {