style: clang-format the entire project

This commit is contained in:
MatthewBeshay
2026-04-09 10:17:55 +10:00
parent 81c2eb82f0
commit cd4b39cf88
803 changed files with 6092 additions and 6095 deletions

View File

@@ -1,6 +1,3 @@
#include "minecraft/IGameServices.h"
#include "minecraft/GameHostOptions.h"
#include "minecraft/util/Log.h"
#include "PlayerConnection.h"
#include <wchar.h>
@@ -11,26 +8,26 @@
#include <format>
#include <utility>
#include "minecraft/GameEnums.h"
#include "minecraft/Console_Debug_enum.h"
#include "minecraft/world/level/dlc/DLCConstants.h"
#include "app/common/DLC/DLCSkinFile.h"
#include "minecraft/network/INetworkService.h"
#include "minecraft/network/platform/NetworkPlayerInterface.h"
#include "app/common/Network/Socket.h"
#include "minecraft/client/model/SkinBox.h"
#include "ServerConnection.h"
#include "app/common/DLC/DLCSkinFile.h"
#include "app/common/Network/Socket.h"
#include "java/Class.h"
#include "java/InputOutputStream/ByteArrayInputStream.h"
#include "java/InputOutputStream/DataInputStream.h"
#include "java/JavaMath.h"
#include "java/Random.h"
#include "java/System.h"
#include "minecraft/Console_Debug_enum.h"
#include "minecraft/Facing.h"
#include "minecraft/GameEnums.h"
#include "minecraft/GameHostOptions.h"
#include "minecraft/IGameServices.h"
#include "minecraft/SharedConstants.h"
#include "minecraft/client/model/SkinBox.h"
#include "minecraft/commands/CommandDispatcher.h"
#include "minecraft/commands/CommandsEnum.h"
#include "minecraft/network/Connection.h"
#include "minecraft/network/INetworkService.h"
#include "minecraft/network/packet/AnimatePacket.h"
#include "minecraft/network/packet/ChatPacket.h"
#include "minecraft/network/packet/ClientCommandPacket.h"
@@ -65,12 +62,14 @@
#include "minecraft/network/packet/TileUpdatePacket.h"
#include "minecraft/network/packet/TradeItemPacket.h"
#include "minecraft/network/packet/UseItemPacket.h"
#include "minecraft/network/platform/NetworkPlayerInterface.h"
#include "minecraft/server/MinecraftServer.h"
#include "minecraft/server/PlayerList.h"
#include "minecraft/server/level/ServerLevel.h"
#include "minecraft/server/level/ServerPlayer.h"
#include "minecraft/server/level/ServerPlayerGameMode.h"
#include "minecraft/stats/GenericStats.h"
#include "minecraft/util/Log.h"
#include "minecraft/world/entity/Entity.h"
#include "minecraft/world/entity/animal/EntityHorse.h"
#include "minecraft/world/entity/item/ItemEntity.h"
@@ -96,6 +95,7 @@
#include "minecraft/world/level/Level.h"
#include "minecraft/world/level/LevelSettings.h"
#include "minecraft/world/level/dimension/Dimension.h"
#include "minecraft/world/level/dlc/DLCConstants.h"
#include "minecraft/world/level/saveddata/MapItemSavedData.h"
#include "minecraft/world/level/tile/Tile.h"
#include "minecraft/world/level/tile/entity/BeaconTileEntity.h"
@@ -138,8 +138,10 @@ PlayerConnection::PlayerConnection(MinecraftServer* server,
m_onlineXUID = INVALID_XUID;
m_bHasClientTickedOnce = false;
setShowOnMaps(
gameServices().getGameHostOption(eGameHostOption_Gamertags) != 0 ? true : false);
setShowOnMaps(gameServices().getGameHostOption(eGameHostOption_Gamertags) !=
0
? true
: false);
}
PlayerConnection::~PlayerConnection() { delete connection; }
@@ -383,8 +385,7 @@ void PlayerConnection::handleMovePlayer(
#if !defined(_CONTENT_PACKAGE)
printf("%s moved wrongly!\n", player->name.c_str());
Log::info("Got position %f, %f, %f\n", xt, yt, zt);
Log::info("Expected %f, %f, %f\n", player->x, player->y,
player->z);
Log::info("Expected %f, %f, %f\n", player->x, player->y, player->z);
#endif
}
player->absMoveTo(xt, yt, zt, yRotT, xRotT);
@@ -407,7 +408,7 @@ void PlayerConnection::handleMovePlayer(
// kicked for floating too long!");
#if !defined(_CONTENT_PACKAGE)
printf("%s was kicked for floating too long!\n",
player->name.c_str());
player->name.c_str());
#endif
disconnect(DisconnectPacket::eDisconnect_NoFlying);
return;
@@ -720,8 +721,8 @@ void PlayerConnection::handlePlayerCommand(
}
} else if (packet->action == PlayerCommandPacket::OPEN_INVENTORY) {
// also only supported by horses...
if ((player->riding != nullptr) &&
player->riding->instanceof(eTYPE_HORSE)) {
if ((player->riding != nullptr) && player->riding->instanceof
(eTYPE_HORSE)) {
std::dynamic_pointer_cast<EntityHorse>(player->riding)
->openInventory(player);
}
@@ -809,11 +810,12 @@ void PlayerConnection::handleTexture(std::shared_ptr<TexturePacket> packet) {
// Request for texture
#if !defined(_CONTENT_PACKAGE)
printf("Server received request for custom texture %s\n",
packet->textureName.c_str());
packet->textureName.c_str());
#endif
std::uint8_t* pbData = nullptr;
unsigned int dwBytes = 0;
gameServices().getMemFileDetails(packet->textureName, &pbData, &dwBytes);
gameServices().getMemFileDetails(packet->textureName, &pbData,
&dwBytes);
if (dwBytes != 0) {
send(std::shared_ptr<TexturePacket>(
@@ -825,10 +827,10 @@ void PlayerConnection::handleTexture(std::shared_ptr<TexturePacket> packet) {
// Response with texture data
#if !defined(_CONTENT_PACKAGE)
printf("Server received custom texture %s\n",
packet->textureName.c_str());
packet->textureName.c_str());
#endif
gameServices().addMemoryTextureFile(packet->textureName, packet->pbData,
packet->dataBytes);
packet->dataBytes);
server->connection->handleTextureReceived(packet->textureName);
}
}
@@ -842,11 +844,12 @@ void PlayerConnection::handleTextureAndGeometry(
// Request for texture and geometry
#if !defined(_CONTENT_PACKAGE)
printf("Server received request for custom texture %s\n",
packet->textureName.c_str());
packet->textureName.c_str());
#endif
std::uint8_t* pbData = nullptr;
unsigned int dwTextureBytes = 0;
gameServices().getMemFileDetails(packet->textureName, &pbData, &dwTextureBytes);
gameServices().getMemFileDetails(packet->textureName, &pbData,
&dwTextureBytes);
DLCSkinFile* pDLCSkinFile =
gameServices().getDLCSkinFile(packet->textureName);
@@ -882,23 +885,23 @@ void PlayerConnection::handleTextureAndGeometry(
// Response with texture and geometry data
#if !defined(_CONTENT_PACKAGE)
printf("Server received custom texture %s and geometry\n",
packet->textureName.c_str());
packet->textureName.c_str());
#endif
gameServices().addMemoryTextureFile(packet->textureName, packet->pbData,
packet->dwTextureBytes);
packet->dwTextureBytes);
// add the geometry to the app list
if (packet->dwBoxC != 0) {
#if !defined(_CONTENT_PACKAGE)
printf("Adding skin boxes for skin id %X, box count %d\n",
packet->dwSkinID, packet->dwBoxC);
packet->dwSkinID, packet->dwBoxC);
#endif
gameServices().setAdditionalSkinBoxes(packet->dwSkinID, packet->BoxDataA,
packet->dwBoxC);
gameServices().setAdditionalSkinBoxes(
packet->dwSkinID, packet->BoxDataA, packet->dwBoxC);
}
// Add the anim override
gameServices().setAnimOverrideBitmask(packet->dwSkinID,
packet->uiAnimOverrideBitmask);
packet->uiAnimOverrideBitmask);
player->setCustomSkin(packet->dwSkinID);
@@ -945,7 +948,8 @@ void PlayerConnection::handleTextureAndGeometryReceived(
textureName, pbData, dwTextureBytes, pDLCSkinFile)));
} else {
// get the data from the app
std::uint32_t dwSkinID = gameServices().getSkinIdFromPath(textureName);
std::uint32_t dwSkinID =
gameServices().getSkinIdFromPath(textureName);
std::vector<SKIN_BOX*>* pvSkinBoxes =
gameServices().getAdditionalSkinBoxes(dwSkinID);
unsigned int uiAnimOverrideBitmask =
@@ -965,11 +969,12 @@ void PlayerConnection::handleTextureChange(
std::shared_ptr<TextureChangePacket> packet) {
switch (packet->action) {
case TextureChangePacket::e_TextureChange_Skin:
player->setCustomSkin(gameServices().getSkinIdFromPath(packet->path));
player->setCustomSkin(
gameServices().getSkinIdFromPath(packet->path));
#if !defined(_CONTENT_PACKAGE)
printf("Skin for server player %s has changed to %s (%d)\n",
player->name.c_str(), player->customTextureUrl.c_str(),
static_cast<int>(player->getPlayerDefaultSkin()));
player->name.c_str(), player->customTextureUrl.c_str(),
static_cast<int>(player->getPlayerDefaultSkin()));
#endif
break;
case TextureChangePacket::e_TextureChange_Cape:
@@ -977,7 +982,7 @@ void PlayerConnection::handleTextureChange(
// player->customTextureUrl2 = packet->path;
#if !defined(_CONTENT_PACKAGE)
printf("Cape for server player %s has changed to %s\n",
player->name.c_str(), player->customTextureUrl2.c_str());
player->name.c_str(), player->customTextureUrl2.c_str());
#endif
break;
}
@@ -1059,43 +1064,44 @@ void PlayerConnection::handleServerSettingsChanged(
gameServices().setGameHostOption(
eGameHostOption_FireSpreads,
GameHostOptions::get(packet->data,
eGameHostOption_FireSpreads));
eGameHostOption_FireSpreads));
gameServices().setGameHostOption(
eGameHostOption_TNT,
GameHostOptions::get(packet->data, eGameHostOption_TNT));
gameServices().setGameHostOption(
eGameHostOption_MobGriefing,
GameHostOptions::get(packet->data,
eGameHostOption_MobGriefing));
eGameHostOption_MobGriefing));
gameServices().setGameHostOption(
eGameHostOption_KeepInventory,
GameHostOptions::get(packet->data,
eGameHostOption_KeepInventory));
eGameHostOption_KeepInventory));
gameServices().setGameHostOption(
eGameHostOption_DoMobSpawning,
GameHostOptions::get(packet->data,
eGameHostOption_DoMobSpawning));
eGameHostOption_DoMobSpawning));
gameServices().setGameHostOption(
eGameHostOption_DoMobLoot,
GameHostOptions::get(packet->data, eGameHostOption_DoMobLoot));
gameServices().setGameHostOption(
eGameHostOption_DoTileDrops,
GameHostOptions::get(packet->data,
eGameHostOption_DoTileDrops));
eGameHostOption_DoTileDrops));
gameServices().setGameHostOption(
eGameHostOption_DoDaylightCycle,
GameHostOptions::get(packet->data,
eGameHostOption_DoDaylightCycle));
eGameHostOption_DoDaylightCycle));
gameServices().setGameHostOption(
eGameHostOption_NaturalRegeneration,
GameHostOptions::get(packet->data,
eGameHostOption_NaturalRegeneration));
eGameHostOption_NaturalRegeneration));
server->getPlayers()->broadcastAll(
std::shared_ptr<ServerSettingsChangedPacket>(
new ServerSettingsChangedPacket(
ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS,
gameServices().getGameHostOption(eGameHostOption_All))));
gameServices().getGameHostOption(
eGameHostOption_All))));
// Update the QoS data
NetworkService.UpdateAndSetGameSessionData();
@@ -1407,10 +1413,10 @@ void PlayerConnection::handlePlayerInfo(
if (serverPlayer != nullptr) {
unsigned int origPrivs = serverPlayer->getAllPlayerGamePrivileges();
bool trustPlayers =
gameServices().getGameHostOption(eGameHostOption_TrustPlayers) != 0;
bool cheats =
gameServices().getGameHostOption(eGameHostOption_CheatsEnabled) != 0;
bool trustPlayers = gameServices().getGameHostOption(
eGameHostOption_TrustPlayers) != 0;
bool cheats = gameServices().getGameHostOption(
eGameHostOption_CheatsEnabled) != 0;
if (serverPlayer == player) {
GameType* gameType =
Player::getPlayerGamePrivilege(
@@ -1423,7 +1429,7 @@ void PlayerConnection::handlePlayerInfo(
gameType) {
#if !defined(_CONTENT_PACKAGE)
printf("Setting %s to game mode %d\n",
serverPlayer->name.c_str(), gameType->getId());
serverPlayer->name.c_str(), gameType->getId());
#endif
serverPlayer->setPlayerGamePrivilege(
Player::ePlayerGamePrivilege_CreativeMode,
@@ -1438,7 +1444,7 @@ void PlayerConnection::handlePlayerInfo(
} else {
#if !defined(_CONTENT_PACKAGE)
printf("%s already has game mode %d\n",
serverPlayer->name.c_str(), gameType->getId());
serverPlayer->name.c_str(), gameType->getId());
#endif
}
if (cheats) {