mirror of
https://github.com/DarkflameUniverse/DarkflameServer
synced 2024-08-30 18:43:58 +00:00
format codebase
This commit is contained in:
@ -98,8 +98,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
if (framesSinceMasterDisconnect >= 30)
|
if (framesSinceMasterDisconnect >= 30)
|
||||||
break; //Exit our loop, shut down.
|
break; //Exit our loop, shut down.
|
||||||
}
|
} else framesSinceMasterDisconnect = 0;
|
||||||
else framesSinceMasterDisconnect = 0;
|
|
||||||
|
|
||||||
//In world we'd update our other systems here.
|
//In world we'd update our other systems here.
|
||||||
|
|
||||||
@ -134,8 +133,7 @@ int main(int argc, char** argv) {
|
|||||||
delete stmt;
|
delete stmt;
|
||||||
|
|
||||||
framesSinceLastSQLPing = 0;
|
framesSinceLastSQLPing = 0;
|
||||||
}
|
} else framesSinceLastSQLPing++;
|
||||||
else framesSinceLastSQLPing++;
|
|
||||||
|
|
||||||
//Sleep our thread since auth can afford to.
|
//Sleep our thread since auth can afford to.
|
||||||
t += std::chrono::milliseconds(mediumFramerate); //Auth can run at a lower "fps"
|
t += std::chrono::milliseconds(mediumFramerate); //Auth can run at a lower "fps"
|
||||||
|
@ -21,8 +21,7 @@ dChatFilter::dChatFilter(const std::string& filepath, bool dontGenerateDCF) {
|
|||||||
if (!BinaryIO::DoesFileExist(filepath + ".dcf") || m_DontGenerateDCF) {
|
if (!BinaryIO::DoesFileExist(filepath + ".dcf") || m_DontGenerateDCF) {
|
||||||
ReadWordlistPlaintext(filepath + ".txt", true);
|
ReadWordlistPlaintext(filepath + ".txt", true);
|
||||||
if (!m_DontGenerateDCF) ExportWordlistToDCF(filepath + ".dcf", true);
|
if (!m_DontGenerateDCF) ExportWordlistToDCF(filepath + ".dcf", true);
|
||||||
}
|
} else if (!ReadWordlistDCF(filepath + ".dcf", true)) {
|
||||||
else if (!ReadWordlistDCF(filepath + ".dcf", true)) {
|
|
||||||
ReadWordlistPlaintext(filepath + ".txt", true);
|
ReadWordlistPlaintext(filepath + ".txt", true);
|
||||||
ExportWordlistToDCF(filepath + ".dcf", true);
|
ExportWordlistToDCF(filepath + ".dcf", true);
|
||||||
}
|
}
|
||||||
@ -85,8 +84,7 @@ bool dChatFilter::ReadWordlistDCF(const std::string& filepath, bool whiteList) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
file.close();
|
file.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -60,8 +60,7 @@ void ChatPacketHandler::HandleFriendlistRequest(Packet* packet) {
|
|||||||
|
|
||||||
//Since this friend is online, we need to update them on the fact that we've just logged in:
|
//Since this friend is online, we need to update them on the fact that we've just logged in:
|
||||||
SendFriendUpdate(fr, player, 1, fd.isBestFriend);
|
SendFriendUpdate(fr, player, 1, fd.isBestFriend);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
fd.isOnline = false;
|
fd.isOnline = false;
|
||||||
fd.zoneID = LWOZONEID();
|
fd.zoneID = LWOZONEID();
|
||||||
}
|
}
|
||||||
@ -371,8 +370,7 @@ void ChatPacketHandler::HandleRemoveFriend(Packet* packet) {
|
|||||||
SendRemoveFriend(goonB, goonAName, true);
|
SendRemoveFriend(goonB, goonAName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatPacketHandler::HandleChatMessage(Packet* packet)
|
void ChatPacketHandler::HandleChatMessage(Packet* packet) {
|
||||||
{
|
|
||||||
CINSTREAM;
|
CINSTREAM;
|
||||||
LWOOBJID playerID = LWOOBJID_EMPTY;
|
LWOOBJID playerID = LWOOBJID_EMPTY;
|
||||||
inStream.Read(playerID);
|
inStream.Read(playerID);
|
||||||
@ -401,8 +399,7 @@ void ChatPacketHandler::HandleChatMessage(Packet* packet)
|
|||||||
|
|
||||||
if (team == nullptr) return;
|
if (team == nullptr) return;
|
||||||
|
|
||||||
for (const auto memberId : team->memberIDs)
|
for (const auto memberId : team->memberIDs) {
|
||||||
{
|
|
||||||
auto* otherMember = playerContainer.GetPlayerData(memberId);
|
auto* otherMember = playerContainer.GetPlayerData(memberId);
|
||||||
|
|
||||||
if (otherMember == nullptr) return;
|
if (otherMember == nullptr) return;
|
||||||
@ -493,8 +490,7 @@ void ChatPacketHandler::HandlePrivateChatMessage(Packet* packet) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatPacketHandler::HandleTeamInvite(Packet* packet)
|
void ChatPacketHandler::HandleTeamInvite(Packet* packet) {
|
||||||
{
|
|
||||||
CINSTREAM;
|
CINSTREAM;
|
||||||
LWOOBJID playerID;
|
LWOOBJID playerID;
|
||||||
inStream.Read(playerID);
|
inStream.Read(playerID);
|
||||||
@ -503,27 +499,23 @@ void ChatPacketHandler::HandleTeamInvite(Packet* packet)
|
|||||||
|
|
||||||
auto* player = playerContainer.GetPlayerData(playerID);
|
auto* player = playerContainer.GetPlayerData(playerID);
|
||||||
|
|
||||||
if (player == nullptr)
|
if (player == nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* team = playerContainer.GetTeam(playerID);
|
auto* team = playerContainer.GetTeam(playerID);
|
||||||
|
|
||||||
if (team == nullptr)
|
if (team == nullptr) {
|
||||||
{
|
|
||||||
team = playerContainer.CreateTeam(playerID);
|
team = playerContainer.CreateTeam(playerID);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* other = playerContainer.GetPlayerData(invitedPlayer);
|
auto* other = playerContainer.GetPlayerData(invitedPlayer);
|
||||||
|
|
||||||
if (other == nullptr)
|
if (other == nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerContainer.GetTeam(other->playerID) != nullptr)
|
if (playerContainer.GetTeam(other->playerID) != nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -539,8 +531,7 @@ void ChatPacketHandler::HandleTeamInvite(Packet* packet)
|
|||||||
Game::logger->Log("ChatPacketHandler", "Got team invite: %llu -> %s", playerID, invitedPlayer.c_str());
|
Game::logger->Log("ChatPacketHandler", "Got team invite: %llu -> %s", playerID, invitedPlayer.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet)
|
void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet) {
|
||||||
{
|
|
||||||
CINSTREAM;
|
CINSTREAM;
|
||||||
LWOOBJID playerID = LWOOBJID_EMPTY;
|
LWOOBJID playerID = LWOOBJID_EMPTY;
|
||||||
inStream.Read(playerID);
|
inStream.Read(playerID);
|
||||||
@ -554,22 +545,19 @@ void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet)
|
|||||||
|
|
||||||
Game::logger->Log("ChatPacketHandler", "Accepted invite: %llu -> %llu (%d)", playerID, leaderID, declined);
|
Game::logger->Log("ChatPacketHandler", "Accepted invite: %llu -> %llu (%d)", playerID, leaderID, declined);
|
||||||
|
|
||||||
if (declined)
|
if (declined) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* team = playerContainer.GetTeam(leaderID);
|
auto* team = playerContainer.GetTeam(leaderID);
|
||||||
|
|
||||||
if (team == nullptr)
|
if (team == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("ChatPacketHandler", "Failed to find team for leader (%llu)", leaderID);
|
Game::logger->Log("ChatPacketHandler", "Failed to find team for leader (%llu)", leaderID);
|
||||||
|
|
||||||
team = playerContainer.GetTeam(playerID);
|
team = playerContainer.GetTeam(playerID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (team == nullptr)
|
if (team == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("ChatPacketHandler", "Failed to find team for player (%llu)", playerID);
|
Game::logger->Log("ChatPacketHandler", "Failed to find team for player (%llu)", playerID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -577,8 +565,7 @@ void ChatPacketHandler::HandleTeamInviteResponse(Packet* packet)
|
|||||||
playerContainer.AddMember(team, playerID);
|
playerContainer.AddMember(team, playerID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatPacketHandler::HandleTeamLeave(Packet* packet)
|
void ChatPacketHandler::HandleTeamLeave(Packet* packet) {
|
||||||
{
|
|
||||||
CINSTREAM;
|
CINSTREAM;
|
||||||
LWOOBJID playerID = LWOOBJID_EMPTY;
|
LWOOBJID playerID = LWOOBJID_EMPTY;
|
||||||
inStream.Read(playerID);
|
inStream.Read(playerID);
|
||||||
@ -590,14 +577,12 @@ void ChatPacketHandler::HandleTeamLeave(Packet* packet)
|
|||||||
|
|
||||||
Game::logger->Log("ChatPacketHandler", "(%llu) leaving team", playerID);
|
Game::logger->Log("ChatPacketHandler", "(%llu) leaving team", playerID);
|
||||||
|
|
||||||
if (team != nullptr)
|
if (team != nullptr) {
|
||||||
{
|
|
||||||
playerContainer.RemoveMember(team, playerID, false, false, true);
|
playerContainer.RemoveMember(team, playerID, false, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatPacketHandler::HandleTeamKick(Packet* packet)
|
void ChatPacketHandler::HandleTeamKick(Packet* packet) {
|
||||||
{
|
|
||||||
CINSTREAM;
|
CINSTREAM;
|
||||||
LWOOBJID playerID = LWOOBJID_EMPTY;
|
LWOOBJID playerID = LWOOBJID_EMPTY;
|
||||||
inStream.Read(playerID);
|
inStream.Read(playerID);
|
||||||
@ -611,12 +596,9 @@ void ChatPacketHandler::HandleTeamKick(Packet* packet)
|
|||||||
|
|
||||||
LWOOBJID kickedId = LWOOBJID_EMPTY;
|
LWOOBJID kickedId = LWOOBJID_EMPTY;
|
||||||
|
|
||||||
if (kicked != nullptr)
|
if (kicked != nullptr) {
|
||||||
{
|
|
||||||
kickedId = kicked->playerID;
|
kickedId = kicked->playerID;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
kickedId = playerContainer.GetId(GeneralUtils::ASCIIToUTF16(kickedPlayer));
|
kickedId = playerContainer.GetId(GeneralUtils::ASCIIToUTF16(kickedPlayer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -624,16 +606,14 @@ void ChatPacketHandler::HandleTeamKick(Packet* packet)
|
|||||||
|
|
||||||
auto* team = playerContainer.GetTeam(playerID);
|
auto* team = playerContainer.GetTeam(playerID);
|
||||||
|
|
||||||
if (team != nullptr)
|
if (team != nullptr) {
|
||||||
{
|
|
||||||
if (team->leaderID != playerID || team->leaderID == kickedId) return;
|
if (team->leaderID != playerID || team->leaderID == kickedId) return;
|
||||||
|
|
||||||
playerContainer.RemoveMember(team, kickedId, false, true, false);
|
playerContainer.RemoveMember(team, kickedId, false, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatPacketHandler::HandleTeamPromote(Packet* packet)
|
void ChatPacketHandler::HandleTeamPromote(Packet* packet) {
|
||||||
{
|
|
||||||
CINSTREAM;
|
CINSTREAM;
|
||||||
LWOOBJID playerID = LWOOBJID_EMPTY;
|
LWOOBJID playerID = LWOOBJID_EMPTY;
|
||||||
inStream.Read(playerID);
|
inStream.Read(playerID);
|
||||||
@ -649,16 +629,14 @@ void ChatPacketHandler::HandleTeamPromote(Packet* packet)
|
|||||||
|
|
||||||
auto* team = playerContainer.GetTeam(playerID);
|
auto* team = playerContainer.GetTeam(playerID);
|
||||||
|
|
||||||
if (team != nullptr)
|
if (team != nullptr) {
|
||||||
{
|
|
||||||
if (team->leaderID != playerID) return;
|
if (team->leaderID != playerID) return;
|
||||||
|
|
||||||
playerContainer.PromoteMember(team, promoted->playerID);
|
playerContainer.PromoteMember(team, promoted->playerID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatPacketHandler::HandleTeamLootOption(Packet* packet)
|
void ChatPacketHandler::HandleTeamLootOption(Packet* packet) {
|
||||||
{
|
|
||||||
CINSTREAM;
|
CINSTREAM;
|
||||||
LWOOBJID playerID = LWOOBJID_EMPTY;
|
LWOOBJID playerID = LWOOBJID_EMPTY;
|
||||||
inStream.Read(playerID);
|
inStream.Read(playerID);
|
||||||
@ -671,8 +649,7 @@ void ChatPacketHandler::HandleTeamLootOption(Packet* packet)
|
|||||||
|
|
||||||
auto* team = playerContainer.GetTeam(playerID);
|
auto* team = playerContainer.GetTeam(playerID);
|
||||||
|
|
||||||
if (team != nullptr)
|
if (team != nullptr) {
|
||||||
{
|
|
||||||
if (team->leaderID != playerID) return;
|
if (team->leaderID != playerID) return;
|
||||||
|
|
||||||
team->lootFlag = option;
|
team->lootFlag = option;
|
||||||
@ -683,8 +660,7 @@ void ChatPacketHandler::HandleTeamLootOption(Packet* packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet)
|
void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet) {
|
||||||
{
|
|
||||||
CINSTREAM;
|
CINSTREAM;
|
||||||
LWOOBJID playerID = LWOOBJID_EMPTY;
|
LWOOBJID playerID = LWOOBJID_EMPTY;
|
||||||
inStream.Read(playerID);
|
inStream.Read(playerID);
|
||||||
@ -693,28 +669,22 @@ void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet)
|
|||||||
auto* team = playerContainer.GetTeam(playerID);
|
auto* team = playerContainer.GetTeam(playerID);
|
||||||
auto* data = playerContainer.GetPlayerData(playerID);
|
auto* data = playerContainer.GetPlayerData(playerID);
|
||||||
|
|
||||||
if (team != nullptr && data != nullptr)
|
if (team != nullptr && data != nullptr) {
|
||||||
{
|
if (team->local && data->zoneID.GetMapID() != team->zoneId.GetMapID() && data->zoneID.GetCloneID() != team->zoneId.GetCloneID()) {
|
||||||
if (team->local && data->zoneID.GetMapID() != team->zoneId.GetMapID() && data->zoneID.GetCloneID() != team->zoneId.GetCloneID())
|
|
||||||
{
|
|
||||||
playerContainer.RemoveMember(team, playerID, false, false, true, true);
|
playerContainer.RemoveMember(team, playerID, false, false, true, true);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (team->memberIDs.size() <= 1 && !team->local)
|
if (team->memberIDs.size() <= 1 && !team->local) {
|
||||||
{
|
|
||||||
playerContainer.DisbandTeam(team);
|
playerContainer.DisbandTeam(team);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!team->local)
|
if (!team->local) {
|
||||||
{
|
|
||||||
ChatPacketHandler::SendTeamSetLeader(data, team->leaderID);
|
ChatPacketHandler::SendTeamSetLeader(data, team->leaderID);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ChatPacketHandler::SendTeamSetLeader(data, LWOOBJID_EMPTY);
|
ChatPacketHandler::SendTeamSetLeader(data, LWOOBJID_EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -722,16 +692,14 @@ void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet)
|
|||||||
|
|
||||||
const auto leaderName = GeneralUtils::ASCIIToUTF16(std::string(data->playerName.c_str()));
|
const auto leaderName = GeneralUtils::ASCIIToUTF16(std::string(data->playerName.c_str()));
|
||||||
|
|
||||||
for (const auto memberId : team->memberIDs)
|
for (const auto memberId : team->memberIDs) {
|
||||||
{
|
|
||||||
auto* otherMember = playerContainer.GetPlayerData(memberId);
|
auto* otherMember = playerContainer.GetPlayerData(memberId);
|
||||||
|
|
||||||
if (memberId == playerID) continue;
|
if (memberId == playerID) continue;
|
||||||
|
|
||||||
const auto memberName = playerContainer.GetName(memberId);
|
const auto memberName = playerContainer.GetName(memberId);
|
||||||
|
|
||||||
if (otherMember != nullptr)
|
if (otherMember != nullptr) {
|
||||||
{
|
|
||||||
ChatPacketHandler::SendTeamSetOffWorldFlag(otherMember, data->playerID, data->zoneID);
|
ChatPacketHandler::SendTeamSetOffWorldFlag(otherMember, data->playerID, data->zoneID);
|
||||||
}
|
}
|
||||||
ChatPacketHandler::SendTeamAddPlayer(data, false, team->local, false, memberId, memberName, otherMember != nullptr ? otherMember->zoneID : LWOZONEID(0, 0, 0));
|
ChatPacketHandler::SendTeamAddPlayer(data, false, team->local, false, memberId, memberName, otherMember != nullptr ? otherMember->zoneID : LWOZONEID(0, 0, 0));
|
||||||
@ -741,8 +709,7 @@ void ChatPacketHandler::HandleTeamStatusRequest(Packet* packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatPacketHandler::SendTeamInvite(PlayerData* receiver, PlayerData* sender)
|
void ChatPacketHandler::SendTeamInvite(PlayerData* receiver, PlayerData* sender) {
|
||||||
{
|
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
|
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
|
||||||
bitStream.Write(receiver->playerID);
|
bitStream.Write(receiver->playerID);
|
||||||
@ -757,8 +724,7 @@ void ChatPacketHandler::SendTeamInvite(PlayerData* receiver, PlayerData* sender)
|
|||||||
SEND_PACKET;
|
SEND_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeaderIsFreeTrial, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, uint8_t ucResponseCode, std::u16string wsLeaderName)
|
void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeaderIsFreeTrial, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, uint8_t ucResponseCode, std::u16string wsLeaderName) {
|
||||||
{
|
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
|
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
|
||||||
bitStream.Write(receiver->playerID);
|
bitStream.Write(receiver->playerID);
|
||||||
@ -777,8 +743,7 @@ void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeader
|
|||||||
bitStream.Write(ucNumOfOtherPlayers);
|
bitStream.Write(ucNumOfOtherPlayers);
|
||||||
bitStream.Write(ucResponseCode);
|
bitStream.Write(ucResponseCode);
|
||||||
bitStream.Write(static_cast<uint32_t>(wsLeaderName.size()));
|
bitStream.Write(static_cast<uint32_t>(wsLeaderName.size()));
|
||||||
for (const auto character : wsLeaderName)
|
for (const auto character : wsLeaderName) {
|
||||||
{
|
|
||||||
bitStream.Write(character);
|
bitStream.Write(character);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -786,8 +751,7 @@ void ChatPacketHandler::SendTeamInviteConfirm(PlayerData* receiver, bool bLeader
|
|||||||
SEND_PACKET;
|
SEND_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, std::u16string wsLeaderName)
|
void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderID, LWOZONEID i64LeaderZoneID, uint8_t ucLootFlag, uint8_t ucNumOfOtherPlayers, std::u16string wsLeaderName) {
|
||||||
{
|
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
|
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
|
||||||
bitStream.Write(receiver->playerID);
|
bitStream.Write(receiver->playerID);
|
||||||
@ -804,8 +768,7 @@ void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderI
|
|||||||
bitStream.Write(ucLootFlag);
|
bitStream.Write(ucLootFlag);
|
||||||
bitStream.Write(ucNumOfOtherPlayers);
|
bitStream.Write(ucNumOfOtherPlayers);
|
||||||
bitStream.Write(static_cast<uint32_t>(wsLeaderName.size()));
|
bitStream.Write(static_cast<uint32_t>(wsLeaderName.size()));
|
||||||
for (const auto character : wsLeaderName)
|
for (const auto character : wsLeaderName) {
|
||||||
{
|
|
||||||
bitStream.Write(character);
|
bitStream.Write(character);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -813,8 +776,7 @@ void ChatPacketHandler::SendTeamStatus(PlayerData* receiver, LWOOBJID i64LeaderI
|
|||||||
SEND_PACKET;
|
SEND_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatPacketHandler::SendTeamSetLeader(PlayerData* receiver, LWOOBJID i64PlayerID)
|
void ChatPacketHandler::SendTeamSetLeader(PlayerData* receiver, LWOOBJID i64PlayerID) {
|
||||||
{
|
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
|
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
|
||||||
bitStream.Write(receiver->playerID);
|
bitStream.Write(receiver->playerID);
|
||||||
@ -831,8 +793,7 @@ void ChatPacketHandler::SendTeamSetLeader(PlayerData* receiver, LWOOBJID i64Play
|
|||||||
SEND_PACKET;
|
SEND_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTrial, bool bLocal, bool bNoLootOnDeath, LWOOBJID i64PlayerID, std::u16string wsPlayerName, LWOZONEID zoneID)
|
void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTrial, bool bLocal, bool bNoLootOnDeath, LWOOBJID i64PlayerID, std::u16string wsPlayerName, LWOZONEID zoneID) {
|
||||||
{
|
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
|
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
|
||||||
bitStream.Write(receiver->playerID);
|
bitStream.Write(receiver->playerID);
|
||||||
@ -848,13 +809,11 @@ void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTria
|
|||||||
bitStream.Write(bNoLootOnDeath);
|
bitStream.Write(bNoLootOnDeath);
|
||||||
bitStream.Write(i64PlayerID);
|
bitStream.Write(i64PlayerID);
|
||||||
bitStream.Write(static_cast<uint32_t>(wsPlayerName.size()));
|
bitStream.Write(static_cast<uint32_t>(wsPlayerName.size()));
|
||||||
for (const auto character : wsPlayerName)
|
for (const auto character : wsPlayerName) {
|
||||||
{
|
|
||||||
bitStream.Write(character);
|
bitStream.Write(character);
|
||||||
}
|
}
|
||||||
bitStream.Write1();
|
bitStream.Write1();
|
||||||
if (receiver->zoneID.GetCloneID() == zoneID.GetCloneID())
|
if (receiver->zoneID.GetCloneID() == zoneID.GetCloneID()) {
|
||||||
{
|
|
||||||
zoneID = LWOZONEID(zoneID.GetMapID(), zoneID.GetInstanceID(), 0);
|
zoneID = LWOZONEID(zoneID.GetMapID(), zoneID.GetInstanceID(), 0);
|
||||||
}
|
}
|
||||||
bitStream.Write(zoneID);
|
bitStream.Write(zoneID);
|
||||||
@ -863,8 +822,7 @@ void ChatPacketHandler::SendTeamAddPlayer(PlayerData* receiver, bool bIsFreeTria
|
|||||||
SEND_PACKET;
|
SEND_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband, bool bIsKicked, bool bIsLeaving, bool bLocal, LWOOBJID i64LeaderID, LWOOBJID i64PlayerID, std::u16string wsPlayerName)
|
void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband, bool bIsKicked, bool bIsLeaving, bool bLocal, LWOOBJID i64LeaderID, LWOOBJID i64PlayerID, std::u16string wsPlayerName) {
|
||||||
{
|
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
|
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
|
||||||
bitStream.Write(receiver->playerID);
|
bitStream.Write(receiver->playerID);
|
||||||
@ -882,8 +840,7 @@ void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband
|
|||||||
bitStream.Write(i64LeaderID);
|
bitStream.Write(i64LeaderID);
|
||||||
bitStream.Write(i64PlayerID);
|
bitStream.Write(i64PlayerID);
|
||||||
bitStream.Write(static_cast<uint32_t>(wsPlayerName.size()));
|
bitStream.Write(static_cast<uint32_t>(wsPlayerName.size()));
|
||||||
for (const auto character : wsPlayerName)
|
for (const auto character : wsPlayerName) {
|
||||||
{
|
|
||||||
bitStream.Write(character);
|
bitStream.Write(character);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -891,8 +848,7 @@ void ChatPacketHandler::SendTeamRemovePlayer(PlayerData* receiver, bool bDisband
|
|||||||
SEND_PACKET;
|
SEND_PACKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChatPacketHandler::SendTeamSetOffWorldFlag(PlayerData* receiver, LWOOBJID i64PlayerID, LWOZONEID zoneID)
|
void ChatPacketHandler::SendTeamSetOffWorldFlag(PlayerData* receiver, LWOOBJID i64PlayerID, LWOZONEID zoneID) {
|
||||||
{
|
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
|
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ROUTE_TO_PLAYER);
|
||||||
bitStream.Write(receiver->playerID);
|
bitStream.Write(receiver->playerID);
|
||||||
@ -904,8 +860,7 @@ void ChatPacketHandler::SendTeamSetOffWorldFlag(PlayerData* receiver, LWOOBJID i
|
|||||||
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);
|
||||||
if (receiver->zoneID.GetCloneID() == zoneID.GetCloneID())
|
if (receiver->zoneID.GetCloneID() == zoneID.GetCloneID()) {
|
||||||
{
|
|
||||||
zoneID = LWOZONEID(zoneID.GetMapID(), zoneID.GetInstanceID(), 0);
|
zoneID = LWOZONEID(zoneID.GetMapID(), zoneID.GetInstanceID(), 0);
|
||||||
}
|
}
|
||||||
bitStream.Write(zoneID);
|
bitStream.Write(zoneID);
|
||||||
@ -943,12 +898,9 @@ void ChatPacketHandler::SendFriendUpdate(PlayerData* friendData, PlayerData* pla
|
|||||||
bitStream.Write(playerData->zoneID.GetMapID());
|
bitStream.Write(playerData->zoneID.GetMapID());
|
||||||
bitStream.Write(playerData->zoneID.GetInstanceID());
|
bitStream.Write(playerData->zoneID.GetInstanceID());
|
||||||
|
|
||||||
if (playerData->zoneID.GetCloneID() == friendData->zoneID.GetCloneID())
|
if (playerData->zoneID.GetCloneID() == friendData->zoneID.GetCloneID()) {
|
||||||
{
|
|
||||||
bitStream.Write(0);
|
bitStream.Write(0);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
bitStream.Write(playerData->zoneID.GetCloneID());
|
bitStream.Write(playerData->zoneID.GetCloneID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,8 +58,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Database::Connect(mysql_host, mysql_database, mysql_username, mysql_password);
|
Database::Connect(mysql_host, mysql_database, mysql_username, mysql_password);
|
||||||
}
|
} catch (sql::SQLException& ex) {
|
||||||
catch (sql::SQLException& ex) {
|
|
||||||
Game::logger->Log("ChatServer", "Got an error while connecting to the database: %s", ex.what());
|
Game::logger->Log("ChatServer", "Got an error while connecting to the database: %s", ex.what());
|
||||||
Database::Destroy("ChatServer");
|
Database::Destroy("ChatServer");
|
||||||
delete Game::server;
|
delete Game::server;
|
||||||
@ -104,8 +103,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
if (framesSinceMasterDisconnect >= 30)
|
if (framesSinceMasterDisconnect >= 30)
|
||||||
break; //Exit our loop, shut down.
|
break; //Exit our loop, shut down.
|
||||||
}
|
} else framesSinceMasterDisconnect = 0;
|
||||||
else framesSinceMasterDisconnect = 0;
|
|
||||||
|
|
||||||
//In world we'd update our other systems here.
|
//In world we'd update our other systems here.
|
||||||
|
|
||||||
@ -122,8 +120,7 @@ int main(int argc, char** argv) {
|
|||||||
if (framesSinceLastFlush >= 900) {
|
if (framesSinceLastFlush >= 900) {
|
||||||
Game::logger->Flush();
|
Game::logger->Flush();
|
||||||
framesSinceLastFlush = 0;
|
framesSinceLastFlush = 0;
|
||||||
}
|
} else framesSinceLastFlush++;
|
||||||
else framesSinceLastFlush++;
|
|
||||||
|
|
||||||
//Every 10 min we ping our sql server to keep it alive hopefully:
|
//Every 10 min we ping our sql server to keep it alive hopefully:
|
||||||
if (framesSinceLastSQLPing >= 40000) {
|
if (framesSinceLastSQLPing >= 40000) {
|
||||||
@ -141,8 +138,7 @@ int main(int argc, char** argv) {
|
|||||||
delete stmt;
|
delete stmt;
|
||||||
|
|
||||||
framesSinceLastSQLPing = 0;
|
framesSinceLastSQLPing = 0;
|
||||||
}
|
} else framesSinceLastSQLPing++;
|
||||||
else framesSinceLastSQLPing++;
|
|
||||||
|
|
||||||
//Sleep our thread since auth can afford to.
|
//Sleep our thread since auth can afford to.
|
||||||
t += std::chrono::milliseconds(mediumFramerate); //Chat can run at a lower "fps"
|
t += std::chrono::milliseconds(mediumFramerate); //Chat can run at a lower "fps"
|
||||||
|
@ -70,12 +70,10 @@ void PlayerContainer::RemovePlayer(Packet* packet) {
|
|||||||
|
|
||||||
auto* team = GetTeam(playerID);
|
auto* team = GetTeam(playerID);
|
||||||
|
|
||||||
if (team != nullptr)
|
if (team != nullptr) {
|
||||||
{
|
|
||||||
const auto memberName = GeneralUtils::ASCIIToUTF16(std::string(player->playerName.c_str()));
|
const auto memberName = GeneralUtils::ASCIIToUTF16(std::string(player->playerName.c_str()));
|
||||||
|
|
||||||
for (const auto memberId : team->memberIDs)
|
for (const auto memberId : team->memberIDs) {
|
||||||
{
|
|
||||||
auto* otherMember = GetPlayerData(memberId);
|
auto* otherMember = GetPlayerData(memberId);
|
||||||
|
|
||||||
if (otherMember == nullptr) continue;
|
if (otherMember == nullptr) continue;
|
||||||
@ -97,8 +95,7 @@ void PlayerContainer::RemovePlayer(Packet* packet) {
|
|||||||
insertLog->executeUpdate();
|
insertLog->executeUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerContainer::MuteUpdate(Packet* packet)
|
void PlayerContainer::MuteUpdate(Packet* packet) {
|
||||||
{
|
|
||||||
CINSTREAM;
|
CINSTREAM;
|
||||||
LWOOBJID playerID;
|
LWOOBJID playerID;
|
||||||
inStream.Read(playerID); //skip header
|
inStream.Read(playerID); //skip header
|
||||||
@ -108,8 +105,7 @@ void PlayerContainer::MuteUpdate(Packet* packet)
|
|||||||
|
|
||||||
auto* player = this->GetPlayerData(playerID);
|
auto* player = this->GetPlayerData(playerID);
|
||||||
|
|
||||||
if (player == nullptr)
|
if (player == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("PlayerContainer", "Failed to find user: %llu", playerID);
|
Game::logger->Log("PlayerContainer", "Failed to find user: %llu", playerID);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -120,8 +116,7 @@ void PlayerContainer::MuteUpdate(Packet* packet)
|
|||||||
BroadcastMuteUpdate(playerID, expire);
|
BroadcastMuteUpdate(playerID, expire);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerContainer::CreateTeamServer(Packet* packet)
|
void PlayerContainer::CreateTeamServer(Packet* packet) {
|
||||||
{
|
|
||||||
CINSTREAM;
|
CINSTREAM;
|
||||||
LWOOBJID playerID;
|
LWOOBJID playerID;
|
||||||
inStream.Read(playerID); //skip header
|
inStream.Read(playerID); //skip header
|
||||||
@ -133,8 +128,7 @@ void PlayerContainer::CreateTeamServer(Packet* packet)
|
|||||||
|
|
||||||
members.reserve(membersSize);
|
members.reserve(membersSize);
|
||||||
|
|
||||||
for (size_t i = 0; i < membersSize; i++)
|
for (size_t i = 0; i < membersSize; i++) {
|
||||||
{
|
|
||||||
LWOOBJID member;
|
LWOOBJID member;
|
||||||
inStream.Read(member);
|
inStream.Read(member);
|
||||||
members.push_back(member);
|
members.push_back(member);
|
||||||
@ -146,16 +140,14 @@ void PlayerContainer::CreateTeamServer(Packet* packet)
|
|||||||
|
|
||||||
auto* team = CreateLocalTeam(members);
|
auto* team = CreateLocalTeam(members);
|
||||||
|
|
||||||
if (team != nullptr)
|
if (team != nullptr) {
|
||||||
{
|
|
||||||
team->zoneId = zoneId;
|
team->zoneId = zoneId;
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateTeamsOnWorld(team, false);
|
UpdateTeamsOnWorld(team, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerContainer::BroadcastMuteUpdate(LWOOBJID player, time_t time)
|
void PlayerContainer::BroadcastMuteUpdate(LWOOBJID player, time_t time) {
|
||||||
{
|
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_MUTE_UPDATE);
|
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_MUTE_UPDATE);
|
||||||
|
|
||||||
@ -165,30 +157,23 @@ void PlayerContainer::BroadcastMuteUpdate(LWOOBJID player, time_t time)
|
|||||||
Game::server->Send(&bitStream, UNASSIGNED_SYSTEM_ADDRESS, true);
|
Game::server->Send(&bitStream, UNASSIGNED_SYSTEM_ADDRESS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TeamData* PlayerContainer::CreateLocalTeam(std::vector<LWOOBJID> members)
|
TeamData* PlayerContainer::CreateLocalTeam(std::vector<LWOOBJID> members) {
|
||||||
{
|
if (members.empty()) {
|
||||||
if (members.empty())
|
|
||||||
{
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
TeamData* newTeam = nullptr;
|
TeamData* newTeam = nullptr;
|
||||||
|
|
||||||
for (const auto member : members)
|
for (const auto member : members) {
|
||||||
{
|
|
||||||
auto* team = GetTeam(member);
|
auto* team = GetTeam(member);
|
||||||
|
|
||||||
if (team != nullptr)
|
if (team != nullptr) {
|
||||||
{
|
|
||||||
RemoveMember(team, member, false, false, true);
|
RemoveMember(team, member, false, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newTeam == nullptr)
|
if (newTeam == nullptr) {
|
||||||
{
|
|
||||||
newTeam = CreateTeam(member, true);
|
newTeam = CreateTeam(member, true);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
AddMember(newTeam, member);
|
AddMember(newTeam, member);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,8 +185,7 @@ TeamData* PlayerContainer::CreateLocalTeam(std::vector<LWOOBJID> members)
|
|||||||
return newTeam;
|
return newTeam;
|
||||||
}
|
}
|
||||||
|
|
||||||
TeamData* PlayerContainer::CreateTeam(LWOOBJID leader, bool local)
|
TeamData* PlayerContainer::CreateTeam(LWOOBJID leader, bool local) {
|
||||||
{
|
|
||||||
auto* team = new TeamData();
|
auto* team = new TeamData();
|
||||||
|
|
||||||
team->teamID = ++mTeamIDCounter;
|
team->teamID = ++mTeamIDCounter;
|
||||||
@ -215,10 +199,8 @@ TeamData* PlayerContainer::CreateTeam(LWOOBJID leader, bool local)
|
|||||||
return team;
|
return team;
|
||||||
}
|
}
|
||||||
|
|
||||||
TeamData* PlayerContainer::GetTeam(LWOOBJID playerID)
|
TeamData* PlayerContainer::GetTeam(LWOOBJID playerID) {
|
||||||
{
|
for (auto* team : mTeams) {
|
||||||
for (auto* team : mTeams)
|
|
||||||
{
|
|
||||||
if (std::find(team->memberIDs.begin(), team->memberIDs.end(), playerID) == team->memberIDs.end()) continue;
|
if (std::find(team->memberIDs.begin(), team->memberIDs.end(), playerID) == team->memberIDs.end()) continue;
|
||||||
|
|
||||||
return team;
|
return team;
|
||||||
@ -227,8 +209,7 @@ TeamData* PlayerContainer::GetTeam(LWOOBJID playerID)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID)
|
void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID) {
|
||||||
{
|
|
||||||
const auto index = std::find(team->memberIDs.begin(), team->memberIDs.end(), playerID);
|
const auto index = std::find(team->memberIDs.begin(), team->memberIDs.end(), playerID);
|
||||||
|
|
||||||
if (index != team->memberIDs.end()) return;
|
if (index != team->memberIDs.end()) return;
|
||||||
@ -245,19 +226,15 @@ void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID)
|
|||||||
|
|
||||||
ChatPacketHandler::SendTeamInviteConfirm(member, false, leader->playerID, leader->zoneID, team->lootFlag, 0, 0, leaderName);
|
ChatPacketHandler::SendTeamInviteConfirm(member, false, leader->playerID, leader->zoneID, team->lootFlag, 0, 0, leaderName);
|
||||||
|
|
||||||
if (!team->local)
|
if (!team->local) {
|
||||||
{
|
|
||||||
ChatPacketHandler::SendTeamSetLeader(member, leader->playerID);
|
ChatPacketHandler::SendTeamSetLeader(member, leader->playerID);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
ChatPacketHandler::SendTeamSetLeader(member, LWOOBJID_EMPTY);
|
ChatPacketHandler::SendTeamSetLeader(member, LWOOBJID_EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateTeamsOnWorld(team, false);
|
UpdateTeamsOnWorld(team, false);
|
||||||
|
|
||||||
for (const auto memberId : team->memberIDs)
|
for (const auto memberId : team->memberIDs) {
|
||||||
{
|
|
||||||
auto* otherMember = GetPlayerData(memberId);
|
auto* otherMember = GetPlayerData(memberId);
|
||||||
|
|
||||||
if (otherMember == member) continue;
|
if (otherMember == member) continue;
|
||||||
@ -266,32 +243,27 @@ void PlayerContainer::AddMember(TeamData* team, LWOOBJID playerID)
|
|||||||
|
|
||||||
ChatPacketHandler::SendTeamAddPlayer(member, false, team->local, false, memberId, otherMemberName, otherMember != nullptr ? otherMember->zoneID : LWOZONEID(0, 0, 0));
|
ChatPacketHandler::SendTeamAddPlayer(member, false, team->local, false, memberId, otherMemberName, otherMember != nullptr ? otherMember->zoneID : LWOZONEID(0, 0, 0));
|
||||||
|
|
||||||
if (otherMember != nullptr)
|
if (otherMember != nullptr) {
|
||||||
{
|
|
||||||
ChatPacketHandler::SendTeamAddPlayer(otherMember, false, team->local, false, member->playerID, memberName, member->zoneID);
|
ChatPacketHandler::SendTeamAddPlayer(otherMember, false, team->local, false, member->playerID, memberName, member->zoneID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerContainer::RemoveMember(TeamData* team, LWOOBJID playerID, bool disband, bool kicked, bool leaving, bool silent)
|
void PlayerContainer::RemoveMember(TeamData* team, LWOOBJID playerID, bool disband, bool kicked, bool leaving, bool silent) {
|
||||||
{
|
|
||||||
const auto index = std::find(team->memberIDs.begin(), team->memberIDs.end(), playerID);
|
const auto index = std::find(team->memberIDs.begin(), team->memberIDs.end(), playerID);
|
||||||
|
|
||||||
if (index == team->memberIDs.end()) return;
|
if (index == team->memberIDs.end()) return;
|
||||||
|
|
||||||
auto* member = GetPlayerData(playerID);
|
auto* member = GetPlayerData(playerID);
|
||||||
|
|
||||||
if (member != nullptr && !silent)
|
if (member != nullptr && !silent) {
|
||||||
{
|
|
||||||
ChatPacketHandler::SendTeamSetLeader(member, LWOOBJID_EMPTY);
|
ChatPacketHandler::SendTeamSetLeader(member, LWOOBJID_EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto memberName = GetName(playerID);
|
const auto memberName = GetName(playerID);
|
||||||
|
|
||||||
for (const auto memberId : team->memberIDs)
|
for (const auto memberId : team->memberIDs) {
|
||||||
{
|
if (silent && memberId == playerID) {
|
||||||
if (silent && memberId == playerID)
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,25 +278,19 @@ void PlayerContainer::RemoveMember(TeamData* team, LWOOBJID playerID, bool disba
|
|||||||
|
|
||||||
UpdateTeamsOnWorld(team, false);
|
UpdateTeamsOnWorld(team, false);
|
||||||
|
|
||||||
if (team->memberIDs.size() <= 1)
|
if (team->memberIDs.size() <= 1) {
|
||||||
{
|
|
||||||
DisbandTeam(team);
|
DisbandTeam(team);
|
||||||
}
|
} else {
|
||||||
else
|
if (playerID == team->leaderID) {
|
||||||
{
|
|
||||||
if (playerID == team->leaderID)
|
|
||||||
{
|
|
||||||
PromoteMember(team, team->memberIDs[0]);
|
PromoteMember(team, team->memberIDs[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerContainer::PromoteMember(TeamData* team, LWOOBJID newLeader)
|
void PlayerContainer::PromoteMember(TeamData* team, LWOOBJID newLeader) {
|
||||||
{
|
|
||||||
team->leaderID = newLeader;
|
team->leaderID = newLeader;
|
||||||
|
|
||||||
for (const auto memberId : team->memberIDs)
|
for (const auto memberId : team->memberIDs) {
|
||||||
{
|
|
||||||
auto* otherMember = GetPlayerData(memberId);
|
auto* otherMember = GetPlayerData(memberId);
|
||||||
|
|
||||||
if (otherMember == nullptr) continue;
|
if (otherMember == nullptr) continue;
|
||||||
@ -333,14 +299,12 @@ void PlayerContainer::PromoteMember(TeamData* team, LWOOBJID newLeader)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerContainer::DisbandTeam(TeamData* team)
|
void PlayerContainer::DisbandTeam(TeamData* team) {
|
||||||
{
|
|
||||||
const auto index = std::find(mTeams.begin(), mTeams.end(), team);
|
const auto index = std::find(mTeams.begin(), mTeams.end(), team);
|
||||||
|
|
||||||
if (index == mTeams.end()) return;
|
if (index == mTeams.end()) return;
|
||||||
|
|
||||||
for (const auto memberId : team->memberIDs)
|
for (const auto memberId : team->memberIDs) {
|
||||||
{
|
|
||||||
auto* otherMember = GetPlayerData(memberId);
|
auto* otherMember = GetPlayerData(memberId);
|
||||||
|
|
||||||
if (otherMember == nullptr) continue;
|
if (otherMember == nullptr) continue;
|
||||||
@ -358,8 +322,7 @@ void PlayerContainer::DisbandTeam(TeamData* team)
|
|||||||
delete team;
|
delete team;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerContainer::TeamStatusUpdate(TeamData* team)
|
void PlayerContainer::TeamStatusUpdate(TeamData* team) {
|
||||||
{
|
|
||||||
const auto index = std::find(mTeams.begin(), mTeams.end(), team);
|
const auto index = std::find(mTeams.begin(), mTeams.end(), team);
|
||||||
|
|
||||||
if (index == mTeams.end()) return;
|
if (index == mTeams.end()) return;
|
||||||
@ -370,14 +333,12 @@ void PlayerContainer::TeamStatusUpdate(TeamData* team)
|
|||||||
|
|
||||||
const auto leaderName = GeneralUtils::ASCIIToUTF16(std::string(leader->playerName.c_str()));
|
const auto leaderName = GeneralUtils::ASCIIToUTF16(std::string(leader->playerName.c_str()));
|
||||||
|
|
||||||
for (const auto memberId : team->memberIDs)
|
for (const auto memberId : team->memberIDs) {
|
||||||
{
|
|
||||||
auto* otherMember = GetPlayerData(memberId);
|
auto* otherMember = GetPlayerData(memberId);
|
||||||
|
|
||||||
if (otherMember == nullptr) continue;
|
if (otherMember == nullptr) continue;
|
||||||
|
|
||||||
if (!team->local)
|
if (!team->local) {
|
||||||
{
|
|
||||||
ChatPacketHandler::SendTeamStatus(otherMember, team->leaderID, leader->zoneID, team->lootFlag, 0, leaderName);
|
ChatPacketHandler::SendTeamStatus(otherMember, team->leaderID, leader->zoneID, team->lootFlag, 0, leaderName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -385,20 +346,17 @@ void PlayerContainer::TeamStatusUpdate(TeamData* team)
|
|||||||
UpdateTeamsOnWorld(team, false);
|
UpdateTeamsOnWorld(team, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerContainer::UpdateTeamsOnWorld(TeamData* team, bool deleteTeam)
|
void PlayerContainer::UpdateTeamsOnWorld(TeamData* team, bool deleteTeam) {
|
||||||
{
|
|
||||||
CBITSTREAM;
|
CBITSTREAM;
|
||||||
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_TEAM_UPDATE);
|
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_TEAM_UPDATE);
|
||||||
|
|
||||||
bitStream.Write(team->teamID);
|
bitStream.Write(team->teamID);
|
||||||
bitStream.Write(deleteTeam);
|
bitStream.Write(deleteTeam);
|
||||||
|
|
||||||
if (!deleteTeam)
|
if (!deleteTeam) {
|
||||||
{
|
|
||||||
bitStream.Write(team->lootFlag);
|
bitStream.Write(team->lootFlag);
|
||||||
bitStream.Write(static_cast<char>(team->memberIDs.size()));
|
bitStream.Write(static_cast<char>(team->memberIDs.size()));
|
||||||
for (const auto memberID : team->memberIDs)
|
for (const auto memberID : team->memberIDs) {
|
||||||
{
|
|
||||||
bitStream.Write(memberID);
|
bitStream.Write(memberID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -406,8 +364,7 @@ void PlayerContainer::UpdateTeamsOnWorld(TeamData* team, bool deleteTeam)
|
|||||||
Game::server->Send(&bitStream, UNASSIGNED_SYSTEM_ADDRESS, true);
|
Game::server->Send(&bitStream, UNASSIGNED_SYSTEM_ADDRESS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::u16string PlayerContainer::GetName(LWOOBJID playerID)
|
std::u16string PlayerContainer::GetName(LWOOBJID playerID) {
|
||||||
{
|
|
||||||
const auto& pair = mNames.find(playerID);
|
const auto& pair = mNames.find(playerID);
|
||||||
|
|
||||||
if (pair == mNames.end()) return u"";
|
if (pair == mNames.end()) return u"";
|
||||||
@ -415,12 +372,9 @@ std::u16string PlayerContainer::GetName(LWOOBJID playerID)
|
|||||||
return pair->second;
|
return pair->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
LWOOBJID PlayerContainer::GetId(const std::u16string& playerName)
|
LWOOBJID PlayerContainer::GetId(const std::u16string& playerName) {
|
||||||
{
|
for (const auto& pair : mNames) {
|
||||||
for (const auto& pair : mNames)
|
if (pair.second == playerName) {
|
||||||
{
|
|
||||||
if (pair.second == playerName)
|
|
||||||
{
|
|
||||||
return pair.first;
|
return pair.first;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -428,7 +382,6 @@ LWOOBJID PlayerContainer::GetId(const std::u16string& playerName)
|
|||||||
return LWOOBJID_EMPTY;
|
return LWOOBJID_EMPTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerContainer::GetIsMuted(PlayerData* data)
|
bool PlayerContainer::GetIsMuted(PlayerData* data) {
|
||||||
{
|
|
||||||
return data->muteExpire == 1 || data->muteExpire > time(NULL);
|
return data->muteExpire == 1 || data->muteExpire > time(NULL);
|
||||||
}
|
}
|
||||||
|
@ -221,8 +221,7 @@ bool GeneralUtils::ReplaceInString(std::string& str, const std::string& from, co
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::wstring> GeneralUtils::SplitString(std::wstring& str, wchar_t delimiter)
|
std::vector<std::wstring> GeneralUtils::SplitString(std::wstring& str, wchar_t delimiter) {
|
||||||
{
|
|
||||||
std::vector<std::wstring> vector = std::vector<std::wstring>();
|
std::vector<std::wstring> vector = std::vector<std::wstring>();
|
||||||
std::wstring current;
|
std::wstring current;
|
||||||
|
|
||||||
@ -239,8 +238,7 @@ std::vector<std::wstring> GeneralUtils::SplitString(std::wstring& str, wchar_t d
|
|||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::u16string> GeneralUtils::SplitString(std::u16string& str, char16_t delimiter)
|
std::vector<std::u16string> GeneralUtils::SplitString(std::u16string& str, char16_t delimiter) {
|
||||||
{
|
|
||||||
std::vector<std::u16string> vector = std::vector<std::u16string>();
|
std::vector<std::u16string> vector = std::vector<std::u16string>();
|
||||||
std::u16string current;
|
std::u16string current;
|
||||||
|
|
||||||
@ -257,22 +255,17 @@ std::vector<std::u16string> GeneralUtils::SplitString(std::u16string& str, char1
|
|||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> GeneralUtils::SplitString(const std::string& str, char delimiter)
|
std::vector<std::string> GeneralUtils::SplitString(const std::string& str, char delimiter) {
|
||||||
{
|
|
||||||
std::vector<std::string> vector = std::vector<std::string>();
|
std::vector<std::string> vector = std::vector<std::string>();
|
||||||
std::string current = "";
|
std::string current = "";
|
||||||
|
|
||||||
for (size_t i = 0; i < str.length(); i++)
|
for (size_t i = 0; i < str.length(); i++) {
|
||||||
{
|
|
||||||
char c = str[i];
|
char c = str[i];
|
||||||
|
|
||||||
if (c == delimiter)
|
if (c == delimiter) {
|
||||||
{
|
|
||||||
vector.push_back(current);
|
vector.push_back(current);
|
||||||
current = "";
|
current = "";
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
current += c;
|
current += c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -300,8 +293,7 @@ std::u16string GeneralUtils::ReadWString(RakNet::BitStream *inStream) {
|
|||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
std::vector<std::string> GeneralUtils::GetFileNamesFromFolder(const std::string& folder)
|
std::vector<std::string> GeneralUtils::GetFileNamesFromFolder(const std::string& folder) {
|
||||||
{
|
|
||||||
std::vector<std::string> names;
|
std::vector<std::string> names;
|
||||||
std::string search_path = folder + "/*.*";
|
std::string search_path = folder + "/*.*";
|
||||||
WIN32_FIND_DATA fd;
|
WIN32_FIND_DATA fd;
|
||||||
|
@ -120,8 +120,7 @@ namespace GeneralUtils {
|
|||||||
if constexpr (std::is_integral_v<T>) { // constexpr only necessary on first statement
|
if constexpr (std::is_integral_v<T>) { // constexpr only necessary on first statement
|
||||||
std::uniform_int_distribution<T> distribution(min, max);
|
std::uniform_int_distribution<T> distribution(min, max);
|
||||||
return distribution(Game::randomEngine);
|
return distribution(Game::randomEngine);
|
||||||
}
|
} else if (std::is_floating_point_v<T>) {
|
||||||
else if (std::is_floating_point_v<T>) {
|
|
||||||
std::uniform_real_distribution<T> distribution(min, max);
|
std::uniform_real_distribution<T> distribution(min, max);
|
||||||
return distribution(Game::randomEngine);
|
return distribution(Game::randomEngine);
|
||||||
}
|
}
|
||||||
@ -145,78 +144,64 @@ namespace GeneralUtils {
|
|||||||
T Parse(const char* value);
|
T Parse(const char* value);
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline int32_t Parse(const char* value)
|
inline int32_t Parse(const char* value) {
|
||||||
{
|
|
||||||
return std::stoi(value);
|
return std::stoi(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline int64_t Parse(const char* value)
|
inline int64_t Parse(const char* value) {
|
||||||
{
|
|
||||||
return std::stoll(value);
|
return std::stoll(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline float Parse(const char* value)
|
inline float Parse(const char* value) {
|
||||||
{
|
|
||||||
return std::stof(value);
|
return std::stof(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline double Parse(const char* value)
|
inline double Parse(const char* value) {
|
||||||
{
|
|
||||||
return std::stod(value);
|
return std::stod(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline uint32_t Parse(const char* value)
|
inline uint32_t Parse(const char* value) {
|
||||||
{
|
|
||||||
return std::stoul(value);
|
return std::stoul(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline uint64_t Parse(const char* value)
|
inline uint64_t Parse(const char* value) {
|
||||||
{
|
|
||||||
return std::stoull(value);
|
return std::stoull(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool TryParse(const char* value, T& dst)
|
bool TryParse(const char* value, T& dst) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
dst = Parse<T>(value);
|
dst = Parse<T>(value);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} catch (...) {
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T Parse(const std::string& value)
|
T Parse(const std::string& value) {
|
||||||
{
|
|
||||||
return Parse<T>(value.c_str());
|
return Parse<T>(value.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool TryParse(const std::string& value, T& dst)
|
bool TryParse(const std::string& value, T& dst) {
|
||||||
{
|
|
||||||
return TryParse<T>(value.c_str(), dst);
|
return TryParse<T>(value.c_str(), dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
std::u16string to_u16string(T value)
|
std::u16string to_u16string(T value) {
|
||||||
{
|
|
||||||
return GeneralUtils::ASCIIToUTF16(std::to_string(value));
|
return GeneralUtils::ASCIIToUTF16(std::to_string(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
// From boost::hash_combine
|
// From boost::hash_combine
|
||||||
template <class T>
|
template <class T>
|
||||||
void hash_combine(std::size_t& s, const T& v)
|
void hash_combine(std::size_t& s, const T& v) {
|
||||||
{
|
|
||||||
std::hash<T> h;
|
std::hash<T> h;
|
||||||
s ^= h(v) + 0x9e3779b9 + (s << 6) + (s >> 2);
|
s ^= h(v) + 0x9e3779b9 + (s << 6) + (s >> 2);
|
||||||
}
|
}
|
||||||
|
@ -72,16 +72,11 @@ LDFBaseData * LDFBaseData::DataFromString(const std::string& format) {
|
|||||||
{
|
{
|
||||||
uint32_t data;
|
uint32_t data;
|
||||||
|
|
||||||
if (dataArray[1] == "true")
|
if (dataArray[1] == "true") {
|
||||||
{
|
|
||||||
data = 1;
|
data = 1;
|
||||||
}
|
} else if (dataArray[1] == "false") {
|
||||||
else if (dataArray[1] == "false")
|
|
||||||
{
|
|
||||||
data = 0;
|
data = 0;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
data = static_cast<uint32_t>(stoul(dataArray[1]));
|
data = static_cast<uint32_t>(stoul(dataArray[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,16 +86,11 @@ LDFBaseData * LDFBaseData::DataFromString(const std::string& format) {
|
|||||||
case LDF_TYPE_BOOLEAN: {
|
case LDF_TYPE_BOOLEAN: {
|
||||||
bool data;
|
bool data;
|
||||||
|
|
||||||
if (dataArray[1] == "true")
|
if (dataArray[1] == "true") {
|
||||||
{
|
|
||||||
data = true;
|
data = true;
|
||||||
}
|
} else if (dataArray[1] == "false") {
|
||||||
else if (dataArray[1] == "false")
|
|
||||||
{
|
|
||||||
data = false;
|
data = false;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
data = static_cast<bool>(stoi(dataArray[1]));
|
data = static_cast<bool>(stoi(dataArray[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,16 +100,14 @@ inline void MD5::II(uint4 &a, uint4 b, uint4 c, uint4 d, uint4 x, uint4 s, uint4
|
|||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
// default ctor, just initailize
|
// default ctor, just initailize
|
||||||
MD5::MD5()
|
MD5::MD5() {
|
||||||
{
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////
|
//////////////////////////////////////////////
|
||||||
|
|
||||||
// nifty shortcut ctor, compute MD5 for string and finalize it right away
|
// nifty shortcut ctor, compute MD5 for string and finalize it right away
|
||||||
MD5::MD5(const std::string &text)
|
MD5::MD5(const std::string& text) {
|
||||||
{
|
|
||||||
init();
|
init();
|
||||||
update(text.c_str(), text.length());
|
update(text.c_str(), text.length());
|
||||||
finalize();
|
finalize();
|
||||||
@ -117,8 +115,7 @@ MD5::MD5(const std::string &text)
|
|||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|
||||||
void MD5::init()
|
void MD5::init() {
|
||||||
{
|
|
||||||
finalized = false;
|
finalized = false;
|
||||||
|
|
||||||
count[0] = 0;
|
count[0] = 0;
|
||||||
@ -134,8 +131,7 @@ void MD5::init()
|
|||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|
||||||
// decodes input (unsigned char) into output (uint4). Assumes len is a multiple of 4.
|
// decodes input (unsigned char) into output (uint4). Assumes len is a multiple of 4.
|
||||||
void MD5::decode(uint4 output[], const uint1 input[], size_type len)
|
void MD5::decode(uint4 output[], const uint1 input[], size_type len) {
|
||||||
{
|
|
||||||
for (unsigned int i = 0, j = 0; j < len; i++, j += 4)
|
for (unsigned int i = 0, j = 0; j < len; i++, j += 4)
|
||||||
output[i] = ((uint4)input[j]) | (((uint4)input[j + 1]) << 8) |
|
output[i] = ((uint4)input[j]) | (((uint4)input[j + 1]) << 8) |
|
||||||
(((uint4)input[j + 2]) << 16) | (((uint4)input[j + 3]) << 24);
|
(((uint4)input[j + 2]) << 16) | (((uint4)input[j + 3]) << 24);
|
||||||
@ -145,8 +141,7 @@ void MD5::decode(uint4 output[], const uint1 input[], size_type len)
|
|||||||
|
|
||||||
// encodes input (uint4) into output (unsigned char). Assumes len is
|
// encodes input (uint4) into output (unsigned char). Assumes len is
|
||||||
// a multiple of 4.
|
// a multiple of 4.
|
||||||
void MD5::encode(uint1 output[], const uint4 input[], size_type len)
|
void MD5::encode(uint1 output[], const uint4 input[], size_type len) {
|
||||||
{
|
|
||||||
for (size_type i = 0, j = 0; j < len; i++, j += 4) {
|
for (size_type i = 0, j = 0; j < len; i++, j += 4) {
|
||||||
output[j] = input[i] & 0xff;
|
output[j] = input[i] & 0xff;
|
||||||
output[j + 1] = (input[i] >> 8) & 0xff;
|
output[j + 1] = (input[i] >> 8) & 0xff;
|
||||||
@ -158,8 +153,7 @@ void MD5::encode(uint1 output[], const uint4 input[], size_type len)
|
|||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|
||||||
// apply MD5 algo on a block
|
// apply MD5 algo on a block
|
||||||
void MD5::transform(const uint1 block[blocksize])
|
void MD5::transform(const uint1 block[blocksize]) {
|
||||||
{
|
|
||||||
uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
|
uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
|
||||||
decode(x, block, blocksize);
|
decode(x, block, blocksize);
|
||||||
|
|
||||||
@ -248,8 +242,7 @@ void MD5::transform(const uint1 block[blocksize])
|
|||||||
|
|
||||||
// MD5 block update operation. Continues an MD5 message-digest
|
// MD5 block update operation. Continues an MD5 message-digest
|
||||||
// operation, processing another message block
|
// operation, processing another message block
|
||||||
void MD5::update(const unsigned char input[], size_type length)
|
void MD5::update(const unsigned char input[], size_type length) {
|
||||||
{
|
|
||||||
// compute number of bytes mod 64
|
// compute number of bytes mod 64
|
||||||
size_type index = count[0] / 8 % blocksize;
|
size_type index = count[0] / 8 % blocksize;
|
||||||
|
|
||||||
@ -264,8 +257,7 @@ void MD5::update(const unsigned char input[], size_type length)
|
|||||||
size_type i;
|
size_type i;
|
||||||
|
|
||||||
// transform as many times as possible.
|
// transform as many times as possible.
|
||||||
if (length >= firstpart)
|
if (length >= firstpart) {
|
||||||
{
|
|
||||||
// fill buffer first, transform
|
// fill buffer first, transform
|
||||||
memcpy(&buffer[index], input, firstpart);
|
memcpy(&buffer[index], input, firstpart);
|
||||||
transform(buffer);
|
transform(buffer);
|
||||||
@ -275,8 +267,7 @@ void MD5::update(const unsigned char input[], size_type length)
|
|||||||
transform(&input[i]);
|
transform(&input[i]);
|
||||||
|
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
// buffer remaining input
|
// buffer remaining input
|
||||||
@ -286,8 +277,7 @@ void MD5::update(const unsigned char input[], size_type length)
|
|||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|
||||||
// for convenience provide a verson with signed char
|
// for convenience provide a verson with signed char
|
||||||
void MD5::update(const char input[], size_type length)
|
void MD5::update(const char input[], size_type length) {
|
||||||
{
|
|
||||||
update((const unsigned char*)input, length);
|
update((const unsigned char*)input, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,8 +285,7 @@ void MD5::update(const char input[], size_type length)
|
|||||||
|
|
||||||
// MD5 finalization. Ends an MD5 message-digest operation, writing the
|
// MD5 finalization. Ends an MD5 message-digest operation, writing the
|
||||||
// the message digest and zeroizing the context.
|
// the message digest and zeroizing the context.
|
||||||
MD5& MD5::finalize()
|
MD5& MD5::finalize() {
|
||||||
{
|
|
||||||
static unsigned char padding[64] = {
|
static unsigned char padding[64] = {
|
||||||
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
@ -332,8 +321,7 @@ MD5& MD5::finalize()
|
|||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|
||||||
// return hex representation of digest as string
|
// return hex representation of digest as string
|
||||||
std::string MD5::hexdigest() const
|
std::string MD5::hexdigest() const {
|
||||||
{
|
|
||||||
if (!finalized)
|
if (!finalized)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
@ -347,15 +335,13 @@ std::string MD5::hexdigest() const
|
|||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& out, MD5 md5)
|
std::ostream& operator<<(std::ostream& out, MD5 md5) {
|
||||||
{
|
|
||||||
return out << md5.hexdigest();
|
return out << md5.hexdigest();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|
||||||
std::string md5(const std::string str)
|
std::string md5(const std::string str) {
|
||||||
{
|
|
||||||
MD5 md5 = MD5(str);
|
MD5 md5 = MD5(str);
|
||||||
|
|
||||||
return md5.hexdigest();
|
return md5.hexdigest();
|
||||||
|
@ -16,55 +16,44 @@ std::vector<MetricVariable> Metrics::m_Variables = {
|
|||||||
MetricVariable::Frame,
|
MetricVariable::Frame,
|
||||||
};
|
};
|
||||||
|
|
||||||
void Metrics::AddMeasurement(MetricVariable variable, int64_t value)
|
void Metrics::AddMeasurement(MetricVariable variable, int64_t value) {
|
||||||
{
|
|
||||||
const auto& iter = m_Metrics.find(variable);
|
const auto& iter = m_Metrics.find(variable);
|
||||||
|
|
||||||
Metric* metric;
|
Metric* metric;
|
||||||
|
|
||||||
if (iter == m_Metrics.end())
|
if (iter == m_Metrics.end()) {
|
||||||
{
|
|
||||||
metric = new Metric();
|
metric = new Metric();
|
||||||
|
|
||||||
m_Metrics[variable] = metric;
|
m_Metrics[variable] = metric;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
metric = iter->second;
|
metric = iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
AddMeasurement(metric, value);
|
AddMeasurement(metric, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Metrics::AddMeasurement(Metric* metric, int64_t value)
|
void Metrics::AddMeasurement(Metric* metric, int64_t value) {
|
||||||
{
|
|
||||||
const auto index = metric->measurementIndex;
|
const auto index = metric->measurementIndex;
|
||||||
|
|
||||||
metric->measurements[index] = value;
|
metric->measurements[index] = value;
|
||||||
|
|
||||||
if (metric->max == -1 || value > metric->max)
|
if (metric->max == -1 || value > metric->max) {
|
||||||
{
|
|
||||||
metric->max = value;
|
metric->max = value;
|
||||||
}
|
} else if (metric->min == -1 || metric->min > value) {
|
||||||
else if (metric->min == -1 || metric->min > value)
|
|
||||||
{
|
|
||||||
metric->min = value;
|
metric->min = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metric->measurementSize < MAX_MEASURMENT_POINTS)
|
if (metric->measurementSize < MAX_MEASURMENT_POINTS) {
|
||||||
{
|
|
||||||
metric->measurementSize++;
|
metric->measurementSize++;
|
||||||
}
|
}
|
||||||
|
|
||||||
metric->measurementIndex = (index + 1) % MAX_MEASURMENT_POINTS;
|
metric->measurementIndex = (index + 1) % MAX_MEASURMENT_POINTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Metric* Metrics::GetMetric(MetricVariable variable)
|
const Metric* Metrics::GetMetric(MetricVariable variable) {
|
||||||
{
|
|
||||||
const auto& iter = m_Metrics.find(variable);
|
const auto& iter = m_Metrics.find(variable);
|
||||||
|
|
||||||
if (iter == m_Metrics.end())
|
if (iter == m_Metrics.end()) {
|
||||||
{
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,8 +61,7 @@ const Metric* Metrics::GetMetric(MetricVariable variable)
|
|||||||
|
|
||||||
int64_t average = 0;
|
int64_t average = 0;
|
||||||
|
|
||||||
for (size_t i = 0; i < metric->measurementSize; i++)
|
for (size_t i = 0; i < metric->measurementSize; i++) {
|
||||||
{
|
|
||||||
average += metric->measurements[i];
|
average += metric->measurements[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,34 +72,28 @@ const Metric* Metrics::GetMetric(MetricVariable variable)
|
|||||||
return metric;
|
return metric;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Metrics::StartMeasurement(MetricVariable variable)
|
void Metrics::StartMeasurement(MetricVariable variable) {
|
||||||
{
|
|
||||||
const auto& iter = m_Metrics.find(variable);
|
const auto& iter = m_Metrics.find(variable);
|
||||||
|
|
||||||
Metric* metric;
|
Metric* metric;
|
||||||
|
|
||||||
if (iter == m_Metrics.end())
|
if (iter == m_Metrics.end()) {
|
||||||
{
|
|
||||||
metric = new Metric();
|
metric = new Metric();
|
||||||
|
|
||||||
m_Metrics[variable] = metric;
|
m_Metrics[variable] = metric;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
metric = iter->second;
|
metric = iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
metric->activeMeasurement = std::chrono::high_resolution_clock::now();
|
metric->activeMeasurement = std::chrono::high_resolution_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Metrics::EndMeasurement(MetricVariable variable)
|
void Metrics::EndMeasurement(MetricVariable variable) {
|
||||||
{
|
|
||||||
const auto end = std::chrono::high_resolution_clock::now();
|
const auto end = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
const auto& iter = m_Metrics.find(variable);
|
const auto& iter = m_Metrics.find(variable);
|
||||||
|
|
||||||
if (iter == m_Metrics.end())
|
if (iter == m_Metrics.end()) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,15 +106,12 @@ void Metrics::EndMeasurement(MetricVariable variable)
|
|||||||
AddMeasurement(metric, nanoseconds);
|
AddMeasurement(metric, nanoseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Metrics::ToMiliseconds(int64_t nanoseconds)
|
float Metrics::ToMiliseconds(int64_t nanoseconds) {
|
||||||
{
|
|
||||||
return (float)nanoseconds / 1e6;
|
return (float)nanoseconds / 1e6;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Metrics::MetricVariableToString(MetricVariable variable)
|
std::string Metrics::MetricVariableToString(MetricVariable variable) {
|
||||||
{
|
switch (variable) {
|
||||||
switch (variable)
|
|
||||||
{
|
|
||||||
case MetricVariable::GameLoop:
|
case MetricVariable::GameLoop:
|
||||||
return "GameLoop";
|
return "GameLoop";
|
||||||
case MetricVariable::PacketHandling:
|
case MetricVariable::PacketHandling:
|
||||||
@ -159,15 +138,12 @@ std::string Metrics::MetricVariableToString(MetricVariable variable)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<MetricVariable>& Metrics::GetAllMetrics()
|
const std::vector<MetricVariable>& Metrics::GetAllMetrics() {
|
||||||
{
|
|
||||||
return m_Variables;
|
return m_Variables;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Metrics::Clear()
|
void Metrics::Clear() {
|
||||||
{
|
for (const auto& pair : m_Metrics) {
|
||||||
for (const auto& pair : m_Metrics)
|
|
||||||
{
|
|
||||||
delete pair.second;
|
delete pair.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,8 +188,7 @@ void Metrics::Clear()
|
|||||||
* memory use) measured in bytes, or zero if the value cannot be
|
* memory use) measured in bytes, or zero if the value cannot be
|
||||||
* determined on this OS.
|
* determined on this OS.
|
||||||
*/
|
*/
|
||||||
size_t Metrics::GetPeakRSS()
|
size_t Metrics::GetPeakRSS() {
|
||||||
{
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
/* Windows -------------------------------------------------- */
|
/* Windows -------------------------------------------------- */
|
||||||
PROCESS_MEMORY_COUNTERS info;
|
PROCESS_MEMORY_COUNTERS info;
|
||||||
@ -226,8 +201,7 @@ size_t Metrics::GetPeakRSS()
|
|||||||
int fd = -1;
|
int fd = -1;
|
||||||
if ((fd = open("/proc/self/psinfo", O_RDONLY)) == -1)
|
if ((fd = open("/proc/self/psinfo", O_RDONLY)) == -1)
|
||||||
return (size_t)0L; /* Can't open? */
|
return (size_t)0L; /* Can't open? */
|
||||||
if ( read( fd, &psinfo, sizeof(psinfo) ) != sizeof(psinfo) )
|
if (read(fd, &psinfo, sizeof(psinfo)) != sizeof(psinfo)) {
|
||||||
{
|
|
||||||
close(fd);
|
close(fd);
|
||||||
return (size_t)0L; /* Can't read? */
|
return (size_t)0L; /* Can't read? */
|
||||||
}
|
}
|
||||||
@ -255,8 +229,7 @@ size_t Metrics::GetPeakRSS()
|
|||||||
* Returns the current resident set size (physical memory use) measured
|
* Returns the current resident set size (physical memory use) measured
|
||||||
* in bytes, or zero if the value cannot be determined on this OS.
|
* in bytes, or zero if the value cannot be determined on this OS.
|
||||||
*/
|
*/
|
||||||
size_t Metrics::GetCurrentRSS()
|
size_t Metrics::GetCurrentRSS() {
|
||||||
{
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
/* Windows -------------------------------------------------- */
|
/* Windows -------------------------------------------------- */
|
||||||
PROCESS_MEMORY_COUNTERS info;
|
PROCESS_MEMORY_COUNTERS info;
|
||||||
@ -278,8 +251,7 @@ size_t Metrics::GetCurrentRSS()
|
|||||||
FILE* fp = NULL;
|
FILE* fp = NULL;
|
||||||
if ((fp = fopen("/proc/self/statm", "r")) == NULL)
|
if ((fp = fopen("/proc/self/statm", "r")) == NULL)
|
||||||
return (size_t)0L; /* Can't open? */
|
return (size_t)0L; /* Can't open? */
|
||||||
if ( fscanf( fp, "%*s%ld", &rss ) != 1 )
|
if (fscanf(fp, "%*s%ld", &rss) != 1) {
|
||||||
{
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return (size_t)0L; /* Can't read? */
|
return (size_t)0L; /* Can't read? */
|
||||||
}
|
}
|
||||||
@ -293,8 +265,7 @@ size_t Metrics::GetCurrentRSS()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Metrics::GetProcessID()
|
size_t Metrics::GetProcessID() {
|
||||||
{
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
return GetCurrentProcessId();
|
return GetCurrentProcessId();
|
||||||
#else
|
#else
|
||||||
|
@ -175,8 +175,7 @@ bool NiPoint3::IsWithinSpehere(const NiPoint3& sphereCenter, float radius) {
|
|||||||
return (diffVec.SquaredLength() <= (radius * radius));
|
return (diffVec.SquaredLength() <= (radius * radius));
|
||||||
}
|
}
|
||||||
|
|
||||||
NiPoint3 NiPoint3::ClosestPointOnLine(const NiPoint3& a, const NiPoint3& b, const NiPoint3& p)
|
NiPoint3 NiPoint3::ClosestPointOnLine(const NiPoint3& a, const NiPoint3& b, const NiPoint3& p) {
|
||||||
{
|
|
||||||
if (a == b) return a;
|
if (a == b) return a;
|
||||||
|
|
||||||
const auto pa = p - a;
|
const auto pa = p - a;
|
||||||
@ -191,16 +190,14 @@ NiPoint3 NiPoint3::ClosestPointOnLine(const NiPoint3& a, const NiPoint3& b, cons
|
|||||||
return a + ab * t;
|
return a + ab * t;
|
||||||
}
|
}
|
||||||
|
|
||||||
float NiPoint3::Angle(const NiPoint3& a, const NiPoint3& b)
|
float NiPoint3::Angle(const NiPoint3& a, const NiPoint3& b) {
|
||||||
{
|
|
||||||
const auto dot = a.DotProduct(b);
|
const auto dot = a.DotProduct(b);
|
||||||
const auto lenA = a.SquaredLength();
|
const auto lenA = a.SquaredLength();
|
||||||
const auto lenB = a.SquaredLength();
|
const auto lenB = a.SquaredLength();
|
||||||
return acos(dot / sqrt(lenA * lenB));
|
return acos(dot / sqrt(lenA * lenB));
|
||||||
}
|
}
|
||||||
|
|
||||||
float NiPoint3::Distance(const NiPoint3& a, const NiPoint3& b)
|
float NiPoint3::Distance(const NiPoint3& a, const NiPoint3& b) {
|
||||||
{
|
|
||||||
const auto dx = a.x - b.x;
|
const auto dx = a.x - b.x;
|
||||||
const auto dy = a.y - b.y;
|
const auto dy = a.y - b.y;
|
||||||
const auto dz = a.z - b.z;
|
const auto dz = a.z - b.z;
|
||||||
@ -208,8 +205,7 @@ float NiPoint3::Distance(const NiPoint3& a, const NiPoint3& b)
|
|||||||
return std::sqrt(dx * dx + dy * dy + dz * dz);
|
return std::sqrt(dx * dx + dy * dy + dz * dz);
|
||||||
}
|
}
|
||||||
|
|
||||||
float NiPoint3::DistanceSquared(const NiPoint3& a, const NiPoint3& b)
|
float NiPoint3::DistanceSquared(const NiPoint3& a, const NiPoint3& b) {
|
||||||
{
|
|
||||||
const auto dx = a.x - b.x;
|
const auto dx = a.x - b.x;
|
||||||
const auto dy = a.y - b.y;
|
const auto dy = a.y - b.y;
|
||||||
const auto dz = a.z - b.z;
|
const auto dz = a.z - b.z;
|
||||||
@ -217,8 +213,7 @@ float NiPoint3::DistanceSquared(const NiPoint3& a, const NiPoint3& b)
|
|||||||
return dx * dx + dy * dy + dz * dz;
|
return dx * dx + dy * dy + dz * dz;
|
||||||
}
|
}
|
||||||
|
|
||||||
NiPoint3 NiPoint3::MoveTowards(const NiPoint3& current, const NiPoint3& target, float maxDistanceDelta)
|
NiPoint3 NiPoint3::MoveTowards(const NiPoint3& current, const NiPoint3& target, float maxDistanceDelta) {
|
||||||
{
|
|
||||||
float dx = target.x - current.x;
|
float dx = target.x - current.x;
|
||||||
float dy = target.y - current.y;
|
float dy = target.y - current.y;
|
||||||
float dz = target.z - current.z;
|
float dz = target.z - current.z;
|
||||||
|
@ -99,8 +99,7 @@ Vector3 NiQuaternion::GetEulerAngles() const {
|
|||||||
|
|
||||||
if (std::abs(sinp) >= 1) {
|
if (std::abs(sinp) >= 1) {
|
||||||
angles.y = std::copysign(3.14 / 2, sinp); // use 90 degrees if out of range
|
angles.y = std::copysign(3.14 / 2, sinp); // use 90 degrees if out of range
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
angles.y = std::asin(sinp);
|
angles.y = std::asin(sinp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,8 +148,7 @@ NiQuaternion NiQuaternion::LookAt(const NiPoint3& sourcePoint, const NiPoint3& d
|
|||||||
return NiQuaternion::CreateFromAxisAngle(vecA, rotAngle);
|
return NiQuaternion::CreateFromAxisAngle(vecA, rotAngle);
|
||||||
}
|
}
|
||||||
|
|
||||||
NiQuaternion NiQuaternion::LookAtUnlocked(const NiPoint3& sourcePoint, const NiPoint3& destPoint)
|
NiQuaternion NiQuaternion::LookAtUnlocked(const NiPoint3& sourcePoint, const NiPoint3& destPoint) {
|
||||||
{
|
|
||||||
NiPoint3 forwardVector = NiPoint3(destPoint - sourcePoint).Unitize();
|
NiPoint3 forwardVector = NiPoint3(destPoint - sourcePoint).Unitize();
|
||||||
|
|
||||||
NiPoint3 posZ = NiPoint3::UNIT_Z;
|
NiPoint3 posZ = NiPoint3::UNIT_Z;
|
||||||
@ -179,8 +177,7 @@ NiQuaternion NiQuaternion::CreateFromAxisAngle(const Vector3& axis, float angle)
|
|||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
|
|
||||||
NiQuaternion NiQuaternion::FromEulerAngles(const NiPoint3& eulerAngles)
|
NiQuaternion NiQuaternion::FromEulerAngles(const NiPoint3& eulerAngles) {
|
||||||
{
|
|
||||||
// Abbreviations for the various angular functions
|
// Abbreviations for the various angular functions
|
||||||
float cy = cos(eulerAngles.z * 0.5);
|
float cy = cos(eulerAngles.z * 0.5);
|
||||||
float sy = sin(eulerAngles.z * 0.5);
|
float sy = sin(eulerAngles.z * 0.5);
|
||||||
|
@ -45,8 +45,7 @@ const unsigned long long SHA512::sha512_k[80] = //ULL = uint64
|
|||||||
0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL,
|
0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL,
|
||||||
0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL };
|
0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL };
|
||||||
|
|
||||||
void SHA512::transform(const unsigned char *message, unsigned int block_nb)
|
void SHA512::transform(const unsigned char* message, unsigned int block_nb) {
|
||||||
{
|
|
||||||
uint64 w[80];
|
uint64 w[80];
|
||||||
uint64 wv[8];
|
uint64 wv[8];
|
||||||
uint64 t1, t2;
|
uint64 t1, t2;
|
||||||
@ -83,8 +82,7 @@ void SHA512::transform(const unsigned char *message, unsigned int block_nb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHA512::init()
|
void SHA512::init() {
|
||||||
{
|
|
||||||
m_h[0] = 0x6a09e667f3bcc908ULL;
|
m_h[0] = 0x6a09e667f3bcc908ULL;
|
||||||
m_h[1] = 0xbb67ae8584caa73bULL;
|
m_h[1] = 0xbb67ae8584caa73bULL;
|
||||||
m_h[2] = 0x3c6ef372fe94f82bULL;
|
m_h[2] = 0x3c6ef372fe94f82bULL;
|
||||||
@ -97,8 +95,7 @@ void SHA512::init()
|
|||||||
m_tot_len = 0;
|
m_tot_len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHA512::update(const unsigned char *message, unsigned int len)
|
void SHA512::update(const unsigned char* message, unsigned int len) {
|
||||||
{
|
|
||||||
unsigned int block_nb;
|
unsigned int block_nb;
|
||||||
unsigned int new_len, rem_len, tmp_len;
|
unsigned int new_len, rem_len, tmp_len;
|
||||||
const unsigned char* shifted_message;
|
const unsigned char* shifted_message;
|
||||||
@ -120,8 +117,7 @@ void SHA512::update(const unsigned char *message, unsigned int len)
|
|||||||
m_tot_len += (block_nb + 1) << 7;
|
m_tot_len += (block_nb + 1) << 7;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SHA512::final(unsigned char *digest)
|
void SHA512::final(unsigned char* digest) {
|
||||||
{
|
|
||||||
unsigned int block_nb;
|
unsigned int block_nb;
|
||||||
unsigned int pm_len;
|
unsigned int pm_len;
|
||||||
unsigned int len_b;
|
unsigned int len_b;
|
||||||
@ -139,8 +135,7 @@ void SHA512::final(unsigned char *digest)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string sha512(std::string input)
|
std::string sha512(std::string input) {
|
||||||
{
|
|
||||||
unsigned char digest[SHA512::DIGEST_SIZE];
|
unsigned char digest[SHA512::DIGEST_SIZE];
|
||||||
memset(digest, 0, SHA512::DIGEST_SIZE);
|
memset(digest, 0, SHA512::DIGEST_SIZE);
|
||||||
class SHA512 ctx;
|
class SHA512 ctx;
|
||||||
|
@ -4,16 +4,13 @@
|
|||||||
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
namespace ZCompression
|
namespace ZCompression {
|
||||||
{
|
int32_t GetMaxCompressedLength(int32_t nLenSrc) {
|
||||||
int32_t GetMaxCompressedLength(int32_t nLenSrc)
|
|
||||||
{
|
|
||||||
int32_t n16kBlocks = (nLenSrc + 16383) / 16384; // round up any fraction of a block
|
int32_t n16kBlocks = (nLenSrc + 16383) / 16384; // round up any fraction of a block
|
||||||
return (nLenSrc + 6 + (n16kBlocks * 5));
|
return (nLenSrc + 6 + (n16kBlocks * 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Compress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst)
|
int32_t Compress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst) {
|
||||||
{
|
|
||||||
z_stream zInfo = { 0 };
|
z_stream zInfo = { 0 };
|
||||||
zInfo.total_in = zInfo.avail_in = nLenSrc;
|
zInfo.total_in = zInfo.avail_in = nLenSrc;
|
||||||
zInfo.total_out = zInfo.avail_out = nLenDst;
|
zInfo.total_out = zInfo.avail_out = nLenDst;
|
||||||
@ -33,8 +30,7 @@ namespace ZCompression
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t Decompress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst, int32_t& nErr)
|
int32_t Decompress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst, int32_t& nErr) {
|
||||||
{
|
|
||||||
// Get the size of the decompressed data
|
// Get the size of the decompressed data
|
||||||
z_stream zInfo = { 0 };
|
z_stream zInfo = { 0 };
|
||||||
zInfo.total_in = zInfo.avail_in = nLenSrc;
|
zInfo.total_in = zInfo.avail_in = nLenSrc;
|
||||||
|
@ -6,8 +6,7 @@
|
|||||||
|
|
||||||
#ifndef DARKFLAME_PLATFORM_WIN32
|
#ifndef DARKFLAME_PLATFORM_WIN32
|
||||||
|
|
||||||
namespace ZCompression
|
namespace ZCompression {
|
||||||
{
|
|
||||||
int32_t GetMaxCompressedLength(int32_t nLenSrc);
|
int32_t GetMaxCompressedLength(int32_t nLenSrc);
|
||||||
|
|
||||||
int32_t Compress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst);
|
int32_t Compress(const uint8_t* abSrc, int32_t nLenSrc, uint8_t* abDst, int32_t nLenDst);
|
||||||
|
@ -542,7 +542,7 @@ enum ePlayerFlags {
|
|||||||
TOOLTIP_TALK_TO_SKYLAND_TO_GET_HAT = 52,
|
TOOLTIP_TALK_TO_SKYLAND_TO_GET_HAT = 52,
|
||||||
MODULAR_BUILD_PLAYER_PLACES_FIRST_MODEL_IN_SCRATCH = 53,
|
MODULAR_BUILD_PLAYER_PLACES_FIRST_MODEL_IN_SCRATCH = 53,
|
||||||
MODULAR_BUILD_FIRST_ARROW_DISPLAY_FOR_MODULE = 54,
|
MODULAR_BUILD_FIRST_ARROW_DISPLAY_FOR_MODULE = 54,
|
||||||
AG_BEACON_QB,_SO_THE_PLAYER_CAN_ALWAYS_BUILD_THEM = 55,
|
AG_BEACON_QB_SO_THE_PLAYER_CAN_ALWAYS_BUILD_THEM = 55,
|
||||||
GF_PET_DIG_FLAG_1 = 56,
|
GF_PET_DIG_FLAG_1 = 56,
|
||||||
GF_PET_DIG_FLAG_2 = 57,
|
GF_PET_DIG_FLAG_2 = 57,
|
||||||
GF_PET_DIG_FLAG_3 = 58,
|
GF_PET_DIG_FLAG_3 = 58,
|
||||||
|
@ -66,8 +66,7 @@ sql::PreparedStatement* Database::CreatePreppedStmt(const std::string& query) {
|
|||||||
Game::logger->Log("Database", "Trying to reconnect to MySQL");
|
Game::logger->Log("Database", "Trying to reconnect to MySQL");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!con->isValid() || con->isClosed())
|
if (!con->isValid() || con->isClosed()) {
|
||||||
{
|
|
||||||
delete con;
|
delete con;
|
||||||
|
|
||||||
con = nullptr;
|
con = nullptr;
|
||||||
|
@ -47,8 +47,7 @@ void MigrationRunner::RunMigrations() {
|
|||||||
auto simpleStatement = Database::CreateStmt();
|
auto simpleStatement = Database::CreateStmt();
|
||||||
simpleStatement->execute(finalSQL);
|
simpleStatement->execute(finalSQL);
|
||||||
delete simpleStatement;
|
delete simpleStatement;
|
||||||
}
|
} catch (sql::SQLException e) {
|
||||||
catch (sql::SQLException e) {
|
|
||||||
Game::logger->Log("MigrationRunner", "Encountered error running migration: %s", e.what());
|
Game::logger->Log("MigrationRunner", "Encountered error running migration: %s", e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,7 @@ std::string CDBehaviorParameterTable::GetName(void) const {
|
|||||||
return "BehaviorParameter";
|
return "BehaviorParameter";
|
||||||
}
|
}
|
||||||
|
|
||||||
CDBehaviorParameter CDBehaviorParameterTable::GetEntry(const uint32_t behaviorID, const std::string& name, const float defaultValue)
|
CDBehaviorParameter CDBehaviorParameterTable::GetEntry(const uint32_t behaviorID, const std::string& name, const float defaultValue) {
|
||||||
{
|
|
||||||
CDBehaviorParameter returnValue;
|
CDBehaviorParameter returnValue;
|
||||||
returnValue.behaviorID = 0;
|
returnValue.behaviorID = 0;
|
||||||
returnValue.parameterID = m_ParametersList.end();
|
returnValue.parameterID = m_ParametersList.end();
|
||||||
|
@ -63,12 +63,10 @@ std::string CDComponentsRegistryTable::GetName(void) const {
|
|||||||
return "ComponentsRegistry";
|
return "ComponentsRegistry";
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, uint32_t componentType, int32_t defaultValue)
|
int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, uint32_t componentType, int32_t defaultValue) {
|
||||||
{
|
|
||||||
const auto& iter = this->mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id));
|
const auto& iter = this->mappedEntries.find(((uint64_t)componentType) << 32 | ((uint64_t)id));
|
||||||
|
|
||||||
if (iter == this->mappedEntries.end())
|
if (iter == this->mappedEntries.end()) {
|
||||||
{
|
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,8 +104,7 @@ int32_t CDComponentsRegistryTable::GetByIDAndType(uint32_t id, uint32_t componen
|
|||||||
if (iter == it->second.end()) {
|
if (iter == it->second.end()) {
|
||||||
it->second.insert(std::make_pair(entry.component_type, entry.component_id));
|
it->second.insert(std::make_pair(entry.component_type, entry.component_id));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
std::map<unsigned int, unsigned int> map;
|
std::map<unsigned int, unsigned int> map;
|
||||||
map.insert(std::make_pair(entry.component_type, entry.component_id));
|
map.insert(std::make_pair(entry.component_type, entry.component_id));
|
||||||
this->mappedEntries.insert(std::make_pair(entry.id, map));
|
this->mappedEntries.insert(std::make_pair(entry.id, map));
|
||||||
|
@ -52,12 +52,9 @@ std::vector<CDFeatureGating> CDFeatureGatingTable::Query(std::function<bool(CDFe
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CDFeatureGatingTable::FeatureUnlocked(const std::string& feature) const
|
bool CDFeatureGatingTable::FeatureUnlocked(const std::string& feature) const {
|
||||||
{
|
for (const auto& entry : entries) {
|
||||||
for (const auto& entry : entries)
|
if (entry.featureName == feature) {
|
||||||
{
|
|
||||||
if (entry.featureName == feature)
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,8 +55,7 @@ std::vector<CDItemSetSkills> CDItemSetSkillsTable::GetEntries(void) const {
|
|||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CDItemSetSkills> CDItemSetSkillsTable::GetBySkillID(unsigned int SkillSetID)
|
std::vector<CDItemSetSkills> CDItemSetSkillsTable::GetBySkillID(unsigned int SkillSetID) {
|
||||||
{
|
|
||||||
std::vector<CDItemSetSkills> toReturn;
|
std::vector<CDItemSetSkills> toReturn;
|
||||||
|
|
||||||
for (CDItemSetSkills entry : this->entries) {
|
for (CDItemSetSkills entry : this->entries) {
|
||||||
|
@ -60,14 +60,11 @@ std::vector<CDMissionTasks> CDMissionTasksTable::Query(std::function<bool(CDMiss
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<CDMissionTasks*> CDMissionTasksTable::GetByMissionID(uint32_t missionID)
|
std::vector<CDMissionTasks*> CDMissionTasksTable::GetByMissionID(uint32_t missionID) {
|
||||||
{
|
|
||||||
std::vector<CDMissionTasks*> tasks;
|
std::vector<CDMissionTasks*> tasks;
|
||||||
|
|
||||||
for (auto& entry : this->entries)
|
for (auto& entry : this->entries) {
|
||||||
{
|
if (entry.id == missionID) {
|
||||||
if (entry.id == missionID)
|
|
||||||
{
|
|
||||||
CDMissionTasks* task = const_cast<CDMissionTasks*>(&entry);
|
CDMissionTasks* task = const_cast<CDMissionTasks*>(&entry);
|
||||||
|
|
||||||
tasks.push_back(task);
|
tasks.push_back(task);
|
||||||
|
@ -108,12 +108,9 @@ const std::vector<CDMissions>& CDMissionsTable::GetEntries(void) const {
|
|||||||
return this->entries;
|
return this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CDMissions* CDMissionsTable::GetPtrByMissionID(uint32_t missionID) const
|
const CDMissions* CDMissionsTable::GetPtrByMissionID(uint32_t missionID) const {
|
||||||
{
|
for (const auto& entry : entries) {
|
||||||
for (const auto& entry : entries)
|
if (entry.id == missionID) {
|
||||||
{
|
|
||||||
if (entry.id == missionID)
|
|
||||||
{
|
|
||||||
return const_cast<CDMissions*>(&entry);
|
return const_cast<CDMissions*>(&entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,12 +118,9 @@ const CDMissions* CDMissionsTable::GetPtrByMissionID(uint32_t missionID) const
|
|||||||
return &Default;
|
return &Default;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CDMissions& CDMissionsTable::GetByMissionID(uint32_t missionID, bool& found) const
|
const CDMissions& CDMissionsTable::GetByMissionID(uint32_t missionID, bool& found) const {
|
||||||
{
|
for (const auto& entry : entries) {
|
||||||
for (const auto& entry : entries)
|
if (entry.id == missionID) {
|
||||||
{
|
|
||||||
if (entry.id == missionID)
|
|
||||||
{
|
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
|
@ -15,23 +15,19 @@ struct CDRarityTable {
|
|||||||
unsigned int rarity;
|
unsigned int rarity;
|
||||||
unsigned int RarityTableIndex;
|
unsigned int RarityTableIndex;
|
||||||
|
|
||||||
friend bool operator> (const CDRarityTable& c1, const CDRarityTable& c2)
|
friend bool operator> (const CDRarityTable& c1, const CDRarityTable& c2) {
|
||||||
{
|
|
||||||
return c1.rarity > c2.rarity;
|
return c1.rarity > c2.rarity;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator>= (const CDRarityTable& c1, const CDRarityTable& c2)
|
friend bool operator>= (const CDRarityTable& c1, const CDRarityTable& c2) {
|
||||||
{
|
|
||||||
return c1.rarity >= c2.rarity;
|
return c1.rarity >= c2.rarity;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator< (const CDRarityTable& c1, const CDRarityTable& c2)
|
friend bool operator< (const CDRarityTable& c1, const CDRarityTable& c2) {
|
||||||
{
|
|
||||||
return c1.rarity < c2.rarity;
|
return c1.rarity < c2.rarity;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator<= (const CDRarityTable& c1, const CDRarityTable& c2)
|
friend bool operator<= (const CDRarityTable& c1, const CDRarityTable& c2) {
|
||||||
{
|
|
||||||
return c1.rarity <= c2.rarity;
|
return c1.rarity <= c2.rarity;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -65,8 +65,7 @@ std::string CDZoneTableTable::GetName(void) const {
|
|||||||
const CDZoneTable* CDZoneTableTable::Query(unsigned int zoneID) {
|
const CDZoneTable* CDZoneTableTable::Query(unsigned int zoneID) {
|
||||||
const auto& iter = m_Entries.find(zoneID);
|
const auto& iter = m_Entries.find(zoneID);
|
||||||
|
|
||||||
if (iter != m_Entries.end())
|
if (iter != m_Entries.end()) {
|
||||||
{
|
|
||||||
return &iter->second;
|
return &iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,8 +78,7 @@ Character::~Character() {
|
|||||||
m_Doc = nullptr;
|
m_Doc = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Character::UpdateFromDatabase()
|
void Character::UpdateFromDatabase() {
|
||||||
{
|
|
||||||
sql::PreparedStatement* stmt = Database::CreatePreppedStmt(
|
sql::PreparedStatement* stmt = Database::CreatePreppedStmt(
|
||||||
"SELECT name, pending_name, needs_rename, prop_clone_id, permission_map FROM charinfo WHERE id=? LIMIT 1;"
|
"SELECT name, pending_name, needs_rename, prop_clone_id, permission_map FROM charinfo WHERE id=? LIMIT 1;"
|
||||||
);
|
);
|
||||||
@ -179,8 +178,7 @@ void Character::DoQuickXMLDataParse() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (bag != nullptr)
|
while (bag != nullptr) {
|
||||||
{
|
|
||||||
auto* sib = bag->FirstChildElement();
|
auto* sib = bag->FirstChildElement();
|
||||||
|
|
||||||
while (sib != nullptr) {
|
while (sib != nullptr) {
|
||||||
@ -279,14 +277,12 @@ void Character::DoQuickXMLDataParse() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Character::UnlockEmote(int emoteID)
|
void Character::UnlockEmote(int emoteID) {
|
||||||
{
|
|
||||||
m_UnlockedEmotes.push_back(emoteID);
|
m_UnlockedEmotes.push_back(emoteID);
|
||||||
GameMessages::SendSetEmoteLockState(EntityManager::Instance()->GetEntity(m_ObjectID), false, emoteID);
|
GameMessages::SendSetEmoteLockState(EntityManager::Instance()->GetEntity(m_ObjectID), false, emoteID);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Character::SetBuildMode(bool buildMode)
|
void Character::SetBuildMode(bool buildMode) {
|
||||||
{
|
|
||||||
m_BuildMode = buildMode;
|
m_BuildMode = buildMode;
|
||||||
|
|
||||||
auto* controller = dZoneManager::Instance()->GetZoneControlObject();
|
auto* controller = dZoneManager::Instance()->GetZoneControlObject();
|
||||||
@ -389,17 +385,14 @@ void Character::SetPlayerFlag(const uint32_t flagId, const bool value) {
|
|||||||
// If the flag is already set, we don't have to recalculate it
|
// If the flag is already set, we don't have to recalculate it
|
||||||
if (GetPlayerFlag(flagId) == value) return;
|
if (GetPlayerFlag(flagId) == value) return;
|
||||||
|
|
||||||
if (value)
|
if (value) {
|
||||||
{
|
|
||||||
// Update the mission component:
|
// Update the mission component:
|
||||||
auto* player = EntityManager::Instance()->GetEntity(m_ObjectID);
|
auto* player = EntityManager::Instance()->GetEntity(m_ObjectID);
|
||||||
|
|
||||||
if (player != nullptr)
|
if (player != nullptr) {
|
||||||
{
|
|
||||||
auto* missionComponent = player->GetComponent<MissionComponent>();
|
auto* missionComponent = player->GetComponent<MissionComponent>();
|
||||||
|
|
||||||
if (missionComponent != nullptr)
|
if (missionComponent != nullptr) {
|
||||||
{
|
|
||||||
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_PLAYER_FLAG, flagId);
|
missionComponent->Progress(MissionTaskType::MISSION_TASK_TYPE_PLAYER_FLAG, flagId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -413,8 +406,7 @@ void Character::SetPlayerFlag(const uint32_t flagId, const bool value) {
|
|||||||
auto it = m_PlayerFlags.find(flagIndex);
|
auto it = m_PlayerFlags.find(flagIndex);
|
||||||
|
|
||||||
// Check if flag index exists
|
// Check if flag index exists
|
||||||
if (it != m_PlayerFlags.end())
|
if (it != m_PlayerFlags.end()) {
|
||||||
{
|
|
||||||
// Update the value
|
// Update the value
|
||||||
if (value) {
|
if (value) {
|
||||||
it->second |= shiftedValue;
|
it->second |= shiftedValue;
|
||||||
@ -458,8 +450,7 @@ void Character::SetRetroactiveFlags() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Character::SaveXmlRespawnCheckpoints()
|
void Character::SaveXmlRespawnCheckpoints() {
|
||||||
{
|
|
||||||
//Export our respawn points:
|
//Export our respawn points:
|
||||||
auto* points = m_Doc->FirstChildElement("obj")->FirstChildElement("res");
|
auto* points = m_Doc->FirstChildElement("obj")->FirstChildElement("res");
|
||||||
if (!points) {
|
if (!points) {
|
||||||
@ -480,8 +471,7 @@ void Character::SaveXmlRespawnCheckpoints()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Character::LoadXmlRespawnCheckpoints()
|
void Character::LoadXmlRespawnCheckpoints() {
|
||||||
{
|
|
||||||
m_WorldRespawnCheckpoints.clear();
|
m_WorldRespawnCheckpoints.clear();
|
||||||
|
|
||||||
auto* points = m_Doc->FirstChildElement("obj")->FirstChildElement("res");
|
auto* points = m_Doc->FirstChildElement("obj")->FirstChildElement("res");
|
||||||
@ -490,8 +480,7 @@ void Character::LoadXmlRespawnCheckpoints()
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto* r = points->FirstChildElement("r");
|
auto* r = points->FirstChildElement("r");
|
||||||
while (r != nullptr)
|
while (r != nullptr) {
|
||||||
{
|
|
||||||
int32_t map = 0;
|
int32_t map = 0;
|
||||||
NiPoint3 point = NiPoint3::ZERO;
|
NiPoint3 point = NiPoint3::ZERO;
|
||||||
|
|
||||||
@ -507,8 +496,7 @@ void Character::LoadXmlRespawnCheckpoints()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Character::OnZoneLoad()
|
void Character::OnZoneLoad() {
|
||||||
{
|
|
||||||
if (m_OurEntity == nullptr) {
|
if (m_OurEntity == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -550,23 +538,19 @@ void Character::OnZoneLoad()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PermissionMap Character::GetPermissionMap() const
|
PermissionMap Character::GetPermissionMap() const {
|
||||||
{
|
|
||||||
return m_PermissionMap;
|
return m_PermissionMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Character::HasPermission(PermissionMap permission) const
|
bool Character::HasPermission(PermissionMap permission) const {
|
||||||
{
|
|
||||||
return (static_cast<uint64_t>(m_PermissionMap) & static_cast<uint64_t>(permission)) != 0;
|
return (static_cast<uint64_t>(m_PermissionMap) & static_cast<uint64_t>(permission)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Character::SetRespawnPoint(LWOMAPID map, const NiPoint3& point)
|
void Character::SetRespawnPoint(LWOMAPID map, const NiPoint3& point) {
|
||||||
{
|
|
||||||
m_WorldRespawnCheckpoints[map] = point;
|
m_WorldRespawnCheckpoints[map] = point;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NiPoint3& Character::GetRespawnPoint(LWOMAPID map) const
|
const NiPoint3& Character::GetRespawnPoint(LWOMAPID map) const {
|
||||||
{
|
|
||||||
const auto& pair = m_WorldRespawnCheckpoints.find(map);
|
const auto& pair = m_WorldRespawnCheckpoints.find(map);
|
||||||
|
|
||||||
if (pair == m_WorldRespawnCheckpoints.end()) return NiPoint3::ZERO;
|
if (pair == m_WorldRespawnCheckpoints.end()) return NiPoint3::ZERO;
|
||||||
@ -575,8 +559,7 @@ const NiPoint3& Character::GetRespawnPoint(LWOMAPID map) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Character::SetCoins(int64_t newCoins, eLootSourceType lootSource) {
|
void Character::SetCoins(int64_t newCoins, eLootSourceType lootSource) {
|
||||||
if (newCoins < 0)
|
if (newCoins < 0) {
|
||||||
{
|
|
||||||
newCoins = 0;
|
newCoins = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -585,21 +568,18 @@ void Character::SetCoins(int64_t newCoins, eLootSourceType lootSource) {
|
|||||||
GameMessages::SendSetCurrency(EntityManager::Instance()->GetEntity(m_ObjectID), m_Coins, 0, 0, 0, 0, true, lootSource);
|
GameMessages::SendSetCurrency(EntityManager::Instance()->GetEntity(m_ObjectID), m_Coins, 0, 0, 0, 0, true, lootSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Character::HasBeenToWorld(LWOMAPID mapID) const
|
bool Character::HasBeenToWorld(LWOMAPID mapID) const {
|
||||||
{
|
|
||||||
return m_WorldRespawnCheckpoints.find(mapID) != m_WorldRespawnCheckpoints.end();
|
return m_WorldRespawnCheckpoints.find(mapID) != m_WorldRespawnCheckpoints.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Character::SendMuteNotice() const
|
void Character::SendMuteNotice() const {
|
||||||
{
|
|
||||||
if (!m_ParentUser->GetIsMuted()) return;
|
if (!m_ParentUser->GetIsMuted()) return;
|
||||||
|
|
||||||
time_t expire = m_ParentUser->GetMuteExpire();
|
time_t expire = m_ParentUser->GetMuteExpire();
|
||||||
|
|
||||||
char buffer[32] = "brought up for review.\0";
|
char buffer[32] = "brought up for review.\0";
|
||||||
|
|
||||||
if (expire != 1)
|
if (expire != 1) {
|
||||||
{
|
|
||||||
std::tm* ptm = std::localtime(&expire);
|
std::tm* ptm = std::localtime(&expire);
|
||||||
// Format: Mo, 15.06.2009 20:20:00
|
// Format: Mo, 15.06.2009 20:20:00
|
||||||
std::strftime(buffer, 32, "%a, %d.%m.%Y %H:%M:%S", ptm);
|
std::strftime(buffer, 32, "%a, %d.%m.%Y %H:%M:%S", ptm);
|
||||||
|
462
dGame/Entity.cpp
462
dGame/Entity.cpp
File diff suppressed because it is too large
Load Diff
@ -338,12 +338,10 @@ protected:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool Entity::TryGetComponent(const int32_t componentId, T*& component) const
|
bool Entity::TryGetComponent(const int32_t componentId, T*& component) const {
|
||||||
{
|
|
||||||
const auto& index = m_Components.find(componentId);
|
const auto& index = m_Components.find(componentId);
|
||||||
|
|
||||||
if (index == m_Components.end())
|
if (index == m_Components.end()) {
|
||||||
{
|
|
||||||
component = nullptr;
|
component = nullptr;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -355,26 +353,22 @@ bool Entity::TryGetComponent(const int32_t componentId, T*& component) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T* Entity::GetComponent() const
|
T* Entity::GetComponent() const {
|
||||||
{
|
|
||||||
return dynamic_cast<T*>(GetComponent(T::ComponentType));
|
return dynamic_cast<T*>(GetComponent(T::ComponentType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
const T& Entity::GetVar(const std::u16string& name) const
|
const T& Entity::GetVar(const std::u16string& name) const {
|
||||||
{
|
|
||||||
auto* data = GetVarData(name);
|
auto* data = GetVarData(name);
|
||||||
|
|
||||||
if (data == nullptr)
|
if (data == nullptr) {
|
||||||
{
|
|
||||||
return LDFData<T>::Default;
|
return LDFData<T>::Default;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* typed = dynamic_cast<LDFData<T>*>(data);
|
auto* typed = dynamic_cast<LDFData<T>*>(data);
|
||||||
|
|
||||||
if (typed == nullptr)
|
if (typed == nullptr) {
|
||||||
{
|
|
||||||
return LDFData<T>::Default;
|
return LDFData<T>::Default;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,14 +376,12 @@ const T& Entity::GetVar(const std::u16string& name) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T Entity::GetVarAs(const std::u16string& name) const
|
T Entity::GetVarAs(const std::u16string& name) const {
|
||||||
{
|
|
||||||
const auto data = GetVarAsString(name);
|
const auto data = GetVarAsString(name);
|
||||||
|
|
||||||
T value;
|
T value;
|
||||||
|
|
||||||
if (!GeneralUtils::TryParse(data, value))
|
if (!GeneralUtils::TryParse(data, value)) {
|
||||||
{
|
|
||||||
return LDFData<T>::Default;
|
return LDFData<T>::Default;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,12 +389,10 @@ T Entity::GetVarAs(const std::u16string& name) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void Entity::SetVar(const std::u16string& name, T value)
|
void Entity::SetVar(const std::u16string& name, T value) {
|
||||||
{
|
|
||||||
auto* data = GetVarData(name);
|
auto* data = GetVarData(name);
|
||||||
|
|
||||||
if (data == nullptr)
|
if (data == nullptr) {
|
||||||
{
|
|
||||||
auto* data = new LDFData<T>(name, value);
|
auto* data = new LDFData<T>(name, value);
|
||||||
|
|
||||||
m_Settings.push_back(data);
|
m_Settings.push_back(data);
|
||||||
@ -412,8 +402,7 @@ void Entity::SetVar(const std::u16string& name, T value)
|
|||||||
|
|
||||||
auto* typed = dynamic_cast<LDFData<T>*>(data);
|
auto* typed = dynamic_cast<LDFData<T>*>(data);
|
||||||
|
|
||||||
if (typed == nullptr)
|
if (typed == nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,8 +110,7 @@ Entity* EntityManager::CreateEntity(EntityInfo info, User* user, Entity* parentE
|
|||||||
// Check if the entitty if a player, in case use the extended player entity class
|
// Check if the entitty if a player, in case use the extended player entity class
|
||||||
if (user != nullptr) {
|
if (user != nullptr) {
|
||||||
entity = new Player(id, info, user, parentEntity);
|
entity = new Player(id, info, user, parentEntity);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
entity = new Entity(id, info, parentEntity);
|
entity = new Entity(id, info, parentEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,8 +231,7 @@ void EntityManager::UpdateEntities(const float deltaTime) {
|
|||||||
Entity* EntityManager::GetEntity(const LWOOBJID& objectId) const {
|
Entity* EntityManager::GetEntity(const LWOOBJID& objectId) const {
|
||||||
const auto& index = m_Entities.find(objectId);
|
const auto& index = m_Entities.find(objectId);
|
||||||
|
|
||||||
if (index == m_Entities.end())
|
if (index == m_Entities.end()) {
|
||||||
{
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,18 +272,15 @@ std::vector<Entity *> EntityManager::GetEntitiesByLOT(const LOT &lot) const {
|
|||||||
return entities;
|
return entities;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity* EntityManager::GetZoneControlEntity() const
|
Entity* EntityManager::GetZoneControlEntity() const {
|
||||||
{
|
|
||||||
return m_ZoneControlEntity;
|
return m_ZoneControlEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity* EntityManager::GetSpawnPointEntity(const std::string& spawnName) const
|
Entity* EntityManager::GetSpawnPointEntity(const std::string& spawnName) const {
|
||||||
{
|
|
||||||
// Lookup the spawn point entity in the map
|
// Lookup the spawn point entity in the map
|
||||||
const auto& spawnPoint = m_SpawnPoints.find(spawnName);
|
const auto& spawnPoint = m_SpawnPoints.find(spawnName);
|
||||||
|
|
||||||
if (spawnPoint == m_SpawnPoints.end())
|
if (spawnPoint == m_SpawnPoints.end()) {
|
||||||
{
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,23 +288,18 @@ Entity* EntityManager::GetSpawnPointEntity(const std::string& spawnName) const
|
|||||||
return GetEntity(spawnPoint->second);
|
return GetEntity(spawnPoint->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::unordered_map<std::string, LWOOBJID>& EntityManager::GetSpawnPointEntities() const
|
const std::unordered_map<std::string, LWOOBJID>& EntityManager::GetSpawnPointEntities() const {
|
||||||
{
|
|
||||||
return m_SpawnPoints;
|
return m_SpawnPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityManager::ConstructEntity(Entity* entity, const SystemAddress& sysAddr, const bool skipChecks) {
|
void EntityManager::ConstructEntity(Entity* entity, const SystemAddress& sysAddr, const bool skipChecks) {
|
||||||
if (entity->GetNetworkId() == 0)
|
if (entity->GetNetworkId() == 0) {
|
||||||
{
|
|
||||||
uint16_t networkId;
|
uint16_t networkId;
|
||||||
|
|
||||||
if (!m_LostNetworkIds.empty())
|
if (!m_LostNetworkIds.empty()) {
|
||||||
{
|
|
||||||
networkId = m_LostNetworkIds.top();
|
networkId = m_LostNetworkIds.top();
|
||||||
m_LostNetworkIds.pop();
|
m_LostNetworkIds.pop();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
networkId = ++m_NetworkIdCounter;
|
networkId = ++m_NetworkIdCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,18 +308,15 @@ void EntityManager::ConstructEntity(Entity* entity, const SystemAddress& sysAddr
|
|||||||
|
|
||||||
const auto checkGhosting = entity->GetIsGhostingCandidate();
|
const auto checkGhosting = entity->GetIsGhostingCandidate();
|
||||||
|
|
||||||
if (checkGhosting)
|
if (checkGhosting) {
|
||||||
{
|
|
||||||
const auto& iter = std::find(m_EntitiesToGhost.begin(), m_EntitiesToGhost.end(), entity);
|
const auto& iter = std::find(m_EntitiesToGhost.begin(), m_EntitiesToGhost.end(), entity);
|
||||||
|
|
||||||
if (iter == m_EntitiesToGhost.end())
|
if (iter == m_EntitiesToGhost.end()) {
|
||||||
{
|
|
||||||
m_EntitiesToGhost.push_back(entity);
|
m_EntitiesToGhost.push_back(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkGhosting && sysAddr == UNASSIGNED_SYSTEM_ADDRESS)
|
if (checkGhosting && sysAddr == UNASSIGNED_SYSTEM_ADDRESS) {
|
||||||
{
|
|
||||||
CheckGhosting(entity);
|
CheckGhosting(entity);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -346,38 +333,26 @@ void EntityManager::ConstructEntity(Entity* entity, const SystemAddress& sysAddr
|
|||||||
entity->WriteBaseReplicaData(&stream, PACKET_TYPE_CONSTRUCTION);
|
entity->WriteBaseReplicaData(&stream, PACKET_TYPE_CONSTRUCTION);
|
||||||
entity->WriteComponents(&stream, PACKET_TYPE_CONSTRUCTION);
|
entity->WriteComponents(&stream, PACKET_TYPE_CONSTRUCTION);
|
||||||
|
|
||||||
if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS)
|
if (sysAddr == UNASSIGNED_SYSTEM_ADDRESS) {
|
||||||
{
|
if (skipChecks) {
|
||||||
if (skipChecks)
|
|
||||||
{
|
|
||||||
Game::server->Send(&stream, UNASSIGNED_SYSTEM_ADDRESS, true);
|
Game::server->Send(&stream, UNASSIGNED_SYSTEM_ADDRESS, true);
|
||||||
}
|
} else {
|
||||||
else
|
for (auto* player : Player::GetAllPlayers()) {
|
||||||
{
|
if (player->GetPlayerReadyForUpdates()) {
|
||||||
for (auto* player : Player::GetAllPlayers())
|
|
||||||
{
|
|
||||||
if (player->GetPlayerReadyForUpdates())
|
|
||||||
{
|
|
||||||
Game::server->Send(&stream, player->GetSystemAddress(), false);
|
Game::server->Send(&stream, player->GetSystemAddress(), false);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
player->AddLimboConstruction(entity->GetObjectID());
|
player->AddLimboConstruction(entity->GetObjectID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
Game::server->Send(&stream, sysAddr, false);
|
Game::server->Send(&stream, sysAddr, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PacketUtils::SavePacket("[24]_"+std::to_string(entity->GetObjectID()) + "_" + std::to_string(m_SerializationCounter) + ".bin", (char*)stream.GetData(), stream.GetNumberOfBytesUsed());
|
// PacketUtils::SavePacket("[24]_"+std::to_string(entity->GetObjectID()) + "_" + std::to_string(m_SerializationCounter) + ".bin", (char*)stream.GetData(), stream.GetNumberOfBytesUsed());
|
||||||
|
|
||||||
if (entity->IsPlayer())
|
if (entity->IsPlayer()) {
|
||||||
{
|
if (entity->GetGMLevel() > GAME_MASTER_LEVEL_CIVILIAN) {
|
||||||
if (entity->GetGMLevel() > GAME_MASTER_LEVEL_CIVILIAN)
|
|
||||||
{
|
|
||||||
GameMessages::SendToggleGMInvis(entity->GetObjectID(), true, sysAddr);
|
GameMessages::SendToggleGMInvis(entity->GetObjectID(), true, sysAddr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -397,8 +372,7 @@ void EntityManager::ConstructAllEntities(const SystemAddress& sysAddr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EntityManager::DestructEntity(Entity* entity, const SystemAddress& sysAddr) {
|
void EntityManager::DestructEntity(Entity* entity, const SystemAddress& sysAddr) {
|
||||||
if (entity->GetNetworkId() == 0)
|
if (entity->GetNetworkId() == 0) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,23 +383,19 @@ void EntityManager::DestructEntity(Entity* entity, const SystemAddress& sysAddr)
|
|||||||
|
|
||||||
Game::server->Send(&stream, sysAddr, sysAddr == UNASSIGNED_SYSTEM_ADDRESS);
|
Game::server->Send(&stream, sysAddr, sysAddr == UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
for (auto* player : Player::GetAllPlayers())
|
for (auto* player : Player::GetAllPlayers()) {
|
||||||
{
|
if (!player->GetPlayerReadyForUpdates()) {
|
||||||
if (!player->GetPlayerReadyForUpdates())
|
|
||||||
{
|
|
||||||
player->RemoveLimboConstruction(entity->GetObjectID());
|
player->RemoveLimboConstruction(entity->GetObjectID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityManager::SerializeEntity(Entity* entity) {
|
void EntityManager::SerializeEntity(Entity* entity) {
|
||||||
if (entity->GetNetworkId() == 0)
|
if (entity->GetNetworkId() == 0) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::find(m_EntitiesToSerialize.begin(), m_EntitiesToSerialize.end(), entity->GetObjectID()) == m_EntitiesToSerialize.end())
|
if (std::find(m_EntitiesToSerialize.begin(), m_EntitiesToSerialize.end(), entity->GetObjectID()) == m_EntitiesToSerialize.end()) {
|
||||||
{
|
|
||||||
m_EntitiesToSerialize.push_back(entity->GetObjectID());
|
m_EntitiesToSerialize.push_back(entity->GetObjectID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,44 +408,35 @@ void EntityManager::DestructAllEntities(const SystemAddress& sysAddr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityManager::SetGhostDistanceMax(float value)
|
void EntityManager::SetGhostDistanceMax(float value) {
|
||||||
{
|
|
||||||
m_GhostDistanceMaxSquared = value * value;
|
m_GhostDistanceMaxSquared = value * value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float EntityManager::GetGhostDistanceMax() const
|
float EntityManager::GetGhostDistanceMax() const {
|
||||||
{
|
|
||||||
return std::sqrt(m_GhostDistanceMaxSquared);
|
return std::sqrt(m_GhostDistanceMaxSquared);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityManager::SetGhostDistanceMin(float value)
|
void EntityManager::SetGhostDistanceMin(float value) {
|
||||||
{
|
|
||||||
m_GhostDistanceMinSqaured = value * value;
|
m_GhostDistanceMinSqaured = value * value;
|
||||||
}
|
}
|
||||||
|
|
||||||
float EntityManager::GetGhostDistanceMin() const
|
float EntityManager::GetGhostDistanceMin() const {
|
||||||
{
|
|
||||||
return std::sqrt(m_GhostDistanceMinSqaured);
|
return std::sqrt(m_GhostDistanceMinSqaured);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityManager::QueueGhostUpdate(LWOOBJID playerID)
|
void EntityManager::QueueGhostUpdate(LWOOBJID playerID) {
|
||||||
{
|
|
||||||
const auto& iter = std::find(m_PlayersToUpdateGhosting.begin(), m_PlayersToUpdateGhosting.end(), playerID);
|
const auto& iter = std::find(m_PlayersToUpdateGhosting.begin(), m_PlayersToUpdateGhosting.end(), playerID);
|
||||||
|
|
||||||
if (iter == m_PlayersToUpdateGhosting.end())
|
if (iter == m_PlayersToUpdateGhosting.end()) {
|
||||||
{
|
|
||||||
m_PlayersToUpdateGhosting.push_back(playerID);
|
m_PlayersToUpdateGhosting.push_back(playerID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityManager::UpdateGhosting()
|
void EntityManager::UpdateGhosting() {
|
||||||
{
|
for (const auto playerID : m_PlayersToUpdateGhosting) {
|
||||||
for (const auto playerID : m_PlayersToUpdateGhosting)
|
|
||||||
{
|
|
||||||
auto* player = Player::GetPlayer(playerID);
|
auto* player = Player::GetPlayer(playerID);
|
||||||
|
|
||||||
if (player == nullptr)
|
if (player == nullptr) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,25 +446,21 @@ void EntityManager::UpdateGhosting()
|
|||||||
m_PlayersToUpdateGhosting.clear();
|
m_PlayersToUpdateGhosting.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityManager::UpdateGhosting(Player* player)
|
void EntityManager::UpdateGhosting(Player* player) {
|
||||||
{
|
if (player == nullptr) {
|
||||||
if (player == nullptr)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* missionComponent = player->GetComponent<MissionComponent>();
|
auto* missionComponent = player->GetComponent<MissionComponent>();
|
||||||
|
|
||||||
if (missionComponent == nullptr)
|
if (missionComponent == nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& referencePoint = player->GetGhostReferencePoint();
|
const auto& referencePoint = player->GetGhostReferencePoint();
|
||||||
const auto isOverride = player->GetGhostOverride();
|
const auto isOverride = player->GetGhostOverride();
|
||||||
|
|
||||||
for (auto* entity : m_EntitiesToGhost)
|
for (auto* entity : m_EntitiesToGhost) {
|
||||||
{
|
|
||||||
const auto isAudioEmitter = entity->GetLOT() == 6368;
|
const auto isAudioEmitter = entity->GetLOT() == 6368;
|
||||||
|
|
||||||
const auto& entityPoint = entity->GetPosition();
|
const auto& entityPoint = entity->GetPosition();
|
||||||
@ -517,30 +474,24 @@ void EntityManager::UpdateGhosting(Player* player)
|
|||||||
auto ghostingDistanceMax = m_GhostDistanceMaxSquared;
|
auto ghostingDistanceMax = m_GhostDistanceMaxSquared;
|
||||||
auto ghostingDistanceMin = m_GhostDistanceMinSqaured;
|
auto ghostingDistanceMin = m_GhostDistanceMinSqaured;
|
||||||
|
|
||||||
if (isAudioEmitter)
|
if (isAudioEmitter) {
|
||||||
{
|
|
||||||
ghostingDistanceMax = ghostingDistanceMin;
|
ghostingDistanceMax = ghostingDistanceMin;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (observed && distance > ghostingDistanceMax && !isOverride)
|
if (observed && distance > ghostingDistanceMax && !isOverride) {
|
||||||
{
|
|
||||||
player->GhostEntity(id);
|
player->GhostEntity(id);
|
||||||
|
|
||||||
DestructEntity(entity, player->GetSystemAddress());
|
DestructEntity(entity, player->GetSystemAddress());
|
||||||
|
|
||||||
entity->SetObservers(entity->GetObservers() - 1);
|
entity->SetObservers(entity->GetObservers() - 1);
|
||||||
}
|
} else if (!observed && ghostingDistanceMin > distance) {
|
||||||
else if (!observed && ghostingDistanceMin > distance)
|
|
||||||
{
|
|
||||||
// Check collectables, don't construct if it has been collected
|
// Check collectables, don't construct if it has been collected
|
||||||
uint32_t collectionId = entity->GetCollectibleID();
|
uint32_t collectionId = entity->GetCollectibleID();
|
||||||
|
|
||||||
if (collectionId != 0)
|
if (collectionId != 0) {
|
||||||
{
|
|
||||||
collectionId = static_cast<uint32_t>(collectionId) + static_cast<uint32_t>(Game::server->GetZoneID() << 8);
|
collectionId = static_cast<uint32_t>(collectionId) + static_cast<uint32_t>(Game::server->GetZoneID() << 8);
|
||||||
|
|
||||||
if (missionComponent->HasCollectible(collectionId))
|
if (missionComponent->HasCollectible(collectionId)) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -554,10 +505,8 @@ void EntityManager::UpdateGhosting(Player* player)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityManager::CheckGhosting(Entity* entity)
|
void EntityManager::CheckGhosting(Entity* entity) {
|
||||||
{
|
if (entity == nullptr) {
|
||||||
if (entity == nullptr)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -568,8 +517,7 @@ void EntityManager::CheckGhosting(Entity* entity)
|
|||||||
|
|
||||||
const auto isAudioEmitter = entity->GetLOT() == 6368;
|
const auto isAudioEmitter = entity->GetLOT() == 6368;
|
||||||
|
|
||||||
for (auto* player : Player::GetAllPlayers())
|
for (auto* player : Player::GetAllPlayers()) {
|
||||||
{
|
|
||||||
const auto& entityPoint = player->GetGhostReferencePoint();
|
const auto& entityPoint = player->GetGhostReferencePoint();
|
||||||
|
|
||||||
const int32_t id = entity->GetObjectID();
|
const int32_t id = entity->GetObjectID();
|
||||||
@ -578,16 +526,13 @@ void EntityManager::CheckGhosting(Entity* entity)
|
|||||||
|
|
||||||
const auto distance = NiPoint3::DistanceSquared(referencePoint, entityPoint);
|
const auto distance = NiPoint3::DistanceSquared(referencePoint, entityPoint);
|
||||||
|
|
||||||
if (observed && distance > ghostingDistanceMax)
|
if (observed && distance > ghostingDistanceMax) {
|
||||||
{
|
|
||||||
player->GhostEntity(id);
|
player->GhostEntity(id);
|
||||||
|
|
||||||
DestructEntity(entity, player->GetSystemAddress());
|
DestructEntity(entity, player->GetSystemAddress());
|
||||||
|
|
||||||
entity->SetObservers(entity->GetObservers() - 1);
|
entity->SetObservers(entity->GetObservers() - 1);
|
||||||
}
|
} else if (!observed && ghostingDistanceMin > distance) {
|
||||||
else if (!observed && ghostingDistanceMin > distance)
|
|
||||||
{
|
|
||||||
player->ObserveEntity(id);
|
player->ObserveEntity(id);
|
||||||
|
|
||||||
ConstructEntity(entity, player->GetSystemAddress());
|
ConstructEntity(entity, player->GetSystemAddress());
|
||||||
@ -597,12 +542,9 @@ void EntityManager::CheckGhosting(Entity* entity)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity* EntityManager::GetGhostCandidate(int32_t id)
|
Entity* EntityManager::GetGhostCandidate(int32_t id) {
|
||||||
{
|
for (auto* entity : m_EntitiesToGhost) {
|
||||||
for (auto* entity : m_EntitiesToGhost)
|
if (entity->GetObjectID() == id) {
|
||||||
{
|
|
||||||
if (entity->GetObjectID() == id)
|
|
||||||
{
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -610,8 +552,7 @@ Entity* EntityManager::GetGhostCandidate(int32_t id)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityManager::GetGhostingEnabled() const
|
bool EntityManager::GetGhostingEnabled() const {
|
||||||
{
|
|
||||||
return m_GhostingEnabled;
|
return m_GhostingEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -633,18 +574,15 @@ void EntityManager::ScheduleForKill(Entity* entity) {
|
|||||||
|
|
||||||
const auto objectId = entity->GetObjectID();
|
const auto objectId = entity->GetObjectID();
|
||||||
|
|
||||||
if (std::count(m_EntitiesToKill.begin(), m_EntitiesToKill.end(), objectId))
|
if (std::count(m_EntitiesToKill.begin(), m_EntitiesToKill.end(), objectId)) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_EntitiesToKill.push_back(objectId);
|
m_EntitiesToKill.push_back(objectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityManager::ScheduleForDeletion(LWOOBJID entity)
|
void EntityManager::ScheduleForDeletion(LWOOBJID entity) {
|
||||||
{
|
if (std::count(m_EntitiesToDelete.begin(), m_EntitiesToDelete.end(), entity)) {
|
||||||
if (std::count(m_EntitiesToDelete.begin(), m_EntitiesToDelete.end(), entity))
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,7 +598,6 @@ void EntityManager::FireEventServerSide(Entity* origin, std::string args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EntityManager::IsExcludedFromGhosting(LOT lot)
|
bool EntityManager::IsExcludedFromGhosting(LOT lot) {
|
||||||
{
|
|
||||||
return std::find(m_GhostingExcludedLOTs.begin(), m_GhostingExcludedLOTs.end(), lot) != m_GhostingExcludedLOTs.end();
|
return std::find(m_GhostingExcludedLOTs.begin(), m_GhostingExcludedLOTs.end(), lot) != m_GhostingExcludedLOTs.end();
|
||||||
}
|
}
|
||||||
|
@ -116,8 +116,7 @@ void LeaderboardManager::SaveScore(LWOOBJID playerID, uint32_t gameID, uint32_t
|
|||||||
if (time <= storedTime) { // Based on time (LU live)
|
if (time <= storedTime) { // Based on time (LU live)
|
||||||
highscore = false;
|
highscore = false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (score <= storedScore) // Based on score (DLU)
|
if (score <= storedScore) // Based on score (DLU)
|
||||||
highscore = false;
|
highscore = false;
|
||||||
}
|
}
|
||||||
|
147
dGame/Player.cpp
147
dGame/Player.cpp
@ -17,8 +17,7 @@
|
|||||||
|
|
||||||
std::vector<Player*> Player::m_Players = {};
|
std::vector<Player*> Player::m_Players = {};
|
||||||
|
|
||||||
Player::Player(const LWOOBJID& objectID, const EntityInfo info, User* user, Entity* parentEntity) : Entity(objectID, info, parentEntity)
|
Player::Player(const LWOOBJID& objectID, const EntityInfo info, User* user, Entity* parentEntity) : Entity(objectID, info, parentEntity) {
|
||||||
{
|
|
||||||
m_ParentUser = user;
|
m_ParentUser = user;
|
||||||
m_Character = m_ParentUser->GetLastUsedChar();
|
m_Character = m_ParentUser->GetLastUsedChar();
|
||||||
m_ParentUser->SetLoggedInChar(objectID);
|
m_ParentUser->SetLoggedInChar(objectID);
|
||||||
@ -38,58 +37,48 @@ Player::Player(const LWOOBJID& objectID, const EntityInfo info, User* user, Enti
|
|||||||
|
|
||||||
const auto& iter = std::find(m_Players.begin(), m_Players.end(), this);
|
const auto& iter = std::find(m_Players.begin(), m_Players.end(), this);
|
||||||
|
|
||||||
if (iter != m_Players.end())
|
if (iter != m_Players.end()) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Players.push_back(this);
|
m_Players.push_back(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
User* Player::GetParentUser() const
|
User* Player::GetParentUser() const {
|
||||||
{
|
|
||||||
return m_ParentUser;
|
return m_ParentUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemAddress Player::GetSystemAddress() const
|
SystemAddress Player::GetSystemAddress() const {
|
||||||
{
|
|
||||||
return m_SystemAddress;
|
return m_SystemAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SetSystemAddress(const SystemAddress& value)
|
void Player::SetSystemAddress(const SystemAddress& value) {
|
||||||
{
|
|
||||||
m_SystemAddress = value;
|
m_SystemAddress = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SetRespawnPos(const NiPoint3 position)
|
void Player::SetRespawnPos(const NiPoint3 position) {
|
||||||
{
|
|
||||||
m_respawnPos = position;
|
m_respawnPos = position;
|
||||||
|
|
||||||
m_Character->SetRespawnPoint(dZoneManager::Instance()->GetZone()->GetWorldID(), position);
|
m_Character->SetRespawnPoint(dZoneManager::Instance()->GetZone()->GetWorldID(), position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SetRespawnRot(const NiQuaternion rotation)
|
void Player::SetRespawnRot(const NiQuaternion rotation) {
|
||||||
{
|
|
||||||
m_respawnRot = rotation;
|
m_respawnRot = rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
NiPoint3 Player::GetRespawnPosition() const
|
NiPoint3 Player::GetRespawnPosition() const {
|
||||||
{
|
|
||||||
return m_respawnPos;
|
return m_respawnPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
NiQuaternion Player::GetRespawnRotation() const
|
NiQuaternion Player::GetRespawnRotation() const {
|
||||||
{
|
|
||||||
return m_respawnRot;
|
return m_respawnRot;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SendMail(const LWOOBJID sender, const std::string& senderName, const std::string& subject, const std::string& body, LOT attachment, uint16_t attachmentCount) const
|
void Player::SendMail(const LWOOBJID sender, const std::string& senderName, const std::string& subject, const std::string& body, LOT attachment, uint16_t attachmentCount) const {
|
||||||
{
|
|
||||||
Mail::SendMail(sender, senderName, this, subject, body, attachment, attachmentCount);
|
Mail::SendMail(sender, senderName, this, subject, body, attachment, attachmentCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId)
|
void Player::SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId) {
|
||||||
{
|
|
||||||
const auto objid = GetObjectID();
|
const auto objid = GetObjectID();
|
||||||
|
|
||||||
ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, zoneId, cloneId, false, [objid](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) {
|
ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, zoneId, cloneId, false, [objid](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) {
|
||||||
@ -121,38 +110,31 @@ void Player::SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::AddLimboConstruction(LWOOBJID objectId)
|
void Player::AddLimboConstruction(LWOOBJID objectId) {
|
||||||
{
|
|
||||||
const auto& iter = std::find(m_LimboConstructions.begin(), m_LimboConstructions.end(), objectId);
|
const auto& iter = std::find(m_LimboConstructions.begin(), m_LimboConstructions.end(), objectId);
|
||||||
|
|
||||||
if (iter != m_LimboConstructions.end())
|
if (iter != m_LimboConstructions.end()) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_LimboConstructions.push_back(objectId);
|
m_LimboConstructions.push_back(objectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::RemoveLimboConstruction(LWOOBJID objectId)
|
void Player::RemoveLimboConstruction(LWOOBJID objectId) {
|
||||||
{
|
|
||||||
const auto& iter = std::find(m_LimboConstructions.begin(), m_LimboConstructions.end(), objectId);
|
const auto& iter = std::find(m_LimboConstructions.begin(), m_LimboConstructions.end(), objectId);
|
||||||
|
|
||||||
if (iter == m_LimboConstructions.end())
|
if (iter == m_LimboConstructions.end()) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_LimboConstructions.erase(iter);
|
m_LimboConstructions.erase(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::ConstructLimboEntities()
|
void Player::ConstructLimboEntities() {
|
||||||
{
|
for (const auto objectId : m_LimboConstructions) {
|
||||||
for (const auto objectId : m_LimboConstructions)
|
|
||||||
{
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(objectId);
|
auto* entity = EntityManager::Instance()->GetEntity(objectId);
|
||||||
|
|
||||||
if (entity == nullptr)
|
if (entity == nullptr) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,52 +144,41 @@ void Player::ConstructLimboEntities()
|
|||||||
m_LimboConstructions.clear();
|
m_LimboConstructions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<LWOOBJID, Loot::Info>& Player::GetDroppedLoot()
|
std::map<LWOOBJID, Loot::Info>& Player::GetDroppedLoot() {
|
||||||
{
|
|
||||||
return m_DroppedLoot;
|
return m_DroppedLoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NiPoint3& Player::GetGhostReferencePoint() const
|
const NiPoint3& Player::GetGhostReferencePoint() const {
|
||||||
{
|
|
||||||
return m_GhostOverride ? m_GhostOverridePoint : m_GhostReferencePoint;
|
return m_GhostOverride ? m_GhostOverridePoint : m_GhostReferencePoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NiPoint3& Player::GetOriginGhostReferencePoint() const
|
const NiPoint3& Player::GetOriginGhostReferencePoint() const {
|
||||||
{
|
|
||||||
return m_GhostReferencePoint;
|
return m_GhostReferencePoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SetGhostReferencePoint(const NiPoint3& value)
|
void Player::SetGhostReferencePoint(const NiPoint3& value) {
|
||||||
{
|
|
||||||
m_GhostReferencePoint = value;
|
m_GhostReferencePoint = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SetGhostOverridePoint(const NiPoint3& value)
|
void Player::SetGhostOverridePoint(const NiPoint3& value) {
|
||||||
{
|
|
||||||
m_GhostOverridePoint = value;
|
m_GhostOverridePoint = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NiPoint3& Player::GetGhostOverridePoint() const
|
const NiPoint3& Player::GetGhostOverridePoint() const {
|
||||||
{
|
|
||||||
return m_GhostOverridePoint;
|
return m_GhostOverridePoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::SetGhostOverride(bool value)
|
void Player::SetGhostOverride(bool value) {
|
||||||
{
|
|
||||||
m_GhostOverride = value;
|
m_GhostOverride = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::GetGhostOverride() const
|
bool Player::GetGhostOverride() const {
|
||||||
{
|
|
||||||
return m_GhostOverride;
|
return m_GhostOverride;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::ObserveEntity(int32_t id)
|
void Player::ObserveEntity(int32_t id) {
|
||||||
{
|
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++) {
|
||||||
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++)
|
if (m_ObservedEntities[i] == 0 || m_ObservedEntities[i] == id) {
|
||||||
{
|
|
||||||
if (m_ObservedEntities[i] == 0 || m_ObservedEntities[i] == id)
|
|
||||||
{
|
|
||||||
m_ObservedEntities[i] = id;
|
m_ObservedEntities[i] = id;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -216,8 +187,7 @@ void Player::ObserveEntity(int32_t id)
|
|||||||
|
|
||||||
const auto index = m_ObservedEntitiesUsed++;
|
const auto index = m_ObservedEntitiesUsed++;
|
||||||
|
|
||||||
if (m_ObservedEntitiesUsed > m_ObservedEntitiesLength)
|
if (m_ObservedEntitiesUsed > m_ObservedEntitiesLength) {
|
||||||
{
|
|
||||||
m_ObservedEntities.resize(m_ObservedEntitiesLength + m_ObservedEntitiesLength);
|
m_ObservedEntities.resize(m_ObservedEntitiesLength + m_ObservedEntitiesLength);
|
||||||
|
|
||||||
m_ObservedEntitiesLength = m_ObservedEntitiesLength + m_ObservedEntitiesLength;
|
m_ObservedEntitiesLength = m_ObservedEntitiesLength + m_ObservedEntitiesLength;
|
||||||
@ -226,12 +196,9 @@ void Player::ObserveEntity(int32_t id)
|
|||||||
m_ObservedEntities[index] = id;
|
m_ObservedEntities[index] = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::IsObserved(int32_t id)
|
bool Player::IsObserved(int32_t id) {
|
||||||
{
|
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++) {
|
||||||
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++)
|
if (m_ObservedEntities[i] == id) {
|
||||||
{
|
|
||||||
if (m_ObservedEntities[i] == id)
|
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -239,34 +206,27 @@ bool Player::IsObserved(int32_t id)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::GhostEntity(int32_t id)
|
void Player::GhostEntity(int32_t id) {
|
||||||
{
|
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++) {
|
||||||
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++)
|
if (m_ObservedEntities[i] == id) {
|
||||||
{
|
|
||||||
if (m_ObservedEntities[i] == id)
|
|
||||||
{
|
|
||||||
m_ObservedEntities[i] = 0;
|
m_ObservedEntities[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Player* Player::GetPlayer(const SystemAddress& sysAddr)
|
Player* Player::GetPlayer(const SystemAddress& sysAddr) {
|
||||||
{
|
|
||||||
auto* entity = UserManager::Instance()->GetUser(sysAddr)->GetLastUsedChar()->GetEntity();
|
auto* entity = UserManager::Instance()->GetUser(sysAddr)->GetLastUsedChar()->GetEntity();
|
||||||
|
|
||||||
return static_cast<Player*>(entity);
|
return static_cast<Player*>(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
Player* Player::GetPlayer(const std::string& name)
|
Player* Player::GetPlayer(const std::string& name) {
|
||||||
{
|
|
||||||
const auto characters = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_CHARACTER);
|
const auto characters = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_CHARACTER);
|
||||||
|
|
||||||
for (auto* character : characters)
|
for (auto* character : characters) {
|
||||||
{
|
|
||||||
if (!character->IsPlayer()) continue;
|
if (!character->IsPlayer()) continue;
|
||||||
|
|
||||||
if (character->GetCharacter()->GetName() == name)
|
if (character->GetCharacter()->GetName() == name) {
|
||||||
{
|
|
||||||
return static_cast<Player*>(character);
|
return static_cast<Player*>(character);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -274,12 +234,9 @@ Player* Player::GetPlayer(const std::string& name)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player* Player::GetPlayer(LWOOBJID playerID)
|
Player* Player::GetPlayer(LWOOBJID playerID) {
|
||||||
{
|
for (auto* player : m_Players) {
|
||||||
for (auto* player : m_Players)
|
if (player->GetObjectID() == playerID) {
|
||||||
{
|
|
||||||
if (player->GetObjectID() == playerID)
|
|
||||||
{
|
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -287,8 +244,7 @@ Player* Player::GetPlayer(LWOOBJID playerID)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<Player*>& Player::GetAllPlayers()
|
const std::vector<Player*>& Player::GetAllPlayers() {
|
||||||
{
|
|
||||||
return m_Players;
|
return m_Players;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,23 +256,19 @@ void Player::SetDroppedCoins(uint64_t value) {
|
|||||||
m_DroppedCoins = value;
|
m_DroppedCoins = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player()
|
Player::~Player() {
|
||||||
{
|
|
||||||
Game::logger->Log("Player", "Deleted player");
|
Game::logger->Log("Player", "Deleted player");
|
||||||
|
|
||||||
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++)
|
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++) {
|
||||||
{
|
|
||||||
const auto id = m_ObservedEntities[i];
|
const auto id = m_ObservedEntities[i];
|
||||||
|
|
||||||
if (id == 0)
|
if (id == 0) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* entity = EntityManager::Instance()->GetGhostCandidate(id);
|
auto* entity = EntityManager::Instance()->GetGhostCandidate(id);
|
||||||
|
|
||||||
if (entity != nullptr)
|
if (entity != nullptr) {
|
||||||
{
|
|
||||||
entity->SetObservers(entity->GetObservers() - 1);
|
entity->SetObservers(entity->GetObservers() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -325,8 +277,7 @@ Player::~Player()
|
|||||||
|
|
||||||
const auto& iter = std::find(m_Players.begin(), m_Players.end(), this);
|
const auto& iter = std::find(m_Players.begin(), m_Players.end(), this);
|
||||||
|
|
||||||
if (iter == m_Players.end())
|
if (iter == m_Players.end()) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,18 +3,13 @@
|
|||||||
|
|
||||||
TeamManager* TeamManager::m_Address = nullptr; //For singleton method
|
TeamManager* TeamManager::m_Address = nullptr; //For singleton method
|
||||||
|
|
||||||
TeamManager::TeamManager()
|
TeamManager::TeamManager() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Team* TeamManager::GetTeam(LWOOBJID member) const
|
Team* TeamManager::GetTeam(LWOOBJID member) const {
|
||||||
{
|
for (const auto& pair : m_Teams) {
|
||||||
for (const auto& pair : m_Teams)
|
for (const auto memberId : pair.second->members) {
|
||||||
{
|
if (memberId == member) {
|
||||||
for (const auto memberId : pair.second->members)
|
|
||||||
{
|
|
||||||
if (memberId == member)
|
|
||||||
{
|
|
||||||
return pair.second;
|
return pair.second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -23,36 +18,29 @@ Team* TeamManager::GetTeam(LWOOBJID member) const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
LWOOBJID TeamManager::GetNextLootOwner(Team* team) const
|
LWOOBJID TeamManager::GetNextLootOwner(Team* team) const {
|
||||||
{
|
|
||||||
team->lootRound++;
|
team->lootRound++;
|
||||||
|
|
||||||
if (team->lootRound >= team->members.size())
|
if (team->lootRound >= team->members.size()) {
|
||||||
{
|
|
||||||
team->lootRound = 0;
|
team->lootRound = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return team->members[team->lootRound];
|
return team->members[team->lootRound];
|
||||||
}
|
}
|
||||||
|
|
||||||
void TeamManager::UpdateTeam(LWOOBJID teamId, char lootOption, const std::vector<LWOOBJID>& members)
|
void TeamManager::UpdateTeam(LWOOBJID teamId, char lootOption, const std::vector<LWOOBJID>& members) {
|
||||||
{
|
|
||||||
const auto& pair = m_Teams.find(teamId);
|
const auto& pair = m_Teams.find(teamId);
|
||||||
|
|
||||||
Team* team;
|
Team* team;
|
||||||
|
|
||||||
if (pair == m_Teams.end())
|
if (pair == m_Teams.end()) {
|
||||||
{
|
if (members.size() <= 1) {
|
||||||
if (members.size() <= 1)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
team = new Team();
|
team = new Team();
|
||||||
m_Teams[teamId] = team;
|
m_Teams[teamId] = team;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
team = pair->second;
|
team = pair->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,8 +48,7 @@ void TeamManager::UpdateTeam(LWOOBJID teamId, char lootOption, const std::vector
|
|||||||
team->lootOption = lootOption;
|
team->lootOption = lootOption;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TeamManager::DeleteTeam(LWOOBJID teamId)
|
void TeamManager::DeleteTeam(LWOOBJID teamId) {
|
||||||
{
|
|
||||||
const auto& pair = m_Teams.find(teamId);
|
const auto& pair = m_Teams.find(teamId);
|
||||||
|
|
||||||
if (pair == m_Teams.end()) return;
|
if (pair == m_Teams.end()) return;
|
||||||
@ -71,6 +58,5 @@ void TeamManager::DeleteTeam(LWOOBJID teamId)
|
|||||||
m_Teams.erase(teamId);
|
m_Teams.erase(teamId);
|
||||||
}
|
}
|
||||||
|
|
||||||
TeamManager::~TeamManager()
|
TeamManager::~TeamManager() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
@ -12,122 +12,93 @@
|
|||||||
|
|
||||||
TradingManager* TradingManager::m_Address = nullptr;
|
TradingManager* TradingManager::m_Address = nullptr;
|
||||||
|
|
||||||
Trade::Trade(LWOOBJID tradeId, LWOOBJID participantA, LWOOBJID participantB)
|
Trade::Trade(LWOOBJID tradeId, LWOOBJID participantA, LWOOBJID participantB) {
|
||||||
{
|
|
||||||
m_TradeId = tradeId;
|
m_TradeId = tradeId;
|
||||||
m_ParticipantA = participantA;
|
m_ParticipantA = participantA;
|
||||||
m_ParticipantB = participantB;
|
m_ParticipantB = participantB;
|
||||||
}
|
}
|
||||||
|
|
||||||
Trade::~Trade()
|
Trade::~Trade() {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LWOOBJID Trade::GetTradeId() const
|
LWOOBJID Trade::GetTradeId() const {
|
||||||
{
|
|
||||||
return m_TradeId;
|
return m_TradeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Trade::IsParticipant(LWOOBJID playerId) const
|
bool Trade::IsParticipant(LWOOBJID playerId) const {
|
||||||
{
|
|
||||||
return m_ParticipantA == playerId || m_ParticipantB == playerId;
|
return m_ParticipantA == playerId || m_ParticipantB == playerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
LWOOBJID Trade::GetParticipantA() const
|
LWOOBJID Trade::GetParticipantA() const {
|
||||||
{
|
|
||||||
return m_ParticipantA;
|
return m_ParticipantA;
|
||||||
}
|
}
|
||||||
|
|
||||||
LWOOBJID Trade::GetParticipantB() const
|
LWOOBJID Trade::GetParticipantB() const {
|
||||||
{
|
|
||||||
return m_ParticipantB;
|
return m_ParticipantB;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity* Trade::GetParticipantAEntity() const
|
Entity* Trade::GetParticipantAEntity() const {
|
||||||
{
|
|
||||||
return EntityManager::Instance()->GetEntity(m_ParticipantA);
|
return EntityManager::Instance()->GetEntity(m_ParticipantA);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity* Trade::GetParticipantBEntity() const
|
Entity* Trade::GetParticipantBEntity() const {
|
||||||
{
|
|
||||||
return EntityManager::Instance()->GetEntity(m_ParticipantB);
|
return EntityManager::Instance()->GetEntity(m_ParticipantB);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trade::SetCoins(LWOOBJID participant, uint64_t coins)
|
void Trade::SetCoins(LWOOBJID participant, uint64_t coins) {
|
||||||
{
|
if (participant == m_ParticipantA) {
|
||||||
if (participant == m_ParticipantA)
|
|
||||||
{
|
|
||||||
m_CoinsA = coins;
|
m_CoinsA = coins;
|
||||||
}
|
} else if (participant == m_ParticipantB) {
|
||||||
else if (participant == m_ParticipantB)
|
|
||||||
{
|
|
||||||
m_CoinsB = coins;
|
m_CoinsB = coins;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trade::SetItems(LWOOBJID participant, std::vector<TradeItem> items)
|
void Trade::SetItems(LWOOBJID participant, std::vector<TradeItem> items) {
|
||||||
{
|
if (participant == m_ParticipantA) {
|
||||||
if (participant == m_ParticipantA)
|
|
||||||
{
|
|
||||||
m_ItemsA = items;
|
m_ItemsA = items;
|
||||||
}
|
} else if (participant == m_ParticipantB) {
|
||||||
else if (participant == m_ParticipantB)
|
|
||||||
{
|
|
||||||
m_ItemsB = items;
|
m_ItemsB = items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trade::SetAccepted(LWOOBJID participant, bool value)
|
void Trade::SetAccepted(LWOOBJID participant, bool value) {
|
||||||
{
|
if (participant == m_ParticipantA) {
|
||||||
if (participant == m_ParticipantA)
|
|
||||||
{
|
|
||||||
m_AcceptedA = !value;
|
m_AcceptedA = !value;
|
||||||
|
|
||||||
Game::logger->Log("Trade", "Accepted from A (%d), B: (%d)", value, m_AcceptedB);
|
Game::logger->Log("Trade", "Accepted from A (%d), B: (%d)", value, m_AcceptedB);
|
||||||
|
|
||||||
auto* entityB = GetParticipantBEntity();
|
auto* entityB = GetParticipantBEntity();
|
||||||
|
|
||||||
if (entityB != nullptr)
|
if (entityB != nullptr) {
|
||||||
{
|
|
||||||
GameMessages::SendServerTradeAccept(m_ParticipantB, value, entityB->GetSystemAddress());
|
GameMessages::SendServerTradeAccept(m_ParticipantB, value, entityB->GetSystemAddress());
|
||||||
}
|
}
|
||||||
}
|
} else if (participant == m_ParticipantB) {
|
||||||
else if (participant == m_ParticipantB)
|
|
||||||
{
|
|
||||||
m_AcceptedB = !value;
|
m_AcceptedB = !value;
|
||||||
|
|
||||||
Game::logger->Log("Trade", "Accepted from B (%d), A: (%d)", value, m_AcceptedA);
|
Game::logger->Log("Trade", "Accepted from B (%d), A: (%d)", value, m_AcceptedA);
|
||||||
|
|
||||||
auto* entityA = GetParticipantAEntity();
|
auto* entityA = GetParticipantAEntity();
|
||||||
|
|
||||||
if (entityA != nullptr)
|
if (entityA != nullptr) {
|
||||||
{
|
|
||||||
GameMessages::SendServerTradeAccept(m_ParticipantA, value, entityA->GetSystemAddress());
|
GameMessages::SendServerTradeAccept(m_ParticipantA, value, entityA->GetSystemAddress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_AcceptedA && m_AcceptedB)
|
if (m_AcceptedA && m_AcceptedB) {
|
||||||
{
|
|
||||||
auto* entityB = GetParticipantBEntity();
|
auto* entityB = GetParticipantBEntity();
|
||||||
|
|
||||||
if (entityB != nullptr)
|
if (entityB != nullptr) {
|
||||||
{
|
|
||||||
GameMessages::SendServerTradeAccept(m_ParticipantB, false, entityB->GetSystemAddress());
|
GameMessages::SendServerTradeAccept(m_ParticipantB, false, entityB->GetSystemAddress());
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* entityA = GetParticipantAEntity();
|
auto* entityA = GetParticipantAEntity();
|
||||||
|
|
||||||
if (entityA != nullptr)
|
if (entityA != nullptr) {
|
||||||
{
|
|
||||||
GameMessages::SendServerTradeAccept(m_ParticipantA, false, entityA->GetSystemAddress());
|
GameMessages::SendServerTradeAccept(m_ParticipantA, false, entityA->GetSystemAddress());
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,8 +106,7 @@ void Trade::SetAccepted(LWOOBJID participant, bool value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trade::Complete()
|
void Trade::Complete() {
|
||||||
{
|
|
||||||
auto* entityA = GetParticipantAEntity();
|
auto* entityA = GetParticipantAEntity();
|
||||||
auto* entityB = GetParticipantBEntity();
|
auto* entityB = GetParticipantBEntity();
|
||||||
|
|
||||||
@ -154,27 +124,23 @@ void Trade::Complete()
|
|||||||
characterA->SetCoins(characterA->GetCoins() - m_CoinsA + m_CoinsB, eLootSourceType::LOOT_SOURCE_TRADE);
|
characterA->SetCoins(characterA->GetCoins() - m_CoinsA + m_CoinsB, eLootSourceType::LOOT_SOURCE_TRADE);
|
||||||
characterB->SetCoins(characterB->GetCoins() - m_CoinsB + m_CoinsA, eLootSourceType::LOOT_SOURCE_TRADE);
|
characterB->SetCoins(characterB->GetCoins() - m_CoinsB + m_CoinsA, eLootSourceType::LOOT_SOURCE_TRADE);
|
||||||
|
|
||||||
for (const auto& tradeItem : m_ItemsA)
|
for (const auto& tradeItem : m_ItemsA) {
|
||||||
{
|
|
||||||
inventoryA->RemoveItem(tradeItem.itemLot, tradeItem.itemCount, INVALID, true);
|
inventoryA->RemoveItem(tradeItem.itemLot, tradeItem.itemCount, INVALID, true);
|
||||||
|
|
||||||
missionsA->Progress(MissionTaskType::MISSION_TASK_TYPE_ITEM_COLLECTION, tradeItem.itemLot, LWOOBJID_EMPTY, "", -tradeItem.itemCount);
|
missionsA->Progress(MissionTaskType::MISSION_TASK_TYPE_ITEM_COLLECTION, tradeItem.itemLot, LWOOBJID_EMPTY, "", -tradeItem.itemCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& tradeItem : m_ItemsB)
|
for (const auto& tradeItem : m_ItemsB) {
|
||||||
{
|
|
||||||
inventoryB->RemoveItem(tradeItem.itemLot, tradeItem.itemCount, INVALID, true);
|
inventoryB->RemoveItem(tradeItem.itemLot, tradeItem.itemCount, INVALID, true);
|
||||||
|
|
||||||
missionsB->Progress(MissionTaskType::MISSION_TASK_TYPE_ITEM_COLLECTION, tradeItem.itemLot, LWOOBJID_EMPTY, "", -tradeItem.itemCount);
|
missionsB->Progress(MissionTaskType::MISSION_TASK_TYPE_ITEM_COLLECTION, tradeItem.itemLot, LWOOBJID_EMPTY, "", -tradeItem.itemCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& tradeItem : m_ItemsA)
|
for (const auto& tradeItem : m_ItemsA) {
|
||||||
{
|
|
||||||
inventoryB->AddItem(tradeItem.itemLot, tradeItem.itemCount, eLootSourceType::LOOT_SOURCE_TRADE);
|
inventoryB->AddItem(tradeItem.itemLot, tradeItem.itemCount, eLootSourceType::LOOT_SOURCE_TRADE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& tradeItem : m_ItemsB)
|
for (const auto& tradeItem : m_ItemsB) {
|
||||||
{
|
|
||||||
inventoryA->AddItem(tradeItem.itemLot, tradeItem.itemCount, eLootSourceType::LOOT_SOURCE_TRADE);
|
inventoryA->AddItem(tradeItem.itemLot, tradeItem.itemCount, eLootSourceType::LOOT_SOURCE_TRADE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,8 +150,7 @@ void Trade::Complete()
|
|||||||
characterB->SaveXMLToDatabase();
|
characterB->SaveXMLToDatabase();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trade::Cancel()
|
void Trade::Cancel() {
|
||||||
{
|
|
||||||
auto* entityA = GetParticipantAEntity();
|
auto* entityA = GetParticipantAEntity();
|
||||||
auto* entityB = GetParticipantBEntity();
|
auto* entityB = GetParticipantBEntity();
|
||||||
|
|
||||||
@ -195,8 +160,7 @@ void Trade::Cancel()
|
|||||||
GameMessages::SendServerTradeCancel(entityB->GetObjectID(), entityB->GetSystemAddress());
|
GameMessages::SendServerTradeCancel(entityB->GetObjectID(), entityB->GetSystemAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Trade::SendUpdateToOther(LWOOBJID participant)
|
void Trade::SendUpdateToOther(LWOOBJID participant) {
|
||||||
{
|
|
||||||
Entity* other = nullptr;
|
Entity* other = nullptr;
|
||||||
Entity* self = nullptr;
|
Entity* self = nullptr;
|
||||||
uint64_t coins;
|
uint64_t coins;
|
||||||
@ -204,22 +168,17 @@ void Trade::SendUpdateToOther(LWOOBJID participant)
|
|||||||
|
|
||||||
Game::logger->Log("Trade", "Attempting to send trade update");
|
Game::logger->Log("Trade", "Attempting to send trade update");
|
||||||
|
|
||||||
if (participant == m_ParticipantA)
|
if (participant == m_ParticipantA) {
|
||||||
{
|
|
||||||
other = GetParticipantBEntity();
|
other = GetParticipantBEntity();
|
||||||
self = GetParticipantAEntity();
|
self = GetParticipantAEntity();
|
||||||
coins = m_CoinsA;
|
coins = m_CoinsA;
|
||||||
itemIds = m_ItemsA;
|
itemIds = m_ItemsA;
|
||||||
}
|
} else if (participant == m_ParticipantB) {
|
||||||
else if (participant == m_ParticipantB)
|
|
||||||
{
|
|
||||||
other = GetParticipantAEntity();
|
other = GetParticipantAEntity();
|
||||||
self = GetParticipantBEntity();
|
self = GetParticipantBEntity();
|
||||||
coins = m_CoinsB;
|
coins = m_CoinsB;
|
||||||
itemIds = m_ItemsB;
|
itemIds = m_ItemsB;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,8 +190,7 @@ void Trade::SendUpdateToOther(LWOOBJID participant)
|
|||||||
|
|
||||||
if (inventoryComponent == nullptr) return;
|
if (inventoryComponent == nullptr) return;
|
||||||
|
|
||||||
for (const auto tradeItem : itemIds)
|
for (const auto tradeItem : itemIds) {
|
||||||
{
|
|
||||||
auto* item = inventoryComponent->FindItemById(tradeItem.itemId);
|
auto* item = inventoryComponent->FindItemById(tradeItem.itemId);
|
||||||
|
|
||||||
if (item == nullptr) return;
|
if (item == nullptr) return;
|
||||||
@ -247,22 +205,18 @@ void Trade::SendUpdateToOther(LWOOBJID participant)
|
|||||||
GameMessages::SendServerTradeUpdate(other->GetObjectID(), coins, items, other->GetSystemAddress());
|
GameMessages::SendServerTradeUpdate(other->GetObjectID(), coins, items, other->GetSystemAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
TradingManager::TradingManager()
|
TradingManager::TradingManager() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TradingManager::~TradingManager()
|
TradingManager::~TradingManager() {
|
||||||
{
|
for (const auto& pair : trades) {
|
||||||
for (const auto& pair : trades)
|
|
||||||
{
|
|
||||||
delete pair.second;
|
delete pair.second;
|
||||||
}
|
}
|
||||||
|
|
||||||
trades.clear();
|
trades.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
Trade* TradingManager::GetTrade(LWOOBJID tradeId) const
|
Trade* TradingManager::GetTrade(LWOOBJID tradeId) const {
|
||||||
{
|
|
||||||
const auto& pair = trades.find(tradeId);
|
const auto& pair = trades.find(tradeId);
|
||||||
|
|
||||||
if (pair == trades.end()) return nullptr;
|
if (pair == trades.end()) return nullptr;
|
||||||
@ -270,12 +224,9 @@ Trade* TradingManager::GetTrade(LWOOBJID tradeId) const
|
|||||||
return pair->second;
|
return pair->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
Trade* TradingManager::GetPlayerTrade(LWOOBJID playerId) const
|
Trade* TradingManager::GetPlayerTrade(LWOOBJID playerId) const {
|
||||||
{
|
for (const auto& pair : trades) {
|
||||||
for (const auto& pair : trades)
|
if (pair.second->IsParticipant(playerId)) {
|
||||||
{
|
|
||||||
if (pair.second->IsParticipant(playerId))
|
|
||||||
{
|
|
||||||
return pair.second;
|
return pair.second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,8 +234,7 @@ Trade* TradingManager::GetPlayerTrade(LWOOBJID playerId) const
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TradingManager::CancelTrade(LWOOBJID tradeId)
|
void TradingManager::CancelTrade(LWOOBJID tradeId) {
|
||||||
{
|
|
||||||
auto* trade = GetTrade(tradeId);
|
auto* trade = GetTrade(tradeId);
|
||||||
|
|
||||||
if (trade == nullptr) return;
|
if (trade == nullptr) return;
|
||||||
@ -294,8 +244,7 @@ void TradingManager::CancelTrade(LWOOBJID tradeId)
|
|||||||
trades.erase(tradeId);
|
trades.erase(tradeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
Trade* TradingManager::NewTrade(LWOOBJID participantA, LWOOBJID participantB)
|
Trade* TradingManager::NewTrade(LWOOBJID participantA, LWOOBJID participantB) {
|
||||||
{
|
|
||||||
const LWOOBJID tradeId = ObjectIDManager::Instance()->GenerateObjectID();
|
const LWOOBJID tradeId = ObjectIDManager::Instance()->GenerateObjectID();
|
||||||
|
|
||||||
auto* trade = new Trade(tradeId, participantA, participantB);
|
auto* trade = new Trade(tradeId, participantA, participantB);
|
||||||
|
@ -109,18 +109,15 @@ Character * User::GetLastUsedChar() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool User::GetIsMuted() const
|
bool User::GetIsMuted() const {
|
||||||
{
|
|
||||||
return m_MuteExpire == 1 || m_MuteExpire > time(NULL);
|
return m_MuteExpire == 1 || m_MuteExpire > time(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t User::GetMuteExpire() const
|
time_t User::GetMuteExpire() const {
|
||||||
{
|
|
||||||
return m_MuteExpire;
|
return m_MuteExpire;
|
||||||
}
|
}
|
||||||
|
|
||||||
void User::SetMuteExpire(time_t value)
|
void User::SetMuteExpire(time_t value) {
|
||||||
{
|
|
||||||
m_MuteExpire = value;
|
m_MuteExpire = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,8 +109,7 @@ User* UserManager::GetUser ( const std::string& username ) {
|
|||||||
bool UserManager::DeleteUser(const SystemAddress& sysAddr) {
|
bool UserManager::DeleteUser(const SystemAddress& sysAddr) {
|
||||||
const auto& it = m_Users.find(sysAddr);
|
const auto& it = m_Users.find(sysAddr);
|
||||||
|
|
||||||
if (it != m_Users.end())
|
if (it != m_Users.end()) {
|
||||||
{
|
|
||||||
if (std::count(m_UsersToDelete.begin(), m_UsersToDelete.end(), it->second)) return false;
|
if (std::count(m_UsersToDelete.begin(), m_UsersToDelete.end(), it->second)) return false;
|
||||||
|
|
||||||
m_UsersToDelete.push_back(it->second);
|
m_UsersToDelete.push_back(it->second);
|
||||||
@ -123,10 +122,8 @@ bool UserManager::DeleteUser ( const SystemAddress& sysAddr ) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserManager::DeletePendingRemovals()
|
void UserManager::DeletePendingRemovals() {
|
||||||
{
|
for (auto* user : m_UsersToDelete) {
|
||||||
for (auto* user : m_UsersToDelete)
|
|
||||||
{
|
|
||||||
Game::logger->Log("UserManager", "Deleted user %i", user->GetAccountID());
|
Game::logger->Log("UserManager", "Deleted user %i", user->GetAccountID());
|
||||||
|
|
||||||
delete user;
|
delete user;
|
||||||
@ -185,8 +182,7 @@ void UserManager::RequestCharacterList ( const SystemAddress& sysAddr ) {
|
|||||||
if (res->rowsCount() > 0) {
|
if (res->rowsCount() > 0) {
|
||||||
std::vector<Character*>& chars = u->GetCharacters();
|
std::vector<Character*>& chars = u->GetCharacters();
|
||||||
|
|
||||||
for (size_t i = 0; i < chars.size(); ++i)
|
for (size_t i = 0; i < chars.size(); ++i) {
|
||||||
{
|
|
||||||
if (chars[i]->GetEntity() == nullptr) // We don't have entity data to save
|
if (chars[i]->GetEntity() == nullptr) // We don't have entity data to save
|
||||||
{
|
{
|
||||||
delete chars[i];
|
delete chars[i];
|
||||||
@ -196,8 +192,7 @@ void UserManager::RequestCharacterList ( const SystemAddress& sysAddr ) {
|
|||||||
|
|
||||||
auto* skillComponent = chars[i]->GetEntity()->GetComponent<SkillComponent>();
|
auto* skillComponent = chars[i]->GetEntity()->GetComponent<SkillComponent>();
|
||||||
|
|
||||||
if (skillComponent != nullptr)
|
if (skillComponent != nullptr) {
|
||||||
{
|
|
||||||
skillComponent->Reset();
|
skillComponent->Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,8 +259,7 @@ void UserManager::CreateCharacter(const SystemAddress& sysAddr, Packet* packet)
|
|||||||
|
|
||||||
if (name == "") {
|
if (name == "") {
|
||||||
Game::logger->Log("UserManager", "AccountID: %i is creating a character with predefined name: %s", u->GetAccountID(), predefinedName.c_str());
|
Game::logger->Log("UserManager", "AccountID: %i is creating a character with predefined name: %s", u->GetAccountID(), predefinedName.c_str());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Game::logger->Log("UserManager", "AccountID: %i is creating a character with name: %s (temporary: %s)", u->GetAccountID(), name.c_str(), predefinedName.c_str());
|
Game::logger->Log("UserManager", "AccountID: %i is creating a character with name: %s (temporary: %s)", u->GetAccountID(), name.c_str(), predefinedName.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -383,8 +377,7 @@ void UserManager::DeleteCharacter(const SystemAddress& sysAddr, Packet* packet)
|
|||||||
if (!hasCharacter) {
|
if (!hasCharacter) {
|
||||||
Game::logger->Log("UserManager", "User %i tried to delete a character that it does not own!", u->GetAccountID());
|
Game::logger->Log("UserManager", "User %i tried to delete a character that it does not own!", u->GetAccountID());
|
||||||
WorldPackets::SendCharacterDeleteResponse(sysAddr, false);
|
WorldPackets::SendCharacterDeleteResponse(sysAddr, false);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Game::logger->Log("UserManager", "Deleting character %i", charID);
|
Game::logger->Log("UserManager", "Deleting character %i", charID);
|
||||||
{
|
{
|
||||||
sql::PreparedStatement* stmt = Database::CreatePreppedStmt("DELETE FROM charxml WHERE id=? LIMIT 1;");
|
sql::PreparedStatement* stmt = Database::CreatePreppedStmt("DELETE FROM charxml WHERE id=? LIMIT 1;");
|
||||||
@ -575,8 +568,7 @@ uint32_t FindCharShirtID(uint32_t shirtColor, uint32_t shirtStyle) {
|
|||||||
auto shirtLOT = tableData.getIntField(0, -1);
|
auto shirtLOT = tableData.getIntField(0, -1);
|
||||||
tableData.finalize();
|
tableData.finalize();
|
||||||
return shirtLOT;
|
return shirtLOT;
|
||||||
}
|
} catch (const std::exception&) {
|
||||||
catch (const std::exception&){
|
|
||||||
Game::logger->Log("Character Create", "Failed to execute query! Using backup...");
|
Game::logger->Log("Character Create", "Failed to execute query! Using backup...");
|
||||||
// in case of no shirt found in CDServer, return problematic red vest.
|
// in case of no shirt found in CDServer, return problematic red vest.
|
||||||
return 4069;
|
return 4069;
|
||||||
@ -591,8 +583,7 @@ uint32_t FindCharPantsID(uint32_t pantsColor) {
|
|||||||
auto pantsLOT = tableData.getIntField(0, -1);
|
auto pantsLOT = tableData.getIntField(0, -1);
|
||||||
tableData.finalize();
|
tableData.finalize();
|
||||||
return pantsLOT;
|
return pantsLOT;
|
||||||
}
|
} catch (const std::exception&) {
|
||||||
catch (const std::exception&){
|
|
||||||
Game::logger->Log("Character Create", "Failed to execute query! Using backup...");
|
Game::logger->Log("Character Create", "Failed to execute query! Using backup...");
|
||||||
// in case of no pants color found in CDServer, return red pants.
|
// in case of no pants color found in CDServer, return red pants.
|
||||||
return 2508;
|
return 2508;
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
#include "BehaviorContext.h"
|
#include "BehaviorContext.h"
|
||||||
#include "EntityManager.h"
|
#include "EntityManager.h"
|
||||||
|
|
||||||
void AirMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void AirMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
uint32_t handle;
|
uint32_t handle;
|
||||||
|
|
||||||
bitStream->Read(handle);
|
bitStream->Read(handle);
|
||||||
@ -12,15 +11,13 @@ void AirMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi
|
|||||||
context->RegisterSyncBehavior(handle, this, branch);
|
context->RegisterSyncBehavior(handle, this, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AirMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void AirMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
const auto handle = context->GetUniqueSkillId();
|
const auto handle = context->GetUniqueSkillId();
|
||||||
|
|
||||||
bitStream->Write(handle);
|
bitStream->Write(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AirMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch)
|
void AirMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
uint32_t behaviorId;
|
uint32_t behaviorId;
|
||||||
|
|
||||||
bit_stream->Read(behaviorId);
|
bit_stream->Read(behaviorId);
|
||||||
@ -31,14 +28,12 @@ void AirMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bit_
|
|||||||
|
|
||||||
auto* behavior = CreateBehavior(behaviorId);
|
auto* behavior = CreateBehavior(behaviorId);
|
||||||
|
|
||||||
if (EntityManager::Instance()->GetEntity(target) != nullptr)
|
if (EntityManager::Instance()->GetEntity(target) != nullptr) {
|
||||||
{
|
|
||||||
branch.target = target;
|
branch.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
behavior->Handle(context, bit_stream, branch);
|
behavior->Handle(context, bit_stream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AirMovementBehavior::Load()
|
void AirMovementBehavior::Load() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit AirMovementBehavior(const uint32_t behavior_id) : Behavior(behavior_id)
|
explicit AirMovementBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -3,18 +3,14 @@
|
|||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "dLogger.h"
|
#include "dLogger.h"
|
||||||
|
|
||||||
void AndBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch)
|
void AndBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||||
{
|
for (auto* behavior : this->m_behaviors) {
|
||||||
for (auto* behavior : this->m_behaviors)
|
|
||||||
{
|
|
||||||
behavior->Handle(context, bitStream, branch);
|
behavior->Handle(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch)
|
void AndBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||||
{
|
for (auto* behavior : this->m_behaviors) {
|
||||||
for (auto* behavior : this->m_behaviors)
|
|
||||||
{
|
|
||||||
behavior->Calculate(context, bitStream, branch);
|
behavior->Calculate(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -25,14 +21,11 @@ void AndBehavior::UnCast(BehaviorContext* context, const BehaviorBranchContext b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndBehavior::Load()
|
void AndBehavior::Load() {
|
||||||
{
|
|
||||||
const auto parameters = GetParameterNames();
|
const auto parameters = GetParameterNames();
|
||||||
|
|
||||||
for (const auto& parameter : parameters)
|
for (const auto& parameter : parameters) {
|
||||||
{
|
if (parameter.first.rfind("behavior", 0) == 0) {
|
||||||
if (parameter.first.rfind("behavior", 0) == 0)
|
|
||||||
{
|
|
||||||
auto* action = GetAction(parameter.second);
|
auto* action = GetAction(parameter.second);
|
||||||
|
|
||||||
this->m_behaviors.push_back(action);
|
this->m_behaviors.push_back(action);
|
||||||
|
@ -12,8 +12,7 @@ public:
|
|||||||
/*
|
/*
|
||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
explicit AndBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit AndBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -5,8 +5,7 @@
|
|||||||
#include "BuffComponent.h"
|
#include "BuffComponent.h"
|
||||||
|
|
||||||
|
|
||||||
void ApplyBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void ApplyBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(branch.target == LWOOBJID_EMPTY ? context->originator : branch.target);
|
auto* entity = EntityManager::Instance()->GetEntity(branch.target == LWOOBJID_EMPTY ? context->originator : branch.target);
|
||||||
|
|
||||||
if (entity == nullptr) return;
|
if (entity == nullptr) return;
|
||||||
@ -19,8 +18,7 @@ void ApplyBuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS
|
|||||||
cancelOnLogout, cancelonRemoveBuff, cancelOnUi, cancelOnUnequip, cancelOnZone);
|
cancelOnLogout, cancelonRemoveBuff, cancelOnUi, cancelOnUnequip, cancelOnZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyBuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch)
|
void ApplyBuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
if (entity == nullptr) return;
|
if (entity == nullptr) return;
|
||||||
@ -32,13 +30,11 @@ void ApplyBuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext b
|
|||||||
buffComponent->RemoveBuff(m_BuffId);
|
buffComponent->RemoveBuff(m_BuffId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyBuffBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void ApplyBuffBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
Handle(context, bitStream, branch);
|
Handle(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyBuffBehavior::Load()
|
void ApplyBuffBehavior::Load() {
|
||||||
{
|
|
||||||
m_BuffId = GetInt("buff_id");
|
m_BuffId = GetInt("buff_id");
|
||||||
m_Duration = GetFloat("duration_secs");
|
m_Duration = GetFloat("duration_secs");
|
||||||
addImmunity = GetBoolean("add_immunity");
|
addImmunity = GetBoolean("add_immunity");
|
||||||
|
@ -21,8 +21,7 @@ public:
|
|||||||
/*
|
/*
|
||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
explicit ApplyBuffBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit ApplyBuffBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -10,14 +10,12 @@
|
|||||||
#include "RebuildComponent.h"
|
#include "RebuildComponent.h"
|
||||||
#include "DestroyableComponent.h"
|
#include "DestroyableComponent.h"
|
||||||
|
|
||||||
void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
uint32_t targetCount;
|
uint32_t targetCount;
|
||||||
|
|
||||||
bitStream->Read(targetCount);
|
bitStream->Read(targetCount);
|
||||||
|
|
||||||
if (targetCount > this->m_maxTargets)
|
if (targetCount > this->m_maxTargets) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,8 +23,7 @@ void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* b
|
|||||||
|
|
||||||
targets.reserve(targetCount);
|
targets.reserve(targetCount);
|
||||||
|
|
||||||
for (auto i = 0u; i < targetCount; ++i)
|
for (auto i = 0u; i < targetCount; ++i) {
|
||||||
{
|
|
||||||
LWOOBJID target;
|
LWOOBJID target;
|
||||||
|
|
||||||
bitStream->Read(target);
|
bitStream->Read(target);
|
||||||
@ -34,20 +31,17 @@ void AreaOfEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* b
|
|||||||
targets.push_back(target);
|
targets.push_back(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto target : targets)
|
for (auto target : targets) {
|
||||||
{
|
|
||||||
branch.target = target;
|
branch.target = target;
|
||||||
|
|
||||||
this->m_action->Handle(context, bitStream, branch);
|
this->m_action->Handle(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
auto* self = EntityManager::Instance()->GetEntity(context->caster);
|
auto* self = EntityManager::Instance()->GetEntity(context->caster);
|
||||||
|
|
||||||
if (self == nullptr)
|
if (self == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("TacArcBehavior", "Invalid self for (%llu)!", context->originator);
|
Game::logger->Log("TacArcBehavior", "Invalid self for (%llu)!", context->originator);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -59,10 +53,8 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
|
|||||||
|
|
||||||
auto* presetTarget = EntityManager::Instance()->GetEntity(branch.target);
|
auto* presetTarget = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
if (presetTarget != nullptr)
|
if (presetTarget != nullptr) {
|
||||||
{
|
if (this->m_radius * this->m_radius >= Vector3::DistanceSquared(reference, presetTarget->GetPosition())) {
|
||||||
if (this->m_radius * this->m_radius >= Vector3::DistanceSquared(reference, presetTarget->GetPosition()))
|
|
||||||
{
|
|
||||||
targets.push_back(presetTarget);
|
targets.push_back(presetTarget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,44 +67,37 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Gets all of the valid targets, passing in if should target enemies and friends
|
// Gets all of the valid targets, passing in if should target enemies and friends
|
||||||
for (auto validTarget : context->GetValidTargets(m_ignoreFaction , includeFaction, m_TargetSelf == 1, m_targetEnemy == 1, m_targetFriend == 1))
|
for (auto validTarget : context->GetValidTargets(m_ignoreFaction, includeFaction, m_TargetSelf == 1, m_targetEnemy == 1, m_targetFriend == 1)) {
|
||||||
{
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(validTarget);
|
auto* entity = EntityManager::Instance()->GetEntity(validTarget);
|
||||||
|
|
||||||
if (entity == nullptr)
|
if (entity == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("TacArcBehavior", "Invalid target (%llu) for (%llu)!", validTarget, context->originator);
|
Game::logger->Log("TacArcBehavior", "Invalid target (%llu) for (%llu)!", validTarget, context->originator);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::find(targets.begin(), targets.end(), entity) != targets.end())
|
if (std::find(targets.begin(), targets.end(), entity) != targets.end()) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
if (destroyableComponent == nullptr)
|
if (destroyableComponent == nullptr) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (destroyableComponent->HasFaction(m_ignoreFaction))
|
if (destroyableComponent->HasFaction(m_ignoreFaction)) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto distance = Vector3::DistanceSquared(reference, entity->GetPosition());
|
const auto distance = Vector3::DistanceSquared(reference, entity->GetPosition());
|
||||||
|
|
||||||
if (this->m_radius * this->m_radius >= distance && (this->m_maxTargets == 0 || targets.size() < this->m_maxTargets))
|
if (this->m_radius * this->m_radius >= distance && (this->m_maxTargets == 0 || targets.size() < this->m_maxTargets)) {
|
||||||
{
|
|
||||||
targets.push_back(entity);
|
targets.push_back(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::sort(targets.begin(), targets.end(), [reference](Entity* a, Entity* b)
|
std::sort(targets.begin(), targets.end(), [reference](Entity* a, Entity* b) {
|
||||||
{
|
|
||||||
const auto aDistance = Vector3::DistanceSquared(a->GetPosition(), reference);
|
const auto aDistance = Vector3::DistanceSquared(a->GetPosition(), reference);
|
||||||
const auto bDistance = Vector3::DistanceSquared(b->GetPosition(), reference);
|
const auto bDistance = Vector3::DistanceSquared(b->GetPosition(), reference);
|
||||||
|
|
||||||
@ -123,30 +108,26 @@ void AreaOfEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream
|
|||||||
|
|
||||||
bitStream->Write(size);
|
bitStream->Write(size);
|
||||||
|
|
||||||
if (size == 0)
|
if (size == 0) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
context->foundTarget = true;
|
context->foundTarget = true;
|
||||||
|
|
||||||
for (auto* target : targets)
|
for (auto* target : targets) {
|
||||||
{
|
|
||||||
bitStream->Write(target->GetObjectID());
|
bitStream->Write(target->GetObjectID());
|
||||||
|
|
||||||
PlayFx(u"cast", context->originator, target->GetObjectID());
|
PlayFx(u"cast", context->originator, target->GetObjectID());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto* target : targets)
|
for (auto* target : targets) {
|
||||||
{
|
|
||||||
branch.target = target->GetObjectID();
|
branch.target = target->GetObjectID();
|
||||||
|
|
||||||
this->m_action->Calculate(context, bitStream, branch);
|
this->m_action->Calculate(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AreaOfEffectBehavior::Load()
|
void AreaOfEffectBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_action = GetAction("action");
|
this->m_action = GetAction("action");
|
||||||
|
|
||||||
this->m_radius = GetFloat("radius");
|
this->m_radius = GetFloat("radius");
|
||||||
|
@ -23,8 +23,7 @@ public:
|
|||||||
/*
|
/*
|
||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
explicit AreaOfEffectBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit AreaOfEffectBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -4,48 +4,41 @@
|
|||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "dLogger.h"
|
#include "dLogger.h"
|
||||||
|
|
||||||
void AttackDelayBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch)
|
void AttackDelayBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
uint32_t handle;
|
uint32_t handle;
|
||||||
|
|
||||||
bitStream->Read(handle);
|
bitStream->Read(handle);
|
||||||
|
|
||||||
for (auto i = 0u; i < this->m_numIntervals; ++i)
|
for (auto i = 0u; i < this->m_numIntervals; ++i) {
|
||||||
{
|
|
||||||
context->RegisterSyncBehavior(handle, this, branch);
|
context->RegisterSyncBehavior(handle, this, branch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttackDelayBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch)
|
void AttackDelayBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
const auto handle = context->GetUniqueSkillId();
|
const auto handle = context->GetUniqueSkillId();
|
||||||
|
|
||||||
bitStream->Write(handle);
|
bitStream->Write(handle);
|
||||||
|
|
||||||
context->foundTarget = true;
|
context->foundTarget = true;
|
||||||
|
|
||||||
for (auto i = 0u; i < this->m_numIntervals; ++i)
|
for (auto i = 0u; i < this->m_numIntervals; ++i) {
|
||||||
{
|
|
||||||
const auto multiple = static_cast<float>(i + 1);
|
const auto multiple = static_cast<float>(i + 1);
|
||||||
|
|
||||||
context->SyncCalculation(handle, this->m_delay * multiple, this, branch, m_ignoreInterrupts);
|
context->SyncCalculation(handle, this->m_delay * multiple, this, branch, m_ignoreInterrupts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttackDelayBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch)
|
void AttackDelayBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
this->m_action->Handle(context, bitStream, branch);
|
this->m_action->Handle(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttackDelayBehavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch)
|
void AttackDelayBehavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
PlayFx(u"cast", context->originator);
|
PlayFx(u"cast", context->originator);
|
||||||
|
|
||||||
this->m_action->Calculate(context, bitStream, branch);
|
this->m_action->Calculate(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttackDelayBehavior::Load()
|
void AttackDelayBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_numIntervals = GetInt("num_intervals");
|
this->m_numIntervals = GetInt("num_intervals");
|
||||||
|
|
||||||
this->m_action = GetAction("action");
|
this->m_action = GetAction("action");
|
||||||
@ -54,8 +47,7 @@ void AttackDelayBehavior::Load()
|
|||||||
|
|
||||||
this->m_ignoreInterrupts = GetBoolean("ignore_interrupts");
|
this->m_ignoreInterrupts = GetBoolean("ignore_interrupts");
|
||||||
|
|
||||||
if (this->m_numIntervals == 0)
|
if (this->m_numIntervals == 0) {
|
||||||
{
|
|
||||||
this->m_numIntervals = 1;
|
this->m_numIntervals = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit AttackDelayBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit AttackDelayBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -10,8 +10,7 @@ public:
|
|||||||
|
|
||||||
Behavior* m_onSuccess;
|
Behavior* m_onSuccess;
|
||||||
|
|
||||||
explicit BasicAttackBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit BasicAttackBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -73,34 +73,28 @@
|
|||||||
std::unordered_map<uint32_t, Behavior*> Behavior::Cache = {};
|
std::unordered_map<uint32_t, Behavior*> Behavior::Cache = {};
|
||||||
CDBehaviorParameterTable* Behavior::BehaviorParameterTable = nullptr;
|
CDBehaviorParameterTable* Behavior::BehaviorParameterTable = nullptr;
|
||||||
|
|
||||||
Behavior* Behavior::GetBehavior(const uint32_t behaviorId)
|
Behavior* Behavior::GetBehavior(const uint32_t behaviorId) {
|
||||||
{
|
if (BehaviorParameterTable == nullptr) {
|
||||||
if (BehaviorParameterTable == nullptr)
|
|
||||||
{
|
|
||||||
BehaviorParameterTable = CDClientManager::Instance()->GetTable<CDBehaviorParameterTable>("BehaviorParameter");
|
BehaviorParameterTable = CDClientManager::Instance()->GetTable<CDBehaviorParameterTable>("BehaviorParameter");
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto pair = Cache.find(behaviorId);
|
const auto pair = Cache.find(behaviorId);
|
||||||
|
|
||||||
if (pair == Cache.end())
|
if (pair == Cache.end()) {
|
||||||
{
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return static_cast<Behavior*>(pair->second);
|
return static_cast<Behavior*>(pair->second);
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior* Behavior::CreateBehavior(const uint32_t behaviorId)
|
Behavior* Behavior::CreateBehavior(const uint32_t behaviorId) {
|
||||||
{
|
|
||||||
auto* cached = GetBehavior(behaviorId);
|
auto* cached = GetBehavior(behaviorId);
|
||||||
|
|
||||||
if (cached != nullptr)
|
if (cached != nullptr) {
|
||||||
{
|
|
||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (behaviorId == 0)
|
if (behaviorId == 0) {
|
||||||
{
|
|
||||||
return new EmptyBehavior(0);
|
return new EmptyBehavior(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,8 +102,7 @@ Behavior* Behavior::CreateBehavior(const uint32_t behaviorId)
|
|||||||
|
|
||||||
Behavior* behavior = nullptr;
|
Behavior* behavior = nullptr;
|
||||||
|
|
||||||
switch (templateId)
|
switch (templateId) {
|
||||||
{
|
|
||||||
case BehaviorTemplates::BEHAVIOR_EMPTY: break;
|
case BehaviorTemplates::BEHAVIOR_EMPTY: break;
|
||||||
case BehaviorTemplates::BEHAVIOR_BASIC_ATTACK:
|
case BehaviorTemplates::BEHAVIOR_BASIC_ATTACK:
|
||||||
behavior = new BasicAttackBehavior(behaviorId);
|
behavior = new BasicAttackBehavior(behaviorId);
|
||||||
@ -273,8 +266,7 @@ Behavior* Behavior::CreateBehavior(const uint32_t behaviorId)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (behavior == nullptr)
|
if (behavior == nullptr) {
|
||||||
{
|
|
||||||
//Game::logger->Log("Behavior", "Failed to load unimplemented template id (%i)!", templateId);
|
//Game::logger->Log("Behavior", "Failed to load unimplemented template id (%i)!", templateId);
|
||||||
|
|
||||||
behavior = new EmptyBehavior(behaviorId);
|
behavior = new EmptyBehavior(behaviorId);
|
||||||
@ -305,19 +297,16 @@ BehaviorTemplates Behavior::GetBehaviorTemplate(const uint32_t behaviorId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For use with enemies, to display the correct damage animations on the players
|
// For use with enemies, to display the correct damage animations on the players
|
||||||
void Behavior::PlayFx(std::u16string type, const LWOOBJID target, const LWOOBJID secondary)
|
void Behavior::PlayFx(std::u16string type, const LWOOBJID target, const LWOOBJID secondary) {
|
||||||
{
|
|
||||||
auto* targetEntity = EntityManager::Instance()->GetEntity(target);
|
auto* targetEntity = EntityManager::Instance()->GetEntity(target);
|
||||||
|
|
||||||
if (targetEntity == nullptr)
|
if (targetEntity == nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto effectId = this->m_effectId;
|
const auto effectId = this->m_effectId;
|
||||||
|
|
||||||
if (effectId == 0)
|
if (effectId == 0) {
|
||||||
{
|
|
||||||
GameMessages::SendPlayFXEffect(targetEntity, -1, type, "", secondary, 1, 1, true);
|
GameMessages::SendPlayFXEffect(targetEntity, -1, type, "", secondary, 1, 1, true);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -327,23 +316,17 @@ void Behavior::PlayFx(std::u16string type, const LWOOBJID target, const LWOOBJID
|
|||||||
|
|
||||||
const auto typeString = GeneralUtils::UTF16ToWTF8(type);
|
const auto typeString = GeneralUtils::UTF16ToWTF8(type);
|
||||||
|
|
||||||
if (m_effectNames == nullptr)
|
if (m_effectNames == nullptr) {
|
||||||
{
|
|
||||||
m_effectNames = new std::unordered_map<std::string, std::string>();
|
m_effectNames = new std::unordered_map<std::string, std::string>();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
const auto pair = m_effectNames->find(typeString);
|
const auto pair = m_effectNames->find(typeString);
|
||||||
|
|
||||||
if (type.empty())
|
if (type.empty()) {
|
||||||
{
|
|
||||||
type = GeneralUtils::ASCIIToUTF16(*m_effectType);
|
type = GeneralUtils::ASCIIToUTF16(*m_effectType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pair != m_effectNames->end())
|
if (pair != m_effectNames->end()) {
|
||||||
{
|
if (renderComponent == nullptr) {
|
||||||
if (renderComponent == nullptr)
|
|
||||||
{
|
|
||||||
GameMessages::SendPlayFXEffect(targetEntity, effectId, type, pair->second, secondary, 1, 1, true);
|
GameMessages::SendPlayFXEffect(targetEntity, effectId, type, pair->second, secondary, 1, 1, true);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -375,15 +358,13 @@ void Behavior::PlayFx(std::u16string type, const LWOOBJID target, const LWOOBJID
|
|||||||
result = idQuery.execQuery();
|
result = idQuery.execQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.eof() || result.fieldIsNull(0))
|
if (result.eof() || result.fieldIsNull(0)) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto name = std::string(result.getStringField(0));
|
const auto name = std::string(result.getStringField(0));
|
||||||
|
|
||||||
if (type.empty())
|
if (type.empty()) {
|
||||||
{
|
|
||||||
const auto typeResult = result.getStringField(1);
|
const auto typeResult = result.getStringField(1);
|
||||||
|
|
||||||
type = GeneralUtils::ASCIIToUTF16(typeResult);
|
type = GeneralUtils::ASCIIToUTF16(typeResult);
|
||||||
@ -395,8 +376,7 @@ void Behavior::PlayFx(std::u16string type, const LWOOBJID target, const LWOOBJID
|
|||||||
|
|
||||||
m_effectNames->insert_or_assign(typeString, name);
|
m_effectNames->insert_or_assign(typeString, name);
|
||||||
|
|
||||||
if (renderComponent == nullptr)
|
if (renderComponent == nullptr) {
|
||||||
{
|
|
||||||
GameMessages::SendPlayFXEffect(targetEntity, effectId, type, name, secondary, 1, 1, true);
|
GameMessages::SendPlayFXEffect(targetEntity, effectId, type, name, secondary, 1, 1, true);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -405,8 +385,7 @@ void Behavior::PlayFx(std::u16string type, const LWOOBJID target, const LWOOBJID
|
|||||||
renderComponent->PlayEffect(effectId, type, name, secondary);
|
renderComponent->PlayEffect(effectId, type, name, secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior::Behavior(const uint32_t behaviorId)
|
Behavior::Behavior(const uint32_t behaviorId) {
|
||||||
{
|
|
||||||
auto behaviorTemplateTable = CDClientManager::Instance()->GetTable<CDBehaviorTemplateTable>("BehaviorTemplate");
|
auto behaviorTemplateTable = CDClientManager::Instance()->GetTable<CDBehaviorTemplateTable>("BehaviorTemplate");
|
||||||
|
|
||||||
CDBehaviorTemplate templateInDatabase{};
|
CDBehaviorTemplate templateInDatabase{};
|
||||||
@ -430,8 +409,7 @@ Behavior::Behavior(const uint32_t behaviorId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make sure we do not proceed if we are trying to load an invalid behavior
|
// Make sure we do not proceed if we are trying to load an invalid behavior
|
||||||
if (templateInDatabase.behaviorID == 0)
|
if (templateInDatabase.behaviorID == 0) {
|
||||||
{
|
|
||||||
Game::logger->Log("Behavior", "Failed to load behavior with id (%i)!", behaviorId);
|
Game::logger->Log("Behavior", "Failed to load behavior with id (%i)!", behaviorId);
|
||||||
|
|
||||||
this->m_effectId = 0;
|
this->m_effectId = 0;
|
||||||
@ -449,40 +427,34 @@ Behavior::Behavior(const uint32_t behaviorId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float Behavior::GetFloat(const std::string& name, const float defaultValue) const
|
float Behavior::GetFloat(const std::string& name, const float defaultValue) const {
|
||||||
{
|
|
||||||
// Get the behavior parameter entry and return its value.
|
// Get the behavior parameter entry and return its value.
|
||||||
if (!BehaviorParameterTable) BehaviorParameterTable = CDClientManager::Instance()->GetTable<CDBehaviorParameterTable>("BehaviorParameter");
|
if (!BehaviorParameterTable) BehaviorParameterTable = CDClientManager::Instance()->GetTable<CDBehaviorParameterTable>("BehaviorParameter");
|
||||||
return BehaviorParameterTable->GetEntry(this->m_behaviorId, name, defaultValue).value;
|
return BehaviorParameterTable->GetEntry(this->m_behaviorId, name, defaultValue).value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Behavior::GetBoolean(const std::string& name, const bool defaultValue) const
|
bool Behavior::GetBoolean(const std::string& name, const bool defaultValue) const {
|
||||||
{
|
|
||||||
return GetFloat(name, defaultValue) > 0;
|
return GetFloat(name, defaultValue) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t Behavior::GetInt(const std::string& name, const int defaultValue) const
|
int32_t Behavior::GetInt(const std::string& name, const int defaultValue) const {
|
||||||
{
|
|
||||||
return static_cast<int32_t>(GetFloat(name, defaultValue));
|
return static_cast<int32_t>(GetFloat(name, defaultValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Behavior* Behavior::GetAction(const std::string& name) const
|
Behavior* Behavior::GetAction(const std::string& name) const {
|
||||||
{
|
|
||||||
const auto id = GetInt(name);
|
const auto id = GetInt(name);
|
||||||
|
|
||||||
return CreateBehavior(id);
|
return CreateBehavior(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior* Behavior::GetAction(float value) const
|
Behavior* Behavior::GetAction(float value) const {
|
||||||
{
|
|
||||||
return CreateBehavior(static_cast<int32_t>(value));
|
return CreateBehavior(static_cast<int32_t>(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, float> Behavior::GetParameterNames() const
|
std::map<std::string, float> Behavior::GetParameterNames() const {
|
||||||
{
|
|
||||||
std::map<std::string, float> templatesInDatabase;
|
std::map<std::string, float> templatesInDatabase;
|
||||||
// Find behavior template by its behavior id.
|
// Find behavior template by its behavior id.
|
||||||
if (!BehaviorParameterTable) BehaviorParameterTable = CDClientManager::Instance()->GetTable<CDBehaviorParameterTable>("BehaviorParameter");
|
if (!BehaviorParameterTable) BehaviorParameterTable = CDClientManager::Instance()->GetTable<CDBehaviorParameterTable>("BehaviorParameter");
|
||||||
@ -493,40 +465,31 @@ std::map<std::string, float> Behavior::GetParameterNames() const
|
|||||||
return templatesInDatabase;
|
return templatesInDatabase;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Behavior::Load()
|
void Behavior::Load() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Behavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void Behavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Behavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void Behavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Behavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch)
|
void Behavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Behavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second)
|
void Behavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Behavior::End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second)
|
void Behavior::End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Behavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void Behavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Behavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void Behavior::SyncCalculation(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Behavior::~Behavior()
|
Behavior::~Behavior() {
|
||||||
{
|
|
||||||
delete m_effectNames;
|
delete m_effectNames;
|
||||||
delete m_effectType;
|
delete m_effectType;
|
||||||
delete m_effectHandle;
|
delete m_effectHandle;
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
#include "BehaviorBranchContext.h"
|
#include "BehaviorBranchContext.h"
|
||||||
|
|
||||||
|
|
||||||
BehaviorBranchContext::BehaviorBranchContext()
|
BehaviorBranchContext::BehaviorBranchContext() {
|
||||||
{
|
|
||||||
this->isProjectile = false;
|
this->isProjectile = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BehaviorBranchContext::BehaviorBranchContext(const LWOOBJID target, const float duration, const NiPoint3& referencePosition)
|
BehaviorBranchContext::BehaviorBranchContext(const LWOOBJID target, const float duration, const NiPoint3& referencePosition) {
|
||||||
{
|
|
||||||
this->target = target;
|
this->target = target;
|
||||||
this->duration = duration;
|
this->duration = duration;
|
||||||
this->referencePosition = referencePosition;
|
this->referencePosition = referencePosition;
|
||||||
|
@ -15,24 +15,19 @@
|
|||||||
#include "PhantomPhysicsComponent.h"
|
#include "PhantomPhysicsComponent.h"
|
||||||
#include "RebuildComponent.h"
|
#include "RebuildComponent.h"
|
||||||
|
|
||||||
BehaviorSyncEntry::BehaviorSyncEntry()
|
BehaviorSyncEntry::BehaviorSyncEntry() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BehaviorTimerEntry::BehaviorTimerEntry()
|
BehaviorTimerEntry::BehaviorTimerEntry() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BehaviorEndEntry::BehaviorEndEntry()
|
BehaviorEndEntry::BehaviorEndEntry() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t BehaviorContext::GetUniqueSkillId() const
|
uint32_t BehaviorContext::GetUniqueSkillId() const {
|
||||||
{
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(this->originator);
|
auto* entity = EntityManager::Instance()->GetEntity(this->originator);
|
||||||
|
|
||||||
if (entity == nullptr)
|
if (entity == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("BehaviorContext", "Invalid entity for (%llu)!", this->originator);
|
Game::logger->Log("BehaviorContext", "Invalid entity for (%llu)!", this->originator);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -40,8 +35,7 @@ uint32_t BehaviorContext::GetUniqueSkillId() const
|
|||||||
|
|
||||||
auto* component = entity->GetComponent<SkillComponent>();
|
auto* component = entity->GetComponent<SkillComponent>();
|
||||||
|
|
||||||
if (component == nullptr)
|
if (component == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("BehaviorContext", "No skill component attached to (%llu)!", this->originator);;
|
Game::logger->Log("BehaviorContext", "No skill component attached to (%llu)!", this->originator);;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -51,8 +45,7 @@ uint32_t BehaviorContext::GetUniqueSkillId() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BehaviorContext::RegisterSyncBehavior(const uint32_t syncId, Behavior* behavior, const BehaviorBranchContext& branchContext)
|
void BehaviorContext::RegisterSyncBehavior(const uint32_t syncId, Behavior* behavior, const BehaviorBranchContext& branchContext) {
|
||||||
{
|
|
||||||
auto entry = BehaviorSyncEntry();
|
auto entry = BehaviorSyncEntry();
|
||||||
|
|
||||||
entry.handle = syncId;
|
entry.handle = syncId;
|
||||||
@ -62,8 +55,7 @@ void BehaviorContext::RegisterSyncBehavior(const uint32_t syncId, Behavior* beha
|
|||||||
this->syncEntries.push_back(entry);
|
this->syncEntries.push_back(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BehaviorContext::RegisterTimerBehavior(Behavior* behavior, const BehaviorBranchContext& branchContext, const LWOOBJID second)
|
void BehaviorContext::RegisterTimerBehavior(Behavior* behavior, const BehaviorBranchContext& branchContext, const LWOOBJID second) {
|
||||||
{
|
|
||||||
BehaviorTimerEntry entry;
|
BehaviorTimerEntry entry;
|
||||||
|
|
||||||
entry.time = branchContext.duration;
|
entry.time = branchContext.duration;
|
||||||
@ -74,8 +66,7 @@ void BehaviorContext::RegisterTimerBehavior(Behavior* behavior, const BehaviorBr
|
|||||||
this->timerEntries.push_back(entry);
|
this->timerEntries.push_back(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BehaviorContext::RegisterEndBehavior(Behavior* behavior, const BehaviorBranchContext& branchContext, const LWOOBJID second)
|
void BehaviorContext::RegisterEndBehavior(Behavior* behavior, const BehaviorBranchContext& branchContext, const LWOOBJID second) {
|
||||||
{
|
|
||||||
BehaviorEndEntry entry;
|
BehaviorEndEntry entry;
|
||||||
|
|
||||||
entry.behavior = behavior;
|
entry.behavior = behavior;
|
||||||
@ -86,20 +77,16 @@ void BehaviorContext::RegisterEndBehavior(Behavior* behavior, const BehaviorBran
|
|||||||
this->endEntries.push_back(entry);
|
this->endEntries.push_back(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BehaviorContext::ScheduleUpdate(const LWOOBJID id)
|
void BehaviorContext::ScheduleUpdate(const LWOOBJID id) {
|
||||||
{
|
if (std::find(this->scheduledUpdates.begin(), this->scheduledUpdates.end(), id) != this->scheduledUpdates.end()) {
|
||||||
if (std::find(this->scheduledUpdates.begin(), this->scheduledUpdates.end(), id) != this->scheduledUpdates.end())
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->scheduledUpdates.push_back(id);
|
this->scheduledUpdates.push_back(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BehaviorContext::ExecuteUpdates()
|
void BehaviorContext::ExecuteUpdates() {
|
||||||
{
|
for (const auto& id : this->scheduledUpdates) {
|
||||||
for (const auto& id : this->scheduledUpdates)
|
|
||||||
{
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(id);
|
auto* entity = EntityManager::Instance()->GetEntity(id);
|
||||||
|
|
||||||
if (entity == nullptr) continue;
|
if (entity == nullptr) continue;
|
||||||
@ -110,20 +97,17 @@ void BehaviorContext::ExecuteUpdates()
|
|||||||
this->scheduledUpdates.clear();
|
this->scheduledUpdates.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream* bitStream)
|
void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream* bitStream) {
|
||||||
{
|
|
||||||
BehaviorSyncEntry entry;
|
BehaviorSyncEntry entry;
|
||||||
auto found = false;
|
auto found = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* There may be more than one of each handle
|
* There may be more than one of each handle
|
||||||
*/
|
*/
|
||||||
for (auto i = 0u; i < this->syncEntries.size(); ++i)
|
for (auto i = 0u; i < this->syncEntries.size(); ++i) {
|
||||||
{
|
|
||||||
const auto syncEntry = this->syncEntries.at(i);
|
const auto syncEntry = this->syncEntries.at(i);
|
||||||
|
|
||||||
if (syncEntry.handle == syncId)
|
if (syncEntry.handle == syncId) {
|
||||||
{
|
|
||||||
found = true;
|
found = true;
|
||||||
entry = syncEntry;
|
entry = syncEntry;
|
||||||
|
|
||||||
@ -133,8 +117,7 @@ void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream* bit
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found) {
|
||||||
{
|
|
||||||
Game::logger->Log("BehaviorContext", "Failed to find behavior sync entry with sync id (%i)!", syncId);
|
Game::logger->Log("BehaviorContext", "Failed to find behavior sync entry with sync id (%i)!", syncId);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -143,8 +126,7 @@ void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream* bit
|
|||||||
auto* behavior = entry.behavior;
|
auto* behavior = entry.behavior;
|
||||||
const auto branch = entry.branchContext;
|
const auto branch = entry.branchContext;
|
||||||
|
|
||||||
if (behavior == nullptr)
|
if (behavior == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("BehaviorContext", "Invalid behavior for sync id (%i)!", syncId);
|
Game::logger->Log("BehaviorContext", "Invalid behavior for sync id (%i)!", syncId);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -154,21 +136,17 @@ void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream* bit
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BehaviorContext::Update(const float deltaTime)
|
void BehaviorContext::Update(const float deltaTime) {
|
||||||
{
|
for (auto i = 0u; i < this->timerEntries.size(); ++i) {
|
||||||
for (auto i = 0u; i < this->timerEntries.size(); ++i)
|
|
||||||
{
|
|
||||||
auto entry = this->timerEntries.at(i);
|
auto entry = this->timerEntries.at(i);
|
||||||
|
|
||||||
if (entry.time > 0)
|
if (entry.time > 0) {
|
||||||
{
|
|
||||||
entry.time -= deltaTime;
|
entry.time -= deltaTime;
|
||||||
|
|
||||||
this->timerEntries[i] = entry;
|
this->timerEntries[i] = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.time > 0)
|
if (entry.time > 0) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,10 +155,8 @@ void BehaviorContext::Update(const float deltaTime)
|
|||||||
|
|
||||||
std::vector<BehaviorTimerEntry> valid;
|
std::vector<BehaviorTimerEntry> valid;
|
||||||
|
|
||||||
for (const auto& entry : this->timerEntries)
|
for (const auto& entry : this->timerEntries) {
|
||||||
{
|
if (entry.time <= 0) {
|
||||||
if (entry.time <= 0)
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,8 +167,7 @@ void BehaviorContext::Update(const float deltaTime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BehaviorContext::SyncCalculation(const uint32_t syncId, const float time, Behavior* behavior, const BehaviorBranchContext& branch, const bool ignoreInterrupts)
|
void BehaviorContext::SyncCalculation(const uint32_t syncId, const float time, Behavior* behavior, const BehaviorBranchContext& branch, const bool ignoreInterrupts) {
|
||||||
{
|
|
||||||
BehaviorSyncEntry entry;
|
BehaviorSyncEntry entry;
|
||||||
|
|
||||||
entry.behavior = behavior;
|
entry.behavior = behavior;
|
||||||
@ -204,14 +179,11 @@ void BehaviorContext::SyncCalculation(const uint32_t syncId, const float time, B
|
|||||||
this->syncEntries.push_back(entry);
|
this->syncEntries.push_back(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BehaviorContext::InvokeEnd(const uint32_t id)
|
void BehaviorContext::InvokeEnd(const uint32_t id) {
|
||||||
{
|
|
||||||
std::vector<BehaviorEndEntry> entries;
|
std::vector<BehaviorEndEntry> entries;
|
||||||
|
|
||||||
for (const auto& entry : this->endEntries)
|
for (const auto& entry : this->endEntries) {
|
||||||
{
|
if (entry.start == id) {
|
||||||
if (entry.start == id)
|
|
||||||
{
|
|
||||||
entry.behavior->End(this, entry.branchContext, entry.second);
|
entry.behavior->End(this, entry.branchContext, entry.second);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@ -223,23 +195,19 @@ void BehaviorContext::InvokeEnd(const uint32_t id)
|
|||||||
this->endEntries = entries;
|
this->endEntries = entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BehaviorContext::CalculateUpdate(const float deltaTime)
|
bool BehaviorContext::CalculateUpdate(const float deltaTime) {
|
||||||
{
|
|
||||||
auto any = false;
|
auto any = false;
|
||||||
|
|
||||||
for (auto i = 0u; i < this->syncEntries.size(); ++i)
|
for (auto i = 0u; i < this->syncEntries.size(); ++i) {
|
||||||
{
|
|
||||||
auto entry = this->syncEntries.at(i);
|
auto entry = this->syncEntries.at(i);
|
||||||
|
|
||||||
if (entry.time > 0)
|
if (entry.time > 0) {
|
||||||
{
|
|
||||||
entry.time -= deltaTime;
|
entry.time -= deltaTime;
|
||||||
|
|
||||||
this->syncEntries[i] = entry;
|
this->syncEntries[i] = entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.time > 0)
|
if (entry.time > 0) {
|
||||||
{
|
|
||||||
any = true;
|
any = true;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@ -257,8 +225,7 @@ bool BehaviorContext::CalculateUpdate(const float deltaTime)
|
|||||||
// Calculate sync
|
// Calculate sync
|
||||||
entry.behavior->SyncCalculation(this, bitStream, entry.branchContext);
|
entry.behavior->SyncCalculation(this, bitStream, entry.branchContext);
|
||||||
|
|
||||||
if (!clientInitalized)
|
if (!clientInitalized) {
|
||||||
{
|
|
||||||
echo.sBitStream.assign((char*)bitStream->GetData(), bitStream->GetNumberOfBytesUsed());
|
echo.sBitStream.assign((char*)bitStream->GetData(), bitStream->GetNumberOfBytesUsed());
|
||||||
|
|
||||||
// Write message
|
// Write message
|
||||||
@ -278,10 +245,8 @@ bool BehaviorContext::CalculateUpdate(const float deltaTime)
|
|||||||
|
|
||||||
std::vector<BehaviorSyncEntry> valid;
|
std::vector<BehaviorSyncEntry> valid;
|
||||||
|
|
||||||
for (const auto& entry : this->syncEntries)
|
for (const auto& entry : this->syncEntries) {
|
||||||
{
|
if (entry.time <= 0) {
|
||||||
if (entry.time <= 0)
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,12 +258,10 @@ bool BehaviorContext::CalculateUpdate(const float deltaTime)
|
|||||||
return any;
|
return any;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BehaviorContext::Interrupt()
|
void BehaviorContext::Interrupt() {
|
||||||
{
|
|
||||||
std::vector<BehaviorSyncEntry> keptSync{};
|
std::vector<BehaviorSyncEntry> keptSync{};
|
||||||
|
|
||||||
for (const auto& entry : this->syncEntries)
|
for (const auto& entry : this->syncEntries) {
|
||||||
{
|
|
||||||
if (!entry.ignoreInterrupts) continue;
|
if (!entry.ignoreInterrupts) continue;
|
||||||
|
|
||||||
keptSync.push_back(entry);
|
keptSync.push_back(entry);
|
||||||
@ -307,15 +270,12 @@ void BehaviorContext::Interrupt()
|
|||||||
this->syncEntries = keptSync;
|
this->syncEntries = keptSync;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BehaviorContext::Reset()
|
void BehaviorContext::Reset() {
|
||||||
{
|
for (const auto& entry : this->timerEntries) {
|
||||||
for (const auto& entry : this->timerEntries)
|
|
||||||
{
|
|
||||||
entry.behavior->Timer(this, entry.branchContext, entry.second);
|
entry.behavior->Timer(this, entry.branchContext, entry.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& entry : this->endEntries)
|
for (const auto& entry : this->endEntries) {
|
||||||
{
|
|
||||||
entry.behavior->End(this, entry.branchContext, entry.second);
|
entry.behavior->End(this, entry.branchContext, entry.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,27 +285,22 @@ void BehaviorContext::Reset()
|
|||||||
this->scheduledUpdates.clear();
|
this->scheduledUpdates.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<LWOOBJID> BehaviorContext::GetValidTargets(int32_t ignoreFaction, int32_t includeFaction, bool targetSelf, bool targetEnemy, bool targetFriend) const
|
std::vector<LWOOBJID> BehaviorContext::GetValidTargets(int32_t ignoreFaction, int32_t includeFaction, bool targetSelf, bool targetEnemy, bool targetFriend) const {
|
||||||
{
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(this->caster);
|
auto* entity = EntityManager::Instance()->GetEntity(this->caster);
|
||||||
|
|
||||||
std::vector<LWOOBJID> targets;
|
std::vector<LWOOBJID> targets;
|
||||||
|
|
||||||
if (entity == nullptr)
|
if (entity == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("BehaviorContext", "Invalid entity for (%llu)!", this->originator);
|
Game::logger->Log("BehaviorContext", "Invalid entity for (%llu)!", this->originator);
|
||||||
|
|
||||||
return targets;
|
return targets;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ignoreFaction && !includeFaction)
|
if (!ignoreFaction && !includeFaction) {
|
||||||
{
|
for (auto entry : entity->GetTargetsInPhantom()) {
|
||||||
for (auto entry : entity->GetTargetsInPhantom())
|
|
||||||
{
|
|
||||||
auto* instance = EntityManager::Instance()->GetEntity(entry);
|
auto* instance = EntityManager::Instance()->GetEntity(entry);
|
||||||
|
|
||||||
if (instance == nullptr)
|
if (instance == nullptr) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,21 +308,17 @@ std::vector<LWOOBJID> BehaviorContext::GetValidTargets(int32_t ignoreFaction, in
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ignoreFaction || includeFaction || (!entity->HasComponent(COMPONENT_TYPE_PHANTOM_PHYSICS) && targets.empty()))
|
if (ignoreFaction || includeFaction || (!entity->HasComponent(COMPONENT_TYPE_PHANTOM_PHYSICS) && targets.empty())) {
|
||||||
{
|
|
||||||
DestroyableComponent* destroyableComponent;
|
DestroyableComponent* destroyableComponent;
|
||||||
if (!entity->TryGetComponent(COMPONENT_TYPE_DESTROYABLE, destroyableComponent))
|
if (!entity->TryGetComponent(COMPONENT_TYPE_DESTROYABLE, destroyableComponent)) {
|
||||||
{
|
|
||||||
return targets;
|
return targets;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto entities = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_CONTROLLABLE_PHYSICS);
|
auto entities = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_CONTROLLABLE_PHYSICS);
|
||||||
for (auto* candidate : entities)
|
for (auto* candidate : entities) {
|
||||||
{
|
|
||||||
const auto id = candidate->GetObjectID();
|
const auto id = candidate->GetObjectID();
|
||||||
|
|
||||||
if ((id != entity->GetObjectID() || targetSelf) && destroyableComponent->CheckValidity(id, ignoreFaction || includeFaction, targetEnemy, targetFriend))
|
if ((id != entity->GetObjectID() || targetSelf) && destroyableComponent->CheckValidity(id, ignoreFaction || includeFaction, targetEnemy, targetFriend)) {
|
||||||
{
|
|
||||||
targets.push_back(id);
|
targets.push_back(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -377,23 +328,18 @@ std::vector<LWOOBJID> BehaviorContext::GetValidTargets(int32_t ignoreFaction, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BehaviorContext::BehaviorContext(const LWOOBJID originator, const bool calculation)
|
BehaviorContext::BehaviorContext(const LWOOBJID originator, const bool calculation) {
|
||||||
{
|
|
||||||
this->originator = originator;
|
this->originator = originator;
|
||||||
this->syncEntries = {};
|
this->syncEntries = {};
|
||||||
this->timerEntries = {};
|
this->timerEntries = {};
|
||||||
|
|
||||||
if (calculation)
|
if (calculation) {
|
||||||
{
|
|
||||||
this->skillUId = GetUniqueSkillId();
|
this->skillUId = GetUniqueSkillId();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
this->skillUId = 0;
|
this->skillUId = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BehaviorContext::~BehaviorContext()
|
BehaviorContext::~BehaviorContext() {
|
||||||
{
|
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,12 @@
|
|||||||
#include "dLogger.h"
|
#include "dLogger.h"
|
||||||
#include "DestroyableComponent.h"
|
#include "DestroyableComponent.h"
|
||||||
|
|
||||||
void BlockBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void BlockBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
const auto target = context->originator;
|
const auto target = context->originator;
|
||||||
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(target);
|
auto* entity = EntityManager::Instance()->GetEntity(target);
|
||||||
|
|
||||||
if (entity == nullptr)
|
if (entity == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target);
|
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -22,36 +20,29 @@ void BlockBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStrea
|
|||||||
|
|
||||||
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
auto* destroyableComponent = entity->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
if (destroyableComponent == nullptr)
|
if (destroyableComponent == nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyableComponent->SetAttacksToBlock(this->m_numAttacksCanBlock);
|
destroyableComponent->SetAttacksToBlock(this->m_numAttacksCanBlock);
|
||||||
|
|
||||||
if (branch.start > 0)
|
if (branch.start > 0) {
|
||||||
{
|
|
||||||
context->RegisterEndBehavior(this, branch);
|
context->RegisterEndBehavior(this, branch);
|
||||||
}
|
} else if (branch.duration > 0) {
|
||||||
else if (branch.duration > 0)
|
|
||||||
{
|
|
||||||
context->RegisterTimerBehavior(this, branch);
|
context->RegisterTimerBehavior(this, branch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void BlockBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
Handle(context, bitStream, branch);
|
Handle(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch)
|
void BlockBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
const auto target = context->originator;
|
const auto target = context->originator;
|
||||||
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(target);
|
auto* entity = EntityManager::Instance()->GetEntity(target);
|
||||||
|
|
||||||
if (entity == nullptr)
|
if (entity == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target);
|
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -61,25 +52,21 @@ void BlockBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branc
|
|||||||
|
|
||||||
destroyableComponent->SetAttacksToBlock(this->m_numAttacksCanBlock);
|
destroyableComponent->SetAttacksToBlock(this->m_numAttacksCanBlock);
|
||||||
|
|
||||||
if (destroyableComponent == nullptr)
|
if (destroyableComponent == nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyableComponent->SetAttacksToBlock(0);
|
destroyableComponent->SetAttacksToBlock(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second)
|
void BlockBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
||||||
{
|
|
||||||
UnCast(context, branch);
|
UnCast(context, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockBehavior::End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second)
|
void BlockBehavior::End(BehaviorContext* context, BehaviorBranchContext branch, LWOOBJID second) {
|
||||||
{
|
|
||||||
UnCast(context, branch);
|
UnCast(context, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockBehavior::Load()
|
void BlockBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_numAttacksCanBlock = GetInt("num_attacks_can_block");
|
this->m_numAttacksCanBlock = GetInt("num_attacks_can_block");
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit BlockBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit BlockBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -7,14 +7,12 @@
|
|||||||
#include "dLogger.h"
|
#include "dLogger.h"
|
||||||
#include "DestroyableComponent.h"
|
#include "DestroyableComponent.h"
|
||||||
|
|
||||||
void BuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void BuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
const auto target = branch.target != LWOOBJID_EMPTY ? branch.target : context->originator;
|
const auto target = branch.target != LWOOBJID_EMPTY ? branch.target : context->originator;
|
||||||
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(target);
|
auto* entity = EntityManager::Instance()->GetEntity(target);
|
||||||
|
|
||||||
if (entity == nullptr)
|
if (entity == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("BuffBehavior", "Invalid target (%llu)!", target);
|
Game::logger->Log("BuffBehavior", "Invalid target (%llu)!", target);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -22,8 +20,7 @@ void BuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream
|
|||||||
|
|
||||||
auto* component = entity->GetComponent<DestroyableComponent>();
|
auto* component = entity->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
if (component == nullptr)
|
if (component == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("BuffBehavior", "Invalid target, no destroyable component (%llu)!", target);
|
Game::logger->Log("BuffBehavior", "Invalid target, no destroyable component (%llu)!", target);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -35,27 +32,21 @@ void BuffBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream
|
|||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(entity);
|
EntityManager::Instance()->SerializeEntity(entity);
|
||||||
|
|
||||||
if (!context->unmanaged)
|
if (!context->unmanaged) {
|
||||||
{
|
if (branch.duration > 0) {
|
||||||
if (branch.duration > 0)
|
|
||||||
{
|
|
||||||
context->RegisterTimerBehavior(this, branch);
|
context->RegisterTimerBehavior(this, branch);
|
||||||
}
|
} else if (branch.start > 0) {
|
||||||
else if (branch.start > 0)
|
|
||||||
{
|
|
||||||
context->RegisterEndBehavior(this, branch);
|
context->RegisterEndBehavior(this, branch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch)
|
void BuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
const auto target = branch.target != LWOOBJID_EMPTY ? branch.target : context->originator;
|
const auto target = branch.target != LWOOBJID_EMPTY ? branch.target : context->originator;
|
||||||
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(target);
|
auto* entity = EntityManager::Instance()->GetEntity(target);
|
||||||
|
|
||||||
if (entity == nullptr)
|
if (entity == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("BuffBehavior", "Invalid target (%llu)!", target);
|
Game::logger->Log("BuffBehavior", "Invalid target (%llu)!", target);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -63,8 +54,7 @@ void BuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch
|
|||||||
|
|
||||||
auto* component = entity->GetComponent<DestroyableComponent>();
|
auto* component = entity->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
if (component == nullptr)
|
if (component == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("BuffBehavior", "Invalid target, no destroyable component (%llu)!", target);
|
Game::logger->Log("BuffBehavior", "Invalid target, no destroyable component (%llu)!", target);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -77,18 +67,15 @@ void BuffBehavior::UnCast(BehaviorContext* context, BehaviorBranchContext branch
|
|||||||
EntityManager::Instance()->SerializeEntity(entity);
|
EntityManager::Instance()->SerializeEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuffBehavior::Timer(BehaviorContext* context, const BehaviorBranchContext branch, LWOOBJID second)
|
void BuffBehavior::Timer(BehaviorContext* context, const BehaviorBranchContext branch, LWOOBJID second) {
|
||||||
{
|
|
||||||
UnCast(context, branch);
|
UnCast(context, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuffBehavior::End(BehaviorContext* context, const BehaviorBranchContext branch, LWOOBJID second)
|
void BuffBehavior::End(BehaviorContext* context, const BehaviorBranchContext branch, LWOOBJID second) {
|
||||||
{
|
|
||||||
UnCast(context, branch);
|
UnCast(context, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuffBehavior::Load()
|
void BuffBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_health = GetInt("life");
|
this->m_health = GetInt("life");
|
||||||
|
|
||||||
this->m_armor = GetInt("armor");
|
this->m_armor = GetInt("armor");
|
||||||
|
@ -13,8 +13,7 @@ public:
|
|||||||
/*
|
/*
|
||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
explicit BuffBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit BuffBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -8,14 +8,12 @@
|
|||||||
#include "dLogger.h"
|
#include "dLogger.h"
|
||||||
#include "PossessableComponent.h"
|
#include "PossessableComponent.h"
|
||||||
|
|
||||||
void CarBoostBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void CarBoostBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
GameMessages::SendVehicleAddPassiveBoostAction(branch.target, UNASSIGNED_SYSTEM_ADDRESS);
|
GameMessages::SendVehicleAddPassiveBoostAction(branch.target, UNASSIGNED_SYSTEM_ADDRESS);
|
||||||
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(context->originator);
|
auto* entity = EntityManager::Instance()->GetEntity(context->originator);
|
||||||
|
|
||||||
if (entity == nullptr)
|
if (entity == nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,8 +41,7 @@ void CarBoostBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CarBoostBehavior::Load()
|
void CarBoostBehavior::Load() {
|
||||||
{
|
|
||||||
m_Action = GetAction("action");
|
m_Action = GetAction("action");
|
||||||
|
|
||||||
m_Time = GetFloat("time");
|
m_Time = GetFloat("time");
|
||||||
|
@ -14,8 +14,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit CarBoostBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit CarBoostBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -3,35 +3,29 @@
|
|||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "dLogger.h"
|
#include "dLogger.h"
|
||||||
|
|
||||||
void ChainBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch)
|
void ChainBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
uint32_t chain_index;
|
uint32_t chain_index;
|
||||||
|
|
||||||
bitStream->Read(chain_index);
|
bitStream->Read(chain_index);
|
||||||
|
|
||||||
chain_index--;
|
chain_index--;
|
||||||
|
|
||||||
if (chain_index < this->m_behaviors.size())
|
if (chain_index < this->m_behaviors.size()) {
|
||||||
{
|
|
||||||
this->m_behaviors.at(chain_index)->Handle(context, bitStream, branch);
|
this->m_behaviors.at(chain_index)->Handle(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChainBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch)
|
void ChainBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
bitStream->Write(1);
|
bitStream->Write(1);
|
||||||
|
|
||||||
this->m_behaviors.at(0)->Calculate(context, bitStream, branch);
|
this->m_behaviors.at(0)->Calculate(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChainBehavior::Load()
|
void ChainBehavior::Load() {
|
||||||
{
|
|
||||||
const auto parameters = GetParameterNames();
|
const auto parameters = GetParameterNames();
|
||||||
|
|
||||||
for (const auto& parameter : parameters)
|
for (const auto& parameter : parameters) {
|
||||||
{
|
if (parameter.first.rfind("behavior", 0) == 0) {
|
||||||
if (parameter.first.rfind("behavior", 0) == 0)
|
|
||||||
{
|
|
||||||
auto* action = GetAction(parameter.second);
|
auto* action = GetAction(parameter.second);
|
||||||
|
|
||||||
this->m_behaviors.push_back(action);
|
this->m_behaviors.push_back(action);
|
||||||
|
@ -13,8 +13,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit ChainBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit ChainBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -4,12 +4,10 @@
|
|||||||
#include "EntityManager.h"
|
#include "EntityManager.h"
|
||||||
#include "BaseCombatAIComponent.h"
|
#include "BaseCombatAIComponent.h"
|
||||||
|
|
||||||
void ChangeOrientationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void ChangeOrientationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeOrientationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void ChangeOrientationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
if (!m_ToTarget) return; // TODO: Add the other arguments to this behavior
|
if (!m_ToTarget) return; // TODO: Add the other arguments to this behavior
|
||||||
|
|
||||||
auto* self = EntityManager::Instance()->GetEntity(context->originator);
|
auto* self = EntityManager::Instance()->GetEntity(context->originator);
|
||||||
@ -20,8 +18,7 @@ void ChangeOrientationBehavior::Calculate(BehaviorContext* context, RakNet::BitS
|
|||||||
const auto source = self->GetPosition();
|
const auto source = self->GetPosition();
|
||||||
const auto destination = self->GetPosition();
|
const auto destination = self->GetPosition();
|
||||||
|
|
||||||
if (m_OrientCaster)
|
if (m_OrientCaster) {
|
||||||
{
|
|
||||||
auto* baseCombatAIComponent = self->GetComponent<BaseCombatAIComponent>();
|
auto* baseCombatAIComponent = self->GetComponent<BaseCombatAIComponent>();
|
||||||
|
|
||||||
/*if (baseCombatAIComponent != nullptr)
|
/*if (baseCombatAIComponent != nullptr)
|
||||||
@ -34,17 +31,14 @@ void ChangeOrientationBehavior::Calculate(BehaviorContext* context, RakNet::BitS
|
|||||||
}
|
}
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(self);
|
EntityManager::Instance()->SerializeEntity(self);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
other->SetRotation(NiQuaternion::LookAt(destination, source));
|
other->SetRotation(NiQuaternion::LookAt(destination, source));
|
||||||
|
|
||||||
EntityManager::Instance()->SerializeEntity(other);
|
EntityManager::Instance()->SerializeEntity(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeOrientationBehavior::Load()
|
void ChangeOrientationBehavior::Load() {
|
||||||
{
|
|
||||||
m_OrientCaster = GetBoolean("orient_caster");
|
m_OrientCaster = GetBoolean("orient_caster");
|
||||||
m_ToTarget = GetBoolean("to_target");
|
m_ToTarget = GetBoolean("to_target");
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit ChangeOrientationBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit ChangeOrientationBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
#include "BehaviorContext.h"
|
#include "BehaviorContext.h"
|
||||||
#include "dLogger.h"
|
#include "dLogger.h"
|
||||||
|
|
||||||
void ChargeUpBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch)
|
void ChargeUpBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
uint32_t handle;
|
uint32_t handle;
|
||||||
|
|
||||||
bitStream->Read(handle);
|
bitStream->Read(handle);
|
||||||
@ -12,16 +11,13 @@ void ChargeUpBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt
|
|||||||
context->RegisterSyncBehavior(handle, this, branch);
|
context->RegisterSyncBehavior(handle, this, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargeUpBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void ChargeUpBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargeUpBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch)
|
void ChargeUpBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
this->m_action->Handle(context, bitStream, branch);
|
this->m_action->Handle(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChargeUpBehavior::Load()
|
void ChargeUpBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_action = GetAction("action");
|
this->m_action = GetAction("action");
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit ChargeUpBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit ChargeUpBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -3,22 +3,19 @@
|
|||||||
#include "BehaviorContext.h"
|
#include "BehaviorContext.h"
|
||||||
|
|
||||||
|
|
||||||
void ClearTargetBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void ClearTargetBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
branch.target = LWOOBJID_EMPTY;
|
branch.target = LWOOBJID_EMPTY;
|
||||||
|
|
||||||
this->m_action->Handle(context, bitStream, branch);
|
this->m_action->Handle(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearTargetBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void ClearTargetBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
branch.target = LWOOBJID_EMPTY;
|
branch.target = LWOOBJID_EMPTY;
|
||||||
|
|
||||||
this->m_action->Calculate(context, bitStream, branch);
|
this->m_action->Calculate(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearTargetBehavior::Load()
|
void ClearTargetBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_action = GetAction("action");
|
this->m_action = GetAction("action");
|
||||||
|
|
||||||
this->m_clearIfCaster = GetBoolean("clear_if_caster");
|
this->m_clearIfCaster = GetBoolean("clear_if_caster");
|
||||||
|
@ -11,8 +11,7 @@ public:
|
|||||||
/*
|
/*
|
||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
explicit ClearTargetBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit ClearTargetBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -7,12 +7,10 @@
|
|||||||
#include "dLogger.h"
|
#include "dLogger.h"
|
||||||
#include "DestroyableComponent.h"
|
#include "DestroyableComponent.h"
|
||||||
|
|
||||||
void DamageAbsorptionBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch)
|
void DamageAbsorptionBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
if (target == nullptr)
|
if (target == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target);
|
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -20,8 +18,7 @@ void DamageAbsorptionBehavior::Handle(BehaviorContext* context, RakNet::BitStrea
|
|||||||
|
|
||||||
auto* destroyable = target->GetComponent<DestroyableComponent>();
|
auto* destroyable = target->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
if (destroyable == nullptr)
|
if (destroyable == nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,17 +29,14 @@ void DamageAbsorptionBehavior::Handle(BehaviorContext* context, RakNet::BitStrea
|
|||||||
context->RegisterTimerBehavior(this, branch, target->GetObjectID());
|
context->RegisterTimerBehavior(this, branch, target->GetObjectID());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DamageAbsorptionBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void DamageAbsorptionBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
Handle(context, bitStream, branch);
|
Handle(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DamageAbsorptionBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, const LWOOBJID second)
|
void DamageAbsorptionBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, const LWOOBJID second) {
|
||||||
{
|
|
||||||
auto* target = EntityManager::Instance()->GetEntity(second);
|
auto* target = EntityManager::Instance()->GetEntity(second);
|
||||||
|
|
||||||
if (target == nullptr)
|
if (target == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", second);
|
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", second);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -50,8 +44,7 @@ void DamageAbsorptionBehavior::Timer(BehaviorContext* context, BehaviorBranchCon
|
|||||||
|
|
||||||
auto* destroyable = target->GetComponent<DestroyableComponent>();
|
auto* destroyable = target->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
if (destroyable == nullptr)
|
if (destroyable == nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +55,6 @@ void DamageAbsorptionBehavior::Timer(BehaviorContext* context, BehaviorBranchCon
|
|||||||
destroyable->SetDamageToAbsorb(present - toRemove);
|
destroyable->SetDamageToAbsorb(present - toRemove);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DamageAbsorptionBehavior::Load()
|
void DamageAbsorptionBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_absorbAmount = GetInt("absorb_amount");
|
this->m_absorbAmount = GetInt("absorb_amount");
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit DamageAbsorptionBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit DamageAbsorptionBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -7,12 +7,10 @@
|
|||||||
#include "dLogger.h"
|
#include "dLogger.h"
|
||||||
#include "DestroyableComponent.h"
|
#include "DestroyableComponent.h"
|
||||||
|
|
||||||
void DamageReductionBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch)
|
void DamageReductionBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
if (target == nullptr)
|
if (target == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("DamageReductionBehavior", "Failed to find target (%llu)!", branch.target);
|
Game::logger->Log("DamageReductionBehavior", "Failed to find target (%llu)!", branch.target);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -20,8 +18,7 @@ void DamageReductionBehavior::Handle(BehaviorContext* context, RakNet::BitStream
|
|||||||
|
|
||||||
auto* destroyable = target->GetComponent<DestroyableComponent>();
|
auto* destroyable = target->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
if (destroyable == nullptr)
|
if (destroyable == nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,17 +27,14 @@ void DamageReductionBehavior::Handle(BehaviorContext* context, RakNet::BitStream
|
|||||||
context->RegisterTimerBehavior(this, branch, target->GetObjectID());
|
context->RegisterTimerBehavior(this, branch, target->GetObjectID());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DamageReductionBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void DamageReductionBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
Handle(context, bitStream, branch);
|
Handle(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DamageReductionBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, const LWOOBJID second)
|
void DamageReductionBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, const LWOOBJID second) {
|
||||||
{
|
|
||||||
auto* target = EntityManager::Instance()->GetEntity(second);
|
auto* target = EntityManager::Instance()->GetEntity(second);
|
||||||
|
|
||||||
if (target == nullptr)
|
if (target == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("DamageReductionBehavior", "Failed to find target (%llu)!", second);
|
Game::logger->Log("DamageReductionBehavior", "Failed to find target (%llu)!", second);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -48,15 +42,13 @@ void DamageReductionBehavior::Timer(BehaviorContext* context, BehaviorBranchCont
|
|||||||
|
|
||||||
auto* destroyable = target->GetComponent<DestroyableComponent>();
|
auto* destroyable = target->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
if (destroyable == nullptr)
|
if (destroyable == nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyable->SetDamageReduction(0);
|
destroyable->SetDamageReduction(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DamageReductionBehavior::Load()
|
void DamageReductionBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_ReductionAmount = GetInt("reduction_amount");
|
this->m_ReductionAmount = GetInt("reduction_amount");
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit DamageReductionBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit DamageReductionBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -2,22 +2,19 @@
|
|||||||
#include "BehaviorBranchContext.h"
|
#include "BehaviorBranchContext.h"
|
||||||
#include "BehaviorContext.h"
|
#include "BehaviorContext.h"
|
||||||
|
|
||||||
void DurationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void DurationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
branch.duration = this->m_duration;
|
branch.duration = this->m_duration;
|
||||||
|
|
||||||
this->m_action->Handle(context, bitStream, branch);
|
this->m_action->Handle(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DurationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void DurationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
branch.duration = this->m_duration;
|
branch.duration = this->m_duration;
|
||||||
|
|
||||||
this->m_action->Calculate(context, bitStream, branch);
|
this->m_action->Calculate(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DurationBehavior::Load()
|
void DurationBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_duration = GetFloat("duration");
|
this->m_duration = GetFloat("duration");
|
||||||
|
|
||||||
this->m_action = GetAction("action");
|
this->m_action = GetAction("action");
|
||||||
|
@ -8,8 +8,7 @@ public:
|
|||||||
|
|
||||||
Behavior* m_action;
|
Behavior* m_action;
|
||||||
|
|
||||||
explicit DurationBehavior(const uint32_t behavior_id) : Behavior(behavior_id)
|
explicit DurationBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
class EmptyBehavior final : public Behavior
|
class EmptyBehavior final : public Behavior
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit EmptyBehavior(const uint32_t behavior_id) : Behavior(behavior_id)
|
explicit EmptyBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -3,17 +3,14 @@
|
|||||||
#include "BehaviorContext.h"
|
#include "BehaviorContext.h"
|
||||||
#include "BehaviorBranchContext.h"
|
#include "BehaviorBranchContext.h"
|
||||||
|
|
||||||
void EndBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void EndBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
context->InvokeEnd(this->m_startBehavior);
|
context->InvokeEnd(this->m_startBehavior);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void EndBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
context->InvokeEnd(this->m_startBehavior);
|
context->InvokeEnd(this->m_startBehavior);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EndBehavior::Load()
|
void EndBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_startBehavior = GetInt("start_action");
|
this->m_startBehavior = GetInt("start_action");
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit EndBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit EndBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -14,8 +14,7 @@ void ForceMovementBehavior::Handle(BehaviorContext* context, RakNet::BitStream*
|
|||||||
context->RegisterSyncBehavior(handle, this, branch);
|
context->RegisterSyncBehavior(handle, this, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForceMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void ForceMovementBehavior::Sync(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
uint32_t next;
|
uint32_t next;
|
||||||
bitStream->Read(next);
|
bitStream->Read(next);
|
||||||
|
|
||||||
@ -51,8 +50,7 @@ void ForceMovementBehavior::Calculate(BehaviorContext* context, RakNet::BitStrea
|
|||||||
context->SyncCalculation(skillHandle, this->m_Duration, this, branch);
|
context->SyncCalculation(skillHandle, this->m_Duration, this, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ForceMovementBehavior::Load()
|
void ForceMovementBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_hitAction = GetAction("hit_action");
|
this->m_hitAction = GetAction("hit_action");
|
||||||
this->m_hitEnemyAction = GetAction("hit_action_enemy");
|
this->m_hitEnemyAction = GetAction("hit_action_enemy");
|
||||||
this->m_hitFactionAction = GetAction("hit_action_faction");
|
this->m_hitFactionAction = GetAction("hit_action_faction");
|
||||||
|
@ -19,8 +19,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit ForceMovementBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit ForceMovementBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -6,12 +6,10 @@
|
|||||||
#include "DestroyableComponent.h"
|
#include "DestroyableComponent.h"
|
||||||
|
|
||||||
|
|
||||||
void HealBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch)
|
void HealBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
if (entity == nullptr)
|
if (entity == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("HealBehavior", "Failed to find entity for (%llu)!", branch.target);
|
Game::logger->Log("HealBehavior", "Failed to find entity for (%llu)!", branch.target);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -19,8 +17,7 @@ void HealBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_strea
|
|||||||
|
|
||||||
auto* destroyable = static_cast<DestroyableComponent*>(entity->GetComponent(COMPONENT_TYPE_DESTROYABLE));
|
auto* destroyable = static_cast<DestroyableComponent*>(entity->GetComponent(COMPONENT_TYPE_DESTROYABLE));
|
||||||
|
|
||||||
if (destroyable == nullptr)
|
if (destroyable == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("HealBehavior", "Failed to find destroyable component for %(llu)!", branch.target);
|
Game::logger->Log("HealBehavior", "Failed to find destroyable component for %(llu)!", branch.target);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -30,13 +27,11 @@ void HealBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_strea
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void HealBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch)
|
void HealBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
Handle(context, bit_stream, branch);
|
Handle(context, bit_stream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void HealBehavior::Load()
|
void HealBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_health = GetInt("health");
|
this->m_health = GetInt("health");
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit HealBehavior(const uint32_t behavior_id) : Behavior(behavior_id)
|
explicit HealBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override;
|
||||||
|
@ -6,19 +6,16 @@
|
|||||||
#include "dLogger.h"
|
#include "dLogger.h"
|
||||||
|
|
||||||
|
|
||||||
void ImaginationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch)
|
void ImaginationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
if (entity == nullptr)
|
if (entity == nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* destroyable = entity->GetComponent<DestroyableComponent>();
|
auto* destroyable = entity->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
if (destroyable == nullptr)
|
if (destroyable == nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,12 +23,10 @@ void ImaginationBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImaginationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch)
|
void ImaginationBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
Handle(context, bit_stream, branch);
|
Handle(context, bit_stream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImaginationBehavior::Load()
|
void ImaginationBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_imagination = GetInt("imagination");
|
this->m_imagination = GetInt("imagination");
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit ImaginationBehavior(const uint32_t behavior_id) : Behavior(behavior_id)
|
explicit ImaginationBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override;
|
||||||
|
@ -7,12 +7,10 @@
|
|||||||
#include "dLogger.h"
|
#include "dLogger.h"
|
||||||
#include "DestroyableComponent.h"
|
#include "DestroyableComponent.h"
|
||||||
|
|
||||||
void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch)
|
void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
if (target == nullptr)
|
if (target == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target);
|
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", branch.target);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -20,13 +18,11 @@ void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt
|
|||||||
|
|
||||||
auto* destroyable = static_cast<DestroyableComponent*>(target->GetComponent(COMPONENT_TYPE_DESTROYABLE));
|
auto* destroyable = static_cast<DestroyableComponent*>(target->GetComponent(COMPONENT_TYPE_DESTROYABLE));
|
||||||
|
|
||||||
if (destroyable == nullptr)
|
if (destroyable == nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->m_immuneBasicAttack)
|
if (!this->m_immuneBasicAttack) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,17 +31,14 @@ void ImmunityBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt
|
|||||||
context->RegisterTimerBehavior(this, branch, target->GetObjectID());
|
context->RegisterTimerBehavior(this, branch, target->GetObjectID());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImmunityBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void ImmunityBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
Handle(context, bitStream, branch);
|
Handle(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImmunityBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, const LWOOBJID second)
|
void ImmunityBehavior::Timer(BehaviorContext* context, BehaviorBranchContext branch, const LWOOBJID second) {
|
||||||
{
|
|
||||||
auto* target = EntityManager::Instance()->GetEntity(second);
|
auto* target = EntityManager::Instance()->GetEntity(second);
|
||||||
|
|
||||||
if (target == nullptr)
|
if (target == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", second);
|
Game::logger->Log("DamageAbsorptionBehavior", "Failed to find target (%llu)!", second);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -53,15 +46,13 @@ void ImmunityBehavior::Timer(BehaviorContext* context, BehaviorBranchContext bra
|
|||||||
|
|
||||||
auto* destroyable = static_cast<DestroyableComponent*>(target->GetComponent(COMPONENT_TYPE_DESTROYABLE));
|
auto* destroyable = static_cast<DestroyableComponent*>(target->GetComponent(COMPONENT_TYPE_DESTROYABLE));
|
||||||
|
|
||||||
if (destroyable == nullptr)
|
if (destroyable == nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyable->PopImmunity();
|
destroyable->PopImmunity();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImmunityBehavior::Load()
|
void ImmunityBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_immuneBasicAttack = GetBoolean("immune_basic_attack");
|
this->m_immuneBasicAttack = GetBoolean("immune_basic_attack");
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit ImmunityBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit ImmunityBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -7,10 +7,8 @@
|
|||||||
#include "SkillComponent.h"
|
#include "SkillComponent.h"
|
||||||
|
|
||||||
|
|
||||||
void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
if (branch.target != context->originator) {
|
||||||
if (branch.target != context->originator)
|
|
||||||
{
|
|
||||||
bool unknown = false;
|
bool unknown = false;
|
||||||
|
|
||||||
bitStream->Read(unknown);
|
bitStream->Read(unknown);
|
||||||
@ -18,8 +16,7 @@ void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS
|
|||||||
if (unknown) return;
|
if (unknown) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->m_interruptBlock)
|
if (!this->m_interruptBlock) {
|
||||||
{
|
|
||||||
bool unknown = false;
|
bool unknown = false;
|
||||||
|
|
||||||
bitStream->Read(unknown);
|
bitStream->Read(unknown);
|
||||||
@ -48,15 +45,12 @@ void InterruptBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitS
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InterruptBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void InterruptBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
if (branch.target != context->originator) {
|
||||||
if (branch.target != context->originator)
|
|
||||||
{
|
|
||||||
bitStream->Write(false);
|
bitStream->Write(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this->m_interruptBlock)
|
if (!this->m_interruptBlock) {
|
||||||
{
|
|
||||||
bitStream->Write(false);
|
bitStream->Write(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,8 +70,7 @@ void InterruptBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* b
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InterruptBehavior::Load()
|
void InterruptBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_target = GetBoolean("target");
|
this->m_target = GetBoolean("target");
|
||||||
|
|
||||||
this->m_interruptBlock = GetBoolean("interrupt_block");
|
this->m_interruptBlock = GetBoolean("interrupt_block");
|
||||||
|
@ -12,8 +12,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit InterruptBehavior(const uint32_t behavior_id) : Behavior(behavior_id)
|
explicit InterruptBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -7,25 +7,21 @@
|
|||||||
#include "GameMessages.h"
|
#include "GameMessages.h"
|
||||||
#include "DestroyableComponent.h"
|
#include "DestroyableComponent.h"
|
||||||
|
|
||||||
void KnockbackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void KnockbackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
bool unknown;
|
bool unknown;
|
||||||
|
|
||||||
bitStream->Read(unknown);
|
bitStream->Read(unknown);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KnockbackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void KnockbackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
bool blocked = false;
|
bool blocked = false;
|
||||||
|
|
||||||
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
if (target != nullptr)
|
if (target != nullptr) {
|
||||||
{
|
|
||||||
auto* destroyableComponent = target->GetComponent<DestroyableComponent>();
|
auto* destroyableComponent = target->GetComponent<DestroyableComponent>();
|
||||||
|
|
||||||
if (destroyableComponent != nullptr)
|
if (destroyableComponent != nullptr) {
|
||||||
{
|
|
||||||
blocked = destroyableComponent->IsKnockbackImmune();
|
blocked = destroyableComponent->IsKnockbackImmune();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -33,8 +29,7 @@ void KnockbackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* b
|
|||||||
bitStream->Write(blocked);
|
bitStream->Write(blocked);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KnockbackBehavior::Load()
|
void KnockbackBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_strength = GetInt("strength");
|
this->m_strength = GetInt("strength");
|
||||||
this->m_angle = GetInt("angle");
|
this->m_angle = GetInt("angle");
|
||||||
this->m_relative = GetBoolean("relative");
|
this->m_relative = GetBoolean("relative");
|
||||||
|
@ -14,8 +14,7 @@ public:
|
|||||||
uint32_t m_time;
|
uint32_t m_time;
|
||||||
|
|
||||||
|
|
||||||
explicit KnockbackBehavior(const uint32_t behaviorID) : Behavior(behaviorID)
|
explicit KnockbackBehavior(const uint32_t behaviorID) : Behavior(behaviorID) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -3,15 +3,13 @@
|
|||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
#include "dLogger.h"
|
#include "dLogger.h"
|
||||||
|
|
||||||
void MovementSwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch)
|
void MovementSwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
if (this->m_groundAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
|
if (this->m_groundAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
|
||||||
this->m_jumpAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
|
this->m_jumpAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
|
||||||
this->m_fallingAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
|
this->m_fallingAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
|
||||||
this->m_doubleJumpAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
|
this->m_doubleJumpAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
|
||||||
this->m_airAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
|
this->m_airAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY &&
|
||||||
this->m_jetpackAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY)
|
this->m_jetpackAction->m_templateId == BehaviorTemplates::BEHAVIOR_EMPTY) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,8 +17,7 @@ void MovementSwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream*
|
|||||||
|
|
||||||
bitStream->Read(movementType);
|
bitStream->Read(movementType);
|
||||||
|
|
||||||
switch (movementType)
|
switch (movementType) {
|
||||||
{
|
|
||||||
case 1:
|
case 1:
|
||||||
this->m_groundAction->Handle(context, bitStream, branch);
|
this->m_groundAction->Handle(context, bitStream, branch);
|
||||||
break;
|
break;
|
||||||
@ -45,8 +42,7 @@ void MovementSwitchBehavior::Handle(BehaviorContext* context, RakNet::BitStream*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MovementSwitchBehavior::Load()
|
void MovementSwitchBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_airAction = GetAction("air_action");
|
this->m_airAction = GetAction("air_action");
|
||||||
|
|
||||||
this->m_doubleJumpAction = GetAction("double_jump_action");
|
this->m_doubleJumpAction = GetAction("double_jump_action");
|
||||||
|
@ -22,8 +22,7 @@ public:
|
|||||||
/*
|
/*
|
||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
explicit MovementSwitchBehavior(const uint32_t behavior_id) : Behavior(behavior_id)
|
explicit MovementSwitchBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -3,26 +3,21 @@
|
|||||||
#include "BehaviorContext.h"
|
#include "BehaviorContext.h"
|
||||||
|
|
||||||
|
|
||||||
void NpcCombatSkillBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch)
|
void NpcCombatSkillBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
context->skillTime = this->m_npcSkillTime;
|
context->skillTime = this->m_npcSkillTime;
|
||||||
|
|
||||||
for (auto* behavior : this->m_behaviors)
|
for (auto* behavior : this->m_behaviors) {
|
||||||
{
|
|
||||||
behavior->Calculate(context, bit_stream, branch);
|
behavior->Calculate(context, bit_stream, branch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NpcCombatSkillBehavior::Load()
|
void NpcCombatSkillBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_npcSkillTime = GetFloat("npc skill time");
|
this->m_npcSkillTime = GetFloat("npc skill time");
|
||||||
|
|
||||||
const auto parameters = GetParameterNames();
|
const auto parameters = GetParameterNames();
|
||||||
|
|
||||||
for (const auto& parameter : parameters)
|
for (const auto& parameter : parameters) {
|
||||||
{
|
if (parameter.first.rfind("behavior", 0) == 0) {
|
||||||
if (parameter.first.rfind("behavior", 0) == 0)
|
|
||||||
{
|
|
||||||
auto* action = GetAction(parameter.second);
|
auto* action = GetAction(parameter.second);
|
||||||
|
|
||||||
this->m_behaviors.push_back(action);
|
this->m_behaviors.push_back(action);
|
||||||
|
@ -12,8 +12,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit NpcCombatSkillBehavior(const uint32_t behavior_id) : Behavior(behavior_id)
|
explicit NpcCombatSkillBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override;
|
void Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override;
|
||||||
|
@ -7,16 +7,14 @@
|
|||||||
#include "SkillComponent.h"
|
#include "SkillComponent.h"
|
||||||
#include "DestroyableComponent.h"
|
#include "DestroyableComponent.h"
|
||||||
|
|
||||||
void OverTimeBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void OverTimeBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
const auto originator = context->originator;
|
const auto originator = context->originator;
|
||||||
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(originator);
|
auto* entity = EntityManager::Instance()->GetEntity(originator);
|
||||||
|
|
||||||
if (entity == nullptr) return;
|
if (entity == nullptr) return;
|
||||||
|
|
||||||
for (size_t i = 0; i < m_NumIntervals; i++)
|
for (size_t i = 0; i < m_NumIntervals; i++) {
|
||||||
{
|
|
||||||
entity->AddCallbackTimer((i + 1) * m_Delay, [originator, branch, this]() {
|
entity->AddCallbackTimer((i + 1) * m_Delay, [originator, branch, this]() {
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(originator);
|
auto* entity = EntityManager::Instance()->GetEntity(originator);
|
||||||
|
|
||||||
@ -31,13 +29,11 @@ void OverTimeBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitSt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverTimeBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void OverTimeBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OverTimeBehavior::Load()
|
void OverTimeBehavior::Load() {
|
||||||
{
|
|
||||||
m_Action = GetInt("action");
|
m_Action = GetInt("action");
|
||||||
// Since m_Action is a skillID and not a behavior, get is correlated behaviorID.
|
// Since m_Action is a skillID and not a behavior, get is correlated behaviorID.
|
||||||
|
|
||||||
|
@ -13,8 +13,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit OverTimeBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit OverTimeBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
#include "BehaviorContext.h"
|
#include "BehaviorContext.h"
|
||||||
#include "BehaviorBranchContext.h"
|
#include "BehaviorBranchContext.h"
|
||||||
|
|
||||||
void PlayEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void PlayEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
// On managed behaviors this is handled by the client
|
// On managed behaviors this is handled by the client
|
||||||
if (!context->unmanaged)
|
if (!context->unmanaged)
|
||||||
return;
|
return;
|
||||||
@ -14,13 +13,11 @@ void PlayEffectBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit
|
|||||||
PlayFx(u"", target);
|
PlayFx(u"", target);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void PlayEffectBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
const auto& target = branch.target == LWOOBJID_EMPTY ? context->originator : branch.target;
|
const auto& target = branch.target == LWOOBJID_EMPTY ? context->originator : branch.target;
|
||||||
|
|
||||||
//PlayFx(u"", target);
|
//PlayFx(u"", target);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayEffectBehavior::Load()
|
void PlayEffectBehavior::Load() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,7 @@ public:
|
|||||||
/*
|
/*
|
||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
explicit PlayEffectBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit PlayEffectBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -7,16 +7,14 @@
|
|||||||
#include "SkillComponent.h"
|
#include "SkillComponent.h"
|
||||||
#include "../dWorldServer/ObjectIDManager.h"
|
#include "../dWorldServer/ObjectIDManager.h"
|
||||||
|
|
||||||
void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
LWOOBJID target;
|
LWOOBJID target;
|
||||||
|
|
||||||
bitStream->Read(target);
|
bitStream->Read(target);
|
||||||
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(context->originator);
|
auto* entity = EntityManager::Instance()->GetEntity(context->originator);
|
||||||
|
|
||||||
if (entity == nullptr)
|
if (entity == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("ProjectileAttackBehavior", "Failed to find originator (%llu)!", context->originator);
|
Game::logger->Log("ProjectileAttackBehavior", "Failed to find originator (%llu)!", context->originator);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -24,23 +22,20 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea
|
|||||||
|
|
||||||
auto* skillComponent = entity->GetComponent<SkillComponent>();
|
auto* skillComponent = entity->GetComponent<SkillComponent>();
|
||||||
|
|
||||||
if (skillComponent == nullptr)
|
if (skillComponent == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("ProjectileAttackBehavior", "Failed to find skill component for (%llu)!", -context->originator);
|
Game::logger->Log("ProjectileAttackBehavior", "Failed to find skill component for (%llu)!", -context->originator);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_useMouseposit)
|
if (m_useMouseposit) {
|
||||||
{
|
|
||||||
NiPoint3 targetPosition = NiPoint3::ZERO;
|
NiPoint3 targetPosition = NiPoint3::ZERO;
|
||||||
bitStream->Read(targetPosition);
|
bitStream->Read(targetPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* targetEntity = EntityManager::Instance()->GetEntity(target);
|
auto* targetEntity = EntityManager::Instance()->GetEntity(target);
|
||||||
|
|
||||||
for (auto i = 0u; i < this->m_projectileCount; ++i)
|
for (auto i = 0u; i < this->m_projectileCount; ++i) {
|
||||||
{
|
|
||||||
LWOOBJID projectileId;
|
LWOOBJID projectileId;
|
||||||
|
|
||||||
bitStream->Read(projectileId);
|
bitStream->Read(projectileId);
|
||||||
@ -53,14 +48,12 @@ void ProjectileAttackBehavior::Handle(BehaviorContext* context, RakNet::BitStrea
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
bitStream->Write(branch.target);
|
bitStream->Write(branch.target);
|
||||||
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(context->originator);
|
auto* entity = EntityManager::Instance()->GetEntity(context->originator);
|
||||||
|
|
||||||
if (entity == nullptr)
|
if (entity == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("ProjectileAttackBehavior", "Failed to find originator (%llu)!", context->originator);
|
Game::logger->Log("ProjectileAttackBehavior", "Failed to find originator (%llu)!", context->originator);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -68,8 +61,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt
|
|||||||
|
|
||||||
auto* skillComponent = entity->GetComponent<SkillComponent>();
|
auto* skillComponent = entity->GetComponent<SkillComponent>();
|
||||||
|
|
||||||
if (skillComponent == nullptr)
|
if (skillComponent == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("ProjectileAttackBehavior", "Failed to find skill component for (%llu)!", context->originator);
|
Game::logger->Log("ProjectileAttackBehavior", "Failed to find skill component for (%llu)!", context->originator);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -78,8 +70,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt
|
|||||||
|
|
||||||
auto* other = EntityManager::Instance()->GetEntity(branch.target);
|
auto* other = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
if (other == nullptr)
|
if (other == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("ProjectileAttackBehavior", "Invalid projectile target (%llu)!", branch.target);
|
Game::logger->Log("ProjectileAttackBehavior", "Invalid projectile target (%llu)!", branch.target);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -104,8 +95,7 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt
|
|||||||
|
|
||||||
const auto maxTime = this->m_maxDistance / this->m_projectileSpeed;
|
const auto maxTime = this->m_maxDistance / this->m_projectileSpeed;
|
||||||
|
|
||||||
for (auto i = 0u; i < this->m_projectileCount; ++i)
|
for (auto i = 0u; i < this->m_projectileCount; ++i) {
|
||||||
{
|
|
||||||
auto id = static_cast<LWOOBJID>(ObjectIDManager::Instance()->GenerateObjectID());
|
auto id = static_cast<LWOOBJID>(ObjectIDManager::Instance()->GenerateObjectID());
|
||||||
|
|
||||||
id = GeneralUtils::SetBit(id, OBJECT_BIT_CLIENT);
|
id = GeneralUtils::SetBit(id, OBJECT_BIT_CLIENT);
|
||||||
@ -128,25 +118,20 @@ void ProjectileAttackBehavior::Calculate(BehaviorContext* context, RakNet::BitSt
|
|||||||
skillComponent->RegisterCalculatedProjectile(id, context, branch, this->m_lot, maxTime, position, direction * this->m_projectileSpeed, this->m_trackTarget, this->m_trackRadius);
|
skillComponent->RegisterCalculatedProjectile(id, context, branch, this->m_lot, maxTime, position, direction * this->m_projectileSpeed, this->m_trackTarget, this->m_trackRadius);
|
||||||
|
|
||||||
// No idea how to calculate this properly
|
// No idea how to calculate this properly
|
||||||
if (this->m_projectileCount == 2)
|
if (this->m_projectileCount == 2) {
|
||||||
{
|
|
||||||
angle += angleDelta;
|
angle += angleDelta;
|
||||||
}
|
} else if (this->m_projectileCount == 3) {
|
||||||
else if (this->m_projectileCount == 3)
|
|
||||||
{
|
|
||||||
angle += angleStep;
|
angle += angleStep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectileAttackBehavior::Load()
|
void ProjectileAttackBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_lot = GetInt("LOT_ID");
|
this->m_lot = GetInt("LOT_ID");
|
||||||
|
|
||||||
this->m_projectileCount = GetInt("spread_count");
|
this->m_projectileCount = GetInt("spread_count");
|
||||||
|
|
||||||
if (this->m_projectileCount == 0)
|
if (this->m_projectileCount == 0) {
|
||||||
{
|
|
||||||
this->m_projectileCount = 1;
|
this->m_projectileCount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,8 +27,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit ProjectileAttackBehavior(const uint32_t behavior_id) : Behavior(behavior_id)
|
explicit ProjectileAttackBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -5,21 +5,18 @@
|
|||||||
#include "EntityManager.h"
|
#include "EntityManager.h"
|
||||||
#include "MovementAIComponent.h"
|
#include "MovementAIComponent.h"
|
||||||
|
|
||||||
void PullToPointBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void PullToPointBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(context->originator);
|
auto* entity = EntityManager::Instance()->GetEntity(context->originator);
|
||||||
|
|
||||||
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
auto* target = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
if (entity == nullptr || target == nullptr)
|
if (entity == nullptr || target == nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* movement = target->GetComponent<MovementAIComponent>();
|
auto* movement = target->GetComponent<MovementAIComponent>();
|
||||||
|
|
||||||
if (movement == nullptr)
|
if (movement == nullptr) {
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,11 +25,9 @@ void PullToPointBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bi
|
|||||||
movement->PullToPoint(position);
|
movement->PullToPoint(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PullToPointBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void PullToPointBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
Handle(context, bitStream, branch);
|
Handle(context, bitStream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PullToPointBehavior::Load()
|
void PullToPointBehavior::Load() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit PullToPointBehavior(const uint32_t behaviorId) : Behavior(behaviorId)
|
explicit PullToPointBehavior(const uint32_t behaviorId) : Behavior(behaviorId) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) override;
|
||||||
|
@ -6,12 +6,10 @@
|
|||||||
#include "dLogger.h"
|
#include "dLogger.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
|
||||||
void RepairBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch)
|
void RepairBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
auto* entity = EntityManager::Instance()->GetEntity(branch.target);
|
||||||
|
|
||||||
if (entity == nullptr)
|
if (entity == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("RepairBehavior", "Failed to find entity for (%llu)!", branch.target);
|
Game::logger->Log("RepairBehavior", "Failed to find entity for (%llu)!", branch.target);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -19,8 +17,7 @@ void RepairBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_str
|
|||||||
|
|
||||||
auto* destroyable = static_cast<DestroyableComponent*>(entity->GetComponent(COMPONENT_TYPE_DESTROYABLE));
|
auto* destroyable = static_cast<DestroyableComponent*>(entity->GetComponent(COMPONENT_TYPE_DESTROYABLE));
|
||||||
|
|
||||||
if (destroyable == nullptr)
|
if (destroyable == nullptr) {
|
||||||
{
|
|
||||||
Game::logger->Log("RepairBehavior", "Failed to find destroyable component for %(llu)!", branch.target);
|
Game::logger->Log("RepairBehavior", "Failed to find destroyable component for %(llu)!", branch.target);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@ -29,12 +26,10 @@ void RepairBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bit_str
|
|||||||
destroyable->Repair(this->m_armor);
|
destroyable->Repair(this->m_armor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepairBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch)
|
void RepairBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bit_stream, const BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
Handle(context, bit_stream, branch);
|
Handle(context, bit_stream, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepairBehavior::Load()
|
void RepairBehavior::Load() {
|
||||||
{
|
|
||||||
this->m_armor = GetInt("armor");
|
this->m_armor = GetInt("armor");
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,7 @@ public:
|
|||||||
* Inherited
|
* Inherited
|
||||||
*/
|
*/
|
||||||
|
|
||||||
explicit RepairBehavior(const uint32_t behavior_id) : Behavior(behavior_id)
|
explicit RepairBehavior(const uint32_t behavior_id) : Behavior(behavior_id) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override;
|
void Handle(BehaviorContext* context, RakNet::BitStream* bit_stream, BehaviorBranchContext branch) override;
|
||||||
|
@ -3,16 +3,13 @@
|
|||||||
#include "BehaviorContext.h"
|
#include "BehaviorContext.h"
|
||||||
#include "BehaviorBranchContext.h"
|
#include "BehaviorBranchContext.h"
|
||||||
|
|
||||||
void SkillCastFailedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void SkillCastFailedBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
context->failed = true;
|
context->failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkillCastFailedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch)
|
void SkillCastFailedBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitStream, BehaviorBranchContext branch) {
|
||||||
{
|
|
||||||
context->failed = true;
|
context->failed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkillCastFailedBehavior::Load()
|
void SkillCastFailedBehavior::Load() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user